*
* @param array|string $values the field value from the API
*/
- public abstract function encodeInput(&$values);
+ abstract public function encodeInput(&$values);
/**
* Decode output.
*
* @return mixed
*/
- public abstract function decodeOutput(&$values);
+ abstract public function decodeOutput(&$values);
/**
* @inheritDoc
'honor_block_text',
'pay_later_text',
'pay_later_receipt',
- 'label', // This is needed for FROM Email Address configuration. dgg
- 'url', // This is needed for navigation items urls
+ // This is needed for FROM Email Address configuration. dgg
+ 'label',
+ // This is needed for navigation items urls
+ 'url',
'details',
- 'msg_text', // message templates’ text versions
- 'text_message', // (send an) email to contact’s and CiviMail’s text version
- 'data', // data i/p of persistent table
- 'sqlQuery', // CRM-6673
+ // message templates’ text versions
+ 'msg_text',
+ // (send an) email to contact’s and CiviMail’s text version
+ 'text_message',
+ // data i/p of persistent table
+ 'data',
+ // CRM-6673
+ 'sqlQuery',
'pcp_title',
'pcp_intro_text',
- 'new', // The 'new' text in word replacements
- 'replyto_email', // e.g. '"Full Name" <user@example.org>'
+ // The 'new' text in word replacements
+ 'new',
+ // e.g. '"Full Name" <user@example.org>'
+ 'replyto_email',
'operator',
- 'content', // CRM-20468
+ // CRM-20468
+ 'content',
];
$custom = CRM_Core_DAO::executeQuery('SELECT id FROM civicrm_custom_field WHERE html_type = "RichTextEditor"');
while ($custom->fetch()) {
if ($isMandatory) {
throw new API_Exception("Failed to match existing record");
}
- return $createParams; // OK, don't care
+ // OK, don't care
+ return $createParams;
}
elseif ($getResult['count'] == 1) {
$item = array_shift($getResult['values']);
*/
class CRM_Utils_Address_BatchUpdate {
- var $start = NULL;
- var $end = NULL;
- var $geocoding = 1;
- var $parse = 1;
- var $throttle = 0;
+ public $start = NULL;
+ public $end = NULL;
+ public $geocoding = 1;
+ public $parse = 1;
+ public $throttle = 0;
- var $returnMessages = [];
- var $returnError = 0;
+ public $returnMessages = [];
+ public $returnError = 0;
/**
* Class constructor.
$this->returnMessages[] = ts("Addresses Evaluated: %1", [
1 => $totalAddresses,
- ]) . "\n";
+ ]) . "\n";
if ($processGeocode) {
$this->returnMessages[] = ts("Addresses Geocoded: %1", [
- 1 => $totalGeocoded,
- ]) . "\n";
+ 1 => $totalGeocoded,
+ ]) . "\n";
}
if ($parseStreetAddress) {
$this->returnMessages[] = ts("Street Addresses Parsed: %1", [
- 1 => $totalAddressParsed,
- ]) . "\n";
+ 1 => $totalAddressParsed,
+ ]) . "\n";
if ($unparseableContactAddress) {
$this->returnMessages[] = "<br />\n" . ts("Following is the list of contacts whose address is not parsed:") . "<br />\n";
foreach ($unparseableContactAddress as $contactLink) {
(count($keys) == 1 &&
(current($keys) > 1 ||
is_string(current($keys)) ||
- (current($keys) == 1 && $array[1] == 1) // handle (0 => 4), (1 => 1)
+ // handle (0 => 4), (1 => 1)
+ (current($keys) == 1 && $array[1] == 1)
)
)
) {
* Ex: 'ArrayCache', 'Memcache', 'Redis'.
*/
public static function getCacheDriver() {
- $className = 'ArrayCache'; // default to ArrayCache for now
+ // default to ArrayCache for now
+ $className = 'ArrayCache';
// Maintain backward compatibility for now.
// Setting CIVICRM_USE_MEMCACHE or CIVICRM_USE_ARRAYCACHE will
*/
class CRM_Utils_Cache_APCcache implements CRM_Utils_Cache_Interface {
- use CRM_Utils_Cache_NaiveMultipleTrait; // TODO Consider native implementation.
- use CRM_Utils_Cache_NaiveHasTrait; // TODO Native implementation
+ // TODO Consider native implementation.
+ use CRM_Utils_Cache_NaiveMultipleTrait;
+ // TODO Native implementation
+ use CRM_Utils_Cache_NaiveHasTrait;
const DEFAULT_TIMEOUT = 3600;
const DEFAULT_PREFIX = '';
public function flush() {
$allinfo = apc_cache_info('user');
$keys = $allinfo['cache_list'];
- $prefix = $this->_prefix; // Our keys follows this pattern: ([A-Za-z0-9_]+)?CRM_[A-Za-z0-9_]+
- $lp = strlen($prefix); // Get prefix length
+ // Our keys follows this pattern: ([A-Za-z0-9_]+)?CRM_[A-Za-z0-9_]+
+ $prefix = $this->_prefix;
+ // Get prefix length
+ $lp = strlen($prefix);
foreach ($keys as $key) {
$name = $key['info'];
class CRM_Utils_Cache_Arraycache implements CRM_Utils_Cache_Interface {
use CRM_Utils_Cache_NaiveMultipleTrait;
- use CRM_Utils_Cache_NaiveHasTrait; // TODO Native implementation
+ // TODO Native implementation
+ use CRM_Utils_Cache_NaiveHasTrait;
const DEFAULT_TIMEOUT = 3600;
/**
* The cache storage container, an in memory array by default
+ * @var array
*/
protected $_cache;
*/
class CRM_Utils_Cache_ArrayDecorator implements CRM_Utils_Cache_Interface {
- use CRM_Utils_Cache_NaiveMultipleTrait; // TODO Consider native implementation.
+ // TODO Consider native implementation.
+ use CRM_Utils_Cache_NaiveMultipleTrait;
/**
* @var int
*/
class CRM_Utils_Cache_FastArrayDecorator implements CRM_Utils_Cache_Interface {
- use CRM_Utils_Cache_NaiveMultipleTrait; // TODO Consider native implementation.
+ // TODO Consider native implementation.
+ use CRM_Utils_Cache_NaiveMultipleTrait;
/**
* @var int
*/
class CRM_Utils_Cache_Memcache implements CRM_Utils_Cache_Interface {
- use CRM_Utils_Cache_NaiveMultipleTrait; // TODO Consider native implementation.
+ // TODO Consider native implementation.
+ use CRM_Utils_Cache_NaiveMultipleTrait;
const DEFAULT_HOST = 'localhost';
const DEFAULT_PORT = 11211;
return ($result !== FALSE);
}
-
/**
* @param $key
*
$value = $this->_cache->get($key);
if ($value === FALSE) {
$value = uniqid();
- $this->_cache->set($key, $value, FALSE, 0); // Indefinite.
+ // Indefinite.
+ $this->_cache->set($key, $value, FALSE, 0);
}
$this->_truePrefix = [
'value' => $value,
*/
class CRM_Utils_Cache_Memcached implements CRM_Utils_Cache_Interface {
- use CRM_Utils_Cache_NaiveMultipleTrait; // TODO Consider native implementation.
+ // TODO Consider native implementation.
+ use CRM_Utils_Cache_NaiveMultipleTrait;
const DEFAULT_HOST = 'localhost';
const DEFAULT_PORT = 11211;
$maxLen = self::MAX_KEY_LEN - strlen($truePrefix);
$key = preg_replace('/\s+|\W+/', '_', $key);
if (strlen($key) > $maxLen) {
- $md5Key = md5($key); // this should be 32 characters in length
+ // this should be 32 characters in length
+ $md5Key = md5($key);
$subKeyLen = $maxLen - 1 - strlen($md5Key);
$key = substr($key, 0, $subKeyLen) . "_" . $md5Key;
}
$value = $this->_cache->get($key);
if ($this->_cache->getResultCode() === Memcached::RES_NOTFOUND) {
$value = uniqid();
- $this->_cache->add($key, $value, 0); // Indefinite.
+ // Indefinite.
+ $this->_cache->add($key, $value, 0);
}
$this->_truePrefix = [
'value' => $value,
}
/**
+ * @param $func
* @param $keys
* @throws \CRM_Utils_Cache_InvalidArgumentException
*/
*/
class CRM_Utils_Cache_NoCache implements CRM_Utils_Cache_Interface {
- use CRM_Utils_Cache_NaiveMultipleTrait; // TODO Consider native implementation.
- use CRM_Utils_Cache_NaiveHasTrait; // TODO Native implementation
+ // TODO Consider native implementation.
+ use CRM_Utils_Cache_NaiveMultipleTrait;
+ // TODO Native implementation
+ use CRM_Utils_Cache_NaiveHasTrait;
/**
* We only need one instance of this object. So we use the singleton
*/
class CRM_Utils_Cache_Redis implements CRM_Utils_Cache_Interface {
- use CRM_Utils_Cache_NaiveMultipleTrait; // TODO Consider native implementation.
- use CRM_Utils_Cache_NaiveHasTrait; // TODO Native implementation
+ // TODO Consider native implementation.
+ use CRM_Utils_Cache_NaiveMultipleTrait;
+ // TODO Native implementation
+ use CRM_Utils_Cache_NaiveHasTrait;
const DEFAULT_HOST = 'localhost';
const DEFAULT_PORT = 6379;
public static function connect($config) {
$host = isset($config['host']) ? $config['host'] : self::DEFAULT_HOST;
$port = isset($config['port']) ? $config['port'] : self::DEFAULT_PORT;
- $pass = CRM_Utils_Constant::value('CIVICRM_DB_CACHE_PASSWORD'); // Ugh.
+ // Ugh.
+ $pass = CRM_Utils_Constant::value('CIVICRM_DB_CACHE_PASSWORD');
$id = implode(':', ['connect', $host, $port /* $pass is constant */]);
if (!isset(Civi::$statics[__CLASS__][$id])) {
// Ideally, we'd track the connection in the service-container, but the
class CRM_Utils_Cache_SerializeCache implements CRM_Utils_Cache_Interface {
use CRM_Utils_Cache_NaiveMultipleTrait;
- use CRM_Utils_Cache_NaiveHasTrait; // TODO Native implementation
+ // TODO Native implementation
+ use CRM_Utils_Cache_NaiveHasTrait;
/**
* The cache storage container, an array by default, stored in a file under templates
+ * @var array
*/
private $_cache;
throw new \RuntimeException("FIXME: " . __CLASS__ . "::set() should support non-NULL TTL");
}
if (file_exists($this->fileName($key))) {
- return FALSE; // WTF, write-once cache?!
+ // WTF, write-once cache?!
+ return FALSE;
}
$this->_cache[$key] = $value;
$bytes = file_put_contents($this->fileName($key), "<?php //" . serialize($value));
public function flush($key = NULL) {
$prefix = "CRM_";
if (!$handle = opendir(CIVICRM_TEMPLATE_COMPILEDIR)) {
- return FALSE; // die? Error?
+ // die? Error?
+ return FALSE;
}
while (FALSE !== ($entry = readdir($handle))) {
if (substr($entry, 0, 4) == $prefix) {
const DEFAULT_TTL = 21600;
const TS_FMT = 'Y-m-d H:i:s';
- use CRM_Utils_Cache_NaiveMultipleTrait; // TODO Consider native implementation.
+ // TODO Consider native implementation.
+ use CRM_Utils_Cache_NaiveMultipleTrait;
/**
* The host name of the memcached server.
protected $group;
/**
- * @var int $componentID The optional component ID (so componenets can share the same name space)
+ * @var int
*/
protected $componentID;
*/
class CRM_Utils_Cache_Tiered implements CRM_Utils_Cache_Interface {
- use CRM_Utils_Cache_NaiveMultipleTrait; // TODO Consider native implementation.
+ // TODO Consider native implementation.
+ use CRM_Utils_Cache_NaiveMultipleTrait;
/**
* @var array
+--------------------------------------------------------------------+
*/
-use GuzzleHttp\Client;
/**
*
/**
* Check if file exists on given URL.
*
- * @param $url
+ * @param string $url
+ * @param int $timeout
* @return bool
* @throws \GuzzleHttp\Exception\GuzzleException
*/
case CRM_Extension_Manager::STATUS_INSTALLED:
if (!empty($remotes[$key]) && version_compare($row['version'], $remotes[$key]->version, '<')) {
$updates[] = ts('%1 (%2) version %3 is installed. <a %4>Upgrade to version %5</a>.', [
- 1 => CRM_Utils_Array::value('label', $row),
- 2 => $key,
- 3 => $row['version'],
- 4 => 'href="' . CRM_Utils_System::url('civicrm/admin/extensions', "action=update&id=$key&key=$key") . '"',
- 5 => $remotes[$key]->version,
- ]);
+ 1 => CRM_Utils_Array::value('label', $row),
+ 2 => $key,
+ 3 => $row['version'],
+ 4 => 'href="' . CRM_Utils_System::url('civicrm/admin/extensions', "action=update&id=$key&key=$key") . '"',
+ 5 => $remotes[$key]->version,
+ ]);
}
else {
if (empty($row['label'])) {
return $messages;
}
-
/**
* Checks if there are pending extension upgrades.
*
$url = CRM_Utils_System::url('civicrm/admin/price/field', [
'reset' => 1,
'action' => 'browse',
- 'sid' => $dao->ps_id]);
+ 'sid' => $dao->ps_id,
+ ]);
$html .= "<tr><td>$dao->ps_title</td><td>$dao->psf_label</td><td><a href='$url'>View Price Set Fields</a></td></tr>";
}
if ($count > 0) {
return $messages;
}
-
/**
* Check that some files are not present.
*
return $messages;
}
-
/**
* Check that the sysadmin has not modified the Cxn
* security setup.
}
}
-
/**
* @param null $timeStamp
*
* @return int
* array $results contains years or months
*/
- static public function calculateAge($birthDate) {
+ public static function calculateAge($birthDate) {
$results = [];
$formatedBirthDate = CRM_Utils_Date::customFormat($birthDate, '%Y-%m-%d');
}
foreach ([
- 'from',
- 'to',
- ] as $item) {
+ 'from',
+ 'to',
+ ] as $item) {
if (!empty($$item)) {
$dateRange[$item] = self::format($$item);
}
return $field;
}
-
/**
* Get the fields required for the 'extra' parameter when adding a datepicker.
*
return $month;
}
-
/**
* Convert a relative date format to an api field.
*
}
foreach ([
- '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;
return civicrm_api3_create_success(TRUE);
}
-
/**
* @deprecated - this is part of the import parser not the API & needs to be moved on out
*
* @endcode
*/
class CRM_Utils_FakeObject {
+
/**
* @param $array
*/
}
}
if (empty($childParts)) {
- return FALSE; // same directory
+ // same directory
+ return FALSE;
}
else {
return TRUE;
*
* @return CRM_Utils_GlobalStack
*/
- static public function singleton() {
+ public static function singleton() {
if (self::$_singleton === NULL) {
self::$_singleton = new CRM_Utils_GlobalStack();
}
const SUMMARY_BELOW = 1;
// place hook content above
const SUMMARY_ABOVE = 2;
- // create your own summaries
+ /**
+ *create your own summaries
+ */
const SUMMARY_REPLACE = 3;
- static $_nullObject = NULL;
+ /**
+ * @var ojbect
+ */
+ public static $_nullObject = NULL;
/**
* We only need one instance of this object. So we use the singleton
*
* @return mixed
*/
- public abstract function invokeViaUF(
+ abstract public function invokeViaUF(
$numParams,
&$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6,
$fnSuffix
'civicrm_triggerInfo'
);
}
+
/**
* This hook allows changes to the spec of which tables to log.
*
}
/**
- * @param CRM_Core_Exception Exception $exception
+ * @param CRM_Core_ExceptionObject $exception
* @param mixed $request
* Reserved for future use.
*/
->invoke(['labelName', 'label', 'format', 'participant'], $labelName, $label, $format, $participant, self::$_nullObject, self::$_nullObject, 'civicrm_alterBadge');
}
-
/**
* This hook is called before encoding data in barcode.
*
}
/**
- * @param array <CRM_Core_FileSearchInterface> $fileSearches
+ * @param array $fileSearches CRM_Core_FileSearchInterface
* @return mixed
*/
public static function fileSearches(&$fileSearches) {
/**
* This hook is called before an inbound SMS is processed.
*
- * @param CRM_SMS_Message Object $message
- * An SMS message recieved
+ * @param \CRM_SMS_MessageObject $message
+ * An SMS message received
* @return mixed
*/
public static function inboundSMS(&$message) {
* This hook is called to modify api params of EntityRef form field
*
* @param array $params
- *
+ * @param string $formName
* @return mixed
*/
public static function alterEntityRefParams(&$params, $formName) {
*
* @return mixed
*/
+
/**
* @param int $numParams
* @param mixed $arg1
*
* @return mixed
*/
+
/**
* @param int $numParams
* @param mixed $arg1
protected $mockObject;
/**
- * @var array $adhocHooks to call
+ * @var array
*/
protected $adhocHooks;
protected $civiModules = NULL;
}
-
/**
* Build the list of plugins ("modules" in CiviCRM terminology) to be processed for hooks.
*
* @copyright CiviCRM LLC (c) 2004-2019
*/
class CRM_Utils_JS {
+
/**
* Parse a javascript file for translatable strings.
*
*/
public 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.', [
- 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>';
+ 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>';
if (is_a($mailer, 'Mail_smtp')) {
$message .= '<ul>' . '<li>' . ts('Your SMTP Username or Password are incorrect.') . '</li>' . '<li>' . ts('Your SMTP Server (machine) name is incorrect.') . '</li>' . '<li>' . ts('You need to use a Port other than the default port 25 in your environment.') . '</li>' . '<li>' . ts('Your SMTP server is just not responding right now (it is down for some reason).') . '</li>';
}
$message .= '<li>' . ts('The FROM Email Address configured for this feature may not be a valid sender based on your email service provider rules.') . '</li>' . '</ul>' . '<p>' . ts('Check <a href="%1">this page</a> for more information.', [
- 1 => CRM_Utils_System::docURL2('user/advanced-configuration/email-system-configuration', TRUE),
- ]) . '</p>';
+ 1 => CRM_Utils_System::docURL2('user/advanced-configuration/email-system-configuration', TRUE),
+ ]) . '</p>';
return $message;
}
// hack for extends_entity_column_value
if ($name == 'extends_entity_column_value') {
if (in_array($object->extends, [
- 'Event',
- 'Activity',
- 'Relationship',
- 'Individual',
- 'Organization',
- 'Household',
- 'Case',
- ])) {
+ 'Event',
+ 'Activity',
+ 'Relationship',
+ 'Individual',
+ 'Organization',
+ 'Household',
+ 'Case',
+ ])) {
if ($object->extends == 'Event') {
$key = 'event_type';
}
$this->appendValue($dao->id, 'civicrm_relationship', $relationship);
$this->addAdditionalContacts([
- $dao->contact_id_a,
- $dao->contact_id_b,
- ],
+ $dao->contact_id_a,
+ $dao->contact_id_b,
+ ],
$additionalContacts
);
}
* @copyright CiviCRM LLC (c) 2004-2019
*/
class CRM_Utils_Migrate_Import {
+
/**
* Class constructor.
*/
* Money utilties
*/
class CRM_Utils_Money {
- static $_currencySymbols = NULL;
+ public static $_currencySymbols = NULL;
/**
* Format a monetary string.
if (!self::$_currencySymbols) {
self::$_currencySymbols = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'currency', [
- 'keyColumn' => 'name',
- 'labelColumn' => 'symbol',
- ]);
+ 'keyColumn' => 'name',
+ 'labelColumn' => 'symbol',
+ ]);
}
if (!$currency) {
* Simple static helpers for network operations
*/
class CRM_Utils_Network {
+
/**
* Try connecting to a TCP service; if it fails, retry. Repeat until serverStartupTimeOut elapses.
*
* Class CRM_Utils_Number
*/
class CRM_Utils_Number {
+
/**
* Create a random number with a given precision.
*
public static function createTruncatedDecimal($keyValue, $precision) {
list ($sigFigs, $decFigs) = $precision;
$sign = ($keyValue < 0) ? '-1' : 1;
- $val = str_replace('.', '', abs($keyValue)); // ex: -123.456 ==> 123456
- $val = substr($val, 0, $sigFigs); // ex: 123456 => 1234
+ // ex: -123.456 ==> 123456
+ $val = str_replace('.', '', abs($keyValue));
+ // ex: 123456 => 1234
+ $val = substr($val, 0, $sigFigs);
// Move any extra digits after decimal
$extraFigs = strlen($val) - ($sigFigs - $decFigs);
if ($extraFigs > 0) {
- return $sign * $val / pow(10, $extraFigs); // ex: 1234 => 1.234
+ // ex: 1234 => 1.234
+ return $sign * $val / pow(10, $extraFigs);
}
else {
return $sign * $val;
// carry some chart params if pass.
foreach ([
- 'xSize',
- 'ySize',
- 'divName',
- ] as $f) {
+ 'xSize',
+ 'ySize',
+ 'divName',
+ ] as $f) {
if (!empty($rows[$f])) {
$chartData[$f] = $rows[$f];
}
// carry some chart params if pass.
foreach ([
- 'xSize',
- 'ySize',
- 'divName',
- ] as $f) {
+ 'xSize',
+ 'ySize',
+ 'divName',
+ ] as $f) {
if (!empty($rows[$f])) {
$chartData[$f] = $rows[$f];
}
$phpWord = \PhpOffice\PhpWord\IOFactory::load($fileName, $formats[$ext]);
}
- \PhpOffice\PhpWord\Settings::setOutputEscapingEnabled(TRUE); //CRM-20015
+ //CRM-20015
+ \PhpOffice\PhpWord\Settings::setOutputEscapingEnabled(TRUE);
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $formats[$ext]);
CRM_Utils_System::setHttpHeader('Content-Type', "application/$ext");
* @param string $type File type
*
* @return array
- * Return extracted content of document in HTML and document type
+ * Return extracted content of document in HTML and document type
*/
public static function docReader($path, $type) {
$type = array_search($type, CRM_Core_SelectValues::documentApplicationType());
// make these properties public due to
// CRM-5880
- // Default label format values
+ /**
+ * Default label format values
+ * @var array
+ */
public $defaults;
- // Current label format values
+ /**
+ * Current label format values
+ * @var array
+ */
public $format;
- // Name of format
+ /**
+ * Name of format
+ * @var string
+ */
public $formatName;
- // Left margin of labels
+ /**
+ * Left margin of labels
+ * @var float
+ */
public $marginLeft;
- // Top margin of labels
+ /**
+ * Top margin of labels
+ * @var float
+ */
public $marginTop;
- // Horizontal space between 2 labels
+ /**
+ * Horizontal space between 2 labels
+ * @var float
+ */
public $xSpace;
- // Vertical space between 2 labels
+ /**
+ * Vertical space between 2 labels
+ * @var float
+ */
public $ySpace;
- // Number of labels horizontally
+ /**
+ * Number of labels horizontally
+ * @var float
+ */
public $xNumber;
- // Number of labels vertically
+ /**
+ * Number of labels vertically
+ * @var float
+ */
public $yNumber;
- // Width of label
+ /**
+ * Width of label
+ * @var float
+ */
public $width;
- // Height of label
+ /**
+ * Height of label
+ * @var float
+ */
public $height;
- // Line Height of label - used in event code
+ /**
+ * Line Height of label - used in event code
+ * @var float
+ */
public $lineHeight = 0;
- // Space between text and left edge of label
+ /**
+ * Space between text and left edge of label
+ * @var float
+ */
public $paddingLeft;
- // Space between text and top edge of label
+ /**
+ * Space between text and top edge of label
+ * @var float
+ */
public $paddingTop;
- // Character size (in points)
+ /**
+ * Character size (in points)
+ * @var float
+ */
public $charSize;
- // Metric used for all PDF doc measurements
+ /**
+ * Metric used for all PDF doc measurements
+ * @var string
+ */
public $metricDoc;
- // Name of the font
+ /**
+ * Name of the font
+ * @var string
+ */
public $fontName;
- // 'B' bold, 'I' italic, 'BI' bold+italic
+ /**
+ * 'B' bold, 'I' italic, 'BI' bold+italic
+ * @var string
+ */
public $fontStyle;
- // Paper size name
+ /**
+ * Paper size name
+ * @var string
+ */
public $paperSize;
- // Paper orientation
+ /**
+ * Paper orientation
+ * @var string
+ */
public $orientation;
- // Paper dimensions array (w, h)
+ /**
+ * Paper dimensions array (w, h)
+ * @var array
+ */
public $paper_dimensions;
- // Counter for positioning labels
+ /**
+ * Counter for positioning labels
+ * @var float
+ */
public $countX = 0;
- // Counter for positioning labels
+ /**
+ * Counter for positioning labels
+ * @var float
+ */
public $countY = 0;
/**
use Dompdf\Dompdf;
use Dompdf\Options;
+
/**
*
* @package CRM
// 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
+ // This library is only in the 'packages' area as of version 4.5
+ require_once 'FPDI/fpdi.php';
$paper_size_arr = [$paper_size[2], $paper_size[3]];
* page variable, but a different form element for one at the bottom.
*/
$this->_response['titleTop'] = ts('Page %1 of %2', [
- 1 => '<input size="2" maxlength="4" name="' . self::PAGE_ID . '" type="text" value="' . $this->_response['currentPage'] . '" />',
- 2 => $this->_response['numPages'],
- ]);
+ 1 => '<input size="2" maxlength="4" name="' . self::PAGE_ID . '" type="text" value="' . $this->_response['currentPage'] . '" />',
+ 2 => $this->_response['numPages'],
+ ]);
$this->_response['titleBottom'] = ts('Page %1 of %2', [
- 1 => '<input size="2" maxlength="4" name="' . self::PAGE_ID_BOTTOM . '" type="text" value="' . $this->_response['currentPage'] . '" />',
- 2 => $this->_response['numPages'],
- ]);
+ 1 => '<input size="2" maxlength="4" name="' . self::PAGE_ID_BOTTOM . '" type="text" value="' . $this->_response['currentPage'] . '" />',
+ 2 => $this->_response['numPages'],
+ ]);
}
/**
class CRM_Utils_PseudoConstant {
/**
* CiviCRM pseudoconstant classes for wrapper functions.
+ * @var array
*/
private static $constantClasses = [
'CRM_Core_PseudoConstant',
*/
const MODE_WILDWORDS_SUFFIX = 'wildwords-suffix';
+ /**
+ * @var \CRM_Utils_QueryFormatter|NULL
+ */
static protected $singleton;
/**
}
/**
- * @param $text
- * @bool $quotes
+ * @param string $text
+ * @param bool $quotes
* @return array
*/
protected function parseWords($text, $quotes) {
/**
* Number of seconds we should let a REST process idle
+ * @var int
*/
- static $rest_timeout = 0;
+ public static $rest_timeout = 0;
/**
* Cache the actual UF Class
+ * @var string
*/
public $ufClass;
CRM_Utils_System::setHttpHeader("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
+ // special treatmenent, because it's often used
+ if (array_key_exists('id', $_GET)) {
+ // an id is always positive
+ $smarty->assign('id', (int) $_GET['id']);
}
$pos = strpos(implode(array_keys($_GET)), '<');
$params['check_permissions'] = TRUE;
$params['version'] = 3;
- $_GET['json'] = $requestParams['json'] = 1; // $requestParams is local-only; this line seems pointless unless there's a side-effect influencing other functions
+ // $requestParams is local-only; this line seems pointless unless there's a side-effect influencing other functions
+ $_GET['json'] = $requestParams['json'] = 1;
if (!$params['sequential']) {
$params['sequential'] = 1;
}
if (!empty($q)) {
if (count($args) == 2 && $args[1] == 'ping') {
CRM_Utils_System::loadBootStrap([], FALSE, FALSE);
- return NULL; // this is pretty wonky but maybe there's some reason I can't see
+ // this is pretty wonky but maybe there's some reason I can't see
+ return NULL;
}
if (count($args) != 3) {
return self::error('ERROR: Malformed REST path');
return self::$_singleton;
}
-
/**
* Check if reCaptcha settings is avilable to add on form.
*/
* @param array $method - '$_GET', '$_POST' or '$_REQUEST'.
*
* @return mixed
- * The value of the variable
+ * The value of the variable
*/
protected static function getValue($name, $method) {
if (isset($method[$name])) {
* @param array $attributes
* The form attributes array.
*
- * @return string $value
+ * @return string
* The desired value.
*/
public static function retrieveComponent($attributes) {
*/
const INTERPOLATE_AUTO = 'auto';
+ /**
+ * @var mixed
+ */
protected $mode = NULL;
+ /**
+ * @var array
+ */
protected $params = [];
- // Public to work-around PHP 5.3 limit.
+ /**
+ * Public to work-around PHP 5.3 limit.
+ * @var bool
+ */
public $strict = NULL;
/**
/**
* Array<string> list of column names
+ * @var array
*/
private $columns;
$row = [];
foreach ((array) $dao as $key => $value) {
if ($value === 'null') {
- $value = NULL; // Blerg!!!
+ // Blerg!!!
+ $value = NULL;
}
// Skip '_foobar' and '{\u00}*_options' and 'N'.
if (preg_match('/[a-zA-Z]/', $key{0}) && $key !== 'N') {
return $this->insertInto($table, $fields);
}
-
/**
* @param array $fields
* The fields to fill in the other table (in order).
const UTF8 = 'DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci';
const CATEGORY_LENGTH = 12;
const CATEGORY_REGEXP = ';^[a-zA-Z0-9]+$;';
- const ID_LENGTH = 37; // MAX{64} - CATEGORY_LENGTH{12} - CONST_LENGHTH{15} = 37
+ // MAX{64} - CATEGORY_LENGTH{12} - CONST_LENGHTH{15} = 37
+ const ID_LENGTH = 37;
const ID_REGEXP = ';^[a-zA-Z0-9_]+$;';
const INNODB = 'ENGINE=InnoDB';
const MEMORY = 'ENGINE=MEMORY';
/**
* @var bool
*/
- protected $durable, $utf8;
+ protected $durable;
+
+ /**
+ * @var bool
+ */
+ protected $utf8;
protected $category;
* Array, fields which should be part of the signature.
*/
public function __construct($secret, $paramNames) {
- sort($paramNames); // ensure consistent serialization of payloads
+ // ensure consistent serialization of payloads
+ sort($paramNames);
$this->secret = $secret;
$this->paramNames = $paramNames;
- $this->signDelim = "_"; // chosen to be valid in URLs but not in salt or md5
+ // chosen to be valid in URLs but not in salt or md5
+ $this->signDelim = "_";
$this->defaultSalt = CRM_Utils_String::createRandom(self::SALT_LEN, CRM_Utils_String::ALPHANUMERIC);
}
/**
* Number of seconds we should let a soap process idle
+ * @var int
*/
- static $soap_timeout = 0;
+ public static $soap_timeout = 0;
/**
* Cache the actual UF Class
+ * @var string
*/
public $ufClass;
return str_replace($search, $replace, $string);
}
-
/**
* Use HTMLPurifier to clean up a text string and remove any potential
* xss attacks. This is primarily used in public facing pages which
*/
class CRM_Utils_System {
- static $_callbacks = NULL;
+ public static $_callbacks = NULL;
/**
* @var string
* Page title
*/
- static $title = '';
+ public static $title = '';
/**
* Access methods in the appropriate CMS class
}
}
- return
- self::url(
+ return self::url(
$path,
CRM_Utils_System::getLinksUrl($urlVar, $includeReset, $includeForce),
$absolute
return $config->userSystem->setMessage($message);
}
-
/**
* Determine whether a value is null-ish.
*
* this function, please go and change the code in the install script as well.
*/
public static function isSSL() {
- return
- (isset($_SERVER['HTTPS']) &&
+ return (isset($_SERVER['HTTPS']) &&
!empty($_SERVER['HTTPS']) &&
strtolower($_SERVER['HTTPS']) != 'off') ? TRUE : FALSE;
}
* The correct method is to have functions on the UF classes for all UF specific
* functions and leave the codebase oblivious to the type of CMS
*
- * @deprecated
* @var bool
+ * @deprecated
* TRUE, if the CMS is Drupal.
*/
- var $is_drupal = FALSE;
+ public $is_drupal = FALSE;
/**
* Deprecated property to check if this is a joomla install. The correct method is to have functions on the UF classes for all UF specific
* functions and leave the codebase oblivious to the type of CMS
*
- * @deprecated
* @var bool
+ * @deprecated
* TRUE, if the CMS is Joomla!.
*/
- var $is_joomla = FALSE;
+ public $is_joomla = FALSE;
/**
* deprecated property to check if this is a wordpress install. The correct method is to have functions on the UF classes for all UF specific
* functions and leave the codebase oblivious to the type of CMS
*
- * @deprecated
* @var bool
+ * @deprecated
* TRUE, if the CMS is WordPress.
*/
- var $is_wordpress = FALSE;
+ public $is_wordpress = FALSE;
/**
* Does this CMS / UF support a CMS specific logging mechanism?
- * @todo - we should think about offering up logging mechanisms in a way that is also extensible by extensions
* @var bool
+ * @todo - we should think about offering up logging mechanisms in a way that is also extensible by extensions
*/
- var $supports_UF_Logging = FALSE;
+ public $supports_UF_Logging = FALSE;
/**
* @var bool
* TRUE, if the CMS allows CMS forms to be extended by hooks.
*/
- var $supports_form_extensions = FALSE;
+ public $supports_form_extensions = FALSE;
public function initialize() {
if (\CRM_Utils_System::isSSL()) {
}
}
- public abstract function loadBootStrap($params = [], $loadUser = TRUE, $throwError = TRUE, $realPath = NULL);
+ abstract public function loadBootStrap($params = [], $loadUser = TRUE, $throwError = TRUE, $realPath = NULL);
/**
* Append an additional breadcrumb tag to the existing breadcrumb.
* @return string
* loginURL for the current CMS
*/
- public abstract function getLoginURL($destination = '');
+ abstract public function getLoginURL($destination = '');
/**
* Get the login destination string.
}
}
-
/**
* Get timezone from CMS.
*
/**
* Does this CMS / UF support a CMS specific logging mechanism?
- * @todo - we should think about offering up logging mechanisms in a way that is also extensible by extensions
* @var bool
+ * @todo - we should think about offering up logging mechanisms in a way that is also extensible by extensions
*/
- var $supports_UF_Logging = TRUE;
+ public $supports_UF_Logging = TRUE;
/**
*/
public function getUserRecordUrl($contactID) {
$uid = CRM_Core_BAO_UFMatch::getUFId($contactID);
if (CRM_Core_Session::singleton()
- ->get('userID') == $contactID || CRM_Core_Permission::checkAnyPerm([
- 'cms:administer users',
- 'cms:view user account',
- ])
+ ->get('userID') == $contactID || CRM_Core_Permission::checkAnyPerm([
+ 'cms:administer users',
+ 'cms:view user account',
+ ])
) {
return $this->url('user/' . $uid);
};
* Joomla specific stuff goes here.
*/
class CRM_Utils_System_Joomla extends CRM_Utils_System_Base {
+
/**
* Class constructor.
*/
global $database;
$query = $db->getQuery(TRUE);
$query->select($db->quoteName('email'))
- ->from($db->quoteName('#__users'))
- ->where($db->quoteName('id') . ' = ' . $user->id);
+ ->from($db->quoteName('#__users'))
+ ->where($db->quoteName('id') . ' = ' . $user->id);
$database->setQuery($query);
$user->email = $database->loadResult();
}
/**
* UF container variables.
+ * @var string
*/
- static $uf = NULL;
- static $ufClass = NULL;
+ public static $uf = NULL;
+ public static $ufClass = NULL;
/**
* Given a permission string, check for access requirements
* Helper authentication class for unit tests
*/
class CRM_Utils_System_UnitTests extends CRM_Utils_System_Base {
+
/**
*/
public function __construct() {
* WordPress specific stuff goes here
*/
class CRM_Utils_System_WordPress extends CRM_Utils_System_Base {
+
/**
*/
public function __construct() {
* Optional credentials
* - name: string, cms username
* - pass: string, cms password
+ * @param bool $loadUser
+ * @param bool $throwError
+ * @param mixed $realPath
*
* @return bool
*/
public function getUserRecordUrl($contactID) {
$uid = CRM_Core_BAO_UFMatch::getUFId($contactID);
if (CRM_Core_Session::singleton()
- ->get('userID') == $contactID || CRM_Core_Permission::checkAnyPerm(['cms:administer users'])
+ ->get('userID') == $contactID || CRM_Core_Permission::checkAnyPerm(['cms:administer users'])
) {
return CRM_Core_Config::singleton()->userFrameworkBaseURL . "wp-admin/user-edit.php?user_id=" . $uid;
}
* @copyright CiviCRM LLC (c) 2004-2019
*/
class CRM_Utils_SystemLogger extends Psr\Log\AbstractLogger implements \Psr\Log\LoggerInterface {
+
/**
* Logs with an arbitrary level.
*
* Class to abstract token replacement.
*/
class CRM_Utils_Token {
- static $_requiredTokens = NULL;
+ public static $_requiredTokens = NULL;
- static $_tokens = [
+ public static $_tokens = [
'action' => [
'forward',
'optOut',
'welcome' => ['group'],
];
-
/**
* @deprecated
* This is used by CiviMail but will be made redundant by FlexMailer.
* The message.
*
* @return bool|array
- * true if all required tokens are found,
+ * true if all required tokens are found,
* else an array of the missing tokens
*/
public static function requiredTokens(&$str) {
* The token variable.
* @param string $value
* The value to substitute for the token.
- * @param string (reference) $str The string to replace in
+ * @param string $str (reference) The string to replace in
*
* @param bool $escapeSmarty
*
// special case for greeting replacement
foreach ([
- 'email_greeting',
- 'postal_greeting',
- 'addressee',
- ] as $val) {
+ 'email_greeting',
+ 'postal_greeting',
+ 'addressee',
+ ] as $val) {
if (!empty($contactDetails[$contactID][$val])) {
$contactDetails[$contactID][$val] = $contactDetails[$contactID]["{$val}_display"];
}
* contactDetails with hooks swapped out
*/
public static function getAnonymousTokenDetails($contactIDs = [
- 0,
- ],
+ 0,
+ ],
$returnProperties = NULL,
$skipOnHold = TRUE,
$skipDeceased = TRUE,
*
* @param string $tokenString
* @param array $contactDetails
+ * @param array $greetingTokens
*/
private static function removeNullContactTokens(&$tokenString, $contactDetails, &$greetingTokens) {
$greetingTokensOriginal = $greetingTokens;
$flattenTokens = [];
foreach ([
- 'html',
- 'text',
- 'subject',
- ] as $prop) {
+ 'html',
+ 'text',
+ 'subject',
+ ] as $prop) {
if (!isset($tokens[$prop])) {
continue;
}
public static function replaceContributionTokens($str, &$contribution, $html = FALSE, $knownTokens = NULL, $escapeSmarty = FALSE) {
$key = 'contribution';
if (!$knownTokens || !CRM_Utils_Array::value($key, $knownTokens)) {
- return $str; //early return
+ //early return
+ return $str;
}
self::_buildContributionTokens();
case 'fee':
try {
$value = civicrm_api3('membership_type', 'getvalue', [
- 'id' => $membership['membership_type_id'],
- 'return' => 'minimum_fee',
- ]);
+ 'id' => $membership['membership_type_id'],
+ 'return' => 'minimum_fee',
+ ]);
$value = CRM_Utils_Money::format($value, NULL, NULL, TRUE);
}
catch (CiviCRM_API3_Exception $e) {
* @param string $entity
* @param bool $usedForTokenWidget
*
- * @return array $customTokens
+ * @return array
* return custom field tokens in array('custom_N' => 'label') format
*/
public static function getCustomFieldTokens($entity, $usedForTokenWidget = FALSE) {
*
* @param string $url
*
- * @return UriInterface
+ * @return \GuzzleHttp\Psr7\UriInterface
*/
public static function parseUrl($url) {
return new Uri($url);
/**
* Unparse url back to a string.
*
- * @param UriInterface $parsed
+ * @param \GuzzleHttp\Psr7\UriInterface $parsed
*
* @return string
*/
* @copyright CiviCRM LLC (c) 2004-2019
*/
class CRM_Utils_Verp {
- /* Mapping of reserved characters to hex codes */
-
- static $encodeMap = [
+ /**
+ * Mapping of reserved characters to hex codes
+ * @var array
+ */
+ public static $encodeMap = [
'+' => '2B',
'@' => '40',
':' => '3A',
']' => '5D',
];
- /* Mapping of hex codes to reserved characters */
-
- static $decodeMap = [
+ /**
+ * Mapping of hex codes to reserved characters
+ * @var array
+ */
+ public static $decodeMap = [
'40' => '@',
'3A' => ':',
'25' => '%',
* To reduce the size of this patch, we only sign the exploitable fields
* which make up "$baseURL" in addOrder() (eg 'filter' or 'dao').
* Less-exploitable fields (eg 'dir') are left unsigned.
+ * 'id','src','dst','dir'
*/
- static $SIGNABLE_FIELDS = ['reset', 'dao', 'idName', 'url', 'filter']; // 'id','src','dst','dir'
+ public static $SIGNABLE_FIELDS = ['reset', 'dao', 'idName', 'url', 'filter'];
/**
* Correct duplicate weight entries by putting them (duplicate weights) in sequence.
* Simple Controller.
*
* The controller which will handle the display and processing of this page.
+ * @var \CRM_Core_Controller_Simple object
*/
protected $_controller;
* (0 => SimpleXMLElement|FALSE, 1 => errorMessage|FALSE)
*/
public static function parseFile($file) {
- $xml = FALSE; // SimpleXMLElement
- $error = FALSE; // string
+ // SimpleXMLElement
+ $xml = FALSE;
+ // string
+ $error = FALSE;
if (!file_exists($file)) {
$error = 'File ' . $file . ' does not exist.';
* (0 => SimpleXMLElement|FALSE, 1 => errorMessage|FALSE)
*/
public static function parseString($string) {
- $xml = FALSE; // SimpleXMLElement
- $error = FALSE; // string
+ // SimpleXMLElement
+ $xml = FALSE;
+ // string
+ $error = FALSE;
$oldLibXMLErrors = libxml_use_internal_errors();
libxml_use_internal_errors(TRUE);
* @return mixed
* FALSE if #root level items !=1; otherwise, the name of base dir
*/
- static public function findBaseDirName(ZipArchive $zip) {
+ public static function findBaseDirName(ZipArchive $zip) {
$cnt = $zip->numFiles;
$base = FALSE;
* @return array(string)
* no trailing /
*/
- static public function findBaseDirs(ZipArchive $zip) {
+ public static function findBaseDirs(ZipArchive $zip) {
$cnt = $zip->numFiles;
$basedirs = [];
* @return string|bool
* Return string or FALSE
*/
- static public function guessBasedir(ZipArchive $zip, $expected) {
+ public static function guessBasedir(ZipArchive $zip, $expected) {
$candidate = FALSE;
$basedirs = CRM_Utils_Zip::findBaseDirs($zip);
if (in_array($expected, $basedirs)) {
}
}
-
/**
* An inefficient helper for creating a ZIP file from data in memory.
* This is only intended for building temp files for unit-testing.
* Array, keys are file names and values are file contents.
* @return bool
*/
- static public function createTestZip($zipName, $dirs, $files) {
+ public static function createTestZip($zipName, $dirs, $files) {
$zip = new ZipArchive();
$res = $zip->open($zipName, ZipArchive::CREATE);
if ($res === TRUE) {