*/
require_once 'api/Wrapper.php';
+
+/**
+ * Class CRM_Utils_API_AbstractFieldCoder
+ */
abstract class CRM_Utils_API_AbstractFieldCoder implements API_Wrapper {
/**
*/
public abstract function encodeInput(&$values);
+ /**
+ * @param $values
+ *
+ * @return mixed
+ */
public abstract function decodeOutput(&$values);
/**
}
}
+ /**
+ * @param $values
+ * @param bool $castToString
+ */
public function decodeOutput(&$values, $castToString = FALSE) {
if (is_array($values)) {
foreach ($values as &$value) {
*/
require_once 'api/Wrapper.php';
+
+/**
+ * Class CRM_Utils_API_MatchOption
+ */
class CRM_Utils_API_MatchOption implements API_Wrapper {
/**
*/
require_once 'api/Wrapper.php';
+
+/**
+ * Class CRM_Utils_API_NullOutputCoder
+ */
class CRM_Utils_API_NullOutputCoder extends CRM_Utils_API_AbstractFieldCoder {
/**
public function encodeInput(&$values) {
}
+ /**
+ * @param $values
+ * @param bool $castToString
+ */
public function decodeOutput(&$values, $castToString = FALSE) {
if (is_array($values)) {
foreach ($values as &$value) {
}
}
+ /**
+ * {@inheritDoc}
+ */
+ /**
+ * @param $apiRequest
+ * @param $result
+ *
+ * @return modified
+ */
public function toApiOutput($apiRequest, $result) {
$lowerAction = strtolower($apiRequest['action']);
if ($lowerAction === 'create') {
*/
require_once 'api/Wrapper.php';
+
+/**
+ * Class CRM_Utils_API_ReloadOption
+ */
class CRM_Utils_API_ReloadOption implements API_Wrapper {
/**
return $finalFormatted;
}
+ /**
+ * @param $format
+ *
+ * @return array
+ */
static function sequence($format) {
// also compute and store the address sequence
$addressSequence = array(
var $returnMessages = array();
var $returnError = 0;
+ /**
+ * @param $params
+ */
public function __construct($params) {
foreach ($params as $name => $value) {
// fixme: more params verification
}
+ /**
+ * @return array
+ */
public function run() {
$config = &CRM_Core_Config::singleton();
return $this->processContacts($config, $processGeocode, $parseStreetAddress);
}
+ /**
+ * @param $config
+ * @param $processGeocode
+ * @param $parseStreetAddress
+ *
+ * @return array
+ * @throws Exception
+ */
function processContacts(&$config, $processGeocode, $parseStreetAddress) {
// build where clause.
$clause = array('( c.id = a.contact_id )');
return $this->returnResult();
}
+ /**
+ * @return array
+ */
function returnResult() {
$result = array();
$result['is_error'] = $this->returnError;
*/
class CRM_Utils_Address_USPS {
+ /**
+ * @param $values
+ *
+ * @return bool
+ */
static function checkAddress(&$values) {
if (!isset($values['street_address']) ||
(!isset($values['city']) &&
+--------------------------------------------------------------------+
*/
+/**
+ * Class CRM_Utils_Api
+ */
class CRM_Utils_Api {
/**
* Attempts to retrieve the API entity name from any calling class.
* @return mixed
* The value found.
*/
+ /**
+ * @param $regexKey
+ * @param $list
+ * @param null $default
+ *
+ * @return null
+ */
static function valueByRegexKey($regexKey, $list, $default = NULL) {
if (is_array($list) && $regexKey) {
$matches = preg_grep($regexKey, array_keys($list));
}
}
+ /**
+ * @param $key
+ * @param $value
+ *
+ * @return bool
+ */
function set($key, &$value) {
if (!apc_store($this->_prefix . $key, $value, $this->_timeout)) {
return FALSE;
return TRUE;
}
+ /**
+ * @param $key
+ *
+ * @return mixed
+ */
function &get($key) {
return apc_fetch($this->_prefix . $key);
}
+ /**
+ * @param $key
+ *
+ * @return bool|string[]
+ */
function delete($key) {
return apc_delete($this->_prefix . $key);
}
<?php
+
+/**
+ * Class CRM_Utils_Cache_Arraycache
+ */
class CRM_Utils_Cache_Arraycache implements CRM_Utils_Cache_Interface {
/**
$this->_cache = array();
}
+ /**
+ * @param string $key
+ * @param mixed $value
+ */
function set($key, &$value) {
$this->_cache[$key] = $value;
}
+ /**
+ * @param string $key
+ *
+ * @return mixed
+ */
function get($key) {
return CRM_Utils_Array::value($key, $this->_cache);
}
+ /**
+ * @param string $key
+ */
function delete($key) {
unset($this->_cache[$key]);
}
}
}
+ /**
+ * @param $key
+ * @param $value
+ *
+ * @return bool
+ */
function set($key, &$value) {
if (!$this->_cache->set($this->_prefix . $key, $value, FALSE, $this->_timeout)) {
return FALSE;
return TRUE;
}
+ /**
+ * @param $key
+ *
+ * @return mixed
+ */
function &get($key) {
$result = $this->_cache->get($this->_prefix . $key);
return $result;
}
+ /**
+ * @param $key
+ *
+ * @return mixed
+ */
function delete($key) {
return $this->_cache->delete($this->_prefix . $key);
}
+ /**
+ * @return mixed
+ */
function flush() {
return $this->_cache->flush();
}
}
}
+ /**
+ * @param $key
+ * @param $value
+ *
+ * @return bool
+ * @throws Exception
+ */
function set($key, &$value) {
$key = $this->cleanKey($key);
if (!$this->_cache->set($key, $value, $this->_timeout)) {
return TRUE;
}
+ /**
+ * @param $key
+ *
+ * @return mixed
+ */
function &get($key) {
$key = $this->cleanKey($key);
$result = $this->_cache->get($key);
return $result;
}
+ /**
+ * @param $key
+ *
+ * @return mixed
+ */
function delete($key) {
$key = $this->cleanKey($key);
return $this->_cache->delete($key);
}
+ /**
+ * @param $key
+ *
+ * @return mixed|string
+ */
function cleanKey($key) {
$key = preg_replace('/\s+|\W+/', '_', $this->_prefix . $key);
if ( strlen($key) > self::MAX_KEY_LEN ) {
function __construct($config) {
}
+ /**
+ * @param string $key
+ * @param mixed $value
+ *
+ * @return bool
+ */
function set($key, &$value) {
return FALSE;
}
+ /**
+ * @param string $key
+ *
+ * @return null
+ */
function get($key) {
return NULL;
}
+ /**
+ * @param string $key
+ *
+ * @return bool
+ */
function delete($key) {
return FALSE;
}
+ /**
+ * @return bool
+ */
function flush() {
return FALSE;
}
+--------------------------------------------------------------------+
*/
+/**
+ * Class CRM_Utils_Cache_SerializeCache
+ */
class CRM_Utils_Cache_SerializeCache implements CRM_Utils_Cache_Interface {
/**
$this->_cache = array();
}
+ /**
+ * @param $key
+ *
+ * @return string
+ */
function fileName ($key) {
if (strlen($key) > 50)
return CIVICRM_TEMPLATE_COMPILEDIR ."CRM_".md5($key).".php";
return CIVICRM_TEMPLATE_COMPILEDIR .$key.".php";
}
+ /**
+ * @param string $key
+ *
+ * @return mixed
+ */
function get ($key) {
if (array_key_exists($key,$this->_cache))
return $this->_cache[$key];
return $this->_cache[$key];
}
+ /**
+ * @param string $key
+ * @param mixed $value
+ */
function set($key, &$value) {
if (file_exists($this->fileName ($key))) {
return;
file_put_contents ($this->fileName ($key),"<?php //".serialize ($value));
}
+ /**
+ * @param string $key
+ */
function delete($key) {
if (file_exists($this->fileName ($key))) {
unlink ($this->fileName ($key));
unset($this->_cache[$key]);
}
+ /**
+ * @param null $key
+ */
function flush($key =null) {
$prefix = "CRM_";
if (!$handle = opendir(CIVICRM_TEMPLATE_COMPILEDIR)) {
}
}
+ /**
+ * @param string $key
+ * @param mixed $value
+ */
function set($key, &$value) {
CRM_Core_BAO_Cache::setItem($value, $this->group, $key, $this->componentID);
$this->frontCache[$key] = $value;
}
+ /**
+ * @param string $key
+ *
+ * @return mixed
+ */
function get($key) {
if (! array_key_exists($key, $this->frontCache)) {
$this->frontCache[$key] = CRM_Core_BAO_Cache::getItem($this->group, $key, $this->componentID);
return $this->frontCache[$key];
}
+ /**
+ * @param $key
+ * @param null $default
+ *
+ * @return mixed
+ */
function getFromFrontCache($key, $default = NULL) {
return CRM_Utils_Array::value($key, $this->frontCache, $default);
}
+ /**
+ * @param string $key
+ */
function delete($key) {
CRM_Core_BAO_Cache::deleteGroup($this->group, $key);
unset($this->frontCache[$key]);
return $messages;
}
+ /**
+ * @return array
+ */
public function checkDebug() {
$messages = array();
return $messages;
}
+ /**
+ * @return array
+ */
public function checkOutboundMail() {
$messages = array();
return $messages;
}
-}
\ No newline at end of file
+}
*/
private $title;
+ /**
+ * @param $name
+ * @param $message
+ * @param $title
+ */
function __construct($name, $message, $title) {
$this->name = $name;
$this->message = $message;
return $result;
}
+ /**
+ * @param $topic
+ *
+ * @return string
+ */
public function createDocUrl($topic) {
return CRM_Utils_System::getWikiBaseURL() . $topic;
}
+--------------------------------------------------------------------+
*/
+/**
+ * Class CRM_Utils_Constant
+ */
class CRM_Utils_Constant {
/**
* Determine the value of a constant, if any.
- *
+ *
* If the specified constant is undefined, return a default value.
*
* @param string $name
return $fullMonthNames;
}
+ /**
+ * @param $string
+ *
+ * @return int
+ */
static function unixTime($string) {
if (empty($string)) {
return 0;
return FALSE;
}
+ /**
+ * @param $date
+ *
+ * @return bool
+ */
static function isDate(&$date) {
if (CRM_Utils_System::isNull($date)) {
return FALSE;
return TRUE;
}
+ /**
+ * @param null $timeStamp
+ *
+ * @return bool|string
+ */
static function currentDBDate($timeStamp = NULL) {
return $timeStamp ? date('YmdHis', $timeStamp) : date('YmdHis');
}
+ /**
+ * @param $date
+ * @param null $now
+ *
+ * @return bool
+ */
static function overdue($date, $now = NULL) {
$mysqlDate = self::isoToMysql($date);
if (!$now) {
}
+ /**
+ * @param $date
+ * @param $dateType
+ *
+ * @return null|string
+ */
static function formatDate($date, $dateType) {
$formattedDate = NULL;
if (empty($date)) {
}
}
+/**
+ * @param $params
+ * @param bool $dupeCheck
+ * @param bool $dupeErrorArray
+ * @param bool $requiredCheck
+ * @param null $dedupeRuleGroupID
+ *
+ * @return array|null
+ */
function _civicrm_api3_deprecated_contact_check_params(
&$params,
$dupeCheck = TRUE,
* @endcode
*/
class CRM_Utils_FakeObject {
+ /**
+ * @param $array
+ */
function __construct($array) {
$this->array = $array;
}
+ /**
+ * @param $name
+ * @param $arguments
+ *
+ * @throws Exception
+ */
function __call($name, $arguments) {
if (isset($this->array[$name]) && is_callable($this->array[$name])) {
return call_user_func_array($this->array[$name], $arguments);
throw new Exception("Call to unimplemented method: $name");
}
}
-}
\ No newline at end of file
+}
}
}
+ /**
+ * @param $source
+ * @param $destination
+ */
static function copyDir($source, $destination) {
$dir = opendir($source);
@mkdir($destination);
return $name;
}
+ /**
+ * @param $dsn
+ * @param $fileName
+ * @param null $prefix
+ * @param bool $isQueryString
+ * @param bool $dieOnErrors
+ */
static function sourceSQLFile($dsn, $fileName, $prefix = NULL, $isQueryString = FALSE, $dieOnErrors = TRUE) {
require_once 'DB.php';
}
}
+ /**
+ * @param $ext
+ *
+ * @return bool
+ */
static function isExtensionSafe($ext) {
static $extensions = NULL;
if (!$extensions) {
return $name;
}
+ /**
+ * @param $name
+ *
+ * @return string
+ */
static function makeFileName($name) {
$uniqID = md5(uniqid(rand(), TRUE));
$info = pathinfo($name);
}
}
+ /**
+ * @param $path
+ * @param $ext
+ *
+ * @return array
+ */
static function getFilesByExtension($path, $ext) {
$path = self::addTrailingSlash($path);
$dh = opendir($path);
return $_path;
}
+ /**
+ * @param $directory
+ *
+ * @return string
+ */
static function relativeDirectory($directory) {
// Do nothing on windows
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
return $directory;
}
+ /**
+ * @param $directory
+ *
+ * @return string
+ */
static function absoluteDirectory($directory) {
// Do nothing on windows - config will need to specify absolute path
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
return self::$_singleton;
}
+ /**
+ * @param $newFrame
+ */
public function push($newFrame) {
$this->backups[] = $this->createBackup($newFrame);
$this->applyFrame($newFrame);
return $frame;
}
+ /**
+ * @param $newFrame
+ */
public function applyFrame($newFrame) {
foreach ($newFrame as $globalKey => $values) {
if (is_array($values)) {
$fnSuffix
);
+ /**
+ * @param $numParams
+ * @param $arg1
+ * @param $arg2
+ * @param $arg3
+ * @param $arg4
+ * @param $arg5
+ * @param $arg6
+ * @param $fnSuffix
+ * @param $fnPrefix
+ *
+ * @return array|bool
+ */
function commonInvoke($numParams,
&$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6,
$fnSuffix, $fnPrefix
return empty($result) ? TRUE : $result;
}
+ /**
+ * @param $moduleList
+ */
function requireCiviModules(&$moduleList) {
$civiModules = CRM_Core_PseudoConstant::getModuleExtensions();
foreach ($civiModules as $civiModule) {
);
}
+ /**
+ * @param $recordBAO
+ * @param $recordID
+ * @param $isActive
+ *
+ * @return mixed
+ */
static function enableDisable($recordBAO, $recordID, $isActive) {
return self::singleton()->invoke(3, $recordBAO, $recordID, $isActive,
self::$_nullObject, self::$_nullObject, self::$_nullObject,
);
}
+ /**
+ * @param $dao
+ *
+ * @return mixed
+ */
static function postSave(&$dao) {
$hookName = 'civicrm_postSave_' . $dao->getTableName();
return self::singleton()->invoke(1, $dao,
);
}
+ /**
+ * @param $varType
+ * @param $var
+ * @param $object
+ *
+ * @return mixed
+ */
static function alterReportVar($varType, &$var, &$object) {
return self::singleton()->invoke(3, $varType, $var, $object,
self::$_nullObject,
*
*/
class CRM_Utils_Hook_Joomla extends CRM_Utils_Hook {
+ /**
+ *Invoke hooks
+ *
+ * @param int $numParams Number of parameters to pass to the hook
+ * @param mixed $arg1 parameter to be passed to the hook
+ * @param mixed $arg2 parameter to be passed to the hook
+ * @param mixed $arg3 parameter to be passed to the hook
+ * @param mixed $arg4 parameter to be passed to the hook
+ * @param mixed $arg5 parameter to be passed to the hook
+ * @param mixed $arg6 parameter to be passed to the hook
+ * @param string $fnSuffix function suffix, this is effectively the hook name
+ *
+ * @return mixed
+ */
+ /**
+ * @param int $numParams
+ * @param mixed $arg1
+ * @param mixed $arg2
+ * @param mixed $arg3
+ * @param mixed $arg4
+ * @param mixed $arg5
+ * @param mixed $arg6
+ * @param string $fnSuffix
+ *
+ * @return mixed
+ */
function invoke($numParams,
&$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6,
$fnSuffix
*
*/
class CRM_Utils_Hook_Soap extends CRM_Utils_Hook {
+ /**
+ *Invoke hooks
+ *
+ * @param int $numParams Number of parameters to pass to the hook
+ * @param mixed $arg1 parameter to be passed to the hook
+ * @param mixed $arg2 parameter to be passed to the hook
+ * @param mixed $arg3 parameter to be passed to the hook
+ * @param mixed $arg4 parameter to be passed to the hook
+ * @param mixed $arg5 parameter to be passed to the hook
+ * @param mixed $arg6 parameter to be passed to the hook
+ * @param string $fnSuffix function suffix, this is effectively the hook name
+ *
+ * @return mixed
+ */
+ /**
+ * @param int $numParams
+ * @param mixed $arg1
+ * @param mixed $arg2
+ * @param mixed $arg3
+ * @param mixed $arg4
+ * @param mixed $arg5
+ * @param mixed $arg6
+ * @param string $fnSuffix
+ *
+ * @return mixed
+ */
function invoke($numParams,
&$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6,
$fnSuffix
$this->adhocHooks[$hook] = $callable;
}
+ /**
+ *Invoke hooks
+ *
+ * @param int $numParams Number of parameters to pass to the hook
+ * @param mixed $arg1 parameter to be passed to the hook
+ * @param mixed $arg2 parameter to be passed to the hook
+ * @param mixed $arg3 parameter to be passed to the hook
+ * @param mixed $arg4 parameter to be passed to the hook
+ * @param mixed $arg5 parameter to be passed to the hook
+ * @param mixed $arg6 parameter to be passed to the hook
+ * @param string $fnSuffix function suffix, this is effectively the hook name
+ *
+ * @return mixed
+ */
+ /**
+ * @param int $numParams
+ * @param mixed $arg1
+ * @param mixed $arg2
+ * @param mixed $arg3
+ * @param mixed $arg4
+ * @param mixed $arg5
+ * @param mixed $arg6
+ * @param string $fnSuffix
+ *
+ * @return mixed
+ */
function invoke($numParams,
&$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6,
$fnSuffix) {
*
*/
class CRM_Utils_Hook_WordPress extends CRM_Utils_Hook {
+ /**
+ *Invoke hooks
+ *
+ * @param int $numParams Number of parameters to pass to the hook
+ * @param mixed $arg1 parameter to be passed to the hook
+ * @param mixed $arg2 parameter to be passed to the hook
+ * @param mixed $arg3 parameter to be passed to the hook
+ * @param mixed $arg4 parameter to be passed to the hook
+ * @param mixed $arg5 parameter to be passed to the hook
+ * @param mixed $arg6 parameter to be passed to the hook
+ * @param string $fnSuffix function suffix, this is effectively the hook name
+ *
+ * @return mixed
+ */
+ /**
+ * @param int $numParams
+ * @param mixed $arg1
+ * @param mixed $arg2
+ * @param mixed $arg3
+ * @param mixed $arg4
+ * @param mixed $arg5
+ * @param mixed $arg6
+ * @param string $fnSuffix
+ *
+ * @return mixed
+ */
function invoke($numParams,
&$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6,
$fnSuffix
*/
protected $connectionTimeout;
+ /**
+ * @return CRM_Utils_HttpClient
+ */
public static function singleton() {
if (!self::$singleton) {
self::$singleton = new CRM_Utils_HttpClient();
return self::$singleton;
}
+ /**
+ * @param null $connectionTimeout
+ */
public function __construct($connectionTimeout = NULL) {
$this->connectionTimeout = $connectionTimeout;
}
return array($ch, $caConfig);
}
+ /**
+ * @return bool
+ */
public function isRedirectSupported() {
return (ini_get('open_basedir') == '') && (ini_get('safe_mode') == 'Off' || ini_get('safe_mode') === FALSE);
}
return FALSE;
}
+ /**
+ * @param $mailer
+ * @param $result
+ *
+ * @return string
+ */
static function errorMessage($mailer, $result) {
$message = '<p>' . ts('An error occurred when CiviCRM attempted to send an email (via %1). If you received this error after submitting on online contribution or event registration - the transaction was completed, but we were unable to send the email receipt.', array(
1 => 'SMTP')) . '</p>' . '<p>' . ts('The mail library returned the following error message:') . '<br /><span class="font-red"><strong>' . $result->getMessage() . '</strong></span></p>' . '<p>' . ts('This is probably related to a problem in your Outbound Email Settings (Administer CiviCRM » System Settings » Outbound Email), OR the FROM email address specifically configured for your contribution page or event. Possible causes are:') . '</p>';
return $message;
}
+ /**
+ * @param $to
+ * @param $headers
+ * @param $message
+ */
static function logger(&$to, &$headers, &$message) {
if (is_array($to)) {
$toString = implode(', ', $to);
return FALSE;
}
+ /**
+ * @param $message
+ * @param null $params
+ *
+ * @return mixed
+ */
static function &setMimeParams(&$message, $params = NULL) {
static $mimeParams = NULL;
if (!$params) {
return $message->get($params);
}
+ /**
+ * @param $name
+ * @param $email
+ * @param bool $useQuote
+ *
+ * @return null|string
+ */
static function formatRFC822Email($name, $email, $useQuote = FALSE) {
$result = NULL;
// before the 4.1 release
define('EMAIL_ACTIVITY_TYPE_ID', NULL);
define('MAIL_BATCH_SIZE', 50);
+
+/**
+ * Class CRM_Utils_Mail_EmailProcessor
+ */
class CRM_Utils_Mail_EmailProcessor {
/**
}
}
+ /**
+ * @param $civiMail
+ * @param $dao
+ *
+ * @throws Exception
+ */
static function _process($civiMail, $dao) {
// 0 = activities; 1 = bounce;
$usedfor = $dao->is_default;
EMAILPROCESSOR_OVERRIDE = 2,
EMAILPROCESSOR_IGNORE = 3;
+ /**
+ * @param $mail
+ * @param $attachments
+ *
+ * @return string
+ */
function formatMail($mail, &$attachments) {
$t = '';
$t .= "From: " . self::formatAddress($mail->from) . "\n";
return $t;
}
+ /**
+ * @param $part
+ * @param $attachments
+ *
+ * @throws Exception
+ */
function formatMailPart($part, &$attachments) {
if ($part instanceof ezcMail) {
return self::formatMail($part, $attachments);
CRM_Core_Error::fatal(ts("No clue about the %1", array(1 => get_class($part))));
}
+ /**
+ * @param $part
+ * @param $attachments
+ *
+ * @throws Exception
+ */
function formatMailMultipart($part, &$attachments) {
if ($part instanceof ezcMailMultiPartAlternative) {
return self::formatMailMultipartAlternative($part, $attachments);
CRM_Core_Error::fatal(ts("No clue about the %1", array(1 => get_class($part))));
}
+ /**
+ * @param $part
+ * @param $attachments
+ *
+ * @return string
+ */
function formatMailMultipartMixed($part, &$attachments) {
$t = '';
foreach ($part->getParts() as $key => $alternativePart) {
return $t;
}
+ /**
+ * @param $part
+ * @param $attachments
+ *
+ * @return string
+ */
function formatMailMultipartRelated($part, &$attachments) {
$t = '';
$t .= "-RELATED MAIN PART-\n";
return $t;
}
+ /**
+ * @param $part
+ * @param $attachments
+ *
+ * @return string
+ */
function formatMailMultipartDigest($part, &$attachments) {
$t = '';
foreach ($part->getParts() as $key => $alternativePart) {
return $t;
}
+ /**
+ * @param $part
+ * @param $attachments
+ *
+ * @return string
+ */
function formatMailRfc822Digest($part, &$attachments) {
$t = '';
$t .= "-DIGEST-ITEM-\n";
return $t;
}
+ /**
+ * @param $part
+ * @param $attachments
+ *
+ * @return string
+ */
function formatMailMultipartAlternative($part, &$attachments) {
$t = '';
foreach ($part->getParts() as $key => $alternativePart) {
return $t;
}
+ /**
+ * @param $part
+ * @param $attachments
+ *
+ * @return string
+ */
function formatMailText($part, &$attachments) {
$t = "\n{$part->text}\n";
return $t;
}
+ /**
+ * @param $part
+ * @param $attachments
+ *
+ * @return string
+ */
function formatMailMultipartReport($part, &$attachments) {
$t = '';
foreach ($part->getParts() as $key => $reportPart) {
return $t;
}
+ /**
+ * @param $part
+ * @param $attachments
+ *
+ * @return null
+ */
function formatMailFile($part, &$attachments) {
$attachments[] = array(
'dispositionType' => $part->dispositionType,
return NULL;
}
+ /**
+ * @param $addresses
+ *
+ * @return string
+ */
function formatAddresses($addresses) {
$fa = array();
foreach ($addresses as $address) {
return implode(', ', $fa);
}
+ /**
+ * @param $address
+ *
+ * @return string
+ */
function formatAddress($address) {
$name = '';
if (!empty($address->name)) {
return $name . "<{$address->email}>";
}
+ /**
+ * @param $file
+ *
+ * @return array
+ * @throws Exception
+ */
function &parse(&$file) {
// check that the file exists and has some content
return $mailParams;
}
+ /**
+ * @param $mail
+ *
+ * @return array
+ */
function parseMailingObject(&$mail) {
$config = CRM_Core_Config::singleton();
return $params;
}
+ /**
+ * @param $address
+ * @param $params
+ * @param $subParam
+ * @param $mail
+ */
function parseAddress(&$address, &$params, &$subParam, &$mail) {
// CRM-9484
if (empty($address->email)) {
$subParam['id'] = $contactID ? $contactID : NULL;
}
+ /**
+ * @param $addresses
+ * @param $token
+ * @param $params
+ * @param $mail
+ */
function parseAddresses(&$addresses, $token, &$params, &$mail) {
$params[$token] = array();
*/
protected $_xml;
+ /**
+ *
+ */
function __construct() {
$this->_xml = array(
'customGroup' => array(
return $result;
}
+ /**
+ * @param $groupName
+ * @param $daoName
+ * @param null $sql
+ */
function fetch($groupName, $daoName, $sql = NULL) {
$idNameFields = isset($this->_xml[$groupName]['idNameFields']) ? $this->_xml[$groupName]['idNameFields'] : NULL;
$mappedFields = isset($this->_xml[$groupName]['mappedFields']) ? $this->_xml[$groupName]['mappedFields'] : NULL;
protected $_sitePrefix = 'Site 1';
+ /**
+ * @param $params
+ */
function __construct(&$params) {
foreach ($params as $name => $value) {
$varName = '_' . $name;
$this->auxTable($auxilaryTables);
}
+ /**
+ * @param $tables
+ */
function auxTable($tables) {
foreach ($tables as $tableName => $daoName) {
$fields = & $this->dbFields($daoName, TRUE);
}
}
+ /**
+ * @param $optionGroupVars
+ */
function optionGroup($optionGroupVars) {
$names = array_values($optionGroupVars);
$str = array();
$this->sql($sql, 'civicrm_option_value', $fields);
}
+ /**
+ * @param $ids
+ * @param $tableName
+ * @param $fields
+ * @param $whereField
+ * @param null $additionalWhereCond
+ */
function table(&$ids,
$tableName,
&$fields,
$this->sql($sql, $tableName, $fields);
}
+ /**
+ * @param $sql
+ * @param $tableName
+ * @param $fields
+ */
function sql($sql, $tableName, &$fields) {
$dao = & CRM_Core_DAO::executeQuery($sql);
$dao->free();
}
+ /**
+ * @param $contactIDs
+ */
function contact(&$contactIDs) {
$fields = & $this->dbFields('CRM_Contact_DAO_Contact', TRUE);
$this->table($contactIDs, 'civicrm_contact', $fields, 'id', NULL);
}
+ /**
+ * @param $contactIDs
+ */
function note(&$contactIDs) {
$fields = & $this->dbFields('CRM_Core_DAO_Note', TRUE);
$this->table($contactIDs, 'civicrm_note', $fields, 'entity_id', "entity_table = 'civicrm_contact'");
}
+ /**
+ * @param $contactIDs
+ */
function phone(&$contactIDs) {
$fields = & $this->dbFields('CRM_Core_DAO_Phone', TRUE);
$this->table($contactIDs, 'civicrm_phone', $fields, 'contact_id', NULL);
}
+ /**
+ * @param $contactIDs
+ */
function email(&$contactIDs) {
$fields = & $this->dbFields('CRM_Core_DAO_Email', TRUE);
$this->table($contactIDs, 'civicrm_email', $fields, 'contact_id', NULL);
}
+ /**
+ * @param $contactIDs
+ */
function im(&$contactIDs) {
$fields = & $this->dbFields('CRM_Core_DAO_IM', TRUE);
$this->table($contactIDs, 'civicrm_im', $fields, 'contact_id', NULL);
}
+ /**
+ * @param $contactIDs
+ */
function website(&$contactIDs) {
$fields = & $this->dbFields('CRM_Core_DAO_Website', TRUE);
$this->table($contactIDs, 'civicrm_website', $fields, 'contact_id', NULL);
}
+ /**
+ * @param $contactIDs
+ */
function address(&$contactIDs) {
$fields = & $this->dbFields('CRM_Core_DAO_Email', TRUE);
$this->table($contactIDs, 'civicrm_address', $fields, 'contact_id', NULL);
}
+ /**
+ * @param $contactIDs
+ */
function groupContact(&$contactIDs) {
$fields = & $this->dbFields('CRM_Contact_DAO_GroupContact', TRUE);
$this->table($contactIDs, 'civicrm_group_contact', $fields, 'contact_id', NULL);
// TODO - support group inheritance
// Parent child group ids are encoded in a text string
+ /**
+ * @param $contactIDs
+ */
function group(&$contactIDs) {
// handle groups only once
static $_groupsHandled = array();
}
// TODO - support search builder and custom saved searches
+ /**
+ * @param $groupIDs
+ */
function savedSearch(&$groupIDs) {
if (empty($groupIDs)) {
return;
$this->sql($sql, 'civicrm_saved_search', $fields);
}
+ /**
+ * @param $contactIDs
+ */
function entityTag(&$contactIDs) {
$fields = & $this->dbFields('CRM_Core_DAO_EntityTag', TRUE);
$this->table($contactIDs, 'civicrm_entity_tag', $fields, 'entity_id', "entity_table = 'civicrm_contact'");
}
+ /**
+ * @param $contactIDs
+ */
function tag(&$contactIDs) {
// handle tags only once
static $_tagsHandled = array();
$this->table($tagIDs, 'civicrm_tag', $fields, 'id');
}
+ /**
+ * @param $contactIDs
+ * @param $additionalContacts
+ */
function relationship(&$contactIDs, &$additionalContacts) {
// handle relationships only once
static $_relationshipsHandled = array();
$dao->free();
}
+ /**
+ * @param $contactIDs
+ * @param $additionalContacts
+ */
function activity(&$contactIDs, &$additionalContacts) {
static $_activitiesHandled = array();
$activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
$dao->free();
}
+ /**
+ * @param $id
+ * @param $name
+ * @param $value
+ */
function appendValue($id, $name, $value) {
if (empty($value)) {
return;
$this->_values[$name][] = array_values($value);
}
+ /**
+ * @param $daoName
+ * @param bool $onlyKeys
+ *
+ * @return array
+ */
function dbFields($daoName, $onlyKeys = FALSE) {
static $_fieldsRetrieved = array();
}
}
+ /**
+ * @param $contactIDs
+ * @param $additionalContacts
+ */
function addAdditionalContacts($contactIDs, &$additionalContacts) {
if (!$this->_discoverContacts) {
return;
}
}
+ /**
+ * @param $contactIDs
+ */
function export(&$contactIDs) {
$chunks = & $this->splitContactIDs($contactIDs);
}
}
+ /**
+ * @param $fileName
+ * @param null $lastExportTime
+ * @param bool $discoverContacts
+ */
function run($fileName,
$lastExportTime = NULL,
$discoverContacts = FALSE
*
*/
class CRM_Utils_Migrate_Import {
+ /**
+ *
+ */
function __construct() {
}
CRM_Core_Config::clearDBCache();
}
+ /**
+ * @param $dao
+ * @param $xml
+ * @param bool $save
+ * @param null $keyName
+ *
+ * @return bool
+ */
function copyData(&$dao, &$xml, $save = FALSE, $keyName = NULL) {
if ($keyName) {
if (isset($xml->$keyName)) {
return TRUE;
}
+ /**
+ * @param $xml
+ * @param $idMap
+ */
function optionGroups(&$xml, &$idMap) {
foreach ($xml->OptionGroups as $optionGroupsXML) {
foreach ($optionGroupsXML->OptionGroup as $optionGroupXML) {
}
}
+ /**
+ * @param $xml
+ * @param $idMap
+ */
function optionValues(&$xml, &$idMap) {
foreach ($xml->OptionValues as $optionValuesXML) {
foreach ($optionValuesXML->OptionValue as $optionValueXML) {
}
}
+ /**
+ * @param $xml
+ */
function relationshipTypes(&$xml) {
foreach ($xml->RelationshipTypes as $relationshipTypesXML) {
}
}
+ /**
+ * @param $xml
+ */
function contributionTypes(&$xml) {
foreach ($xml->ContributionTypes as $contributionTypesXML) {
}
}
+ /**
+ * @param $xml
+ * @param $idMap
+ */
function customGroups(&$xml, &$idMap) {
foreach ($xml->CustomGroups as $customGroupsXML) {
foreach ($customGroupsXML->CustomGroup as $customGroupXML) {
}
}
+ /**
+ * @param $xml
+ * @param $idMap
+ */
function customFields(&$xml, &$idMap) {
// Re-index by group id so we can build out the custom fields one table
// at a time, and then rebuild the table triggers at the end, rather than
}
}
+ /**
+ * @param $xml
+ * @param $idMap
+ */
function dbTemplateString(&$xml, &$idMap) {
foreach ($xml->Persistent as $persistentXML) {
foreach ($persistentXML->Persistent as $persistent) {
}
}
+ /**
+ * @param $xml
+ * @param $idMap
+ */
function profileGroups(&$xml, &$idMap) {
foreach ($xml->ProfileGroups as $profileGroupsXML) {
foreach ($profileGroupsXML->ProfileGroup as $profileGroupXML) {
}
}
+ /**
+ * @param $xml
+ * @param $idMap
+ *
+ * @throws Exception
+ */
function profileFields(&$xml, &$idMap) {
foreach ($xml->ProfileFields as $profileFieldsXML) {
foreach ($profileFieldsXML->ProfileField as $profileFieldXML) {
}
}
+ /**
+ * @param $xml
+ * @param $idMap
+ */
function profileJoins(&$xml, &$idMap) {
foreach ($xml->ProfileJoins as $profileJoinsXML) {
foreach ($profileJoinsXML->ProfileJoin as $profileJoinXML) {
protected $_saveMapping;
+ /**
+ *
+ */
function __construct() {
$this->_lookupCache = array();
$this->_saveMapping = array();
}
+ /**
+ * @param $file
+ */
function run($file) {
$json = file_get_contents($file);
CRM_Core_Config::clearDBCache();
}
+ /**
+ * @param $contact
+ */
function contact(&$contact) {
$this->restore($contact,
'CRM_Contact_DAO_Contact',
);
}
+ /**
+ * @param $email
+ */
function email(&$email) {
$this->restore($email,
'CRM_Core_DAO_Email',
);
}
+ /**
+ * @param $phone
+ */
function phone(&$phone) {
$this->restore($phone,
'CRM_Core_DAO_Phone',
);
}
+ /**
+ * @param $address
+ */
function address(&$address) {
$this->restore($address,
'CRM_Core_DAO_Address',
);
}
+ /**
+ * @param $note
+ */
function note(&$note) {
$this->restore($note,
'CRM_Core_DAO_Note',
);
}
+ /**
+ * @param $relationship
+ */
function relationship(&$relationship) {
$this->restore($relationship,
'CRM_Contact_DAO_Relationship',
);
}
+ /**
+ * @param $activity
+ * @param $activityContacts
+ */
function activity($activity, $activityContacts) {
$this->restore($activity,
'CRM_Activity_DAO_Activity',
);
}
+ /**
+ * @param $group
+ * @param $groupContact
+ */
function group($group, $groupContact) {
$this->restore($group,
'CRM_Contact_DAO_Group',
);
}
+ /**
+ * @param $tag
+ * @param $entityTag
+ */
function tag($tag, $entityTag) {
$this->restore($tag,
'CRM_Core_DAO_Tag',
);
}
+ /**
+ * @param $chunk
+ * @param $daoName
+ * @param null $lookUpMapping
+ * @param null $dateFields
+ */
function restore(&$chunk, $daoName, $lookUpMapping = NULL, $dateFields = NULL) {
$object = new $daoName();
$tableName = $object->__table;
}
}
+ /**
+ * @param $tableName
+ */
function populateCache($tableName) {
if (isset($this->_lookupCache[$tableName])) {
return;
<?php
+
+/**
+ * Class CRM_Utils_Number
+ */
class CRM_Utils_Number {
/**
* Create a random number with a given precision
return $chart;
}
+ /**
+ * @param $rows
+ * @param $chart
+ * @param $interval
+ *
+ * @return array
+ */
static function chart($rows, $chart, $interval) {
$chartData = $dateKeys = array();
return self::buildChart($chartData, $chart);
}
+ /**
+ * @param $rows
+ * @param $chart
+ * @param $interval
+ * @param $chartInfo
+ *
+ * @return array
+ */
static function reportChart($rows, $chart, $interval, &$chartInfo) {
foreach ($interval as $key => $val) {
$graph[$val] = $rows['value'][$key];
return self::buildChart($chartData, $chart);
}
+ /**
+ * @param $params
+ * @param $chart
+ *
+ * @return array
+ */
static function buildChart(&$params, $chart) {
$openFlashChart = array();
if ($chart && is_array($params) && !empty($params)) {
<?php
+/**
+ * Class CRM_Utils_OptionBag
+ */
class CRM_Utils_OptionBag implements ArrayAccess, IteratorAggregate, Countable {
protected $data;
+ /**
+ * @param array $data
+ */
public function __construct($data = array()) {
$this->data = $data;
}
}
}
+ /**
+ * @param $key
+ *
+ * @return bool
+ */
public function has($key) {
return isset($this->data[$key]);
}
}
-}
\ No newline at end of file
+}
*/
require_once 'tcpdf/tcpdf.php';
+
+/**
+ * Class CRM_Utils_PDF_Label
+ */
class CRM_Utils_PDF_Label extends TCPDF {
// make these properties public due to
$this->setPrintFooter(FALSE);
}
+ /**
+ * @param $objectinstance
+ * @param string $methodname
+ */
function SetGenerator($objectinstance, $methodname = 'generateLabel') {
$this->generatorMethod = $methodname;
$this->generatorObject = $objectinstance;
}
+ /**
+ * @param $name
+ * @param bool $convert
+ *
+ * @return float|int|mixed
+ */
function getFormatValue($name, $convert = FALSE) {
if (isset($this->format[$name])) {
$value = $this->format[$name];
/*
* Function to initialize label format settings
*/
+ /**
+ * @param $format
+ * @param $unit
+ */
function LabelSetFormat(&$format, $unit) {
$this->defaults = CRM_Core_BAO_LabelFormat::getDefaultValues();
$this->format = &$format;
/*
* function to Generate the pdf of one label (can be modified using SetGenerator)
*/
+ /**
+ * @param $text
+ */
function generateLabel($text) {
$args = array(
'w' => $this->width,
/*
* function to Print a label
*/
+ /**
+ * @param $texte
+ */
function AddPdfLabel($texte) {
if ($this->countX == $this->xNumber) {
// Page full, we start a new one
*/
class CRM_Utils_PDF_Utils {
+ /**
+ * @param $text
+ * @param string $fileName
+ * @param bool $output
+ * @param null $pdfFormat
+ *
+ * @return string|void
+ */
static function html2pdf(&$text, $fileName = 'civicrm.pdf', $output = FALSE, $pdfFormat = NULL) {
if (is_array($text)) {
$pages = &$text;
}
}
+ /**
+ * @param $paper_size
+ * @param $orientation
+ * @param $html
+ * @param $output
+ * @param $fileName
+ *
+ * @return string
+ */
static function _html2pdf_dompdf($paper_size, $orientation, $html, $output, $fileName) {
require_once 'packages/dompdf/dompdf_config.inc.php';
spl_autoload_register('DOMPDF_autoload');
}
}
+ /**
+ * @param $paper_size
+ * @param $orientation
+ * @param $margins
+ * @param $html
+ * @param $output
+ * @param $fileName
+ */
static function _html2pdf_wkhtmltopdf($paper_size, $orientation, $margins, $html, $output, $fileName) {
require_once 'packages/snappy/src/autoload.php';
$config = CRM_Core_Config::singleton();
/*
* function to convert value from one metric to another
*/
+ /**
+ * @param $value
+ * @param $from
+ * @param $to
+ * @param null $precision
+ *
+ * @return float|int
+ */
static function convertMetric($value, $from, $to, $precision = NULL) {
switch ($from . $to) {
case 'incm':
return $value;
}
+ /**
+ * @param $fileName
+ * @param $searchPath
+ * @param $values
+ * @param int $numPages
+ * @param bool $echo
+ * @param string $output
+ * @param string $creator
+ * @param string $author
+ * @param string $title
+ */
static function &pdflib($fileName,
$searchPath,
&$values,
*/
require_once 'Pager/Sliding.php';
+
+/**
+ * Class CRM_Utils_Pager
+ */
class CRM_Utils_Pager extends Pager_Sliding {
/**
return array($offset, $this->_perPage);
}
+ /**
+ * @return string
+ */
function getCurrentLocation() {
$config = CRM_Core_Config::singleton();
$path = CRM_Utils_Array::value($config->userFrameworkURLVar, $_GET);
return CRM_Utils_System::url($path, CRM_Utils_System::getLinksUrl(self::PAGE_ID, FALSE, TRUE), FALSE, NULL, FALSE) . $this->getCurrentPageID();
}
+ /**
+ * @return string
+ */
function getFirstPageLink() {
if ($this->isFirstPage()) {
return '';
) . $this->_spacesBefore . $this->_spacesAfter;
}
+ /**
+ * @return string
+ */
function getLastPageLink() {
if ($this->isLastPage()) {
return '';
);
}
+ /**
+ * @return string
+ */
function getBackPageLink() {
if ($this->_currentPage > 1) {
$href = $this->makeURL(self::PAGE_ID, $this->getPreviousPageID());
return '';
}
+ /**
+ * @return string
+ */
function getNextPageLink() {
if ($this->_currentPage < $this->_totalPages) {
$href = $this->makeURL(self::PAGE_ID, $this->getNextPageID());
}
// Generates values needed for error messages
+ /**
+ * @param string $message
+ *
+ * @return array
+ */
static function error($message = 'Unknown Error') {
$values = array(
'error_message' => $message,
}
// Generates values needed for non-error responses.
+ /**
+ * @param $params
+ *
+ * @return array
+ */
static function simple($params) {
$values = array('is_error' => 0);
$values += $params;
return $values;
}
+ /**
+ * @return string
+ */
function run() {
$result = self::handle();
return self::output($result);
}
+ /**
+ * @return string
+ */
function bootAndRun() {
$response = $this->loadCMSBootstrap();
if (is_array($response)) {
return $this->run();
}
+ /**
+ * @param $result
+ *
+ * @return string
+ */
static function output(&$result) {
$requestParams = CRM_Utils_Request::exportValues();
return $xml;
}
+ /**
+ * @param $json
+ *
+ * @return string
+ */
static function jsonFormated($json) {
$tabcount = 0;
$result = '';
return $result;
}
+ /**
+ * @return array|int
+ */
static function handle() {
$requestParams = CRM_Utils_Request::exportValues();
return self::process($args, self::buildParamList());
}
+ /**
+ * @param $args
+ * @param $params
+ *
+ * @return array|int
+ */
static function process(&$args, $params) {
$params['check_permissions'] = TRUE;
$fnName = $apiFile = NULL;
return $result;
}
+ /**
+ * @return array|mixed|null
+ */
static function &buildParamList() {
$requestParams = CRM_Utils_Request::exportValues();
$params = array();
return $params;
}
+ /**
+ * @param $pearError
+ */
static function fatal($pearError) {
header('Content-Type: text/xml');
$error = array();
return self::$_singleton;
}
+ /**
+ *
+ */
function __construct() {}
/**
);
}
+ /**
+ * @param $value
+ * @param $form
+ *
+ * @return mixed
+ */
static function validate($value, $form) {
$config = CRM_Core_Config::singleton();
require_once 'HTML/QuickForm/Rule/Email.php';
+/**
+ * Class CRM_Utils_Rule
+ */
class CRM_Utils_Rule {
+ /**
+ * @param $str
+ * @param int $maxLength
+ *
+ * @return bool
+ */
static function title($str, $maxLength = 127) {
// check length etc
return TRUE;
}
+ /**
+ * @param $str
+ *
+ * @return bool
+ */
static function longTitle($str) {
return self::title($str, 255);
}
+ /**
+ * @param $str
+ *
+ * @return bool
+ */
static function variable($str) {
// check length etc
if (empty($str) || strlen($str) > 31) {
return TRUE;
}
+ /**
+ * @param $str
+ *
+ * @return bool
+ */
static function qfVariable($str) {
// check length etc
//if ( empty( $str ) || strlen( $str ) > 31 ) {
return TRUE;
}
+ /**
+ * @param $phone
+ *
+ * @return bool
+ */
static function phone($phone) {
// check length etc
if (empty($phone) || strlen($phone) > 16) {
return FALSE;
}
+ /**
+ * @param $query
+ *
+ * @return bool
+ */
static function query($query) {
// check length etc
if (empty($query) || strlen($query) < 3 || strlen($query) > 127) {
return TRUE;
}
+ /**
+ * @param $url
+ *
+ * @return bool
+ */
static function url($url) {
return (bool) filter_var($url, FILTER_VALIDATE_URL);
}
+ /**
+ * @param $string
+ *
+ * @return bool
+ */
static function wikiURL($string) {
$items = explode(' ', trim($string), 2);
return self::url($items[0]);
}
+ /**
+ * @param $domain
+ *
+ * @return bool
+ */
static function domain($domain) {
// not perfect, but better than the previous one; see CRM-1502
if (!preg_match('/^[A-Za-z0-9]([A-Za-z0-9\.\-]*[A-Za-z0-9])?$/', $domain)) {
return TRUE;
}
+ /**
+ * @param $value
+ * @param null $default
+ *
+ * @return null
+ */
static function date($value, $default = NULL) {
if (is_string($value) &&
preg_match('/^\d\d\d\d-?\d\d-?\d\d$/', $value)
return $default;
}
+ /**
+ * @param $value
+ * @param null $default
+ *
+ * @return null|string
+ */
static function dateTime($value, $default = NULL) {
$result = $default;
if (is_string($value) &&
return FALSE;
}
+ /**
+ * @param $value
+ *
+ * @return bool
+ */
static function integer($value) {
if (is_int($value)) {
return TRUE;
return FALSE;
}
+ /**
+ * @param $value
+ *
+ * @return bool
+ */
static function positiveInteger($value) {
if (is_int($value)) {
return ($value < 0) ? FALSE : TRUE;
return FALSE;
}
+ /**
+ * @param $value
+ *
+ * @return bool
+ */
static function numeric($value) {
// lets use a php gatekeeper to ensure this is numeric
if (!is_numeric($value)) {
return preg_match('/(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/', $value) ? TRUE : FALSE;
}
+ /**
+ * @param $value
+ * @param $noOfDigit
+ *
+ * @return bool
+ */
static function numberOfDigit($value, $noOfDigit) {
return preg_match('/^\d{' . $noOfDigit . '}$/', $value) ? TRUE : FALSE;
}
+ /**
+ * @param $value
+ *
+ * @return mixed
+ */
static function cleanMoney($value) {
// first remove all white space
$value = str_replace(array(' ', "\t", "\n"), '', $value);
return $value;
}
+ /**
+ * @param $value
+ *
+ * @return bool
+ */
static function money($value) {
$config = CRM_Core_Config::singleton();
return preg_match('/(^-?\d+\.\d?\d?$)|(^-?\.\d\d?$)/', $value) ? TRUE : FALSE;
}
+ /**
+ * @param $value
+ * @param int $maxLength
+ *
+ * @return bool
+ */
static function string($value, $maxLength = 0) {
if (is_string($value) &&
($maxLength === 0 || strlen($value) <= $maxLength)
return FALSE;
}
+ /**
+ * @param $value
+ *
+ * @return bool
+ */
static function boolean($value) {
return preg_match(
'/(^(1|0)$)|(^(Y(es)?|N(o)?)$)|(^(T(rue)?|F(alse)?)$)/i', $value
) ? TRUE : FALSE;
}
+ /**
+ * @param $value
+ *
+ * @return bool
+ */
static function email($value) {
return (bool) filter_var($value, FILTER_VALIDATE_EMAIL);
}
+ /**
+ * @param $list
+ *
+ * @return bool
+ */
static function emailList($list) {
$emails = explode(',', $list);
foreach ($emails as $email) {
// allow between 4-6 digits as postal code since india needs 6 and US needs 5 (or
// if u disregard the first 0, 4 (thanx excel!)
// FIXME: we need to figure out how to localize such rules
+ /**
+ * @param $value
+ *
+ * @return bool
+ */
static function postalCode($value) {
if (preg_match('/^\d{4,6}(-\d{4})?$/', $value)) {
return TRUE;
return CRM_Core_DAO::objectExists($value, CRM_Utils_Array::value(0, $options), CRM_Utils_Array::value(1, $options), CRM_Utils_Array::value(2, $options, $name));
}
+ /**
+ * @param $value
+ * @param $options
+ *
+ * @return bool
+ */
static function optionExists($value, $options) {
return CRM_Core_OptionValue::optionExists($value, $options[0], $options[1], $options[2], CRM_Utils_Array::value(3, $options, 'name'));
}
+ /**
+ * @param $value
+ * @param $type
+ *
+ * @return bool
+ */
static function creditCardNumber($value, $type) {
require_once 'Validate/Finance/CreditCard.php';
return Validate_Finance_CreditCard::number($value, $type);
}
+ /**
+ * @param $value
+ * @param $type
+ *
+ * @return bool
+ */
static function cvv($value, $type) {
require_once 'Validate/Finance/CreditCard.php';
return Validate_Finance_CreditCard::cvv($value, $type);
}
+ /**
+ * @param $value
+ *
+ * @return bool
+ */
static function currencyCode($value) {
static $currencyCodes = NULL;
if (!$currencyCodes) {
return FALSE;
}
+ /**
+ * @param $value
+ *
+ * @return bool
+ */
static function xssString($value) {
if (is_string($value)) {
return preg_match('!<(vb)?script[^>]*>.*</(vb)?script.*>!ims',
}
}
+ /**
+ * @param $path
+ *
+ * @return bool
+ */
static function fileExists($path) {
return file_exists($path);
}
+ /**
+ * @param $value
+ * @param $options
+ *
+ * @return bool
+ */
static function autocomplete($value, $options) {
if ($value) {
$selectOption = CRM_Core_BAO_CustomOption::valuesByID($options['fieldID'], $options['optionGroupID']);
return TRUE;
}
+ /**
+ * @param $value
+ * @param null $actualElementValue
+ *
+ * @return bool
+ */
static function validContact($value, $actualElementValue = NULL) {
if ($actualElementValue) {
$value = $actualElementValue;
return FALSE;
}
+ /**
+ * @param $key
+ *
+ * @return bool
+ */
static function qfKey($key) {
return ($key) ? CRM_Core_Key::valid($key) : FALSE;
}
return ($token == $newToken);
}
+ /**
+ * @return string
+ */
function createSalt() {
// It would be more secure to generate a new value but liable to run this
// many times on certain admin pages; so instead we'll re-use the hash.
return civicrm_api('Mailing', 'event_bounce', $params);
}
+ /**
+ * @param $key
+ * @param $job
+ * @param $queue
+ * @param $hash
+ *
+ * @return array|int
+ * @throws SoapFault
+ */
public function mailer_event_unsubscribe($key, $job, $queue, $hash) {
$this->verify($key);
$params = array(
return civicrm_api('MailingGroup', 'event_unsubscribe', $params);
}
+ /**
+ * @param $key
+ * @param $job
+ * @param $queue
+ * @param $hash
+ *
+ * @return array|int
+ * @throws SoapFault
+ */
public function mailer_event_domain_unsubscribe($key, $job, $queue, $hash) {
$this->verify($key);
$params = array(
return civicrm_api('MailingGroup', 'event_domain_unsubscribe', $params);
}
+ /**
+ * @param $key
+ * @param $job
+ * @param $queue
+ * @param $hash
+ *
+ * @return array|int
+ * @throws SoapFault
+ */
public function mailer_event_resubscribe($key, $job, $queue, $hash) {
$this->verify($key);
$params = array(
return civicrm_api('MailingGroup', 'event_resubscribe', $params);
}
+ /**
+ * @param $key
+ * @param $email
+ * @param $domain
+ * @param $group
+ *
+ * @return array|int
+ * @throws SoapFault
+ */
public function mailer_event_subscribe($key, $email, $domain, $group) {
$this->verify($key);
$params = array(
return civicrm_api('MailingGroup', 'event_subscribe', $params);
}
+ /**
+ * @param $key
+ * @param $contact
+ * @param $subscribe
+ * @param $hash
+ *
+ * @return array|int
+ * @throws SoapFault
+ */
public function mailer_event_confirm($key, $contact, $subscribe, $hash) {
$this->verify($key);
$params = array(
return civicrm_api('Mailing', 'event_confirm', $params);
}
+ /**
+ * @param $key
+ * @param $job
+ * @param $queue
+ * @param $hash
+ * @param $bodyTxt
+ * @param $rt
+ * @param null $bodyHTML
+ * @param null $fullEmail
+ *
+ * @return array|int
+ * @throws SoapFault
+ */
public function mailer_event_reply($key, $job, $queue, $hash, $bodyTxt, $rt, $bodyHTML = NULL, $fullEmail = NULL) {
$this->verify($key);
$params = array(
return civicrm_api('Mailing', 'event_reply', $params);
}
+ /**
+ * @param $key
+ * @param $job
+ * @param $queue
+ * @param $hash
+ * @param $email
+ *
+ * @return array|int
+ * @throws SoapFault
+ */
public function mailer_event_forward($key, $job, $queue, $hash, $email) {
$this->verify($key);
$params = array(
return civicrm_api('Mailing', 'event_forward', $params);
}
+ /**
+ * @param $key
+ * @param $params
+ *
+ * @return array|int
+ * @throws SoapFault
+ */
public function get_contact($key, $params) {
$this->verify($key);
$params['version'] = 3;
return CRM_Core_DAO::$_nullArray;
}
+ /**
+ * @param $str
+ * @param $stringRules
+ *
+ * @return mixed
+ */
static function redaction($str, $stringRules) {
//redact the strings
if (!empty($stringRules)) {
return $text;
}
+ /**
+ * @param $string
+ * @param $params
+ */
static function extractName($string, &$params) {
$name = trim($string);
if (empty($name)) {
}
}
+ /**
+ * @param $string
+ *
+ * @return array
+ */
static function &makeArray($string) {
$string = trim($string);
static $_apiURL = 'http://api.sunlightlabs.com/';
static $_apiKey = NULL;
+ /**
+ * @param $uri
+ *
+ * @return SimpleXMLElement
+ * @throws Exception
+ */
static function makeAPICall($uri) {
require_once 'HTTP/Request.php';
$params = array(
return simplexml_load_string($string);
}
+ /**
+ * @param $zipcode
+ *
+ * @return array
+ */
static function getCityState($zipcode) {
$key = self::$_apiKey;
$uri = "places.getCityStateFromZip.php?zip={$zipcode}&apikey={$key}&output=xml";
return array($xml->city, $xml->state);
}
+ /**
+ * @param $peopleID
+ *
+ * @return array
+ */
static function getDetailedInfo($peopleID) {
$key = self::$_apiKey;
$uri = "people.getPersonInfo.php?id={$peopleID}&apikey={$key}&output=xml";
return $result;
}
+ /**
+ * @param $uri
+ *
+ * @return array
+ */
static function getPeopleInfo($uri) {
$xml = self::makeAPICall($uri);
return $result;
}
+ /**
+ * @param $city
+ * @param $state
+ *
+ * @return array|null
+ */
static function getRepresentativeInfo($city, $state) {
if (!$city ||
!$state
return self::getPeopleInfo($uri);
}
+ /**
+ * @param $state
+ *
+ * @return array|null
+ */
static function getSenatorInfo($state) {
if (!$state) {
return NULL;
return self::getPeopleInfo($uri);
}
+ /**
+ * @param $city
+ * @param $state
+ * @param null $zipcode
+ *
+ * @return array
+ */
static function getInfo($city, $state, $zipcode = NULL) {
if ($zipcode) {
list($city, $state) = self::getCityState($zipcode);
return $config->userSystem->url($path, $query, $absolute, $fragment, $htmlize, $frontend, $forceBackend);
}
+ /**
+ * @param $text
+ * @param null $path
+ * @param null $query
+ * @param bool $absolute
+ * @param null $fragment
+ * @param bool $htmlize
+ * @param bool $frontend
+ * @param bool $forceBackend
+ *
+ * @return string
+ */
static function href($text, $path = NULL, $query = NULL, $absolute = TRUE,
$fragment = NULL, $htmlize = TRUE, $frontend = FALSE, $forceBackend = FALSE
) {
return "<a href=\"$url\">$text</a>";
}
+ /**
+ * @return mixed
+ */
static function permissionDenied() {
$config = CRM_Core_Config::singleton();
return $config->userSystem->permissionDenied();
}
+ /**
+ * @return mixed
+ */
static function logout() {
$config = CRM_Core_Config::singleton();
return $config->userSystem->logout();
* @return string
* IP address of logged in user.
*/
+ /**
+ * @param bool $strictIPV4
+ *
+ * @return mixed|string
+ */
static function ipAddress($strictIPV4 = TRUE) {
$address = CRM_Utils_Array::value('REMOTE_ADDR', $_SERVER);
return $cache;
}
+ /**
+ * @return bool
+ */
static function isInUpgradeMode() {
$args = explode('/', $_GET['q']);
$upgradeInProcess = CRM_Core_Session::singleton()->get('isUpgradePending');
return FALSE;
}
}
-}
\ No newline at end of file
+}
drupal_set_message($message);
}
+ /**
+ * @return mixed
+ */
function logout() {
module_load_include('inc', 'user', 'user.pages');
return user_logout();
*
*/
class CRM_Utils_SystemLogger extends Psr\Log\AbstractLogger implements \Psr\Log\LoggerInterface {
+ /**
+ * Logs with an arbitrary level.
+ *
+ * @param mixed $level
+ * @param string $message
+ * @param array $context
+ * @return null
+ */
+ /**
+ * @param mixed $level
+ * @param string $message
+ * @param array $context
+ *
+ * @return null
+ */
public function log($level, $message, array $context = array()) {
if(!isset($context['hostname'])) {
$context['hostname'] = CRM_Utils_System::ipAddress();
}
return $tokenHtml;
}
- public static function getHookTokenReplacement(
+
+ /**
+ * @param $token
+ * @param $contact
+ * @param $category
+ * @param bool $html
+ * @param bool $escapeSmarty
+ *
+ * @return mixed|string
+ */public static function getHookTokenReplacement(
$token,
&$contact,
$category,
}
}
+ /**
+ * @param $tokens
+ *
+ * @return array
+ */
static function flattenTokens(&$tokens) {
$flattenTokens = array();
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
+
+/**
+ * Class CRM_Utils_Weight
+ */
class CRM_Utils_Weight {
/**
* @var array, list of GET fields which must be validated
return $resultDAO;
}
+ /**
+ * @param $rows
+ * @param $daoName
+ * @param $idName
+ * @param $returnURL
+ * @param null $filter
+ */
static function addOrder(&$rows, $daoName, $idName, $returnURL, $filter = NULL) {
if (empty($rows)) {
return;
self::fixOrderOutput($url);
}
+ /**
+ * @param $url
+ */
static function fixOrderOutput($url) {
if (empty($_GET['snippet']) || $_GET['snippet'] !== 'json') {
CRM_Utils_System::redirect($url);
return array($xml, $error);
}
+ /**
+ * @param $errors
+ *
+ * @return string
+ */
protected static function formatErrors($errors) {
$messages = array();