本文整理汇总了PHP中CRM_Core_BAO_Note::save方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_Note::save方法的具体用法?PHP CRM_Core_BAO_Note::save怎么用?PHP CRM_Core_BAO_Note::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_BAO_Note
的用法示例。
在下文中一共展示了CRM_Core_BAO_Note::save方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: date
/**
* 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;
}