Detect SuiteCRM only with global variable ['sugarcrm']
This commit is contained in:
parent
052824e4b7
commit
3249260653
6 changed files with 153 additions and 147 deletions
|
@ -16,7 +16,7 @@ REQUIREMENTS
|
||||||
------------
|
------------
|
||||||
|
|
||||||
**SuiteDesk** began long time ago as a Drupal 6 project, and now continues as a
|
**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
|
* A web server (Apache web server with mode_rewrite module and the ability to
|
||||||
use local .htaccess files is recommended),
|
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
|
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:
|
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
|
tar -zxvf archive.tar.gz
|
||||||
|
|
||||||
This will create a new directory `suitedesk/` containing all **SuiteDesk** files
|
This will create a new directory called `suitedesk-version/` containing all
|
||||||
and directories. Move the contents of that directory into a directory within
|
**SuiteDesk** files and directories. Move the contents of that directory into
|
||||||
your web server's document root or your public HTML directory:
|
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
|
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.
|
problems when upgrading, **SuiteDesk** is not packaged with an actual settings
|
||||||
You must create a file named settings.php. You may do so by making a copy of
|
file. You must create a file named `settings.php`. You may do so by making a
|
||||||
default.settings.php (or create an empty file with this name in the same
|
copy of `default.settings.php`. For example (from the `config` directory):
|
||||||
directory). For example, (from the installation directory) make a copy of the
|
|
||||||
default.settings.php file with the command:
|
|
||||||
|
|
||||||
cp config/default/default.settings.php config/default/settings.php
|
cp config/default/default.settings.php config/default/settings.php
|
||||||
|
|
||||||
Next, give the web server write privileges to the 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):
|
file with the command (from the `config` directory):
|
||||||
|
|
||||||
chmod o+w config/default/settings.php
|
chmod o+w config/default/settings.php
|
||||||
|
|
||||||
So that the files directory can be created automatically, give the web server
|
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
|
write privileges to the `config/default` directory with the command (from the
|
||||||
installation directory):
|
`config` directory):
|
||||||
|
|
||||||
chmod o+w config/default
|
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
|
The configuration directory will be discovered by stripping the website's
|
||||||
user will need sufficient privileges to run SuiteDesk.
|
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
|
To create a database using PHPMyAdmin or a web-based control panel consult the
|
||||||
documentation or ask your webhost service provider.
|
documentation or ask your webhost service provider.
|
||||||
|
|
||||||
Take note of the username, password, database name and hostname as you create
|
Take note of the *username*, *password*, *database name* and *hostname* as you
|
||||||
the database. You will enter these items in the install script.
|
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
|
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
|
has the CREATE and GRANT privileges. Use the appropriate user name for your
|
||||||
system.
|
system.
|
||||||
|
|
||||||
First, you must create a new database for your Drupal site (here, 'databasename'
|
First, you must create a new database for your site (here, *databasename* is the
|
||||||
is the name of the new database):
|
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
|
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:
|
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
|
Again, you will be asked for the *username* database password. At the MySQL
|
||||||
prompt, enter following command:
|
prompt, enter following command:
|
||||||
|
|
||||||
|
```sql
|
||||||
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER,
|
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER,
|
||||||
CREATE TEMPORARY TABLES ON databasename.*
|
CREATE TEMPORARY TABLES ON databasename.*
|
||||||
TO 'username'@'localhost' IDENTIFIED BY 'password';
|
TO 'username'@'localhost' IDENTIFIED BY 'password';
|
||||||
|
```
|
||||||
|
|
||||||
where
|
where
|
||||||
|
|
||||||
'databasename' is the name of your database
|
*databasename* is the name of your database
|
||||||
'username@localhost' is the username of your MySQL account
|
*username@localhost* is the username of your MySQL account
|
||||||
'password' is the password required for that username
|
*password* is the password required for that username
|
||||||
|
|
||||||
Note: Unless your database user has all of the privileges listed above, you will
|
Note: Unless your database user has all of the privileges listed above, you will
|
||||||
not be able to run Drupal.
|
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
|
To run the install script point your browser to the base URL of your website
|
||||||
(e.g., http://www.example.com).
|
(e.g., http://www.example.com).
|
||||||
|
@ -149,7 +225,7 @@ system.
|
||||||
file is at config/default/settings.php, it may be in another location
|
file is at config/default/settings.php, it may be in another location
|
||||||
if you use the multi-site setup, as explained below.
|
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"
|
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
|
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
|
running FastCGI can run into problems if the $base_url variable is left
|
||||||
commented out (see http://bugs.php.net/bug.php?id=19656).
|
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
|
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.
|
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
|
Windows file permissions" (http://drupal.org/node/202491) in the online
|
||||||
handbook.
|
handbook.
|
||||||
|
|
||||||
### 7. CRON MAINTENANCE TASKS
|
### 8. CRON MAINTENANCE TASKS
|
||||||
|
|
||||||
Many Drupal modules have periodic tasks that must be triggered by a cron
|
Many Drupal modules have periodic tasks that must be triggered by a cron
|
||||||
maintenance task, including search module (to build and update the index
|
maintenance task, including search module (to build and update the index
|
||||||
|
|
|
@ -7,88 +7,13 @@
|
||||||
* This file may have been set to read-only by Drupal. If you make changes to
|
* 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.
|
* this file, be sure to protect it again after making your modifications.
|
||||||
* Failure to remove write permission to this file is a security risk.
|
* 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:
|
||||||
* Database settings.
|
$db_url['default'] = 'mysql://username:password@localhost/databasename';
|
||||||
*
|
|
||||||
* 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';
|
|
||||||
$db_prefix = '';
|
$db_prefix = '';
|
||||||
|
|
||||||
/**
|
// SuiteCRM (a fork of SugarCRM) database access:
|
||||||
* 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;
|
|
||||||
# $db_url['sugarcrm'] = 'mysql://username:password@localhost/databasename';
|
# $db_url['sugarcrm'] = 'mysql://username:password@localhost/databasename';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -356,7 +356,7 @@ function storm_user($op, &$edit, &$account, $category = NULL) {
|
||||||
* $_SESSION['SuiteCRM_Session_ID'] = Session ID for user in SuiteCRM
|
* $_SESSION['SuiteCRM_Session_ID'] = Session ID for user in SuiteCRM
|
||||||
*/
|
*/
|
||||||
function storm_init() {
|
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.
|
// 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);
|
drupal_add_js(drupal_get_path('module', 'storm') .'/storm.js', 'module', 'header', FALSE);
|
||||||
|
@ -397,7 +397,7 @@ function storm_init() {
|
||||||
$_SESSION['deskmenu'] = $deskmenu;
|
$_SESSION['deskmenu'] = $deskmenu;
|
||||||
|
|
||||||
// Verify SuiteCRM access. Get the SuiteCRM User ID:
|
// 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));
|
$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)) {
|
if (!empty($sugaruid)) {
|
||||||
$password = md5(substr(md5(microtime()), rand(0, 26), 16));
|
$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 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:
|
* Switch from original user to mail submission user and back. Notes:
|
||||||
*
|
*
|
||||||
|
|
|
@ -393,9 +393,7 @@ function stormorganization_form(&$node) {
|
||||||
* Implements hook_form_FORM_ID_alter().
|
* Implements hook_form_FORM_ID_alter().
|
||||||
*/
|
*/
|
||||||
function stormorganization_form_stormorganization_node_form_alter(&$form, &$form_state) {
|
function stormorganization_form_stormorganization_node_form_alter(&$form, &$form_state) {
|
||||||
global $conf;
|
if (storm_suitecrm_is_defined()) {
|
||||||
|
|
||||||
if ($conf['storm_suitecrm']) {
|
|
||||||
$form['group3']['#access'] = FALSE;
|
$form['group3']['#access'] = FALSE;
|
||||||
$form['group4']['#access'] = FALSE;
|
$form['group4']['#access'] = FALSE;
|
||||||
$form['group5']['taxid']['#access'] = FALSE;
|
$form['group5']['taxid']['#access'] = FALSE;
|
||||||
|
@ -448,7 +446,7 @@ function stormorganization_update($node) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function stormorganization_nodeapi(&$node, $op, $teaser, $page) {
|
function stormorganization_nodeapi(&$node, $op, $teaser, $page) {
|
||||||
global $base_url, $conf;
|
global $base_url;
|
||||||
|
|
||||||
if ($node->type != 'stormorganization') {
|
if ($node->type != 'stormorganization') {
|
||||||
return;
|
return;
|
||||||
|
@ -474,7 +472,7 @@ function stormorganization_nodeapi(&$node, $op, $teaser, $page) {
|
||||||
case 'validate':
|
case 'validate':
|
||||||
$nid = $node->nid;
|
$nid = $node->nid;
|
||||||
$organization_name = $node->title;
|
$organization_name = $node->title;
|
||||||
if (!$conf['storm_suitecrm'] || empty($organization_name)) {
|
if (!storm_suitecrm_is_defined() || empty($organization_name)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Checking if exists the organization in SuiteCRM:
|
// Checking if exists the organization in SuiteCRM:
|
||||||
|
@ -506,7 +504,7 @@ function stormorganization_nodeapi(&$node, $op, $teaser, $page) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'presave':
|
case 'presave':
|
||||||
if ($conf['storm_suitecrm']) {
|
if (storm_suitecrm_is_defined()) {
|
||||||
$sugarid = $node->field_stormorganization_sugarid[0]['value'];
|
$sugarid = $node->field_stormorganization_sugarid[0]['value'];
|
||||||
|
|
||||||
db_set_active('sugarcrm');
|
db_set_active('sugarcrm');
|
||||||
|
@ -528,7 +526,7 @@ function stormorganization_nodeapi(&$node, $op, $teaser, $page) {
|
||||||
|
|
||||||
case 'insert':
|
case 'insert':
|
||||||
case 'update':
|
case 'update':
|
||||||
if ($conf['storm_suitecrm']) {
|
if (storm_suitecrm_is_defined()) {
|
||||||
$sugarid = $node->field_stormorganization_sugarid[0]['value'];
|
$sugarid = $node->field_stormorganization_sugarid[0]['value'];
|
||||||
if (!empty($sugarid)) {
|
if (!empty($sugarid)) {
|
||||||
db_set_active('sugarcrm');
|
db_set_active('sugarcrm');
|
||||||
|
@ -539,7 +537,7 @@ function stormorganization_nodeapi(&$node, $op, $teaser, $page) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'delete':
|
case 'delete':
|
||||||
if ($conf['storm_suitecrm']) {
|
if (storm_suitecrm_is_defined()) {
|
||||||
$sugarid = $node->field_stormorganization_sugarid[0]['value'];
|
$sugarid = $node->field_stormorganization_sugarid[0]['value'];
|
||||||
if (!empty($sugarid)) {
|
if (!empty($sugarid)) {
|
||||||
db_set_active('sugarcrm');
|
db_set_active('sugarcrm');
|
||||||
|
@ -555,7 +553,7 @@ function stormorganization_nodeapi(&$node, $op, $teaser, $page) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'view':
|
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'];
|
$sugarid = $node->field_stormorganization_sugarid[0]['value'];
|
||||||
if (!empty($sugarid)) {
|
if (!empty($sugarid)) {
|
||||||
db_set_active('sugarcrm');
|
db_set_active('sugarcrm');
|
||||||
|
|
|
@ -389,9 +389,7 @@ function stormperson_form(&$node) {
|
||||||
* Implements hook_form_FORM_ID_alter().
|
* Implements hook_form_FORM_ID_alter().
|
||||||
*/
|
*/
|
||||||
function stormperson_form_stormperson_node_form_alter(&$form, &$form_state) {
|
function stormperson_form_stormperson_node_form_alter(&$form, &$form_state) {
|
||||||
global $conf;
|
if (storm_suitecrm_is_defined()) {
|
||||||
|
|
||||||
if ($conf['storm_suitecrm']) {
|
|
||||||
$form['group1']['#access'] = FALSE;
|
$form['group1']['#access'] = FALSE;
|
||||||
$form['group3']['#access'] = FALSE;
|
$form['group3']['#access'] = FALSE;
|
||||||
$form['group4']['#access'] = FALSE;
|
$form['group4']['#access'] = FALSE;
|
||||||
|
@ -501,7 +499,7 @@ function _stormperson_aftersave(&$node) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function stormperson_nodeapi(&$node, $op, $teaser, $page) {
|
function stormperson_nodeapi(&$node, $op, $teaser, $page) {
|
||||||
global $base_url, $conf;
|
global $base_url;
|
||||||
|
|
||||||
if ($node->type != 'stormperson') {
|
if ($node->type != 'stormperson') {
|
||||||
return;
|
return;
|
||||||
|
@ -512,7 +510,7 @@ function stormperson_nodeapi(&$node, $op, $teaser, $page) {
|
||||||
$name = $node->field_stormperson_name[0]['value'];
|
$name = $node->field_stormperson_name[0]['value'];
|
||||||
$lastname = $node->field_stormperson_lastname[0]['value'];
|
$lastname = $node->field_stormperson_lastname[0]['value'];
|
||||||
$fullname = empty($lastname) ? $name : $lastname . ', ' . $name;
|
$fullname = empty($lastname) ? $name : $lastname . ', ' . $name;
|
||||||
if (!$conf['storm_suitecrm'] || empty($fullname)) {
|
if (!storm_suitecrm_is_defined() || empty($fullname)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Checking if exists the contact in SuiteCRM:
|
// Checking if exists the contact in SuiteCRM:
|
||||||
|
@ -544,7 +542,7 @@ function stormperson_nodeapi(&$node, $op, $teaser, $page) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'presave':
|
case 'presave':
|
||||||
if ($conf['storm_suitecrm']) {
|
if (storm_suitecrm_is_defined()) {
|
||||||
$sugarid = $node->field_stormperson_sugarid[0]['value'];
|
$sugarid = $node->field_stormperson_sugarid[0]['value'];
|
||||||
|
|
||||||
db_set_active('sugarcrm');
|
db_set_active('sugarcrm');
|
||||||
|
@ -566,7 +564,7 @@ function stormperson_nodeapi(&$node, $op, $teaser, $page) {
|
||||||
|
|
||||||
case 'insert':
|
case 'insert':
|
||||||
case 'update':
|
case 'update':
|
||||||
if ($conf['storm_suitecrm']) {
|
if (storm_suitecrm_is_defined()) {
|
||||||
$sugarid = $node->field_stormperson_sugarid[0]['value'];
|
$sugarid = $node->field_stormperson_sugarid[0]['value'];
|
||||||
if (!empty($sugarid)) {
|
if (!empty($sugarid)) {
|
||||||
db_set_active('sugarcrm');
|
db_set_active('sugarcrm');
|
||||||
|
@ -577,7 +575,7 @@ function stormperson_nodeapi(&$node, $op, $teaser, $page) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'delete':
|
case 'delete':
|
||||||
if ($conf['storm_suitecrm']) {
|
if (storm_suitecrm_is_defined()) {
|
||||||
$sugarid = $node->field_stormperson_sugarid[0]['value'];
|
$sugarid = $node->field_stormperson_sugarid[0]['value'];
|
||||||
if (!empty($sugarid)) {
|
if (!empty($sugarid)) {
|
||||||
db_set_active('sugarcrm');
|
db_set_active('sugarcrm');
|
||||||
|
@ -593,7 +591,7 @@ function stormperson_nodeapi(&$node, $op, $teaser, $page) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'view':
|
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'];
|
$sugarid = $node->field_stormperson_sugarid[0]['value'];
|
||||||
if (!empty($sugarid)) {
|
if (!empty($sugarid)) {
|
||||||
db_set_active('sugarcrm');
|
db_set_active('sugarcrm');
|
||||||
|
|
Reference in a new issue