/**
* Class constructor
*/
- function __construct($controller, $action = CRM_Core_Action::NONE) {
+ public function __construct($controller, $action = CRM_Core_Action::NONE) {
parent::__construct($controller, $action);
$this->_pages = array();
* @param int $tableID
* @param int $userID
*/
- static function register(
+ public static function register(
$contactID,
$tableName,
$tableID,
* configuration file and injects them into system wide
* configuration object.
*
- * @param $config
+ * @param CRM_Core_Config $config
* @param $oldMode
- *
- * @return array
- * collection of component settings
*/
public function add($config, $oldMode) {
foreach (get_class_vars(get_class($this)) as $key => $value) {
}
/**
- * TODO
+ * @param array $defaults
*/
public function setDefaults(&$defaults) {
foreach (get_class_vars(get_class($this)) as $key => $value) {
/**
* @param array $params
*
- * @return array
+ * @return array|void
* @throws Exception
*/
public function make_payment(&$params) {
}
public function preProcessCommon() {
- $this->_force =
- CRM_Utils_Request::retrieve(
- 'force',
- 'Boolean',
- CRM_Core_DAO::$_nullObject
- );
+ $this->_force
+ = CRM_Utils_Request::retrieve(
+ 'force',
+ 'Boolean',
+ CRM_Core_DAO::$_nullObject
+ );
- $this->_dashBoardRowCount =
- CRM_Utils_Request::retrieve(
- 'rowCount',
- 'Integer',
- CRM_Core_DAO::$_nullObject
- );
+ $this->_dashBoardRowCount
+ = CRM_Utils_Request::retrieve(
+ 'rowCount',
+ 'Integer',
+ CRM_Core_DAO::$_nullObject
+ );
$this->_section = CRM_Utils_Request::retrieve('section', 'Integer', CRM_Core_DAO::$_nullObject);
}
public function addBreadCrumb() {
- $breadCrumbs =
- array(
+ $breadCrumbs
+ = array(
array(
'title' => ts('Report Templates'),
'url' => CRM_Utils_System::url('civicrm/admin/report/template/list', 'reset=1'),
}
// set alias = table-name, unless already set
- $alias = isset($field['alias']) ? $field['alias'] : (isset($this->_columns[$tableName]['alias']) ?
- $this->_columns[$tableName]['alias'] : $tableName
+ $alias = isset($field['alias']) ? $field['alias'] : (
+ isset($this->_columns[$tableName]['alias']) ? $this->_columns[$tableName]['alias'] : $tableName
);
$this->_columns[$tableName][$fieldGrp][$fieldName]['alias'] = $alias;
// set dbAlias = alias.name, unless already set
if (!isset($this->_columns[$tableName][$fieldGrp][$fieldName]['dbAlias'])) {
- $this->_columns[$tableName][$fieldGrp][$fieldName]['dbAlias'] =
- $alias . '.' .
+ $this->_columns[$tableName][$fieldGrp][$fieldName]['dbAlias']
+ = $alias . '.' .
$this->_columns[$tableName][$fieldGrp][$fieldName]['name'];
}
case CRM_Utils_Type::T_BOOLEAN:
$this->_columns[$tableName][$fieldGrp][$fieldName]['operatorType'] = CRM_Report_Form::OP_SELECT;
if (!array_key_exists('options', $this->_columns[$tableName][$fieldGrp][$fieldName])) {
- $this->_columns[$tableName][$fieldGrp][$fieldName]['options'] =
- array(
+ $this->_columns[$tableName][$fieldGrp][$fieldName]['options']
+ = array(
'' => ts('Any'),
'0' => ts('No'),
'1' => ts('Yes'),
}
}
- /* Add searchable custom fields as order-by options, if so requested
- * (These are already indexed, so allowing to order on them is cheap.)
- */
-
+ // Add searchable custom fields as order-by options, if so requested
+ // (These are already indexed, so allowing to order on them is cheap.)
if ($this->_autoIncludeIndexedFieldsAsOrderBys &&
array_key_exists('extends', $table) && !empty($table['extends'])
if (!empty($options)) {
$options = array(
- '-' => ' - none - ',
- ) + $options;
+ '-' => ' - none - ',
+ ) + $options;
for ($i = 1; $i <= 5; $i++) {
$this->addElement('select', "order_bys[{$i}][column]", ts('Order by Column'), $options);
$this->addElement('select', "order_bys[{$i}][order]", ts('Order by Order'), array(
*
* @return null|string
*/
- function whereClause(
+ public function whereClause(
&$field, $op,
$value, $min, $max
) {
foreach ($value as $key => $selection) {
$value[$key] = CRM_Utils_Type::escape($selection, $type);
}
- $clause =
- "( {$field['dbAlias']} $sqlOP ( '" . implode("' , '", $value) .
+ $clause
+ = "( {$field['dbAlias']} $sqlOP ( '" . implode("' , '", $value) .
"') )";
}
else {
// mhas == multiple has
if ($value !== NULL && count($value) > 0) {
$sqlOP = $this->getSQLOperator($op);
- $clause =
- "{$field['dbAlias']} REGEXP '[[:<:]]" . implode('|', $value) .
+ $clause
+ = "{$field['dbAlias']} REGEXP '[[:<:]]" . implode('|', $value) .
"[[:>:]]'";
}
break;
// mnot == multiple is not one of
if ($value !== NULL && count($value) > 0) {
$sqlOP = $this->getSQLOperator($op);
- $clause =
- "( {$field['dbAlias']} NOT REGEXP '[[:<:]]" . implode('|', $value) .
+ $clause
+ = "( {$field['dbAlias']} NOT REGEXP '[[:<:]]" . implode('|', $value) .
"[[:>:]]' OR {$field['dbAlias']} IS NULL )";
}
break;
*
* @return null|string
*/
- function dateClause(
+ public function dateClause(
$fieldName,
$relative, $from, $to, $type = NULL, $fromTime = NULL, $toTime = NULL
) {
* @param $customField
* @param $fieldValueMap
*
- * @return float|string
+ * @return float|string|void
*/
public function formatCustomValues($value, $customField, $fieldValueMap) {
if (CRM_Utils_System::isNull($value)) {
}
case 'Money':
if ($htmlType == 'Text') {
-
-
$retValue = CRM_Utils_Money::format($value, NULL, '%a');
break;
}
// select() method below has been added recently (v3.3), and many of the report templates might
// still be having their own select() method. We should fix them as and when encountered and move
// towards generalizing the select() method below.
+
+ /**
+ * Generate the SELECT clause and set class variable $_select
+ */
public function select() {
$select = $this->_selectAliases = array();
// for graphs and charts -
if (!empty($this->_params['group_bys_freq'][$fieldName])) {
$this->_interval = $field['title'];
- $this->_columnHeaders["{$tableName}_{$fieldName}_start"]['title'] =
- $field['title'] . ' Beginning';
+ $this->_columnHeaders["{$tableName}_{$fieldName}_start"]['title']
+ = $field['title'] . ' Beginning';
$this->_columnHeaders["{$tableName}_{$fieldName}_start"]['type'] = $field['type'];
$this->_columnHeaders["{$tableName}_{$fieldName}_start"]['group_by'] = $this->_params['group_bys_freq'][$fieldName];
$op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params);
$value = CRM_Utils_Array::value("{$fieldName}_value", $this->_params);
if (is_array($value) && !empty($value)) {
- $clause =
- "(month({$field['dbAlias']}) $op (" . implode(', ', $value) .
+ $clause
+ = "(month({$field['dbAlias']}) $op (" . implode(', ', $value) .
'))';
}
}
CRM_Core_DAO::$_nullObject
);
- $this->_sendmail =
- CRM_Utils_Request::retrieve(
+ $this->_sendmail
+ = CRM_Utils_Request::retrieve(
'sendmail',
'Boolean',
CRM_Core_DAO::$_nullObject
$ifnulls[] = "ifnull($alias, '') as $alias";
}
- /* Group (un-limited) report by all aliases and get counts. This might
- * be done more efficiently when the contents of $sql are known, ie. by
- * overriding this method in the report class.
- */
-
+ // Group (un-limited) report by all aliases and get counts. This might
+ // be done more efficiently when the contents of $sql are known, ie. by
+ // overriding this method in the report class.
$query = "select " . implode(", ", $ifnulls) .
", count(*) as ct from ($sql) as subquery group by " .
CRM_Utils_Array::value('operatorType', $field) !=
CRM_Report_Form::OP_MONTH
) {
- list($from, $to) =
- $this->getFromTo(
+ list($from, $to)
+ = $this->getFromTo(
CRM_Utils_Array::value("{$fieldName}_relative", $this->_params),
CRM_Utils_Array::value("{$fieldName}_from", $this->_params),
CRM_Utils_Array::value("{$fieldName}_to", $this->_params),
$attachments = array();
if ($this->_outputMode == 'csv') {
- $content =
- $this->_formValues['report_header'] . '<p>' . ts('Report URL') .
+ $content
+ = $this->_formValues['report_header'] . '<p>' . ts('Report URL') .
": {$url}</p>" . '<p>' .
ts('The report is attached as a CSV file.') . '</p>' .
$this->_formValues['report_footer'];
)
);
// generate Email Content
- $content =
- $this->_formValues['report_header'] . '<p>' . ts('Report URL') .
+ $content
+ = $this->_formValues['report_header'] . '<p>' . ts('Report URL') .
": {$url}</p>" . '<p>' .
ts('The report is attached as a PDF file.') . '</p>' .
$this->_formValues['report_footer'];
//get chart image name
$chartImg = $this->_chartId . '.png';
//get image url path
- $uploadUrl =
- str_replace('/persist/contribute/', '/persist/', $config->imageUploadURL) .
+ $uploadUrl
+ = str_replace('/persist/contribute/', '/persist/', $config->imageUploadURL) .
'openFlashChart/';
$uploadUrl .= $chartImg;
//get image doc path to overwrite
- $uploadImg =
- str_replace('/persist/contribute/', '/persist/', $config->imageUploadDir) .
+ $uploadImg
+ = str_replace('/persist/contribute/', '/persist/', $config->imageUploadDir) .
'openFlashChart/' . $chartImg;
//Load the image
$chart = imagecreatefrompng($uploadUrl);
* Fetch array of DAO tables having columns included in SELECT or ORDER BY clause
* (building the array if it's unset)
*
- * @return Array
- * >_selectedTables
+ * @return array
+ * selectedTables
*/
public function selectedTables() {
if (!$this->_selectedTables) {
// prepare the directory
$config = CRM_Core_Config::singleton();
- $defaultPath =
- str_replace('/persist/contribute/', '/persist/', $config->imageUploadDir) .
+ $defaultPath
+ = str_replace('/persist/contribute/', '/persist/', $config->imageUploadDir) .
'/openFlashChart/';
if (!file_exists($defaultPath)) {
mkdir($defaultPath, 0777, TRUE);
if (in_array($fieldName, $locationFields)) {
$result['schema'][$fieldName]['civiIsLocation'] = TRUE;
}
- if (in_array($fieldName, array('phone', 'phone_and_ext'))) { // FIXME what about phone_ext?
+ if (in_array($fieldName, array('phone', 'phone_and_ext'))) {
+ // FIXME what about phone_ext?
$result['schema'][$fieldName]['civiIsPhone'] = TRUE;
}
}
*
* @return string
*/
- static function theme(
+ public static function theme(
&$content,
$print = FALSE,
$maintenance = FALSE
* @return string
* An HTML string containing a link to the given path.
*/
- static function url(
+ public static function url(
$path = NULL,
$query = NULL,
$absolute = FALSE,
*
* @return string
*/
- static function href(
+ public static function href(
$text, $path = NULL, $query = NULL, $absolute = TRUE,
$fragment = NULL, $htmlize = TRUE, $frontend = FALSE, $forceBackend = FALSE
) {
* @param string $message
* (optional) The message to provide in the body of the redirect page.
*/
- static function jsRedirect(
+ public static function jsRedirect(
$url = NULL,
$title = NULL,
$message = NULL
* @param bool $output
* @param string $disposition
*/
- static function download(
+ public static function download(
$name, $mimeType, &$buffer,
$ext = NULL,
$output = TRUE,
* @param array $params
* An array of parameters (see CRM_Utils_System::docURL2 method for names)
*
- * @return string
+ * @return string|void
* URL or link to documentation page, based on provided parameters.
*/
public static function docURL($params) {
CRM_ACL_BAO_Cache::resetCache();
// reset various static arrays used here
- CRM_Contact_BAO_Contact::$_importableFields =
- CRM_Contact_BAO_Contact::$_exportableFields =
- CRM_Contribute_BAO_Contribution::$_importableFields =
- CRM_Contribute_BAO_Contribution::$_exportableFields =
- CRM_Pledge_BAO_Pledge::$_exportableFields =
- CRM_Contribute_BAO_Query::$_contributionFields =
- CRM_Core_BAO_CustomField::$_importFields =
- CRM_Core_BAO_Cache::$_cache =
- CRM_Core_DAO::$_dbColumnValueCache = NULL;
+ CRM_Contact_BAO_Contact::$_importableFields
+ = CRM_Contact_BAO_Contact::$_exportableFields
+ = CRM_Contribute_BAO_Contribution::$_importableFields
+ = CRM_Contribute_BAO_Contribution::$_exportableFields
+ = CRM_Pledge_BAO_Pledge::$_exportableFields
+ = CRM_Contribute_BAO_Query::$_contributionFields
+ = CRM_Core_BAO_CustomField::$_importFields
+ = CRM_Core_BAO_Cache::$_cache
+ = CRM_Core_DAO::$_dbColumnValueCache
+ = NULL;
CRM_Core_OptionGroup::flushAll();
CRM_Utils_PseudoConstant::flushAll();
* @return string
* , formatted url.
*/
- static function languageNegotiationURL(
+ public static function languageNegotiationURL(
$url,
$addLanguagePart = TRUE,
$removeLanguagePart = FALSE
* (optional) Sent by contribution/event reg/profile pages which uses a id
* specific extra file name if present.
*/
- static function appendTPLFile(
+ public static function appendTPLFile(
$fileName,
&$content,
$overideFileName = NULL
* Associative array of property name/value pairs to insert in new job.
*
* @return array
+ *
* {@getfields Job_create}
*/
function civicrm_api3_job_create($params) {
/**
* Retrieve one or more job
- * @param array input parameters
+ *
+ * @param array $params
+ * input parameters
* @return array
- * api result array
+ *
* {@getfields email_get}
*/
function civicrm_api3_job_get($params) {
*
* @param array $params
*
- * @return array
- * API Result Array
* {@getfields Job_delete}
*/
function civicrm_api3_job_delete($params) {
* and results are handled in the job log.
*
* @param array $params
- * (reference ) input parameters.
+ * input parameters (unused).
*
* @return array
* API Result Array
* Geocode group of contacts based on given params
*
* @param array $params
- * (reference ) input parameters.
+ * input parameters.
*
* @return array
* API Result Array
function civicrm_api3_job_geocode($params) {
$gc = new CRM_Utils_Address_BatchUpdate($params);
-
$result = $gc->run();
if ($result['is_error'] == 0) {
'type' => CRM_Utils_Type::T_STRING,
);
$params['gt'] = array(
- 'api.required' => 1,
- 'title' => 'Greeting Type',
- 'type' => CRM_Utils_Type::T_STRING,
+ 'api.required' => 1,
+ 'title' => 'Greeting Type',
+ 'type' => CRM_Utils_Type::T_STRING,
);
}
CRM_Utils_Mail_EmailProcessor::processActivities();
$values = array();
$lock->release();
- return civicrm_api3_create_success($values, $params,'mailing','activities');
+ return civicrm_api3_create_success($values, $params, 'mailing', 'activities');
}
catch (Exception $e) {
$lock->release();
* @param array $params
* Input parameters NOT USED.
*
- * @return boolean
+ * @return bool
* true if success, else false
*/
function civicrm_api3_job_process_membership(/** @noinspection PhpUnusedParameterInspection */
* @param array $params
* (reference ) input parameters.
*
- * @return boolean
+ * @return bool
* true if success, else false
*/
function civicrm_api3_job_process_respondent($params) {
* This api cleans up all the old session entries and temp tables. We recommend that sites run this on an hourly basis
*
* @param array $params
- * (reference ) - sends in various config parameters to decide what needs to be cleaned.
- *
- * @return boolean
- * true if success, else false
+ * Sends in various config parameters to decide what needs to be cleaned.
*/
function civicrm_api3_job_cleanup($params) {
- $session = CRM_Utils_Array::value('session', $params, true );
- $tempTable = CRM_Utils_Array::value('tempTables', $params, true );
- $jobLog = CRM_Utils_Array::value('jobLog', $params, true );
- $prevNext = CRM_Utils_Array::value('prevNext', $params, true );
- $dbCache = CRM_Utils_Array::value('dbCache', $params, false);
- $memCache = CRM_Utils_Array::value('memCache', $params, false);
+ $session = CRM_Utils_Array::value('session', $params, TRUE);
+ $tempTable = CRM_Utils_Array::value('tempTables', $params, TRUE);
+ $jobLog = CRM_Utils_Array::value('jobLog', $params, TRUE);
+ $prevNext = CRM_Utils_Array::value('prevNext', $params, TRUE);
+ $dbCache = CRM_Utils_Array::value('dbCache', $params, FALSE);
+ $memCache = CRM_Utils_Array::value('memCache', $params, FALSE);
if ($session || $tempTable || $prevNext) {
CRM_Core_BAO_Cache::cleanup($session, $tempTable, $prevNext);
$limit = CRM_Utils_Array::value('limit', $params, 0);
- CRM_Contact_BAO_GroupContactCache::loadAll(null, $limit);
+ CRM_Contact_BAO_GroupContactCache::loadAll(NULL, $limit);
$lock->release();
return civicrm_api3_create_success();
* @return array
* array of properties,
* if error an array with an error id and error message
+ *
* {@getfields note_get}
*/
function civicrm_api3_note_get($params) {
* String DAO to check for required fields (create functions only).
* @param array $keyoptions
* List of required fields options. One of the options is required.
- *
- * @return null
- * or throws error if there the required fields not present
- * @
*/
function civicrm_api3_verify_one_mandatory($params, $daoName = NULL, $keyoptions = array()) {
$keys = array(array());
* @param array $keys
* List of required fields. A value can be an array denoting that either this or that is required.
* @param bool $verifyDAO
- *
- * @throws API_Exception
- * @return null
- * or throws error if there the required fields not present
- *
- * @todo see notes on _civicrm_api3_check_required_fields regarding removing $daoName param
*/
function civicrm_api3_verify_mandatory($params, $daoName = NULL, $keys = array(), $verifyDAO = TRUE) {
$getCount,
$skipPermissions
);
- if ($getCount) { // only return the count of contacts
+ if ($getCount) {
+ // only return the count of contacts
return $entities;
}
* @param array $params
* @param string $mode
* @param string $entity
- * @return array(CRM_Core_DAO|CRM_Contact_BAO_Query)
+ * @return array
+ * [CRM_Core_DAO|CRM_Contact_BAO_Query]
*/
function _civicrm_api3_get_query_object($params, $mode, $entity) {
- $options = _civicrm_api3_get_options_from_params($params, TRUE, $entity, 'get');
- $sort = CRM_Utils_Array::value('sort', $options, NULL);
- $offset = CRM_Utils_Array::value('offset', $options);
- $rowCount = CRM_Utils_Array::value('limit', $options);
- $inputParams = CRM_Utils_Array::value('input_params', $options, array());
+ $options = _civicrm_api3_get_options_from_params($params, TRUE, $entity, 'get');
+ $sort = CRM_Utils_Array::value('sort', $options, NULL);
+ $offset = CRM_Utils_Array::value('offset', $options);
+ $rowCount = CRM_Utils_Array::value('limit', $options);
+ $inputParams = CRM_Utils_Array::value('input_params', $options, array());
$returnProperties = CRM_Utils_Array::value('return', $options, NULL);
if (empty($returnProperties)) {
$returnProperties = CRM_Contribute_BAO_Query::defaultReturnProperties($mode);
/**
* build fields array. This is the array of fields as it relates to the given DAO
* returns unique fields as keys by default but if set but can return by DB fields
- * @param $bao
+ *
+ * @param CRM_Core_DAO $bao
* @param bool $unique
- * @return
+ *
+ * @return array
*/
function _civicrm_api3_build_fields_array(&$bao, $unique = TRUE) {
$fields = $bao->fields();
/**
* build fields array. This is the array of fields as it relates to the given DAO
* returns unique fields as keys by default but if set but can return by DB fields
+ *
* @param CRM_Core_DAO $bao
*
- * @return mixed
+ * @return array
*/
function _civicrm_api3_get_unique_name_array(&$bao) {
$fields = $bao->fields();
* @param bool $autoFind
*
* @return array
- *
*/
function _civicrm_api3_dao_to_array($dao, $params = NULL, $uniqueFields = TRUE, $entity = "", $autoFind = TRUE) {
$result = array();
* && it can take custom fields & there is the string 'custom' in their return request we get them all, they are filtered on the way out
* @todo filter so only required fields are queried
*
- * @param array $params
* @param string $entity
* Entity name in CamelCase.
+ * @param array $params
*
* @return bool
*/
* @param array $values
* (reference) array.
* @param array|bool $uniqueFields
- *
- * @return array
*/
function _civicrm_api3_object_to_array(&$dao, &$values, $uniqueFields = FALSE) {
_civicrm_api3_validate_date($params, $fieldName, $fieldInfo);
break;
- case 32://blob
+ case 32:
+ //blob
_civicrm_api3_validate_html($params, $fieldName, $fieldInfo);
break;
if (strpos($op, 'NULL') !== FALSE || strpos($op, 'EMPTY') !== FALSE) {
break;
}
- foreach((array)$fieldValue as $fieldvalue) {
+ foreach ((array) $fieldValue as $fieldvalue) {
if (!CRM_Utils_Rule::money($fieldvalue) && !empty($fieldvalue)) {
throw new Exception($fieldName . " is not a valid amount: " . $params[$fieldName]);
}
* @throws \API_Exception
*/
function _civicrm_api3_validate_constraint(&$fieldValue, &$fieldName, &$fieldInfo) {
- $dao = new $fieldInfo['FKClassName'];
+ $daoName = $fieldInfo['FKClassName'];
+ $dao = new $daoName();
$dao->id = $fieldValue;
$dao->selectAdd();
$dao->selectAdd('id');
/**
* Translate the custom field data_type attribute into a std 'type'
* @param $dataType
- * @return
+ * @return int
*/
function _getStandardTypeFromCustomDataType($dataType) {
$mapping = array(
&& $uniqueName
&& $field != $uniqueName
&& array_key_exists($uniqueName, $apiRequest['params'])
- )
- {
+ ) {
$apiRequest['params'][$field] = CRM_Utils_Array::value($values['uniqueName'], $apiRequest['params']);
// note that it would make sense to unset the original field here but tests need to be in place first
}
if (!is_numeric($fieldValue) && is_scalar($fieldValue)) {
$realContactId = _civicrm_api3_resolve_contactID($fieldValue);
if ('unknown-user' === $realContactId) {
- throw new API_Exception("\"$fieldName\" \"{$fieldValue}\" cannot be resolved to a contact ID", 2002, array('error_field' => $fieldName,"type"=>"integer"));
- } elseif (is_numeric($realContactId)) {
+ throw new API_Exception("\"$fieldName\" \"{$fieldValue}\" cannot be resolved to a contact ID", 2002, array('error_field' => $fieldName, "type" => "integer"));
+ }
+ elseif (is_numeric($realContactId)) {
$fieldValue = $realContactId;
}
}
}
// Check our field length
- if(is_string($fieldValue) && !empty($fieldInfo['maxlength']) && strlen($fieldValue) > $fieldInfo['maxlength']
+ if (is_string($fieldValue) && !empty($fieldInfo['maxlength']) && strlen($fieldValue) > $fieldInfo['maxlength']
) {
throw new API_Exception( $fieldValue . " is " . strlen($fieldValue) . " characters - longer than $fieldName length" . $fieldInfo['maxlength'] . ' characters',
- 2100, array('field' => $fieldName, "max_length"=>$fieldInfo['maxlength'])
+ 2100, array('field' => $fieldName, "max_length" => $fieldInfo['maxlength'])
);
}
}
}
if ($fieldValue) {
if (!CRM_Utils_Rule::xssString($fieldValue)) {
- throw new API_Exception('Illegal characters in input (potential scripting attack)', array("field"=>$fieldName,"error_code"=>"xss"));
+ throw new API_Exception('Illegal characters in input (potential scripting attack)', array("field" => $fieldName, "error_code" => "xss"));
}
}
}
/**
* Validate & swap a single option value for a field
*
- * @param string $value: field value
- * @param array $options: array of options for this field
- * @param string $fieldName: field name used in api call (not necessarily the canonical name)
+ * @param string $value field value
+ * @param array $options array of options for this field
+ * @param string $fieldName field name used in api call (not necessarily the canonical name)
* @throws API_Exception
*/
function _civicrm_api3_api_match_pseudoconstant_value(&$value, $options, $fieldName) {
*
* @param array $params
* @param string $fieldName
- * @return string|int|boolean|date|null
+ * @return mixed
*/
function _civicrm_api3_field_value_check(&$params, $fieldName) {
$fieldValue = CRM_Utils_Array::value($fieldName, $params);
global $installType;
$installType = strtolower($_SESSION['civicrm_install_type']);
-if (!in_array($installType, array(
- 'drupal',
- 'wordpress'
-))
-) {
+if (!in_array($installType, array('drupal', 'wordpress'))) {
$errorTitle = "Oops! Unsupported installation mode";
$errorMsg = "";
errorDisplayPage($errorTitle, $errorMsg);
$errorMsg = "Please untar (uncompress) your downloaded copy of CiviCRM in the <strong>" . implode(CIVICRM_DIRECTORY_SEPARATOR, array(
'sites',
'all',
- 'modules'
+ 'modules',
)) . "</strong> directory below your Drupal root directory. Refer to the online " . $docLink . " for more information.";
errorDisplayPage($errorTitle, $errorMsg);
}
$errorMsg = "CiviCRM has already been installed in this Drupal site. <ul><li>To <strong>start over</strong>, you must delete or rename the existing CiviCRM settings file - <strong>civicrm.settings.php</strong> - from <strong>" . implode(CIVICRM_DIRECTORY_SEPARATOR, array(
'[your Drupal root directory]',
'sites',
- $siteDir
+ $siteDir,
)) . "</strong>.</li><li>To <strong>upgrade an existing installation</strong>, refer to the online " . $docLink . ".</li></ul>";
}
elseif ($installType == 'wordpress') {
* @param $databaseConfig
* @param $dbName
*/
- function checkdatabase($databaseConfig, $dbName) {
+ public function checkdatabase($databaseConfig, $dbName) {
if ($this->requireFunction('mysql_connect',
array(
"PHP Configuration",
/**
* Check everything except the database
*/
- function check() {
+ public function check() {
global $crmPath, $installType;
$this->errors = NULL;
"PHP Configuration",
"PHP5 installed",
NULL,
- "PHP version " . phpversion()
+ "PHP version " . phpversion(),
));
// Check that we can identify the root folder successfully
array(
"File permissions",
"$dir folder exists",
- "There is no $dir folder"
+ "There is no $dir folder",
), TRUE
);
}
$this->requireServerVariables(array('SCRIPT_NAME', 'HTTP_HOST', 'SCRIPT_FILENAME'), array(
"Webserver config",
"Recognised webserver",
- "You seem to be using an unsupported webserver. The server variables SCRIPT_NAME, HTTP_HOST, SCRIPT_FILENAME need to be set."
+ "You seem to be using an unsupported webserver. The server variables SCRIPT_NAME, HTTP_HOST, SCRIPT_FILENAME need to be set.",
));
// Check for MySQL support
* @param $recommended
* @param $testDetails
*/
- function requireMemory($min, $recommended, $testDetails) {
+ public function requireMemory($min, $recommended, $testDetails) {
$this->testing($testDetails);
$mem = $this->getPHPMemory();
/**
* @return float
*/
- function getPHPMemory() {
+ public function getPHPMemory() {
$memString = ini_get("memory_limit");
switch (strtolower(substr($memString, -1))) {
}
}
- function listErrors() {
+ public function listErrors() {
if ($this->errors) {
echo "<p>The following problems are preventing me from installing CiviCRM:</p>";
foreach ($this->errors as $error) {
/**
* @param null $section
*/
- function showTable($section = NULL) {
+ public function showTable($section = NULL) {
if ($section) {
$tests = $this->tests[$section];
echo "<table class=\"testResults\" width=\"100%\">";
*
* @return bool
*/
- function requireFunction($funcName, $testDetails) {
+ public function requireFunction($funcName, $testDetails) {
$this->testing($testDetails);
if (!function_exists($funcName)) {
/**
* @param $testDetails
*/
- function checkXCache($testDetails) {
+ public function checkXCache($testDetails) {
if (function_exists('xcache_isset') &&
ini_get('xcache.size') > 0
) {
* @param $testDetails
* @param null $maxVersion
*/
- function requirePHPVersion($minVersion, $testDetails, $maxVersion = NULL) {
+ public function requirePHPVersion($minVersion, $testDetails, $maxVersion = NULL) {
$this->testing($testDetails);
* @param $testDetails
* @param bool $absolute
*/
- function requireFile($filename, $testDetails, $absolute = FALSE) {
+ public function requireFile($filename, $testDetails, $absolute = FALSE) {
$this->testing($testDetails);
if (!$absolute) {
$filename = $this->getBaseDir() . $filename;
/**
* @param $testDetails
*/
- function requireNoPathSeparator($testDetails) {
+ public function requireNoPathSeparator($testDetails) {
$this->testing($testDetails);
if (substr_count($this->getBaseDir(), PATH_SEPARATOR)) {
$this->error($testDetails);
* @param string $filename
* @param $testDetails
*/
- function requireNoFile($filename, $testDetails) {
+ public function requireNoFile($filename, $testDetails) {
$this->testing($testDetails);
$filename = $this->getBaseDir() . $filename;
if (file_exists($filename)) {
* @param string $filename
* @param $testDetails
*/
- function moveFileOutOfTheWay($filename, $testDetails) {
+ public function moveFileOutOfTheWay($filename, $testDetails) {
$this->testing($testDetails);
$filename = $this->getBaseDir() . $filename;
if (file_exists($filename)) {
* @param $testDetails
* @param bool $absolute
*/
- function requireWriteable($filename, $testDetails, $absolute = FALSE) {
+ public function requireWriteable($filename, $testDetails, $absolute = FALSE) {
$this->testing($testDetails);
if (!$absolute) {
$filename = $this->getBaseDir() . $filename;
* @param string $moduleName
* @param $testDetails
*/
- function requireApacheModule($moduleName, $testDetails) {
+ public function requireApacheModule($moduleName, $testDetails) {
$this->testing($testDetails);
if (!in_array($moduleName, apache_get_modules())) {
$this->error($testDetails);
* @param $password
* @param $testDetails
*/
- function requireMysqlConnection($server, $username, $password, $testDetails) {
+ public function requireMysqlConnection($server, $username, $password, $testDetails) {
$this->testing($testDetails);
$conn = @mysql_connect($server, $username, $password);
* @param $server
* @param $testDetails
*/
- function requireMySQLServer($server, $testDetails) {
+ public function requireMySQLServer($server, $testDetails) {
$this->testing($testDetails);
$conn = @mysql_connect($server, NULL, NULL);
* @param $version
* @param $testDetails
*/
- function requireMySQLVersion($version, $testDetails) {
+ public function requireMySQLVersion($version, $testDetails) {
$this->testing($testDetails);
if (!mysql_get_server_info()) {
* @param $database
* @param $testDetails
*/
- function requireMySQLInnoDB($server, $username, $password, $database, $testDetails) {
+ public function requireMySQLInnoDB($server, $username, $password, $database, $testDetails) {
$this->testing($testDetails);
$conn = @mysql_connect($server, $username, $password);
if (!$conn) {
* @param $database
* @param $testDetails
*/
- function requireMySQLTempTables($server, $username, $password, $database, $testDetails) {
+ public function requireMySQLTempTables($server, $username, $password, $database, $testDetails) {
$this->testing($testDetails);
$conn = @mysql_connect($server, $username, $password);
if (!$conn) {
* @param $database
* @param $testDetails
*/
- function requireMySQLTrigger($server, $username, $password, $database, $testDetails) {
+ public function requireMySQLTrigger($server, $username, $password, $database, $testDetails) {
$this->testing($testDetails);
$conn = @mysql_connect($server, $username, $password);
if (!$conn) {
* @param $database
* @param $testDetails
*/
- function requireMySQLLockTables($server, $username, $password, $database, $testDetails) {
+ public function requireMySQLLockTables($server, $username, $password, $database, $testDetails) {
$this->testing($testDetails);
$conn = @mysql_connect($server, $username, $password);
if (!$conn) {
}
$result = mysql_query('DROP TEMPORARY TABLE civicrm_install_temp_table_test');
- return;
}
/**
* @param $password
* @param $testDetails
*/
- function requireMySQLAutoIncrementIncrementOne($server, $username, $password, $testDetails) {
+ public function requireMySQLAutoIncrementIncrementOne($server, $username, $password, $testDetails) {
$this->testing($testDetails);
$conn = @mysql_connect($server, $username, $password);
if (!$conn) {
* @param $minValueKB
* @param $testDetails
*/
- function requireMySQLThreadStack($server, $username, $password, $database, $minValueKB, $testDetails) {
+ public function requireMySQLThreadStack($server, $username, $password, $database, $minValueKB, $testDetails) {
$this->testing($testDetails);
$conn = @mysql_connect($server, $username, $password);
if (!$conn) {
* @param $testDetails
* @param bool $onlyRequire
*/
- function requireDatabaseOrCreatePermissions(
+ public function requireDatabaseOrCreatePermissions(
$server,
$username,
$password,
* @param $varNames
* @param $errorMessage
*/
- function requireServerVariables($varNames, $errorMessage) {
+ public function requireServerVariables($varNames, $errorMessage) {
//$this->testing($testDetails);
foreach ($varNames as $varName) {
if (!$_SERVER[$varName]) {
*
* @return bool
*/
- function isRunningApache($testDetails) {
+ public function isRunningApache($testDetails) {
$this->testing($testDetails);
if (function_exists('apache_get_modules') || stristr($_SERVER['SERVER_SIGNATURE'], 'Apache')) {
return TRUE;
/**
* @return string
*/
- function getBaseDir() {
+ public function getBaseDir() {
return dirname($_SERVER['SCRIPT_FILENAME']) . CIVICRM_DIRECTORY_SEPARATOR;
}
/**
* @param $testDetails
*/
- function testing($testDetails) {
+ public function testing($testDetails) {
if (!$testDetails) {
return;
}
/**
* @param $testDetails
*/
- function error($testDetails) {
+ public function error($testDetails) {
$section = $testDetails[0];
$test = $testDetails[1];
/**
* @param $testDetails
*/
- function warning($testDetails) {
+ public function warning($testDetails) {
$section = $testDetails[0];
$test = $testDetails[1];
/**
* @return int
*/
- function hasErrors() {
- return sizeof($this->errors);
+ public function hasErrors() {
+ return count($this->errors);
}
/**
* @return int
*/
- function hasWarnings() {
- return sizeof($this->warnings);
+ public function hasWarnings() {
+ return count($this->warnings);
}
}
* @param $password
* @param $database
*/
- function createDatabaseIfNotExists($server, $username, $password, $database) {
+ public function createDatabaseIfNotExists($server, $username, $password, $database) {
$conn = @mysql_connect($server, $username, $password);
if (@mysql_select_db($database)) {
*
* @return mixed
*/
- function install($config) {
+ public function install($config) {
global $installDirPath;
// create database if does not exists
foreach (array_diff($perms, $allPerms) as $perm) {
watchdog('civicrm',
'Cannot grant the %perm permission because it does not yet exist.',
- array(
- '%perm' => $perm
- ), WATCHDOG_ERROR
+ array('%perm' => $perm),
+ WATCHDOG_ERROR
);
}
$perms = array_intersect($perms, $allPerms);