X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FContact%2FPage%2FAJAX.php;fp=CRM%2FContact%2FPage%2FAJAX.php;h=5018815665a5896141f86af6a2e1ca378078dff5;hb=7d86179d7d8e91160bbb5e6643fa265198a99a2d;hp=11a3202147deddf92f5311c60ef3e1028a6c42f1;hpb=3ca2a40961ecdf72c6d1766c886c3aeca5e4c442;p=civicrm-core.git diff --git a/CRM/Contact/Page/AJAX.php b/CRM/Contact/Page/AJAX.php index 11a3202147..5018815665 100644 --- a/CRM/Contact/Page/AJAX.php +++ b/CRM/Contact/Page/AJAX.php @@ -1,7 +1,7 @@ 'context', 'rel' => 'rel', 'contact_sub_type' => 'contact_sub_type', - 'contact_type' => 'contact_type' + 'contact_type' => 'contact_type', ); foreach ($whitelist as $key => $param) { if (!empty($_GET[$key])) { @@ -107,7 +107,7 @@ class CRM_Contact_Page_AJAX { * * Todo: Migrate contact reference fields to use EntityRef */ - static function contactReference() { + public static function contactReference() { $name = CRM_Utils_Array::value('term', $_GET); $name = CRM_Utils_Type::escape($name, 'String'); $cfID = CRM_Utils_Type::escape($_GET['id'], 'Positive'); @@ -135,8 +135,8 @@ class CRM_Contact_Page_AJAX { } $list = array_keys(CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, - 'contact_reference_options' - ), '1'); + 'contact_reference_options' + ), '1'); $return = array_unique(array_merge(array('sort_name'), $list)); @@ -148,7 +148,21 @@ class CRM_Contact_Page_AJAX { } if (!empty($action)) { - $excludeGet = array('reset', 'key', 'className', 'fnName', 'json', 'reset', 'context', 'timestamp', 'limit', 'id', 's', 'q', 'action'); + $excludeGet = array( + 'reset', + 'key', + 'className', + 'fnName', + 'json', + 'reset', + 'context', + 'timestamp', + 'limit', + 'id', + 's', + 'q', + 'action' + ); foreach ($_GET as $param => $val) { if (empty($val) || in_array($param, $excludeGet) || @@ -196,11 +210,11 @@ class CRM_Contact_Page_AJAX { } /** - * Function to fetch PCP ID by PCP Supporter sort_name, also displays PCP title and associated Contribution Page title + * Fetch PCP ID by PCP Supporter sort_name, also displays PCP title and associated Contribution Page title */ - static function getPCPList() { - $name = CRM_Utils_Array::value('term', $_GET); - $name = CRM_Utils_Type::escape($name, 'String'); + public static function getPCPList() { + $name = CRM_Utils_Array::value('term', $_GET); + $name = CRM_Utils_Type::escape($name, 'String'); $limit = '10'; $where = ' AND pcp.page_id = cp.id AND pcp.contact_id = cc.id'; @@ -254,7 +268,7 @@ class CRM_Contact_Page_AJAX { CRM_Utils_JSON::output($results); } - static function relationship() { + public static function relationship() { $relType = CRM_Utils_Request::retrieve('rel_type', 'Positive', CRM_Core_DAO::$_nullObject, TRUE); $relContactID = CRM_Utils_Request::retrieve('rel_contact', 'Positive', CRM_Core_DAO::$_nullObject, TRUE); $relationshipID = CRM_Utils_Array::value('rel_id', $_REQUEST); // this used only to determine add or update mode @@ -268,7 +282,7 @@ class CRM_Contact_Page_AJAX { $ret = array('is_error' => 0); - foreach($clientList as $sourceContactID) { + foreach ($clientList as $sourceContactID) { $relationParams = array( 'relationship_type_id' => $relType . '_a_b', 'contact_check' => array($relContactID => 1), @@ -288,7 +302,7 @@ class CRM_Contact_Page_AJAX { $caseRelationships->contact_id_a = $sourceContactID; $caseRelationships->find(); - while($caseRelationships->fetch()) { + while ($caseRelationships->fetch()) { $relationIds['relationship'] = $caseRelationships->id; $relationIds['contactTarget'] = $relContactID; } @@ -296,7 +310,7 @@ class CRM_Contact_Page_AJAX { } // create new or update existing relationship - $return = CRM_Contact_BAO_Relationship::create($relationParams, $relationIds); + $return = CRM_Contact_BAO_Relationship::createMultiple($relationParams, $relationIds); if (!empty($return[4][0])) { $relationshipID = $return[4][0]; @@ -308,7 +322,7 @@ class CRM_Contact_Page_AJAX { $ret = array( 'is_error' => 1, 'error_message' => ts('The relationship type definition for the case role is not valid for the client and / or staff contact types. You can review and edit relationship types at Administer >> Option Lists >> Relationship Types.', - array(1 => CRM_Utils_System::url('civicrm/admin/reltype', 'reset=1'))) + array(1 => CRM_Utils_System::url('civicrm/admin/reltype', 'reset=1'))), ); } } @@ -317,19 +331,19 @@ class CRM_Contact_Page_AJAX { } /** - * Function to fetch the custom field help + * Fetch the custom field help */ - static function customField() { - $fieldId = CRM_Utils_Type::escape($_REQUEST['id'], 'Integer'); - $params = array('id' => $fieldId); + public static function customField() { + $fieldId = CRM_Utils_Type::escape($_REQUEST['id'], 'Integer'); + $params = array('id' => $fieldId); $returnProperties = array('help_pre', 'help_post'); - $values = array(); + $values = array(); CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_CustomField', $params, $values, $returnProperties); CRM_Utils_JSON::output($values); } - static function groupTree() { + public static function groupTree() { $gids = CRM_Utils_Type::escape($_GET['gids'], 'String'); echo CRM_Contact_BAO_GroupNestingCache::json($gids); CRM_Utils_System::civiExit(); @@ -340,7 +354,7 @@ class CRM_Contact_Page_AJAX { * Old quicksearch function. No longer used in core. * @todo: Remove this function and associated menu entry in CiviCRM 5 */ - static function search() { + public static function search() { $json = TRUE; $name = CRM_Utils_Array::value('name', $_GET, ''); if (!array_key_exists('name', $_GET)) { @@ -368,8 +382,8 @@ class CRM_Contact_Page_AJAX { $relType = NULL; if (isset($_GET['rel'])) { $relation = explode('_', $_GET['rel']); - $relType = CRM_Utils_Type::escape($relation[0], 'Integer'); - $rel = CRM_Utils_Type::escape($relation[2], 'String'); + $relType = CRM_Utils_Type::escape($relation[0], 'Integer'); + $rel = CRM_Utils_Type::escape($relation[2], 'String'); } //shared household info @@ -403,8 +417,8 @@ class CRM_Contact_Page_AJAX { $splitName = explode(' :: ', $name); if ($splitName) { $contactName = trim(CRM_Utils_Array::value('0', $splitName)); - $street = trim(CRM_Utils_Array::value('1', $splitName)); - $city = trim(CRM_Utils_Array::value('2', $splitName)); + $street = trim(CRM_Utils_Array::value('1', $splitName)); + $city = trim(CRM_Utils_Array::value('2', $splitName)); } else { $contactName = $name; @@ -483,7 +497,8 @@ ORDER BY sort_name "; else { while ($dao->fetch()) { if ($json) { - $elements[] = array('name' => addslashes($dao->sort_name), + $elements[] = array( + 'name' => addslashes($dao->sort_name), 'id' => $dao->id, ); } @@ -518,10 +533,9 @@ ORDER BY sort_name "; } /** - * Function to delete custom value - * + * Delete custom value */ - static function deleteCustomValue() { + public static function deleteCustomValue() { $customValueID = CRM_Utils_Type::escape($_REQUEST['valueID'], 'Positive'); $customGroupID = CRM_Utils_Type::escape($_REQUEST['groupID'], 'Positive'); @@ -537,12 +551,11 @@ ORDER BY sort_name "; } /** - * Function to perform enable / disable actions on record. - * + * Perform enable / disable actions on record. */ - static function enableDisable() { - $op = CRM_Utils_Type::escape($_REQUEST['op'], 'String'); - $recordID = CRM_Utils_Type::escape($_REQUEST['recordID'], 'Positive'); + public static function enableDisable() { + $op = CRM_Utils_Type::escape($_REQUEST['op'], 'String'); + $recordID = CRM_Utils_Type::escape($_REQUEST['recordID'], 'Positive'); $recordBAO = CRM_Utils_Type::escape($_REQUEST['recordBAO'], 'String'); $isActive = NULL; @@ -561,7 +574,7 @@ ORDER BY sort_name "; // make sure recordClass is namespaced (we cant check CRM since extensions can also use this) // but it should be at least 3 levels deep if (count($recordClass) >= 3) { - require_once (str_replace('_', DIRECTORY_SEPARATOR, $recordBAO) . ".php"); + require_once str_replace('_', DIRECTORY_SEPARATOR, $recordBAO) . ".php"; $method = 'setIsActive'; if (method_exists($recordBAO, $method)) { @@ -581,9 +594,8 @@ ORDER BY sort_name "; } /** - *Function to check the CMS username - * - */ + * check the CMS username + */ static public function checkUserName() { $signer = new CRM_Utils_Signer(CRM_Core_Key::privateKey(), array('for', 'ts')); if ( @@ -620,7 +632,7 @@ ORDER BY sort_name "; /** * Function to get email address of a contact */ - static function getContactEmail() { + public static function getContactEmail() { if (!empty($_REQUEST['contact_id'])) { $contactID = CRM_Utils_Type::escape($_REQUEST['contact_id'], 'Positive'); if (!CRM_Contact_BAO_Contact_Permission::allow($contactID, CRM_Core_Permission::EDIT)) { @@ -628,7 +640,7 @@ ORDER BY sort_name "; } list($displayName, $userEmail - ) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contactID); + ) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contactID); if ($userEmail) { echo $userEmail; } @@ -647,15 +659,15 @@ ORDER BY sort_name "; } } else { - $cid = CRM_Utils_Array::value('cid', $_GET); - if ($cid) { + $cid = CRM_Utils_Array::value('cid', $_GET); + if ($cid) { //check cid for interger $contIDS = explode(',', $cid); foreach ($contIDS as $contID) { CRM_Utils_Type::escape($contID, 'Integer'); } $queryString = " cc.id IN ( $cid )"; - } + } } if ($queryString) { @@ -711,11 +723,10 @@ LIMIT {$offset}, {$rowCount} CRM_Utils_Array::value('cid', $_GET) ); - $dao = CRM_Core_DAO::executeQuery($query); while ($dao->fetch()) { - //working here + //working here $result[] = array( 'text' => '"' . $dao->name . '" <' . $dao->email . '>', 'id' => (CRM_Utils_Array::value('id', $_GET)) ? "{$dao->id}::{$dao->email}" : '"' . $dao->name . '" <' . $dao->email . '>', @@ -730,7 +741,7 @@ LIMIT {$offset}, {$rowCount} CRM_Utils_System::civiExit(); } - static function getContactPhone() { + public static function getContactPhone() { $queryString = NULL; //check for mobile type @@ -743,8 +754,8 @@ LIMIT {$offset}, {$rowCount} $queryString = " ( cc.sort_name LIKE '%$name%' OR cp.phone LIKE '%$name%' ) "; } else { - $cid = CRM_Utils_Array::value('cid', $_GET); - if ($cid) { + $cid = CRM_Utils_Array::value('cid', $_GET); + if ($cid) { //check cid for interger $contIDS = explode(',', $cid); foreach ($contIDS as $contID) { @@ -800,7 +811,7 @@ LIMIT {$offset}, {$rowCount} } - static function buildSubTypes() { + public static function buildSubTypes() { $parent = CRM_Utils_Array::value('parentId', $_REQUEST); switch ($parent) { @@ -822,7 +833,7 @@ LIMIT {$offset}, {$rowCount} CRM_Utils_JSON::output($subTypes); } - static function buildDedupeRules() { + public static function buildDedupeRules() { $parent = CRM_Utils_Array::value('parentId', $_REQUEST); switch ($parent) { @@ -847,7 +858,7 @@ LIMIT {$offset}, {$rowCount} /** * Function used for CiviCRM dashboard operations */ - static function dashboard() { + public static function dashboard() { $operation = CRM_Utils_Type::escape($_REQUEST['op'], 'String'); switch ($operation) { @@ -877,12 +888,12 @@ LIMIT {$offset}, {$rowCount} } /** - * Function to retrieve signature based on email id + * Retrieve signature based on email id */ - static function getSignature() { + public static function getSignature() { $emailID = CRM_Utils_Type::escape($_REQUEST['emailID'], 'Positive'); - $query = "SELECT signature_text, signature_html FROM civicrm_email WHERE id = {$emailID}"; - $dao = CRM_Core_DAO::executeQuery($query); + $query = "SELECT signature_text, signature_html FROM civicrm_email WHERE id = {$emailID}"; + $dao = CRM_Core_DAO::executeQuery($query); $signatures = array(); while ($dao->fetch()) { @@ -896,13 +907,12 @@ LIMIT {$offset}, {$rowCount} } /** - * Function to process dupes. - * + * Process dupes. */ - static function processDupes() { + public static function processDupes() { $oper = CRM_Utils_Type::escape($_REQUEST['op'], 'String'); - $cid = CRM_Utils_Type::escape($_REQUEST['cid'], 'Positive'); - $oid = CRM_Utils_Type::escape($_REQUEST['oid'], 'Positive'); + $cid = CRM_Utils_Type::escape($_REQUEST['cid'], 'Positive'); + $oid = CRM_Utils_Type::escape($_REQUEST['oid'], 'Positive'); if (!$oper || !$cid || !$oid) { return; @@ -928,26 +938,25 @@ LIMIT {$offset}, {$rowCount} CRM_Utils_JSON::output(array('status' => ($status) ? $oper : $status)); } - static function getDedupes() { + public static function getDedupes() { - $sEcho = CRM_Utils_Type::escape($_REQUEST['sEcho'], 'Integer'); - $offset = isset($_REQUEST['iDisplayStart']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayStart'], 'Integer') : 0; - $rowCount = isset($_REQUEST['iDisplayLength']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayLength'], 'Integer') : 25; - $sort = 'sort_name'; + $sEcho = CRM_Utils_Type::escape($_REQUEST['sEcho'], 'Integer'); + $offset = isset($_REQUEST['iDisplayStart']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayStart'], 'Integer') : 0; + $rowCount = isset($_REQUEST['iDisplayLength']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayLength'], 'Integer') : 25; + $sort = 'sort_name'; $sortOrder = isset($_REQUEST['sSortDir_0']) ? CRM_Utils_Type::escape($_REQUEST['sSortDir_0'], 'String') : 'asc'; - $gid = isset($_REQUEST['gid']) ? CRM_Utils_Type::escape($_REQUEST['gid'], 'Integer') : 0; - $rgid = isset($_REQUEST['rgid']) ? CRM_Utils_Type::escape($_REQUEST['rgid'], 'Integer') : 0; + $gid = isset($_REQUEST['gid']) ? CRM_Utils_Type::escape($_REQUEST['gid'], 'Integer') : 0; + $rgid = isset($_REQUEST['rgid']) ? CRM_Utils_Type::escape($_REQUEST['rgid'], 'Integer') : 0; $contactType = ''; if ($rgid) { $contactType = CRM_Core_DAO::getFieldValue('CRM_Dedupe_DAO_RuleGroup', $rgid, 'contact_type'); } - $cacheKeyString = "merge {$contactType}_{$rgid}_{$gid}"; - $searchRows = array(); + $cacheKeyString = "merge {$contactType}_{$rgid}_{$gid}"; + $searchRows = array(); $selectorElements = array('src', 'dst', 'weight', 'actions'); - $join = "LEFT JOIN civicrm_dedupe_exception de ON ( pn.entity_id1 = de.contact_id1 AND pn.entity_id2 = de.contact_id2 )"; $where = "de.id IS NULL"; @@ -980,9 +989,9 @@ LIMIT {$offset}, {$rowCount} } /** - * Function to retrieve a PDF Page Format for the PDF Letter form + * Retrieve a PDF Page Format for the PDF Letter form */ - function pdfFormat() { + public function pdfFormat() { $formatId = CRM_Utils_Type::escape($_REQUEST['formatId'], 'Integer'); $pdfFormat = CRM_Core_BAO_PdfFormat::getById($formatId); @@ -991,9 +1000,9 @@ LIMIT {$offset}, {$rowCount} } /** - * Function to retrieve Paper Size dimensions + * Retrieve Paper Size dimensions */ - static function paperSize() { + public static function paperSize() { $paperSizeName = CRM_Utils_Type::escape($_REQUEST['paperSizeName'], 'String'); $paperSize = CRM_Core_BAO_PaperSize::getByName($paperSizeName); @@ -1001,10 +1010,10 @@ LIMIT {$offset}, {$rowCount} CRM_Utils_JSON::output($paperSize); } - static function selectUnselectContacts() { - $name = CRM_Utils_Array::value('name', $_REQUEST); - $cacheKey = CRM_Utils_Array::value('qfKey', $_REQUEST); - $state = CRM_Utils_Array::value('state', $_REQUEST, 'checked'); + public static function selectUnselectContacts() { + $name = CRM_Utils_Array::value('name', $_REQUEST); + $cacheKey = CRM_Utils_Array::value('qfKey', $_REQUEST); + $state = CRM_Utils_Array::value('state', $_REQUEST, 'checked'); $variableType = CRM_Utils_Array::value('variableType', $_REQUEST, 'single'); $actionToPerform = CRM_Utils_Array::value('action', $_REQUEST, 'select'); @@ -1036,18 +1045,18 @@ LIMIT {$offset}, {$rowCount} } /** - * @param $name + * @param string $name * * @return string */ - static function _convertToId($name) { + public static function _convertToId($name) { if (substr($name, 0, CRM_Core_Form::CB_PREFIX_LEN) == CRM_Core_Form::CB_PREFIX) { $cId = substr($name, CRM_Core_Form::CB_PREFIX_LEN); } return $cId; } - static function getAddressDisplay() { + public static function getAddressDisplay() { $contactId = CRM_Utils_Array::value('contact_id', $_REQUEST); if (!$contactId) { $addressVal["error_message"] = "no contact id found"; @@ -1065,7 +1074,7 @@ LIMIT {$offset}, {$rowCount} } /** - * Function to retrieve contact relationships + * Retrieve contact relationships */ public static function getContactRelationships() { $contactID = CRM_Utils_Type::escape($_GET['cid'], 'Integer'); @@ -1085,10 +1094,10 @@ LIMIT {$offset}, {$rowCount} 10 => '', ); - $sEcho = CRM_Utils_Type::escape($_REQUEST['sEcho'], 'Integer'); - $offset = isset($_REQUEST['iDisplayStart']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayStart'], 'Integer') : 0; - $rowCount = isset($_REQUEST['iDisplayLength']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayLength'], 'Integer') : 25; - $sort = isset($_REQUEST['iSortCol_0']) ? CRM_Utils_Array::value(CRM_Utils_Type::escape($_REQUEST['iSortCol_0'], 'Integer'), $sortMapper) : NULL; + $sEcho = CRM_Utils_Type::escape($_REQUEST['sEcho'], 'Integer'); + $offset = isset($_REQUEST['iDisplayStart']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayStart'], 'Integer') : 0; + $rowCount = isset($_REQUEST['iDisplayLength']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayLength'], 'Integer') : 25; + $sort = isset($_REQUEST['iSortCol_0']) ? CRM_Utils_Array::value(CRM_Utils_Type::escape($_REQUEST['iSortCol_0'], 'Integer'), $sortMapper) : NULL; $sortOrder = isset($_REQUEST['sSortDir_0']) ? CRM_Utils_Type::escape($_REQUEST['sSortDir_0'], 'String') : 'asc'; $params = $_POST;