Skip to content
Snippets Groups Projects
Commit a5ecff8d authored by xurizaemon's avatar xurizaemon
Browse files

Code style & docs.

parent f3d83384
No related branches found
No related tags found
No related merge requests found
......@@ -63,7 +63,7 @@ class CRM_Utils_System_Drupal extends CRM_Utils_System_Base {
$admin = user_access('administer users');
if (!variable_get('user_email_verification', TRUE) || $admin) {
$form_state['input']['pass'] = array('pass1'=>$params['cms_pass'],'pass2'=>$params['cms_pass']);
$form_state['input']['pass'] = array('pass1'=>$params['cms_pass'],'pass2'=>$params['cms_pass']);
}
if(!empty($params['notify'])){
......@@ -98,9 +98,7 @@ class CRM_Utils_System_Drupal extends CRM_Utils_System_Base {
if (form_get_errors()) {
return FALSE;
}
else {
return $form_state['user']->uid;
}
return $form_state['user']->uid;
}
/*
......@@ -550,7 +548,8 @@ class CRM_Utils_System_Drupal extends CRM_Utils_System_Base {
*
* @param string $name the user name
* @param string $password the password for the above user name
* @param $loadCMSBootstrap boolean load cms bootstrap?
* @param boolean $loadCMSBootstrap load cms bootstrap?
* @param NULL|string $realPath filename of script
*
* @return mixed false if no auth
* array(
......@@ -567,8 +566,6 @@ class CRM_Utils_System_Drupal extends CRM_Utils_System_Base {
CRM_Core_Error::fatal("Cannot connect to drupal db via $config->userFrameworkDSN, " . $dbDrupal->getMessage());
}
$account = $userUid = $userMail = NULL;
if ($loadCMSBootstrap) {
$bootStrapParams = array();
......@@ -725,11 +722,11 @@ AND u.status = 1
/**
* load drupal bootstrap
*
* @param $params array with uid or name and password
* @param $loadUser boolean load cms user?
* @param $throwError throw error on failure?
* @param array $params Either uid, or name & pass.
* @param boolean $loadUser boolean Require CMS user load.
* @param boolean $throwError If true, print error on failure and exit.
* @param boolean|string $realPath path to script
*/
function loadBootStrap($params = array(), $loadUser = TRUE, $throwError = TRUE, $realPath = NULL) {
//take the cms root path.
$cmsPath = $this->cmsRootPath($realPath);
......@@ -826,8 +823,10 @@ AND u.status = 1
return FALSE;
}
/**
*
*/
function cmsRootPath($scriptFilename = NULL) {
$cmsRoot = $valid = NULL;
if (!is_null($scriptFilename)) {
......@@ -913,11 +912,7 @@ AND u.status = 1
* @return string $url, formatted url.
* @static
*/
function languageNegotiationURL(
$url,
$addLanguagePart = TRUE,
$removeLanguagePart = FALSE
) {
function languageNegotiationURL($url, $addLanguagePart = TRUE, $removeLanguagePart = FALSE) {
if (empty($url)) {
return $url;
}
......@@ -1009,12 +1004,17 @@ AND u.status = 1
/**
* Wrapper for og_membership creation
*
* @param integer $ogID Organic Group ID
* @param integer $drupalID drupal User ID
*/
function og_membership_create($ogID, $drupalID){
if (function_exists('og_entity_query_alter')) {
// sort-of-randomly chose a function that only exists in the 7.x-2.x branch
// TODO: Find a more solid way to make this test
// Also, since we don't know how to get the entity type of the group, we'll assume it's 'node'
// sort-of-randomly chose a function that only exists in the // 7.x-2.x branch
//
// @TODO Find more solid way to check - try system_get_info('module', 'og').
//
// Also, since we don't know how to get the entity type of the // group, we'll assume it's 'node'
og_group('node', $ogID, array('entity' => user_load($drupalID)));
}
else {
......@@ -1025,6 +1025,9 @@ AND u.status = 1
/**
* Wrapper for og_membership deletion
*
* @param integer $ogID Organic Group ID
* @param integer $drupalID drupal User ID
*/
function og_membership_delete($ogID, $drupalID) {
if (function_exists('og_entity_query_alter')) {
......
......@@ -119,9 +119,7 @@ class CRM_Utils_System_Drupal6 extends CRM_Utils_System_Base {
if (form_get_errors() || !isset($form_state['user'])) {
return FALSE;
}
return $form_state['user']->uid;
}
/*
......@@ -158,7 +156,6 @@ class CRM_Utils_System_Drupal6 extends CRM_Utils_System_Base {
$email = $dao->escape(CRM_Utils_Array::value('mail', $params));
_user_edit_validate(NULL, $params);
$errors = form_get_errors();
if ($errors) {
if (CRM_Utils_Array::value('name', $errors)) {
$errors['cms_name'] = $errors['name'];
......@@ -170,7 +167,7 @@ class CRM_Utils_System_Drupal6 extends CRM_Utils_System_Base {
unset($_SESSION['messages']);
}
// drupal api sucks do the name check manually
// Do the name check manually.
$nameError = user_validate_name($params['name']);
if ($nameError) {
$errors['cms_name'] = $nameError;
......@@ -181,7 +178,6 @@ SELECT name, mail
FROM {$config->userFrameworkUsersTableName}
WHERE (LOWER(name) = LOWER('$name')) OR (LOWER(mail) = LOWER('$email'))";
$db_cms = DB::connect($config->userFrameworkDSN);
if (DB::isError($db_cms)) {
die("Cannot connect to UF db via $dsn, " . $db_cms->getMessage());
......@@ -426,7 +422,6 @@ SELECT name, mail
*
* @return string the url to post the form
* @access public
*/
function postURL($action) {
if (!empty($action)) {
......@@ -516,6 +511,8 @@ SELECT name, mail
*
* @param string $name the user name
* @param string $password the password for the above user name
* @param boolean $loadCMSBootstrap load cms bootstrap?
* @param NULL|string $realPath filename of script
*
* @return mixed false if no auth
* array(
......@@ -557,8 +554,8 @@ SELECT name, mail
}
CRM_Utils_System::loadBootStrap($bootStrapParams, TRUE, TRUE, $realPath);
}
return array($contactID, $row['uid'], mt_rand());
}
return array($contactID, $row['uid'], mt_rand());
}
}
return FALSE;
}
......@@ -641,11 +638,12 @@ SELECT name, mail
/**
* load drupal bootstrap
*
* @param $name string optional username for login
* @param $pass string optional password for login
* @param array $params Either uid, or name & pass.
* @param boolean $loadUser boolean Require CMS user load.
* @param boolean $throwError If true, print error on failure and exit.
* @param boolean|string $realPath path to script
*/
function loadBootStrap($params = array(
), $loadUser = TRUE, $throwError = TRUE, $realPath = NULL) {
function loadBootStrap($params = array(), $loadUser = TRUE, $throwError = TRUE, $realPath = NULL) {
$uid = CRM_Utils_Array::value('uid', $params);
$name = CRM_Utils_Array::value('name', $params, FALSE) ? $params['name'] : trim(CRM_Utils_Array::value('name', $_REQUEST));
$pass = CRM_Utils_Array::value('pass', $params, FALSE) ? $params['pass'] : trim(CRM_Utils_Array::value('pass', $_REQUEST));
......@@ -661,12 +659,11 @@ SELECT name, mail
require_once 'includes/bootstrap.inc';
@drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
if (!function_exists('module_exists') ||
!module_exists('civicrm')
) {
echo '<br />Sorry, could not able to load drupal bootstrap.';
if (!function_exists('module_exists') || !module_exists('civicrm')) {
echo '<br />Sorry, could not load drupal bootstrap.';
exit();
}
// lets also fix the clean url setting
// CRM-6948
$config->cleanURL = (int) variable_get('clean_url', '0');
......@@ -701,6 +698,9 @@ SELECT name, mail
}
}
/**
*
*/
function cmsRootPath($scriptFilename = NULL) {
$cmsRoot = $valid = NULL;
......@@ -710,6 +710,7 @@ SELECT name, mail
else {
$path = $_SERVER['SCRIPT_FILENAME'];
}
if (function_exists('drush_get_context')) {
// drush anyway takes care of multisite install etc
return drush_get_context('DRUSH_DRUPAL_ROOT');
......@@ -786,10 +787,7 @@ SELECT name, mail
* @return string $url, formatted url.
* @static
*/
function languageNegotiationURL($url,
$addLanguagePart = TRUE,
$removeLanguagePart = FALSE
) {
function languageNegotiationURL($url, $addLanguagePart = TRUE, $removeLanguagePart = FALSE) {
if (empty($url)) {
return $url;
}
......@@ -936,4 +934,3 @@ SELECT name, mail
drupal_flush_all_caches();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment