X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FUtils%2FWeight.php;h=3e4add68b7cf54cfe1be34b3ffc72080118797da;hb=9ea8e8dbf8676ea9714681f52a669409705083fe;hp=62ef87790c1613b6feb0f6b2adde09c28e02fce7;hpb=6b79b04e197a144801be8b740b4151a9ef8f306f;p=civicrm-core.git diff --git a/CRM/Utils/Weight.php b/CRM/Utils/Weight.php index 62ef87790c..3e4add68b7 100644 --- a/CRM/Utils/Weight.php +++ b/CRM/Utils/Weight.php @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 5 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2018 | + | Copyright CiviCRM LLC (c) 2004-2019 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -35,8 +35,9 @@ class CRM_Utils_Weight { * 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 = array('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. @@ -205,7 +206,7 @@ class CRM_Utils_Weight { $selectField = "id AS fieldID, $weightField AS weight"; $field = CRM_Utils_Weight::query('SELECT', $daoName, $fieldValues, $selectField); $sameWeightCount = 0; - $weights = array(); + $weights = []; while ($field->fetch()) { if (in_array($field->weight, $weights)) { $sameWeightCount++; @@ -308,11 +309,11 @@ class CRM_Utils_Weight { $fields = &$dao->fields(); $fieldlist = array_keys($fields); - $whereConditions = array(); + $whereConditions = []; if ($additionalWhere) { $whereConditions[] = $additionalWhere; } - $params = array(); + $params = []; $fieldNum = 0; if (is_array($fieldValues)) { foreach ($fieldValues as $fieldName => $value) { @@ -323,7 +324,7 @@ class CRM_Utils_Weight { $fieldNum++; $whereConditions[] = "$fieldName = %$fieldNum"; $fieldType = $fields[$fieldName]['type']; - $params[$fieldNum] = array($value, CRM_Utils_Type::typeToString($fieldType)); + $params[$fieldNum] = [$value, CRM_Utils_Type::typeToString($fieldType)]; } } $where = implode(' AND ', $whereConditions); @@ -386,13 +387,13 @@ class CRM_Utils_Weight { $config = CRM_Core_Config::singleton(); $imageURL = $config->userFrameworkResourceURL . 'i/arrow'; - $queryParams = array( + $queryParams = [ 'reset' => 1, 'dao' => $daoName, 'idName' => $idName, 'url' => $returnURL, 'filter' => $filter, - ); + ]; $signer = new CRM_Utils_Signer(CRM_Core_Key::privateKey(), self::$SIGNABLE_FIELDS); $queryParams['_sgn'] = $signer->sign($queryParams); @@ -403,7 +404,7 @@ class CRM_Utils_Weight { $prevID = $ids[$i - 1]; $nextID = $ids[$i + 1]; - $links = array(); + $links = []; $url = "{$baseURL}&src=$id"; if ($prevID != 0) { @@ -461,17 +462,17 @@ class CRM_Utils_Weight { $tableName = $object->tableName(); $query = "UPDATE $tableName SET weight = %1 WHERE $idName = %2"; - $params = array( - 1 => array($dstWeight, 'Integer'), - 2 => array($src, 'Integer'), - ); + $params = [ + 1 => [$dstWeight, 'Integer'], + 2 => [$src, 'Integer'], + ]; CRM_Core_DAO::executeQuery($query, $params); if ($dir == 'swap') { - $params = array( - 1 => array($srcWeight, 'Integer'), - 2 => array($dst, 'Integer'), - ); + $params = [ + 1 => [$srcWeight, 'Integer'], + 2 => [$dst, 'Integer'], + ]; CRM_Core_DAO::executeQuery($query, $params); } elseif ($dir == 'first') { @@ -480,10 +481,10 @@ class CRM_Utils_Weight { if ($filter) { $query .= " AND $filter"; } - $params = array( - 1 => array($src, 'Integer'), - 2 => array($srcWeight, 'Integer'), - ); + $params = [ + 1 => [$src, 'Integer'], + 2 => [$srcWeight, 'Integer'], + ]; CRM_Core_DAO::executeQuery($query, $params); } elseif ($dir == 'last') { @@ -492,10 +493,10 @@ class CRM_Utils_Weight { if ($filter) { $query .= " AND $filter"; } - $params = array( - 1 => array($src, 'Integer'), - 2 => array($srcWeight, 'Integer'), - ); + $params = [ + 1 => [$src, 'Integer'], + 2 => [$srcWeight, 'Integer'], + ]; CRM_Core_DAO::executeQuery($query, $params); } @@ -510,9 +511,9 @@ class CRM_Utils_Weight { CRM_Utils_System::redirect($url); } - CRM_Core_Page_AJAX::returnJsonResponse(array( + CRM_Core_Page_AJAX::returnJsonResponse([ 'userContext' => $url, - )); + ]); } }