public static function getPCPList() {
$name = CRM_Utils_Array::value('term', $_GET);
$name = CRM_Utils_Type::escape($name, 'String');
- $limit = '10';
+ $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_num'])) {
+ $page = (int) $_GET['page_num'];
+ $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);
}
public static function relationship() {
}
public static function groupTree() {
- header('Content-Type: application/json');
+ CRM_Utils_System::setHttpHeader('Content-Type', 'application/json');
$gids = CRM_Utils_Type::escape($_GET['gids'], 'String');
echo CRM_Contact_BAO_GroupNestingCache::json($gids);
CRM_Utils_System::civiExit();
* Delete custom value.
*/
public static function deleteCustomValue() {
- header('Content-Type: text/plain');
+ CRM_Utils_System::setHttpHeader('Content-Type', 'text/plain');
$customValueID = CRM_Utils_Type::escape($_REQUEST['valueID'], 'Positive');
$customGroupID = CRM_Utils_Type::escape($_REQUEST['groupID'], 'Positive');
$config->userSystem->checkUserNameEmailExists($params, $errors);
if (isset($errors['cms_name']) || isset($errors['name'])) {
- //user name is not availble
+ //user name is not available
$user = array('name' => 'no');
CRM_Utils_JSON::output($user);
}
$userEmail
) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contactID);
- header('Content-Type: text/plain');
+ CRM_Utils_System::setHttpHeader('Content-Type', 'text/plain');
if ($userEmail) {
echo $userEmail;
}
else {
$cid = CRM_Utils_Array::value('cid', $_GET);
if ($cid) {
- //check cid for interger
+ //check cid for integer
$contIDS = explode(',', $cid);
foreach ($contIDS as $contID) {
CRM_Utils_Type::escape($contID, 'Integer');
else {
$cid = CRM_Utils_Array::value('cid', $_GET);
if ($cid) {
- //check cid for interger
+ //check cid for integer
$contIDS = explode(',', $cid);
foreach ($contIDS as $contID) {
CRM_Utils_Type::escape($contID, 'Integer');
}
}
- header('Content-Type: application/json');
+ CRM_Utils_System::setHttpHeader('Content-Type', 'application/json');
echo CRM_Utils_JSON::encodeDataTableSelector($searchRows, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
CRM_Utils_System::civiExit();
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);
+ $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();
}
- $sortMapper = array(
- 0 => 'relation',
- 1 => 'sort_name',
- 2 => 'start_date',
- 3 => 'end_date',
- 4 => 'city',
- 5 => 'state',
- 6 => 'email',
- 7 => 'phone',
- 8 => 'links',
- 9 => '',
- 10 => '',
- );
+ $sortMapper = array();
+ foreach ($_GET['columns'] as $key => $value) {
+ $sortMapper[$key] = $value['data'];
+ };
- $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';
+ $offset = isset($_GET['start']) ? CRM_Utils_Type::escape($_GET['start'], 'Integer') : 0;
+ $rowCount = isset($_GET['length']) ? CRM_Utils_Type::escape($_GET['length'], 'Integer') : 25;
+ $sort = isset($_GET['order'][0]['column']) ? CRM_Utils_Array::value(CRM_Utils_Type::escape($_GET['order'][0]['column'], 'Integer'), $sortMapper) : NULL;
+ $sortOrder = isset($_GET['order'][0]['dir']) ? CRM_Utils_Type::escape($_GET['order'][0]['dir'], 'String') : 'asc';
- $params = $_POST;
+ $params = $_GET;
if ($sort && $sortOrder) {
$params['sortBy'] = $sort . ' ' . $sortOrder;
}
// get the contact relationships
$relationships = CRM_Contact_BAO_Relationship::getContactRelationshipSelector($params);
- $iFilteredTotal = $iTotal = $params['total'];
- $selectorElements = array(
- 'relation',
- 'name',
- 'start_date',
- 'end_date',
- 'city',
- 'state',
- 'email',
- 'phone',
- 'links',
- 'id',
- 'is_active',
- );
-
- header('Content-Type: application/json');
- echo CRM_Utils_JSON::encodeDataTableSelector($relationships, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
- CRM_Utils_System::civiExit();
+ CRM_Utils_JSON::output($relationships);
}
}