コード例 #1
0
 /**
  * Browse all activities for a particular contact
  *
  * @param boolean $history - true if we want to browse activity history, false otherwise.
  * @return none
  *
  * @access public
  */
 function browse($history)
 {
     $this->assign('totalCountOpenActivity', CRM_Contact_BAO_Contact::getNumOpenActivity($this->_contactId));
     $this->assign('totalCountActivity', CRM_Core_BAO_History::getNumHistory($this->_contactId, 'Activity'));
     require_once 'CRM/Core/Selector/Controller.php';
     if ($history) {
         $this->assign('history', true);
         // create the selector, controller and run - store results in session
         $output = CRM_CORE_SELECTOR_CONTROLLER_SESSION;
         require_once 'CRM/History/Selector/Activity.php';
         $selector =& new CRM_History_Selector_Activity($this->_contactId, $this->_permission);
         $sortID = null;
         if ($this->get(CRM_UTILS_SORT_SORT_ID)) {
             $sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_UTILS_SORT_SORT_ID), $this->get(CRM_UTILS_SORT_SORT_DIRECTION));
         }
         $controller =& new CRM_Core_Selector_Controller($selector, $this->get(CRM_UTILS_PAGER_PAGE_ID), $sortID, CRM_CORE_ACTION_VIEW, $this, $output);
         $controller->setEmbedded(true);
         $controller->run();
         $controller->moveFromSessionToTemplate();
     } else {
         $this->assign('history', false);
         // create the selector, controller and run - store results in session
         $output = CRM_CORE_SELECTOR_CONTROLLER_SESSION;
         require_once 'CRM/Contact/Selector/Activity.php';
         $selector =& new CRM_Contact_Selector_Activity($this->_contactId, $this->_permission);
         $sortID = null;
         if ($this->get(CRM_UTILS_SORT_SORT_ID)) {
             $sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_UTILS_SORT_SORT_ID), $this->get(CRM_UTILS_SORT_SORT_DIRECTION));
         }
         $controller =& new CRM_Core_Selector_Controller($selector, $this->get(CRM_UTILS_PAGER_PAGE_ID), $sortID, CRM_CORE_ACTION_VIEW, $this, $output);
         $controller->setEmbedded(true);
         $controller->run();
         $controller->moveFromSessionToTemplate();
     }
 }
コード例 #2
0
 /**
  * Returns total number of rows for the query.
  *
  * @param string $action - action being performed
  * @return int Total number of rows 
  * @access public
  */
 function getTotalCount($action)
 {
     return CRM_Contact_BAO_Contact::getNumOpenActivity($this->_contactId);
 }
コード例 #3
0
 /**
  * Takes a bunch of params that are needed to match certain criteria and
  * retrieves the relevant objects. Typically the valid params are only
  * contact_id. We'll tweak this function to be more full featured over a period
  * of time. This is the inverse function of create. It also stores all the retrieved
  * values in the default array
  *
  * @param array $params   (reference ) an assoc array of name/value pairs
  * @param array $defaults (reference ) an assoc array to hold the name / value pairs
  *                        in a hierarchical manner
  * @param array $ids      (reference) the array that holds all the db ids
  *
  * @return object CRM_Contact_BAO_Contact object
  * @access public
  * @static
  */
 function retrieve(&$params, &$defaults, &$ids)
 {
     $contact = CRM_Contact_BAO_Contact::getValues($params, $defaults, $ids);
     unset($params['id']);
     require_once str_replace('_', DIRECTORY_SEPARATOR, "CRM_Contact_BAO_" . $contact->contact_type) . ".php";
     eval('$contact->contact_type_object =& CRM_Contact_BAO_' . $contact->contact_type . '::getValues( $params, $defaults, $ids );');
     $locParams = $params + array('entity_id' => $params['contact_id'], 'entity_table' => CRM_Contact_BAO_Contact::getTableName());
     $contact->location =& CRM_Core_BAO_Location::getValues($locParams, $defaults, $ids, 3);
     $contact->notes =& CRM_Core_BAO_Note::getValues($params, $defaults, $ids);
     $contact->relationship =& CRM_Contact_BAO_Relationship::getValues($params, $defaults, $ids);
     $contact->groupContact =& CRM_Contact_BAO_GroupContact::getValues($params, $defaults, $ids);
     $activityParam = array('entity_id' => $params['contact_id']);
     $contact->activity =& CRM_Core_BAO_History::getValues($activityParam, $defaults, 'Activity');
     $activityParam = array('contact_id' => $params['contact_id']);
     $defaults['openActivity'] = array('data' => CRM_Contact_BAO_Contact::getOpenActivities($activityParam, 0, 3), 'totalCount' => CRM_Contact_BAO_Contact::getNumOpenActivity($params['contact_id']));
     return $contact;
 }