/** * Create an activity. * * @todo elaborate on what this does. * * @param CRM_Core_DAO_Activity $activity * @param string $logMessage * * @return bool */ public static function logActivityAction($activity, $logMessage = NULL) { $session = CRM_Core_Session::singleton(); $id = $session->get('userID'); if (!$id) { $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts); $id = self::getActivityContact($activity->id, $sourceID); } $logParams = array('entity_table' => 'civicrm_activity', 'entity_id' => $activity->id, 'modified_id' => $id, 'modified_date' => date('YmdHis'), 'data' => $logMessage); CRM_Core_BAO_Log::add($logParams); return TRUE; }
/** * Takes an associative array and creates a participant object. * * @param array $params * (reference ) an assoc array of name/value pairs. * * @return CRM_Event_BAO_Participant */ public static function create(&$params) { $transaction = new CRM_Core_Transaction(); $status = NULL; if (!empty($params['id'])) { $status = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $params['id'], 'status_id'); } $participant = self::add($params); if (is_a($participant, 'CRM_Core_Error')) { $transaction->rollback(); return $participant; } if (!CRM_Utils_Array::value('id', $params) || isset($params['status_id']) && $params['status_id'] != $status) { CRM_Activity_BAO_Activity::addActivity($participant); } //CRM-5403 //for update mode if (self::isPrimaryParticipant($participant->id) && $status) { self::updateParticipantStatus($participant->id, $status, $participant->status_id); } $session = CRM_Core_Session::singleton(); $id = $session->get('userID'); if (!$id) { $id = CRM_Utils_Array::value('contact_id', $params); } // add custom field values if (!empty($params['custom']) && is_array($params['custom'])) { CRM_Core_BAO_CustomValueTable::store($params['custom'], 'civicrm_participant', $participant->id); } //process note, CRM-7634 $noteId = NULL; if (!empty($params['id'])) { $note = CRM_Core_BAO_Note::getNote($params['id'], 'civicrm_participant'); $noteId = key($note); } $noteValue = NULL; $hasNoteField = FALSE; foreach (array('note', 'participant_note') as $noteFld) { if (array_key_exists($noteFld, $params)) { $noteValue = $params[$noteFld]; $hasNoteField = TRUE; break; } } if ($noteId || $noteValue) { if ($noteValue) { $noteParams = array('entity_table' => 'civicrm_participant', 'note' => $noteValue, 'entity_id' => $participant->id, 'contact_id' => $id, 'modified_date' => date('Ymd')); $noteIDs = array(); if ($noteId) { $noteIDs['id'] = $noteId; } CRM_Core_BAO_Note::add($noteParams, $noteIDs); } elseif ($noteId && $hasNoteField) { CRM_Core_BAO_Note::del($noteId, FALSE); } } // Log the information on successful add/edit of Participant data. $logParams = array('entity_table' => 'civicrm_participant', 'entity_id' => $participant->id, 'data' => CRM_Event_PseudoConstant::participantStatus($participant->status_id), 'modified_id' => $id, 'modified_date' => date('Ymd')); CRM_Core_BAO_Log::add($logParams); $params['participant_id'] = $participant->id; $transaction->commit(); // do not add to recent items for import, CRM-4399 if (empty($params['skipRecentView'])) { $url = CRM_Utils_System::url('civicrm/contact/view/participant', "action=view&reset=1&id={$participant->id}&cid={$participant->contact_id}&context=home"); $recentOther = array(); if (CRM_Core_Permission::check('edit event participants')) { $recentOther['editUrl'] = CRM_Utils_System::url('civicrm/contact/view/participant', "action=update&reset=1&id={$participant->id}&cid={$participant->contact_id}&context=home"); } if (CRM_Core_Permission::check('delete in CiviEvent')) { $recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/contact/view/participant', "action=delete&reset=1&id={$participant->id}&cid={$participant->contact_id}&context=home"); } $participantRoles = CRM_Event_PseudoConstant::participantRole(); if ($participant->role_id) { $role = explode(CRM_Core_DAO::VALUE_SEPARATOR, $participant->role_id); foreach ($role as &$roleValue) { if (isset($roleValue)) { $roleValue = $participantRoles[$roleValue]; } } $roles = implode(', ', $role); } $roleString = empty($roles) ? '' : $roles; $eventTitle = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $participant->event_id, 'title'); $title = CRM_Contact_BAO_Contact::displayName($participant->contact_id) . ' (' . $roleString . ' - ' . $eventTitle . ')'; // add the recently created Participant CRM_Utils_Recent::add($title, $url, $participant->id, 'Participant', $participant->contact_id, NULL, $recentOther); } return $participant; }
/** * function to create the event * * @param array $params reference array contains the values submitted by the form * * @return object * @access public * @static * */ public static function create(&$params) { $transaction = new CRM_Core_Transaction(); if (empty($params['is_template'])) { $params['is_template'] = 0; } // check if new event, if so set the created_id (if not set) // and always set created_date to now if (empty($params['id'])) { if (empty($params['created_id'])) { $session = CRM_Core_Session::singleton(); $params['created_id'] = $session->get('userID'); } $params['created_date'] = date('YmdHis'); } $event = self::add($params); CRM_Price_BAO_PriceSet::setPriceSets($params, $event, 'event'); if (is_a($event, 'CRM_Core_Error')) { CRM_Core_DAO::transaction('ROLLBACK'); return $event; } $session = CRM_Core_Session::singleton(); $contactId = $session->get('userID'); if (!$contactId) { $contactId = CRM_Utils_Array::value('contact_id', $params); } // Log the information on successful add/edit of Event $logParams = array('entity_table' => 'civicrm_event', 'entity_id' => $event->id, 'modified_id' => $contactId, 'modified_date' => date('Ymd')); CRM_Core_BAO_Log::add($logParams); if (!empty($params['custom']) && is_array($params['custom'])) { CRM_Core_BAO_CustomValueTable::store($params['custom'], 'civicrm_event', $event->id); } $transaction->commit(); return $event; }
/** * function to create the event * * @param array $params reference array contains the values submitted by the form * * @access public * @static * */ public static function create(&$params) { require_once 'CRM/Core/Transaction.php'; $transaction = new CRM_Core_Transaction(); $event = self::add($params); if (is_a($event, 'CRM_Core_Error')) { CRM_Core_DAO::transaction('ROLLBACK'); return $event; } $session =& CRM_Core_Session::singleton(); $contactId = $session->get('userID'); if (!$contactId) { $contactId = CRM_Utils_Array::value('contact_id', $params); } // Log the information on successful add/edit of Event require_once 'CRM/Core/BAO/Log.php'; $logParams = array('entity_table' => 'civicrm_event', 'entity_id' => $event->id, 'modified_id' => $contactId, 'modified_date' => date('Ymd')); CRM_Core_BAO_Log::add($logParams); if (CRM_Utils_Array::value('custom', $params) && is_array($params['custom'])) { require_once 'CRM/Core/BAO/CustomValueTable.php'; CRM_Core_BAO_CustomValueTable::store($params['custom'], 'civicrm_event', $event->id); } $transaction->commit(); return $event; }
/** * takes an associative array and creates a participant object * * @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_Event_BAO_Participant object * @access public * @static */ static function &create(&$params) { require_once 'CRM/Utils/Date.php'; require_once 'CRM/Core/Transaction.php'; $transaction = new CRM_Core_Transaction(); $status = null; if (CRM_Utils_Array::value('id', $params)) { $status = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $params['id'], 'status_id'); } $participant =& self::add($params); if (is_a($participant, 'CRM_Core_Error')) { $transaction->rollback(); return $participant; } if (!CRM_Utils_Array::value('id', $params) || $params['status_id'] != $status) { require_once 'CRM/Activity/BAO/Activity.php'; CRM_Activity_BAO_Activity::addActivity($participant); } //CRM-5403 //for update mode if (self::isPrimaryParticipant($participant->id) && $status) { self::updateParticipantStatus($participant->id, $status, $participant->status_id); } $session =& CRM_Core_Session::singleton(); $id = $session->get('userID'); if (!$id) { $id = $params['contact_id']; } // add custom field values if (CRM_Utils_Array::value('custom', $params) && is_array($params['custom'])) { require_once 'CRM/Core/BAO/CustomValueTable.php'; CRM_Core_BAO_CustomValueTable::store($params['custom'], 'civicrm_participant', $participant->id); } if (CRM_Utils_Array::value('note', $params) || CRM_Utils_Array::value('participant_note', $params)) { if (CRM_Utils_Array::value('note', $params)) { $note = CRM_Utils_Array::value('note', $params); } else { $note = CRM_Utils_Array::value('participant_note', $params); } $noteDetails = CRM_Core_BAO_Note::getNote($participant->id, 'civicrm_participant'); $noteIDs = array(); if (!empty($noteDetails)) { $noteIDs['id'] = array_pop(array_flip($noteDetails)); } if ($note) { require_once 'CRM/Core/BAO/Note.php'; $noteParams = array('entity_table' => 'civicrm_participant', 'note' => $note, 'entity_id' => $participant->id, 'contact_id' => $id, 'modified_date' => date('Ymd')); CRM_Core_BAO_Note::add($noteParams, $noteIDs); } } // Log the information on successful add/edit of Participant data. require_once 'CRM/Core/BAO/Log.php'; $logParams = array('entity_table' => 'civicrm_participant', 'entity_id' => $participant->id, 'data' => CRM_Event_PseudoConstant::participantStatus($participant->status_id), 'modified_id' => $id, 'modified_date' => date('Ymd')); CRM_Core_BAO_Log::add($logParams); $params['participant_id'] = $participant->id; $transaction->commit(); // do not add to recent items for import, CRM-4399 if (!CRM_Utils_Array::value('skipRecentView', $params)) { require_once 'CRM/Utils/Recent.php'; require_once 'CRM/Event/PseudoConstant.php'; require_once 'CRM/Contact/BAO/Contact.php'; $url = CRM_Utils_System::url('civicrm/contact/view/participant', "action=view&reset=1&id={$participant->id}&cid={$participant->contact_id}&context=home"); $recentOther = array(); if (CRM_Core_Permission::check('edit event participants')) { $recentOther['editUrl'] = CRM_Utils_System::url('civicrm/contact/view/participant', "action=update&reset=1&id={$participant->id}&cid={$participant->contact_id}&context=home"); } if (CRM_Core_Permission::check('delete in CiviEvent')) { $recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/contact/view/participant', "action=delete&reset=1&id={$participant->id}&cid={$participant->contact_id}&context=home"); } $participantRoles = CRM_Event_PseudoConstant::participantRole(); if ($participant->role_id) { $role = explode(CRM_Core_DAO::VALUE_SEPARATOR, $participant->role_id); foreach ($role as $roleKey => $roleValue) { if (isset($roles)) { $roles .= ", " . $participantRoles[$roleValue]; } else { $roles = $participantRoles[$roleValue]; } } } $eventTitle = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $participant->event_id, 'title'); $title = CRM_Contact_BAO_Contact::displayName($participant->contact_id) . ' (' . $roles . ' - ' . $eventTitle . ')'; // add the recently created Participant CRM_Utils_Recent::add($title, $url, $participant->id, 'Participant', $participant->contact_id, null, $recentOther); } return $participant; }
function logVersion($version = null) { if (!$version) { $version = CRM_Core_BAO_Domain::version(); } if ($version) { require_once 'CRM/Core/BAO/Log.php'; $session =& CRM_Core_Session::singleton(); $logParams = array('entity_table' => 'civicrm_domain', 'entity_id' => 1, 'data' => "version,{$version}", 'modified_date' => date('YmdHis')); CRM_Core_BAO_Log::add($logParams); return true; } return false; }
/** * Create the event. * * @param array $params * Reference array contains the values submitted by the form. * @param array $ids * Reference array contains the id. * * @return object */ public static function create(&$params, &$ids) { $transaction = new CRM_Core_Transaction(); $grant = self::add($params, $ids); if (is_a($grant, 'CRM_Core_Error')) { $transaction->rollback(); return $grant; } $session = CRM_Core_Session::singleton(); $id = $session->get('userID'); if (!$id) { $id = CRM_Utils_Array::value('contact_id', $params); } if (!empty($params['note']) || CRM_Utils_Array::value('id', CRM_Utils_Array::value('note', $ids))) { $noteParams = array('entity_table' => 'civicrm_grant', 'note' => $params['note'] = $params['note'] ? $params['note'] : "null", 'entity_id' => $grant->id, 'contact_id' => $id, 'modified_date' => date('Ymd')); CRM_Core_BAO_Note::add($noteParams, (array) CRM_Utils_Array::value('note', $ids)); } // Log the information on successful add/edit of Grant $logParams = array('entity_table' => 'civicrm_grant', 'entity_id' => $grant->id, 'modified_id' => $id, 'modified_date' => date('Ymd')); CRM_Core_BAO_Log::add($logParams); // add custom field values if (!empty($params['custom']) && is_array($params['custom'])) { CRM_Core_BAO_CustomValueTable::store($params['custom'], 'civicrm_grant', $grant->id); } // check and attach and files as needed CRM_Core_BAO_File::processAttachment($params, 'civicrm_grant', $grant->id); $transaction->commit(); return $grant; }
public function logActivityAction($activity, $logMessage = null) { $session =& CRM_Core_Session::singleton(); $id = $session->get('userID'); require_once 'CRM/Core/BAO/Log.php'; $logParams = array('entity_table' => 'civicrm_activity', 'entity_id' => $activity->id, 'modified_id' => $id, 'modified_date' => date('YmdHis'), 'data' => $logMessage); CRM_Core_BAO_Log::add($logParams); return true; }
/** * takes an associative array and creates a case object * * @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_Case_BAO_Case object * @access public * @static */ static function &create(&$params) { require_once 'CRM/Core/Transaction.php'; $transaction = new CRM_Core_Transaction(); $case = self::add($params); if (is_a($case, 'CRM_Core_Error')) { $transaction->rollback(); return $case; } $session =& CRM_Core_Session::singleton(); $id = $session->get('userID'); if (!$id) { $id = $params['contact_id']; } // Log the information on successful add/edit of Case require_once 'CRM/Core/BAO/Log.php'; $logParams = array('entity_table' => 'civicrm_case', 'entity_id' => $case->id, 'modified_id' => $id, 'modified_date' => date('Ymd')); CRM_Core_BAO_Log::add($logParams); $transaction->commit(); return $case; }
/** * @param $newVersion * * @return bool */ public function logVersion($newVersion) { if ($newVersion) { $oldVersion = CRM_Core_BAO_Domain::version(); $session = CRM_Core_Session::singleton(); $logParams = array('entity_table' => 'civicrm_domain', 'entity_id' => 1, 'data' => "upgrade:{$oldVersion}->{$newVersion}", 'modified_date' => date('YmdHis')); CRM_Core_BAO_Log::add($logParams); return TRUE; } return FALSE; }
public static function logActivityAction($activity, $logMessage = NULL) { $session = CRM_Core_Session::singleton(); $id = $session->get('userID'); if (!$id) { $id = $activity->source_contact_id; } $logParams = array('entity_table' => 'civicrm_activity', 'entity_id' => $activity->id, 'modified_id' => $id, 'modified_date' => date('YmdHis'), 'data' => $logMessage); CRM_Core_BAO_Log::add($logParams); return TRUE; }