'pay_later_text',
'pay_later_receipt',
'label', // This is needed for FROM Email Address configuration. dgg
- 'url', // This is needed for navigation items urls
+ 'url', // This is needed for navigation items urls
'details',
'msg_text', // message templates’ text versions
'text_message', // (send an) email to contact’s and CiviMail’s text version
$apiRequest['params'] = $this->match($apiRequest['entity'], $apiRequest['params'], $keys, $isMandatory);
}
break;
+
case 'replace':
// In addition to matching on the listed keys, also match on the set-definition keys.
// For example, if the $apiRequest is to "replace the set of civicrm_emails for contact_id=123 while
$apiRequest['params']['values'][$offset] = $createParams;
}
break;
+
default:
// be forgiveful of sloppily api calls
}
*/
static function format(
$fields,
- $format = NULL,
- $microformat = FALSE,
- $mailing = FALSE,
+ $format = NULL,
+ $microformat = FALSE,
+ $mailing = FALSE,
$individualFormat = FALSE,
- $tokenFields = NULL
+ $tokenFields = NULL
) {
static $config = NULL;
}
if (!$microformat) {
- // replacements in case of Individual Name Format
+ // replacements in case of Individual Name Format
$replacements = array(
'contact.display_name' => CRM_Utils_Array::value('display_name', $fields),
'contact.individual_prefix' => CRM_Utils_Array::value('individual_prefix', $fields),
$dao = CRM_Core_DAO::executeQuery($query, $params);
if ($processGeocode) {
- require_once (str_replace('_', DIRECTORY_SEPARATOR, $config->geocodeMethod) . '.php');
+ require_once str_replace('_', DIRECTORY_SEPARATOR, $config->geocodeMethod) . '.php';
}
-
$unparseableContactAddress = array();
while ($dao->fetch()) {
$totalAddresses++;
}
$className = $config->geocodeMethod;
- $className::format( $params, true );
+ $className::format( $params, TRUE );
// see if we got a geocode error, in this case we'll trigger a fatal
// CRM-13760
return FALSE;
}
-
$userID = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::ADDRESS_STANDARDIZATION_PREFERENCES_NAME,
'address_standardization_userid'
);
return FALSE;
}
- $values['street_address'] = (string)$xml->Address->Address2;
- $values['city'] = (string)$xml->Address->City;
- $values['state_province'] = (string)$xml->Address->State;
- $values['postal_code'] = (string)$xml->Address->Zip5;
- $values['postal_code_suffix'] = (string)$xml->Address->Zip4;
+ $values['street_address'] = (string) $xml->Address->Address2;
+ $values['city'] = (string) $xml->Address->City;
+ $values['state_province'] = (string) $xml->Address->State;
+ $values['postal_code'] = (string) $xml->Address->Zip5;
+ $values['postal_code_suffix'] = (string) $xml->Address->Zip4;
if (array_key_exists('Address1', $xml->Address)) {
- $values['supplemental_address_1'] = (string)$xml->Address->Address1;
+ $values['supplemental_address_1'] = (string) $xml->Address->Address1;
}
return TRUE;
* When passed an array of strings, unsets $items[$k] for each string $k
* in the array.
*/
- public static function remove(&$items) {
- foreach (func_get_args() as $n => $key) {
- // Skip argument 0 ($items) by testing $n for truth.
- if ($n && is_array($key)) {
- foreach($key as $k) {
- unset($items[$k]);
- }
- }
- elseif ($n) {
- unset($items[$key]);
- }
- }
- }
+ public static function remove(&$items) {
+ foreach (func_get_args() as $n => $key) {
+ // Skip argument 0 ($items) by testing $n for truth.
+ if ($n && is_array($key)) {
+ foreach($key as $k) {
+ unset($items[$k]);
+ }
+ }
+ elseif ($n) {
+ unset($items[$key]);
+ }
+ }
+ }
/**
* Builds an array-tree which indexes the records in an array.
$node = &$node[$keyvalue];
}
if (is_array($record)) {
- $node[ $record[$final_key] ] = $record;
+ $node[$record[$final_key]] = $record;
} else {
- $node[ $record->{$final_key} ] = $record;
+ $node[$record->{$final_key}] = $record;
}
}
return $result;
// a generic method for utilizing any of the available db caches.
$dbCacheClass = 'CRM_Utils_Cache_' . $className;
- require_once(str_replace('_', DIRECTORY_SEPARATOR, $dbCacheClass) . '.php');
+ require_once str_replace('_', DIRECTORY_SEPARATOR, $dbCacheClass) . '.php';
$settings = self::getCacheSettings($className);
self::$_singleton = new $dbCacheClass($settings);
}
foreach ($keys as $key) {
$name = $key['info'];
- if ($prefix == substr($name,0,$lp)) { // Ours?
+ if ($prefix == substr($name, 0, $lp)) { // Ours?
apc_delete($this->_prefix . $name);
}
}
* @return string
*/
public function fileName ($key) {
- if (strlen($key) > 50)
+ if (strlen($key) > 50) {
return CIVICRM_TEMPLATE_COMPILEDIR ."CRM_".md5($key).".php";
+ }
return CIVICRM_TEMPLATE_COMPILEDIR .$key.".php";
}
* @return mixed
*/
public function get ($key) {
- if (array_key_exists($key,$this->_cache))
+ if (array_key_exists($key, $this->_cache)) {
return $this->_cache[$key];
+ }
- if (!file_exists($this->fileName ($key))) {
+ if (!file_exists($this->fileName($key))) {
return;
}
- $this->_cache[$key] = unserialize (substr (file_get_contents ($this->fileName ($key)),8));
+ $this->_cache[$key] = unserialize(substr(file_get_contents($this->fileName($key)), 8));
return $this->_cache[$key];
}
* @param mixed $value
*/
public function set($key, &$value) {
- if (file_exists($this->fileName ($key))) {
+ if (file_exists($this->fileName($key))) {
return;
}
$this->_cache[$key] = $value;
- file_put_contents ($this->fileName ($key),"<?php //".serialize ($value));
+ file_put_contents($this->fileName($key), "<?php //".serialize($value));
}
/**
* @param string $key
*/
public function delete($key) {
- if (file_exists($this->fileName ($key))) {
- unlink ($this->fileName ($key));
+ if (file_exists($this->fileName($key))) {
+ unlink($this->fileName($key));
}
unset($this->_cache[$key]);
}
/**
* @param null $key
*/
- public function flush($key =null) {
+ public function flush($key = NULL) {
$prefix = "CRM_";
if (!$handle = opendir(CIVICRM_TEMPLATE_COMPILEDIR)) {
return; // die? Error?
}
- while (false !== ($entry = readdir($handle))) {
- if (substr ($entry,0,4) == $prefix) {
- unlink (CIVICRM_TEMPLATE_COMPILEDIR.$entry);
+ while (FALSE !== ($entry = readdir($handle))) {
+ if (substr($entry, 0, 4) == $prefix) {
+ unlink(CIVICRM_TEMPLATE_COMPILEDIR.$entry);
}
}
closedir($handle);
case 'CiviCase':
$checks[] = new CRM_Utils_Check_Case(CRM_Case_XMLRepository::singleton(), CRM_Case_PseudoConstant::caseType('name'));
break;
+
default:
}
}
'checkOutboundMail',
ts('Warning: Outbound email is disabled in <a href="%1">system settings</a>. Proper settings should be enabled on production servers.',
array(1 => CRM_Utils_System::url('civicrm/admin/setting/smtp', 'reset=1'))),
-
ts('Outbound Email Settings')
);
}
switch ($config->userFramework) {
case 'Joomla':
return '/media/';
+
default:
return '/files/';
}
* @static
*/
public static function convertToDefaultDate(&$params, $dateType, $dateParam) {
- $now = getDate();
+ $now = getdate();
$cen = substr($now['year'], 0, 2);
$prevCen = $cen - 1;
}
}
-
if ($dateType == 2 || $dateType == 4) {
$formattedDate = explode("/", $value);
if (count($formattedDate) != 3) {
* actuall today pass 'dayParams' as null. or else pass the day,
* month, year values as array values
* Example: $dayParams = array(
- 'day' => '25', 'month' => '10',
+ 'day' => '25', 'month' => '10',
* 'year' => '2007' );
*
- * @param Array $dayParams
+ * @param array $dayParamsArray of the day, month, year.
* Array of the day, month, year.
* values.
* @param string $format
* @static
*/
public static function relativeToAbsolute($relativeTerm, $unit) {
- $now = getDate();
+ $now = getdate();
$from = $to = $dateRange = array();
$from['H'] = $from['i'] = $from['s'] = 0;
$from['Y'] = $now['year'];
$from['H'] = 00;
$from['i'] = $to['s'] = 00;
- $to = self::intervalAdd('month', +1, $from);
- $to = self::intervalAdd('second',-1, $to);
+ $to = self::intervalAdd('month', + 1, $from);
+ $to = self::intervalAdd('second', -1, $to);
break;
}
break;
$from['M'] = $now['mon'];
$from['Y'] = $now['year'];
$from = self::intervalAdd('day', -1 * ($now['wday']) + 7, $from);
- $to = self::intervalAdd('day', +6, $from);
+ $to = self::intervalAdd('day', + 6, $from);
break;
case 'starting':
$from['Y'] = $now['year'];
$from['H'] = 00;
$from['i'] = $to['s'] = 00;
- $to = self::intervalAdd('day', +7, $from);
+ $to = self::intervalAdd('day', + 7, $from);
$to = self::intervalAdd('second', -1, $to);
break;
}
$to['d'] = $now['mday'];
$to['M'] = $now['mon'];
$to['Y'] = $now['year'];
- $to = self::intervalAdd('day', +1, $to);
+ $to = self::intervalAdd('day', + 1, $to);
$from['d'] = $to['d'];
$from['M'] = $to['M'];
$from['Y'] = $to['Y'];
$dateFormat = CRM_Utils_Array::value( $format, $actualPHPFormats );
*/
-
$dateFormat = 'm/d/Y';
$date = date($dateFormat, strtotime($mysqlDate));
*
* @return array|CRM_Error
*/
-function _civicrm_api3_deprecated_formatted_param($params, &$values, $create = FALSE, $onDuplicate = Null) {
+function _civicrm_api3_deprecated_formatted_param($params, &$values, $create = FALSE, $onDuplicate = NULL) {
// copy all the contribution fields as is
$fields = CRM_Contribute_DAO_Contribution::fields();
return civicrm_api3_create_error("Invalid email address(duplicate) $email for Soft Credit. Row was skipped");
}
elseif (count($matchingContactIds) == 1) {
- $contactId = $matchingContactIds[0];
+ $contactId = $matchingContactIds[0];
unset($softParam['email']);
$values[$key][$softKey] = $softParam + array('contact_id' => $contactId);
}
}
}
}
- }
- break;
+ }
+ break;
case 'pledge_payment':
case 'pledge_id':
$defaultLocation = CRM_Core_BAO_LocationType::getDefault();
//set the value to default location id else set to 1
- if (!$defaultLocationId = (int)$defaultLocation->id) {
+ if (!$defaultLocationId = (int) $defaultLocation->id) {
$defaultLocationId = 1;
}
}
}
foreach (array(
- 'Phone', 'Email', 'IM', 'OpenID','Phone_Ext') as $block) {
+ 'Phone', 'Email', 'IM', 'OpenID', 'Phone_Ext') as $block) {
$name = strtolower($block);
if (!array_key_exists($name, $values)) {
continue;
$customFieldID = CRM_Core_BAO_CustomField::getKeyID($key);
if ($customFieldID && array_key_exists($customFieldID, $customFields)) {
// mark an entry in fields array since we want the value of custom field to be copied
- $fields['Address'][$key] = null;
+ $fields['Address'][$key] = NULL;
$htmlType = CRM_Utils_Array::value( 'html_type', $customFields[$customFieldID] );
switch ( $htmlType ) {
- case 'CheckBox':
- case 'AdvMulti-Select':
- case 'Multi-Select':
- if ( $val ) {
- $mulValues = explode( ',', $val );
- $customOption = CRM_Core_BAO_CustomOption::getCustomOption( $customFieldID, true );
- $newValues[$key] = array( );
- foreach ( $mulValues as $v1 ) {
- foreach ( $customOption as $v2 ) {
- if ( ( strtolower( $v2['label'] ) == strtolower( trim( $v1 ) ) ) ||
+ case 'CheckBox':
+ case 'AdvMulti-Select':
+ case 'Multi-Select':
+ if ( $val ) {
+ $mulValues = explode( ',', $val );
+ $customOption = CRM_Core_BAO_CustomOption::getCustomOption( $customFieldID, TRUE );
+ $newValues[$key] = array();
+ foreach ( $mulValues as $v1 ) {
+ foreach ( $customOption as $v2 ) {
+ if ( ( strtolower( $v2['label'] ) == strtolower( trim( $v1 ) ) ) ||
( strtolower( $v2['value'] ) == strtolower( trim( $v1 ) ) ) ) {
- if ( $htmlType == 'CheckBox' ) {
- $newValues[$key][$v2['value']] = 1;
- } else {
- $newValues[$key][] = $v2['value'];
+ if ( $htmlType == 'CheckBox' ) {
+ $newValues[$key][$v2['value']] = 1;
+ } else {
+ $newValues[$key][] = $v2['value'];
+ }
}
}
}
}
- }
- break;
+ break;
}
}
}
$errorMsg = "Invalid Custom Field Contact Type: {$params['contact_type']}";
if (!empty($csType)) {
- $errorMsg .= " or Mismatched SubType: " . implode(', ', (array)$csType);
+ $errorMsg .= " or Mismatched SubType: " . implode(', ', (array) $csType);
}
return civicrm_api3_create_error($errorMsg);
}
),
);
-
// contact_type has a limited number of valid values
if(empty($params['contact_type'])) {
return civicrm_api3_create_error("No Contact Type");
if ($csType = CRM_Utils_Array::value('contact_sub_type', $params)) {
if (!(CRM_Contact_BAO_ContactType::isExtendsContactType($csType, $params['contact_type']))) {
- return civicrm_api3_create_error("Invalid or Mismatched Contact Subtype: " . implode(', ', (array)$csType));
+ return civicrm_api3_create_error("Invalid or Mismatched Contact Subtype: " . implode(', ', (array) $csType));
}
}
elseif (is_file($object)) {
if (!unlink($object)) {
CRM_Core_Session::setStatus(ts('Unable to remove file %1', array(1 => $object)), ts('Warning'), 'error');
+ }
}
}
}
- }
closedir($sourcedir);
if ($rmdir) {
CRM_Core_Session::setStatus(ts('Removed directory %1', array(1 => $target)), '', 'success');
}
return TRUE;
- }
+ }
else {
CRM_Core_Session::setStatus(ts('Unable to remove directory %1', array(1 => $target)), ts('Warning'), 'error');
- }
- }
+ }
+ }
}
}
CRM_Utils_File::copyDir($fromDir, $toDir);
if (!CRM_Utils_File::cleanDir($fromDir, TRUE, FALSE)) {
- CRM_Core_Session::setStatus(ts('Failed to clean temp dir: %1', array(1 => $fromDir)), '', 'alert');
+ CRM_Core_Session::setStatus(ts('Failed to clean temp dir: %1', array(1 => $fromDir)), '', 'alert');
return FALSE;
}
return TRUE;
) {
$ret = $xml->result->geometry->location->children();
if ($ret->lat && $ret->lng) {
- $values['geo_code_1'] = (float)$ret->lat;
- $values['geo_code_2'] = (float)$ret->lng;
+ $values['geo_code_1'] = (float) $ret->lat;
+ $values['geo_code_2'] = (float) $ret->lng;
return TRUE;
}
}
if (self::$_singleton == NULL || $fresh) {
$config = CRM_Core_Config::singleton();
$class = $config->userHookClass;
- require_once (str_replace('_', DIRECTORY_SEPARATOR, $config->userHookClass) . '.php');
+ require_once str_replace('_', DIRECTORY_SEPARATOR, $config->userHookClass) . '.php';
self::$_singleton = new $class();
}
return self::$_singleton;
}
/**
- *Invoke hooks
+ * Invoke hooks
*
* @param int $numParams
* Number of parameters to pass to the hook.
if (!empty($config->customPHPPathDir) &&
file_exists("{$config->customPHPPathDir}/civicrmHooks.php")
) {
- @include_once ("civicrmHooks.php");
+ @include_once "civicrmHooks.php";
}
if (!empty($fnPrefix)) {
}
include_once $civiModule['filePath'];
$moduleList[$civiModule['prefix']] = $civiModule['prefix'];
- }
}
+ }
/**
* This hook is called before a db write on some core objects.
*/
static function tokenValues(&$details,
$contactIDs,
- $jobID = NULL,
- $tokens = array(),
+ $jobID = NULL,
+ $tokens = array(),
$className = NULL
) {
return self::singleton()->invoke(5, $details, $contactIDs, $jobID, $tokens, $className, self::$_nullObject, 'civicrm_tokenValues');
* Reserved for future use.
*/
static function unhandledException($exception, $request = NULL) {
- self::singleton()->invoke(2, $exception, $request, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,'civicrm_unhandled_exception');
+ self::singleton()->invoke(2, $exception, $request, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_unhandled_exception');
// == 4.4 ==
//$event = new stdClass();
//$event->exception = $exception;
*
* @return mixed
*/
- public static function alterBarcode( &$data, $type = 'barcode', $context = 'name_badge' ) {
+ public static function alterBarcode(&$data, $type = 'barcode', $context = 'name_badge') {
return self::singleton()->invoke(3, $data, $type, $context, self::$_nullObject,
self::$_nullObject, self::$_nullObject, 'civicrm_alterBarcode');
}
*/
class CRM_Utils_Hook_Joomla extends CRM_Utils_Hook {
/**
- *Invoke hooks
+ * Invoke hooks
*
* @param int $numParams
* Number of parameters to pass to the hook.
*/
class CRM_Utils_Hook_Soap extends CRM_Utils_Hook {
/**
- *Invoke hooks
+ * Invoke hooks
*
* @param int $numParams
* Number of parameters to pass to the hook.
}
/**
- *Invoke hooks
+ * Invoke hooks
*
* @param int $numParams
* Number of parameters to pass to the hook.
);
/**
- *Invoke hooks
+ * Invoke hooks
*
* @param int $numParams
* Number of parameters to pass to the hook.
&$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6,
$fnSuffix
) {
-
+
/**
- * do_action_ref_array is the default way of calling WordPress hooks
- * because for the most part no return value is wanted. However, this is
- * only generally true, so using do_action_ref_array() is only called for those
+ * do_action_ref_array is the default way of calling WordPress hooks
+ * because for the most part no return value is wanted. However, this is
+ * only generally true, so using do_action_ref_array() is only called for those
* hooks which do not require a return value. We exclude the following, which
* are incompatible with the WordPress Plugin API:
- *
+ *
* civicrm_upgrade
* http://wiki.civicrm.org/confluence/display/CRMDOC43/hook_civicrm_upgrade
- *
+ *
* civicrm_caseSummary
* http://wiki.civicrm.org/confluence/display/CRMDOC43/hook_civicrm_caseSummary
- *
+ *
* civicrm_dashboard
* http://wiki.civicrm.org/confluence/display/CRMDOC43/hook_civicrm_dashboard
*/
-
+
// distinguish between types of hook
if ( ! in_array( $fnSuffix, $this->hooksThatReturn ) ) {
-
+
// only pass the arguments that have values
- $args = array_slice(
- array( &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6 ),
- 0,
+ $args = array_slice(
+ array( &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6 ),
+ 0,
$numParams
);
-
+
/**
* Use WordPress Plugins API to modify $args
*
- * Because $args are passed as references to the WordPress callbacks,
+ * Because $args are passed as references to the WordPress callbacks,
* runHooks subsequently receives appropriately modified parameters.
*/
-
+
// protect from REST calls
if (function_exists('do_action_ref_array')) {
do_action_ref_array( $fnSuffix, $args );
}
-
+
}
-
-
-
+
/**
- * The following is based on the logic of the Joomla hook file by allowing
+ * The following is based on the logic of the Joomla hook file by allowing
* WordPress callbacks to do their stuff before runHooks gets called.
- *
- * It also follows the logic of the Drupal hook file by building the "module"
+ *
+ * It also follows the logic of the Drupal hook file by building the "module"
* (read "plugin") list and then calling runHooks directly. This should avoid
* the need for the post-processing that the Joomla hook file does.
- *
- * Note that hooks which require a return value are incompatible with the
- * signature of apply_filters_ref_array and must therefore be called in
- * global scope, like in Drupal. It's not ideal, but plugins can always route
+ *
+ * Note that hooks which require a return value are incompatible with the
+ * signature of apply_filters_ref_array and must therefore be called in
+ * global scope, like in Drupal. It's not ideal, but plugins can always route
* these calls to methods in their classes.
- *
+ *
* At some point, those hooks could be pre-processed and called via the WordPress
* Plugin API, but it would change their signature and require the CiviCRM docs
* to be rewritten for those calls in WordPress. So it's been done this way for
- * now. Ideally these hooks will be deprecated in favour of hooks that do not
+ * now. Ideally these hooks will be deprecated in favour of hooks that do not
* require return values.
*/
-
+
// build list of registered plugin codes
$this->buildModuleList();
-
+
// Call runHooks the same way Drupal does
$moduleResult = $this->runHooks(
- $this->allModules,
+ $this->allModules,
$fnSuffix,
- $numParams,
+ $numParams,
$arg1, $arg2, $arg3, $arg4, $arg5, $arg6
);
-
+
// finally, return
return empty($moduleResult) ? TRUE : $moduleResult;
-
+
}
-
+
/**
* Build the list of plugins ("modules" in CiviCRM terminology) to be processed for hooks.
* We need to do this to preserve the CiviCRM hook signatures for hooks that require
* a return value, since the WordPress Plugin API seems to be incompatible with them.
- *
+ *
* Copied and adapted from: CRM/Utils/Hook/Drupal6.php
*/
public function buildModuleList() {
if ($this->isBuilt === FALSE) {
-
+
if ($this->wordpressModules === NULL) {
-
+
// include custom PHP file - copied from parent->commonBuildModuleList()
$config = CRM_Core_Config::singleton();
if (!empty($config->customPHPPathDir) &&
file_exists("{$config->customPHPPathDir}/civicrmHooks.php")
) {
- @include_once ('civicrmHooks.php');
+ @include_once 'civicrmHooks.php';
}
// initialise with the pre-existing 'wordpress' prefix
$this->wordpressModules = array('wordpress');
-
+
/**
* Use WordPress Plugin API to build list
* a plugin simply needs to declare its "unique_plugin_code" thus:
* add_filter('civicrm_wp_plugin_codes', 'function_that_returns_my_unique_plugin_code');
*/
-
+
// protect from REST calls
if (function_exists('apply_filters')) {
$this->wordpressModules = apply_filters('civicrm_wp_plugin_codes', $this->wordpressModules);
}
-
+
}
if ($this->civiModules === NULL) {
$this->requireCiviModules($this->civiModules);
}
- $this->allModules = array_merge((array)$this->wordpressModules, (array)$this->civiModules);
+ $this->allModules = array_merge((array) $this->wordpressModules, (array) $this->civiModules);
if ($this->wordpressModules !== NULL && $this->civiModules !== NULL) {
// both CRM and CMS have bootstrapped, so this is the final list
$this->isBuilt = TRUE;
}
-
+
}
}
}
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_POST, true);
- curl_setopt($ch, CURLOPT_POST,count($params));
- curl_setopt($ch, CURLOPT_POSTFIELDS,$params);
+ curl_setopt($ch, CURLOPT_POST, TRUE);
+ curl_setopt($ch, CURLOPT_POST, count($params));
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
$data = curl_exec($ch);
if (curl_errno($ch)) {
return array(self::STATUS_DL_ERROR, $data);
$headers = &$msg->headers($headers);
$to = array($params['toEmail']);
- $result = null;
+ $result = NULL;
$mailer =& CRM_Core_Config::getMailer( );
// Mail_smtp and Mail_sendmail mailers require Bcc anc Cc emails
// be included in both $to and $headers['Cc', 'Bcc']
if (get_class($mailer) != "Mail_mail") {
- //get emails from headers, since these are
- //combination of name and email addresses.
- if (!empty($headers['Cc'])) {
- $to[] = CRM_Utils_Array::value( 'Cc', $headers );
- }
- if (!empty($headers['Bcc'])) {
- $to[] = CRM_Utils_Array::value( 'Bcc', $headers );
- }
+ //get emails from headers, since these are
+ //combination of name and email addresses.
+ if (!empty($headers['Cc'])) {
+ $to[] = CRM_Utils_Array::value( 'Cc', $headers );
+ }
+ if (!empty($headers['Bcc'])) {
+ $to[] = CRM_Utils_Array::value( 'Bcc', $headers );
+ }
}
if (is_object($mailer)) {
$errorScope = CRM_Core_TemporaryErrorScope::ignoreException();
$usedfor = $dao->is_default;
$emailActivityTypeId =
- (defined('EMAIL_ACTIVITY_TYPE_ID') && EMAIL_ACTIVITY_TYPE_ID) ?
- EMAIL_ACTIVITY_TYPE_ID :
- CRM_Core_OptionGroup::getValue(
+ (defined('EMAIL_ACTIVITY_TYPE_ID') && EMAIL_ACTIVITY_TYPE_ID) ? EMAIL_ACTIVITY_TYPE_ID : CRM_Core_OptionGroup::getValue(
'activity_type',
'Inbound Email',
'name'
CRM_Core_Error::fatal($message);
}
-
// process fifty at a time, CRM-4002
while ($mails = $store->fetchNext(MAIL_BATCH_SIZE)) {
foreach ($mails as $key => $mail) {
$subParam['email'] = $address->email;
$subParam['name'] = $address->name;
-
$contactID = self::getContactID($subParam['email'],
$subParam['name'],
TRUE,
$result = array();
foreach (array_keys($this->_xml) as $key) {
if (!empty($this->_xml[$key]['data'])) {
- $result[ $this->_xml[$key]['name'] ] = array_values($this->_xml[$key]['data']);
+ $result[$this->_xml[$key]['name']] = array_values($this->_xml[$key]['data']);
}
}
return $result;
DIRECTORY_SEPARATOR,
$daoName
) . '.php';
- include_once ($daoFile);
+ include_once $daoFile;
$daoFields = & $daoName::fields();
";
}
-
$dao = & CRM_Core_DAO::executeQuery($sql);
$contactIDs = array();
}
if ($barKey = CRM_Utils_Array::value($barCount, CRM_Utils_Array::value('barKeys', $params))) {
- $bars[$barCount]->key($barKey,12);
+ $bars[$barCount]->key($barKey, 12);
}
// call user define function to handle on click event.
// set_labels function requires xValues array of string or x_axis_label
// so type casting array values to string values
array_walk($xValues, function(&$value, $index) {
- $value = (string)$value;
- });
+ $value = (string) $value;
+ });
$xLabels->set_labels($xValues);
// set angle for labels.
// get the required data.
$values = array();
foreach ($allValues as $label => $value) {
- $values[] = new pie_value((double)$value, $label);
+ $values[] = new pie_value((double) $value, $label);
}
$graphTitle = !empty($params['legend']) ? $params['legend'] : ts('Pie Chart');
continue;
}
- $xValueLabels[] = (string)$xVal;
+ $xValueLabels[] = (string) $xVal;
foreach ($criterias as $criteria) {
- $xReferences[$criteria][$xVal] = (double)CRM_Utils_Array::value($criteria, $yVal, 0);
- $yValues[] = (double)CRM_Utils_Array::value($criteria, $yVal, 0);
+ $xReferences[$criteria][$xVal] = (double) CRM_Utils_Array::value($criteria, $yVal, 0);
+ $yValues[] = (double) CRM_Utils_Array::value($criteria, $yVal, 0);
}
}
// set colour pattel
$xValues[$count]->set_colour(self::$_colours[$count]);
// define colur pattel with bar criterias
- $xValues[$count]->key((string)$criteria, 12);
+ $xValues[$count]->key((string) $criteria, 12);
// define bar chart values
$xValues[$count]->set_values(array_values($values));
'dejavusans' => ts('Deja Vu Sans (UTF-8)'),
);
-
// Check to see if we have any additional fonts to add. You can specify more fonts in
// civicrm.settings.php via: $config['CiviCRM Preferences']['additional_fonts']
// CRM-13307
$stationery_path = $doc_root . "/" . $stationery_path_partial;
}
- $margins = array($metric,$t,$r,$b,$l);
+ $margins = array($metric, $t, $r, $b, $l);
$config = CRM_Core_Config::singleton();
$html = "
// This function also uses the FPDI library documented at: http://www.setasign.com/products/fpdi/about/
// Syntax borrowed from https://github.com/jake-mw/CDNTaxReceipts/blob/master/cdntaxreceipts.functions.inc
require_once 'tcpdf/tcpdf.php';
- require_once('FPDI/fpdi.php'); // This library is only in the 'packages' area as of version 4.5
+ require_once 'FPDI/fpdi.php'; // This library is only in the 'packages' area as of version 4.5
$paper_size_arr = array( $paper_size[2], $paper_size[3]);
$pdf->SetAuthor('');
$pdf->SetKeywords('CiviCRM.org');
- $pdf->setPageUnit( $margins[0] ) ;
- $pdf->SetMargins($margins[4], $margins[1], $margins[2], true);
+ $pdf->setPageUnit( $margins[0] );
+ $pdf->SetMargins($margins[4], $margins[1], $margins[2], TRUE);
$pdf->setJPEGQuality('100');
- $pdf->SetAutoPageBreak(true, $margins[3]);
+ $pdf->SetAutoPageBreak(TRUE, $margins[3]);
$pdf->AddPage();
- $ln = true ;
- $fill = false ;
- $reset_parm = false;
- $cell = false;
- $align = '' ;
+ $ln = TRUE;
+ $fill = FALSE;
+ $reset_parm = FALSE;
+ $cell = FALSE;
+ $align = '';
// output the HTML content
$pdf->writeHTML($html, $ln, $fill, $reset_parm, $cell, $align);
// close and output the PDF
$pdf->Close();
- $pdf_file = 'CiviLetter'.'.pdf';
+ $pdf_file = 'CiviLetter'.'.pdf';
$pdf->Output($pdf_file, 'D');
CRM_Utils_System::civiExit(1);
}
$searchPath,
&$values,
$numPages = 1,
- $echo = TRUE,
- $output = 'College_Match_App',
- $creator = 'CiviCRM',
- $author = 'http://www.civicrm.org/',
- $title = '2006 College Match Scholarship Application'
+ $echo = TRUE,
+ $output = 'College_Match_App',
+ $creator = 'CiviCRM',
+ $author = 'http://www.civicrm.org/',
+ $title = '2006 College Match Scholarship Application'
) {
try {
$pdf = new PDFlib();
$pdf->fit_pdi_page($page, 0, 0, 'adjustpage');
-
$status = array();
/* Fill all text blocks with dynamic data */
$params['prevImg'] = ' ' . ts('< Previous');
$params['nextImg'] = ts('Next >') . ' ';
-
// set first and last text fragments
$params['firstPagePre'] = '';
$params['firstPageText'] = ' ' . ts('<< First');
$currentPage = $defaultPageId;
if (!empty($_POST)) {
if (isset($_POST[CRM_Utils_Array::value('buttonTop', $params)]) && isset($_POST[self::PAGE_ID])) {
- $currentPage = max((int )@$_POST[self::PAGE_ID], 1);
+ $currentPage = max((int ) @$_POST[self::PAGE_ID], 1);
}
elseif (isset($_POST[$params['buttonBottom']]) && isset($_POST[self::PAGE_ID_BOTTOM])) {
- $currentPage = max((int )@$_POST[self::PAGE_ID_BOTTOM], 1);
+ $currentPage = max((int ) @$_POST[self::PAGE_ID_BOTTOM], 1);
}
elseif (isset($_POST[self::PAGE_ID])) {
- $currentPage = max((int )@$_POST[self::PAGE_ID], 1);
+ $currentPage = max((int ) @$_POST[self::PAGE_ID], 1);
}
elseif (isset($_POST[self::PAGE_ID_BOTTOM])) {
- $currentPage = max((int )@$_POST[self::PAGE_ID_BOTTOM]);
+ $currentPage = max((int ) @$_POST[self::PAGE_ID_BOTTOM]);
}
}
elseif (isset($_GET[self::PAGE_ID])) {
- $currentPage = max((int )@$_GET[self::PAGE_ID], 1);
+ $currentPage = max((int ) @$_GET[self::PAGE_ID], 1);
}
return $currentPage;
}
public function getPageRowCount($defaultPageRowCount = self::ROWCOUNT) {
// POST has higher priority than GET vars
if (isset($_POST[self::PAGE_ROWCOUNT])) {
- $rowCount = max((int )@$_POST[self::PAGE_ROWCOUNT], 1);
+ $rowCount = max((int ) @$_POST[self::PAGE_ROWCOUNT], 1);
}
elseif (isset($_GET[self::PAGE_ROWCOUNT])) {
- $rowCount = max((int )@$_GET[self::PAGE_ROWCOUNT], 1);
+ $rowCount = max((int ) @$_GET[self::PAGE_ROWCOUNT], 1);
}
else {
$rowCount = $defaultPageRowCount;
//get the current path
$path = CRM_Utils_System::currentPath();
- $qfKey = null;
+ $qfKey = NULL;
if (isset($query->_formValues)) {
$qfKey = CRM_Utils_Array::value('qfKey', $query->_formValues);
}
case self::LANG_SQL_FTS:
$text = $this->_formatFts($text, $this->mode);
break;
+
case self::LANG_SQL_FTSBOOL:
$text = $this->_formatFtsBool($text, $this->mode);
break;
+
case self::LANG_SQL_LIKE:
$text = $this->_formatLike($text, $this->mode);
break;
+
default:
$text = NULL;
}
return $json;
}
-
if (isset($result['count'])) {
$count = ' count="' . $result['count'] . '" ';
}
- else $count = "";
+ else { $count = "";
+ }
$xml = "<?xml version=\"1.0\"?>
<ResultSet xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" $count>
";
if ($inquote || $inarray) {
$result .= $char;
}
- else $result .= $char . $newline . str_repeat($tab, $tabcount);
+ else { $result .= $char . $newline . str_repeat($tab, $tabcount);
+ }
break;
case '"':
$args[2] = CRM_Utils_array::value('action', $requestParams);
}
-
// Everyone should be required to provide the server key, so the whole
// interface can be disabled in more change to the configuration file.
// first check for civicrm site key
return self::error("FATAL: 'key' is incorrect. More info at: " . $docLink);
}
-
// At this point we know we are not calling ping which does not require authentication.
// Therefore, at this point we need to make sure we're working with a trusted user.
// Valid users are those who provide a valid server key and API key
return $result;
}
- if ($_SERVER['REQUEST_METHOD'] == 'GET' && strtolower(substr( $args[2],0,3)) != 'get') {
+ if ($_SERVER['REQUEST_METHOD'] == 'GET' && strtolower(substr( $args[2], 0, 3)) != 'get') {
// get only valid for non destructive methods
require_once 'api/v3/utils.php';
return civicrm_api3_create_error("SECURITY: All requests that modify the database must be http POST, not GET.",
}
}
if (array_key_exists('return', $requestParams) && is_array($requestParams['return'])) {
- foreach ($requestParams['return'] as $key => $v) $params['return.' . $key] = 1;
+ foreach ($requestParams['return'] as $key => $v) { $params['return.' . $key] = 1;
+ }
}
return $params;
}
/** used to load a template "inline", eg. for ajax, without having to build a menu for each template */
static function loadTemplate () {
$request = CRM_Utils_Request::retrieve( 'q', 'String');
- if (false !== strpos($request, '..')) {
+ if (FALSE !== strpos($request, '..')) {
die ("SECURITY FATAL: the url can't contain '..'. Please report the issue on the forum at civicrm.org");
}
- $request = split ('/',$request);
+ $request = split('/', $request);
$entity = _civicrm_api_get_camel_name($request[2]);
- $tplfile=_civicrm_api_get_camel_name($request[3]);
+ $tplfile = _civicrm_api_get_camel_name($request[3]);
$tpl = 'CRM/'.$entity.'/Page/Inline/'.$tplfile.'.tpl';
- $smarty= CRM_Core_Smarty::singleton( );
+ $smarty = CRM_Core_Smarty::singleton( );
CRM_Utils_System::setTitle( "$entity::$tplfile inline $tpl" );
if( !$smarty->template_exists($tpl) ){
header("Status: 404 Not Found");
die ("Can't find the requested template file templates/$tpl");
}
- if (array_key_exists('id',$_GET)) {// special treatmenent, because it's often used
- $smarty->assign ('id',(int)$_GET['id']);// an id is always positive
+ if (array_key_exists('id', $_GET)) {// special treatmenent, because it's often used
+ $smarty->assign('id', (int) $_GET['id']);// an id is always positive
}
- $pos = strpos (implode (array_keys ($_GET)),'<') ;
+ $pos = strpos(implode(array_keys($_GET)), '<');
- if ($pos !== false) {
+ if ($pos !== FALSE) {
die ("SECURITY FATAL: one of the param names contains <");
}
- $param = array_map( 'htmlentities' , $_GET);
+ $param = array_map( 'htmlentities', $_GET);
unset($param['q']);
$smarty->assign_by_ref("request", $param);
- if ( ! array_key_exists ( 'HTTP_X_REQUESTED_WITH', $_SERVER ) ||
+ if ( ! array_key_exists( 'HTTP_X_REQUESTED_WITH', $_SERVER ) ||
$_SERVER['HTTP_X_REQUESTED_WITH'] != "XMLHttpRequest" ) {
- $smarty->assign( 'tplFile', $tpl );
- $config = CRM_Core_Config::singleton();
- $content = $smarty->fetch( 'CRM/common/'. strtolower($config->userFramework) .'.tpl' );
+ $smarty->assign( 'tplFile', $tpl );
+ $config = CRM_Core_Config::singleton();
+ $content = $smarty->fetch( 'CRM/common/'. strtolower($config->userFramework) .'.tpl' );
- if (!defined('CIVICRM_UF_HEAD') && $region = CRM_Core_Region::instance('html-header', FALSE)) {
- CRM_Utils_System::addHTMLHead($region->render(''));
- }
- CRM_Utils_System::appendTPLFile( $tpl, $content );
+ if (!defined('CIVICRM_UF_HEAD') && $region = CRM_Core_Region::instance('html-header', FALSE)) {
+ CRM_Utils_System::addHTMLHead($region->render(''));
+ }
+ CRM_Utils_System::appendTPLFile( $tpl, $content );
- return CRM_Utils_System::theme($content);
+ return CRM_Utils_System::theme($content);
- } else {
- $content = "<!-- .tpl file embeded: $tpl -->\n";
- CRM_Utils_System::appendTPLFile( $tpl, $content );
- echo $content . $smarty->fetch ($tpl);
- CRM_Utils_System::civiExit( );
+ } else {
+ $content = "<!-- .tpl file embeded: $tpl -->\n";
+ CRM_Utils_System::appendTPLFile( $tpl, $content );
+ echo $content . $smarty->fetch($tpl);
+ CRM_Utils_System::civiExit( );
}
}
/**
*
*/
- public function __construct() {}
+ public function __construct() {
+ }
/**
* Add element to form
$config = CRM_Core_Config::singleton();
- //CRM-14868
+ //CRM-14868
$currencySymbols = CRM_Core_PseudoConstant::get(
'CRM_Contribute_DAO_Contribution',
'currency', array(
'keyColumn' => 'name',
'labelColumn' => 'symbol'
));
- $value = str_replace($currencySymbols,'',$value);
+ $value = str_replace($currencySymbols, '', $value);
if ($config->monetaryThousandSeparator) {
$mon_thousands_sep = $config->monetaryThousandSeparator;
if (empty($salt)) {
$message['salt'] = $this->createSalt();
} else {
- $message['salt'] = $salt;
+ $message['salt'] = $salt;
}
// recall: paramNames is pre-sorted for stability
foreach ($this->paramNames as $paramName) {
} else { // $paramName is not included or ===NULL
$params[$paramName] = '';
}
- $message['payload'][$paramName] = $params[$paramName];
- }
+ $message['payload'][$paramName] = $params[$paramName];
+ }
$token = $message['salt'] . $this->signDelim . md5(serialize($message));
return $token;
}
throw new SoapFault('Client', 'Invalid key');
}
-
if (self::$soap_timeout &&
$t > ($session->get('soap_time') + self::$soap_timeout)
) {
* @static
*/
public function authenticate($name, $pass, $loadCMSBootstrap = FALSE) {
- require_once (str_replace('_', DIRECTORY_SEPARATOR, $this->ufClass) . '.php');
+ require_once str_replace('_', DIRECTORY_SEPARATOR, $this->ufClass) . '.php';
if ($this->ufClass == 'CRM_Utils_System_Joomla'){
- $loadCMSBootstrap = true;
+ $loadCMSBootstrap = TRUE;
}
$className = $this->ufClass;
$_replaceChar = '_';
}
-
if ($search == NULL) {
$search = $_searchChars;
}
* @static
*/
public static function purifyHTML($string) {
- static $_filter = null;
+ static $_filter = NULL;
if (!$_filter) {
$config = HTMLPurifier_Config::createDefault();
$config->set('Core.Encoding', 'UTF-8');
// Disable the cache entirely
- $config->set('Cache.DefinitionImpl', null);
+ $config->set('Cache.DefinitionImpl', NULL);
$_filter = new HTMLPurifier($config);
}
return $string;
}
else {
- return substr($string, 0, $maxLen-3) . '...';
+ return substr($string, 0, $maxLen - 3) . '...';
}
}
return array($defaultPrefix, $string);
}
else {
- return array(substr($string, 0, $pos), substr($string, 1+$pos));
+ return array(substr($string, 0, $pos), substr($string, 1 + $pos));
}
}
*
* @return string returns the masked Email address
*/
- public static function maskEmail($email, $maskChar= '*', $percent=50) {
+ public static function maskEmail($email, $maskChar = '*', $percent = 50) {
list($user, $domain) = preg_split("/@/", $email);
$len = strlen($user);
- $maskCount = floor($len * $percent /100);
+ $maskCount = floor($len * $percent / 100);
$offset = floor(($len - $maskCount) / 2);
$masked = substr($user, 0, $offset)
.str_repeat($maskChar, $maskCount)
.substr($user, $maskCount + $offset);
- return($masked.'@'.$domain);
+ return ($masked.'@'.$domain);
}
/**
*/
static function theme(
&$content,
- $print = FALSE,
+ $print = FALSE,
$maintenance = FALSE
) {
$config = &CRM_Core_Config::singleton();
*/
static function url(
$path = NULL,
- $query = NULL,
+ $query = NULL,
$absolute = FALSE,
$fragment = NULL,
- $htmlize = TRUE,
+ $htmlize = TRUE,
$frontend = FALSE,
$forceBackend = FALSE
) {
*
*/
static function jsRedirect(
- $url = NULL,
- $title = NULL,
+ $url = NULL,
+ $title = NULL,
$message = NULL
) {
if (!$url) {
if (preg_match('/<h2>([^<]+)<\/h2>/', $vTmp[$i], $vMat)) {
$vName = trim($vMat[1]);
$vTmp2 = explode("\n", $vTmp[$i + 1]);
- foreach ($vTmp2 AS $vOne) {
+ foreach ($vTmp2 as $vOne) {
$vPat = '<info>([^<]+)<\/info>';
$vPat3 = "/$vPat\s*$vPat\s*$vPat/";
$vPat2 = "/$vPat\s*$vPat/";
* (optional) Whether to log the memory usage information.
*/
public static function xMemory($title = NULL, $log = FALSE) {
- $mem = (float ) xdebug_memory_usage() / (float )(1024);
+ $mem = (float ) xdebug_memory_usage() / (float ) (1024);
$mem = number_format($mem, 5) . ", " . time();
if ($log) {
echo "<p>$title: $mem<p>";
list($className, $methodName) = explode('::', $callback);
$fileName = str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
// ignore errors if any
- @include_once ($fileName);
+ @include_once $fileName;
if (!class_exists($className)) {
self::$_callbacks[$callback] = FALSE;
}
array(dirname(__FILE__), '..', '..', 'civicrm-version.php')
);
if (file_exists($verFile)) {
- require_once ($verFile);
+ require_once $verFile;
if (function_exists('civicrmVersion')) {
$info = civicrmVersion();
$version = $info['version'];
* Note that we inline this function in install/civicrm.php, so if you change
* this function, please go and change the code in the install script as well.
*/
- public static function isSSL( ) {
+ public static function isSSL() {
return
(isset($_SERVER['HTTPS']) &&
!empty($_SERVER['HTTPS']) &&
CRM_Core_Error::fatal('HTTPS is not set up on this machine');
}
else {
- CRM_Core_Session::setStatus(ts('HTTPS is not set up on this machine'), ts('Warning'), 'alert');
+ CRM_Core_Session::setStatus(ts('HTTPS is not set up on this machine'), ts('Warning'), 'alert');
// admin should be the only one following this
// since we dont want the user stuck in a bad place
return;
if ($config->userSystem->is_drupal && function_exists('ip_address')) {
//drupal function handles the server being behind a proxy securely. We still have legacy ipn methods
// that reach this point without bootstrapping hence the check that the fn exists
- $address = ip_address();
+ $address = ip_address();
}
// hack for safari
// return just the URL, no matter what other parameters are defined
if (!function_exists('ts')) {
if ($resource == 'wiki') {
- $docBaseURL = self::getWikiBaseURL();
+ $docBaseURL = self::getWikiBaseURL();
} else {
$docBaseURL = self::getDocBaseURL();
}
/**
* Reset the various system caches and some important static variables.
*/
- public static function flushCache( ) {
+ public static function flushCache() {
// flush out all cache entries so we can reload new data
// a bit aggressive, but livable for now
$cache = CRM_Utils_Cache::singleton();
throw new \Exception('Constant "ABSPATH" is not defined, even though WordPress is the user framework.');
}
if (is_admin()) {
- require_once (ABSPATH . 'wp-admin/admin-header.php');
+ require_once ABSPATH . 'wp-admin/admin-header.php';
}
else {
// FIXME: we need to figure out to replace civicrm content on the frontend pages
return FALSE;
}
- $timeZoneOffset = sprintf("%02d:%02d", $tz / 3600, abs(($tz/60)%60));
+ $timeZoneOffset = sprintf("%02d:%02d", $tz / 3600, abs(($tz / 60) % 60));
if ($timeZoneOffset > 0) {
$timeZoneOffset = '+' . $timeZoneOffset;
* @return mixed $uniqueIdentifer Unique identifier from the user Framework system
*
*/
- public function getUniqueIdentifierFromUserObject($user) {}
+ public function getUniqueIdentifierFromUserObject($user) {
+ }
/**
* Get User ID from UserFramework system (CMS)
* @return mixed <NULL, number>
*
*/
- public function getUserIDFromUserObject($user) {}
+ public function getUserIDFromUserObject($user) {
+ }
/**
* Get currently logged in user uf id.
*
* @return int $userID logged in user uf id.
*/
- public function getLoggedInUfID() {}
+ public function getLoggedInUfID() {
+ }
/**
* Get currently logged in user unique identifier - this tends to be the email address or user name.
*
* @return string $userID logged in user unique identifier
*/
- public function getLoggedInUniqueIdentifier() {}
+ public function getLoggedInUniqueIdentifier() {
+ }
/**
* Return a UFID (user account ID from the UserFramework / CMS system being based on the user object
/**
* Append to coreResourcesList
*/
- public function appendCoreResources(&$list) {}
+ public function appendCoreResources(&$list) {
+ }
}
$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'])){
case 'page-footer':
$params['scope'] = substr($region, 5);
break;
+
default:
return FALSE;
}
case 'page-footer':
$params['scope'] = substr($region, 5);
break;
+
default:
return FALSE;
}
* array(
* contactID, ufID, unique string ) if success
*/
- public static function authenticate($name, $password, $loadCMSBootstrap = FALSE, $realPath = NULL) {
+ public static function authenticate($name, $password, $loadCMSBootstrap = FALSE, $realPath = NULL) {
require_once 'DB.php';
$config = CRM_Core_Config::singleton();
// Contact CiviSMTP folks if we run into issues with this :)
$cmsPath = $config->userSystem->cmsRootPath($realPath);
- require_once ("$cmsPath/includes/bootstrap.inc");
- require_once ("$cmsPath/includes/password.inc");
+ require_once "$cmsPath/includes/bootstrap.inc";
+ require_once "$cmsPath/includes/password.inc";
$strtolower = function_exists('mb_strtolower') ? 'mb_strtolower' : 'strtolower';
$name = $dbDrupal->escapeSimple($strtolower($name));
// which means that define(CIVICRM_CLEANURL) was correctly set.
// So we correct it
$config = CRM_Core_Config::singleton();
- $config->cleanURL = (int)variable_get('clean_url', '0');
+ $config->cleanURL = (int) variable_get('clean_url', '0');
// CRM-8655: Drupal wasn't available during bootstrap, so hook_civicrm_config never executes
CRM_Utils_Hook::config($config);
if (variable_get('configurable_timezones', 1) && $user->uid && strlen($user->timezone)) {
$timezone = $user->timezone;
} else {
- $timezone = variable_get('date_default_timezone', null);
+ $timezone = variable_get('date_default_timezone', NULL);
}
if (!$timezone) {
$timezone = parent::getTimeZoneString();
* contactID, ufID, unique string ) if success
*/
public function authenticate($name, $password, $loadCMSBootstrap = FALSE, $realPath = NULL) {
- //@todo this 'PEAR-y' stuff is only required when bookstrap is not being loaded which is rare
- // if ever now.
- // probably if bootstrap is loaded this call
- // CRM_Utils_System::loadBootStrap($bootStrapParams, TRUE, TRUE, $realPath); would be
- // sufficient to do what this fn does. It does exist as opposed to return which might need some hanky-panky to make
- // safe in the unknown situation where authenticate might be called & it is important that
- // false is returned
+ //@todo this 'PEAR-y' stuff is only required when bookstrap is not being loaded which is rare
+ // if ever now.
+ // probably if bootstrap is loaded this call
+ // CRM_Utils_System::loadBootStrap($bootStrapParams, TRUE, TRUE, $realPath); would be
+ // sufficient to do what this fn does. It does exist as opposed to return which might need some hanky-panky to make
+ // safe in the unknown situation where authenticate might be called & it is important that
+ // false is returned
require_once 'DB.php';
$config = CRM_Core_Config::singleton();
// which means that define(CIVICRM_CLEANURL) was correctly set.
// So we correct it
$config = CRM_Core_Config::singleton();
- $config->cleanURL = (int)variable_get('clean_url', '0');
+ $config->cleanURL = (int) variable_get('clean_url', '0');
// CRM-8655: Drupal wasn't available during bootstrap, so hook_civicrm_config never executes
CRM_Utils_Hook::config($config);
* Drupal User ID.
*/
public function og_membership_delete($ogID, $drupalID) {
- og_delete_subscription( $ogID, $drupalID );
+ og_delete_subscription( $ogID, $drupalID );
}
/**
if (variable_get('configurable_timezones', 1) && $user->uid && strlen($user->timezone)) {
$timezone = $user->timezone;
} else {
- $timezone = variable_get('date_default_timezone', null);
+ $timezone = variable_get('date_default_timezone', NULL);
}
if (!$timezone) {
$timezone = parent::getTimeZoneString();
case $user_register_conf == 'admin_only' || $user->isAuthenticated():
_user_mail_notify('register_admin_created', $account);
break;
+
case $user_register_conf == 'visitors':
_user_mail_notify('register_no_approval_required', $account);
break;
+
case 'visitors_admin_approval':
_user_mail_notify('register_pending_approval', $account);
break;
// This checks for both username uniqueness and validity.
$violations = iterator_to_array($user->validate());
// We only care about violations on the username field; discard the rest.
- $violations = array_filter($violations, function ($v) { return $v->getPropertyPath() == 'name.0.value'; });
+ $violations = array_filter($violations, function ($v) { return $v->getPropertyPath() == 'name.0.value';
+ });
if (count($violations) > 0) {
$errors['cms_name'] = $violations[0]->getMessage();
}
// This checks for both email uniqueness.
$violations = iterator_to_array($user->validate());
// We only care about violations on the email field; discard the rest.
- $violations = array_filter($violations, function ($v) { return $v->getPropertyPath() == 'mail.0.value'; });
+ $violations = array_filter($violations, function ($v) { return $v->getPropertyPath() == 'mail.0.value';
+ });
if (count($violations) > 0) {
$errors[$emailName] = $violations[0]->getMessage();
}
case 'page-footer':
$options['scope'] = substr($region, 5);
break;
+
default:
return FALSE;
}
case 'page-footer':
$options['scope'] = substr($region, 5);
break;
+
default:
return FALSE;
}
*/
public function loadBootStrap($params = array(), $loadUser = TRUE, $throwError = TRUE, $realPath = NULL) {
static $run_once = FALSE;
- if ($run_once) return TRUE; else $run_once = TRUE;
+ if ($run_once) { return TRUE;
+ } else { $run_once = TRUE;
+ }
if (!($root = $this->cmsRootPath())) {
return FALSE;
/**
* Change user name in host CMS
*
- * @param integer $ufID User ID in CMS
- * @param string $ufName User name
+ * @param int $ufID
+ * @param string $ufName User name
*/
public function updateCMSName($ufID, $ufName) {
$ufID = CRM_Utils_Type::escape($ufID, 'Integer');
$errors['cms_name'] = ts('Your username contains invalid characters or is too short');
}
-
$JUserTable = &JTable::getInstance('User', 'JTable');
$db = $JUserTable->getDbo();
*
* @return mixed false if no auth
* array(
- contactID, ufID, unique string ) if success
+ contactID, ufID, unique string ) if success
*/
public function authenticate($name, $password, $loadCMSBootstrap = FALSE) {
require_once 'DB.php';
}
}
else {
- if (!JUserHelper::verifyPassword($password, $dbPassword, $dbId)) return FALSE;
+ if (!JUserHelper::verifyPassword($password, $dbPassword, $dbId)) { return FALSE;
+ }
//include additional files required by Joomla 3.2.1+
if ( version_compare(JVERSION, '3.2.1', 'ge') ) {
$result = array();
$db = JFactory::getDbo();
- $query = $db->getQuery(true);
+ $query = $db->getQuery(TRUE);
$query->select('type, folder, element, enabled')
->from('#__extensions')
->where('type =' . $db->Quote('plugin'));
parent::outputError($content);
}
}
-
+
/**
* Append to coreResourcesList
*/
*
* @return void
*/
- public function setEmail(&$user) {}
+ public function setEmail(&$user) {
+ }
/**
* Authenticate a user against the real UF
*/
public function __construct() {
$this->is_drupal = FALSE;
- $this->supports_form_extensions = False;
+ $this->supports_form_extensions = FALSE;
}
/**
*
* @return bool
*/
- public function loadUser( $user ) {
- return true;
+ public function loadUser($user) {
+ return TRUE;
}
public function permissionDenied() {
wp_redirect(wp_login_url());
}
- public function updateCategories() {}
+ public function updateCategories() {
+ }
/**
* Get the locale set in the hosting CMS
CRM_Core_Error::fatal("Could not find the install directory for WordPress");
}
- require_once ($cmsRootPath . DIRECTORY_SEPARATOR . 'wp-load.php');
+ require_once $cmsRootPath . DIRECTORY_SEPARATOR . 'wp-load.php';
$wpUserTimezone = get_option('timezone_string');
if ($wpUserTimezone) {
date_default_timezone_set($wpUserTimezone);
CRM_Core_Config::singleton()->userSystem->setMySQLTimeZone();
}
- require_once ($cmsRootPath . DIRECTORY_SEPARATOR . 'wp-includes/pluggable.php');
+ require_once $cmsRootPath . DIRECTORY_SEPARATOR . 'wp-includes/pluggable.php';
$uid = CRM_Utils_Array::value('uid', $name);
if ($uid) {
$account = wp_set_current_user($uid);
return TRUE;
}
}
- return true;
+ return TRUE;
}
/**
$ufID = CRM_Utils_Type::escape($ufID, 'Integer');
$ufName = CRM_Utils_Type::escape($ufName, 'String');
- $values = array ('ID' => $ufID, 'user_email' => $ufName);
+ $values = array('ID' => $ufID, 'user_email' => $ufName);
if( $ufID ) {
- wp_update_user( $values ) ;
+ wp_update_user( $values );
}
}
}
return preg_replace(array('/{/', '/(?<!{ldelim)}/'), array('{ldelim}', '{rdelim}'), $string);
}
- /**
+ /**
* Replace all the domain-level tokens in $str
*
* @param string $str
$str = preg_replace_callback(
self::tokenRegex($key),
function ($matches) use(&$domain, $html, $escapeSmarty) {
- return CRM_Utils_Token::getDomainTokenReplacement($matches[1], $domain, $html, $escapeSmarty);
+ return CRM_Utils_Token::getDomainTokenReplacement($matches[1], $domain, $html, $escapeSmarty);
},
$str
);
$str = preg_replace_callback(
self::tokenRegex($key),
function ($matches) use(&$mailing, $escapeSmarty) {
- return CRM_Utils_Token::getMailingTokenReplacement($matches[1], $mailing, $escapeSmarty);
+ return CRM_Utils_Token::getMailingTokenReplacement($matches[1], $mailing, $escapeSmarty);
},
$str
);
$str = preg_replace_callback(
self::tokenRegex($key),
function ($matches) use(&$addresses, &$urls, $html, $escapeSmarty) {
- return CRM_Utils_Token::getActionTokenReplacement($matches[1], $addresses, $urls, $html, $escapeSmarty);
+ return CRM_Utils_Token::getActionTokenReplacement($matches[1], $addresses, $urls, $html, $escapeSmarty);
},
$str
);
$str = preg_replace_callback(
self::tokenRegex($key),
function ($matches) use(&$contact, $html, $returnBlankToken, $escapeSmarty) {
- return CRM_Utils_Token::getContactTokenReplacement($matches[1], $contact, $html, $returnBlankToken, $escapeSmarty);
+ return CRM_Utils_Token::getContactTokenReplacement($matches[1], $contact, $html, $returnBlankToken, $escapeSmarty);
},
$str
);
$str = preg_replace_callback(
self::tokenRegex($key),
function ($matches) use(&$contact, $key, $html, $escapeSmarty) {
- return CRM_Utils_Token::getHookTokenReplacement($matches[1], $contact, $key, $html, $escapeSmarty);
+ return CRM_Utils_Token::getHookTokenReplacement($matches[1], $contact, $key, $html, $escapeSmarty);
},
$str
);
*
* this routine will remove the extra backslashes and braces
*
- * @param $str ref to the string that will be scanned and modified
- * @return void this function works directly on the string that is passed
- * @access public
- * @static
+ * @param $str ref to the string that will be scanned and modified
+ * @return void this function works directly on the string that is passed
+ * @access public
+ * @static
*/
public static function unescapeTokens(&$str) {
$str = preg_replace('/\\\\|\{(\{\w+\.\w+\})\}/', '\\1', $str);
*
*/
public static function getReturnProperties(&$string) {
- $returnProperties = array();
- $matches = array();
- preg_match_all('/(?<!\{|\\\\)\{(\w+\.\w+)\}(?!\})/',
+ $returnProperties = array();
+ $matches = array();
+ preg_match_all('/(?<!\{|\\\\)\{(\w+\.\w+)\}(?!\})/',
$string,
$matches,
PREG_PATTERN_ORDER
);
- if ($matches[1]) {
- foreach ($matches[1] as $token) {
- list($type, $name) = preg_split('/\./', $token, 2);
- if ($name) {
- $returnProperties["{$name}"] = 1;
- }
+ if ($matches[1]) {
+ foreach ($matches[1] as $token) {
+ list($type, $name) = preg_split('/\./', $token, 2);
+ if ($name) {
+ $returnProperties["{$name}"] = 1;
}
}
+ }
- return $returnProperties;
+ return $returnProperties;
}
/**
* @param $contactIDs
* @param array $returnProperties
* Of required properties.
- * @param boolean $skipOnHold
+ * @param bool $skipOnHoldDon't return on_hold contact info also.
* Don't return on_hold contact info also.
- * @param boolean $skipDeceased
+ * @param bool $skipDeceasedDon't return deceased contact info.
* Don't return deceased contact info.
* @param array $extraParams
* Extra params.
*/
static function getTokenDetails($contactIDs,
$returnProperties = NULL,
- $skipOnHold = TRUE,
- $skipDeceased = TRUE,
- $extraParams = NULL,
- $tokens = array(),
- $className = NULL,
- $jobID = NULL
+ $skipOnHold = TRUE,
+ $skipDeceased = TRUE,
+ $extraParams = NULL,
+ $tokens = array(),
+ $className = NULL,
+ $jobID = NULL
) {
if (empty($contactIDs)) {
// putting a fatal here so we can track if/when this happens
*/
public function getAnonymousTokenDetails($contactIDs = array(0),
$returnProperties = NULL,
- $skipOnHold = TRUE,
- $skipDeceased = TRUE,
- $extraParams = NULL,
- $tokens = array(),
- $className = NULL,
- $jobID = NULL) {
+ $skipOnHold = TRUE,
+ $skipDeceased = TRUE,
+ $extraParams = NULL,
+ $tokens = array(),
+ $className = NULL,
+ $jobID = NULL) {
$details = array(0 => array());
- // also call a hook and get token details
- CRM_Utils_Hook::tokenValues($details[0],
+ // also call a hook and get token details
+ CRM_Utils_Hook::tokenValues($details[0],
$contactIDs,
$jobID,
$tokens,
*/
static function getContributionTokenDetails($contributionIDs,
$returnProperties = NULL,
- $extraParams = NULL,
- $tokens = array(),
- $className = NULL
+ $extraParams = NULL,
+ $tokens = array(),
+ $className = NULL
) {
//@todo - this function basically replications calling civicrm_api3('contribution', 'get', array('id' => array('IN' => array())
if (empty($contributionIDs)) {
$str = preg_replace_callback(
self::tokenRegex($key),
function ($matches) use($escapeSmarty) {
- return CRM_Utils_Token::getUserTokenReplacement($matches[1], $escapeSmarty);
+ return CRM_Utils_Token::getUserTokenReplacement($matches[1], $escapeSmarty);
},
$str
);
return $str;
}
- $fn = 'get' . ucFirst($entity) . 'tokenReplacement';
+ $fn = 'get' . ucfirst($entity) . 'tokenReplacement';
//since we already know the tokens lets just use them & do str_replace which is faster & simpler than preg_replace
foreach ($knownTokens[$entity] as $token) {
$replaceMent = CRM_Utils_Token::$fn($token, $entityArray, $escapeSmarty);
$str = preg_replace_callback(
self::tokenRegex($key),
function ($matches) use(&$contribution, $html, $escapeSmarty) {
- return CRM_Utils_Token::getContributionTokenReplacement($matches[1], $contribution, $html, $escapeSmarty);
+ return CRM_Utils_Token::getContributionTokenReplacement($matches[1], $contribution, $html, $escapeSmarty);
},
$str
);
public static function getMembershipTokenReplacement($token, $membership, $escapeSmarty = FALSE) {
$entity = 'membership';
self::_buildMembershipTokens();
- switch ($token) {
- case 'type':
- $value = $membership['membership_name'];
- break;
- case 'status':
- $statuses = CRM_Member_BAO_Membership::buildOptions('status_id');
- $value = $statuses[$membership['status_id']];
- break;
- case 'fee':
- try{
- $value = civicrm_api3('membership_type', 'getvalue', array('id' => $membership['membership_type_id'], 'return' => 'minimum_fee'));
- }
- catch (CiviCRM_API3_Exception $e) {
- // we can anticipate we will get an error if the minimum fee is set to 'NULL' because of the way the
- // api handles NULL (4.4)
- $value = 0;
- }
- break;
- default:
- if (in_array($token, self::$_tokens[$entity])) {
- $value = $membership[$token];
- }
- else {
- //ie unchanged
- $value = "{$entity}.{$token}";
- }
- break;
+ switch ($token) {
+ case 'type':
+ $value = $membership['membership_name'];
+ break;
+
+ case 'status':
+ $statuses = CRM_Member_BAO_Membership::buildOptions('status_id');
+ $value = $statuses[$membership['status_id']];
+ break;
+
+ case 'fee':
+ try{
+ $value = civicrm_api3('membership_type', 'getvalue', array('id' => $membership['membership_type_id'], 'return' => 'minimum_fee'));
+ }
+ catch (CiviCRM_API3_Exception $e) {
+ // we can anticipate we will get an error if the minimum fee is set to 'NULL' because of the way the
+ // api handles NULL (4.4)
+ $value = 0;
+ }
+ break;
+
+ default:
+ if (in_array($token, self::$_tokens[$entity])) {
+ $value = $membership[$token];
+ }
+ else {
+ //ie unchanged
+ $value = "{$entity}.{$token}";
+ }
+ break;
}
if ($escapeSmarty) {
break;
}
-
if ($escapeSmarty) {
$value = self::tokenEscapeSmarty($value);
}
* @param array (ref) $parentNode which parent node should we search in ?
*
* @return array(
- ref) | false node if found else false
+ ref) | false node if found else false
*
*/
//public function &findNode(&$parentNode, $name)
* Currently leaf nodes are strings and non-leaf nodes are arrays
*
* @param array(
- ref) $node node which needs to checked
+ ref) $node node which needs to checked
*
* @return boolean
*
$string = 'Blob';
break;
- // CRM-10404
+ // CRM-10404
case 12:
case 256:
$string = 'Timestamp';
break;
case 'Positive':
- // CRM-8925 the 3 below are for custom fields of this type
+ // CRM-8925 the 3 below are for custom fields of this type
case 'Country':
case 'StateProvince':
// Checked for multi valued state/country value
* @var array
*/
protected $stats = array();
-
+
/**
* Path to cache file
*
$this->cacheFile = $config->uploadDir . self::CACHEFILE_NAME;
if (file_exists($localFile)) {
- require_once ($localFile);
+ require_once $localFile;
}
if (function_exists('civicrmVersion')) {
$info = civicrmVersion();
public function versionAlert() {
$versionAlertSetting = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'versionAlert', NULL, 1);
$securityAlertSetting = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'securityUpdateAlert', NULL, 3);
- $settingsUrl = CRM_Utils_System::url('civicrm/admin/setting/misc', 'reset=1', FALSE, NULL, FALSE, FALSE, TRUE);
+ $settingsUrl = CRM_Utils_System::url('civicrm/admin/setting/misc', 'reset=1', FALSE, NULL, FALSE, FALSE, TRUE);
if (CRM_Core_Permission::check('administer CiviCRM') && $securityAlertSetting > 1 && $this->isSecurityUpdateAvailable()) {
$session = CRM_Core_Session::singleton();
if ($session->timer('version_alert', 24 * 60 * 60)) {
return FALSE;
}
- $weight = (int)$object->weight;
+ $weight = (int) $object->weight;
if ($weight < 1) {
return FALSE;
}
$fieldValues = NULL,
$queryData,
$additionalWhere = NULL,
- $orderBy = NULL,
- $groupBy = NULL
+ $orderBy = NULL,
+ $groupBy = NULL
) {
- require_once (str_replace('_', DIRECTORY_SEPARATOR, $daoName) . ".php");
+ require_once str_replace('_', DIRECTORY_SEPARATOR, $daoName) . ".php";
$dao = new $daoName;
$table = $dao->getTablename();
$tableName = $object->tableName();
$query = "UPDATE $tableName SET weight = %1 WHERE $idName = %2";
- $params = array(1 => array($dstWeight, 'Integer'),
+ $params = array(
+ 1 => array($dstWeight, 'Integer'),
2 => array($src, 'Integer'),
);
CRM_Core_DAO::executeQuery($query, $params);
if ($dir == 'swap') {
- $params = array(1 => array($srcWeight, 'Integer'),
+ $params = array(
+ 1 => array($srcWeight, 'Integer'),
2 => array($dst, 'Integer'),
);
CRM_Core_DAO::executeQuery($query, $params);
if ($filter) {
$query .= " AND $filter";
}
- $params = array(1 => array($src, 'Integer'),
+ $params = array(
+ 1 => array($src, 'Integer'),
2 => array($srcWeight, 'Integer'),
);
CRM_Core_DAO::executeQuery($query, $params);
if ($filter) {
$query .= " AND $filter";
}
- $params = array(1 => array($src, 'Integer'),
+ $params = array(
+ 1 => array($src, 'Integer'),
2 => array($srcWeight, 'Integer'),
);
CRM_Core_DAO::executeQuery($query, $params);
$parts = array();
if ($error->file) {
- $parts[] = "File=$error->file";
+ $parts[] = "File=$error->file";
}
$parts[] = "Line=$error->line";
$parts[] = "Column=$error->column";
}
$zip->close();
} else {
- return FALSE;
+ return FALSE;
}
return TRUE;
}