Ejemplo n.º 1
0
 /**
  * This function is called when action is browse
  * 
  * return null
  * @access public
  */
 function browse()
 {
     $links =& CRM_Contact_Page_View_Relationship::links();
     $mask = CRM_Core_Action::mask($this->_permission);
     $currentRelationships = CRM_Contact_BAO_Relationship::getRelationship($this->_contactId, CRM_CONTACT_BAO_RELATIONSHIP_CURRENT, 0, 0, 0, $links, $mask);
     $pastRelationships = CRM_Contact_BAO_Relationship::getRelationship($this->_contactId, CRM_CONTACT_BAO_RELATIONSHIP_PAST, 0, 0, 0, $links, $mask);
     $disableRelationships = CRM_Contact_BAO_Relationship::getRelationship($this->_contactId, CRM_CONTACT_BAO_RELATIONSHIP_DISABLED, 0, 0, 0, $links, $mask);
     $this->assign('currentRelationships', $currentRelationships);
     $this->assign('pastRelationships', $pastRelationships);
     $this->assign('disableRelationships', $disableRelationships);
 }
Ejemplo n.º 2
0
 /**
  * Wrapper for contact relationship selector.
  *
  * @param array $params
  *   Associated array for params record id.
  *
  * @return array
  *   associated array of contact relationships
  */
 public static function getContactRelationshipSelector(&$params)
 {
     // format the params
     $params['offset'] = ($params['page'] - 1) * $params['rp'];
     $params['sort'] = CRM_Utils_Array::value('sortBy', $params);
     if ($params['context'] == 'past') {
         $relationshipStatus = CRM_Contact_BAO_Relationship::INACTIVE;
     } elseif ($params['context'] == 'all') {
         $relationshipStatus = CRM_Contact_BAO_Relationship::ALL;
     } else {
         $relationshipStatus = CRM_Contact_BAO_Relationship::CURRENT;
     }
     // check logged in user for permission
     $page = new CRM_Core_Page();
     CRM_Contact_Page_View::checkUserPermission($page, $params['contact_id']);
     $permissions = array($page->_permission);
     if ($page->_permission == CRM_Core_Permission::EDIT) {
         $permissions[] = CRM_Core_Permission::DELETE;
     }
     $mask = CRM_Core_Action::mask($permissions);
     $permissionedContacts = TRUE;
     if ($params['context'] != 'user') {
         $links = CRM_Contact_Page_View_Relationship::links();
     } else {
         $links = CRM_Contact_Page_View_UserDashBoard::links();
         $mask = NULL;
     }
     // get contact relationships
     $relationships = CRM_Contact_BAO_Relationship::getRelationship($params['contact_id'], $relationshipStatus, $params['rp'], 0, 0, $links, $mask, $permissionedContacts, $params);
     $contactRelationships = array();
     $params['total'] = 0;
     if (!empty($relationships)) {
         // FIXME: we cannot directly determine total permissioned relationship, hence re-fire query
         $permissionedRelationships = CRM_Contact_BAO_Relationship::getRelationship($params['contact_id'], $relationshipStatus, 0, 0, 0, NULL, NULL, $permissionedContacts);
         $params['total'] = count($permissionedRelationships);
         // format params
         foreach ($relationships as $relationshipId => $values) {
             $relationship = array();
             $relationship['DT_RowId'] = $values['id'];
             $relationship['DT_RowClass'] = 'crm-entity';
             if ($values['is_active'] == 0) {
                 $relationship['DT_RowClass'] .= ' disabled';
             }
             $relationship['DT_RowAttr'] = array();
             $relationship['DT_RowAttr']['data-entity'] = 'relationship';
             $relationship['DT_RowAttr']['data-id'] = $values['id'];
             //Add image icon for related contacts: CRM-14919
             $icon = CRM_Contact_BAO_Contact_Utils::getImage($values['contact_type'], FALSE, $values['cid']);
             $relationship['sort_name'] = $icon . ' ' . CRM_Utils_System::href($values['name'], 'civicrm/contact/view', "reset=1&cid={$values['cid']}");
             $relationship['relation'] = CRM_Utils_System::href($values['relation'], 'civicrm/contact/view/rel', "action=view&reset=1&cid={$values['cid']}&id={$values['id']}&rtype={$values['rtype']}");
             if ($params['context'] == 'current') {
                 if ($params['contact_id'] == $values['contact_id_a'] and $values['is_permission_a_b'] == 1 or $params['contact_id'] == $values['contact_id_b'] and $values['is_permission_b_a'] == 1) {
                     $relationship['sort_name'] .= '<span id="permission-a-b" class="crm-marker permission-relationship"> *</span>';
                 }
                 if ($values['cid'] == $values['contact_id_a'] and $values['is_permission_a_b'] == 1 or $values['cid'] == $values['contact_id_b'] and $values['is_permission_b_a'] == 1) {
                     $relationship['relation'] .= '<span id="permission-b-a" class="crm-marker permission-relationship"> *</span>';
                 }
             }
             if (!empty($values['description'])) {
                 $relationship['relation'] .= "<p class='description'>{$values['description']}</p>";
             }
             $relationship['start_date'] = CRM_Utils_Date::customFormat($values['start_date']);
             $relationship['end_date'] = CRM_Utils_Date::customFormat($values['end_date']);
             $relationship['city'] = $values['city'];
             $relationship['state'] = $values['state'];
             $relationship['email'] = $values['email'];
             $relationship['phone'] = $values['phone'];
             $relationship['links'] = $values['action'];
             array_push($contactRelationships, $relationship);
         }
     }
     $relationshipsDT = array();
     $relationshipsDT['data'] = $contactRelationships;
     $relationshipsDT['recordsTotal'] = $params['total'];
     $relationshipsDT['recordsFiltered'] = $params['total'];
     return $relationshipsDT;
 }