diff --git a/README.md b/README.md index 72d47b9..df92336 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ If you are upgrading, then please refer to the `UPGRADE.md` file. COPYRIGHT NOTICES ----------------- -All Drupal code is Copyright 2001 - 2012 by the original authors. +All Drupal code is Copyright 2001 - 2012 by the original authors. Also contrib modules code is Copyright 2001 - 2017 by the original authors. This program is free software; you can redistribute it and/or modify it under diff --git a/config/INSTALL.md b/config/INSTALL.md index 734d02e..65ca43e 100644 --- a/config/INSTALL.md +++ b/config/INSTALL.md @@ -16,7 +16,7 @@ REQUIREMENTS ------------ **SuiteDesk** began long time ago as a Drupal 6 project, and now continues as a -standalone software product. It requires: +standalone open software product. It requires: * A web server (Apache web server with mode_rewrite module and the ability to use local .htaccess files is recommended), @@ -38,85 +38,161 @@ You can obtain the latest **SuiteDesk** release from: If you select files in `.tar.gz` or `.zip` format, they can be extracted using most compression tools. Example, on a typical Unix command line, use: - wget REPOSITORY/archive.tar.gz?ref=master + wget REPOSITORY/archive.tar.gz?ref=version tar -zxvf archive.tar.gz -This will create a new directory `suitedesk/` containing all **SuiteDesk** files -and directories. Move the contents of that directory into a directory within +This will create a new directory called `suitedesk-version/` containing all +**SuiteDesk** files and directories. Move the contents of that directory into your web server's document root or your public HTML directory: - mv suitedesk/* suitedesk/.htaccess /var/www/html + mv suitedesk-version/* suitedesk-version/.htaccess /var/www/html -### 2. CREATE THE CONFIGURATION FILE AND GRANT WRITE PERMISSIONS +### 2. DOWNLOAD PDF TOOL -SuiteDesk comes with a default.settings.php file in the config/default +The print PDF module requires the use of an external PDF generation tool. The +currently supported is *wkhtmltopdf*. To install follow the next steps: + +1. Download *wkhtmltopdf* from https://wkhtmltopdf.org/downloads.html. You can + choose to download the source and compile it or simply download the static + binary, which doesn't require you to compile anything. Note that the compiled + version may require a running X server (static uses patched libs that can + work without one). +2. Place the `wkhtmltopdf` executable into the `libraries` directory. You can + also place a symbolic link to the executable. +3. Check https://wkhtmltopdf.org/usage/wkhtmltopdf.txt for further information. + +### 3. CREATE THE CONFIGURATION FILE AND GRANT WRITE PERMISSIONS + +**SuiteDesk** comes with a `default.settings.php` file in the `config/default` directory. Use this file as a template to create your settings file. To avoid -problems when upgrading, SuiteDesk is not packaged with an actual settings file. -You must create a file named settings.php. You may do so by making a copy of -default.settings.php (or create an empty file with this name in the same -directory). For example, (from the installation directory) make a copy of the -default.settings.php file with the command: +problems when upgrading, **SuiteDesk** is not packaged with an actual settings +file. You must create a file named `settings.php`. You may do so by making a +copy of `default.settings.php`. For example (from the `config` directory): cp config/default/default.settings.php config/default/settings.php -Next, give the web server write privileges to the config/default/settings.php -file with the command (from the installation directory): +Next, give the web server write privileges to the `config/default/settings.php` +file with the command (from the `config` directory): chmod o+w config/default/settings.php So that the files directory can be created automatically, give the web server -write privileges to the config/default directory with the command (from the -installation directory): +write privileges to the `config/default` directory with the command (from the +`config` directory): chmod o+w config/default -### 3. CREATE THE SUITEDESK DATABASE +You can create more than one configuration file, and the configuration file to +be loaded is based upon the rules below. -SuiteDesk requires access to a database in order to be installed. Your database -user will need sufficient privileges to run SuiteDesk. +The configuration directory will be discovered by stripping the website's +hostname from left to right and pathname from right to left. The first +configuration file found will be used and any others will be ignored. If no +other configuration file is found then the default configuration file at +`config/default` will be used. For example, for a fictitious site installed at +http://www.example.org/mysite/test the `settings.php` is searched in the +following directories: + + 1. config/www.example.org.mysite.test + 2. config/example.org.mysite.test + 3. config/org.mysite.test + + 4. config/www.example.org.mysite + 5. config/example.org.mysite + 6. config/org.mysite + + 7. config/www.example.org + 8. config/example.org + 9. config/org + + 10. config/default + +If you are installing on a non-standard port number, prefix the hostname with +that number. For example, http://www.example.org:8080/mysite/test could be +loaded from `config/8080.www.drupal.org.mysite.test` directory. + +### 4. CREATE THE SUITEDESK DATABASE + +**SuiteDesk** requires access to a database in order to be installed. Your +database user will need sufficient privileges to run **SuiteDesk**. To create a database using PHPMyAdmin or a web-based control panel consult the documentation or ask your webhost service provider. -Take note of the username, password, database name and hostname as you create -the database. You will enter these items in the install script. +Take note of the *username*, *password*, *database name* and *hostname* as you +create the database. You will enter these items in the next commands. 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 +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): +First, you must create a new database for your site (here, *databasename* is the +name of the new database): - mysqladmin -u username -p create databasename + mysqladmin -u username -p create databasename - MySQL will prompt for the 'username' database password and then create the - initial database files. Next you must login and set the access database rights: +MySQL will prompt for the *username* database password and then create the +initial database files. Next you must login and set the access database rights: - mysql -u username -p + mysql -u username -p - Again, you will be asked for the 'username' database password. At the MySQL - prompt, enter following command: +Again, you will be asked for the *username* database password. At the MySQL +prompt, enter following command: - GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, - CREATE TEMPORARY TABLES ON databasename.* - TO 'username'@'localhost' IDENTIFIED BY 'password'; + ```sql + GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, + CREATE TEMPORARY TABLES ON databasename.* + TO 'username'@'localhost' IDENTIFIED BY 'password'; + ``` - where +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 + *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. +Note: Unless your database user has all of the privileges listed above, you will +not be able to run **SuiteDesk**. - If successful, MySQL will reply with: +If successful, MySQL will reply with: - Query OK, 0 rows affected + Query OK, 0 rows affected -### 4. RUN THE INSTALL SCRIPT +In the configuration file you will fill out the `$db_url` variable to configure +the database connection using the format: + + $db_url['default'] = 'mysql://username:password@localhost/databasename'; + +If your *username*, *password* or *database name* contain characters used to +delineate `$db_url` parts, you can escape them via URI hex encodings: + + : = %3a / = %2f @ = %40 + + = %2b ( = %28 ) = %29 + ? = %3f = = %3d & = %26 + +If you prefix some or all database table names, you can use the `$db_prefix` +setting and each table name will be prepended with its value. Be sure to use +valid database characters only, usually alphanumeric and underscore. If no +prefixes are desired, leave it as an empty string ''. + +To have all database names prefixed, set `$db_prefix` as a string: + + $db_prefix = 'main_'; + +To provide prefixes for specific tables set `$db_prefix` as an array where keys +are the table names and the values are the prefixes. The `default` element holds +the prefix for any tables not specified elsewhere in the array: + + $db_prefix = array( + 'default' => 'main_', + 'users' => 'shared_', + 'sessions' => 'shared_', + 'role' => 'shared_', + 'authmap' => 'shared_', + ); + +### 5. 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). @@ -149,7 +225,7 @@ system. file is at config/default/settings.php, it may be in another location if you use the multi-site setup, as explained below. -### 5. CONFIGURE SUITEDESK +### 6. CONFIGURE SUITEDESK When the install script succeeds, you will be directed to the "Welcome" page, and you will be logged in as the administrator already. Proceed with @@ -161,7 +237,7 @@ system. running FastCGI can run into problems if the $base_url variable is left commented out (see http://bugs.php.net/bug.php?id=19656). -### 6. REVIEW FILE SYSTEM STORAGE SETTINGS AND FILE PERMISSIONS +### 7. REVIEW FILE SYSTEM STORAGE SETTINGS AND FILE PERMISSIONS 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. @@ -225,7 +301,7 @@ system. Windows file permissions" (http://drupal.org/node/202491) in the online handbook. -### 7. CRON MAINTENANCE TASKS +### 8. CRON MAINTENANCE TASKS Many Drupal modules have periodic tasks that must be triggered by a cron maintenance task, including search module (to build and update the index diff --git a/config/default/default.settings.php b/config/default/default.settings.php index 20ca449..718d912 100644 --- a/config/default/default.settings.php +++ b/config/default/default.settings.php @@ -7,88 +7,13 @@ * This file may have been set to read-only by Drupal. If you make changes to * this file, be sure to protect it again after making your modifications. * Failure to remove write permission to this file is a security risk. - * - * The configuration file to be loaded is based upon the rules below. - * - * The configuration directory will be discovered by stripping the website's - * hostname from left to right and pathname from right to left. The first - * configuration file found will be used and any others will be ignored. If no - * other configuration file is found then the default configuration file at - * 'config/default' will be used. For example, for a fictitious site installed - * at http://www.example.org/mysite/test the 'settings.php' is searched in the - * following directories: - * - * 1. config/www.example.org.mysite.test - * 2. config/example.org.mysite.test - * 3. config/org.mysite.test - * - * 4. config/www.example.org.mysite - * 5. config/example.org.mysite - * 6. config/org.mysite - * - * 7. config/www.example.org - * 8. config/example.org - * 9. config/org - * - * 10. config/default - * - * If you are installing on a non-standard port number, prefix the hostname with - * that number. For example, http://www.example.org:8080/mysite/test could be - * loaded from config/8080.www.drupal.org.mysite.test directory. */ -/** - * Database settings. - * - * Note that the $db_url variable gets parsed using PHP's built-in URL parser - * (i.e. using the "parse_url()" function) so make sure not to confuse the - * parser. If your username, password or database name contain characters used - * to delineate $db_url parts, you can escape them via URI hex encodings: - * - * : = %3a / = %2f @ = %40 - * + = %2b ( = %28 ) = %29 - * ? = %3f = = %3d & = %26 - * - * To specify multiple connections to use in your site (i.e. for complex custom - * modules) you can also specify an associative array of $db_url variables with - * the 'default' element used until otherwise requested. - * - * If you prefix some or all database table names, you can use the $db_prefix - * setting and each table name will be prepended with its value. Be sure to use - * valid database characters only, usually alphanumeric and underscore. If no - * prefixes are desired, leave it as an empty string ''. - * - * To have all database names prefixed, set $db_prefix as a string: - * - * $db_prefix = 'main_'; - * - * To provide prefixes for specific tables set $db_prefix as an array where keys - * are the table names and the values are the prefixes. The 'default' element - * holds the prefix for any tables not specified elsewhere in the array: - * - * $db_prefix = array( - * 'default' => 'main_', - * 'users' => 'shared_', - * 'sessions' => 'shared_', - * 'role' => 'shared_', - * 'authmap' => 'shared_', - * ); - * - * Database URL format: - * $db_url = 'mysql://username:password@localhost/databasename'; - * $db_url = 'mysqli://username:password@localhost/databasename'; - * $db_url = 'pgsql://username:password@localhost/databasename'; - */ -$db_url = 'mysql://username:password@localhost/databasename'; +// Database settings: +$db_url['default'] = 'mysql://username:password@localhost/databasename'; $db_prefix = ''; -/** - * SuiteCRM (a fork of SugarCRM) access. - * - * Don't forget to assign TRUE to this variable and uncomment to provide the - * SuiteCRM database connection. - */ -$conf['storm_suitecrm'] = FALSE; +// SuiteCRM (a fork of SugarCRM) database access: # $db_url['sugarcrm'] = 'mysql://username:password@localhost/databasename'; /** diff --git a/modules/storm/storm.module b/modules/storm/storm.module index 6b54818..2b591c8 100644 --- a/modules/storm/storm.module +++ b/modules/storm/storm.module @@ -356,7 +356,7 @@ function storm_user($op, &$edit, &$account, $category = NULL) { * $_SESSION['SuiteCRM_Session_ID'] = Session ID for user in SuiteCRM */ function storm_init() { - global $user, $base_url, $conf; + global $user, $base_url; // It is intended to move these calls to pages which specifically need them rather than on hook_init. drupal_add_js(drupal_get_path('module', 'storm') .'/storm.js', 'module', 'header', FALSE); @@ -397,7 +397,7 @@ function storm_init() { $_SESSION['deskmenu'] = $deskmenu; // Verify SuiteCRM access. Get the SuiteCRM User ID: - if ($conf['storm_suitecrm']) { + if (storm_suitecrm_is_defined()) { $sugaruid = $user->uid == 1 ? 1 : db_result(db_query("SELECT field_stormperson_sugaruid_value FROM {stormperson} JOIN {content_type_stormperson} USING (vid) WHERE user_uid = %d", $user->uid)); if (!empty($sugaruid)) { $password = md5(substr(md5(microtime()), rand(0, 26), 16)); @@ -3360,6 +3360,15 @@ function storm_cron_is_running() { return preg_match('/\/cron.php$/', $_SERVER['SCRIPT_NAME']); } +/** + * Return TRUE if database connection with SuiteCRM is defined. + */ +function storm_suitecrm_is_defined() { + global $db_url; + + return !empty($db_url['sugarcrm']); +} + /** * Switch from original user to mail submission user and back. Notes: * diff --git a/modules/storm/stormorganization/stormorganization.module b/modules/storm/stormorganization/stormorganization.module index d133704..a55d9c9 100644 --- a/modules/storm/stormorganization/stormorganization.module +++ b/modules/storm/stormorganization/stormorganization.module @@ -393,9 +393,7 @@ function stormorganization_form(&$node) { * Implements hook_form_FORM_ID_alter(). */ function stormorganization_form_stormorganization_node_form_alter(&$form, &$form_state) { - global $conf; - - if ($conf['storm_suitecrm']) { + if (storm_suitecrm_is_defined()) { $form['group3']['#access'] = FALSE; $form['group4']['#access'] = FALSE; $form['group5']['taxid']['#access'] = FALSE; @@ -448,7 +446,7 @@ function stormorganization_update($node) { } function stormorganization_nodeapi(&$node, $op, $teaser, $page) { - global $base_url, $conf; + global $base_url; if ($node->type != 'stormorganization') { return; @@ -474,7 +472,7 @@ function stormorganization_nodeapi(&$node, $op, $teaser, $page) { case 'validate': $nid = $node->nid; $organization_name = $node->title; - if (!$conf['storm_suitecrm'] || empty($organization_name)) { + if (!storm_suitecrm_is_defined() || empty($organization_name)) { return; } // Checking if exists the organization in SuiteCRM: @@ -501,12 +499,12 @@ function stormorganization_nodeapi(&$node, $op, $teaser, $page) { array('!organization' => l(t('organization'), drupal_get_path_alias('node/' . $organization_nid))) ) ); - } + } } break; case 'presave': - if ($conf['storm_suitecrm']) { + if (storm_suitecrm_is_defined()) { $sugarid = $node->field_stormorganization_sugarid[0]['value']; db_set_active('sugarcrm'); @@ -528,7 +526,7 @@ function stormorganization_nodeapi(&$node, $op, $teaser, $page) { case 'insert': case 'update': - if ($conf['storm_suitecrm']) { + if (storm_suitecrm_is_defined()) { $sugarid = $node->field_stormorganization_sugarid[0]['value']; if (!empty($sugarid)) { db_set_active('sugarcrm'); @@ -539,7 +537,7 @@ function stormorganization_nodeapi(&$node, $op, $teaser, $page) { break; case 'delete': - if ($conf['storm_suitecrm']) { + if (storm_suitecrm_is_defined()) { $sugarid = $node->field_stormorganization_sugarid[0]['value']; if (!empty($sugarid)) { db_set_active('sugarcrm'); @@ -555,7 +553,7 @@ function stormorganization_nodeapi(&$node, $op, $teaser, $page) { break; case 'view': - if ($conf['storm_suitecrm'] && !storm_cron_is_running()) { + if (storm_suitecrm_is_defined() && !storm_cron_is_running()) { $sugarid = $node->field_stormorganization_sugarid[0]['value']; if (!empty($sugarid)) { db_set_active('sugarcrm'); @@ -591,7 +589,7 @@ function stormorganization_nodeapi(&$node, $op, $teaser, $page) { function _stormorganization_validate_predelete($node) { $nid = $node->nid; $items = array(); - + if (_storm_validate_predelete('stormperson', "s.organization_nid = $nid")) { $items[] = '' . t('people') . ''; } diff --git a/modules/storm/stormperson/stormperson.module b/modules/storm/stormperson/stormperson.module index 47f452a..d3f96cc 100644 --- a/modules/storm/stormperson/stormperson.module +++ b/modules/storm/stormperson/stormperson.module @@ -389,9 +389,7 @@ function stormperson_form(&$node) { * Implements hook_form_FORM_ID_alter(). */ function stormperson_form_stormperson_node_form_alter(&$form, &$form_state) { - global $conf; - - if ($conf['storm_suitecrm']) { + if (storm_suitecrm_is_defined()) { $form['group1']['#access'] = FALSE; $form['group3']['#access'] = FALSE; $form['group4']['#access'] = FALSE; @@ -501,7 +499,7 @@ function _stormperson_aftersave(&$node) { } function stormperson_nodeapi(&$node, $op, $teaser, $page) { - global $base_url, $conf; + global $base_url; if ($node->type != 'stormperson') { return; @@ -512,7 +510,7 @@ function stormperson_nodeapi(&$node, $op, $teaser, $page) { $name = $node->field_stormperson_name[0]['value']; $lastname = $node->field_stormperson_lastname[0]['value']; $fullname = empty($lastname) ? $name : $lastname . ', ' . $name; - if (!$conf['storm_suitecrm'] || empty($fullname)) { + if (!storm_suitecrm_is_defined() || empty($fullname)) { return; } // Checking if exists the contact in SuiteCRM: @@ -544,7 +542,7 @@ function stormperson_nodeapi(&$node, $op, $teaser, $page) { break; case 'presave': - if ($conf['storm_suitecrm']) { + if (storm_suitecrm_is_defined()) { $sugarid = $node->field_stormperson_sugarid[0]['value']; db_set_active('sugarcrm'); @@ -566,7 +564,7 @@ function stormperson_nodeapi(&$node, $op, $teaser, $page) { case 'insert': case 'update': - if ($conf['storm_suitecrm']) { + if (storm_suitecrm_is_defined()) { $sugarid = $node->field_stormperson_sugarid[0]['value']; if (!empty($sugarid)) { db_set_active('sugarcrm'); @@ -577,7 +575,7 @@ function stormperson_nodeapi(&$node, $op, $teaser, $page) { break; case 'delete': - if ($conf['storm_suitecrm']) { + if (storm_suitecrm_is_defined()) { $sugarid = $node->field_stormperson_sugarid[0]['value']; if (!empty($sugarid)) { db_set_active('sugarcrm'); @@ -593,7 +591,7 @@ function stormperson_nodeapi(&$node, $op, $teaser, $page) { break; case 'view': - if ($conf['storm_suitecrm'] && !storm_cron_is_running()) { + if (storm_suitecrm_is_defined() && !storm_cron_is_running()) { $sugarid = $node->field_stormperson_sugarid[0]['value']; if (!empty($sugarid)) { db_set_active('sugarcrm'); @@ -606,7 +604,7 @@ function stormperson_nodeapi(&$node, $op, $teaser, $page) { if ($node->field_stormperson_sugarmod[0]['value'] != $suitecrm_contact['date_modified']) { $node_update = node_load($node->nid); // Prepare node for a submit. - $node_update = node_submit($node_update); + $node_update = node_submit($node_update); node_save($node_update); drupal_set_message(t('SuiteCRM contact has been updated, refresh to view changes.')); }