Merge pull request #5112 from totten/master-include-case
[civicrm-core.git] / CRM / Contact / Page / AJAX.php
index 4cd911fb46111a9e17833b4811473234424c3f7c..81aef571076d655c6493e74f3244b99ebced784c 100644 (file)
@@ -23,7 +23,7 @@
  | GNU Affero General Public License or the licensing of CiviCRM,     |
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
-*/
+ */
 
 /**
  *
@@ -103,7 +103,7 @@ class CRM_Contact_Page_AJAX {
   }
 
   /**
-   * Ajax callback for custom fields of type ContactReference
+   * Ajax callback for custom fields of type ContactReference.
    *
    * Todo: Migrate contact reference fields to use EntityRef
    */
@@ -331,7 +331,7 @@ class CRM_Contact_Page_AJAX {
   }
 
   /**
-   * Fetch the custom field help
+   * Fetch the custom field help.
    */
   public static function customField() {
     $fieldId = CRM_Utils_Type::escape($_REQUEST['id'], 'Integer');
@@ -533,7 +533,7 @@ ORDER BY sort_name ";
   }
 
   /**
-   * Delete custom value
+   * Delete custom value.
    */
   public static function deleteCustomValue() {
     $customValueID = CRM_Utils_Type::escape($_REQUEST['valueID'], 'Positive');
@@ -594,7 +594,7 @@ ORDER BY sort_name ";
   }
 
   /**
-   *  check the CMS username
+   *  check the CMS username.
    */
   static public function checkUserName() {
     $signer = new CRM_Utils_Signer(CRM_Core_Key::privateKey(), array('for', 'ts'));
@@ -630,7 +630,7 @@ ORDER BY sort_name ";
   }
 
   /**
-   *  Function to get email address of a contact
+   *  Function to get email address of a contact.
    */
   public static function getContactEmail() {
     if (!empty($_REQUEST['contact_id'])) {
@@ -856,7 +856,7 @@ LIMIT {$offset}, {$rowCount}
   }
 
   /**
-   * Function used for CiviCRM dashboard operations
+   * Function used for CiviCRM dashboard operations.
    */
   public static function dashboard() {
     $operation = CRM_Utils_Type::escape($_REQUEST['op'], 'String');
@@ -888,7 +888,7 @@ LIMIT {$offset}, {$rowCount}
   }
 
   /**
-   * Retrieve signature based on email id
+   * Retrieve signature based on email id.
    */
   public static function getSignature() {
     $emailID = CRM_Utils_Type::escape($_REQUEST['emailID'], 'Positive');
@@ -975,8 +975,8 @@ LIMIT {$offset}, {$rowCount}
           $mergeParams .= "&gid={$gid}";
         }
 
-        $searchRows[$mainId]['actions'] = CRM_Utils_System::href(ts('merge'), 'civicrm/contact/merge', $mergeParams);
-        $searchRows[$mainId]['actions'] .= "&nbsp;|&nbsp; <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>';
@@ -989,7 +989,7 @@ LIMIT {$offset}, {$rowCount}
   }
 
   /**
-   * Retrieve a PDF Page Format for the PDF Letter form
+   * Retrieve a PDF Page Format for the PDF Letter form.
    */
   public function pdfFormat() {
     $formatId = CRM_Utils_Type::escape($_REQUEST['formatId'], 'Integer');
@@ -1000,7 +1000,7 @@ LIMIT {$offset}, {$rowCount}
   }
 
   /**
-   * Retrieve Paper Size dimensions
+   * Retrieve Paper Size dimensions.
    */
   public static function paperSize() {
     $paperSizeName = CRM_Utils_Type::escape($_REQUEST['paperSizeName'], 'String');
@@ -1010,6 +1010,9 @@ LIMIT {$offset}, {$rowCount}
     CRM_Utils_JSON::output($paperSize);
   }
 
+  /**
+   * 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);
@@ -1073,12 +1076,16 @@ LIMIT {$offset}, {$rowCount}
   }
 
   /**
-   * 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');
 
+    if (!CRM_Contact_BAO_Contact_Permission::allow($contactID)) {
+      return CRM_Utils_System::permissionDenied();
+    }
+
     $sortMapper = array(
       0 => 'relation',
       1 => 'sort_name',
@@ -1131,4 +1138,5 @@ LIMIT {$offset}, {$rowCount}
     echo CRM_Utils_JSON::encodeDataTableSelector($relationships, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
     CRM_Utils_System::civiExit();
   }
+
 }