本文整理汇总了PHP中CRM_Core_BAO_Log类的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_Log类的具体用法?PHP CRM_Core_BAO_Log怎么用?PHP CRM_Core_BAO_Log使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRM_Core_BAO_Log类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: browse
/**
* This function is called when action is browse
*
* return null
* @access public
*/
function browse()
{
$loggingReport = CRM_Core_BAO_Log::useLoggingReport();
$this->assign('useLogging', $loggingReport);
if ($loggingReport) {
$this->assign('instanceUrl', CRM_Utils_System::url("civicrm/report/instance/{$loggingReport}", "reset=1&force=1&snippet=4§ion=2&altered_contact_id_op=eq&altered_contact_id_value={$this->_contactId}&cid={$this->_contactId}", FALSE, NULL, FALSE));
return;
}
$log = new CRM_Core_DAO_Log();
$log->entity_table = 'civicrm_contact';
$log->entity_id = $this->_contactId;
$log->orderBy('modified_date desc');
$log->find();
$logEntries = array();
while ($log->fetch()) {
list($displayName, $contactImage) = CRM_Contact_BAO_Contact::getDisplayAndImage($log->modified_id);
$logEntries[] = array('id' => $log->modified_id, 'name' => $displayName, 'image' => $contactImage, 'date' => $log->modified_date);
}
$this->assign('logCount', count($logEntries));
$this->assign_by_ref('log', $logEntries);
}
示例2: updateContactEmail
/**
* Update the email value for the contact and user profile.
*
* @param int $contactId
* Contact ID of the user.
* @param string $emailAddress
* Email to be modified for the user.
*/
public static function updateContactEmail($contactId, $emailAddress)
{
$strtolower = function_exists('mb_strtolower') ? 'mb_strtolower' : 'strtolower';
$emailAddress = $strtolower($emailAddress);
$ufmatch = new CRM_Core_DAO_UFMatch();
$ufmatch->contact_id = $contactId;
$ufmatch->domain_id = CRM_Core_Config::domainID();
if ($ufmatch->find(TRUE)) {
// Save the email in UF Match table
$ufmatch->uf_name = $emailAddress;
CRM_Core_BAO_UFMatch::create((array) $ufmatch);
//check if the primary email for the contact exists
//$contactDetails[1] - email
//$contactDetails[3] - email id
$contactDetails = CRM_Contact_BAO_Contact_Location::getEmailDetails($contactId);
if (trim($contactDetails[1])) {
$emailID = $contactDetails[3];
//update if record is found
$query = "UPDATE civicrm_email\n SET email = %1\n WHERE id = %2";
$p = array(1 => array($emailAddress, 'String'), 2 => array($emailID, 'Integer'));
$dao = CRM_Core_DAO::executeQuery($query, $p);
} else {
//else insert a new email record
$email = new CRM_Core_DAO_Email();
$email->contact_id = $contactId;
$email->is_primary = 1;
$email->email = $emailAddress;
$email->save();
$emailID = $email->id;
}
CRM_Core_BAO_Log::register($contactId, 'civicrm_email', $emailID);
}
}
示例3: CRM_Core_Transaction
/**
* 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;
}
示例4: create
/**
* 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;
}
示例5: response
/**
* Common function for all inline contact edit forms
* Prepares ajaxResponse
*
* @return void
* @protected
*/
protected function response()
{
// Load changelog footer from template
$smarty = CRM_Core_Smarty::singleton();
$smarty->assign('contactId', $this->_contactId);
$smarty->assign('external_identifier', CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_contactId, 'external_identifier'));
$smarty->assign('lastModified', CRM_Core_BAO_Log::lastModified($this->_contactId, 'civicrm_contact'));
$viewOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_view_options', TRUE);
$smarty->assign('changeLog', $viewOptions['log']);
$this->ajaxResponse = array_merge(array('changeLog' => array('count' => CRM_Contact_BAO_Contact::getCountComponent('log', $this->_contactId), 'markup' => $smarty->fetch('CRM/common/contactFooter.tpl'))), $this->ajaxResponse, CRM_Contact_Form_Inline_Lock::getResponse($this->_contactId));
// Note: Post hooks will be called by CRM_Core_Form::mainProcess
}
示例6: postProcess
/**
* process the form
*
* @return void
* @access public
*/
public function postProcess()
{
$params = $this->exportValues();
// need to process / save address
$params['contact_id'] = $this->_contactId;
$params['updateBlankLocInfo'] = TRUE;
// process shared contact address.
CRM_Contact_BAO_Contact_Utils::processSharedAddress($params['address']);
if ($this->_parseStreetAddress) {
CRM_Contact_Form_Contact::parseAddress($params);
}
if ($this->_addressId > 0) {
$params['address'][$this->_locBlockNo]['id'] = $this->_addressId;
}
// save address changes
$address = CRM_Core_BAO_Address::create($params, TRUE);
// make entry in log table
CRM_Core_BAO_Log::register($this->_contactId, 'civicrm_contact', $this->_contactId);
$response = array('status' => 'save', 'addressId' => $address[0]->id);
$this->postProcessHook();
echo json_encode($response);
CRM_Utils_System::civiExit();
}
示例7: add
/**
* 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
*
* @return object CRM_Contact_BAO_Contact object
* @access public
* @static
*/
static function add(&$params)
{
$contact =& new CRM_Contact_DAO_Contact();
if (empty($params)) {
return;
}
//fixed contact source
if (isset($params['contact_source'])) {
$params['source'] = $params['contact_source'];
}
//fix for preferred communication method
$prefComm = CRM_Utils_Array::value('preferred_communication_method', $params);
if ($prefComm && is_array($prefComm)) {
unset($params['preferred_communication_method']);
$newPref = array();
foreach ($prefComm as $k => $v) {
if ($v) {
$newPref[$k] = $v;
}
}
$prefComm = $newPref;
if (is_array($prefComm) && !empty($prefComm)) {
$prefComm = CRM_Core_BAO_CustomOption::VALUE_SEPERATOR . implode(CRM_Core_BAO_CustomOption::VALUE_SEPERATOR, array_keys($prefComm)) . CRM_Core_BAO_CustomOption::VALUE_SEPERATOR;
$contact->preferred_communication_method = $prefComm;
} else {
$contact->preferred_communication_method = '';
}
}
$allNull = $contact->copyValues($params);
$contact->id = CRM_Utils_Array::value('contact_id', $params);
if ($contact->contact_type == 'Individual') {
$allNull = false;
//format individual fields
require_once "CRM/Contact/BAO/Individual.php";
CRM_Contact_BAO_Individual::format($params, $contact);
} else {
if ($contact->contact_type == 'Household') {
if (isset($params['household_name'])) {
$allNull = false;
$contact->display_name = $contact->sort_name = CRM_Utils_Array::value('household_name', $params, '');
}
} else {
if ($contact->contact_type == 'Organization') {
if (isset($params['organization_name'])) {
$allNull = false;
$contact->display_name = $contact->sort_name = CRM_Utils_Array::value('organization_name', $params, '');
}
}
}
}
// privacy block
$privacy = CRM_Utils_Array::value('privacy', $params);
if ($privacy && is_array($privacy) && !empty($privacy)) {
$allNull = false;
foreach (self::$_commPrefs as $name) {
$contact->{$name} = CRM_Utils_Array::value($name, $privacy, false);
}
}
// since hash was required, make sure we have a 0 value for it, CRM-1063
// fixed in 1.5 by making hash optional
// only do this in create mode, not update
if ((!array_key_exists('hash', $contact) || !$contact->hash) && !$contact->id) {
$allNull = false;
$contact->hash = md5(uniqid(rand(), true));
}
if (!$allNull) {
$contact->save();
require_once 'CRM/Core/BAO/Log.php';
CRM_Core_BAO_Log::register($contact->id, 'civicrm_contact', $contact->id);
}
if ($contact->contact_type == 'Individual' && array_key_exists('current_employer', $params)) {
// create current employer
if ($params['current_employer']) {
require_once 'CRM/Contact/BAO/Contact/Utils.php';
CRM_Contact_BAO_Contact_Utils::createCurrentEmployerRelationship($contact->id, $params['current_employer']);
} else {
//unset if employer id exits
if ($employerId = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $contact->id, 'employer_id')) {
require_once 'CRM/Contact/BAO/Contact/Utils.php';
CRM_Contact_BAO_Contact_Utils::clearCurrentEmployer($contact->id, $employerId);
}
}
}
//update cached employee name
if ($contact->contact_type == 'Organization') {
require_once 'CRM/Contact/BAO/Contact/Utils.php';
CRM_Contact_BAO_Contact_Utils::updateCurrentEmployer($contact->id);
//.........这里部分代码省略.........
示例8: CRM_Core_Transaction
/**
* 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;
}
示例9: add
/**
* Takes an associative array and creates a note object.
*
* the function extract all the params it needs to initialize the create a
* note 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
* (deprecated) associated array with note id - preferably set $params['id'].
*
* @return object
* $note CRM_Core_BAO_Note object
*/
public static function add(&$params, $ids = array())
{
$dataExists = self::dataExists($params);
if (!$dataExists) {
return CRM_Core_DAO::$_nullObject;
}
$note = new CRM_Core_BAO_Note();
if (!isset($params['modified_date'])) {
$params['modified_date'] = date("Ymd");
}
if (!isset($params['privacy'])) {
$params['privacy'] = 0;
}
$note->copyValues($params);
if (empty($params['contact_id'])) {
if ($params['entity_table'] == 'civicrm_contact') {
$note->contact_id = $params['entity_id'];
}
}
$id = CRM_Utils_Array::value('id', $params, CRM_Utils_Array::value('id', $ids));
if ($id) {
$note->id = $id;
}
$note->save();
// check and attach and files as needed
CRM_Core_BAO_File::processAttachment($params, 'civicrm_note', $note->id);
if ($note->entity_table == 'civicrm_contact') {
CRM_Core_BAO_Log::register($note->entity_id, 'civicrm_note', $note->id);
$displayName = CRM_Contact_BAO_Contact::displayName($note->entity_id);
$noteActions = FALSE;
$session = CRM_Core_Session::singleton();
if ($session->get('userID')) {
if ($session->get('userID') == $note->entity_id) {
$noteActions = TRUE;
} elseif (CRM_Contact_BAO_Contact_Permission::allow($note->entity_id, CRM_Core_Permission::EDIT)) {
$noteActions = TRUE;
}
}
$recentOther = array();
if ($noteActions) {
$recentOther = array('editUrl' => CRM_Utils_System::url('civicrm/contact/view/note', "reset=1&action=update&cid={$note->entity_id}&id={$note->id}&context=home"), 'deleteUrl' => CRM_Utils_System::url('civicrm/contact/view/note', "reset=1&action=delete&cid={$note->entity_id}&id={$note->id}&context=home"));
}
// add the recently created Note
CRM_Utils_Recent::add($displayName . ' - ' . $note->subject, CRM_Utils_System::url('civicrm/contact/view/note', "reset=1&action=view&cid={$note->entity_id}&id={$note->id}&context=home"), $note->id, 'Note', $note->entity_id, $displayName, $recentOther);
}
return $note;
}
示例10: response
/**
* Final response from successful form submit
*
* @param response: array - data to send to the client
*
* @return void
* @protected
*/
protected function response($response = array())
{
// Load changelog footer from template
$smarty = CRM_Core_Smarty::singleton();
$smarty->assign('contactId', $this->_contactId);
$smarty->assign('external_identifier', CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_contactId, 'external_identifier'));
$smarty->assign('lastModified', CRM_Core_BAO_Log::lastModified($this->_contactId, 'civicrm_contact'));
$viewOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_view_options', TRUE);
$smarty->assign('changeLog', $viewOptions['log']);
$response = array_merge(array('status' => 'save', 'changeLog' => array('count' => CRM_Contact_BAO_Contact::getCountComponent('log', $this->_contactId), 'markup' => $smarty->fetch('CRM/common/contactFooter.tpl'))), $response, CRM_Contact_Form_Inline_Lock::getResponse($this->_contactId));
$this->postProcessHook();
// CRM-11831 @see http://www.malsup.com/jquery/form/#file-upload
$xhr = isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest';
if (!$xhr) {
echo '<textarea>';
}
echo json_encode($response);
if (!$xhr) {
echo '</textarea>';
}
CRM_Utils_System::civiExit();
}
示例11: postProcess
/**
* process the form
*
* @return void
* @access public
*/
public function postProcess()
{
$params = $this->exportValues();
// need to process / save emails
$params['contact_id'] = $this->_contactId;
$params['updateBlankLocInfo'] = TRUE;
// save email changes
CRM_Core_BAO_Block::create('email', $params);
// make entry in log table
CRM_Core_BAO_Log::register($this->_contactId, 'civicrm_contact', $this->_contactId);
$response = array('status' => 'save');
$this->postProcessHook();
echo json_encode($response);
CRM_Utils_System::civiExit();
}
示例12: logVersion
/**
* @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;
}
示例13: CRM_Core_BAO_Note
/**
* takes an associative array and creates a note object
*
* the function extract all the params it needs to initialize the create a
* note object. the params array could contain additional unused name/value
* pairs
*
* @param array $params (reference ) an assoc array of name/value pairs
*
* @return object CRM_Core_BAO_Note object
* @access public
* @static
*/
static function &add(&$params, $ids)
{
$dataExists = self::dataExists($params);
if (!$dataExists) {
return CRM_Core_DAO::$_nullObject;
}
$note =& new CRM_Core_BAO_Note();
$params['modified_date'] = date("Ymd");
$note->copyValues($params);
if (!$params['contact_id']) {
if ($params['entity_table'] == 'civicrm_contact') {
$note->contact_id = $params['entity_id'];
} else {
CRM_Core_Error::statusBounce(ts('We could not find your logged in user ID'));
}
}
if (CRM_Utils_Array::value('id', $ids)) {
$note->id = CRM_Utils_Array::value('id', $ids);
}
$note->save();
if ($note->entity_table == 'civicrm_contact') {
require_once 'CRM/Core/BAO/Log.php';
CRM_Core_BAO_Log::register($note->entity_id, 'civicrm_note', $note->id);
require_once 'CRM/Contact/BAO/Contact.php';
$displayName = CRM_Contact_BAO_Contact::displayName($note->entity_id);
// add the recently created Note
require_once 'CRM/Utils/Recent.php';
CRM_Utils_Recent::add($displayName . ' - ' . $note->subject, CRM_Utils_System::url('civicrm/contact/view/note', "reset=1&action=view&cid={$note->entity_id}&id={$note->id}&context=home"), $note->id, 'Note', $note->entity_id, $displayName);
}
return $note;
}
示例14: CRM_Core_BAO_Note
/**
* takes an associative array and creates a note object
*
* the function extract all the params it needs to initialize the create a
* note object. the params array could contain additional unused name/value
* pairs
*
* @param array $params (reference ) an assoc array of name/value pairs
*
* @return object CRM_Core_BAO_Note object
* @access public
* @static
*/
static function &add(&$params, $ids)
{
$dataExists = self::dataExists($params);
if (!$dataExists) {
return CRM_Core_DAO::$_nullObject;
}
$note = new CRM_Core_BAO_Note();
if (!isset($params['modified_date'])) {
$params['modified_date'] = date("Ymd");
}
if (!isset($params['privacy'])) {
$params['privacy'] = 0;
}
$note->copyValues($params);
if (!$params['contact_id']) {
if ($params['entity_table'] == 'civicrm_contact') {
$note->contact_id = $params['entity_id'];
} else {
CRM_Core_Error::statusBounce(ts('We could not find your logged in user ID'));
}
}
if (CRM_Utils_Array::value('id', $ids)) {
$note->id = CRM_Utils_Array::value('id', $ids);
}
$note->save();
if ($note->entity_table == 'civicrm_contact') {
require_once 'CRM/Core/BAO/Log.php';
CRM_Core_BAO_Log::register($note->entity_id, 'civicrm_note', $note->id);
require_once 'CRM/Contact/BAO/Contact.php';
$displayName = CRM_Contact_BAO_Contact::displayName($note->entity_id);
$noteActions = false;
$session = CRM_Core_Session::singleton();
if ($session->get('userID')) {
require_once 'CRM/Contact/BAO/Contact/Permission.php';
if ($session->get('userID') == $note->entity_id) {
$noteActions = true;
} else {
if (CRM_Contact_BAO_Contact_Permission::allow($note->entity_id, CRM_Core_Permission::EDIT)) {
$noteActions = true;
}
}
}
$recentOther = array();
if ($noteActions) {
$recentOther = array('editUrl' => CRM_Utils_System::url('civicrm/contact/view/note', "reset=1&action=update&cid={$note->entity_id}&id={$note->id}&context=home"), 'deleteUrl' => CRM_Utils_System::url('civicrm/contact/view/note', "reset=1&action=delete&cid={$note->entity_id}&id={$note->id}&context=home"));
}
// add the recently created Note
require_once 'CRM/Utils/Recent.php';
CRM_Utils_Recent::add($displayName . ' - ' . $note->subject, CRM_Utils_System::url('civicrm/contact/view/note', "reset=1&action=view&cid={$note->entity_id}&id={$note->id}&context=home"), $note->id, 'Note', $note->entity_id, $displayName, $recentOther);
}
return $note;
}
示例15: postProcess
/**
* Process the user submitted custom data values.
*/
public function postProcess()
{
// Get the form values and groupTree
//CRM-18183
$params = $this->controller->exportValues($this->_name);
CRM_Core_BAO_CustomValueTable::postProcess($params, 'civicrm_contact', $this->_tableID, $this->_entityType);
$table = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $this->_groupID, 'table_name');
$cgcount = CRM_Core_BAO_CustomGroup::customGroupDataExistsForEntity($this->_tableID, $table, TRUE);
$cgcount += 1;
$buttonName = $this->controller->getButtonName();
if ($buttonName == $this->getButtonName('upload', 'new')) {
CRM_Core_Session::singleton()->pushUserContext(CRM_Utils_System::url('civicrm/contact/view/cd/edit', "reset=1&type={$this->_contactType}&groupID={$this->_groupID}&entityID={$this->_tableID}&cgcount={$cgcount}&multiRecordDisplay=single&mode=add"));
}
// Add entry in the log table
CRM_Core_BAO_Log::register($this->_tableID, 'civicrm_contact', $this->_tableID);
if (CRM_Core_Resources::isAjaxMode()) {
$this->ajaxResponse += CRM_Contact_Form_Inline::renderFooter($this->_tableID);
}
// reset the group contact cache for this group
CRM_Contact_BAO_GroupContactCache::remove();
}