From 971d41b1c4889952bbd7bae9360a72d410e13640 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Tue, 13 Jan 2015 14:12:40 -0500 Subject: [PATCH] INFRA-132 - Batch #1 --- CRM/Contribute/StateMachine/Search.php | 2 +- CRM/Core/BAO/Log.php | 2 +- CRM/Core/Component/Config.php | 7 +- CRM/Event/Cart/Form/Checkout/Payment.php | 2 +- CRM/Report/Form.php | 122 +++++++++++------------ CRM/UF/Page/ProfileEditor.php | 3 +- CRM/Utils/System.php | 35 +++---- api/v3/Job.php | 45 ++++----- api/v3/Note.php | 1 + api/v3/utils.php | 72 ++++++------- install/index.php | 96 +++++++++--------- 11 files changed, 185 insertions(+), 202 deletions(-) diff --git a/CRM/Contribute/StateMachine/Search.php b/CRM/Contribute/StateMachine/Search.php index 7c752e0103..84c75a82fd 100644 --- a/CRM/Contribute/StateMachine/Search.php +++ b/CRM/Contribute/StateMachine/Search.php @@ -44,7 +44,7 @@ class CRM_Contribute_StateMachine_Search extends CRM_Core_StateMachine { /** * 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(); diff --git a/CRM/Core/BAO/Log.php b/CRM/Core/BAO/Log.php index c7b29965a8..12859cfd4a 100644 --- a/CRM/Core/BAO/Log.php +++ b/CRM/Core/BAO/Log.php @@ -86,7 +86,7 @@ class CRM_Core_BAO_Log extends CRM_Core_DAO_Log { * @param int $tableID * @param int $userID */ - static function register( + public static function register( $contactID, $tableName, $tableID, diff --git a/CRM/Core/Component/Config.php b/CRM/Core/Component/Config.php index 2833538d5c..0e59999935 100644 --- a/CRM/Core/Component/Config.php +++ b/CRM/Core/Component/Config.php @@ -41,11 +41,8 @@ abstract class CRM_Core_Component_Config { * 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) { @@ -54,7 +51,7 @@ abstract class CRM_Core_Component_Config { } /** - * TODO + * @param array $defaults */ public function setDefaults(&$defaults) { foreach (get_class_vars(get_class($this)) as $key => $value) { diff --git a/CRM/Event/Cart/Form/Checkout/Payment.php b/CRM/Event/Cart/Form/Checkout/Payment.php index 38b7b9c7b2..9933061ad8 100644 --- a/CRM/Event/Cart/Form/Checkout/Payment.php +++ b/CRM/Event/Cart/Form/Checkout/Payment.php @@ -561,7 +561,7 @@ class CRM_Event_Cart_Form_Checkout_Payment extends CRM_Event_Cart_Form_Cart { /** * @param array $params * - * @return array + * @return array|void * @throws Exception */ public function make_payment(&$params) { diff --git a/CRM/Report/Form.php b/CRM/Report/Form.php index 6f66ecfc7b..70e7485da9 100644 --- a/CRM/Report/Form.php +++ b/CRM/Report/Form.php @@ -356,19 +356,19 @@ class CRM_Report_Form extends CRM_Core_Form { } 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); @@ -481,8 +481,8 @@ class CRM_Report_Form extends CRM_Core_Form { } public function addBreadCrumb() { - $breadCrumbs = - array( + $breadCrumbs + = array( array( 'title' => ts('Report Templates'), 'url' => CRM_Utils_System::url('civicrm/admin/report/template/list', 'reset=1'), @@ -566,8 +566,8 @@ class CRM_Report_Form extends CRM_Core_Form { } // 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; @@ -578,8 +578,8 @@ class CRM_Report_Form extends CRM_Core_Form { // 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']; } @@ -604,8 +604,8 @@ class CRM_Report_Form extends CRM_Core_Form { 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'), @@ -1104,10 +1104,8 @@ class CRM_Report_Form extends CRM_Core_Form { } } - /* 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']) @@ -1126,8 +1124,8 @@ class CRM_Report_Form extends CRM_Core_Form { 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( @@ -1418,7 +1416,7 @@ class CRM_Report_Form extends CRM_Core_Form { * * @return null|string */ - function whereClause( + public function whereClause( &$field, $op, $value, $min, $max ) { @@ -1492,8 +1490,8 @@ class CRM_Report_Form extends CRM_Core_Form { 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 { @@ -1514,8 +1512,8 @@ class CRM_Report_Form extends CRM_Core_Form { // 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; @@ -1524,8 +1522,8 @@ class CRM_Report_Form extends CRM_Core_Form { // 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; @@ -1604,7 +1602,7 @@ class CRM_Report_Form extends CRM_Core_Form { * * @return null|string */ - function dateClause( + public function dateClause( $fieldName, $relative, $from, $to, $type = NULL, $fromTime = NULL, $toTime = NULL ) { @@ -1774,7 +1772,7 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND * @param $customField * @param $fieldValueMap * - * @return float|string + * @return float|string|void */ public function formatCustomValues($value, $customField, $fieldValueMap) { if (CRM_Utils_System::isNull($value)) { @@ -1812,8 +1810,6 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND } case 'Money': if ($htmlType == 'Text') { - - $retValue = CRM_Utils_Money::format($value, NULL, '%a'); break; } @@ -2025,6 +2021,10 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND // 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(); @@ -2165,8 +2165,8 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND // 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]; @@ -2241,8 +2241,8 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND $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) . '))'; } } @@ -2290,8 +2290,8 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND CRM_Core_DAO::$_nullObject ); - $this->_sendmail = - CRM_Utils_Request::retrieve( + $this->_sendmail + = CRM_Utils_Request::retrieve( 'sendmail', 'Boolean', CRM_Core_DAO::$_nullObject @@ -2586,11 +2586,9 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND $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 " . @@ -2717,8 +2715,8 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND 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), @@ -2833,8 +2831,8 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND $attachments = array(); if ($this->_outputMode == 'csv') { - $content = - $this->_formValues['report_header'] . '

' . ts('Report URL') . + $content + = $this->_formValues['report_header'] . '

' . ts('Report URL') . ": {$url}

" . '

' . ts('The report is attached as a CSV file.') . '

' . $this->_formValues['report_footer']; @@ -2859,8 +2857,8 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND ) ); // generate Email Content - $content = - $this->_formValues['report_header'] . '

' . ts('Report URL') . + $content + = $this->_formValues['report_header'] . '

' . ts('Report URL') . ": {$url}

" . '

' . ts('The report is attached as a PDF file.') . '

' . $this->_formValues['report_footer']; @@ -2892,13 +2890,13 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND //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); @@ -3548,8 +3546,8 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a * 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) { @@ -3980,8 +3978,8 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a // 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); diff --git a/CRM/UF/Page/ProfileEditor.php b/CRM/UF/Page/ProfileEditor.php index db9c0592a5..0e5a84782b 100644 --- a/CRM/UF/Page/ProfileEditor.php +++ b/CRM/UF/Page/ProfileEditor.php @@ -229,7 +229,8 @@ class CRM_UF_Page_ProfileEditor extends CRM_Core_Page { 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; } } diff --git a/CRM/Utils/System.php b/CRM/Utils/System.php index d8c637c2e6..353d59351c 100644 --- a/CRM/Utils/System.php +++ b/CRM/Utils/System.php @@ -183,7 +183,7 @@ class CRM_Utils_System { * * @return string */ - static function theme( + public static function theme( &$content, $print = FALSE, $maintenance = FALSE @@ -229,7 +229,7 @@ class CRM_Utils_System { * @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, @@ -261,7 +261,7 @@ class CRM_Utils_System { * * @return string */ - static function href( + public static function href( $text, $path = NULL, $query = NULL, $absolute = TRUE, $fragment = NULL, $htmlize = TRUE, $frontend = FALSE, $forceBackend = FALSE ) { @@ -427,7 +427,7 @@ class CRM_Utils_System { * @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 @@ -799,7 +799,7 @@ class CRM_Utils_System { * @param bool $output * @param string $disposition */ - static function download( + public static function download( $name, $mimeType, &$buffer, $ext = NULL, $output = TRUE, @@ -1300,7 +1300,7 @@ class CRM_Utils_System { * @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) { @@ -1464,15 +1464,16 @@ class CRM_Utils_System { 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(); @@ -1642,7 +1643,7 @@ class CRM_Utils_System { * @return string * , formatted url. */ - static function languageNegotiationURL( + public static function languageNegotiationURL( $url, $addLanguagePart = TRUE, $removeLanguagePart = FALSE @@ -1664,7 +1665,7 @@ class CRM_Utils_System { * (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 diff --git a/api/v3/Job.php b/api/v3/Job.php index 32acc25fee..af6c14f63c 100644 --- a/api/v3/Job.php +++ b/api/v3/Job.php @@ -62,6 +62,7 @@ function _civicrm_api3_job_create_spec(&$params) { * Associative array of property name/value pairs to insert in new job. * * @return array + * * {@getfields Job_create} */ function civicrm_api3_job_create($params) { @@ -70,9 +71,11 @@ 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) { @@ -84,8 +87,6 @@ function civicrm_api3_job_get($params) { * * @param array $params * - * @return array - * API Result Array * {@getfields Job_delete} */ function civicrm_api3_job_delete($params) { @@ -97,7 +98,7 @@ 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 @@ -124,7 +125,7 @@ function _civicrm_api3_job_execute_spec(&$params) { * Geocode group of contacts based on given params * * @param array $params - * (reference ) input parameters. + * input parameters. * * @return array * API Result Array @@ -132,7 +133,6 @@ function _civicrm_api3_job_execute_spec(&$params) { function civicrm_api3_job_geocode($params) { $gc = new CRM_Utils_Address_BatchUpdate($params); - $result = $gc->run(); if ($result['is_error'] == 0) { @@ -269,9 +269,9 @@ function _civicrm_api3_job_update_greeting_spec(&$params) { '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, ); } @@ -370,7 +370,7 @@ function civicrm_api3_job_fetch_activities($params) { 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(); @@ -409,7 +409,7 @@ function civicrm_api3_job_process_participant($params) { * @param array $params * Input parameters NOT USED. * - * @return boolean + * @return bool * true if success, else false */ function civicrm_api3_job_process_membership(/** @noinspection PhpUnusedParameterInspection */ @@ -436,7 +436,7 @@ function civicrm_api3_job_process_membership(/** @noinspection PhpUnusedParamete * @param array $params * (reference ) input parameters. * - * @return boolean + * @return bool * true if success, else false */ function civicrm_api3_job_process_respondent($params) { @@ -542,18 +542,15 @@ function civicrm_api3_job_run_payment_cron($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); @@ -605,7 +602,7 @@ function civicrm_api3_job_group_rebuild($params) { $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(); diff --git a/api/v3/Note.php b/api/v3/Note.php index 82542c550f..834cbc21e5 100644 --- a/api/v3/Note.php +++ b/api/v3/Note.php @@ -93,6 +93,7 @@ function civicrm_api3_note_delete($params) { * @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) { diff --git a/api/v3/utils.php b/api/v3/utils.php index 7deeab9744..0e04b694b7 100644 --- a/api/v3/utils.php +++ b/api/v3/utils.php @@ -54,10 +54,6 @@ function _civicrm_api3_initialize() { * 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()); @@ -77,12 +73,6 @@ function civicrm_api3_verify_one_mandatory($params, $daoName = NULL, $keyoptions * @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) { @@ -527,7 +517,8 @@ function _civicrm_api3_get_using_query_object($entity, $params, $additional_opti $getCount, $skipPermissions ); - if ($getCount) { // only return the count of contacts + if ($getCount) { + // only return the count of contacts return $entities; } @@ -542,14 +533,15 @@ function _civicrm_api3_get_using_query_object($entity, $params, $additional_opti * @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); @@ -824,9 +816,11 @@ function _civicrm_api3_apply_options_to_dao(&$params, &$dao, $entity) { /** * 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(); @@ -848,9 +842,10 @@ function _civicrm_api3_build_fields_array(&$bao, $unique = TRUE) { /** * 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(); @@ -871,7 +866,6 @@ function _civicrm_api3_get_unique_name_array(&$bao) { * @param bool $autoFind * * @return array - * */ function _civicrm_api3_dao_to_array($dao, $params = NULL, $uniqueFields = TRUE, $entity = "", $autoFind = TRUE) { $result = array(); @@ -916,9 +910,9 @@ function _civicrm_api3_dao_to_array($dao, $params = NULL, $uniqueFields = TRUE, * && 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 */ @@ -941,8 +935,6 @@ function _civicrm_api3_custom_fields_are_required($entity, $params) { * @param array $values * (reference) array. * @param array|bool $uniqueFields - * - * @return array */ function _civicrm_api3_object_to_array(&$dao, &$values, $uniqueFields = FALSE) { @@ -1413,7 +1405,8 @@ function _civicrm_api3_validate_fields($entity, $action, &$params, $fields, $err _civicrm_api3_validate_date($params, $fieldName, $fieldInfo); break; - case 32://blob + case 32: + //blob _civicrm_api3_validate_html($params, $fieldName, $fieldInfo); break; @@ -1426,7 +1419,7 @@ function _civicrm_api3_validate_fields($entity, $action, &$params, $fields, $err 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]); } @@ -1527,7 +1520,8 @@ function _civicrm_api3_getValidDate($dateValue, $fieldName, $fieldType) { * @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'); @@ -1746,7 +1740,7 @@ function _civicrm_api_get_custom_fields($entity, &$params) { /** * Translate the custom field data_type attribute into a std 'type' * @param $dataType - * @return + * @return int */ function _getStandardTypeFromCustomDataType($dataType) { $mapping = array( @@ -1801,8 +1795,7 @@ function _civicrm_api3_swap_out_aliases(&$apiRequest, $fields) { && $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 } @@ -1834,8 +1827,9 @@ function _civicrm_api3_validate_integer(&$params, &$fieldName, &$fieldInfo, $ent 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; } } @@ -1851,10 +1845,10 @@ function _civicrm_api3_validate_integer(&$params, &$fieldName, &$fieldInfo, $ent } // 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']) ); } } @@ -1912,7 +1906,7 @@ function _civicrm_api3_validate_html(&$params, &$fieldName, $fieldInfo) { } 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")); } } } @@ -2023,9 +2017,9 @@ function _civicrm_api3_api_match_pseudoconstant(&$fieldValue, $entity, $fieldNam /** * 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) { @@ -2116,7 +2110,7 @@ function _civicrm_api3_deprecation_check($entity, $result = array()) { * * @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); diff --git a/install/index.php b/install/index.php index 5bec5dc5d7..42ad1d61f9 100644 --- a/install/index.php +++ b/install/index.php @@ -50,11 +50,7 @@ else { 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); @@ -93,7 +89,7 @@ if ($installType == 'drupal') { $errorMsg = "Please untar (uncompress) your downloaded copy of CiviCRM in the " . implode(CIVICRM_DIRECTORY_SEPARATOR, array( 'sites', 'all', - 'modules' + 'modules', )) . " directory below your Drupal root directory. Refer to the online " . $docLink . " for more information."; errorDisplayPage($errorTitle, $errorMsg); } @@ -175,7 +171,7 @@ if ($alreadyInstalled) { $errorMsg = "CiviCRM has already been installed in this Drupal site. "; } elseif ($installType == 'wordpress') { @@ -286,7 +282,7 @@ class InstallRequirements { * @param $databaseConfig * @param $dbName */ - function checkdatabase($databaseConfig, $dbName) { + public function checkdatabase($databaseConfig, $dbName) { if ($this->requireFunction('mysql_connect', array( "PHP Configuration", @@ -404,7 +400,7 @@ class InstallRequirements { /** * Check everything except the database */ - function check() { + public function check() { global $crmPath, $installType; $this->errors = NULL; @@ -413,7 +409,7 @@ class InstallRequirements { "PHP Configuration", "PHP5 installed", NULL, - "PHP version " . phpversion() + "PHP version " . phpversion(), )); // Check that we can identify the root folder successfully @@ -443,7 +439,7 @@ class InstallRequirements { array( "File permissions", "$dir folder exists", - "There is no $dir folder" + "There is no $dir folder", ), TRUE ); } @@ -503,7 +499,7 @@ class InstallRequirements { $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 @@ -542,7 +538,7 @@ class InstallRequirements { * @param $recommended * @param $testDetails */ - function requireMemory($min, $recommended, $testDetails) { + public function requireMemory($min, $recommended, $testDetails) { $this->testing($testDetails); $mem = $this->getPHPMemory(); @@ -563,7 +559,7 @@ class InstallRequirements { /** * @return float */ - function getPHPMemory() { + public function getPHPMemory() { $memString = ini_get("memory_limit"); switch (strtolower(substr($memString, -1))) { @@ -581,7 +577,7 @@ class InstallRequirements { } } - function listErrors() { + public function listErrors() { if ($this->errors) { echo "

The following problems are preventing me from installing CiviCRM:

"; foreach ($this->errors as $error) { @@ -593,7 +589,7 @@ class InstallRequirements { /** * @param null $section */ - function showTable($section = NULL) { + public function showTable($section = NULL) { if ($section) { $tests = $this->tests[$section]; echo ""; @@ -621,7 +617,7 @@ class InstallRequirements { * * @return bool */ - function requireFunction($funcName, $testDetails) { + public function requireFunction($funcName, $testDetails) { $this->testing($testDetails); if (!function_exists($funcName)) { @@ -636,7 +632,7 @@ class InstallRequirements { /** * @param $testDetails */ - function checkXCache($testDetails) { + public function checkXCache($testDetails) { if (function_exists('xcache_isset') && ini_get('xcache.size') > 0 ) { @@ -650,7 +646,7 @@ class InstallRequirements { * @param $testDetails * @param null $maxVersion */ - function requirePHPVersion($minVersion, $testDetails, $maxVersion = NULL) { + public function requirePHPVersion($minVersion, $testDetails, $maxVersion = NULL) { $this->testing($testDetails); @@ -682,7 +678,7 @@ class InstallRequirements { * @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; @@ -696,7 +692,7 @@ class InstallRequirements { /** * @param $testDetails */ - function requireNoPathSeparator($testDetails) { + public function requireNoPathSeparator($testDetails) { $this->testing($testDetails); if (substr_count($this->getBaseDir(), PATH_SEPARATOR)) { $this->error($testDetails); @@ -707,7 +703,7 @@ class InstallRequirements { * @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)) { @@ -720,7 +716,7 @@ class InstallRequirements { * @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)) { @@ -736,7 +732,7 @@ class InstallRequirements { * @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; @@ -761,7 +757,7 @@ class InstallRequirements { * @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); @@ -774,7 +770,7 @@ class InstallRequirements { * @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); @@ -791,7 +787,7 @@ class InstallRequirements { * @param $server * @param $testDetails */ - function requireMySQLServer($server, $testDetails) { + public function requireMySQLServer($server, $testDetails) { $this->testing($testDetails); $conn = @mysql_connect($server, NULL, NULL); @@ -808,7 +804,7 @@ class InstallRequirements { * @param $version * @param $testDetails */ - function requireMySQLVersion($version, $testDetails) { + public function requireMySQLVersion($version, $testDetails) { $this->testing($testDetails); if (!mysql_get_server_info()) { @@ -836,7 +832,7 @@ class InstallRequirements { * @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) { @@ -871,7 +867,7 @@ class InstallRequirements { * @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) { @@ -901,7 +897,7 @@ class InstallRequirements { * @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) { @@ -941,7 +937,7 @@ class InstallRequirements { * @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) { @@ -980,7 +976,6 @@ class InstallRequirements { } $result = mysql_query('DROP TEMPORARY TABLE civicrm_install_temp_table_test'); - return; } /** @@ -989,7 +984,7 @@ class InstallRequirements { * @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) { @@ -1023,7 +1018,7 @@ class InstallRequirements { * @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) { @@ -1060,7 +1055,7 @@ class InstallRequirements { * @param $testDetails * @param bool $onlyRequire */ - function requireDatabaseOrCreatePermissions( + public function requireDatabaseOrCreatePermissions( $server, $username, $password, @@ -1101,7 +1096,7 @@ class InstallRequirements { * @param $varNames * @param $errorMessage */ - function requireServerVariables($varNames, $errorMessage) { + public function requireServerVariables($varNames, $errorMessage) { //$this->testing($testDetails); foreach ($varNames as $varName) { if (!$_SERVER[$varName]) { @@ -1122,7 +1117,7 @@ class InstallRequirements { * * @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; @@ -1135,14 +1130,14 @@ class InstallRequirements { /** * @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; } @@ -1161,7 +1156,7 @@ class InstallRequirements { /** * @param $testDetails */ - function error($testDetails) { + public function error($testDetails) { $section = $testDetails[0]; $test = $testDetails[1]; @@ -1172,7 +1167,7 @@ class InstallRequirements { /** * @param $testDetails */ - function warning($testDetails) { + public function warning($testDetails) { $section = $testDetails[0]; $test = $testDetails[1]; @@ -1183,15 +1178,15 @@ class InstallRequirements { /** * @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); } } @@ -1205,7 +1200,7 @@ class Installer extends InstallRequirements { * @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)) { @@ -1227,7 +1222,7 @@ class Installer extends InstallRequirements { * * @return mixed */ - function install($config) { + public function install($config) { global $installDirPath; // create database if does not exists @@ -1431,9 +1426,8 @@ function civicrm_install_set_drupal_perms() { 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); -- 2.25.1