diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 94522f5a..08acf95a 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,3 +1,10 @@ +Drupal 7.19, 2013-01-16 +----------------------- +- Fixed security issues (multiple vulnerabilities). See SA-CORE-2013-001. + +Drupal 7.18, 2012-12-19 +----------------------- +- Fixed security issues (multiple vulnerabilities). See SA-CORE-2012-004. Drupal 7.17, 2012-11-07 ----------------------- diff --git a/INSTALL.mysql.txt b/INSTALL.mysql.txt new file mode 100644 index 00000000..bee58110 --- /dev/null +++ b/INSTALL.mysql.txt @@ -0,0 +1,42 @@ + +CREATE THE MySQL DATABASE +-------------------------- + +This step is only necessary if you don't already have a database set up (e.g., +by your host). In the following examples, 'username' is an example MySQL user +which has the CREATE and GRANT privileges. Use the appropriate user name for +your system. + +First, you must create a new database for your Drupal site (here, 'databasename' +is the name of the new database): + + mysqladmin -u username -p create databasename + +MySQL will prompt for the 'username' database password and then create the +initial database files. Next you must log in and set the access database rights: + + mysql -u username -p + +Again, you will be asked for the 'username' database password. At the MySQL +prompt, enter the following command: + + GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER + ON databasename.* + TO 'username'@'localhost' IDENTIFIED BY 'password'; + +where + + 'databasename' is the name of your database + 'username@localhost' is the username of your MySQL account + 'password' is the password required for that username + +Note: Unless your database user has all of the privileges listed above, you will +not be able to run Drupal. + +If successful, MySQL will reply with: + + Query OK, 0 rows affected + +If the InnoDB storage engine is available, it will be used for all database +tables. InnoDB provides features over MyISAM such as transaction support, +row-level locks, and consistent non-locking reads. diff --git a/INSTALL.pgsql.txt b/INSTALL.pgsql.txt new file mode 100644 index 00000000..8fe80433 --- /dev/null +++ b/INSTALL.pgsql.txt @@ -0,0 +1,44 @@ + +CREATE THE PostgreSQL DATABASE +------------------------------ + +Note that the database must be created with UTF-8 (Unicode) encoding. + +1. CREATE DATABASE USER + + This step is only necessary if you don't already have a user set up (e.g., by + your host), or want to create a new user for use with Drupal only. The + following command creates a new user named 'username' and asks for a password + for that user: + + createuser --pwprompt --encrypted --no-createrole --no-createdb username + + If there are no errors, then the command was successful. + +2. CREATE DRUPAL DATABASE + + This step is only necessary if you don't already have a database set up + (e.g., by your host) or want to create a new database for use with Drupal + only. The following command creates a new database named 'databasename', + which is owned by the previously created 'username': + + createdb --encoding=UTF8 --owner=username databasename + + If there are no errors, then the command was successful. + +3. CREATE SCHEMA OR SCHEMAS (Optional advanced step) + + Drupal will run across different schemas within your database if you so wish. + By default, Drupal runs inside the 'public' schema but you can use $db_prefix + inside settings.php to define a schema for Drupal to run inside of, or + specify tables that are shared inside of a separate schema. Drupal will not + create schemas for you. In fact, the user that Drupal runs as should not be + allowed to do this. You'll need to execute the SQL below as a superuser, + replace 'username' with the username that Drupal uses to connect to + PostgreSQL, and replace 'schema_name' with a schema name you wish to use, + such as 'shared': + + CREATE SCHEMA schema_name AUTHORIZATION username; + + Do this for as many schemas as you need. See default.settings.php for + instructions on how to set which tables use which schemas. diff --git a/INSTALL.sqlite.txt b/INSTALL.sqlite.txt new file mode 100644 index 00000000..8e57d60c --- /dev/null +++ b/INSTALL.sqlite.txt @@ -0,0 +1,31 @@ + +SQLITE REQUIREMENTS +------------------- + +To use SQLite with your Drupal installation, the following requirements must be +met: Server has PHP 5.2 or later with PDO, and the PDO SQLite driver must be +enabled. + +SQLITE DATABASE CREATION +------------------------ + +The Drupal installer will create the SQLite database for you. The only +requirement is that the installer must have write permissions to the directory +where the database file resides. This directory (not just the database file) also +has to remain writeable by the web server going forward for SQLite to continue to +be able to operate. + +On the "Database configuration" form in the "Database file" field, you must +supply the exact path to where you wish your database file to reside. It is +strongly suggested that you choose a path that is outside of the webroot, yet +ensure that the directory is writeable by the web server. + +If you must place your database file in your webroot, you could try using the +following in your "Database file" field: + + sites/default/files/.ht.sqlite + +Note: The .ht in the name will tell Apache to prevent the database from being +downloaded. Please check that the file is, indeed, protected by your webserver. +If not, please consult the documentation of your webserver on how to protect a +file from downloading. diff --git a/INSTALL.txt b/INSTALL.txt new file mode 100644 index 00000000..c3a26adf --- /dev/null +++ b/INSTALL.txt @@ -0,0 +1,398 @@ + +CONTENTS OF THIS FILE +--------------------- + + * Requirements and notes + * Optional server requirements + * Installation + * Building and customizing your site + * Multisite configuration + * More information + +REQUIREMENTS AND NOTES +---------------------- + +Drupal requires: + +- A web server. Apache (version 2.0 or greater) is recommended. +- PHP 5.2.4 (or greater) (http://www.php.net/). +- One of the following databases: + - MySQL 5.0.15 (or greater) (http://www.mysql.com/). + - MariaDB 5.1.44 (or greater) (http://mariadb.org/). MariaDB is a fully + compatible drop-in replacement for MySQL. + - PostgreSQL 8.3 (or greater) (http://www.postgresql.org/). + - SQLite 3.4.2 (or greater) (http://www.sqlite.org/). + +For more detailed information about Drupal requirements, including a list of +PHP extensions and configurations that are required, see "System requirements" +(http://drupal.org/requirements) in the Drupal.org online documentation. + +For detailed information on how to configure a test server environment using a +variety of operating systems and web servers, see "Local server setup" +(http://drupal.org/node/157602) in the Drupal.org online documentation. + +Note that all directories mentioned in this document are always relative to the +directory of your Drupal installation, and commands are meant to be run from +this directory (except for the initial commands that create that directory). + +OPTIONAL SERVER REQUIREMENTS +---------------------------- + +- If you want to use Drupal's "Clean URLs" feature on an Apache web server, you + will need the mod_rewrite module and the ability to use local .htaccess + files. For Clean URLs support on IIS, see "Clean URLs with IIS" + (http://drupal.org/node/3854) in the Drupal.org online documentation. + +- If you plan to use XML-based services such as RSS aggregation, you will need + PHP's XML extension. This extension is enabled by default on most PHP + installations. + +- To serve gzip compressed CSS and JS files on an Apache web server, you will + need the mod_headers module and the ability to use local .htaccess files. + +- Some Drupal functionality (e.g., checking whether Drupal and contributed + modules need updates, RSS aggregation, etc.) require that the web server be + able to go out to the web and download information. If you want to use this + functionality, you need to verify that your hosting provider or server + configuration allows the web server to initiate outbound connections. Most web + hosting setups allow this. + +INSTALLATION +------------ + +1. Download and extract Drupal. + + You can obtain the latest Drupal release from http://drupal.org -- the files + are available in .tar.gz and .zip formats and can be extracted using most + compression tools. + + To download and extract the files, on a typical Unix/Linux command line, use + the following commands (assuming you want version x.y of Drupal in .tar.gz + format): + + wget http://drupal.org/files/projects/drupal-x.y.tar.gz + tar -zxvf drupal-x.y.tar.gz + + This will create a new directory drupal-x.y/ containing all Drupal files and + directories. Then, to move the contents of that directory into a directory + within your web server's document root or your public HTML directory, + continue with this command: + + mv drupal-x.y/* drupal-x.y/.htaccess /path/to/your/installation + +2. Optionally, download a translation. + + By default, Drupal is installed in English, and further languages may be + installed later. If you prefer to install Drupal in another language + initially: + + - Download a translation file for the correct Drupal version and language + from the translation server: http://localize.drupal.org/translate/downloads + + - Place the file into your installation profile's translations directory. + For instance, if you are using the Standard installation profile, + move the .po file into the directory: + + profiles/standard/translations/ + + For detailed instructions, visit http://drupal.org/localize + +3. Create the Drupal database. + + Because Drupal stores all site information in a database, you must create + this database in order to install Drupal, and grant Drupal certain database + privileges (such as the ability to create tables). For details, consult + INSTALL.mysql.txt, INSTALL.pgsql.txt, or INSTALL.sqlite.txt. You may also + need to consult your web hosting provider for instructions specific to your + web host. + + Take note of the username, password, database name, and hostname as you + create the database. You will enter this information during the install. + +4. Run the install script. + + To run the install script, point your browser to the base URL of your + website (e.g., http://www.example.com). + + You will be guided through several screens to set up the database, add the + site maintenance account (the first user, also known as user/1), and provide + basic web site settings. + + During installation, several files and directories need to be created, which + the install script will try to do automatically. However, on some hosting + environments, manual steps are required, and the install script will tell + you that it cannot proceed until you fix certain issues. This is normal and + does not indicate a problem with your server. + + The most common steps you may need to perform are: + + a. Missing files directory. + + The install script will attempt to create a file storage directory in + the default location at sites/default/files (the location of the files + directory may be changed after Drupal is installed). + + If auto-creation fails, you can make it work by changing permissions on + the sites/default directory so that the web server can create the files + directory within it for you. (If you are creating a multisite + installation, substitute the correct sites directory for sites/default; + see the Multisite Configuration section of this file, below.) + + For example, on a Unix/Linux command line, you can grant everyone + (including the web server) permission to write to the sites/default + directory with this command: + + chmod a+w sites/default + + Be sure to set the permissions back after the installation is finished! + Sample command: + + chmod go-w sites/default + + Alternatively, instead of allowing the web server to create the files + directory for you as described above, you can create it yourself. Sample + commands from a Unix/Linux command line: + + mkdir sites/default/files + chmod a+w sites/default/files + + b. Missing settings file. + + Drupal will try to automatically create a settings.php configuration file, + which is normally in the directory sites/default (to avoid problems when + upgrading, Drupal is not packaged with this file). If auto-creation fails, + you will need to create this file yourself, using the file + sites/default/default.settings.php as a template. + + For example, on a Unix/Linux command line, you can make a copy of the + default.settings.php file with the command: + + cp sites/default/default.settings.php sites/default/settings.php + + Next, grant write privileges to the file to everyone (including the web + server) with the command: + + chmod a+w sites/default/settings.php + + Be sure to set the permissions back after the installation is finished! + Sample command: + + chmod go-w sites/default/settings.php + + c. Write permissions after install. + + The install script will attempt to write-protect the settings.php file and + the sites/default directory after saving your configuration. If this + fails, you will be notified, and you can do it manually. Sample commands + from a Unix/Linux command line: + + chmod go-w sites/default/settings.php + chmod go-w sites/default + +5. Verify that the site is working. + + When the install script finishes, you will be logged in with the site + maintenance account on a "Welcome" page. If the default Drupal theme is not + displaying properly and links on the page result in "Page Not Found" errors, + you may be experiencing problems with clean URLs. Visit + http://drupal.org/getting-started/clean-urls to troubleshoot. + +6. Change file system storage settings (optional). + + The files directory created in step 4 is the default file system path used to + store all uploaded files, as well as some temporary files created by + Drupal. After installation, you can modify the file system path to store + uploaded files in a different location. + + It is not necessary to modify this path, but you may wish to change it if: + + - Your site runs multiple Drupal installations from a single codebase (modify + the file system path of each installation to a different directory so that + uploads do not overlap between installations). + + - Your site runs on a number of web servers behind a load balancer or reverse + proxy (modify the file system path on each server to point to a shared file + repository). + + - You want to restrict access to uploaded files. + + To modify the file system path: + + a. Ensure that the new location for the path exists and is writable by the + web server. For example, to create a new directory named uploads and grant + write permissions, use the following commands on a Unix/Linux command + line: + + mkdir uploads + chmod a+w uploads + + b. Navigate to Administration > Configuration > Media > File system, and + enter the desired path. Note that if you want to use private file storage, + you need to first enter the path for private files and save the + configuration, and then change the "Default download method" setting and + save again. + + Changing the file system path after files have been uploaded may cause + unexpected problems on an existing site. If you modify the file system path + on an existing site, remember to copy all files from the original location + to the new location. + +7. Revoke documentation file permissions (optional). + + Some administrators suggest making the documentation files, especially + CHANGELOG.txt, non-readable so that the exact version of Drupal you are + running is slightly more difficult to determine. If you wish to implement + this optional security measure, from a Unix/Linux command line you can use + the following command: + + chmod a-r CHANGELOG.txt + + Note that the example only affects CHANGELOG.txt. To completely hide all + documentation files from public view, repeat this command for each of the + Drupal documentation files in the installation directory, substituting the + name of each file for CHANGELOG.txt in the example. + + For more information on setting file permissions, see "Modifying Linux, + Unix, and Mac file permissions" (http://drupal.org/node/202483) or + "Modifying Windows file permissions" (http://drupal.org/node/202491) in the + Drupal.org online documentation. + +8. Set up independent "cron" maintenance jobs. + + Many Drupal modules have tasks that must be run periodically, including the + Search module (building and updating the index used for keyword searching), + the Aggregator module (retrieving feeds from other sites), and the System + module (performing routine maintenance and pruning of database tables). These + tasks are known as "cron maintenance tasks", named after the Unix/Linux + "cron" utility. + + When you install Drupal, its built-in cron feature is enabled, which + automatically runs the cron tasks periodically, triggered by people visiting + pages of your site. You can configure the built-in cron feature by navigating + to Administration > Configuration > System > Cron. + + It is also possible to run the cron tasks independent of site visits; this is + recommended for most sites. To do this, you will need to set up an automated + process to visit the page cron.php on your site, which executes the cron + tasks. + + The URL of the cron.php page requires a "cron key" to protect against + unauthorized access. Your site's cron key is automatically generated during + installation and is specific to your site. The full URL of the page, with the + cron key, is available in the "Cron maintenance tasks" section of the Status + report page at Administration > Reports > Status report. + + As an example for how to set up this automated process, you can use the + crontab utility on Unix/Linux systems. The following crontab line uses the + wget command to visit the cron.php page, and runs each hour, on the hour: + + 0 * * * * wget -O - -q -t 1 http://example.com/cron.php?cron_key=YOURKEY + + Replace the text "http://example.com/cron.php?cron_key=YOURKEY" in the + example with the full URL displayed under "Cron maintenance tasks" on the + "Status report" page. + + More information about cron maintenance tasks is available at + http://drupal.org/cron, and sample cron shell scripts can be found in the + scripts/ directory. (Note that these scripts must be customized like the + above example, to add your site-specific cron key and domain name.) + +BUILDING AND CUSTOMIZING YOUR SITE +---------------------------------- + +A new installation of Drupal defaults to a very basic configuration. To extend +your site, you use "modules" and "themes". A module is a plugin that adds +functionality to Drupal, while a theme changes the look of your site. The core +of Drupal provides several optional modules and themes, and you can download +more at http://drupal.org/project/modules and http://drupal.org/project/themes + +Do not mix downloaded or custom modules and themes with Drupal's core modules +and themes. Drupal's modules and themes are located in the top-level modules and +themes directories, while the modules and themes you add to Drupal are normally +placed in the sites/all/modules and sites/all/themes directories. If you run a +multisite installation, you can also place modules and themes in the +site-specific directories -- see the Multisite Configuration section, below. + +Never edit Drupal's core modules and themes; instead, use the hooks available in +the Drupal API. To modify the behavior of Drupal, develop a module as described +at http://drupal.org/developing/modules. To modify the look of Drupal, create a +subtheme as described at http://drupal.org/node/225125, or a completely new +theme as described at http://drupal.org/documentation/theme + +MULTISITE CONFIGURATION +----------------------- + +A single Drupal installation can host several Drupal-powered sites, each with +its own individual configuration. + +Additional site configurations are created in subdirectories within the 'sites' +directory. Each subdirectory must have a 'settings.php' file, which specifies +the configuration settings. The easiest way to create additional sites is to +copy the 'default' directory and modify the 'settings.php' file as appropriate. +The new directory name is constructed from the site's URL. The configuration for +www.example.com could be in 'sites/example.com/settings.php' (note that 'www.' +should be omitted if users can access your site at http://example.com/). + +Sites do not have to have a different domain. You can also use subdomains and +subdirectories for Drupal sites. For example, example.com, sub.example.com, and +sub.example.com/site3 can all be defined as independent Drupal sites. The setup +for a configuration such as this would look like the following: + + sites/default/settings.php + sites/example.com/settings.php + sites/sub.example.com/settings.php + sites/sub.example.com.site3/settings.php + +When searching for a site configuration (for example www.sub.example.com/site3), +Drupal will search for configuration files in the following order, using the +first configuration it finds: + + sites/www.sub.example.com.site3/settings.php + sites/sub.example.com.site3/settings.php + sites/example.com.site3/settings.php + sites/www.sub.example.com/settings.php + sites/sub.example.com/settings.php + sites/example.com/settings.php + sites/default/settings.php + +If you are installing on a non-standard port, the port number is treated as the +deepest subdomain. For example: http://www.example.com:8080/ could be loaded +from sites/8080.www.example.com/. The port number will be removed according to +the pattern above if no port-specific configuration is found, just like a real +subdomain. + +Each site configuration can have its own site-specific modules and themes in +addition to those installed in the standard 'modules' and 'themes' directories. +To use site-specific modules or themes, simply create a 'modules' or 'themes' +directory within the site configuration directory. For example, if +sub.example.com has a custom theme and a custom module that should not be +accessible to other sites, the setup would look like this: + + sites/sub.example.com/ + settings.php + themes/custom_theme + modules/custom_module + +NOTE: for more information about multiple virtual hosts or the configuration +settings, consult http://drupal.org/getting-started/6/install/multi-site + +For more information on configuring Drupal's file system path in a multisite +configuration, see step 6 above. + +MORE INFORMATION +---------------- + +- See the Drupal.org online documentation: + http://drupal.org/documentation + +- For a list of security announcements, see the "Security advisories" page at + http://drupal.org/security (available as an RSS feed). This page also + describes how to subscribe to these announcements via e-mail. + +- For information about the Drupal security process, or to find out how to + report a potential security issue to the Drupal security team, see the + "Security team" page at http://drupal.org/security-team + +- For information about the wide range of available support options, visit + http://drupal.org and click on Community and Support in the top or bottom + navigation. diff --git a/icon.png b/icon.png new file mode 100644 index 00000000..bf9d7ba7 Binary files /dev/null and b/icon.png differ diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc index c9b17fe2..53f70e1a 100644 --- a/includes/bootstrap.inc +++ b/includes/bootstrap.inc @@ -8,7 +8,7 @@ /** * The current system version. */ -define('VERSION', '7.17'); +define('VERSION', '7.19'); /** * Core API compatibility. diff --git a/includes/entity.inc b/includes/entity.inc index 4f0c6c1d..2fefd590 100644 --- a/includes/entity.inc +++ b/includes/entity.inc @@ -160,18 +160,6 @@ class DrupalDefaultEntityController implements DrupalEntityControllerInterface { public function load($ids = array(), $conditions = array()) { $entities = array(); - # PATCH http://drupal.org/node/1003788#comment-5195682 - // Clean the $ids array to remove non-integer values that can be passed - // in from various sources, including menu callbacks. - if (is_array($ids)) { - foreach ($ids as $key => $id) { - if (empty($id) || ((string) $id !== (string) (int) $id)) { - unset($ids[$key]); - } - } - } - # endpatch - // Revisions are not statically cached, and require a different query to // other conditions, so separate the revision id into its own variable. if ($this->revisionKey && isset($conditions[$this->revisionKey])) { diff --git a/includes/file.inc b/includes/file.inc index 1e256c63..278be3dd 100644 --- a/includes/file.inc +++ b/includes/file.inc @@ -1113,6 +1113,9 @@ function file_munge_filename($filename, $extensions, $alerts = TRUE) { // Allow potentially insecure uploads for very savvy users and admin if (!variable_get('allow_insecure_uploads', 0)) { + // Remove any null bytes. See http://php.net/manual/en/security.filesystem.nullbytes.php + $filename = str_replace(chr(0), '', $filename); + $whitelist = array_unique(explode(' ', trim($extensions))); // Split the filename up by periods. The first part becomes the basename diff --git a/misc/autocomplete.js b/misc/autocomplete.js index 56790817..8f7ac601 100644 --- a/misc/autocomplete.js +++ b/misc/autocomplete.js @@ -114,7 +114,6 @@ Drupal.jsAC.prototype.onkeyup = function (input, e) { */ Drupal.jsAC.prototype.select = function (node) { this.input.value = $(node).data('autocompleteValue'); - $(this.input).trigger('autocompleteSelect', [node]); }; /** @@ -168,7 +167,7 @@ Drupal.jsAC.prototype.unhighlight = function (node) { Drupal.jsAC.prototype.hidePopup = function (keycode) { // Select item if the right key or mousebutton was pressed. if (this.selected && ((keycode && keycode != 46 && keycode != 8 && keycode != 27) || !keycode)) { - this.select(this.selected); + this.input.value = $(this.selected).data('autocompleteValue'); } // Hide popup. var popup = this.popup; @@ -221,7 +220,7 @@ Drupal.jsAC.prototype.found = function (matches) { for (key in matches) { $('
') .html($('').html(matches[key])) - .mousedown(function () { ac.hidePopup(this); }) + .mousedown(function () { ac.select(this); }) .mouseover(function () { ac.highlight(this); }) .mouseout(function () { ac.unhighlight(this); }) .data('autocompleteValue', key) diff --git a/misc/collapse.js b/misc/collapse.js index bd51ce53..512ff2f9 100644 --- a/misc/collapse.js +++ b/misc/collapse.js @@ -58,9 +58,9 @@ Drupal.behaviors.collapse = { $('fieldset.collapsible', context).once('collapse', function () { var $fieldset = $(this); // Expand fieldset if there are errors inside, or if it contains an - // element that is targeted by the URI fragment identifier. + // element that is targeted by the URI fragment identifier. var anchor = location.hash && location.hash != '#' ? ', ' + location.hash : ''; - if ($('.error' + anchor, $fieldset).length) { + if ($fieldset.find('.error' + anchor).length) { $fieldset.removeClass('collapsed'); } diff --git a/misc/drupal.js b/misc/drupal.js index 83b08842..643baa1b 100644 --- a/misc/drupal.js +++ b/misc/drupal.js @@ -6,6 +6,27 @@ jQuery.noConflict(); (function ($) { +/** + * Override jQuery.fn.init to guard against XSS attacks. + * + * See http://bugs.jquery.com/ticket/9521 + */ +var jquery_init = $.fn.init; +$.fn.init = function (selector, context, rootjQuery) { + // If the string contains a "#" before a "<", treat it as invalid HTML. + if (selector && typeof selector === 'string') { + var hash_position = selector.indexOf('#'); + if (hash_position >= 0) { + var bracket_position = selector.indexOf('<'); + if (bracket_position > hash_position) { + throw 'Syntax error, unrecognized expression: ' + selector; + } + } + } + return jquery_init.call(this, selector, context, rootjQuery); +}; +$.fn.init.prototype = jquery_init.prototype; + /** * Attach all registered behaviors to a page element. * diff --git a/misc/vertical-tabs.js b/misc/vertical-tabs.js index 14d06607..ebfaa4f7 100644 --- a/misc/vertical-tabs.js +++ b/misc/vertical-tabs.js @@ -50,8 +50,8 @@ Drupal.behaviors.verticalTabs = { if (!tab_focus) { // If the current URL has a fragment and one of the tabs contains an // element that matches the URL fragment, activate that tab. - if (window.location.hash && $(window.location.hash, this).length) { - tab_focus = $(window.location.hash, this).closest('.vertical-tabs-pane'); + if (window.location.hash && $(this).find(window.location.hash).length) { + tab_focus = $(this).find(window.location.hash).closest('.vertical-tabs-pane'); } else { tab_focus = $('> .vertical-tabs-pane:first', this); diff --git a/modules/aggregator/aggregator.info b/modules/aggregator/aggregator.info index 2f1d0535..252b1949 100644 --- a/modules/aggregator/aggregator.info +++ b/modules/aggregator/aggregator.info @@ -7,8 +7,8 @@ files[] = aggregator.test configure = admin/config/services/aggregator/settings stylesheets[all][] = aggregator.css -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/aggregator/tests/aggregator_test.info b/modules/aggregator/tests/aggregator_test.info index 204d2edf..8debb68d 100644 --- a/modules/aggregator/tests/aggregator_test.info +++ b/modules/aggregator/tests/aggregator_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/block/block.info b/modules/block/block.info index cd9bf089..9b19636b 100644 --- a/modules/block/block.info +++ b/modules/block/block.info @@ -6,8 +6,8 @@ core = 7.x files[] = block.test configure = admin/structure/block -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/block/tests/block_test.info b/modules/block/tests/block_test.info index 07751520..589df56e 100644 --- a/modules/block/tests/block_test.info +++ b/modules/block/tests/block_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/block/tests/themes/block_test_theme/block_test_theme.info b/modules/block/tests/themes/block_test_theme/block_test_theme.info index 4b585c5c..ca7b9c1c 100644 --- a/modules/block/tests/themes/block_test_theme/block_test_theme.info +++ b/modules/block/tests/themes/block_test_theme/block_test_theme.info @@ -13,8 +13,8 @@ regions[footer] = Footer regions[highlighted] = Highlighted regions[help] = Help -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/blog/blog.info b/modules/blog/blog.info index bdfc3c03..e015c8d0 100644 --- a/modules/blog/blog.info +++ b/modules/blog/blog.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x files[] = blog.test -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/book/book.info b/modules/book/book.info index d3e42dd4..b7ef56ea 100644 --- a/modules/book/book.info +++ b/modules/book/book.info @@ -7,8 +7,8 @@ files[] = book.test configure = admin/content/book/settings stylesheets[all][] = book.css -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/book/book.pages.inc b/modules/book/book.pages.inc index 583eb7a8..63a1d15a 100644 --- a/modules/book/book.pages.inc +++ b/modules/book/book.pages.inc @@ -38,6 +38,15 @@ function book_render() { * format determined by the $type parameter. */ function book_export($type, $nid) { + // Check that the node exists and that the current user has access to it. + $node = node_load($nid); + if (!$node) { + return MENU_NOT_FOUND; + } + if (!node_access('view', $node)) { + return MENU_ACCESS_DENIED; + } + $type = drupal_strtolower($type); $export_function = 'book_export_' . $type; diff --git a/modules/book/book.test b/modules/book/book.test index d1f52738..2708e367 100644 --- a/modules/book/book.test +++ b/modules/book/book.test @@ -258,6 +258,13 @@ class BookTestCase extends DrupalWebTestCase { // Try getting the URL directly, and verify it fails. $this->drupalGet('book/export/html/' . $this->book->nid); $this->assertResponse('403', t('Anonymous user properly forbidden.')); + + // Now grant anonymous users permission to view the printer-friendly + // version and verify that node access restrictions still prevent them from + // seeing it. + user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access printer-friendly version')); + $this->drupalGet('book/export/html/' . $this->book->nid); + $this->assertResponse('403', 'Anonymous user properly forbidden from seeing the printer-friendly version when denied by node access.'); } /** diff --git a/modules/color/color.info b/modules/color/color.info index a12fcdd5..e6fa50b8 100644 --- a/modules/color/color.info +++ b/modules/color/color.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x files[] = color.test -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/comment/comment.info b/modules/comment/comment.info index c42f7afb..b17a4d58 100644 --- a/modules/comment/comment.info +++ b/modules/comment/comment.info @@ -9,8 +9,8 @@ files[] = comment.test configure = admin/content/comment stylesheets[all][] = comment.css -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/contact/contact.info b/modules/contact/contact.info index 42c36999..4d5775c8 100644 --- a/modules/contact/contact.info +++ b/modules/contact/contact.info @@ -6,8 +6,8 @@ core = 7.x files[] = contact.test configure = admin/structure/contact -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/contextual/contextual.info b/modules/contextual/contextual.info index b8819446..271d95b5 100644 --- a/modules/contextual/contextual.info +++ b/modules/contextual/contextual.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x files[] = contextual.test -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/dashboard/dashboard.info b/modules/dashboard/dashboard.info index 30091ddc..822e13d8 100644 --- a/modules/dashboard/dashboard.info +++ b/modules/dashboard/dashboard.info @@ -7,8 +7,8 @@ files[] = dashboard.test dependencies[] = block configure = admin/dashboard/customize -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/dblog/dblog.info b/modules/dblog/dblog.info index 3935ee9a..ea05c6f5 100644 --- a/modules/dblog/dblog.info +++ b/modules/dblog/dblog.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x files[] = dblog.test -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/field/field.info b/modules/field/field.info index 88d4088b..cf00c2d3 100644 --- a/modules/field/field.info +++ b/modules/field/field.info @@ -10,8 +10,8 @@ dependencies[] = field_sql_storage required = TRUE stylesheets[all][] = theme/field.css -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/field/modules/field_sql_storage/field_sql_storage.info b/modules/field/modules/field_sql_storage/field_sql_storage.info index d7d5e8e5..702ed408 100644 --- a/modules/field/modules/field_sql_storage/field_sql_storage.info +++ b/modules/field/modules/field_sql_storage/field_sql_storage.info @@ -7,8 +7,8 @@ dependencies[] = field files[] = field_sql_storage.test required = TRUE -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/field/modules/list/list.info b/modules/field/modules/list/list.info index 515b3109..a8d83d86 100644 --- a/modules/field/modules/list/list.info +++ b/modules/field/modules/list/list.info @@ -7,8 +7,8 @@ dependencies[] = field dependencies[] = options files[] = tests/list.test -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/field/modules/list/tests/list_test.info b/modules/field/modules/list/tests/list_test.info index 107e3f98..e0fecc9a 100644 --- a/modules/field/modules/list/tests/list_test.info +++ b/modules/field/modules/list/tests/list_test.info @@ -5,8 +5,8 @@ package = Testing version = VERSION hidden = TRUE -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/field/modules/number/number.info b/modules/field/modules/number/number.info index 478f2301..9770d991 100644 --- a/modules/field/modules/number/number.info +++ b/modules/field/modules/number/number.info @@ -6,8 +6,8 @@ core = 7.x dependencies[] = field files[] = number.test -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/field/modules/options/options.info b/modules/field/modules/options/options.info index abe3ac44..b9380452 100644 --- a/modules/field/modules/options/options.info +++ b/modules/field/modules/options/options.info @@ -6,8 +6,8 @@ core = 7.x dependencies[] = field files[] = options.test -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/field/modules/text/text.info b/modules/field/modules/text/text.info index 811d6417..9968c853 100644 --- a/modules/field/modules/text/text.info +++ b/modules/field/modules/text/text.info @@ -7,8 +7,8 @@ dependencies[] = field files[] = text.test required = TRUE -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/field/tests/field_test.info b/modules/field/tests/field_test.info index 2b767392..0e37017b 100644 --- a/modules/field/tests/field_test.info +++ b/modules/field/tests/field_test.info @@ -6,8 +6,8 @@ files[] = field_test.entity.inc version = VERSION hidden = TRUE -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/field_ui/field_ui.info b/modules/field_ui/field_ui.info index b68a951b..2bf6803f 100644 --- a/modules/field_ui/field_ui.info +++ b/modules/field_ui/field_ui.info @@ -6,8 +6,8 @@ core = 7.x dependencies[] = field files[] = field_ui.test -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/file/file.info b/modules/file/file.info index 16b58dd4..60b130c3 100644 --- a/modules/file/file.info +++ b/modules/file/file.info @@ -6,8 +6,8 @@ core = 7.x dependencies[] = field files[] = tests/file.test -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/file/tests/file_module_test.info b/modules/file/tests/file_module_test.info index a0725de9..afa457ea 100644 --- a/modules/file/tests/file_module_test.info +++ b/modules/file/tests/file_module_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/filter/filter.info b/modules/filter/filter.info index 8de2adfc..89f41903 100644 --- a/modules/filter/filter.info +++ b/modules/filter/filter.info @@ -7,8 +7,8 @@ files[] = filter.test required = TRUE configure = admin/config/content/formats -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/forum/forum.info b/modules/forum/forum.info index 5f46897d..13305845 100644 --- a/modules/forum/forum.info +++ b/modules/forum/forum.info @@ -9,8 +9,8 @@ files[] = forum.test configure = admin/structure/forum stylesheets[all][] = forum.css -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/help/help.info b/modules/help/help.info index 23645a23..673681f0 100644 --- a/modules/help/help.info +++ b/modules/help/help.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x files[] = help.test -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/image/image.info b/modules/image/image.info index df255181..a53514db 100644 --- a/modules/image/image.info +++ b/modules/image/image.info @@ -7,8 +7,8 @@ dependencies[] = file files[] = image.test configure = admin/config/media/image-styles -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/image/image.module b/modules/image/image.module index ff50452d..07f48923 100644 --- a/modules/image/image.module +++ b/modules/image/image.module @@ -292,7 +292,8 @@ function image_file_download($uri) { if ($info = image_get_info($uri)) { // Check the permissions of the original to grant access to this image. $headers = module_invoke_all('file_download', $original_uri); - if (!in_array(-1, $headers)) { + // Confirm there's at least one module granting access and none denying access. + if (!empty($headers) && !in_array(-1, $headers)) { return array( // Send headers describing the image's size, and MIME-type... 'Content-Type' => $info['mime_type'], diff --git a/modules/image/tests/image_module_test.info b/modules/image/tests/image_module_test.info index 9e383223..58f99cda 100644 --- a/modules/image/tests/image_module_test.info +++ b/modules/image/tests/image_module_test.info @@ -6,8 +6,8 @@ core = 7.x files[] = image_module_test.module hidden = TRUE -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/locale/locale.info b/modules/locale/locale.info index 0861a48e..f3f119ce 100644 --- a/modules/locale/locale.info +++ b/modules/locale/locale.info @@ -6,8 +6,8 @@ core = 7.x files[] = locale.test configure = admin/config/regional/language -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/locale/tests/locale_test.info b/modules/locale/tests/locale_test.info index ffd5175f..d213776c 100644 --- a/modules/locale/tests/locale_test.info +++ b/modules/locale/tests/locale_test.info @@ -5,8 +5,8 @@ package = Testing version = VERSION hidden = TRUE -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/menu/menu.info b/modules/menu/menu.info index 18a57a73..a01130b8 100644 --- a/modules/menu/menu.info +++ b/modules/menu/menu.info @@ -6,8 +6,8 @@ core = 7.x files[] = menu.test configure = admin/structure/menu -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/node/node.info b/modules/node/node.info index d2fd883a..fa08d126 100644 --- a/modules/node/node.info +++ b/modules/node/node.info @@ -9,8 +9,8 @@ required = TRUE configure = admin/structure/types stylesheets[all][] = node.css -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/node/tests/node_access_test.info b/modules/node/tests/node_access_test.info index 7312d2fa..4e629995 100644 --- a/modules/node/tests/node_access_test.info +++ b/modules/node/tests/node_access_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/node/tests/node_test.info b/modules/node/tests/node_test.info index 702d44a4..625b1a1b 100644 --- a/modules/node/tests/node_test.info +++ b/modules/node/tests/node_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/node/tests/node_test_exception.info b/modules/node/tests/node_test_exception.info index 795f5366..b2c8a9d6 100644 --- a/modules/node/tests/node_test_exception.info +++ b/modules/node/tests/node_test_exception.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/openid/openid.info b/modules/openid/openid.info index 5faa5f53..bdd3c476 100644 --- a/modules/openid/openid.info +++ b/modules/openid/openid.info @@ -5,8 +5,8 @@ package = Core core = 7.x files[] = openid.test -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/openid/tests/openid_test.info b/modules/openid/tests/openid_test.info index dccc075c..a3fd263e 100644 --- a/modules/openid/tests/openid_test.info +++ b/modules/openid/tests/openid_test.info @@ -6,8 +6,8 @@ core = 7.x dependencies[] = openid hidden = TRUE -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/overlay/overlay.info b/modules/overlay/overlay.info index f6dd0277..a4569e8d 100644 --- a/modules/overlay/overlay.info +++ b/modules/overlay/overlay.info @@ -4,8 +4,8 @@ package = Core version = VERSION core = 7.x -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/path/path.info b/modules/path/path.info index 8e79a1e7..9c704df1 100644 --- a/modules/path/path.info +++ b/modules/path/path.info @@ -6,8 +6,8 @@ core = 7.x files[] = path.test configure = admin/config/search/path -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/php/php.info b/modules/php/php.info index 5409ab10..071047fe 100644 --- a/modules/php/php.info +++ b/modules/php/php.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x files[] = php.test -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/poll/poll.info b/modules/poll/poll.info index 2c1536ce..bd0bd597 100644 --- a/modules/poll/poll.info +++ b/modules/poll/poll.info @@ -6,8 +6,8 @@ core = 7.x files[] = poll.test stylesheets[all][] = poll.css -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/profile/profile.info b/modules/profile/profile.info index 051ad84b..bb84f75e 100644 --- a/modules/profile/profile.info +++ b/modules/profile/profile.info @@ -11,8 +11,8 @@ configure = admin/config/people/profile ; See user_system_info_alter(). hidden = TRUE -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/rdf/rdf.info b/modules/rdf/rdf.info index 6b0e523d..59b505fd 100644 --- a/modules/rdf/rdf.info +++ b/modules/rdf/rdf.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x files[] = rdf.test -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/rdf/tests/rdf_test.info b/modules/rdf/tests/rdf_test.info index 0dbbce8b..36c73649 100644 --- a/modules/rdf/tests/rdf_test.info +++ b/modules/rdf/tests/rdf_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/search/search.info b/modules/search/search.info index 25271b99..1ce63073 100644 --- a/modules/search/search.info +++ b/modules/search/search.info @@ -8,8 +8,8 @@ files[] = search.test configure = admin/config/search/settings stylesheets[all][] = search.css -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/search/tests/search_embedded_form.info b/modules/search/tests/search_embedded_form.info index 2c48e471..1a6f3cba 100644 --- a/modules/search/tests/search_embedded_form.info +++ b/modules/search/tests/search_embedded_form.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/search/tests/search_extra_type.info b/modules/search/tests/search_extra_type.info index 208fb6d3..94f92fb2 100644 --- a/modules/search/tests/search_extra_type.info +++ b/modules/search/tests/search_extra_type.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/shortcut/shortcut.info b/modules/shortcut/shortcut.info index cc741e18..93584830 100644 --- a/modules/shortcut/shortcut.info +++ b/modules/shortcut/shortcut.info @@ -6,8 +6,8 @@ core = 7.x files[] = shortcut.test configure = admin/config/user-interface/shortcut -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/simpletest/simpletest.info b/modules/simpletest/simpletest.info index b9a77fc6..1dd2fef1 100644 --- a/modules/simpletest/simpletest.info +++ b/modules/simpletest/simpletest.info @@ -55,8 +55,8 @@ files[] = tests/upgrade/update.trigger.test files[] = tests/upgrade/update.field.test files[] = tests/upgrade/update.user.test -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/simpletest/tests/actions_loop_test.info b/modules/simpletest/tests/actions_loop_test.info index 6efd837d..0c2fc046 100644 --- a/modules/simpletest/tests/actions_loop_test.info +++ b/modules/simpletest/tests/actions_loop_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/simpletest/tests/ajax_forms_test.info b/modules/simpletest/tests/ajax_forms_test.info index 6b93949f..911566d2 100644 --- a/modules/simpletest/tests/ajax_forms_test.info +++ b/modules/simpletest/tests/ajax_forms_test.info @@ -5,8 +5,8 @@ package = Testing version = VERSION hidden = TRUE -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/simpletest/tests/ajax_test.info b/modules/simpletest/tests/ajax_test.info index ef9b93f8..90bf1ebb 100644 --- a/modules/simpletest/tests/ajax_test.info +++ b/modules/simpletest/tests/ajax_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/simpletest/tests/batch_test.info b/modules/simpletest/tests/batch_test.info index 6ded129f..5c00bc2c 100644 --- a/modules/simpletest/tests/batch_test.info +++ b/modules/simpletest/tests/batch_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/simpletest/tests/common_test.info b/modules/simpletest/tests/common_test.info index b999bb06..ba9517e1 100644 --- a/modules/simpletest/tests/common_test.info +++ b/modules/simpletest/tests/common_test.info @@ -7,8 +7,8 @@ stylesheets[all][] = common_test.css stylesheets[print][] = common_test.print.css hidden = TRUE -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/simpletest/tests/common_test_cron_helper.info b/modules/simpletest/tests/common_test_cron_helper.info index 0ccf87db..a5501e06 100644 --- a/modules/simpletest/tests/common_test_cron_helper.info +++ b/modules/simpletest/tests/common_test_cron_helper.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/simpletest/tests/database_test.info b/modules/simpletest/tests/database_test.info index 1e2a3ea0..9f3a58d1 100644 --- a/modules/simpletest/tests/database_test.info +++ b/modules/simpletest/tests/database_test.info @@ -5,8 +5,8 @@ package = Testing version = VERSION hidden = TRUE -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/simpletest/tests/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.info b/modules/simpletest/tests/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.info index 07a44a14..eb6d7d8b 100644 --- a/modules/simpletest/tests/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.info +++ b/modules/simpletest/tests/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/simpletest/tests/drupal_system_listing_incompatible_test/drupal_system_listing_incompatible_test.info b/modules/simpletest/tests/drupal_system_listing_incompatible_test/drupal_system_listing_incompatible_test.info index 1ad4e306..05cdd1f6 100644 --- a/modules/simpletest/tests/drupal_system_listing_incompatible_test/drupal_system_listing_incompatible_test.info +++ b/modules/simpletest/tests/drupal_system_listing_incompatible_test/drupal_system_listing_incompatible_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/simpletest/tests/entity_cache_test.info b/modules/simpletest/tests/entity_cache_test.info index c2f02075..dd500154 100644 --- a/modules/simpletest/tests/entity_cache_test.info +++ b/modules/simpletest/tests/entity_cache_test.info @@ -6,8 +6,8 @@ core = 7.x dependencies[] = entity_cache_test_dependency hidden = TRUE -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/simpletest/tests/entity_cache_test_dependency.info b/modules/simpletest/tests/entity_cache_test_dependency.info index 71018af3..e5a20fb3 100644 --- a/modules/simpletest/tests/entity_cache_test_dependency.info +++ b/modules/simpletest/tests/entity_cache_test_dependency.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/simpletest/tests/entity_crud_hook_test.info b/modules/simpletest/tests/entity_crud_hook_test.info index 9540f9ac..c4a61286 100644 --- a/modules/simpletest/tests/entity_crud_hook_test.info +++ b/modules/simpletest/tests/entity_crud_hook_test.info @@ -5,8 +5,8 @@ package = Testing version = VERSION hidden = TRUE -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/simpletest/tests/entity_query_access_test.info b/modules/simpletest/tests/entity_query_access_test.info index e5437532..0d8ac9e5 100644 --- a/modules/simpletest/tests/entity_query_access_test.info +++ b/modules/simpletest/tests/entity_query_access_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/simpletest/tests/error_test.info b/modules/simpletest/tests/error_test.info index 12a5a51b..123fcea0 100644 --- a/modules/simpletest/tests/error_test.info +++ b/modules/simpletest/tests/error_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/simpletest/tests/file_test.info b/modules/simpletest/tests/file_test.info index b7b76197..367f2eee 100644 --- a/modules/simpletest/tests/file_test.info +++ b/modules/simpletest/tests/file_test.info @@ -6,8 +6,8 @@ core = 7.x files[] = file_test.module hidden = TRUE -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/simpletest/tests/filter_test.info b/modules/simpletest/tests/filter_test.info index 9f58a303..873a21af 100644 --- a/modules/simpletest/tests/filter_test.info +++ b/modules/simpletest/tests/filter_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/simpletest/tests/form_test.info b/modules/simpletest/tests/form_test.info index a5be94b8..e1fbc1c4 100644 --- a/modules/simpletest/tests/form_test.info +++ b/modules/simpletest/tests/form_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/simpletest/tests/image_test.info b/modules/simpletest/tests/image_test.info index f3b34229..201d113e 100644 --- a/modules/simpletest/tests/image_test.info +++ b/modules/simpletest/tests/image_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/simpletest/tests/menu_test.info b/modules/simpletest/tests/menu_test.info index 1b9c676b..b35d57b5 100644 --- a/modules/simpletest/tests/menu_test.info +++ b/modules/simpletest/tests/menu_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/simpletest/tests/module_test.info b/modules/simpletest/tests/module_test.info index e591d354..9d74f0ad 100644 --- a/modules/simpletest/tests/module_test.info +++ b/modules/simpletest/tests/module_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/simpletest/tests/path_test.info b/modules/simpletest/tests/path_test.info index 94c85084..0e49736f 100644 --- a/modules/simpletest/tests/path_test.info +++ b/modules/simpletest/tests/path_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/simpletest/tests/requirements1_test.info b/modules/simpletest/tests/requirements1_test.info index 855ada58..6d7bdb22 100644 --- a/modules/simpletest/tests/requirements1_test.info +++ b/modules/simpletest/tests/requirements1_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/simpletest/tests/requirements2_test.info b/modules/simpletest/tests/requirements2_test.info index f1d5886d..f22562a3 100644 --- a/modules/simpletest/tests/requirements2_test.info +++ b/modules/simpletest/tests/requirements2_test.info @@ -7,8 +7,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/simpletest/tests/session_test.info b/modules/simpletest/tests/session_test.info index 35b2f7f5..87b1f4a5 100644 --- a/modules/simpletest/tests/session_test.info +++ b/modules/simpletest/tests/session_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/simpletest/tests/system_dependencies_test.info b/modules/simpletest/tests/system_dependencies_test.info index 09e49cb8..ce7bb02f 100644 --- a/modules/simpletest/tests/system_dependencies_test.info +++ b/modules/simpletest/tests/system_dependencies_test.info @@ -6,8 +6,8 @@ core = 7.x hidden = TRUE dependencies[] = _missing_dependency -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/simpletest/tests/system_incompatible_core_version_dependencies_test.info b/modules/simpletest/tests/system_incompatible_core_version_dependencies_test.info index 03de8dd7..372a0b9e 100644 --- a/modules/simpletest/tests/system_incompatible_core_version_dependencies_test.info +++ b/modules/simpletest/tests/system_incompatible_core_version_dependencies_test.info @@ -6,8 +6,8 @@ core = 7.x hidden = TRUE dependencies[] = system_incompatible_core_version_test -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/simpletest/tests/system_incompatible_core_version_test.info b/modules/simpletest/tests/system_incompatible_core_version_test.info index 98f045a3..4f5679d2 100644 --- a/modules/simpletest/tests/system_incompatible_core_version_test.info +++ b/modules/simpletest/tests/system_incompatible_core_version_test.info @@ -5,8 +5,8 @@ version = VERSION core = 5.x hidden = TRUE -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/simpletest/tests/system_incompatible_module_version_dependencies_test.info b/modules/simpletest/tests/system_incompatible_module_version_dependencies_test.info index 5cba8c5c..c1c18d43 100644 --- a/modules/simpletest/tests/system_incompatible_module_version_dependencies_test.info +++ b/modules/simpletest/tests/system_incompatible_module_version_dependencies_test.info @@ -7,8 +7,8 @@ hidden = TRUE ; system_incompatible_module_version_test declares version 1.0 dependencies[] = system_incompatible_module_version_test (>2.0) -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/simpletest/tests/system_incompatible_module_version_test.info b/modules/simpletest/tests/system_incompatible_module_version_test.info index 229df455..5af3b5ee 100644 --- a/modules/simpletest/tests/system_incompatible_module_version_test.info +++ b/modules/simpletest/tests/system_incompatible_module_version_test.info @@ -5,8 +5,8 @@ version = 1.0 core = 7.x hidden = TRUE -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/simpletest/tests/system_test.info b/modules/simpletest/tests/system_test.info index f88b575a..98de621e 100644 --- a/modules/simpletest/tests/system_test.info +++ b/modules/simpletest/tests/system_test.info @@ -6,8 +6,8 @@ core = 7.x files[] = system_test.module hidden = TRUE -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/simpletest/tests/taxonomy_test.info b/modules/simpletest/tests/taxonomy_test.info index 4b36f550..18034473 100644 --- a/modules/simpletest/tests/taxonomy_test.info +++ b/modules/simpletest/tests/taxonomy_test.info @@ -6,8 +6,8 @@ core = 7.x hidden = TRUE dependencies[] = taxonomy -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/simpletest/tests/theme_test.info b/modules/simpletest/tests/theme_test.info index b76dee57..83adcfcd 100644 --- a/modules/simpletest/tests/theme_test.info +++ b/modules/simpletest/tests/theme_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/simpletest/tests/themes/test_basetheme/test_basetheme.info b/modules/simpletest/tests/themes/test_basetheme/test_basetheme.info index 97553613..2cf64aa9 100644 --- a/modules/simpletest/tests/themes/test_basetheme/test_basetheme.info +++ b/modules/simpletest/tests/themes/test_basetheme/test_basetheme.info @@ -6,8 +6,8 @@ hidden = TRUE settings[basetheme_only] = base theme value settings[subtheme_override] = base theme value -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/simpletest/tests/themes/test_subtheme/test_subtheme.info b/modules/simpletest/tests/themes/test_subtheme/test_subtheme.info index 082f782e..34154f55 100644 --- a/modules/simpletest/tests/themes/test_subtheme/test_subtheme.info +++ b/modules/simpletest/tests/themes/test_subtheme/test_subtheme.info @@ -6,8 +6,8 @@ hidden = TRUE settings[subtheme_override] = subtheme value -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/simpletest/tests/themes/test_theme/test_theme.info b/modules/simpletest/tests/themes/test_theme/test_theme.info index fa187353..5d527da4 100644 --- a/modules/simpletest/tests/themes/test_theme/test_theme.info +++ b/modules/simpletest/tests/themes/test_theme/test_theme.info @@ -17,8 +17,8 @@ stylesheets[all][] = system.base.css settings[theme_test_setting] = default value -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/simpletest/tests/update_script_test.info b/modules/simpletest/tests/update_script_test.info index 3a240fe7..ada207a3 100644 --- a/modules/simpletest/tests/update_script_test.info +++ b/modules/simpletest/tests/update_script_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/simpletest/tests/update_test_1.info b/modules/simpletest/tests/update_test_1.info index c4febe3d..5e80c651 100644 --- a/modules/simpletest/tests/update_test_1.info +++ b/modules/simpletest/tests/update_test_1.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/simpletest/tests/update_test_2.info b/modules/simpletest/tests/update_test_2.info index c4febe3d..5e80c651 100644 --- a/modules/simpletest/tests/update_test_2.info +++ b/modules/simpletest/tests/update_test_2.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/simpletest/tests/update_test_3.info b/modules/simpletest/tests/update_test_3.info index c4febe3d..5e80c651 100644 --- a/modules/simpletest/tests/update_test_3.info +++ b/modules/simpletest/tests/update_test_3.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/simpletest/tests/url_alter_test.info b/modules/simpletest/tests/url_alter_test.info index d7fe962c..94d672a6 100644 --- a/modules/simpletest/tests/url_alter_test.info +++ b/modules/simpletest/tests/url_alter_test.info @@ -5,8 +5,8 @@ package = Testing version = VERSION hidden = TRUE -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/simpletest/tests/xmlrpc_test.info b/modules/simpletest/tests/xmlrpc_test.info index b6a3cc49..ff0d1559 100644 --- a/modules/simpletest/tests/xmlrpc_test.info +++ b/modules/simpletest/tests/xmlrpc_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/statistics/statistics.info b/modules/statistics/statistics.info index 628a94ef..ebdfcbda 100644 --- a/modules/statistics/statistics.info +++ b/modules/statistics/statistics.info @@ -6,8 +6,8 @@ core = 7.x files[] = statistics.test configure = admin/config/system/statistics -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/syslog/syslog.info b/modules/syslog/syslog.info index 963d87c5..c3bb3328 100644 --- a/modules/syslog/syslog.info +++ b/modules/syslog/syslog.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x files[] = syslog.test -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/system/system.info b/modules/system/system.info index fab267a7..1d42f18b 100644 --- a/modules/system/system.info +++ b/modules/system/system.info @@ -12,8 +12,8 @@ files[] = system.test required = TRUE configure = admin/config/system -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/taxonomy/taxonomy.info b/modules/taxonomy/taxonomy.info index 2a565ab0..d62b8ef1 100644 --- a/modules/taxonomy/taxonomy.info +++ b/modules/taxonomy/taxonomy.info @@ -8,8 +8,8 @@ files[] = taxonomy.module files[] = taxonomy.test configure = admin/structure/taxonomy -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/toolbar/toolbar.info b/modules/toolbar/toolbar.info index 3191b5f5..7576972b 100644 --- a/modules/toolbar/toolbar.info +++ b/modules/toolbar/toolbar.info @@ -4,8 +4,8 @@ core = 7.x package = Core version = VERSION -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/tracker/tracker.info b/modules/tracker/tracker.info index d3d8706c..16c6a1d8 100644 --- a/modules/tracker/tracker.info +++ b/modules/tracker/tracker.info @@ -6,8 +6,8 @@ version = VERSION core = 7.x files[] = tracker.test -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/translation/tests/translation_test.info b/modules/translation/tests/translation_test.info index d11abcf9..aa84109a 100644 --- a/modules/translation/tests/translation_test.info +++ b/modules/translation/tests/translation_test.info @@ -5,8 +5,8 @@ package = Testing version = VERSION hidden = TRUE -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/translation/translation.info b/modules/translation/translation.info index 1449c7ad..a9d7d679 100644 --- a/modules/translation/translation.info +++ b/modules/translation/translation.info @@ -6,8 +6,8 @@ version = VERSION core = 7.x files[] = translation.test -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/trigger/tests/trigger_test.info b/modules/trigger/tests/trigger_test.info index 5067e6a8..d34da4c5 100644 --- a/modules/trigger/tests/trigger_test.info +++ b/modules/trigger/tests/trigger_test.info @@ -4,8 +4,8 @@ package = Testing core = 7.x hidden = TRUE -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/trigger/trigger.info b/modules/trigger/trigger.info index 222b3828..fe18dae3 100644 --- a/modules/trigger/trigger.info +++ b/modules/trigger/trigger.info @@ -6,8 +6,8 @@ core = 7.x files[] = trigger.test configure = admin/structure/trigger -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/update/tests/aaa_update_test.info b/modules/update/tests/aaa_update_test.info index 7c5179a2..1043ad5c 100644 --- a/modules/update/tests/aaa_update_test.info +++ b/modules/update/tests/aaa_update_test.info @@ -4,8 +4,8 @@ package = Testing core = 7.x hidden = TRUE -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/update/tests/bbb_update_test.info b/modules/update/tests/bbb_update_test.info index d88c1fe9..89204cba 100644 --- a/modules/update/tests/bbb_update_test.info +++ b/modules/update/tests/bbb_update_test.info @@ -4,8 +4,8 @@ package = Testing core = 7.x hidden = TRUE -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/update/tests/ccc_update_test.info b/modules/update/tests/ccc_update_test.info index 591af8fb..fa96e11e 100644 --- a/modules/update/tests/ccc_update_test.info +++ b/modules/update/tests/ccc_update_test.info @@ -4,8 +4,8 @@ package = Testing core = 7.x hidden = TRUE -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/update/tests/themes/update_test_basetheme/update_test_basetheme.info b/modules/update/tests/themes/update_test_basetheme/update_test_basetheme.info index 9e92226d..d3f29920 100644 --- a/modules/update/tests/themes/update_test_basetheme/update_test_basetheme.info +++ b/modules/update/tests/themes/update_test_basetheme/update_test_basetheme.info @@ -3,8 +3,8 @@ description = Test theme which acts as a base theme for other test subthemes. core = 7.x hidden = TRUE -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/update/tests/themes/update_test_subtheme/update_test_subtheme.info b/modules/update/tests/themes/update_test_subtheme/update_test_subtheme.info index 3dca01d4..68a81e61 100644 --- a/modules/update/tests/themes/update_test_subtheme/update_test_subtheme.info +++ b/modules/update/tests/themes/update_test_subtheme/update_test_subtheme.info @@ -4,8 +4,8 @@ core = 7.x base theme = update_test_basetheme hidden = TRUE -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/update/tests/update_test.info b/modules/update/tests/update_test.info index d6883aef..1c17b944 100644 --- a/modules/update/tests/update_test.info +++ b/modules/update/tests/update_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/update/update.info b/modules/update/update.info index f1a00def..c146e8c3 100644 --- a/modules/update/update.info +++ b/modules/update/update.info @@ -6,8 +6,8 @@ core = 7.x files[] = update.test configure = admin/reports/updates/settings -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/user/tests/user_form_test.info b/modules/user/tests/user_form_test.info index 1b33a82d..43f4afd3 100644 --- a/modules/user/tests/user_form_test.info +++ b/modules/user/tests/user_form_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/user/user.info b/modules/user/user.info index 1f271a49..36aa7395 100644 --- a/modules/user/user.info +++ b/modules/user/user.info @@ -9,8 +9,8 @@ required = TRUE configure = admin/config/people stylesheets[all][] = user.css -; Information added by drupal.org packaging script on 2012-11-07 -version = "7.17" +; Information added by drupal.org packaging script on 2013-01-16 +version = "7.19" project = "drupal" -datestamp = "1352325357" +datestamp = "1358374870" diff --git a/modules/user/user.module b/modules/user/user.module index 56343536..622fe4d2 100644 --- a/modules/user/user.module +++ b/modules/user/user.module @@ -933,14 +933,18 @@ function user_search_execute($keys = NULL, $conditions = NULL) { $query = db_select('users')->extend('PagerDefault'); $query->fields('users', array('uid')); if (user_access('administer users')) { - // Administrators can also search in the otherwise private email field. + // Administrators can also search in the otherwise private email field, + // and they don't need to be restricted to only active users. $query->fields('users', array('mail')); $query->condition(db_or()-> condition('name', '%' . db_like($keys) . '%', 'LIKE')-> condition('mail', '%' . db_like($keys) . '%', 'LIKE')); } else { - $query->condition('name', '%' . db_like($keys) . '%', 'LIKE'); + // Regular users can only search via usernames, and we do not show them + // blocked accounts. + $query->condition('name', '%' . db_like($keys) . '%', 'LIKE') + ->condition('status', 1); } $uids = $query ->limit(15) @@ -2285,26 +2289,14 @@ function user_external_login_register($name, $module) { * * @param object $account * An object containing the user account. - * @param array $options - * (optional) A keyed array of settings. Supported options are: - * - langcode: A language code to be used when generating locale-sensitive - * urls. If langcode is NULL the users preferred language is used. * * @return * A unique URL that provides a one-time log in for the user, from which * they can change their password. */ -function user_pass_reset_url($account, $options = array()) { +function user_pass_reset_url($account) { $timestamp = REQUEST_TIME; - $url_options = array('absolute' => TRUE); - if (isset($options['langcode'])) { - $languages = language_list(); - $url_options['language'] = $languages[$options['langcode']]; - } - else { - $url_options['language'] = user_preferred_language($account); - } - return url("user/reset/$account->uid/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->login), $url_options); + return url("user/reset/$account->uid/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->login), array('absolute' => TRUE)); } /** @@ -2316,10 +2308,6 @@ function user_pass_reset_url($account, $options = array()) { * - uid: The user uid number. * - pass: The hashed user password string. * - login: The user login name. - * @param array $options - * (optional) A keyed array of settings. Supported options are: - * - langcode: A language code to be used when generating locale-sensitive - * urls. If langcode is NULL the users preferred language is used. * * @return * A unique URL that may be used to confirm the cancellation of the user @@ -2328,17 +2316,9 @@ function user_pass_reset_url($account, $options = array()) { * @see user_mail_tokens() * @see user_cancel_confirm() */ -function user_cancel_url($account, $options = array()) { +function user_cancel_url($account) { $timestamp = REQUEST_TIME; - $url_options = array('absolute' => TRUE); - if (isset($options['langcode'])) { - $languages = language_list(); - $url_options['language'] = $languages[$options['langcode']]; - } - else { - $url_options['language'] = user_preferred_language($account); - } - return url("user/$account->uid/cancel/confirm/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->login), $url_options); + return url("user/$account->uid/cancel/confirm/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->login), array('absolute' => TRUE)); } /** @@ -2787,7 +2767,7 @@ Your account on [site:name] has been canceled. if ($replace) { // We do not sanitize the token replacement, since the output of this // replacement is intended for an e-mail message, not a web browser. - return token_replace($text, $variables, array('langcode' => $langcode, 'callback' => 'user_mail_tokens', 'sanitize' => FALSE, 'clear' => TRUE)); + return token_replace($text, $variables, array('language' => $language, 'callback' => 'user_mail_tokens', 'sanitize' => FALSE, 'clear' => TRUE)); } return $text; @@ -2814,8 +2794,8 @@ Your account on [site:name] has been canceled. */ function user_mail_tokens(&$replacements, $data, $options) { if (isset($data['user'])) { - $replacements['[user:one-time-login-url]'] = user_pass_reset_url($data['user'], $options); - $replacements['[user:cancel-url]'] = user_cancel_url($data['user'], $options); + $replacements['[user:one-time-login-url]'] = user_pass_reset_url($data['user']); + $replacements['[user:cancel-url]'] = user_cancel_url($data['user']); } } diff --git a/modules/user/user.module.orig b/modules/user/user.module.orig deleted file mode 100644 index 2c02f8ce..00000000 --- a/modules/user/user.module.orig +++ /dev/null @@ -1,3963 +0,0 @@ -' . t('About') . ''; - $output .= '' . t('The User module allows users to register, log in, and log out. It also allows users with proper permissions to manage user roles (used to classify users) and permissions associated with those roles. For more information, see the online handbook entry for User module.', array('@user' => 'http://drupal.org/documentation/modules/user')) . '
'; - $output .= '' . t("This web page allows administrators to register new users. Users' e-mail addresses and usernames must be unique.") . '
'; - case 'admin/people/permissions': - return '' . t('Permissions let you control what users can do and see on your site. You can define a specific set of permissions for each role. (See the Roles page to create a role). Two important roles to consider are Authenticated Users and Administrators. Any permissions granted to the Authenticated Users role will be given to any user who can log into your site. You can make any role the Administrator role for the site, meaning this will be granted all new permissions automatically. You can do this on the User Settings page. You should be careful to ensure that only trusted users are given this access and level of control of your site.', array('@role' => url('admin/people/permissions/roles'), '@settings' => url('admin/config/people/accounts'))) . '
'; - case 'admin/people/permissions/roles': - $output = '' . t('Roles allow you to fine tune the security and administration of Drupal. A role defines a group of users that have certain privileges as defined on the permissions page. Examples of roles include: anonymous user, authenticated user, moderator, administrator and so on. In this area you will define the names and order of the roles on your site. It is recommended to order your roles from least permissive (anonymous user) to most permissive (administrator). To delete a role choose "edit role".', array('@permissions' => url('admin/people/permissions'))) . '
'; - $output .= '' . t('By default, Drupal comes with two user roles:') . '
'; - $output .= '' . t('This form lets administrators add, edit, and arrange fields for storing user data.') . '
'; - case 'admin/config/people/accounts/display': - return '' . t('This form lets administrators configure how fields should be displayed when rendering a user profile page.') . '
'; - case 'admin/people/search': - return '' . t('Enter a simple pattern ("*" may be used as a wildcard match) to search for a username or e-mail address. For example, one may search for "br" and Drupal might return "brian", "brad", and "brenda@example.com".') . '
'; - } -} - -/** - * Invokes a user hook in every module. - * - * We cannot use module_invoke() for this, because the arguments need to - * be passed by reference. - * - * @param $type - * A text string that controls which user hook to invoke. Valid choices are: - * - cancel: Invokes hook_user_cancel(). - * - insert: Invokes hook_user_insert(). - * - login: Invokes hook_user_login(). - * - presave: Invokes hook_user_presave(). - * - update: Invokes hook_user_update(). - * @param $edit - * An associative array variable containing form values to be passed - * as the first parameter of the hook function. - * @param $account - * The user account object to be passed as the second parameter of the hook - * function. - * @param $category - * The category of user information being acted upon. - */ -function user_module_invoke($type, &$edit, $account, $category = NULL) { - foreach (module_implements('user_' . $type) as $module) { - $function = $module . '_user_' . $type; - $function($edit, $account, $category); - } -} - -/** - * Implements hook_theme(). - */ -function user_theme() { - return array( - 'user_picture' => array( - 'variables' => array('account' => NULL), - 'template' => 'user-picture', - ), - 'user_profile' => array( - 'render element' => 'elements', - 'template' => 'user-profile', - 'file' => 'user.pages.inc', - ), - 'user_profile_category' => array( - 'render element' => 'element', - 'template' => 'user-profile-category', - 'file' => 'user.pages.inc', - ), - 'user_profile_item' => array( - 'render element' => 'element', - 'template' => 'user-profile-item', - 'file' => 'user.pages.inc', - ), - 'user_list' => array( - 'variables' => array('users' => NULL, 'title' => NULL), - ), - 'user_admin_permissions' => array( - 'render element' => 'form', - 'file' => 'user.admin.inc', - ), - 'user_admin_roles' => array( - 'render element' => 'form', - 'file' => 'user.admin.inc', - ), - 'user_permission_description' => array( - 'variables' => array('permission_item' => NULL, 'hide' => NULL), - 'file' => 'user.admin.inc', - ), - 'user_signature' => array( - 'variables' => array('signature' => NULL), - ), - ); -} - -/** - * Implements hook_entity_info(). - */ -function user_entity_info() { - $return = array( - 'user' => array( - 'label' => t('User'), - 'controller class' => 'UserController', - 'base table' => 'users', - 'uri callback' => 'user_uri', - 'label callback' => 'format_username', - 'fieldable' => TRUE, - // $user->language is only the preferred user language for the user - // interface textual elements. As it is not necessarily related to the - // language assigned to fields, we do not define it as the entity language - // key. - 'entity keys' => array( - 'id' => 'uid', - ), - 'bundles' => array( - 'user' => array( - 'label' => t('User'), - 'admin' => array( - 'path' => 'admin/config/people/accounts', - 'access arguments' => array('administer users'), - ), - ), - ), - 'view modes' => array( - 'full' => array( - 'label' => t('User account'), - 'custom settings' => FALSE, - ), - ), - ), - ); - return $return; -} - -/** - * Entity URI callback. - */ -function user_uri($user) { - return array( - 'path' => 'user/' . $user->uid, - ); -} - -/** - * Implements hook_field_info_alter(). - */ -function user_field_info_alter(&$info) { - // Add the 'user_register_form' instance setting to all field types. - foreach ($info as $field_type => &$field_type_info) { - $field_type_info += array('instance_settings' => array()); - $field_type_info['instance_settings'] += array( - 'user_register_form' => FALSE, - ); - } -} - -/** - * Implements hook_field_extra_fields(). - */ -function user_field_extra_fields() { - $return['user']['user'] = array( - 'form' => array( - 'account' => array( - 'label' => t('User name and password'), - 'description' => t('User module account form elements.'), - 'weight' => -10, - ), - 'timezone' => array( - 'label' => t('Timezone'), - 'description' => t('User module timezone form element.'), - 'weight' => 6, - ), - ), - 'display' => array( - 'summary' => array( - 'label' => t('History'), - 'description' => t('User module history view element.'), - 'weight' => 5, - ), - ), - ); - - return $return; -} - -/** - * Fetches a user object based on an external authentication source. - * - * @param string $authname - * The external authentication username. - * - * @return - * A fully-loaded user object if the user is found or FALSE if not found. - */ -function user_external_load($authname) { - $uid = db_query("SELECT uid FROM {authmap} WHERE authname = :authname", array(':authname' => $authname))->fetchField(); - - if ($uid) { - return user_load($uid); - } - else { - return FALSE; - } -} - -/** - * Load multiple users based on certain conditions. - * - * This function should be used whenever you need to load more than one user - * from the database. Users are loaded into memory and will not require - * database access if loaded again during the same page request. - * - * @param $uids - * An array of user IDs. - * @param $conditions - * (deprecated) An associative array of conditions on the {users} - * table, where the keys are the database fields and the values are the - * values those fields must have. Instead, it is preferable to use - * EntityFieldQuery to retrieve a list of entity IDs loadable by - * this function. - * @param $reset - * A boolean indicating that the internal cache should be reset. Use this if - * loading a user object which has been altered during the page request. - * - * @return - * An array of user objects, indexed by uid. - * - * @see entity_load() - * @see user_load() - * @see user_load_by_mail() - * @see user_load_by_name() - * @see EntityFieldQuery - * - * @todo Remove $conditions in Drupal 8. - */ -function user_load_multiple($uids = array(), $conditions = array(), $reset = FALSE) { - return entity_load('user', $uids, $conditions, $reset); -} - -/** - * Controller class for users. - * - * This extends the DrupalDefaultEntityController class, adding required - * special handling for user objects. - */ -class UserController extends DrupalDefaultEntityController { - - function attachLoad(&$queried_users, $revision_id = FALSE) { - // Build an array of user picture IDs so that these can be fetched later. - $picture_fids = array(); - foreach ($queried_users as $key => $record) { - $picture_fids[] = $record->picture; - $queried_users[$key]->data = unserialize($record->data); - $queried_users[$key]->roles = array(); - if ($record->uid) { - $queried_users[$record->uid]->roles[DRUPAL_AUTHENTICATED_RID] = 'authenticated user'; - } - else { - $queried_users[$record->uid]->roles[DRUPAL_ANONYMOUS_RID] = 'anonymous user'; - } - } - - // Add any additional roles from the database. - $result = db_query('SELECT r.rid, r.name, ur.uid FROM {role} r INNER JOIN {users_roles} ur ON ur.rid = r.rid WHERE ur.uid IN (:uids)', array(':uids' => array_keys($queried_users))); - foreach ($result as $record) { - $queried_users[$record->uid]->roles[$record->rid] = $record->name; - } - - // Add the full file objects for user pictures if enabled. - if (!empty($picture_fids) && variable_get('user_pictures', 1) == 1) { - $pictures = file_load_multiple($picture_fids); - foreach ($queried_users as $account) { - if (!empty($account->picture) && isset($pictures[$account->picture])) { - $account->picture = $pictures[$account->picture]; - } - else { - $account->picture = NULL; - } - } - } - // Call the default attachLoad() method. This will add fields and call - // hook_user_load(). - parent::attachLoad($queried_users, $revision_id); - } -} - -/** - * Loads a user object. - * - * Drupal has a global $user object, which represents the currently-logged-in - * user. So to avoid confusion and to avoid clobbering the global $user object, - * it is a good idea to assign the result of this function to a different local - * variable, generally $account. If you actually do want to act as the user you - * are loading, it is essential to call drupal_save_session(FALSE); first. - * See - * @link http://drupal.org/node/218104 Safely impersonating another user @endlink - * for more information. - * - * @param $uid - * Integer specifying the user ID to load. - * @param $reset - * TRUE to reset the internal cache and load from the database; FALSE - * (default) to load from the internal cache, if set. - * - * @return - * A fully-loaded user object upon successful user load, or FALSE if the user - * cannot be loaded. - * - * @see user_load_multiple() - */ -function user_load($uid, $reset = FALSE) { - $users = user_load_multiple(array($uid), array(), $reset); - return reset($users); -} - -/** - * Fetch a user object by email address. - * - * @param $mail - * String with the account's e-mail address. - * @return - * A fully-loaded $user object upon successful user load or FALSE if user - * cannot be loaded. - * - * @see user_load_multiple() - */ -function user_load_by_mail($mail) { - $users = user_load_multiple(array(), array('mail' => $mail)); - return reset($users); -} - -/** - * Fetch a user object by account name. - * - * @param $name - * String with the account's user name. - * @return - * A fully-loaded $user object upon successful user load or FALSE if user - * cannot be loaded. - * - * @see user_load_multiple() - */ -function user_load_by_name($name) { - $users = user_load_multiple(array(), array('name' => $name)); - return reset($users); -} - -/** - * Save changes to a user account or add a new user. - * - * @param $account - * (optional) The user object to modify or add. If you want to modify - * an existing user account, you will need to ensure that (a) $account - * is an object, and (b) you have set $account->uid to the numeric - * user ID of the user account you wish to modify. If you - * want to create a new user account, you can set $account->is_new to - * TRUE or omit the $account->uid field. - * @param $edit - * An array of fields and values to save. For example array('name' - * => 'My name'). Key / value pairs added to the $edit['data'] will be - * serialized and saved in the {users.data} column. - * @param $category - * (optional) The category for storing profile information in. - * - * @return - * A fully-loaded $user object upon successful save or FALSE if the save failed. - * - * @todo D8: Drop $edit and fix user_save() to be consistent with others. - */ -function user_save($account, $edit = array(), $category = 'account') { - $transaction = db_transaction(); - try { - if (!empty($edit['pass'])) { - // Allow alternate password hashing schemes. - require_once DRUPAL_ROOT . '/' . variable_get('password_inc', 'includes/password.inc'); - $edit['pass'] = user_hash_password(trim($edit['pass'])); - // Abort if the hashing failed and returned FALSE. - if (!$edit['pass']) { - return FALSE; - } - } - else { - // Avoid overwriting an existing password with a blank password. - unset($edit['pass']); - } - if (isset($edit['mail'])) { - $edit['mail'] = trim($edit['mail']); - } - - // Load the stored entity, if any. - if (!empty($account->uid) && !isset($account->original)) { - $account->original = entity_load_unchanged('user', $account->uid); - } - - if (empty($account)) { - $account = new stdClass(); - } - if (!isset($account->is_new)) { - $account->is_new = empty($account->uid); - } - // Prepopulate $edit['data'] with the current value of $account->data. - // Modules can add to or remove from this array in hook_user_presave(). - if (!empty($account->data)) { - $edit['data'] = !empty($edit['data']) ? array_merge($account->data, $edit['data']) : $account->data; - } - - // Invoke hook_user_presave() for all modules. - user_module_invoke('presave', $edit, $account, $category); - - // Invoke presave operations of Field Attach API and Entity API. Those APIs - // require a fully-fledged and updated entity object. Therefore, we need to - // copy any new property values of $edit into it. - foreach ($edit as $key => $value) { - $account->$key = $value; - } - field_attach_presave('user', $account); - module_invoke_all('entity_presave', $account, 'user'); - - if (is_object($account) && !$account->is_new) { - // Process picture uploads. - if (!empty($account->picture->fid) && (!isset($account->original->picture->fid) || $account->picture->fid != $account->original->picture->fid)) { - $picture = $account->picture; - // If the picture is a temporary file move it to its final location and - // make it permanent. - if (!$picture->status) { - $info = image_get_info($picture->uri); - $picture_directory = file_default_scheme() . '://' . variable_get('user_picture_path', 'pictures'); - - // Prepare the pictures directory. - file_prepare_directory($picture_directory, FILE_CREATE_DIRECTORY); - $destination = file_stream_wrapper_uri_normalize($picture_directory . '/picture-' . $account->uid . '-' . REQUEST_TIME . '.' . $info['extension']); - - // Move the temporary file into the final location. - if ($picture = file_move($picture, $destination, FILE_EXISTS_RENAME)) { - $picture->status = FILE_STATUS_PERMANENT; - $account->picture = file_save($picture); - file_usage_add($picture, 'user', 'user', $account->uid); - } - } - // Delete the previous picture if it was deleted or replaced. - if (!empty($account->original->picture->fid)) { - file_usage_delete($account->original->picture, 'user', 'user', $account->uid); - file_delete($account->original->picture); - } - } - elseif (isset($edit['picture_delete']) && $edit['picture_delete']) { - file_usage_delete($account->original->picture, 'user', 'user', $account->uid); - file_delete($account->original->picture); - } - $account->picture = empty($account->picture->fid) ? 0 : $account->picture->fid; - - // Do not allow 'uid' to be changed. - $account->uid = $account->original->uid; - // Save changes to the user table. - $success = drupal_write_record('users', $account, 'uid'); - if ($success === FALSE) { - // The query failed - better to abort the save than risk further - // data loss. - return FALSE; - } - - // Reload user roles if provided. - if ($account->roles != $account->original->roles) { - db_delete('users_roles') - ->condition('uid', $account->uid) - ->execute(); - - $query = db_insert('users_roles')->fields(array('uid', 'rid')); - foreach (array_keys($account->roles) as $rid) { - if (!in_array($rid, array(DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID))) { - $query->values(array( - 'uid' => $account->uid, - 'rid' => $rid, - )); - } - } - $query->execute(); - } - - // Delete a blocked user's sessions to kick them if they are online. - if ($account->original->status != $account->status && $account->status == 0) { - drupal_session_destroy_uid($account->uid); - } - - // If the password changed, delete all open sessions and recreate - // the current one. - if ($account->pass != $account->original->pass) { - drupal_session_destroy_uid($account->uid); - if ($account->uid == $GLOBALS['user']->uid) { - drupal_session_regenerate(); - } - } - - // Save Field data. - field_attach_update('user', $account); - - // Send emails after we have the new user object. - if ($account->status != $account->original->status) { - // The user's status is changing; conditionally send notification email. - $op = $account->status == 1 ? 'status_activated' : 'status_blocked'; - _user_mail_notify($op, $account); - } - - // Update $edit with any interim changes to $account. - foreach ($account as $key => $value) { - if (!property_exists($account->original, $key) || $value !== $account->original->$key) { - $edit[$key] = $value; - } - } - user_module_invoke('update', $edit, $account, $category); - module_invoke_all('entity_update', $account, 'user'); - } - else { - // Allow 'uid' to be set by the caller. There is no danger of writing an - // existing user as drupal_write_record will do an INSERT. - if (empty($account->uid)) { - $account->uid = db_next_id(db_query('SELECT MAX(uid) FROM {users}')->fetchField()); - } - // Allow 'created' to be set by the caller. - if (!isset($account->created)) { - $account->created = REQUEST_TIME; - } - $success = drupal_write_record('users', $account); - if ($success === FALSE) { - // On a failed INSERT some other existing user's uid may be returned. - // We must abort to avoid overwriting their account. - return FALSE; - } - - // Make sure $account is properly initialized. - $account->roles[DRUPAL_AUTHENTICATED_RID] = 'authenticated user'; - - field_attach_insert('user', $account); - $edit = (array) $account; - user_module_invoke('insert', $edit, $account, $category); - module_invoke_all('entity_insert', $account, 'user'); - - // Save user roles. - if (count($account->roles) > 1) { - $query = db_insert('users_roles')->fields(array('uid', 'rid')); - foreach (array_keys($account->roles) as $rid) { - if (!in_array($rid, array(DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID))) { - $query->values(array( - 'uid' => $account->uid, - 'rid' => $rid, - )); - } - } - $query->execute(); - } - } - // Clear internal properties. - unset($account->is_new); - unset($account->original); - // Clear the static loading cache. - entity_get_controller('user')->resetCache(array($account->uid)); - - return $account; - } - catch (Exception $e) { - $transaction->rollback(); - watchdog_exception('user', $e); - throw $e; - } -} - -/** - * Verify the syntax of the given name. - */ -function user_validate_name($name) { - if (!$name) { - return t('You must enter a username.'); - } - if (substr($name, 0, 1) == ' ') { - return t('The username cannot begin with a space.'); - } - if (substr($name, -1) == ' ') { - return t('The username cannot end with a space.'); - } - if (strpos($name, ' ') !== FALSE) { - return t('The username cannot contain multiple spaces in a row.'); - } - if (preg_match('/[^\x{80}-\x{F7} a-z0-9@_.\'-]/i', $name)) { - return t('The username contains an illegal character.'); - } - if (preg_match('/[\x{80}-\x{A0}' . // Non-printable ISO-8859-1 + NBSP - '\x{AD}' . // Soft-hyphen - '\x{2000}-\x{200F}' . // Various space characters - '\x{2028}-\x{202F}' . // Bidirectional text overrides - '\x{205F}-\x{206F}' . // Various text hinting characters - '\x{FEFF}' . // Byte order mark - '\x{FF01}-\x{FF60}' . // Full-width latin - '\x{FFF9}-\x{FFFD}' . // Replacement characters - '\x{0}-\x{1F}]/u', // NULL byte and control characters - $name)) { - return t('The username contains an illegal character.'); - } - if (drupal_strlen($name) > USERNAME_MAX_LENGTH) { - return t('The username %name is too long: it must be %max characters or less.', array('%name' => $name, '%max' => USERNAME_MAX_LENGTH)); - } -} - -/** - * Validates a user's email address. - * - * Checks that a user's email address exists and follows all standard - * validation rules. Returns error messages when the address is invalid. - * - * @param $mail - * A user's email address. - * - * @return - * If the address is invalid, a human-readable error message is returned. - * If the address is valid, nothing is returned. - */ -function user_validate_mail($mail) { - if (!$mail) { - return t('You must enter an e-mail address.'); - } - if (!valid_email_address($mail)) { - return t('The e-mail address %mail is not valid.', array('%mail' => $mail)); - } -} - -/** - * Validates an image uploaded by a user. - * - * @see user_account_form() - */ -function user_validate_picture(&$form, &$form_state) { - // If required, validate the uploaded picture. - $validators = array( - 'file_validate_is_image' => array(), - 'file_validate_image_resolution' => array(variable_get('user_picture_dimensions', '85x85')), - 'file_validate_size' => array(variable_get('user_picture_file_size', '30') * 1024), - ); - - // Save the file as a temporary file. - $file = file_save_upload('picture_upload', $validators); - if ($file === FALSE) { - form_set_error('picture_upload', t("Failed to upload the picture image; the %directory directory doesn't exist or is not writable.", array('%directory' => variable_get('user_picture_path', 'pictures')))); - } - elseif ($file !== NULL) { - $form_state['values']['picture_upload'] = $file; - } -} - -/** - * Generate a random alphanumeric password. - */ -function user_password($length = 10) { - // This variable contains the list of allowable characters for the - // password. Note that the number 0 and the letter 'O' have been - // removed to avoid confusion between the two. The same is true - // of 'I', 1, and 'l'. - $allowable_characters = 'abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789'; - - // Zero-based count of characters in the allowable list: - $len = strlen($allowable_characters) - 1; - - // Declare the password as a blank string. - $pass = ''; - - // Loop the number of times specified by $length. - for ($i = 0; $i < $length; $i++) { - - // Each iteration, pick a random character from the - // allowable string and append it to the password: - $pass .= $allowable_characters[mt_rand(0, $len)]; - } - - return $pass; -} - -/** - * Determine the permissions for one or more roles. - * - * @param $roles - * An array whose keys are the role IDs of interest, such as $user->roles. - * - * @return - * An array indexed by role ID. Each value is an array whose keys are the - * permission strings for the given role ID. - */ -function user_role_permissions($roles = array()) { - $cache = &drupal_static(__FUNCTION__, array()); - - $role_permissions = $fetch = array(); - - if ($roles) { - foreach ($roles as $rid => $name) { - if (isset($cache[$rid])) { - $role_permissions[$rid] = $cache[$rid]; - } - else { - // Add this rid to the list of those needing to be fetched. - $fetch[] = $rid; - // Prepare in case no permissions are returned. - $cache[$rid] = array(); - } - } - - if ($fetch) { - // Get from the database permissions that were not in the static variable. - // Only role IDs with at least one permission assigned will return rows. - $result = db_query("SELECT rid, permission FROM {role_permission} WHERE rid IN (:fetch)", array(':fetch' => $fetch)); - - foreach ($result as $row) { - $cache[$row->rid][$row->permission] = TRUE; - } - foreach ($fetch as $rid) { - // For every rid, we know we at least assigned an empty array. - $role_permissions[$rid] = $cache[$rid]; - } - } - } - - return $role_permissions; -} - -/** - * Determine whether the user has a given privilege. - * - * @param $string - * The permission, such as "administer nodes", being checked for. - * @param $account - * (optional) The account to check, if not given use currently logged in user. - * - * @return - * Boolean TRUE if the current user has the requested permission. - * - * All permission checks in Drupal should go through this function. This - * way, we guarantee consistent behavior, and ensure that the superuser - * can perform all actions. - */ -function user_access($string, $account = NULL) { - global $user; - - if (!isset($account)) { - $account = $user; - } - - // User #1 has all privileges: - if ($account->uid == 1) { - return TRUE; - } - - // To reduce the number of SQL queries, we cache the user's permissions - // in a static variable. - // Use the advanced drupal_static() pattern, since this is called very often. - static $drupal_static_fast; - if (!isset($drupal_static_fast)) { - $drupal_static_fast['perm'] = &drupal_static(__FUNCTION__); - } - $perm = &$drupal_static_fast['perm']; - if (!isset($perm[$account->uid])) { - $role_permissions = user_role_permissions($account->roles); - - $perms = array(); - foreach ($role_permissions as $one_role) { - $perms += $one_role; - } - $perm[$account->uid] = $perms; - } - - return isset($perm[$account->uid][$string]); -} - -/** - * Checks for usernames blocked by user administration. - * - * @param $name - * A string containing a name of the user. - * - * @return - * Object with property 'name' (the user name), if the user is blocked; - * FALSE if the user is not blocked. - */ -function user_is_blocked($name) { - return db_select('users') - ->fields('users', array('name')) - ->condition('name', db_like($name), 'LIKE') - ->condition('status', 0) - ->execute()->fetchObject(); -} - -/** - * Implements hook_permission(). - */ -function user_permission() { - return array( - 'administer permissions' => array( - 'title' => t('Administer permissions'), - 'restrict access' => TRUE, - ), - 'administer users' => array( - 'title' => t('Administer users'), - 'restrict access' => TRUE, - ), - 'access user profiles' => array( - 'title' => t('View user profiles'), - ), - 'change own username' => array( - 'title' => t('Change own username'), - ), - 'cancel account' => array( - 'title' => t('Cancel own user account'), - 'description' => t('Note: content may be kept, unpublished, deleted or transferred to the %anonymous-name user depending on the configured user settings.', array('%anonymous-name' => variable_get('anonymous', t('Anonymous')), '@user-settings-url' => url('admin/config/people/accounts'))), - ), - 'select account cancellation method' => array( - 'title' => t('Select method for cancelling own account'), - 'restrict access' => TRUE, - ), - ); -} - -/** - * Implements hook_file_download(). - * - * Ensure that user pictures (avatars) are always downloadable. - */ -function user_file_download($uri) { - if (strpos(file_uri_target($uri), variable_get('user_picture_path', 'pictures') . '/picture-') === 0) { - $info = image_get_info($uri); - return array('Content-Type' => $info['mime_type']); - } -} - -/** - * Implements hook_file_move(). - */ -function user_file_move($file, $source) { - // If a user's picture is replaced with a new one, update the record in - // the users table. - if (isset($file->fid) && isset($source->fid) && $file->fid != $source->fid) { - db_update('users') - ->fields(array( - 'picture' => $file->fid, - )) - ->condition('picture', $source->fid) - ->execute(); - } -} - -/** - * Implements hook_file_delete(). - */ -function user_file_delete($file) { - // Remove any references to the file. - db_update('users') - ->fields(array('picture' => 0)) - ->condition('picture', $file->fid) - ->execute(); -} - -/** - * Implements hook_search_info(). - */ -function user_search_info() { - return array( - 'title' => 'Users', - ); -} - -/** - * Implements hook_search_access(). - */ -function user_search_access() { - return user_access('access user profiles'); -} - -/** - * Implements hook_search_execute(). - */ -function user_search_execute($keys = NULL, $conditions = NULL) { - $find = array(); - // Replace wildcards with MySQL/PostgreSQL wildcards. - $keys = preg_replace('!\*+!', '%', $keys); - $query = db_select('users')->extend('PagerDefault'); - $query->fields('users', array('uid')); - if (user_access('administer users')) { - // Administrators can also search in the otherwise private email field. - $query->fields('users', array('mail')); - $query->condition(db_or()-> - condition('name', '%' . db_like($keys) . '%', 'LIKE')-> - condition('mail', '%' . db_like($keys) . '%', 'LIKE')); - } - else { - $query->condition('name', '%' . db_like($keys) . '%', 'LIKE'); - } - $uids = $query - ->limit(15) - ->execute() - ->fetchCol(); - $accounts = user_load_multiple($uids); - - $results = array(); - foreach ($accounts as $account) { - $result = array( - 'title' => format_username($account), - 'link' => url('user/' . $account->uid, array('absolute' => TRUE)), - ); - if (user_access('administer users')) { - $result['title'] .= ' (' . $account->mail . ')'; - } - $results[] = $result; - } - - return $results; -} - -/** - * Implements hook_element_info(). - */ -function user_element_info() { - $types['user_profile_category'] = array( - '#theme_wrappers' => array('user_profile_category'), - ); - $types['user_profile_item'] = array( - '#theme' => 'user_profile_item', - ); - return $types; -} - -/** - * Implements hook_user_view(). - */ -function user_user_view($account) { - $account->content['user_picture'] = array( - '#markup' => theme('user_picture', array('account' => $account)), - '#weight' => -10, - ); - if (!isset($account->content['summary'])) { - $account->content['summary'] = array(); - } - $account->content['summary'] += array( - '#type' => 'user_profile_category', - '#attributes' => array('class' => array('user-member')), - '#weight' => 5, - '#title' => t('History'), - ); - $account->content['summary']['member_for'] = array( - '#type' => 'user_profile_item', - '#title' => t('Member for'), - '#markup' => format_interval(REQUEST_TIME - $account->created), - ); -} - -/** - * Helper function to add default user account fields to user registration and edit form. - * - * @see user_account_form_validate() - * @see user_validate_current_pass() - * @see user_validate_picture() - * @see user_validate_mail() - */ -function user_account_form(&$form, &$form_state) { - global $user; - - $account = $form['#user']; - $register = ($form['#user']->uid > 0 ? FALSE : TRUE); - - $admin = user_access('administer users'); - - $form['#validate'][] = 'user_account_form_validate'; - - // Account information. - $form['account'] = array( - '#type' => 'container', - '#weight' => -10, - ); - // Only show name field on registration form or user can change own username. - $form['account']['name'] = array( - '#type' => 'textfield', - '#title' => t('Username'), - '#maxlength' => USERNAME_MAX_LENGTH, - '#description' => t('Spaces are allowed; punctuation is not allowed except for periods, hyphens, apostrophes, and underscores.'), - '#required' => TRUE, - '#attributes' => array('class' => array('username')), - '#default_value' => (!$register ? $account->name : ''), - '#access' => ($register || ($user->uid == $account->uid && user_access('change own username')) || $admin), - '#weight' => -10, - ); - - $form['account']['mail'] = array( - '#type' => 'textfield', - '#title' => t('E-mail address'), - '#maxlength' => EMAIL_MAX_LENGTH, - '#description' => t('A valid e-mail address. All e-mails from the system will be sent to this address. The e-mail address is not made public and will only be used if you wish to receive a new password or wish to receive certain news or notifications by e-mail.'), - '#required' => TRUE, - '#default_value' => (!$register ? $account->mail : ''), - ); - - // Display password field only for existing users or when user is allowed to - // assign a password during registration. - if (!$register) { - $form['account']['pass'] = array( - '#type' => 'password_confirm', - '#size' => 25, - '#description' => t('To change the current user password, enter the new password in both fields.'), - ); - // To skip the current password field, the user must have logged in via a - // one-time link and have the token in the URL. - $pass_reset = isset($_SESSION['pass_reset_' . $account->uid]) && isset($_GET['pass-reset-token']) && ($_GET['pass-reset-token'] == $_SESSION['pass_reset_' . $account->uid]); - $protected_values = array(); - $current_pass_description = ''; - // The user may only change their own password without their current - // password if they logged in via a one-time login link. - if (!$pass_reset) { - $protected_values['mail'] = $form['account']['mail']['#title']; - $protected_values['pass'] = t('Password'); - $request_new = l(t('Request new password'), 'user/password', array('attributes' => array('title' => t('Request new password via e-mail.')))); - $current_pass_description = t('Enter your current password to change the %mail or %pass. !request_new.', array('%mail' => $protected_values['mail'], '%pass' => $protected_values['pass'], '!request_new' => $request_new)); - } - // The user must enter their current password to change to a new one. - if ($user->uid == $account->uid) { - $form['account']['current_pass_required_values'] = array( - '#type' => 'value', - '#value' => $protected_values, - ); - $form['account']['current_pass'] = array( - '#type' => 'password', - '#title' => t('Current password'), - '#size' => 25, - '#access' => !empty($protected_values), - '#description' => $current_pass_description, - '#weight' => -5, - '#attributes' => array('autocomplete' => 'off'), - ); - $form['#validate'][] = 'user_validate_current_pass'; - } - } - elseif (!variable_get('user_email_verification', TRUE) || $admin) { - $form['account']['pass'] = array( - '#type' => 'password_confirm', - '#size' => 25, - '#description' => t('Provide a password for the new account in both fields.'), - '#required' => TRUE, - ); - } - - if ($admin) { - $status = isset($account->status) ? $account->status : 1; - } - else { - $status = $register ? variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL) == USER_REGISTER_VISITORS : $account->status; - } - $form['account']['status'] = array( - '#type' => 'radios', - '#title' => t('Status'), - '#default_value' => $status, - '#options' => array(t('Blocked'), t('Active')), - '#access' => $admin, - ); - - $roles = array_map('check_plain', user_roles(TRUE)); - // The disabled checkbox subelement for the 'authenticated user' role - // must be generated separately and added to the checkboxes element, - // because of a limitation in Form API not supporting a single disabled - // checkbox within a set of checkboxes. - // @todo This should be solved more elegantly. See issue #119038. - $checkbox_authenticated = array( - '#type' => 'checkbox', - '#title' => $roles[DRUPAL_AUTHENTICATED_RID], - '#default_value' => TRUE, - '#disabled' => TRUE, - ); - unset($roles[DRUPAL_AUTHENTICATED_RID]); - $form['account']['roles'] = array( - '#type' => 'checkboxes', - '#title' => t('Roles'), - '#default_value' => (!$register && isset($account->roles) ? array_keys($account->roles) : array()), - '#options' => $roles, - '#access' => $roles && user_access('administer permissions'), - DRUPAL_AUTHENTICATED_RID => $checkbox_authenticated, - ); - - $form['account']['notify'] = array( - '#type' => 'checkbox', - '#title' => t('Notify user of new account'), - '#access' => $register && $admin, - ); - - // Signature. - $form['signature_settings'] = array( - '#type' => 'fieldset', - '#title' => t('Signature settings'), - '#weight' => 1, - '#access' => (!$register && variable_get('user_signatures', 0)), - ); - - $form['signature_settings']['signature'] = array( - '#type' => 'text_format', - '#title' => t('Signature'), - '#default_value' => isset($account->signature) ? $account->signature : '', - '#description' => t('Your signature will be publicly displayed at the end of your comments.'), - '#format' => isset($account->signature_format) ? $account->signature_format : NULL, - ); - - // Picture/avatar. - $form['picture'] = array( - '#type' => 'fieldset', - '#title' => t('Picture'), - '#weight' => 1, - '#access' => (!$register && variable_get('user_pictures', 0)), - ); - $form['picture']['picture'] = array( - '#type' => 'value', - '#value' => isset($account->picture) ? $account->picture : NULL, - ); - $form['picture']['picture_current'] = array( - '#markup' => theme('user_picture', array('account' => $account)), - ); - $form['picture']['picture_delete'] = array( - '#type' => 'checkbox', - '#title' => t('Delete picture'), - '#access' => !empty($account->picture->fid), - '#description' => t('Check this box to delete your current picture.'), - ); - $form['picture']['picture_upload'] = array( - '#type' => 'file', - '#title' => t('Upload picture'), - '#size' => 48, - '#description' => t('Your virtual face or picture. Pictures larger than @dimensions pixels will be scaled down.', array('@dimensions' => variable_get('user_picture_dimensions', '85x85'))) . ' ' . filter_xss_admin(variable_get('user_picture_guidelines', '')), - ); - $form['#validate'][] = 'user_validate_picture'; -} - -/** - * Form validation handler for the current password on the user_account_form(). - * - * @see user_account_form() - */ -function user_validate_current_pass(&$form, &$form_state) { - $account = $form['#user']; - foreach ($form_state['values']['current_pass_required_values'] as $key => $name) { - // This validation only works for required textfields (like mail) or - // form values like password_confirm that have their own validation - // that prevent them from being empty if they are changed. - if ((strlen(trim($form_state['values'][$key])) > 0) && ($form_state['values'][$key] != $account->$key)) { - require_once DRUPAL_ROOT . '/' . variable_get('password_inc', 'includes/password.inc'); - $current_pass_failed = empty($form_state['values']['current_pass']) || !user_check_password($form_state['values']['current_pass'], $account); - if ($current_pass_failed) { - form_set_error('current_pass', t("Your current password is missing or incorrect; it's required to change the %name.", array('%name' => $name))); - form_set_error($key); - } - // We only need to check the password once. - break; - } - } -} - -/** - * Form validation handler for user_account_form(). - * - * @see user_account_form() - */ -function user_account_form_validate($form, &$form_state) { - if ($form['#user_category'] == 'account' || $form['#user_category'] == 'register') { - $account = $form['#user']; - // Validate new or changing username. - if (isset($form_state['values']['name'])) { - if ($error = user_validate_name($form_state['values']['name'])) { - form_set_error('name', $error); - } - elseif ((bool) db_select('users')->fields('users', array('uid'))->condition('uid', $account->uid, '<>')->condition('name', db_like($form_state['values']['name']), 'LIKE')->range(0, 1)->execute()->fetchField()) { - form_set_error('name', t('The name %name is already taken.', array('%name' => $form_state['values']['name']))); - } - } - - // Trim whitespace from mail, to prevent confusing 'e-mail not valid' - // warnings often caused by cutting and pasting. - $mail = trim($form_state['values']['mail']); - form_set_value($form['account']['mail'], $mail, $form_state); - - // Validate the e-mail address, and check if it is taken by an existing user. - if ($error = user_validate_mail($form_state['values']['mail'])) { - form_set_error('mail', $error); - } - elseif ((bool) db_select('users')->fields('users', array('uid'))->condition('uid', $account->uid, '<>')->condition('mail', db_like($form_state['values']['mail']), 'LIKE')->range(0, 1)->execute()->fetchField()) { - // Format error message dependent on whether the user is logged in or not. - if ($GLOBALS['user']->uid) { - form_set_error('mail', t('The e-mail address %email is already taken.', array('%email' => $form_state['values']['mail']))); - } - else { - form_set_error('mail', t('The e-mail address %email is already registered. Have you forgotten your password?', array('%email' => $form_state['values']['mail'], '@password' => url('user/password')))); - } - } - - // Make sure the signature isn't longer than the size of the database field. - // Signatures are disabled by default, so make sure it exists first. - if (isset($form_state['values']['signature'])) { - // Move text format for user signature into 'signature_format'. - $form_state['values']['signature_format'] = $form_state['values']['signature']['format']; - // Move text value for user signature into 'signature'. - $form_state['values']['signature'] = $form_state['values']['signature']['value']; - - $user_schema = drupal_get_schema('users'); - if (drupal_strlen($form_state['values']['signature']) > $user_schema['fields']['signature']['length']) { - form_set_error('signature', t('The signature is too long: it must be %max characters or less.', array('%max' => $user_schema['fields']['signature']['length']))); - } - } - } -} - -/** - * Implements hook_user_presave(). - */ -function user_user_presave(&$edit, $account, $category) { - if ($category == 'account' || $category == 'register') { - if (!empty($edit['picture_upload'])) { - $edit['picture'] = $edit['picture_upload']; - } - // Delete picture if requested, and if no replacement picture was given. - elseif (!empty($edit['picture_delete'])) { - $edit['picture'] = NULL; - } - // Prepare user roles. - if (isset($edit['roles'])) { - $edit['roles'] = array_filter($edit['roles']); - } - } - - // Move account cancellation information into $user->data. - foreach (array('user_cancel_method', 'user_cancel_notify') as $key) { - if (isset($edit[$key])) { - $edit['data'][$key] = $edit[$key]; - } - } -} - -/** - * Implements hook_user_categories(). - */ -function user_user_categories() { - return array(array( - 'name' => 'account', - 'title' => t('Account settings'), - 'weight' => 1, - )); -} - -function user_login_block($form) { - $form['#action'] = url(current_path(), array('query' => drupal_get_destination(), 'external' => FALSE)); - $form['#id'] = 'user-login-form'; - $form['#validate'] = user_login_default_validators(); - $form['#submit'][] = 'user_login_submit'; - $form['name'] = array('#type' => 'textfield', - '#title' => t('Username'), - '#maxlength' => USERNAME_MAX_LENGTH, - '#size' => 15, - '#required' => TRUE, - ); - $form['pass'] = array('#type' => 'password', - '#title' => t('Password'), - '#size' => 15, - '#required' => TRUE, - ); - $form['actions'] = array('#type' => 'actions'); - $form['actions']['submit'] = array('#type' => 'submit', - '#value' => t('Log in'), - ); - $items = array(); - if (variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL)) { - $items[] = l(t('Create new account'), 'user/register', array('attributes' => array('title' => t('Create a new user account.')))); - } - $items[] = l(t('Request new password'), 'user/password', array('attributes' => array('title' => t('Request new password via e-mail.')))); - $form['links'] = array('#markup' => theme('item_list', array('items' => $items))); - return $form; -} - -/** - * Implements hook_block_info(). - */ -function user_block_info() { - global $user; - - $blocks['login']['info'] = t('User login'); - // Not worth caching. - $blocks['login']['cache'] = DRUPAL_NO_CACHE; - - $blocks['new']['info'] = t('Who\'s new'); - $blocks['new']['properties']['administrative'] = TRUE; - - // Too dynamic to cache. - $blocks['online']['info'] = t('Who\'s online'); - $blocks['online']['cache'] = DRUPAL_NO_CACHE; - $blocks['online']['properties']['administrative'] = TRUE; - - return $blocks; -} - -/** - * Implements hook_block_configure(). - */ -function user_block_configure($delta = '') { - global $user; - - switch ($delta) { - case 'new': - $form['user_block_whois_new_count'] = array( - '#type' => 'select', - '#title' => t('Number of users to display'), - '#default_value' => variable_get('user_block_whois_new_count', 5), - '#options' => drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)), - ); - return $form; - - case 'online': - $period = drupal_map_assoc(array(30, 60, 120, 180, 300, 600, 900, 1800, 2700, 3600, 5400, 7200, 10800, 21600, 43200, 86400), 'format_interval'); - $form['user_block_seconds_online'] = array('#type' => 'select', '#title' => t('User activity'), '#default_value' => variable_get('user_block_seconds_online', 900), '#options' => $period, '#description' => t('A user is considered online for this long after they have last viewed a page.')); - $form['user_block_max_list_count'] = array('#type' => 'select', '#title' => t('User list length'), '#default_value' => variable_get('user_block_max_list_count', 10), '#options' => drupal_map_assoc(array(0, 5, 10, 15, 20, 25, 30, 40, 50, 75, 100)), '#description' => t('Maximum number of currently online users to display.')); - return $form; - } -} - -/** - * Implements hook_block_save(). - */ -function user_block_save($delta = '', $edit = array()) { - global $user; - - switch ($delta) { - case 'new': - variable_set('user_block_whois_new_count', $edit['user_block_whois_new_count']); - break; - - case 'online': - variable_set('user_block_seconds_online', $edit['user_block_seconds_online']); - variable_set('user_block_max_list_count', $edit['user_block_max_list_count']); - break; - } -} - -/** - * Implements hook_block_view(). - */ -function user_block_view($delta = '') { - global $user; - - $block = array(); - - switch ($delta) { - case 'login': - // For usability's sake, avoid showing two login forms on one page. - if (!$user->uid && !(arg(0) == 'user' && !is_numeric(arg(1)))) { - - $block['subject'] = t('User login'); - $block['content'] = drupal_get_form('user_login_block'); - } - return $block; - - case 'new': - if (user_access('access content')) { - // Retrieve a list of new users who have subsequently accessed the site successfully. - $items = db_query_range('SELECT uid, name FROM {users} WHERE status <> 0 AND access <> 0 ORDER BY created DESC', 0, variable_get('user_block_whois_new_count', 5))->fetchAll(); - $output = theme('user_list', array('users' => $items)); - - $block['subject'] = t('Who\'s new'); - $block['content'] = $output; - } - return $block; - - case 'online': - if (user_access('access content')) { - // Count users active within the defined period. - $interval = REQUEST_TIME - variable_get('user_block_seconds_online', 900); - - // Perform database queries to gather online user lists. We use s.timestamp - // rather than u.access because it is much faster. - $authenticated_count = db_query("SELECT COUNT(DISTINCT s.uid) FROM {sessions} s WHERE s.timestamp >= :timestamp AND s.uid > 0", array(':timestamp' => $interval))->fetchField(); - - $output = '' . format_plural($authenticated_count, 'There is currently 1 user online.', 'There are currently @count users online.') . '
'; - - // Display a list of currently online users. - $max_users = variable_get('user_block_max_list_count', 10); - if ($authenticated_count && $max_users) { - $items = db_query_range('SELECT u.uid, u.name, MAX(s.timestamp) AS max_timestamp FROM {users} u INNER JOIN {sessions} s ON u.uid = s.uid WHERE s.timestamp >= :interval AND s.uid > 0 GROUP BY u.uid, u.name ORDER BY max_timestamp DESC', 0, $max_users, array(':interval' => $interval))->fetchAll(); - $output .= theme('user_list', array('users' => $items)); - } - - $block['subject'] = t('Who\'s online'); - $block['content'] = $output; - } - return $block; - } -} - -/** - * Process variables for user-picture.tpl.php. - * - * The $variables array contains the following arguments: - * - $account: A user, node or comment object with 'name', 'uid' and 'picture' - * fields. - * - * @see user-picture.tpl.php - */ -function template_preprocess_user_picture(&$variables) { - $variables['user_picture'] = ''; - if (variable_get('user_pictures', 0)) { - $account = $variables['account']; - if (!empty($account->picture)) { - // @TODO: Ideally this function would only be passed file objects, but - // since there's a lot of legacy code that JOINs the {users} table to - // {node} or {comments} and passes the results into this function if we - // a numeric value in the picture field we'll assume it's a file id - // and load it for them. Once we've got user_load_multiple() and - // comment_load_multiple() functions the user module will be able to load - // the picture files in mass during the object's load process. - if (is_numeric($account->picture)) { - $account->picture = file_load($account->picture); - } - if (!empty($account->picture->uri)) { - $filepath = $account->picture->uri; - } - } - elseif (variable_get('user_picture_default', '')) { - $filepath = variable_get('user_picture_default', ''); - } - if (isset($filepath)) { - $alt = t("@user's picture", array('@user' => format_username($account))); - // If the image does not have a valid Drupal scheme (for eg. HTTP), - // don't load image styles. - if (module_exists('image') && file_valid_uri($filepath) && $style = variable_get('user_picture_style', '')) { - $variables['user_picture'] = theme('image_style', array('style_name' => $style, 'path' => $filepath, 'alt' => $alt, 'title' => $alt)); - } - else { - $variables['user_picture'] = theme('image', array('path' => $filepath, 'alt' => $alt, 'title' => $alt)); - } - if (!empty($account->uid) && user_access('access user profiles')) { - $attributes = array('attributes' => array('title' => t('View user profile.')), 'html' => TRUE); - $variables['user_picture'] = l($variables['user_picture'], "user/$account->uid", $attributes); - } - } - } -} - -/** - * Returns HTML for a list of users. - * - * @param $variables - * An associative array containing: - * - users: An array with user objects. Should contain at least the name and - * uid. - * - title: (optional) Title to pass on to theme_item_list(). - * - * @ingroup themeable - */ -function theme_user_list($variables) { - $users = $variables['users']; - $title = $variables['title']; - $items = array(); - - if (!empty($users)) { - foreach ($users as $user) { - $items[] = theme('username', array('account' => $user)); - } - } - return theme('item_list', array('items' => $items, 'title' => $title)); -} - -function user_is_anonymous() { - // Menu administrators can see items for anonymous when administering. - return !$GLOBALS['user']->uid || !empty($GLOBALS['menu_admin']); -} - -function user_is_logged_in() { - return (bool) $GLOBALS['user']->uid; -} - -function user_register_access() { - return user_is_anonymous() && variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL); -} - -/** - * User view access callback. - * - * @param $account - * Can either be a full user object or a $uid. - */ -function user_view_access($account) { - $uid = is_object($account) ? $account->uid : (int) $account; - - // Never allow access to view the anonymous user account. - if ($uid) { - // Admins can view all, users can view own profiles at all times. - if ($GLOBALS['user']->uid == $uid || user_access('administer users')) { - return TRUE; - } - elseif (user_access('access user profiles')) { - // At this point, load the complete account object. - if (!is_object($account)) { - $account = user_load($uid); - } - return (is_object($account) && $account->status); - } - } - return FALSE; -} - -/** - * Access callback for user account editing. - */ -function user_edit_access($account) { - return (($GLOBALS['user']->uid == $account->uid) || user_access('administer users')) && $account->uid > 0; -} - -/** - * Menu access callback; limit access to account cancellation pages. - * - * Limit access to users with the 'cancel account' permission or administrative - * users, and prevent the anonymous user from cancelling the account. - */ -function user_cancel_access($account) { - return ((($GLOBALS['user']->uid == $account->uid) && user_access('cancel account')) || user_access('administer users')) && $account->uid > 0; -} - -/** - * Implements hook_menu(). - */ -function user_menu() { - $items['user/autocomplete'] = array( - 'title' => 'User autocomplete', - 'page callback' => 'user_autocomplete', - 'access callback' => 'user_access', - 'access arguments' => array('access user profiles'), - 'type' => MENU_CALLBACK, - 'file' => 'user.pages.inc', - ); - - // Registration and login pages. - $items['user'] = array( - 'title' => 'User account', - 'title callback' => 'user_menu_title', - 'page callback' => 'user_page', - 'access callback' => TRUE, - 'file' => 'user.pages.inc', - 'weight' => -10, - 'menu_name' => 'user-menu', - ); - - $items['user/login'] = array( - 'title' => 'Log in', - 'access callback' => 'user_is_anonymous', - 'type' => MENU_DEFAULT_LOCAL_TASK, - ); - - $items['user/register'] = array( - 'title' => 'Create new account', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('user_register_form'), - 'access callback' => 'user_register_access', - 'type' => MENU_LOCAL_TASK, - ); - - $items['user/password'] = array( - 'title' => 'Request new password', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('user_pass'), - 'access callback' => TRUE, - 'type' => MENU_LOCAL_TASK, - 'file' => 'user.pages.inc', - ); - $items['user/reset/%/%/%'] = array( - 'title' => 'Reset password', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('user_pass_reset', 2, 3, 4), - 'access callback' => TRUE, - 'type' => MENU_CALLBACK, - 'file' => 'user.pages.inc', - ); - - $items['user/logout'] = array( - 'title' => 'Log out', - 'access callback' => 'user_is_logged_in', - 'page callback' => 'user_logout', - 'weight' => 10, - 'menu_name' => 'user-menu', - 'file' => 'user.pages.inc', - ); - - // User listing pages. - $items['admin/people'] = array( - 'title' => 'People', - 'description' => 'Manage user accounts, roles, and permissions.', - 'page callback' => 'user_admin', - 'page arguments' => array('list'), - 'access arguments' => array('administer users'), - 'position' => 'left', - 'weight' => -4, - 'file' => 'user.admin.inc', - ); - $items['admin/people/people'] = array( - 'title' => 'List', - 'description' => 'Find and manage people interacting with your site.', - 'access arguments' => array('administer users'), - 'type' => MENU_DEFAULT_LOCAL_TASK, - 'weight' => -10, - 'file' => 'user.admin.inc', - ); - - // Permissions and role forms. - $items['admin/people/permissions'] = array( - 'title' => 'Permissions', - 'description' => 'Determine access to features by selecting permissions for roles.', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('user_admin_permissions'), - 'access arguments' => array('administer permissions'), - 'file' => 'user.admin.inc', - 'type' => MENU_LOCAL_TASK, - ); - $items['admin/people/permissions/list'] = array( - 'title' => 'Permissions', - 'description' => 'Determine access to features by selecting permissions for roles.', - 'type' => MENU_DEFAULT_LOCAL_TASK, - 'weight' => -8, - ); - $items['admin/people/permissions/roles'] = array( - 'title' => 'Roles', - 'description' => 'List, edit, or add user roles.', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('user_admin_roles'), - 'access arguments' => array('administer permissions'), - 'file' => 'user.admin.inc', - 'type' => MENU_LOCAL_TASK, - 'weight' => -5, - ); - $items['admin/people/permissions/roles/edit/%user_role'] = array( - 'title' => 'Edit role', - 'page arguments' => array('user_admin_role', 5), - 'access callback' => 'user_role_edit_access', - 'access arguments' => array(5), - ); - $items['admin/people/permissions/roles/delete/%user_role'] = array( - 'title' => 'Delete role', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('user_admin_role_delete_confirm', 5), - 'access callback' => 'user_role_edit_access', - 'access arguments' => array(5), - 'file' => 'user.admin.inc', - ); - - $items['admin/people/create'] = array( - 'title' => 'Add user', - 'page arguments' => array('create'), - 'access arguments' => array('administer users'), - 'type' => MENU_LOCAL_ACTION, - ); - - // Administration pages. - $items['admin/config/people'] = array( - 'title' => 'People', - 'description' => 'Configure user accounts.', - 'position' => 'left', - 'weight' => -20, - 'page callback' => 'system_admin_menu_block_page', - 'access arguments' => array('access administration pages'), - 'file' => 'system.admin.inc', - 'file path' => drupal_get_path('module', 'system'), - ); - $items['admin/config/people/accounts'] = array( - 'title' => 'Account settings', - 'description' => 'Configure default behavior of users, including registration requirements, e-mails, fields, and user pictures.', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('user_admin_settings'), - 'access arguments' => array('administer users'), - 'file' => 'user.admin.inc', - 'weight' => -10, - ); - $items['admin/config/people/accounts/settings'] = array( - 'title' => 'Settings', - 'type' => MENU_DEFAULT_LOCAL_TASK, - 'weight' => -10, - ); - - $items['user/%user'] = array( - 'title' => 'My account', - 'title callback' => 'user_page_title', - 'title arguments' => array(1), - 'page callback' => 'user_view_page', - 'page arguments' => array(1), - 'access callback' => 'user_view_access', - 'access arguments' => array(1), - // By assigning a different menu name, this item (and all registered child - // paths) are no longer considered as children of 'user'. When accessing the - // user account pages, the preferred menu link that is used to build the - // active trail (breadcrumb) will be found in this menu (unless there is - // more specific link), so the link to 'user' will not be in the breadcrumb. - 'menu_name' => 'navigation', - ); - - $items['user/%user/view'] = array( - 'title' => 'View', - 'type' => MENU_DEFAULT_LOCAL_TASK, - 'weight' => -10, - ); - - $items['user/%user/cancel'] = array( - 'title' => 'Cancel account', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('user_cancel_confirm_form', 1), - 'access callback' => 'user_cancel_access', - 'access arguments' => array(1), - 'file' => 'user.pages.inc', - ); - - $items['user/%user/cancel/confirm/%/%'] = array( - 'title' => 'Confirm account cancellation', - 'page callback' => 'user_cancel_confirm', - 'page arguments' => array(1, 4, 5), - 'access callback' => 'user_cancel_access', - 'access arguments' => array(1), - 'file' => 'user.pages.inc', - ); - - $items['user/%user/edit'] = array( - 'title' => 'Edit', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('user_profile_form', 1), - 'access callback' => 'user_edit_access', - 'access arguments' => array(1), - 'type' => MENU_LOCAL_TASK, - 'file' => 'user.pages.inc', - ); - - $items['user/%user_category/edit/account'] = array( - 'title' => 'Account', - 'type' => MENU_DEFAULT_LOCAL_TASK, - 'load arguments' => array('%map', '%index'), - ); - - if (($categories = _user_categories()) && (count($categories) > 1)) { - foreach ($categories as $key => $category) { - // 'account' is already handled by the MENU_DEFAULT_LOCAL_TASK. - if ($category['name'] != 'account') { - $items['user/%user_category/edit/' . $category['name']] = array( - 'title callback' => 'check_plain', - 'title arguments' => array($category['title']), - 'page callback' => 'drupal_get_form', - 'page arguments' => array('user_profile_form', 1, 3), - 'access callback' => isset($category['access callback']) ? $category['access callback'] : 'user_edit_access', - 'access arguments' => isset($category['access arguments']) ? $category['access arguments'] : array(1), - 'type' => MENU_LOCAL_TASK, - 'weight' => $category['weight'], - 'load arguments' => array('%map', '%index'), - 'tab_parent' => 'user/%/edit', - 'file' => 'user.pages.inc', - ); - } - } - } - return $items; -} - -/** - * Implements hook_menu_site_status_alter(). - */ -function user_menu_site_status_alter(&$menu_site_status, $path) { - if ($menu_site_status == MENU_SITE_OFFLINE) { - // If the site is offline, log out unprivileged users. - if (user_is_logged_in() && !user_access('access site in maintenance mode')) { - module_load_include('pages.inc', 'user', 'user'); - user_logout(); - } - - if (user_is_anonymous()) { - switch ($path) { - case 'user': - // Forward anonymous user to login page. - drupal_goto('user/login'); - case 'user/login': - case 'user/password': - // Disable offline mode. - $menu_site_status = MENU_SITE_ONLINE; - break; - default: - if (strpos($path, 'user/reset/') === 0) { - // Disable offline mode. - $menu_site_status = MENU_SITE_ONLINE; - } - break; - } - } - } - if (user_is_logged_in()) { - if ($path == 'user/login') { - // If user is logged in, redirect to 'user' instead of giving 403. - drupal_goto('user'); - } - if ($path == 'user/register') { - // Authenticated user should be redirected to user edit page. - drupal_goto('user/' . $GLOBALS['user']->uid . '/edit'); - } - } -} - -/** - * Implements hook_menu_link_alter(). - */ -function user_menu_link_alter(&$link) { - // The path 'user' must be accessible for anonymous users, but only visible - // for authenticated users. Authenticated users should see "My account", but - // anonymous users should not see it at all. Therefore, invoke - // user_translated_menu_link_alter() to conditionally hide the link. - if ($link['link_path'] == 'user' && $link['module'] == 'system') { - $link['options']['alter'] = TRUE; - } - - // Force the Logout link to appear on the top-level of 'user-menu' menu by - // default (i.e., unless it has been customized). - if ($link['link_path'] == 'user/logout' && $link['module'] == 'system' && empty($link['customized'])) { - $link['plid'] = 0; - } -} - -/** - * Implements hook_translated_menu_link_alter(). - */ -function user_translated_menu_link_alter(&$link) { - // Hide the "User account" link for anonymous users. - if ($link['link_path'] == 'user' && $link['module'] == 'system' && !$GLOBALS['user']->uid) { - $link['hidden'] = 1; - } -} - -/** - * Implements hook_admin_paths(). - */ -function user_admin_paths() { - $paths = array( - 'user/*/cancel' => TRUE, - 'user/*/edit' => TRUE, - 'user/*/edit/*' => TRUE, - ); - return $paths; -} - -/** - * Returns $arg or the user ID of the current user if $arg is '%' or empty. - * - * Deprecated. Use %user_uid_optional instead. - * - * @todo D8: Remove. - */ -function user_uid_only_optional_to_arg($arg) { - return user_uid_optional_to_arg($arg); -} - -/** - * Load either a specified or the current user account. - * - * @param $uid - * An optional user ID of the user to load. If not provided, the current - * user's ID will be used. - * @return - * A fully-loaded $user object upon successful user load, FALSE if user - * cannot be loaded. - * - * @see user_load() - * @todo rethink the naming of this in Drupal 8. - */ -function user_uid_optional_load($uid = NULL) { - if (!isset($uid)) { - $uid = $GLOBALS['user']->uid; - } - return user_load($uid); -} - -/** - * Return a user object after checking if any profile category in the path exists. - */ -function user_category_load($uid, &$map, $index) { - static $user_categories, $accounts; - - // Cache $account - this load function will get called for each profile tab. - if (!isset($accounts[$uid])) { - $accounts[$uid] = user_load($uid); - } - $valid = TRUE; - if ($account = $accounts[$uid]) { - // Since the path is like user/%/edit/category_name, the category name will - // be at a position 2 beyond the index corresponding to the % wildcard. - $category_index = $index + 2; - // Valid categories may contain slashes, and hence need to be imploded. - $category_path = implode('/', array_slice($map, $category_index)); - if ($category_path) { - // Check that the requested category exists. - $valid = FALSE; - if (!isset($user_categories)) { - $user_categories = _user_categories(); - } - foreach ($user_categories as $category) { - if ($category['name'] == $category_path) { - $valid = TRUE; - // Truncate the map array in case the category name had slashes. - $map = array_slice($map, 0, $category_index); - // Assign the imploded category name to the last map element. - $map[$category_index] = $category_path; - break; - } - } - } - } - return $valid ? $account : FALSE; -} - -/** - * Returns $arg or the user ID of the current user if $arg is '%' or empty. - * - * @todo rethink the naming of this in Drupal 8. - */ -function user_uid_optional_to_arg($arg) { - // Give back the current user uid when called from eg. tracker, aka. - // with an empty arg. Also use the current user uid when called from - // the menu with a % for the current account link. - return empty($arg) || $arg == '%' ? $GLOBALS['user']->uid : $arg; -} - -/** - * Menu item title callback for the 'user' path. - * - * Anonymous users should see "User account", but authenticated users are - * expected to see "My account". - */ -function user_menu_title() { - return user_is_logged_in() ? t('My account') : t('User account'); -} - -/** - * Menu item title callback - use the user name. - */ -function user_page_title($account) { - return is_object($account) ? format_username($account) : ''; -} - -/** - * Discover which external authentication module(s) authenticated a username. - * - * @param $authname - * A username used by an external authentication module. - * @return - * An associative array with module as key and username as value. - */ -function user_get_authmaps($authname = NULL) { - $authmaps = db_query("SELECT module, authname FROM {authmap} WHERE authname = :authname", array(':authname' => $authname))->fetchAllKeyed(); - return count($authmaps) ? $authmaps : 0; -} - -/** - * Save mappings of which external authentication module(s) authenticated - * a user. Maps external usernames to user ids in the users table. - * - * @param $account - * A user object. - * @param $authmaps - * An associative array with a compound key and the username as the value. - * The key is made up of 'authname_' plus the name of the external authentication - * module. - * @see user_external_login_register() - */ -function user_set_authmaps($account, $authmaps) { - foreach ($authmaps as $key => $value) { - $module = explode('_', $key, 2); - if ($value) { - db_merge('authmap') - ->key(array( - 'uid' => $account->uid, - 'module' => $module[1], - )) - ->fields(array('authname' => $value)) - ->execute(); - } - else { - db_delete('authmap') - ->condition('uid', $account->uid) - ->condition('module', $module[1]) - ->execute(); - } - } -} - -/** - * Form builder; the main user login form. - * - * @ingroup forms - */ -function user_login($form, &$form_state) { - global $user; - - // If we are already logged on, go to the user page instead. - if ($user->uid) { - drupal_goto('user/' . $user->uid); - } - - // Display login form: - $form['name'] = array('#type' => 'textfield', - '#title' => t('Username'), - '#size' => 60, - '#maxlength' => USERNAME_MAX_LENGTH, - '#required' => TRUE, - ); - - $form['name']['#description'] = t('Enter your @s username.', array('@s' => variable_get('site_name', 'Drupal'))); - $form['pass'] = array('#type' => 'password', - '#title' => t('Password'), - '#description' => t('Enter the password that accompanies your username.'), - '#required' => TRUE, - ); - $form['#validate'] = user_login_default_validators(); - $form['actions'] = array('#type' => 'actions'); - $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Log in')); - - return $form; -} - -/** - * Set up a series for validators which check for blocked users, - * then authenticate against local database, then return an error if - * authentication fails. Distributed authentication modules are welcome - * to use hook_form_alter() to change this series in order to - * authenticate against their user database instead of the local users - * table. If a distributed authentication module is successful, it - * should set $form_state['uid'] to a user ID. - * - * We use three validators instead of one since external authentication - * modules usually only need to alter the second validator. - * - * @see user_login_name_validate() - * @see user_login_authenticate_validate() - * @see user_login_final_validate() - * @return array - * A simple list of validate functions. - */ -function user_login_default_validators() { - return array('user_login_name_validate', 'user_login_authenticate_validate', 'user_login_final_validate'); -} - -/** - * A FAPI validate handler. Sets an error if supplied username has been blocked. - */ -function user_login_name_validate($form, &$form_state) { - if (isset($form_state['values']['name']) && user_is_blocked($form_state['values']['name'])) { - // Blocked in user administration. - form_set_error('name', t('The username %name has not been activated or is blocked.', array('%name' => $form_state['values']['name']))); - } -} - -/** - * A validate handler on the login form. Check supplied username/password - * against local users table. If successful, $form_state['uid'] - * is set to the matching user ID. - */ -function user_login_authenticate_validate($form, &$form_state) { - $password = trim($form_state['values']['pass']); - if (!empty($form_state['values']['name']) && !empty($password)) { - // Do not allow any login from the current user's IP if the limit has been - // reached. Default is 50 failed attempts allowed in one hour. This is - // independent of the per-user limit to catch attempts from one IP to log - // in to many different user accounts. We have a reasonably high limit - // since there may be only one apparent IP for all users at an institution. - if (!flood_is_allowed('failed_login_attempt_ip', variable_get('user_failed_login_ip_limit', 50), variable_get('user_failed_login_ip_window', 3600))) { - $form_state['flood_control_triggered'] = 'ip'; - return; - } - $account = db_query("SELECT * FROM {users} WHERE name = :name AND status = 1", array(':name' => $form_state['values']['name']))->fetchObject(); - if ($account) { - if (variable_get('user_failed_login_identifier_uid_only', FALSE)) { - // Register flood events based on the uid only, so they apply for any - // IP address. This is the most secure option. - $identifier = $account->uid; - } - else { - // The default identifier is a combination of uid and IP address. This - // is less secure but more resistant to denial-of-service attacks that - // could lock out all users with public user names. - $identifier = $account->uid . '-' . ip_address(); - } - $form_state['flood_control_user_identifier'] = $identifier; - - // Don't allow login if the limit for this user has been reached. - // Default is to allow 5 failed attempts every 6 hours. - if (!flood_is_allowed('failed_login_attempt_user', variable_get('user_failed_login_user_limit', 5), variable_get('user_failed_login_user_window', 21600), $identifier)) { - $form_state['flood_control_triggered'] = 'user'; - return; - } - } - // We are not limited by flood control, so try to authenticate. - // Set $form_state['uid'] as a flag for user_login_final_validate(). - $form_state['uid'] = user_authenticate($form_state['values']['name'], $password); - } -} - -/** - * The final validation handler on the login form. - * - * Sets a form error if user has not been authenticated, or if too many - * logins have been attempted. This validation function should always - * be the last one. - */ -function user_login_final_validate($form, &$form_state) { - if (empty($form_state['uid'])) { - // Always register an IP-based failed login event. - flood_register_event('failed_login_attempt_ip', variable_get('user_failed_login_ip_window', 3600)); - // Register a per-user failed login event. - if (isset($form_state['flood_control_user_identifier'])) { - flood_register_event('failed_login_attempt_user', variable_get('user_failed_login_user_window', 21600), $form_state['flood_control_user_identifier']); - } - - if (isset($form_state['flood_control_triggered'])) { - if ($form_state['flood_control_triggered'] == 'user') { - form_set_error('name', format_plural(variable_get('user_failed_login_user_limit', 5), 'Sorry, there has been more than one failed login attempt for this account. It is temporarily blocked. Try again later or request a new password.', 'Sorry, there have been more than @count failed login attempts for this account. It is temporarily blocked. Try again later or request a new password.', array('@url' => url('user/password')))); - } - else { - // We did not find a uid, so the limit is IP-based. - form_set_error('name', t('Sorry, too many failed login attempts from your IP address. This IP address is temporarily blocked. Try again later or request a new password.', array('@url' => url('user/password')))); - } - } - else { - form_set_error('name', t('Sorry, unrecognized username or password. Have you forgotten your password?', array('@password' => url('user/password')))); - watchdog('user', 'Login attempt failed for %user.', array('%user' => $form_state['values']['name'])); - } - } - elseif (isset($form_state['flood_control_user_identifier'])) { - // Clear past failures for this user so as not to block a user who might - // log in and out more than once in an hour. - flood_clear_event('failed_login_attempt_user', $form_state['flood_control_user_identifier']); - } -} - -/** - * Try to validate the user's login credentials locally. - * - * @param $name - * User name to authenticate. - * @param $password - * A plain-text password, such as trimmed text from form values. - * @return - * The user's uid on success, or FALSE on failure to authenticate. - */ -function user_authenticate($name, $password) { - $uid = FALSE; - if (!empty($name) && !empty($password)) { - $account = user_load_by_name($name); - if ($account) { - // Allow alternate password hashing schemes. - require_once DRUPAL_ROOT . '/' . variable_get('password_inc', 'includes/password.inc'); - if (user_check_password($password, $account)) { - // Successful authentication. - $uid = $account->uid; - - // Update user to new password scheme if needed. - if (user_needs_new_hash($account)) { - user_save($account, array('pass' => $password)); - } - } - } - } - return $uid; -} - -/** - * Finalize the login process. Must be called when logging in a user. - * - * The function records a watchdog message about the new session, saves the - * login timestamp, calls hook_user op 'login' and generates a new session. * - */ -function user_login_finalize(&$edit = array()) { - global $user; - watchdog('user', 'Session opened for %name.', array('%name' => $user->name)); - // Update the user table timestamp noting user has logged in. - // This is also used to invalidate one-time login links. - $user->login = REQUEST_TIME; - db_update('users') - ->fields(array('login' => $user->login)) - ->condition('uid', $user->uid) - ->execute(); - - // Regenerate the session ID to prevent against session fixation attacks. - // This is called before hook_user in case one of those functions fails - // or incorrectly does a redirect which would leave the old session in place. - drupal_session_regenerate(); - - user_module_invoke('login', $edit, $user); -} - -/** - * Submit handler for the login form. Load $user object and perform standard login - * tasks. The user is then redirected to the My Account page. Setting the - * destination in the query string overrides the redirect. - */ -function user_login_submit($form, &$form_state) { - global $user; - $user = user_load($form_state['uid']); - $form_state['redirect'] = 'user/' . $user->uid; - - user_login_finalize($form_state); -} - -/** - * Helper function for authentication modules. Either logs in or registers - * the current user, based on username. Either way, the global $user object is - * populated and login tasks are performed. - */ -function user_external_login_register($name, $module) { - $account = user_external_load($name); - if (!$account) { - // Register this new user. - $userinfo = array( - 'name' => $name, - 'pass' => user_password(), - 'init' => $name, - 'status' => 1, - 'access' => REQUEST_TIME - ); - $account = user_save(drupal_anonymous_user(), $userinfo); - // Terminate if an error occurred during user_save(). - if (!$account) { - drupal_set_message(t("Error saving user account."), 'error'); - return; - } - user_set_authmaps($account, array("authname_$module" => $name)); - } - - // Log user in. - $form_state['uid'] = $account->uid; - user_login_submit(array(), $form_state); -} - -/** - * Generates a unique URL for a user to login and reset their password. - * - * @param object $account - * An object containing the user account. - * - * @return - * A unique URL that provides a one-time log in for the user, from which - * they can change their password. - */ -function user_pass_reset_url($account) { - $timestamp = REQUEST_TIME; - return url("user/reset/$account->uid/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->login), array('absolute' => TRUE)); -} - -/** - * Generates a URL to confirm an account cancellation request. - * - * @param object $account - * The user account object, which must contain at least the following - * properties: - * - uid: The user uid number. - * - pass: The hashed user password string. - * - login: The user login name. - * - * @return - * A unique URL that may be used to confirm the cancellation of the user - * account. - * - * @see user_mail_tokens() - * @see user_cancel_confirm() - */ -function user_cancel_url($account) { - $timestamp = REQUEST_TIME; - return url("user/$account->uid/cancel/confirm/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->login), array('absolute' => TRUE)); -} - -/** - * Creates a unique hash value for use in time-dependent per-user URLs. - * - * This hash is normally used to build a unique and secure URL that is sent to - * the user by email for purposes such as resetting the user's password. In - * order to validate the URL, the same hash can be generated again, from the - * same information, and compared to the hash value from the URL. The URL - * normally contains both the time stamp and the numeric user ID. The login - * name and hashed password are retrieved from the database as necessary. For a - * usage example, see user_cancel_url() and user_cancel_confirm(). - * - * @param $password - * The hashed user account password value. - * @param $timestamp - * A unix timestamp. - * @param $login - * The user account login name. - * - * @return - * A string that is safe for use in URLs and SQL statements. - */ -function user_pass_rehash($password, $timestamp, $login) { - return drupal_hmac_base64($timestamp . $login, drupal_get_hash_salt() . $password); -} - -/** - * Cancel a user account. - * - * Since the user cancellation process needs to be run in a batch, either - * Form API will invoke it, or batch_process() needs to be invoked after calling - * this function and should define the path to redirect to. - * - * @param $edit - * An array of submitted form values. - * @param $uid - * The user ID of the user account to cancel. - * @param $method - * The account cancellation method to use. - * - * @see _user_cancel() - */ -function user_cancel($edit, $uid, $method) { - global $user; - - $account = user_load($uid); - - if (!$account) { - drupal_set_message(t('The user account %id does not exist.', array('%id' => $uid)), 'error'); - watchdog('user', 'Attempted to cancel non-existing user account: %id.', array('%id' => $uid), WATCHDOG_ERROR); - return; - } - - // Initialize batch (to set title). - $batch = array( - 'title' => t('Cancelling account'), - 'operations' => array(), - ); - batch_set($batch); - - // Modules use hook_user_delete() to respond to deletion. - if ($method != 'user_cancel_delete') { - // Allow modules to add further sets to this batch. - module_invoke_all('user_cancel', $edit, $account, $method); - } - - // Finish the batch and actually cancel the account. - $batch = array( - 'title' => t('Cancelling user account'), - 'operations' => array( - array('_user_cancel', array($edit, $account, $method)), - ), - ); - batch_set($batch); - - // Batch processing is either handled via Form API or has to be invoked - // manually. -} - -/** - * Last batch processing step for cancelling a user account. - * - * Since batch and session API require a valid user account, the actual - * cancellation of a user account needs to happen last. - * - * @see user_cancel() - */ -function _user_cancel($edit, $account, $method) { - global $user; - - switch ($method) { - case 'user_cancel_block': - case 'user_cancel_block_unpublish': - default: - // Send account blocked notification if option was checked. - if (!empty($edit['user_cancel_notify'])) { - _user_mail_notify('status_blocked', $account); - } - user_save($account, array('status' => 0)); - drupal_set_message(t('%name has been disabled.', array('%name' => $account->name))); - watchdog('user', 'Blocked user: %name %email.', array('%name' => $account->name, '%email' => '<' . $account->mail . '>'), WATCHDOG_NOTICE); - break; - - case 'user_cancel_reassign': - case 'user_cancel_delete': - // Send account canceled notification if option was checked. - if (!empty($edit['user_cancel_notify'])) { - _user_mail_notify('status_canceled', $account); - } - user_delete($account->uid); - drupal_set_message(t('%name has been deleted.', array('%name' => $account->name))); - watchdog('user', 'Deleted user: %name %email.', array('%name' => $account->name, '%email' => '<' . $account->mail . '>'), WATCHDOG_NOTICE); - break; - } - - // After cancelling account, ensure that user is logged out. - if ($account->uid == $user->uid) { - // Destroy the current session, and reset $user to the anonymous user. - session_destroy(); - } - - // Clear the cache for anonymous users. - cache_clear_all(); -} - -/** - * Delete a user. - * - * @param $uid - * A user ID. - */ -function user_delete($uid) { - user_delete_multiple(array($uid)); -} - -/** - * Delete multiple user accounts. - * - * @param $uids - * An array of user IDs. - */ -function user_delete_multiple(array $uids) { - if (!empty($uids)) { - $accounts = user_load_multiple($uids, array()); - - $transaction = db_transaction(); - try { - foreach ($accounts as $uid => $account) { - module_invoke_all('user_delete', $account); - module_invoke_all('entity_delete', $account, 'user'); - field_attach_delete('user', $account); - drupal_session_destroy_uid($account->uid); - } - - db_delete('users') - ->condition('uid', $uids, 'IN') - ->execute(); - db_delete('users_roles') - ->condition('uid', $uids, 'IN') - ->execute(); - db_delete('authmap') - ->condition('uid', $uids, 'IN') - ->execute(); - } - catch (Exception $e) { - $transaction->rollback(); - watchdog_exception('user', $e); - throw $e; - } - entity_get_controller('user')->resetCache(); - } -} - -/** - * Page callback wrapper for user_view(). - */ -function user_view_page($account) { - // An administrator may try to view a non-existent account, - // so we give them a 404 (versus a 403 for non-admins). - return is_object($account) ? user_view($account) : MENU_NOT_FOUND; -} - -/** - * Generate an array for rendering the given user. - * - * When viewing a user profile, the $page array contains: - * - * - $page['content']['Profile Category']: - * Profile categories keyed by their human-readable names. - * - $page['content']['Profile Category']['profile_machine_name']: - * Profile fields keyed by their machine-readable names. - * - $page['content']['user_picture']: - * User's rendered picture. - * - $page['content']['summary']: - * Contains the default "History" profile data for a user. - * - $page['content']['#account']: - * The user account of the profile being viewed. - * - * To theme user profiles, copy modules/user/user-profile.tpl.php - * to your theme directory, and edit it as instructed in that file's comments. - * - * @param $account - * A user object. - * @param $view_mode - * View mode, e.g. 'full'. - * @param $langcode - * (optional) A language code to use for rendering. Defaults to the global - * content language of the current request. - * - * @return - * An array as expected by drupal_render(). - */ -function user_view($account, $view_mode = 'full', $langcode = NULL) { - if (!isset($langcode)) { - $langcode = $GLOBALS['language_content']->language; - } - - // Retrieve all profile fields and attach to $account->content. - user_build_content($account, $view_mode, $langcode); - - $build = $account->content; - // We don't need duplicate rendering info in account->content. - unset($account->content); - - $build += array( - '#theme' => 'user_profile', - '#account' => $account, - '#view_mode' => $view_mode, - '#language' => $langcode, - ); - - // Allow modules to modify the structured user. - $type = 'user'; - drupal_alter(array('user_view', 'entity_view'), $build, $type); - - return $build; -} - -/** - * Builds a structured array representing the profile content. - * - * @param $account - * A user object. - * @param $view_mode - * View mode, e.g. 'full'. - * @param $langcode - * (optional) A language code to use for rendering. Defaults to the global - * content language of the current request. - */ -function user_build_content($account, $view_mode = 'full', $langcode = NULL) { - if (!isset($langcode)) { - $langcode = $GLOBALS['language_content']->language; - } - - // Remove previously built content, if exists. - $account->content = array(); - - // Allow modules to change the view mode. - $context = array( - 'entity_type' => 'user', - 'entity' => $account, - 'langcode' => $langcode, - ); - drupal_alter('entity_view_mode', $view_mode, $context); - - // Build fields content. - field_attach_prepare_view('user', array($account->uid => $account), $view_mode, $langcode); - entity_prepare_view('user', array($account->uid => $account), $langcode); - $account->content += field_attach_view('user', $account, $view_mode, $langcode); - - // Populate $account->content with a render() array. - module_invoke_all('user_view', $account, $view_mode, $langcode); - module_invoke_all('entity_view', $account, 'user', $view_mode, $langcode); - - // Make sure the current view mode is stored if no module has already - // populated the related key. - $account->content += array('#view_mode' => $view_mode); -} - -/** - * Implements hook_mail(). - */ -function user_mail($key, &$message, $params) { - $language = $message['language']; - $variables = array('user' => $params['account']); - $message['subject'] .= _user_mail_text($key . '_subject', $language, $variables); - $message['body'][] = _user_mail_text($key . '_body', $language, $variables); -} - -/** - * Returns a mail string for a variable name. - * - * Used by user_mail() and the settings forms to retrieve strings. - */ -function _user_mail_text($key, $language = NULL, $variables = array(), $replace = TRUE) { - $langcode = isset($language) ? $language->language : NULL; - - if ($admin_setting = variable_get('user_mail_' . $key, FALSE)) { - // An admin setting overrides the default string. - $text = $admin_setting; - } - else { - // No override, return default string. - switch ($key) { - case 'register_no_approval_required_subject': - $text = t('Account details for [user:name] at [site:name]', array(), array('langcode' => $langcode)); - break; - case 'register_no_approval_required_body': - $text = t("[user:name], - -Thank you for registering at [site:name]. You may now log in by clicking this link or copying and pasting it to your browser: - -[user:one-time-login-url] - -This link can only be used once to log in and will lead you to a page where you can set your password. - -After setting your password, you will be able to log in at [site:login-url] in the future using: - -username: [user:name] -password: Your password - --- [site:name] team", array(), array('langcode' => $langcode)); - break; - - case 'register_admin_created_subject': - $text = t('An administrator created an account for you at [site:name]', array(), array('langcode' => $langcode)); - break; - case 'register_admin_created_body': - $text = t("[user:name], - -A site administrator at [site:name] has created an account for you. You may now log in by clicking this link or copying and pasting it to your browser: - -[user:one-time-login-url] - -This link can only be used once to log in and will lead you to a page where you can set your password. - -After setting your password, you will be able to log in at [site:login-url] in the future using: - -username: [user:name] -password: Your password - --- [site:name] team", array(), array('langcode' => $langcode)); - break; - - case 'register_pending_approval_subject': - case 'register_pending_approval_admin_subject': - $text = t('Account details for [user:name] at [site:name] (pending admin approval)', array(), array('langcode' => $langcode)); - break; - case 'register_pending_approval_body': - $text = t("[user:name], - -Thank you for registering at [site:name]. Your application for an account is currently pending approval. Once it has been approved, you will receive another e-mail containing information about how to log in, set your password, and other details. - - --- [site:name] team", array(), array('langcode' => $langcode)); - break; - case 'register_pending_approval_admin_body': - $text = t("[user:name] has applied for an account. - -[user:edit-url]", array(), array('langcode' => $langcode)); - break; - - case 'password_reset_subject': - $text = t('Replacement login information for [user:name] at [site:name]', array(), array('langcode' => $langcode)); - break; - case 'password_reset_body': - $text = t("[user:name], - -A request to reset the password for your account has been made at [site:name]. - -You may now log in by clicking this link or copying and pasting it to your browser: - -[user:one-time-login-url] - -This link can only be used once to log in and will lead you to a page where you can set your password. It expires after one day and nothing will happen if it's not used. - --- [site:name] team", array(), array('langcode' => $langcode)); - break; - - case 'status_activated_subject': - $text = t('Account details for [user:name] at [site:name] (approved)', array(), array('langcode' => $langcode)); - break; - case 'status_activated_body': - $text = t("[user:name], - -Your account at [site:name] has been activated. - -You may now log in by clicking this link or copying and pasting it into your browser: - -[user:one-time-login-url] - -This link can only be used once to log in and will lead you to a page where you can set your password. - -After setting your password, you will be able to log in at [site:login-url] in the future using: - -username: [user:name] -password: Your password - --- [site:name] team", array(), array('langcode' => $langcode)); - break; - - case 'status_blocked_subject': - $text = t('Account details for [user:name] at [site:name] (blocked)', array(), array('langcode' => $langcode)); - break; - case 'status_blocked_body': - $text = t("[user:name], - -Your account on [site:name] has been blocked. - --- [site:name] team", array(), array('langcode' => $langcode)); - break; - - case 'cancel_confirm_subject': - $text = t('Account cancellation request for [user:name] at [site:name]', array(), array('langcode' => $langcode)); - break; - case 'cancel_confirm_body': - $text = t("[user:name], - -A request to cancel your account has been made at [site:name]. - -You may now cancel your account on [site:url-brief] by clicking this link or copying and pasting it into your browser: - -[user:cancel-url] - -NOTE: The cancellation of your account is not reversible. - -This link expires in one day and nothing will happen if it is not used. - --- [site:name] team", array(), array('langcode' => $langcode)); - break; - - case 'status_canceled_subject': - $text = t('Account details for [user:name] at [site:name] (canceled)', array(), array('langcode' => $langcode)); - break; - case 'status_canceled_body': - $text = t("[user:name], - -Your account on [site:name] has been canceled. - --- [site:name] team", array(), array('langcode' => $langcode)); - break; - } - } - - if ($replace) { - // We do not sanitize the token replacement, since the output of this - // replacement is intended for an e-mail message, not a web browser. - return token_replace($text, $variables, array('language' => $language, 'callback' => 'user_mail_tokens', 'sanitize' => FALSE, 'clear' => TRUE)); - } - - return $text; -} - -/** - * Token callback to add unsafe tokens for user mails. - * - * This function is used by the token_replace() call at the end of - * _user_mail_text() to set up some additional tokens that can be - * used in email messages generated by user_mail(). - * - * @param $replacements - * An associative array variable containing mappings from token names to - * values (for use with strtr()). - * @param $data - * An associative array of token replacement values. If the 'user' element - * exists, it must contain a user account object with the following - * properties: - * - login: The account login name. - * - pass: The hashed account login password. - * @param $options - * Unused parameter required by the token_replace() function. - */ -function user_mail_tokens(&$replacements, $data, $options) { - if (isset($data['user'])) { - $replacements['[user:one-time-login-url]'] = user_pass_reset_url($data['user']); - $replacements['[user:cancel-url]'] = user_cancel_url($data['user']); - } -} - -/*** Administrative features ***********************************************/ - -/** - * Retrieve an array of roles matching specified conditions. - * - * @param $membersonly - * Set this to TRUE to exclude the 'anonymous' role. - * @param $permission - * A string containing a permission. If set, only roles containing that - * permission are returned. - * - * @return - * An associative array with the role id as the key and the role name as - * value. - */ -function user_roles($membersonly = FALSE, $permission = NULL) { - $query = db_select('role', 'r'); - $query->addTag('translatable'); - $query->fields('r', array('rid', 'name')); - $query->orderBy('weight'); - $query->orderBy('name'); - if (!empty($permission)) { - $query->innerJoin('role_permission', 'p', 'r.rid = p.rid'); - $query->condition('p.permission', $permission); - } - $result = $query->execute(); - - $roles = array(); - foreach ($result as $role) { - switch ($role->rid) { - // We only translate the built in role names - case DRUPAL_ANONYMOUS_RID: - if (!$membersonly) { - $roles[$role->rid] = t($role->name); - } - break; - case DRUPAL_AUTHENTICATED_RID: - $roles[$role->rid] = t($role->name); - break; - default: - $roles[$role->rid] = $role->name; - } - } - - return $roles; -} - -/** - * Fetches a user role by role ID. - * - * @param $rid - * An integer representing the role ID. - * - * @return - * A fully-loaded role object if a role with the given ID exists, or FALSE - * otherwise. - * - * @see user_role_load_by_name() - */ -function user_role_load($rid) { - return db_select('role', 'r') - ->fields('r') - ->condition('rid', $rid) - ->execute() - ->fetchObject(); -} - -/** - * Fetches a user role by role name. - * - * @param $role_name - * A string representing the role name. - * - * @return - * A fully-loaded role object if a role with the given name exists, or FALSE - * otherwise. - * - * @see user_role_load() - */ -function user_role_load_by_name($role_name) { - return db_select('role', 'r') - ->fields('r') - ->condition('name', $role_name) - ->execute() - ->fetchObject(); -} - -/** - * Save a user role to the database. - * - * @param $role - * A role object to modify or add. If $role->rid is not specified, a new - * role will be created. - * @return - * Status constant indicating if role was created or updated. - * Failure to write the user role record will return FALSE. Otherwise. - * SAVED_NEW or SAVED_UPDATED is returned depending on the operation - * performed. - */ -function user_role_save($role) { - if ($role->name) { - // Prevent leading and trailing spaces in role names. - $role->name = trim($role->name); - } - if (!isset($role->weight)) { - // Set a role weight to make this new role last. - $query = db_select('role'); - $query->addExpression('MAX(weight)'); - $role->weight = $query->execute()->fetchField() + 1; - } - - // Let modules modify the user role before it is saved to the database. - module_invoke_all('user_role_presave', $role); - - if (!empty($role->rid) && $role->name) { - $status = drupal_write_record('role', $role, 'rid'); - module_invoke_all('user_role_update', $role); - } - else { - $status = drupal_write_record('role', $role); - module_invoke_all('user_role_insert', $role); - } - - // Clear the user access cache. - drupal_static_reset('user_access'); - drupal_static_reset('user_role_permissions'); - - return $status; -} - -/** - * Delete a user role from database. - * - * @param $role - * A string with the role name, or an integer with the role ID. - */ -function user_role_delete($role) { - if (is_int($role)) { - $role = user_role_load($role); - } - else { - $role = user_role_load_by_name($role); - } - - db_delete('role') - ->condition('rid', $role->rid) - ->execute(); - db_delete('role_permission') - ->condition('rid', $role->rid) - ->execute(); - // Update the users who have this role set: - db_delete('users_roles') - ->condition('rid', $role->rid) - ->execute(); - - module_invoke_all('user_role_delete', $role); - - // Clear the user access cache. - drupal_static_reset('user_access'); - drupal_static_reset('user_role_permissions'); -} - -/** - * Menu access callback for user role editing. - */ -function user_role_edit_access($role) { - // Prevent the system-defined roles from being altered or removed. - if ($role->rid == DRUPAL_ANONYMOUS_RID || $role->rid == DRUPAL_AUTHENTICATED_RID) { - return FALSE; - } - - return user_access('administer permissions'); -} - -/** - * Determine the modules that permissions belong to. - * - * @return - * An associative array in the format $permission => $module. - */ -function user_permission_get_modules() { - $permissions = array(); - foreach (module_implements('permission') as $module) { - $perms = module_invoke($module, 'permission'); - foreach ($perms as $key => $value) { - $permissions[$key] = $module; - } - } - return $permissions; -} - -/** - * Change permissions for a user role. - * - * This function may be used to grant and revoke multiple permissions at once. - * For example, when a form exposes checkboxes to configure permissions for a - * role, the form submit handler may directly pass the submitted values for the - * checkboxes form element to this function. - * - * @param $rid - * The ID of a user role to alter. - * @param $permissions - * An associative array, where the key holds the permission name and the value - * determines whether to grant or revoke that permission. Any value that - * evaluates to TRUE will cause the permission to be granted. Any value that - * evaluates to FALSE will cause the permission to be revoked. - * @code - * array( - * 'administer nodes' => 0, // Revoke 'administer nodes' - * 'administer blocks' => FALSE, // Revoke 'administer blocks' - * 'access user profiles' => 1, // Grant 'access user profiles' - * 'access content' => TRUE, // Grant 'access content' - * 'access comments' => 'access comments', // Grant 'access comments' - * ) - * @endcode - * Existing permissions are not changed, unless specified in $permissions. - * - * @see user_role_grant_permissions() - * @see user_role_revoke_permissions() - */ -function user_role_change_permissions($rid, array $permissions = array()) { - // Grant new permissions for the role. - $grant = array_filter($permissions); - if (!empty($grant)) { - user_role_grant_permissions($rid, array_keys($grant)); - } - // Revoke permissions for the role. - $revoke = array_diff_assoc($permissions, $grant); - if (!empty($revoke)) { - user_role_revoke_permissions($rid, array_keys($revoke)); - } -} - -/** - * Grant permissions to a user role. - * - * @param $rid - * The ID of a user role to alter. - * @param $permissions - * A list of permission names to grant. - * - * @see user_role_change_permissions() - * @see user_role_revoke_permissions() - */ -function user_role_grant_permissions($rid, array $permissions = array()) { - $modules = user_permission_get_modules(); - // Grant new permissions for the role. - foreach ($permissions as $name) { - db_merge('role_permission') - ->key(array( - 'rid' => $rid, - 'permission' => $name, - )) - ->fields(array( - 'module' => $modules[$name], - )) - ->execute(); - } - - // Clear the user access cache. - drupal_static_reset('user_access'); - drupal_static_reset('user_role_permissions'); -} - -/** - * Revoke permissions from a user role. - * - * @param $rid - * The ID of a user role to alter. - * @param $permissions - * A list of permission names to revoke. - * - * @see user_role_change_permissions() - * @see user_role_grant_permissions() - */ -function user_role_revoke_permissions($rid, array $permissions = array()) { - // Revoke permissions for the role. - db_delete('role_permission') - ->condition('rid', $rid) - ->condition('permission', $permissions, 'IN') - ->execute(); - - // Clear the user access cache. - drupal_static_reset('user_access'); - drupal_static_reset('user_role_permissions'); -} - -/** - * Implements hook_user_operations(). - */ -function user_user_operations($form = array(), $form_state = array()) { - $operations = array( - 'unblock' => array( - 'label' => t('Unblock the selected users'), - 'callback' => 'user_user_operations_unblock', - ), - 'block' => array( - 'label' => t('Block the selected users'), - 'callback' => 'user_user_operations_block', - ), - 'cancel' => array( - 'label' => t('Cancel the selected user accounts'), - ), - ); - - if (user_access('administer permissions')) { - $roles = user_roles(TRUE); - unset($roles[DRUPAL_AUTHENTICATED_RID]); // Can't edit authenticated role. - - $add_roles = array(); - foreach ($roles as $key => $value) { - $add_roles['add_role-' . $key] = $value; - } - - $remove_roles = array(); - foreach ($roles as $key => $value) { - $remove_roles['remove_role-' . $key] = $value; - } - - if (count($roles)) { - $role_operations = array( - t('Add a role to the selected users') => array( - 'label' => $add_roles, - ), - t('Remove a role from the selected users') => array( - 'label' => $remove_roles, - ), - ); - - $operations += $role_operations; - } - } - - // If the form has been posted, we need to insert the proper data for - // role editing if necessary. - if (!empty($form_state['submitted'])) { - $operation_rid = explode('-', $form_state['values']['operation']); - $operation = $operation_rid[0]; - if ($operation == 'add_role' || $operation == 'remove_role') { - $rid = $operation_rid[1]; - if (user_access('administer permissions')) { - $operations[$form_state['values']['operation']] = array( - 'callback' => 'user_multiple_role_edit', - 'callback arguments' => array($operation, $rid), - ); - } - else { - watchdog('security', 'Detected malicious attempt to alter protected user fields.', array(), WATCHDOG_WARNING); - return; - } - } - } - - return $operations; -} - -/** - * Callback function for admin mass unblocking users. - */ -function user_user_operations_unblock($accounts) { - $accounts = user_load_multiple($accounts); - foreach ($accounts as $account) { - // Skip unblocking user if they are already unblocked. - if ($account !== FALSE && $account->status == 0) { - user_save($account, array('status' => 1)); - } - } -} - -/** - * Callback function for admin mass blocking users. - */ -function user_user_operations_block($accounts) { - $accounts = user_load_multiple($accounts); - foreach ($accounts as $account) { - // Skip blocking user if they are already blocked. - if ($account !== FALSE && $account->status == 1) { - // For efficiency manually save the original account before applying any - // changes. - $account->original = clone $account; - user_save($account, array('status' => 0)); - } - } -} - -/** - * Callback function for admin mass adding/deleting a user role. - */ -function user_multiple_role_edit($accounts, $operation, $rid) { - // The role name is not necessary as user_save() will reload the user - // object, but some modules' hook_user() may look at this first. - $role_name = db_query('SELECT name FROM {role} WHERE rid = :rid', array(':rid' => $rid))->fetchField(); - - switch ($operation) { - case 'add_role': - $accounts = user_load_multiple($accounts); - foreach ($accounts as $account) { - // Skip adding the role to the user if they already have it. - if ($account !== FALSE && !isset($account->roles[$rid])) { - $roles = $account->roles + array($rid => $role_name); - // For efficiency manually save the original account before applying - // any changes. - $account->original = clone $account; - user_save($account, array('roles' => $roles)); - } - } - break; - case 'remove_role': - $accounts = user_load_multiple($accounts); - foreach ($accounts as $account) { - // Skip removing the role from the user if they already don't have it. - if ($account !== FALSE && isset($account->roles[$rid])) { - $roles = array_diff($account->roles, array($rid => $role_name)); - // For efficiency manually save the original account before applying - // any changes. - $account->original = clone $account; - user_save($account, array('roles' => $roles)); - } - } - break; - } -} - -function user_multiple_cancel_confirm($form, &$form_state) { - $edit = $form_state['input']; - - $form['accounts'] = array('#prefix' => '