<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.5 |
+ | CiviCRM version 4.6 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014 |
+ | Copyright CiviCRM LLC (c) 2004-2015 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
-*/
+ */
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2014
+ * @copyright CiviCRM LLC (c) 2004-2015
*
*/
const AUTOCOMPLETE_TTL = 21600; // 6hr; 6*60*60
- /**
- * @deprecated
- */
- static function getContactList() {
- // if context is 'customfield'
- if (CRM_Utils_Array::value('context', $_GET) == 'customfield') {
- return self::contactReference();
- }
-
- $params = array('version' => 3, 'check_permissions' => TRUE);
-
- // String params
- // FIXME: param keys don't match input keys, using this array to translate
- $whitelist = array(
- 's' => 'name',
- 'fieldName' => 'field_name',
- 'tableName' => 'table_name',
- 'context' => 'context',
- 'rel' => 'rel',
- 'contact_sub_type' => 'contact_sub_type',
- 'contact_type' => 'contact_type'
- );
- foreach ($whitelist as $key => $param) {
- if (!empty($_GET[$key])) {
- $params[$param] = $_GET[$key];
- }
- }
-
- //CRM-10687: Allow quicksearch by multiple fields
- if (!empty($params['field_name'])) {
- if ($params['field_name'] == 'phone_numeric') {
- $params['name'] = preg_replace('/[^\d]/', '', $params['name']);
- }
- if (!$params['name']) {
- CRM_Utils_System::civiExit();
- }
- }
-
- // Numeric params
- $whitelist = array(
- 'limit',
- 'org',
- 'employee_id',
- 'cid',
- 'id',
- 'cmsuser',
- );
- foreach ($whitelist as $key) {
- if (!empty($_GET[$key]) && is_numeric($_GET[$key])) {
- $params[$key] = $_GET[$key];
- }
- }
-
- $result = civicrm_api('Contact', 'getquick', $params);
- CRM_Core_Page_AJAX::autocompleteResults(CRM_Utils_Array::value('values', $result), 'data');
- }
-
/**
* Ajax callback for custom fields of type ContactReference
*
* 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');
}
$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));
}
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) ||
$contactList[] = array('id' => $value['id'], 'text' => implode(' :: ', $view));
}
- CRM_Utils_System::civiExit(json_encode($contactList));
+ CRM_Utils_JSON::output($contactList);
}
/**
- * 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');
- $limit = '10';
+ public static function getPCPList() {
+ $name = CRM_Utils_Array::value('term', $_GET);
+ $name = CRM_Utils_Type::escape($name, 'String');
+ $limit = $max = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'search_autocomplete_count', NULL, 10);
$where = ' AND pcp.page_id = cp.id AND pcp.contact_id = cc.id';
$whereClause = " WHERE ( sort_name LIKE '$strSearch' $includeNickName ) {$where} ";
}
- if (!empty($_GET['limit'])) {
- $limit = CRM_Utils_Type::escape($_GET['limit'], 'Positive');
+ $offset = $count = 0;
+ if (!empty($_GET['page'])) {
+ $page = (int) $_GET['page'];
+ $offset = $limit * ($page - 1);
+ $limit++;
}
$select = 'cc.sort_name, pcp.title, cp.title';
FROM civicrm_pcp pcp, civicrm_event cp, civicrm_contact cc
{$includeEmailFrom}
{$whereClause} AND pcp.page_type = 'event'
- LIMIT 0, {$limit}
) t
ORDER BY sort_name
+ LIMIT $offset, $limit
";
$dao = CRM_Core_DAO::executeQuery($query);
- $results = array();
+ $output = array('results' => array(), 'more' => FALSE);
while ($dao->fetch()) {
- $results[] = array('id' => $dao->id, 'text' => $dao->data);
+ if (++$count > $max) {
+ $output['more'] = TRUE;
+ }
+ else {
+ $output['results'][] = array('id' => $dao->id, 'text' => $dao->data);
+ }
}
- CRM_Utils_JSON::output($results);
+ CRM_Utils_JSON::output($output);
}
- 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
+ $relationshipID = CRM_Utils_Request::retrieve('rel_id', 'Positive', CRM_Core_DAO::$_nullObject); // this used only to determine add or update mode
$caseID = CRM_Utils_Request::retrieve('case_id', 'Positive', CRM_Core_DAO::$_nullObject, TRUE);
// check if there are multiple clients for this case, if so then we need create
$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),
$caseRelationships->contact_id_a = $sourceContactID;
$caseRelationships->find();
- while($caseRelationships->fetch()) {
+ while ($caseRelationships->fetch()) {
$relationIds['relationship'] = $caseRelationships->id;
$relationIds['contactTarget'] = $relContactID;
}
}
// create new or update existing relationship
- $return = CRM_Contact_BAO_Relationship::create($relationParams, $relationIds);
+ $return = CRM_Contact_BAO_Relationship::legacyCreateMultiple($relationParams, $relationIds);
if (!empty($return[4][0])) {
$relationshipID = $return[4][0];
$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 <a href="%1">Administer >> Option Lists >> Relationship Types</a>.',
- array(1 => CRM_Utils_System::url('civicrm/admin/reltype', 'reset=1')))
+ array(1 => CRM_Utils_System::url('civicrm/admin/reltype', 'reset=1'))),
);
}
}
}
/**
- * 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() {
+ header('Content-Type: application/json');
$gids = CRM_Utils_Type::escape($_GET['gids'], 'String');
echo CRM_Contact_BAO_GroupNestingCache::json($gids);
CRM_Utils_System::civiExit();
}
/**
- * @deprecated
- * Old quicksearch function. No longer used in core.
- * @todo: Remove this function and associated menu entry in CiviCRM 5
- */
- static function search() {
- $json = TRUE;
- $name = CRM_Utils_Array::value('name', $_GET, '');
- if (!array_key_exists('name', $_GET)) {
- $name = CRM_Utils_Array::value('s', $_GET) . '%';
- $json = FALSE;
- }
- $name = CRM_Utils_Type::escape($name, 'String');
- $whereIdClause = '';
- if (!empty($_GET['id'])) {
- $json = TRUE;
- if (is_numeric($_GET['id'])) {
- $id = CRM_Utils_Type::escape($_GET['id'], 'Integer');
- $whereIdClause = " AND civicrm_contact.id = {$id}";
- }
- else {
- $name = $_GET['id'];
- }
- }
-
- $elements = array();
- if ($name || isset($id)) {
- $name = $name . '%';
-
- //contact's based of relationhip type
- $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');
- }
-
- //shared household info
- $shared = NULL;
- if (isset($_GET['sh'])) {
- $shared = CRM_Utils_Type::escape($_GET['sh'], 'Integer');
- if ($shared == 1) {
- $contactType = 'Household';
- $cName = 'household_name';
- }
- else {
- $contactType = 'Organization';
- $cName = 'organization_name';
- }
- }
-
- // contacts of type household
- $hh = $addStreet = $addCity = NULL;
- if (isset($_GET['hh'])) {
- $hh = CRM_Utils_Type::escape($_GET['hh'], 'Integer');
- }
-
- //organization info
- $organization = $street = $city = NULL;
- if (isset($_GET['org'])) {
- $organization = CRM_Utils_Type::escape($_GET['org'], 'Integer');
- }
-
- if (isset($_GET['org']) || isset($_GET['hh'])) {
- $json = FALSE;
- $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));
- }
- else {
- $contactName = $name;
- }
-
- if ($street) {
- $addStreet = "AND civicrm_address.street_address LIKE '$street%'";
- }
- if ($city) {
- $addCity = "AND civicrm_address.city LIKE '$city%'";
- }
- }
-
- if ($organization) {
-
- $query = "
-SELECT CONCAT_WS(' :: ',sort_name,LEFT(street_address,25),city) 'sort_name',
-civicrm_contact.id 'id'
-FROM civicrm_contact
-LEFT JOIN civicrm_address ON ( civicrm_contact.id = civicrm_address.contact_id
- AND civicrm_address.is_primary=1
- )
-WHERE civicrm_contact.contact_type='Organization' AND organization_name LIKE '%$contactName%'
-{$addStreet} {$addCity} {$whereIdClause}
-ORDER BY organization_name ";
- }
- elseif ($shared) {
- $query = "
-SELECT CONCAT_WS(':::' , sort_name, supplemental_address_1, sp.abbreviation, postal_code, cc.name )'sort_name' , civicrm_contact.id 'id' , civicrm_contact.display_name 'disp' FROM civicrm_contact LEFT JOIN civicrm_address ON (civicrm_contact.id =civicrm_address.contact_id AND civicrm_address.is_primary =1 )LEFT JOIN civicrm_state_province sp ON (civicrm_address.state_province_id =sp.id )LEFT JOIN civicrm_country cc ON (civicrm_address.country_id =cc.id )WHERE civicrm_contact.contact_type ='{$contactType}' AND {$cName} LIKE '%$name%' {$whereIdClause} ORDER BY {$cName} ";
- }
- elseif ($hh) {
- $query = "
-SELECT CONCAT_WS(' :: ' , sort_name, LEFT(street_address,25),city) 'sort_name' , location_type_id 'location_type_id', is_primary 'is_primary', is_billing 'is_billing', civicrm_contact.id 'id'
-FROM civicrm_contact
-LEFT JOIN civicrm_address ON (civicrm_contact.id =civicrm_address.contact_id AND civicrm_address.is_primary =1 )
-WHERE civicrm_contact.contact_type ='Household'
-AND household_name LIKE '%$contactName%' {$addStreet} {$addCity} {$whereIdClause} ORDER BY household_name ";
- }
- elseif ($relType) {
- if (!empty($_GET['case'])) {
- $query = "
-SELECT distinct(c.id), c.sort_name
-FROM civicrm_contact c
-LEFT JOIN civicrm_relationship ON civicrm_relationship.contact_id_{$rel} = c.id
-WHERE c.sort_name LIKE '%$name%'
-AND civicrm_relationship.relationship_type_id = $relType
-GROUP BY sort_name
-";
- }
- }
- else {
-
- $query = "
-SELECT sort_name, id
-FROM civicrm_contact
-WHERE sort_name LIKE '%$name'
-{$whereIdClause}
-ORDER BY sort_name ";
- }
-
- $limit = 10;
- if (isset($_GET['limit'])) {
- $limit = CRM_Utils_Type::escape($_GET['limit'], 'Positive');
- }
-
- $query .= " LIMIT 0,{$limit}";
-
- $dao = CRM_Core_DAO::executeQuery($query);
-
- if ($shared) {
- while ($dao->fetch()) {
- echo $dao->sort_name;
- CRM_Utils_System::civiExit();
- }
- }
- else {
- while ($dao->fetch()) {
- if ($json) {
- $elements[] = array('name' => addslashes($dao->sort_name),
- 'id' => $dao->id,
- );
- }
- else {
- echo $elements = "$dao->sort_name|$dao->id|$dao->location_type_id|$dao->is_primary|$dao->is_billing\n";
- }
- }
- //for adding new household address / organization
- if (empty($elements) && !$json && ($hh || $organization)) {
- echo CRM_Utils_Array::value('s', $_GET);
- }
- }
- }
-
- if (isset($_GET['sh'])) {
- echo "";
- CRM_Utils_System::civiExit();
- }
-
- if (empty($elements)) {
- $name = str_replace('%', '', $name);
- $elements[] = array(
- 'name' => $name,
- 'id' => $name,
- );
- }
-
- if ($json) {
- echo json_encode($elements);
- }
- CRM_Utils_System::civiExit();
- }
-
- /**
- * Function to delete custom value
- *
+ * Delete custom value.
*/
- static function deleteCustomValue() {
+ public static function deleteCustomValue() {
+ header('Content-Type: text/plain');
$customValueID = CRM_Utils_Type::escape($_REQUEST['valueID'], 'Positive');
$customGroupID = CRM_Utils_Type::escape($_REQUEST['groupID'], 'Positive');
-
+ $contactId = CRM_Utils_Request::retrieve('contactId', 'Positive', CRM_Core_DAO::$_nullObject);
CRM_Core_BAO_CustomValue::deleteCustomValue($customValueID, $customGroupID);
- $contactId = CRM_Utils_Array::value('contactId', $_REQUEST);
if ($contactId) {
- echo CRM_Contact_BAO_Contact::getCountComponent('custom_' . $_REQUEST['groupID'], $contactId);
+ echo CRM_Contact_BAO_Contact::getCountComponent('custom_' . $customGroupID, $contactId);
}
// reset the group contact cache for this group
}
/**
- * Function to perform enable / disable actions on record.
- *
+ * check the CMS username.
*/
- 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;
- if ($op == 'disable-enable') {
- $isActive = TRUE;
- }
- elseif ($op == 'enable-disable') {
- $isActive = FALSE;
- }
- $status = array('status' => 'record-updated-fail');
- if (isset($isActive)) {
- // first munge and clean the recordBAO and get rid of any non alpha numeric characters
- $recordBAO = CRM_Utils_String::munge($recordBAO);
- $recordClass = explode('_', $recordBAO);
-
- // 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");
- $method = 'setIsActive';
-
- if (method_exists($recordBAO, $method)) {
- $updated = call_user_func_array(array($recordBAO, $method),
- array($recordID, $isActive)
- );
- if ($updated) {
- $status = array('status' => 'record-updated-success');
- }
-
- // call hook enableDisable
- CRM_Utils_Hook::enableDisable($recordBAO, $recordID, $isActive);
- }
- }
- CRM_Utils_JSON::output($status);
- }
- }
-
- /**
- *Function to check the CMS username
- *
- */
static public function checkUserName() {
$signer = new CRM_Utils_Signer(CRM_Core_Key::privateKey(), array('for', 'ts'));
+ $sig = CRM_Utils_Request::retrieve('sig', 'String', CRM_Core_DAO::$_nullObject);
+ $for = CRM_Utils_Request::retrieve('for', 'String', CRM_Core_DAO::$_nullObject);
if (
CRM_Utils_Time::getTimeRaw() > $_REQUEST['ts'] + self::CHECK_USERNAME_TTL
- || $_REQUEST['for'] != 'civicrm/ajax/cmsuser'
- || !$signer->validate($_REQUEST['sig'], $_REQUEST)
+ || $for != 'civicrm/ajax/cmsuser'
+ || !$signer->validate($sig, $_REQUEST)
) {
$user = array('name' => 'error');
- echo json_encode($user);
- CRM_Utils_System::civiExit();
+ CRM_Utils_JSON::output($user);
}
$config = CRM_Core_Config::singleton();
- $username = trim($_REQUEST['cms_name']);
+ $username = trim(CRM_Utils_Type::escape($_REQUEST['cms_name'], 'String'));
$params = array('name' => $username);
if (isset($errors['cms_name']) || isset($errors['name'])) {
//user name is not availble
$user = array('name' => 'no');
- echo json_encode($user);
+ CRM_Utils_JSON::output($user);
}
else {
//user name is available
$user = array('name' => 'yes');
- echo json_encode($user);
+ CRM_Utils_JSON::output($user);
}
+
+ // Not reachable: JSON::output() above exits.
CRM_Utils_System::civiExit();
}
/**
- * Function to get email address of a contact
+ * 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)) {
}
list($displayName,
$userEmail
- ) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contactID);
+ ) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contactID);
+
+ header('Content-Type: text/plain');
if ($userEmail) {
echo $userEmail;
}
}
}
else {
- $cid = CRM_Utils_Array::value('cid', $_GET);
- if ($cid) {
- //check cid for interger
+ $cid = CRM_Utils_Array::value('cid', $_GET);
+ if ($cid) {
+ //check cid for integer
$contIDS = explode(',', $cid);
foreach ($contIDS as $contID) {
CRM_Utils_Type::escape($contID, 'Integer');
}
$queryString = " cc.id IN ( $cid )";
- }
+ }
}
if ($queryString) {
// send query to hook to be modified if needed
CRM_Utils_Hook::contactListQuery($query,
$name,
- CRM_Utils_Array::value('context', $_GET),
- CRM_Utils_Array::value('cid', $_GET)
+ CRM_Utils_Request::retrieve('context', 'String', CRM_Core_DAO::$_nullObject),
+ CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject)
);
$dao = CRM_Core_DAO::executeQuery($query);
// send query to hook to be modified if needed
CRM_Utils_Hook::contactListQuery($query,
$name,
- CRM_Utils_Array::value('context', $_GET),
- CRM_Utils_Array::value('cid', $_GET)
+ CRM_Utils_Request::retrieve('context', 'String', CRM_Core_DAO::$_nullObject),
+ CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject)
);
-
$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 . '>',
}
}
if ($result) {
- echo json_encode($result);
+ CRM_Utils_JSON::output($result);
}
}
}
CRM_Utils_System::civiExit();
}
- static function getContactPhone() {
+ public static function getContactPhone() {
$queryString = NULL;
//check for mobile type
$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) {
// send query to hook to be modified if needed
CRM_Utils_Hook::contactListQuery($query,
$name,
- CRM_Utils_Array::value('context', $_GET),
- CRM_Utils_Array::value('cid', $_GET)
+ CRM_Utils_Request::retrieve('context', 'String', CRM_Core_DAO::$_nullObject),
+ CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject)
);
$dao = CRM_Core_DAO::executeQuery($query);
}
if ($result) {
- echo json_encode($result);
+ CRM_Utils_JSON::output($result);
}
CRM_Utils_System::civiExit();
}
- static function buildSubTypes() {
- $parent = CRM_Utils_Array::value('parentId', $_REQUEST);
+ public static function buildSubTypes() {
+ $parent = CRM_Utils_Request::retrieve('parentId', 'Positive', CRM_Core_DAO::$_nullObject);
switch ($parent) {
case 1:
CRM_Utils_JSON::output($subTypes);
}
- static function buildDedupeRules() {
- $parent = CRM_Utils_Array::value('parentId', $_REQUEST);
+ public static function buildDedupeRules() {
+ $parent = CRM_Utils_Request::retrieve('parentId', 'Positive', CRM_Core_DAO::$_nullObject);
switch ($parent) {
case 1:
}
/**
- * Function used for CiviCRM dashboard operations
+ * Function used for CiviCRM dashboard operations.
*/
- static function dashboard() {
+ public static function dashboard() {
$operation = CRM_Utils_Type::escape($_REQUEST['op'], 'String');
switch ($operation) {
}
/**
- * 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()) {
}
/**
- * 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;
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";
$mergeParams .= "&gid={$gid}";
}
- $searchRows[$mainId]['actions'] = CRM_Utils_System::href(ts('merge'), 'civicrm/contact/merge', $mergeParams);
- $searchRows[$mainId]['actions'] .= " | <a id='notDuplicate' href='#' onClick=\"processDupes( {$main['srcID']}, {$main['dstID']}, 'dupe-nondupe', 'dupe-listing'); return false;\">" . ts('not a duplicate') . "</a>";
+ $searchRows[$mainId]['actions'] = '<a class="action-item crm-hover-button" href="' . CRM_Utils_System::url('civicrm/contact/merge', $mergeParams) . '">' . ts('merge') . '</a>';
+ $searchRows[$mainId]['actions'] .= "<a class='action-item crm-hover-button crm-notDuplicate' href='#' onClick=\"processDupes( {$main['srcID']}, {$main['dstID']}, 'dupe-nondupe', 'dupe-listing'); return false;\">" . ts('not a duplicate') . "</a>";
}
else {
$searchRows[$mainId]['actions'] = '<em>' . ts('Insufficient access rights - cannot merge') . '</em>';
}
}
+ header('Content-Type: application/json');
echo CRM_Utils_JSON::encodeDataTableSelector($searchRows, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
CRM_Utils_System::civiExit();
}
/**
- * 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);
}
/**
- * 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);
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');
+ /**
+ * Used to store selected contacts across multiple pages in advanced search.
+ */
+ 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');
}
/**
- * @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() {
- $contactId = CRM_Utils_Array::value('contact_id', $_REQUEST);
+ public static function getAddressDisplay() {
+ $contactId = CRM_Utils_Request::retrieve('contact_id', 'Positive', CRM_Core_DAO::$_nullObject);
if (!$contactId) {
$addressVal["error_message"] = "no contact id found";
}
else {
- $entityBlock =
- array(
- 'contact_id' => $contactId,
- 'entity_id' => $contactId,
- );
+ $entityBlock = array(
+ 'contact_id' => $contactId,
+ 'entity_id' => $contactId,
+ );
$addressVal = CRM_Core_BAO_Address::getValues($entityBlock);
}
}
/**
- * Function to retrieve contact relationships
+ * Retrieve contact relationships.
*/
public static function getContactRelationships() {
$contactID = CRM_Utils_Type::escape($_GET['cid'], 'Integer');
$context = CRM_Utils_Type::escape($_GET['context'], 'String');
+ $relationship_type_id = CRM_Utils_Type::escape(CRM_Utils_Array::value('relationship_type_id', $_GET), 'Integer',
+ FALSE);
if (!CRM_Contact_BAO_Contact_Permission::allow($contactID)) {
return CRM_Utils_System::permissionDenied();
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;
$params['contact_id'] = $contactID;
$params['context'] = $context;
+ if ($relationship_type_id) {
+ $params['relationship_type_id'] = $relationship_type_id;
+ }
// get the contact relationships
$relationships = CRM_Contact_BAO_Relationship::getContactRelationshipSelector($params);
'is_active',
);
+ header('Content-Type: application/json');
echo CRM_Utils_JSON::encodeDataTableSelector($relationships, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
CRM_Utils_System::civiExit();
}
+
}