/** * takes an associative array and creates a contact object * * the function extract all the params it needs to initialize the create a * contact object. the params array could contain additional unused name/value * pairs * * @param array $params (reference ) an assoc array of name/value pairs * @param array $ids the array that holds all the db ids * * @return object CRM_Core_DAO_OtherActivity object * @access public * @static */ function add(&$params, &$ids) { if (!CRM_Core_BAO_OtherActivity::dataExists($params)) { return null; } $otherActivity =& new CRM_Core_DAO_Activity(); $otherActivity->copyValues($params); $otherActivity->id = CRM_Utils_Array::value('otherActivity', $ids); return $otherActivity->save(); }
/** * This function is called when action is update or new * * return null * @access public */ function edit() { //set the path depending on open activity or activity history (view mode) $history = CRM_Utils_Request::retrieve('history', $this); // set the userContext stack $session =& CRM_Core_Session::singleton(); $url = CRM_Utils_System::url('civicrm/contact/view/activity', 'show=1&action=browse&reset=1&history=' . $history . '&cid=' . $this->_contactId); $session->pushUserContext($url); if (CRM_Utils_Request::retrieve('confirmed', $form, '', '', 'GET')) { require_once 'CRM/Core/BAO/OtherActivity.php'; CRM_Core_BAO_OtherActivity::del($this->_id); CRM_Utils_System::redirect($url); } $controller =& new CRM_Core_Controller_Simple('CRM_Activity_Form_OtherActivity', ts('Contact Other Activity'), $this->_action); $controller->reset(); $controller->setEmbedded(true); $controller->set('contactId', $this->_contactId); $controller->set('id', $this->_id); $controller->set('pid', $this->get('pid')); $controller->set('log', $this->get('log')); $controller->process(); $controller->run(); }
/** * Function to process the form * * @access public * @return None */ function postProcess() { if ($this->_action & CRM_CORE_ACTION_VIEW) { return; } if ($this->_action & CRM_CORE_ACTION_DELETE) { CRM_Core_BAO_OtherActivity::del($this->_id); return; } // store the submitted values in an array $params = $this->controller->exportValues($this->_name); $ids = array(); // store the date with proper format $params['scheduled_date_time'] = CRM_Utils_Date::format($params['scheduled_date_time']); // store the contact id and current drupal user id $params['source_contact_id'] = $this->_userId; $params['target_entity_id'] = $this->_contactId; $params['target_entity_table'] = 'civicrm_contact'; //set parent id if exists for follow up activities if ($this->_pid) { $params['parent_id'] = $this->_pid; } if ($this->_action & CRM_CORE_ACTION_UPDATE) { $ids['otherActivity'] = $this->_id; } $otherActivity = CRM_Core_BAO_OtherActivity::add($params, $ids); CRM_Core_BAO_CustomGroup::postProcess($this->_groupTree, $params); // do the updates/inserts CRM_Core_BAO_CustomGroup::updateCustomData($this->_groupTree, 'Activity', $otherActivity->id); $activityType = CRM_Core_PseudoConstant::activityType(true); if ($otherActivity->status == 'Completed') { // we need to insert an activity history record here $params = array('entity_table' => 'civicrm_contact', 'entity_id' => $this->_contactId, 'activity_type' => $activityType[$params['activity_type_id']], 'module' => 'CiviCRM', 'callback' => 'CRM_Activity_Form_OtherActivity::showOtherActivityDetails', 'activity_id' => $otherActivity->id, 'activity_summary' => $otherActivity->subject, 'activity_date' => $otherActivity->scheduled_date_time); if (is_a(crm_create_activity_history($params), 'CRM_Core_Error')) { return false; } } if ($otherActivity->status == 'Completed') { CRM_Core_Session::setStatus(ts('Activity "%1" has been logged to Activity History.', array(1 => $otherActivity->subject))); } else { if ($this->_action & CRM_CORE_ACTION_DELETE) { CRM_Core_Session::setStatus(ts("Selected Activity is deleted sucessfully.")); } else { CRM_Core_Session::setStatus(ts('Activity "%1" has been saved.', array(1 => $otherActivity->subject))); } } }