本文整理汇总了PHP中CRM_Core_PseudoConstant::priority方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_PseudoConstant::priority方法的具体用法?PHP CRM_Core_PseudoConstant::priority怎么用?PHP CRM_Core_PseudoConstant::priority使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_PseudoConstant
的用法示例。
在下文中一共展示了CRM_Core_PseudoConstant::priority方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _civicrm_activity_check_params
/**
* Function to check for required params
*
* @param array $params associated array of fields
* @param boolean $addMode true for add mode
*
* @return array $error array with errors
*/
function _civicrm_activity_check_params(&$params, $addMode = false)
{
// return error if we do not get any params
if (empty($params)) {
return civicrm_create_error(ts('Input Parameters empty'));
}
$contactIds = array('source' => CRM_Utils_Array::value('source_contact_id', $params), 'assignee' => CRM_Utils_Array::value('assignee_contact_id', $params), 'target' => CRM_Utils_Array::value('target_contact_id', $params));
foreach ($contactIds as $key => $value) {
if (empty($value)) {
continue;
}
$valueIds = array($value);
if (is_array($value)) {
$valueIds = array();
foreach ($value as $id) {
if ($id) {
$valueIds[$id] = $id;
}
}
}
if (empty($valueIds)) {
continue;
}
$sql = '
SELECT count(*)
FROM civicrm_contact
WHERE id IN (' . implode(', ', $valueIds) . ' )';
if (count($valueIds) != CRM_Core_DAO::singleValueQuery($sql)) {
return civicrm_create_error(ts('Invalid %1 Contact Id', array(1 => ucfirst($key))));
}
}
$activityIds = array('activity' => CRM_Utils_Array::value('id', $params), 'parent' => CRM_Utils_Array::value('parent_id', $params), 'original' => CRM_Utils_Array::value('original_id', $params));
foreach ($activityIds as $id => $value) {
if ($value && !CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $value, 'id')) {
return civicrm_create_error(ts('Invalid %1 Id', array(1 => ucfirst($id))));
}
}
// check for activity subject if add mode
if ($addMode && !isset($params['subject'])) {
return civicrm_create_error(ts('Missing Subject'));
}
if (!$addMode && !isset($params['id'])) {
return civicrm_create_error(ts('Required parameter "id" not found'));
}
if (!$addMode && $params['id'] && !is_numeric($params['id'])) {
return civicrm_create_error(ts('Invalid activity "id"'));
}
require_once 'CRM/Core/PseudoConstant.php';
$activityTypes = CRM_Core_PseudoConstant::activityType(true, true, true, 'name');
// check if activity type_id is passed in
if ($addMode && !isset($params['activity_name']) && !isset($params['activity_type_id'])) {
//when name AND id are both absent
return civicrm_create_error(ts('Missing Activity Type'));
} else {
$activityName = CRM_Utils_Array::value('activity_name', $params);
$activityTypeId = CRM_Utils_Array::value('activity_type_id', $params);
if ($activityName) {
$activityNameId = array_search(ucfirst($activityName), $activityTypes);
if (!$activityNameId) {
return civicrm_create_error(ts('Invalid Activity Name'));
} else {
if ($activityTypeId && $activityTypeId != $activityNameId) {
return civicrm_create_error(ts('Mismatch in Activity'));
}
}
$params['activity_type_id'] = $activityNameId;
} else {
if ($activityTypeId && !array_key_exists($activityTypeId, $activityTypes)) {
return civicrm_create_error(ts('Invalid Activity Type ID'));
}
}
}
// check for activity status is passed in
if (isset($params['status_id'])) {
require_once "CRM/Core/PseudoConstant.php";
$activityStatus = CRM_Core_PseudoConstant::activityStatus();
if (is_numeric($params['status_id']) && !array_key_exists($params['status_id'], $activityStatus)) {
return civicrm_create_error(ts('Invalid Activity Status'));
} elseif (!is_numeric($params['status_id'])) {
$statusId = array_search($params['status_id'], $activityStatus);
if (!is_numeric($statusId)) {
return civicrm_create_error(ts('Invalid Activity Status'));
}
}
}
if (isset($params['priority_id']) && is_numeric($params['priority_id'])) {
require_once "CRM/Core/PseudoConstant.php";
$activityPriority = CRM_Core_PseudoConstant::priority();
if (!array_key_exists($params['priority_id'], $activityStatus)) {
return civicrm_create_error(ts('Invalid Priority'));
}
}
//.........这里部分代码省略.........
示例2: getCaseActivity
/**
* Function to get Case Activities
*
* @param int $caseID case id
* @param array $params posted params
* @param int $contactID contact id
*
* @return returns case activities
*
* @static
*/
static function getCaseActivity($caseID, &$params, $contactID)
{
$values = array();
$select = 'SELECT count(ca.id) as ismultiple, ca.id as id,
ca.activity_type_id as type,
cc.sort_name as reporter,
cc.id as reporter_id,
acc.sort_name AS assignee,
acc.id AS assignee_id,
IF(ca.activity_date_time < NOW() AND ca.status_id=ov.value,
ca.activity_date_time,
DATE_ADD(NOW(), INTERVAL 1 YEAR)
) as overdue_date,
ca.activity_date_time as display_date,
ca.status_id as status,
ca.subject as subject,
ca.is_deleted as deleted,
ca.priority_id as priority ';
$from = 'FROM civicrm_case_activity cca
INNER JOIN civicrm_activity ca ON ca.id = cca.activity_id
INNER JOIN civicrm_contact cc ON cc.id = ca.source_contact_id
LEFT OUTER JOIN civicrm_option_group og ON og.name="activity_status"
LEFT OUTER JOIN civicrm_option_value ov ON ov.option_group_id=og.id AND ov.name="Scheduled"
LEFT JOIN civicrm_activity_assignment caa
ON caa.activity_id = ca.id
LEFT JOIN civicrm_contact acc ON acc.id = caa.assignee_contact_id ';
$where = 'WHERE cca.case_id= %1
AND ca.is_current_revision = 1';
if (CRM_Utils_Array::value('reporter_id', $params)) {
$where .= " AND ca.source_contact_id = " . CRM_Utils_Type::escape($params['reporter_id'], 'Integer');
}
if (CRM_Utils_Array::value('status_id', $params)) {
$where .= " AND ca.status_id = " . CRM_Utils_Type::escape($params['status_id'], 'Integer');
}
if (CRM_Utils_Array::value('activity_deleted', $params)) {
$where .= " AND ca.is_deleted = 1";
} else {
$where .= " AND ca.is_deleted = 0";
}
if (CRM_Utils_Array::value('activity_type_id', $params)) {
$where .= " AND ca.activity_type_id = " . CRM_Utils_Type::escape($params['activity_type_id'], 'Integer');
}
if (CRM_Utils_Array::value('activity_date_low', $params)) {
$fromActivityDate = CRM_Utils_Type::escape(CRM_Utils_Date::processDate($params['activity_date_low']), 'Date');
}
if (CRM_Utils_Array::value('activity_date_high', $params)) {
$toActivityDate = CRM_Utils_Type::escape(CRM_Utils_Date::processDate($params['activity_date_high']), 'Date');
$toActivityDate = $toActivityDate ? $toActivityDate + 235959 : null;
}
if (!empty($fromActivityDate)) {
$where .= " AND ca.activity_date_time >= '{$fromActivityDate}'";
}
if (!empty($toActivityDate)) {
$where .= " AND ca.activity_date_time <= '{$toActivityDate}'";
}
// hack to handle to allow initial sorting to be done by query
if (CRM_Utils_Array::value('sortname', $params) == 'undefined') {
$params['sortname'] = null;
}
if (CRM_Utils_Array::value('sortorder', $params) == 'undefined') {
$params['sortorder'] = null;
}
$sortname = CRM_Utils_Array::value('sortname', $params);
$sortorder = CRM_Utils_Array::value('sortorder', $params);
$groupBy = " GROUP BY ca.id ";
if (!$sortname and !$sortorder) {
$orderBy = " ORDER BY overdue_date ASC, display_date DESC";
} else {
$orderBy = " ORDER BY {$sortname} {$sortorder}, display_date DESC";
}
$page = CRM_Utils_Array::value('page', $params);
$rp = CRM_Utils_Array::value('rp', $params);
if (!$page) {
$page = 1;
}
if (!$rp) {
$rp = 10;
}
$start = ($page - 1) * $rp;
$query = $select . $from . $where . $groupBy . $orderBy;
$params = array(1 => array($caseID, 'Integer'));
$dao =& CRM_Core_DAO::executeQuery($query, $params);
$params['total'] = $dao->N;
//FIXME: need to optimize/cache these queries
$limit = " LIMIT {$start}, {$rp}";
$query .= $limit;
$dao =& CRM_Core_DAO::executeQuery($query, $params);
$activityTypes = CRM_Case_PseudoConstant::activityType(false, true);
require_once "CRM/Utils/Date.php";
//.........这里部分代码省略.........
示例3: getCaseActivity
/**
* Function to get Case Activities
*
* @param int $caseID case id
* @param array $params posted params
* @param int $contactID contact id
*
* @return returns case activities
*
* @static
*/
static function getCaseActivity($caseID, &$params, $contactID, $context = NULL, $userID = NULL, $type = NULL)
{
$values = array();
// CRM-5081 - formatting the dates to omit seconds.
// Note the 00 in the date format string is needed otherwise later on it thinks scheduled ones are overdue.
$select = "SELECT count(ca.id) as ismultiple, ca.id as id, \n ca.activity_type_id as type,\n ca.activity_type_id as activity_type_id, \n cc.sort_name as reporter,\n cc.id as reporter_id,\n acc.sort_name AS assignee,\n acc.id AS assignee_id,\n DATE_FORMAT(IF(ca.activity_date_time < NOW() AND ca.status_id=ov.value,\n ca.activity_date_time,\n DATE_ADD(NOW(), INTERVAL 1 YEAR)\n ), '%Y%m%d%H%i00') as overdue_date,\n DATE_FORMAT(ca.activity_date_time, '%Y%m%d%H%i00') as display_date,\n ca.status_id as status, \n ca.subject as subject, \n ca.is_deleted as deleted,\n ca.priority_id as priority,\n ca.weight as weight ";
$from = 'FROM civicrm_case_activity cca
INNER JOIN civicrm_activity ca ON ca.id = cca.activity_id
INNER JOIN civicrm_contact cc ON cc.id = ca.source_contact_id
INNER JOIN civicrm_option_group cog ON cog.name = "activity_type"
INNER JOIN civicrm_option_value cov ON cov.option_group_id = cog.id
AND cov.value = ca.activity_type_id AND cov.is_active = 1
LEFT OUTER JOIN civicrm_option_group og ON og.name="activity_status"
LEFT OUTER JOIN civicrm_option_value ov ON ov.option_group_id=og.id AND ov.name="Scheduled"
LEFT JOIN civicrm_activity_assignment caa
ON caa.activity_id = ca.id
LEFT JOIN civicrm_contact acc ON acc.id = caa.assignee_contact_id ';
$where = 'WHERE cca.case_id= %1
AND ca.is_current_revision = 1';
if (CRM_Utils_Array::value('reporter_id', $params)) {
$where .= " AND ca.source_contact_id = " . CRM_Utils_Type::escape($params['reporter_id'], 'Integer');
}
if (CRM_Utils_Array::value('status_id', $params)) {
$where .= " AND ca.status_id = " . CRM_Utils_Type::escape($params['status_id'], 'Integer');
}
if (CRM_Utils_Array::value('activity_deleted', $params)) {
$where .= " AND ca.is_deleted = 1";
} else {
$where .= " AND ca.is_deleted = 0";
}
if (CRM_Utils_Array::value('activity_type_id', $params)) {
$where .= " AND ca.activity_type_id = " . CRM_Utils_Type::escape($params['activity_type_id'], 'Integer');
}
if (CRM_Utils_Array::value('activity_date_low', $params)) {
$fromActivityDate = CRM_Utils_Type::escape(CRM_Utils_Date::processDate($params['activity_date_low']), 'Date');
}
if (CRM_Utils_Array::value('activity_date_high', $params)) {
$toActivityDate = CRM_Utils_Type::escape(CRM_Utils_Date::processDate($params['activity_date_high']), 'Date');
$toActivityDate = $toActivityDate ? $toActivityDate + 235959 : NULL;
}
if (!empty($fromActivityDate)) {
$where .= " AND ca.activity_date_time >= '{$fromActivityDate}'";
}
if (!empty($toActivityDate)) {
$where .= " AND ca.activity_date_time <= '{$toActivityDate}'";
}
// hack to handle to allow initial sorting to be done by query
if (CRM_Utils_Array::value('sortname', $params) == 'undefined') {
$params['sortname'] = NULL;
}
if (CRM_Utils_Array::value('sortorder', $params) == 'undefined') {
$params['sortorder'] = NULL;
}
$sortname = CRM_Utils_Array::value('sortname', $params);
$sortorder = CRM_Utils_Array::value('sortorder', $params);
$groupBy = " GROUP BY ca.id ";
if (!$sortname and !$sortorder) {
// CRM-5081 - added id to act like creation date
$orderBy = " ORDER BY overdue_date ASC, display_date DESC, weight DESC";
} else {
$orderBy = " ORDER BY {$sortname} {$sortorder}";
if ($sortname != 'display_date') {
$orderBy .= ', display_date DESC';
}
}
$page = CRM_Utils_Array::value('page', $params);
$rp = CRM_Utils_Array::value('rp', $params);
if (!$page) {
$page = 1;
}
if (!$rp) {
$rp = 10;
}
$start = ($page - 1) * $rp;
$query = $select . $from . $where . $groupBy . $orderBy;
$params = array(1 => array($caseID, 'Integer'));
$dao = CRM_Core_DAO::executeQuery($query, $params);
$params['total'] = $dao->N;
//FIXME: need to optimize/cache these queries
$limit = " LIMIT {$start}, {$rp}";
$query .= $limit;
$dao = CRM_Core_DAO::executeQuery($query, $params);
$activityTypes = CRM_Case_PseudoConstant::caseActivityType(FALSE, TRUE);
$activityStatus = CRM_Core_PseudoConstant::activityStatus();
$activityPriority = CRM_Core_PseudoConstant::priority();
$url = CRM_Utils_System::url("civicrm/case/activity", "reset=1&cid={$contactID}&caseid={$caseID}", FALSE, NULL, FALSE);
$contextUrl = '';
if ($context == 'fulltext') {
$contextUrl = "&context={$context}";
//.........这里部分代码省略.........
示例4:
/**
* Get all Priorities
*
* The static array Priority is returned
*
* @access public
* @static
* @return array - array reference of all Priority
*/
public static function &priority()
{
if (!self::$priority) {
require_once 'CRM/Core/OptionGroup.php';
self::$priority = CRM_Core_OptionGroup::values('priority');
}
return self::$priority;
}
示例5: setDefaultValues
/**
* This function sets the default values for the form. For edit/view mode
* the default values are retrieved from the database
*
* @access public
* @return None
*/
function setDefaultValues()
{
if ($this->_cdType) {
return CRM_Custom_Form_CustomData::setDefaultValues($this);
}
$defaults = array();
$params = array();
$config =& CRM_Core_Config::singleton();
// if we're editing...
if (isset($this->_activityId)) {
$params = array('id' => $this->_activityId);
CRM_Activity_BAO_Activity::retrieve($params, $defaults);
$defaults['source_contact_qid'] = $defaults['source_contact_id'];
$defaults['source_contact_id'] = $defaults['source_contact'];
if (!CRM_Utils_Array::crmIsEmptyArray($defaults['target_contact'])) {
$target_contact_value = explode(';', trim($defaults['target_contact_value']));
$this->assign('target_contact', array_combine(array_unique($defaults['target_contact']), $target_contact_value));
}
if (!CRM_Utils_Array::crmIsEmptyArray($defaults['assignee_contact'])) {
$assignee_contact_value = explode(';', trim($defaults['assignee_contact_value']));
$this->assign('assignee_contact', array_combine($defaults['assignee_contact'], $assignee_contact_value));
}
if (!CRM_Utils_Array::value('activity_date_time', $defaults)) {
list($defaults['activity_date_time'], $defaults['activity_date_time_time']) = CRM_Utils_Date::setDateDefaults(null, 'activityDateTime');
} else {
if ($this->_action & CRM_Core_Action::UPDATE) {
list($defaults['activity_date_time'], $defaults['activity_date_time_time']) = CRM_Utils_Date::setDateDefaults($defaults['activity_date_time'], 'activityDateTime');
}
}
//set the assigneed contact count to template
if (!empty($defaults['assignee_contact'])) {
$this->assign('assigneeContactCount', count($defaults['assignee_contact']));
} else {
$this->assign('assigneeContactCount', 1);
}
//set the target contact count to template
if (!empty($defaults['target_contact'])) {
$this->assign('targetContactCount', count($defaults['target_contact']));
} else {
$this->assign('targetContactCount', 1);
}
if ($this->_context != 'standalone') {
$this->assign('target_contact_value', CRM_Utils_Array::value('target_contact_value', $defaults));
$this->assign('assignee_contact_value', CRM_Utils_Array::value('assignee_contact_value', $defaults));
$this->assign('source_contact_value', CRM_Utils_Array::value('source_contact', $defaults));
}
} else {
// if it's a new activity, we need to set default values for associated contact fields
// since those are jQuery fields, unfortunately we cannot use defaults directly
$this->_sourceContactId = $this->_currentUserId;
$this->_targetContactId = $this->_currentlyViewedContactId;
$target_contact = array();
$defaults['source_contact_id'] = self::_getDisplayNameById($this->_sourceContactId);
$defaults['source_contact_qid'] = $this->_sourceContactId;
if ($this->_context != 'standalone' && isset($this->_targetContactId)) {
$target_contact[$this->_targetContactId] = self::_getDisplayNameById($this->_targetContactId);
}
$this->assign('target_contact', $target_contact);
list($defaults['activity_date_time'], $defaults['activity_date_time_time']) = CRM_Utils_Date::setDateDefaults(null, 'activityDateTime');
}
if ($this->_activityTypeId) {
$defaults["activity_type_id"] = $this->_activityTypeId;
}
if ($this->_action & (CRM_Core_Action::DELETE | CRM_Core_Action::RENEW)) {
$this->assign('delName', $defaults['subject']);
}
if ($this->_activityTypeFile) {
eval('$defaults += CRM_' . $this->_crmDir . '_Form_Activity_' . $this->_activityTypeFile . '::setDefaultValues($this);');
}
if (!CRM_Utils_Array::value('priority_id', $defaults)) {
require_once 'CRM/Core/PseudoConstant.php';
$priority = CRM_Core_PseudoConstant::priority();
$defaults['priority_id'] = array_search('Normal', $priority);
}
return $defaults;
}
示例6: create
/**
* Function to process the activities
*
* @param object $form form object
* @param array $params associated array of the submitted values
* @param array $ids array of ids
* @param string $activityType activity Type
* @param boolean $record true if it is Record Activity
* @access public
* @return
*/
public function create(&$params)
{
// check required params
if (!self::dataExists($params)) {
CRM_Core_Error::fatal('Not enough data to create activity object,');
}
$activity =& new CRM_Activity_DAO_Activity();
if (!CRM_Utils_Array::value('status_id', $params)) {
if (isset($params['activity_date_time']) && strcmp($params['activity_date_time'], CRM_Utils_Date::processDate(date('Ymd')) == -1)) {
$params['status_id'] = 2;
} else {
$params['status_id'] = 1;
}
}
//set priority to Normal for Auto-populated activities (for Cases)
if (!CRM_Utils_Array::value('priority_id', $params)) {
require_once 'CRM/Core/PseudoConstant.php';
$priority = CRM_Core_PseudoConstant::priority();
$params['priority_id'] = array_search('Normal', $priority);
}
if (empty($params['id'])) {
unset($params['id']);
}
if (!empty($params['target_contact_id']) && is_array($params['target_contact_id'])) {
$params['target_contact_id'] = array_unique($params['target_contact_id']);
}
if (!empty($params['assignee_contact_id']) && is_array($params['assignee_contact_id'])) {
$params['assignee_contact_id'] = array_unique($params['assignee_contact_id']);
}
$activity->copyValues($params);
// start transaction
require_once 'CRM/Core/Transaction.php';
$transaction = new CRM_Core_Transaction();
$result = $activity->save();
if (is_a($result, 'CRM_Core_Error')) {
$transaction->rollback();
return $result;
}
$activityId = $activity->id;
// check and attach and files as needed
require_once 'CRM/Core/BAO/File.php';
CRM_Core_BAO_File::processAttachment($params, 'civicrm_activity', $activityId);
// attempt to save activity assignment
$resultAssignment = null;
if (CRM_Utils_Array::value('assignee_contact_id', $params)) {
require_once 'CRM/Activity/BAO/ActivityAssignment.php';
$assignmentParams = array('activity_id' => $activityId);
if (is_array($params['assignee_contact_id'])) {
if (CRM_Utils_Array::value('deleteActivityAssignment', $params, true)) {
// first delete existing assignments if any
self::deleteActivityAssignment($activityId);
}
foreach ($params['assignee_contact_id'] as $acID) {
if ($acID) {
$assignmentParams['assignee_contact_id'] = $acID;
$resultAssignment = CRM_Activity_BAO_ActivityAssignment::create($assignmentParams);
if (is_a($resultAssignment, 'CRM_Core_Error')) {
$transaction->rollback();
return $resultAssignment;
}
}
}
} else {
$assignmentParams['assignee_contact_id'] = $params['assignee_contact_id'];
if (CRM_Utils_Array::value('id', $params)) {
$assignment =& new CRM_Activity_BAO_ActivityAssignment();
$assignment->activity_id = $activityId;
$assignment->find(true);
if ($assignment->assignee_contact_id != $params['assignee_contact_id']) {
$assignmentParams['id'] = $assignment->id;
$resultAssignment = CRM_Activity_BAO_ActivityAssignment::create($assignmentParams);
}
} else {
$resultAssignment = CRM_Activity_BAO_ActivityAssignment::create($assignmentParams);
}
}
} else {
if (CRM_Utils_Array::value('deleteActivityAssignment', $params, true)) {
self::deleteActivityAssignment($activityId);
}
}
if (is_a($resultAssignment, 'CRM_Core_Error')) {
$transaction->rollback();
return $resultAssignment;
}
// attempt to save activity targets
$resultTarget = null;
if (CRM_Utils_Array::value('target_contact_id', $params)) {
$targetParams = array('activity_id' => $activityId);
//.........这里部分代码省略.........
示例7: __construct
function __construct()
{
$this->_columns = array('civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => array('id' => array('required' => true, 'no_display' => true), 'display_name' => array('title' => ts('Contact Name'), 'default' => true, 'no_repeat' => true)), 'filters' => array('sort_name' => array('title' => ts('Contact Name'))), 'group_bys' => array('display_name' => array('name' => 'id', 'title' => ts('Contact'), 'default' => true)), 'grouping' => 'contact-fields'), 'civicrm_email' => array('dao' => 'CRM_Core_DAO_Email', 'fields' => array('email' => array('title' => 'Email', 'default' => true)), 'grouping' => 'contact-fields'), 'civicrm_phone' => array('dao' => 'CRM_Core_DAO_Email', 'fields' => array('phone' => array('title' => 'Phone')), 'grouping' => 'contact-fields'), 'civicrm_activity' => array('dao' => 'CRM_Activity_DAO_Activity', 'fields' => array('activity_type_id' => array('title' => ts('Activity Type'), 'default' => true, 'type' => CRM_Utils_Type::T_STRING), 'id' => array('title' => 'Total Activities', 'required' => true, 'statistics' => array('count' => ts('Activity Count')))), 'filters' => array('activity_date_time' => array('operatorType' => CRM_Report_Form::OP_DATE), 'activity_type_id' => array('title' => ts('Activity Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::activityType()), 'status_id' => array('title' => ts('Activity Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::activityStatus()), 'priority_id' => array('title' => ts('Priority'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::priority())), 'group_bys' => array('activity_date_time' => array('title' => ts('Activity Date'), 'frequency' => true), 'activity_type_id' => array('title' => ts('Activity Type'), 'default' => true)), 'grouping' => 'activity-fields', 'alias' => 'activity'));
parent::__construct();
}
示例8:
/**
* Get all Priorities
*
* The static array Priority is returned
*
* @access public
* @static
*
* @return array - array reference of all Priority
*/
public static function &priority()
{
if (!self::$priority) {
self::$priority = CRM_Core_OptionGroup::values('priority');
}
return self::$priority;
}
示例9: create
/**
* Function to process the activities
*
* @param object $form form object
* @param array $params associated array of the submitted values
* @param array $ids array of ids
* @param string $activityType activity Type
* @param boolean $record true if it is Record Activity
* @access public
*
* @return
*/
public static function create(&$params)
{
// check required params
if (!self::dataExists($params)) {
CRM_Core_Error::fatal('Not enough data to create activity object,');
}
$activity = new CRM_Activity_DAO_Activity();
if (isset($params['id']) && empty($params['id'])) {
unset($params['id']);
}
if (!CRM_Utils_Array::value('status_id', $params) && !CRM_Utils_Array::value('activity_status_id', $params) && !CRM_Utils_Array::value('id', $params)) {
if (isset($params['activity_date_time']) && strcmp($params['activity_date_time'], CRM_Utils_Date::processDate(date('Ymd')) == -1)) {
$params['status_id'] = 2;
} else {
$params['status_id'] = 1;
}
}
//set priority to Normal for Auto-populated activities (for Cases)
if (CRM_Utils_Array::value('priority_id', $params) === NULL && !CRM_Utils_Array::value('id', $params)) {
$priority = CRM_Core_PseudoConstant::priority();
$params['priority_id'] = array_search('Normal', $priority);
}
if (!empty($params['target_contact_id']) && is_array($params['target_contact_id'])) {
$params['target_contact_id'] = array_unique($params['target_contact_id']);
}
if (!empty($params['assignee_contact_id']) && is_array($params['assignee_contact_id'])) {
$params['assignee_contact_id'] = array_unique($params['assignee_contact_id']);
}
// CRM-9137
if (CRM_Utils_Array::value('id', $params)) {
CRM_Utils_Hook::pre('edit', 'Activity', $activity->id, $params);
} else {
CRM_Utils_Hook::pre('create', 'Activity', NULL, $params);
}
$activity->copyValues($params);
if (isset($params['case_id'])) {
// CRM-8708, preserve case ID even though it's not part of the SQL model
$activity->case_id = $params['case_id'];
} elseif (is_numeric($activity->id)) {
// CRM-8708, preserve case ID even though it's not part of the SQL model
$activity->case_id = CRM_Case_BAO_Case::getCaseIdByActivityId($activity->id);
}
// start transaction
$transaction = new CRM_Core_Transaction();
$result = $activity->save();
if (is_a($result, 'CRM_Core_Error')) {
$transaction->rollback();
return $result;
}
$activityId = $activity->id;
// check and attach and files as needed
CRM_Core_BAO_File::processAttachment($params, 'civicrm_activity', $activityId);
// attempt to save activity assignment
$resultAssignment = NULL;
if (CRM_Utils_Array::value('assignee_contact_id', $params)) {
$assignmentParams = array('activity_id' => $activityId);
if (is_array($params['assignee_contact_id'])) {
if (CRM_Utils_Array::value('deleteActivityAssignment', $params, TRUE)) {
// first delete existing assignments if any
self::deleteActivityAssignment($activityId);
}
$values = array();
foreach ($params['assignee_contact_id'] as $acID) {
if ($acID) {
$values[] = "( {$activityId}, {$acID} )";
}
}
while (!empty($values)) {
$input = array_splice($values, 0, CRM_Core_DAO::BULK_INSERT_COUNT);
$str = implode(',', $input);
$sql = "INSERT INTO civicrm_activity_assignment ( activity_id, assignee_contact_id ) VALUES {$str};";
CRM_Core_DAO::executeQuery($sql);
}
} else {
$assignmentParams['assignee_contact_id'] = $params['assignee_contact_id'];
if (CRM_Utils_Array::value('id', $params)) {
$assignment = new CRM_Activity_BAO_ActivityAssignment();
$assignment->activity_id = $activityId;
$assignment->find(TRUE);
if ($assignment->assignee_contact_id != $params['assignee_contact_id']) {
$assignmentParams['id'] = $assignment->id;
$resultAssignment = CRM_Activity_BAO_ActivityAssignment::create($assignmentParams);
}
} else {
$resultAssignment = CRM_Activity_BAO_ActivityAssignment::create($assignmentParams);
}
}
} else {
//.........这里部分代码省略.........