本文整理汇总了PHP中CRM_Core_PseudoConstant::activityStatus方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_PseudoConstant::activityStatus方法的具体用法?PHP CRM_Core_PseudoConstant::activityStatus怎么用?PHP CRM_Core_PseudoConstant::activityStatus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_PseudoConstant
的用法示例。
在下文中一共展示了CRM_Core_PseudoConstant::activityStatus方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
*/
public function __construct()
{
//filter options for survey activity status.
$responseStatus = array('' => '- Any -');
self::$_surveyRespondentStatus = array();
$activityStatus = CRM_Core_PseudoConstant::activityStatus('name');
if ($statusId = array_search('Scheduled', $activityStatus)) {
$responseStatus[$statusId] = ts('Reserved');
self::$_surveyRespondentStatus[$statusId] = 'Reserved';
}
if ($statusId = array_search('Completed', $activityStatus)) {
$responseStatus[$statusId] = ts('Interviewed');
self::$_surveyRespondentStatus[$statusId] = 'Interviewed';
}
$optionGroups = CRM_Campaign_BAO_Survey::getResultSets('name');
$resultOptions = array();
foreach ($optionGroups as $gid => $name) {
if ($name) {
$value = array();
$value = CRM_Core_OptionGroup::values($name);
if (!empty($value)) {
$value = array_combine($value, $value);
}
$resultOptions = $resultOptions + $value;
}
}
asort($resultOptions);
//get all interviewers.
$allSurveyInterviewers = CRM_Campaign_BAO_Survey::getInterviewers();
$this->_columns = array('civicrm_activity_contact' => array('dao' => 'CRM_Activity_DAO_ActivityContact', 'fields' => array('contact_id' => array('title' => ts('Interviewer Name'))), 'filters' => array('contact_id' => array('name' => 'contact_id', 'title' => ts('Interviewer Name'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => array('' => ts('- any interviewer -')) + $allSurveyInterviewers)), 'grouping' => 'survey-interviewer-fields'), 'civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => array('id' => array('title' => ts('Contact ID'), 'no_display' => TRUE, 'required' => TRUE), 'sort_name' => array('title' => ts('Respondent Name'), 'required' => TRUE, 'no_repeat' => TRUE)), 'filters' => array('sort_name' => array('title' => ts('Respondent Name'), 'operator' => 'like')), 'grouping' => 'contact-fields', 'order_bys' => array('sort_name' => array('title' => ts('Respondent Name'), 'required' => TRUE))), 'civicrm_phone' => array('dao' => 'CRM_Core_DAO_Phone', 'fields' => array('phone' => array('name' => 'phone', 'title' => ts('Phone'))), 'grouping' => 'location-fields'), 'civicrm_address' => array('dao' => 'CRM_Core_DAO_Address', 'fields' => array('street_number' => array('name' => 'street_number', 'title' => ts('Street Number'), 'type' => 1), 'street_name' => array('name' => 'street_name', 'title' => ts('Street Name'), 'type' => 1), 'street_unit' => array('name' => 'street_unit', 'title' => ts('Street Unit'), 'type' => 1), 'postal_code' => array('name' => 'postal_code', 'title' => ts('Postal Code'), 'type' => 1), 'city' => array('name' => 'city', 'title' => ts('City'), 'type' => 1), 'state_province_id' => array('name' => 'state_province_id', 'title' => ts('State/Province')), 'country_id' => array('name' => 'country_id', 'title' => ts('Country'))), 'filters' => array('street_number' => array('title' => ts('Street Number'), 'type' => 1, 'name' => 'street_number'), 'street_name' => array('title' => ts('Street Name'), 'name' => 'street_name', 'operator' => 'like'), 'postal_code' => array('title' => ts('Postal Code'), 'type' => 1, 'name' => 'postal_code'), 'city' => array('title' => ts('City'), 'operator' => 'like', 'name' => 'city'), 'state_province_id' => array('name' => 'state_province_id', 'title' => ts('State/Province'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::stateProvince()), 'country_id' => array('name' => 'country_id', 'title' => ts('Country'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::country())), 'order_bys' => array('street_name' => array('title' => ts('Street Name')), 'street_number_odd_even' => array('title' => ts('Odd / Even Street Number'), 'name' => 'street_number', 'dbAlias' => 'address_civireport.street_number%2'), 'street_number' => array('title' => 'Street Number')), 'grouping' => 'location-fields'), 'civicrm_email' => array('dao' => 'CRM_Core_DAO_Email', 'fields' => array('email' => array('name' => 'email', 'title' => ts('Email'))), 'grouping' => 'location-fields'), 'civicrm_activity' => array('dao' => 'CRM_Activity_DAO_Activity', 'alias' => 'survey_activity', 'fields' => array('survey_id' => array('name' => 'source_record_id', 'title' => ts('Survey'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Campaign_BAO_Survey::getSurveys()), 'survey_response' => array('name' => 'survey_response', 'title' => ts('Survey Responses')), 'details' => array('name' => 'details', 'title' => ts('Note'), 'type' => 1), 'result' => array('name' => 'result', 'required' => TRUE, 'title' => ts('Survey Result'))), 'filters' => array('survey_id' => array('name' => 'source_record_id', 'title' => ts('Survey'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Campaign_BAO_Survey::getSurveys()), 'status_id' => array('name' => 'status_id', 'title' => ts('Respondent Status'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => $responseStatus), 'result' => array('title' => ts('Survey Result'), 'type' => CRM_Utils_Type::T_STRING, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $resultOptions)), 'grouping' => 'survey-activity-fields'));
parent::__construct();
}
示例2: onCaseChange
/**
* @param \Civi\CCase\Event\CaseChangeEvent $event
*
* @throws \CiviCRM_API3_Exception
*/
public function onCaseChange(\Civi\CCase\Event\CaseChangeEvent $event)
{
/** @var \Civi\CCase\Analyzer $analyzer */
$analyzer = $event->analyzer;
$activitySetXML = $this->getSequenceXml($analyzer->getXml());
if (!$activitySetXML) {
return;
}
$actTypes = array_flip(\CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'name'));
$actStatuses = array_flip(\CRM_Core_PseudoConstant::activityStatus('name'));
$actIndex = $analyzer->getActivityIndex(array('activity_type_id', 'status_id'));
foreach ($activitySetXML->ActivityTypes->ActivityType as $actTypeXML) {
$actTypeId = $actTypes[(string) $actTypeXML->name];
if (empty($actIndex[$actTypeId])) {
// Haven't tried this step yet!
$this->createActivity($analyzer, $actTypeXML);
return;
} elseif (empty($actIndex[$actTypeId][$actStatuses['Completed']])) {
// Haven't gotten past this step yet!
return;
}
}
// OK, the activity has completed every step in the sequence!
civicrm_api3('Case', 'create', array('id' => $analyzer->getCaseId(), 'status_id' => 'Closed'));
$analyzer->flush();
}
示例3: buildForm
/**
* @param $form
*/
function buildForm(&$form)
{
/**
* You can define a custom title for the search form
*/
$this->setTitle('Find Latest Activities');
/**
* Define the search form fields here
*/
// Allow user to choose which type of contact to limit search on
$form->add('select', 'contact_type', ts('Find...'), CRM_Core_SelectValues::contactType());
// Text box for Activity Subject
$form->add('text', 'activity_subject', ts('Activity Subject'));
// Select box for Activity Type
$activityType = array('' => ' - select activity - ') + CRM_Core_PseudoConstant::activityType();
$form->add('select', 'activity_type_id', ts('Activity Type'), $activityType, FALSE);
// textbox for Activity Status
$activityStatus = array('' => ' - select status - ') + CRM_Core_PseudoConstant::activityStatus();
$form->add('select', 'activity_status_id', ts('Activity Status'), $activityStatus, FALSE);
// Activity Date range
$form->addDate('start_date', ts('Activity Date From'), FALSE, array('formatType' => 'custom'));
$form->addDate('end_date', ts('...through'), FALSE, array('formatType' => 'custom'));
// Contact Name field
$form->add('text', 'sort_name', ts('Contact Name'));
/**
* If you are using the sample template, this array tells the template fields to render
* for the search form.
*/
$form->assign('elements', array('contact_type', 'activity_subject', 'activity_type_id', 'activity_status_id', 'start_date', 'end_date', 'sort_name'));
}
示例4: __construct
function __construct()
{
$this->activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, TRUE);
asort($this->activityTypes);
$this->activityStatuses = CRM_Core_PseudoConstant::activityStatus();
$this->_columns = array('civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => array('id' => array('title' => ts('Contact ID'), 'no_display' => TRUE, 'required' => TRUE), 'sort_name' => array('title' => ts('Contact Name'), 'required' => TRUE, 'no_repeat' => TRUE)), 'filters' => array('sort_name' => array('title' => ts('Contact Name'), 'operator' => 'like', 'type' => CRM_Report_Form::OP_STRING))), '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), 'activity_date_time' => array('title' => ts('Activity Date'), 'default' => TRUE), 'status_id' => array('title' => ts('Activity Status'), 'default' => FALSE, 'type' => CRM_Utils_Type::T_STRING), 'id' => array('title' => ts('Activity ID'), 'default' => TRUE), 'duration' => array('title' => ts('Duration'), 'default' => TRUE, 'type' => CRM_Utils_Type::T_INT), 'subject' => array('title' => ts('Activity Subject'), 'default' => FALSE)), 'filters' => array('activity_date_time' => array('operatorType' => CRM_Report_Form::OP_DATE), 'subject' => array('title' => ts('Activity Subject'), 'operator' => 'like'), 'activity_type_id' => array('title' => ts('Activity Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->activityTypes), 'status_id' => array('title' => ts('Activity Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->activityStatuses))), 'civicrm_activity_source' => array('dao' => 'CRM_Activity_DAO_ActivityContact', 'fields' => array('contact_id' => array('title' => ts('Contact ID'), 'default' => TRUE, 'no_display' => TRUE)), 'group_bys' => array('contact_id' => array('title' => ts('Totals Only'), 'default' => TRUE)), 'grouping' => 'activity-fields'), 'civicrm_case_activity' => array('dao' => 'CRM_Case_DAO_CaseActivity', 'fields' => array('case_id' => array('title' => ts('Case ID'), 'default' => FALSE)), 'filters' => array('case_id_filter' => array('name' => 'case_id', 'title' => ts('Cases?'), 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => array(1 => ts('Exclude non-case'), 2 => ts('Exclude cases'), 3 => ts('Include Both')), 'default' => 3))));
parent::__construct();
}
示例5: testSequence
public function testSequence()
{
$actStatuses = array_flip(\CRM_Core_PseudoConstant::activityStatus('name'));
$caseStatuses = array_flip(\CRM_Case_PseudoConstant::caseStatus('name'));
// Create case; schedule first activity
\CRM_Utils_Time::setTime('2013-11-30 01:00:00');
$case = $this->callAPISuccess('case', 'create', $this->_params);
$analyzer = new \Civi\CCase\Analyzer($case['id']);
$this->assertEquals($caseStatuses['Open'], self::ag($analyzer->getCase(), 'status_id'));
$this->assertApproxTime('2013-11-30 01:00:00', self::ag($analyzer->getSingleActivity('Medical evaluation'), 'activity_date_time'));
$this->assertEquals($actStatuses['Scheduled'], self::ag($analyzer->getSingleActivity('Medical evaluation'), 'status_id'));
$this->assertFalse($analyzer->hasActivity('Mental health evaluation'));
$this->assertFalse($analyzer->hasActivity('Secure temporary housing'));
// Edit details of first activity -- but don't finish it yet!
\CRM_Utils_Time::setTime('2013-11-30 01:30:00');
$this->callApiSuccess('Activity', 'create', array('id' => self::ag($analyzer->getSingleActivity('Medical evaluation'), 'id'), 'subject' => 'This is the new subject'));
$analyzer = new \Civi\CCase\Analyzer($case['id']);
$this->assertEquals($caseStatuses['Open'], self::ag($analyzer->getCase(), 'status_id'));
$this->assertApproxTime('2013-11-30 01:00:00', self::ag($analyzer->getSingleActivity('Medical evaluation'), 'activity_date_time'));
$this->assertEquals($actStatuses['Scheduled'], self::ag($analyzer->getSingleActivity('Medical evaluation'), 'status_id'));
$this->assertFalse($analyzer->hasActivity('Mental health evaluation'));
$this->assertFalse($analyzer->hasActivity('Secure temporary housing'));
// Complete first activity; schedule second
\CRM_Utils_Time::setTime('2013-11-30 02:00:00');
$this->callApiSuccess('Activity', 'create', array('id' => self::ag($analyzer->getSingleActivity('Medical evaluation'), 'id'), 'status_id' => $actStatuses['Completed']));
$analyzer->flush();
$this->assertEquals($caseStatuses['Open'], self::ag($analyzer->getCase(), 'status_id'));
$this->assertApproxTime('2013-11-30 01:00:00', self::ag($analyzer->getSingleActivity('Medical evaluation'), 'activity_date_time'));
$this->assertEquals($actStatuses['Completed'], self::ag($analyzer->getSingleActivity('Medical evaluation'), 'status_id'));
$this->assertApproxTime('2013-11-30 02:00:00', self::ag($analyzer->getSingleActivity('Mental health evaluation'), 'activity_date_time'));
$this->assertEquals($actStatuses['Scheduled'], self::ag($analyzer->getSingleActivity('Mental health evaluation'), 'status_id'));
$this->assertFalse($analyzer->hasActivity('Secure temporary housing'));
// Complete second activity; schedule third
\CRM_Utils_Time::setTime('2013-11-30 03:00:00');
$this->callApiSuccess('Activity', 'create', array('id' => self::ag($analyzer->getSingleActivity('Mental health evaluation'), 'id'), 'status_id' => $actStatuses['Completed']));
$analyzer->flush();
$this->assertEquals($caseStatuses['Open'], self::ag($analyzer->getCase(), 'status_id'));
$this->assertApproxTime('2013-11-30 01:00:00', self::ag($analyzer->getSingleActivity('Medical evaluation'), 'activity_date_time'));
$this->assertEquals($actStatuses['Completed'], self::ag($analyzer->getSingleActivity('Medical evaluation'), 'status_id'));
$this->assertApproxTime('2013-11-30 02:00:00', self::ag($analyzer->getSingleActivity('Mental health evaluation'), 'activity_date_time'));
$this->assertEquals($actStatuses['Completed'], self::ag($analyzer->getSingleActivity('Mental health evaluation'), 'status_id'));
$this->assertApproxTime('2013-11-30 03:00:00', self::ag($analyzer->getSingleActivity('Secure temporary housing'), 'activity_date_time'));
$this->assertEquals($actStatuses['Scheduled'], self::ag($analyzer->getSingleActivity('Secure temporary housing'), 'status_id'));
// Complete third activity; close case
\CRM_Utils_Time::setTime('2013-11-30 04:00:00');
$this->callApiSuccess('Activity', 'create', array('id' => self::ag($analyzer->getSingleActivity('Secure temporary housing'), 'id'), 'status_id' => $actStatuses['Completed']));
$analyzer->flush();
$this->assertApproxTime('2013-11-30 01:00:00', self::ag($analyzer->getSingleActivity('Medical evaluation'), 'activity_date_time'));
$this->assertEquals($actStatuses['Completed'], self::ag($analyzer->getSingleActivity('Medical evaluation'), 'status_id'));
$this->assertApproxTime('2013-11-30 02:00:00', self::ag($analyzer->getSingleActivity('Mental health evaluation'), 'activity_date_time'));
$this->assertEquals($actStatuses['Completed'], self::ag($analyzer->getSingleActivity('Mental health evaluation'), 'status_id'));
$this->assertApproxTime('2013-11-30 03:00:00', self::ag($analyzer->getSingleActivity('Secure temporary housing'), 'activity_date_time'));
$this->assertEquals($actStatuses['Completed'], self::ag($analyzer->getSingleActivity('Secure temporary housing'), 'status_id'));
$this->assertEquals($caseStatuses['Closed'], self::ag($analyzer->getCase(), 'status_id'));
// */
}
示例6: releaseRespondent
public function releaseRespondent()
{
require_once 'CRM/Core/PseudoConstant.php';
require_once 'CRM/Campaign/BAO/Survey.php';
$activityStatus = CRM_Core_PseudoConstant::activityStatus('name');
$reserveStatusId = array_search('Scheduled', $activityStatus);
$surveyActivityTypes = CRM_Campaign_BAO_Survey::getSurveyActivityType();
$surveyActivityTypesIds = array_keys($surveyActivityTypes);
//retrieve all survey activities related to reserve action.
$releasedCount = 0;
if ($reserveStatusId && !empty($surveyActivityTypesIds)) {
$query = '
SELECT activity.id as id,
activity.activity_date_time as activity_date_time,
survey.id as surveyId,
survey.release_frequency as release_frequency
FROM civicrm_activity activity
INNER JOIN civicrm_survey survey ON ( survey.id = activity.source_record_id )
WHERE activity.is_deleted = 0
AND activity.status_id = %1
AND activity.activity_type_id IN ( ' . implode(', ', $surveyActivityTypesIds) . ' )';
$activity = CRM_Core_DAO::executeQuery($query, array(1 => array($reserveStatusId, 'Positive')));
$releasedIds = array();
while ($activity->fetch()) {
if (!$activity->release_frequency) {
continue;
}
$reservedSeconds = CRM_Utils_Date::unixTime($activity->activity_date_time);
$releasedSeconds = $activity->release_frequency * 24 * 3600;
$totalReservedSeconds = $reservedSeconds + $releasedSeconds;
if ($totalReservedSeconds < time()) {
$releasedIds[$activity->id] = $activity->id;
}
}
//released respondent.
if (!empty($releasedIds)) {
$query = '
UPDATE civicrm_activity
SET is_deleted = 1
WHERE id IN ( ' . implode(', ', $releasedIds) . ' )';
CRM_Core_DAO::executeQuery($query);
$releasedCount = count($releasedIds);
}
}
echo "<br /><br />Number of respondents released = {$releasedCount}";
}
示例7: where
function where()
{
$params = array('sequential' => 1, 'option_group_id' => 'activity_type', 'name' => 'Public Holiday', 'return' => 'value');
$publicHolidayID = civicrm_api3('OptionValue', 'getvalue', $params);
$this->_where = " WHERE {$this->_aliases['civicrm_activity']}.activity_type_id = {$publicHolidayID} AND\n {$this->_aliases['civicrm_activity']}.is_test = 0 AND\n {$this->_aliases['civicrm_activity']}.is_deleted = 0 AND\n {$this->_aliases['civicrm_activity']}.is_current_revision = 1";
$clauses = array();
foreach ($this->_columns as $tableName => $table) {
if (array_key_exists('filters', $table)) {
foreach ($table['filters'] as $fieldName => $field) {
$clause = NULL;
if (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE) {
$relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params);
$from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params);
$to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params);
$clause = $this->dateClause($field['name'], $relative, $from, $to, $field['type']);
}
if (array_key_exists("{$fieldName}_value", $this->_params)) {
if ($field['name'] == 'status_id' && $this->_params["{$fieldName}_value"]) {
$status = CRM_Core_PseudoConstant::activityStatus();
if ($this->_params["{$fieldName}_value"] == 1) {
$this->_params["{$fieldName}_value"] = array_search('Scheduled', $status);
} elseif ($this->_params["{$fieldName}_value"] == 0) {
$this->_params["{$fieldName}_value"] = array_search('Cancelled', $status);
}
$op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params);
$clause = $this->whereClause($field, $op, CRM_Utils_Array::value("{$fieldName}_value", $this->_params), CRM_Utils_Array::value("{$fieldName}_min", $this->_params), CRM_Utils_Array::value("{$fieldName}_max", $this->_params));
}
}
if (!empty($clause)) {
$clauses[] = $clause;
}
}
}
}
if (empty($clauses)) {
$this->_where .= " ";
} else {
$this->_where .= " AND " . implode(' AND ', $clauses);
}
if ($this->_aclWhere) {
$this->_where .= " AND {$this->_aclWhere} ";
}
}
示例8: __construct
function __construct()
{
//filter options for survey activity status.
$responseStatus = array();
self::$_surveyRespondentStatus = array();
$activityStatus = CRM_Core_PseudoConstant::activityStatus('name');
if ($statusId = array_search('Scheduled', $activityStatus)) {
$responseStatus[$statusId] = ts('Reserved');
self::$_surveyRespondentStatus[$statusId] = 'Reserved';
}
if ($statusId = array_search('Completed', $activityStatus)) {
$responseStatus[$statusId] = ts('Interviewed');
self::$_surveyRespondentStatus[$statusId] = 'Interviewed';
}
//get all interviewers.
$allSurveyInterviewers = CRM_Campaign_BAO_Survey::getInterviewers();
$this->_columns = array('civicrm_activity_assignment' => array('dao' => 'CRM_Activity_DAO_ActivityAssignment', 'fields' => array('assignee_contact_id' => array('title' => ts('Interviewer Name'))), 'filters' => array('assignee_contact_id' => array('name' => 'assignee_contact_id', 'title' => ts('Interviewer Name'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => array('' => ts('- any interviewer -')) + $allSurveyInterviewers)), 'grouping' => 'survey-interviewer-fields'), 'civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => array('id' => array('title' => ts('Contact ID'), 'no_display' => TRUE, 'required' => TRUE), 'sort_name' => array('title' => ts('Respondent Name'), 'required' => TRUE, 'no_repeat' => TRUE)), 'filters' => array('sort_name' => array('title' => ts('Respondent Name'), 'operator' => 'like')), 'grouping' => 'contact-fields', 'order_bys' => array('sort_name' => array('title' => ts('Respondent Name'), 'required' => TRUE))), 'civicrm_phone' => array('dao' => 'CRM_Core_DAO_Phone', 'fields' => array('phone' => array('name' => 'phone', 'title' => ts('Phone'))), 'grouping' => 'location-fields'), 'civicrm_address' => array('dao' => 'CRM_Core_DAO_Address', 'fields' => array('street_number' => array('name' => 'street_number', 'title' => ts('Street Number'), 'type' => 1), 'street_name' => array('name' => 'street_name', 'title' => ts('Street Name'), 'type' => 1), 'street_unit' => array('name' => 'street_unit', 'title' => ts('Street Unit'), 'type' => 1), 'postal_code' => array('name' => 'postal_code', 'title' => ts('Postal Code'), 'type' => 1), 'city' => array('name' => 'city', 'title' => ts('City'), 'type' => 1), 'state_province_id' => array('name' => 'state_province_id', 'title' => ts('State/Province')), 'country_id' => array('name' => 'country_id', 'title' => ts('Country'))), 'filters' => array('street_number' => array('title' => ts('Street Number'), 'type' => 1, 'name' => 'street_number'), 'street_name' => array('title' => ts('Street Name'), 'name' => 'street_name', 'operator' => 'like'), 'postal_code' => array('title' => ts('Postal Code'), 'type' => 1, 'name' => 'postal_code'), 'city' => array('title' => ts('City'), 'operator' => 'like', 'name' => 'city'), 'state_province_id' => array('name' => 'state_province_id', 'title' => ts('State/Province'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::stateProvince()), 'country_id' => array('name' => 'country_id', 'title' => ts('Country'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::country())), 'group_bys' => array('street_name' => array('title' => ts('Street Name')), 'street_number' => array('title' => 'Odd / Even Street Number')), 'order_bys' => array('street_name' => array('title' => ts('Street Name')), 'street_number' => array('title' => 'Odd / Even Street Number')), 'grouping' => 'location-fields'), 'civicrm_email' => array('dao' => 'CRM_Core_DAO_Email', 'fields' => array('email' => array('name' => 'email', 'title' => ts('Email'))), 'grouping' => 'location-fields'), 'civicrm_activity' => array('dao' => 'CRM_Activity_DAO_Activity', 'alias' => 'survey_activity', 'fields' => array('survey_id' => array('name' => 'source_record_id', 'title' => ts('Survey'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Campaign_BAO_Survey::getSurveys()), 'survey_response' => array('name' => 'survey_response', 'title' => ts('Survey Responses')), 'result' => array('name' => 'result', 'required' => TRUE, 'title' => ts('Survey Result'))), 'filters' => array('survey_id' => array('name' => 'source_record_id', 'title' => ts('Survey'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Campaign_BAO_Survey::getSurveys()), 'status_id' => array('name' => 'status_id', 'title' => ts('Respondent Status'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => $responseStatus)), 'grouping' => 'survey-activity-fields'));
parent::__construct();
}
示例9: buildProfile
//.........这里部分代码省略.........
} elseif ($fieldName == 'product_name') {
list($products, $options) = CRM_Contribute_BAO_Premium::getPremiumProductInfo();
$sel =& $form->addElement('hierselect', $name, $title);
$products = array('0' => ts('- select -')) + $products;
$sel->setOptions(array($products, $options));
} elseif ($fieldName == 'payment_instrument') {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(), $required);
} elseif ($fieldName == 'financial_type') {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::financialType(), $required);
} elseif ($fieldName == 'contribution_status_id') {
$contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus();
$statusName = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
foreach (array('In Progress', 'Overdue', 'Refunded') as $suppress) {
unset($contributionStatuses[CRM_Utils_Array::key($suppress, $statusName)]);
}
$form->add('select', $name, $title, array('' => ts('- select -')) + $contributionStatuses, $required);
} elseif ($fieldName == 'soft_credit_type') {
$name = "soft_credit_type[{$rowNumber}]";
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Core_OptionGroup::values("soft_credit_type"));
//CRM-15350: choose SCT field default value as 'Gift' for membership use
//else (for contribution), use configured SCT default value
$SCTDefaultValue = CRM_Core_OptionGroup::getDefaultValue("soft_credit_type");
if ($field['field_type'] == 'Membership') {
$SCTDefaultValue = CRM_Core_OptionGroup::getValue('soft_credit_type', 'Gift', 'name');
}
$form->addElement('hidden', 'sct_default_id', $SCTDefaultValue, array('id' => 'sct_default_id'));
} elseif ($fieldName == 'currency') {
$form->addCurrency($name, $title, $required);
} elseif ($fieldName == 'contribution_page_id') {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::contributionPage(), $required, 'class="big"');
} elseif ($fieldName == 'participant_register_date') {
$form->addDateTime($name, $title, $required, array('formatType' => 'activityDateTime'));
} elseif ($fieldName == 'activity_status_id') {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Core_PseudoConstant::activityStatus(), $required);
} elseif ($fieldName == 'activity_engagement_level') {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Campaign_PseudoConstant::engagementLevel(), $required);
} elseif ($fieldName == 'activity_date_time') {
$form->addDateTime($name, $title, $required, array('formatType' => 'activityDateTime'));
} elseif ($fieldName == 'participant_status') {
$cond = NULL;
if ($online == TRUE) {
$cond = 'visibility_id = 1';
}
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Event_PseudoConstant::participantStatus(NULL, $cond, 'label'), $required);
} elseif ($fieldName == 'participant_role') {
if (!empty($field['is_multiple'])) {
$form->addCheckBox($name, $title, CRM_Event_PseudoConstant::participantRole(), NULL, NULL, NULL, NULL, ' ', TRUE);
} else {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Event_PseudoConstant::participantRole(), $required);
}
} elseif ($fieldName == 'world_region') {
$form->add('select', $name, $title, CRM_Core_PseudoConstant::worldRegion(), $required, $selectAttributes);
} elseif ($fieldName == 'signature_html') {
$form->add('wysiwyg', $name, $title, CRM_Core_DAO::getAttribute('CRM_Core_DAO_Email', $fieldName));
} elseif ($fieldName == 'signature_text') {
$form->add('textarea', $name, $title, CRM_Core_DAO::getAttribute('CRM_Core_DAO_Email', $fieldName));
} elseif (substr($fieldName, -11) == 'campaign_id') {
if (CRM_Campaign_BAO_Campaign::isCampaignEnable()) {
$campaigns = CRM_Campaign_BAO_Campaign::getCampaigns(CRM_Utils_Array::value($contactId, $form->_componentCampaigns));
$form->add('select', $name, $title, array('' => ts('- select -')) + $campaigns, $required, 'class="crm-select2 big"');
}
} elseif ($fieldName == 'activity_details') {
$form->add('wysiwyg', $fieldName, $title, array('rows' => 4, 'cols' => 60), $required);
} elseif ($fieldName == 'activity_duration') {
$form->add('text', $name, $title, $attributes, $required);
$form->addRule($name, ts('Please enter the duration as number of minutes (integers only).'), 'positiveInteger');
示例10: alterDisplay
function alterDisplay(&$rows)
{
// custom code to alter rows
$entryFound = false;
$activityType = CRM_Core_PseudoConstant::activityType();
$activityStatus = CRM_Core_PseudoConstant::activityStatus();
$onHover = ts('View Contact Summary for this Contact');
foreach ($rows as $rowNum => $row) {
if (array_key_exists('civicrm_contact_contact_source', $row)) {
if ($value = $row['civicrm_contact_source_contact_id']) {
$url = CRM_Utils_System::url("civicrm/contact/view", 'reset=1&cid=' . $value, $this->_absoluteUrl);
$rows[$rowNum]['civicrm_contact_contact_source_link'] = $url;
$rows[$rowNum]['civicrm_contact_contact_source_hover'] = $onHover;
$entryFound = true;
}
}
if (array_key_exists('civicrm_contact_contact_assignee', $row)) {
if ($value = $row['civicrm_activity_assignment_assignee_contact_id']) {
$url = CRM_Utils_System::url("civicrm/contact/view", 'reset=1&cid=' . $value, $this->_absoluteUrl);
$rows[$rowNum]['civicrm_contact_contact_assignee_link'] = $url;
$rows[$rowNum]['civicrm_contact_contact_assignee_hover'] = $onHover;
$entryFound = true;
}
}
if (array_key_exists('civicrm_contact_contact_target', $row)) {
if ($value = $row['civicrm_activity_target_target_contact_id']) {
$url = CRM_Utils_System::url("civicrm/contact/view", 'reset=1&cid=' . $value, $this->_absoluteUrl);
$rows[$rowNum]['civicrm_contact_contact_target_link'] = $url;
$rows[$rowNum]['civicrm_contact_contact_target_hover'] = $onHover;
$entryFound = true;
}
}
if (array_key_exists('civicrm_activity_activity_type_id', $row)) {
if ($value = $row['civicrm_activity_activity_type_id']) {
$rows[$rowNum]['civicrm_activity_activity_type_id'] = $activityType[$value];
$entryFound = true;
}
}
if (array_key_exists('civicrm_activity_status_id', $row)) {
if ($value = $row['civicrm_activity_status_id']) {
$rows[$rowNum]['civicrm_activity_status_id'] = $activityStatus[$value];
$entryFound = true;
}
}
if (!$entryFound) {
break;
}
}
}
示例11: array
/**
* DEPRECATED. Please use the buildOptions() method in the appropriate BAO object.
*
* Get all Activity Statuses.
*
* The static array activityStatus is returned
*
* @access public
* @static
*
* @return array - array reference of all activity statuses
*/
public static function &activityStatus($column = 'label')
{
if (NULL === self::$activityStatus) {
self::$activityStatus = array();
}
if (!array_key_exists($column, self::$activityStatus)) {
self::$activityStatus[$column] = array();
self::$activityStatus[$column] = CRM_Core_OptionGroup::values('activity_status', FALSE, FALSE, FALSE, NULL, $column);
}
return self::$activityStatus[$column];
}
示例12: voterClause
/**
* @param array $params
*
* @return array
*/
public static function voterClause($params)
{
$voterClause = array();
$fromClause = $whereClause = NULL;
if (!is_array($params) || empty($params)) {
return $voterClause;
}
$surveyId = CRM_Utils_Array::value('campaign_survey_id', $params);
$searchVoterFor = CRM_Utils_Array::value('campaign_search_voter_for', $params);
//get the survey activities.
$activityStatus = CRM_Core_PseudoConstant::activityStatus('name');
$status = array('Scheduled');
if ($searchVoterFor == 'reserve') {
$status[] = 'Completed';
}
$completedStatusId = NULL;
foreach ($status as $name) {
if ($statusId = array_search($name, $activityStatus)) {
$statusIds[] = $statusId;
if ($name == 'Completed') {
$completedStatusId = $statusId;
}
}
}
$voterActValues = CRM_Campaign_BAO_Survey::getSurveyVoterInfo($surveyId, NULL, $statusIds);
if (!empty($voterActValues)) {
$operator = 'IN';
$voterIds = array_keys($voterActValues);
if ($searchVoterFor == 'reserve') {
$operator = 'NOT IN';
//filter out recontact survey contacts.
$recontactInterval = CRM_Core_DAO::getFieldValue('CRM_Campaign_DAO_Survey', $surveyId, 'recontact_interval');
$recontactInterval = unserialize($recontactInterval);
if ($surveyId && is_array($recontactInterval) && !empty($recontactInterval)) {
$voterIds = array();
foreach ($voterActValues as $values) {
$numOfDays = CRM_Utils_Array::value($values['result'], $recontactInterval);
if ($numOfDays && $values['status_id'] == $completedStatusId) {
$recontactIntSeconds = $numOfDays * 24 * 3600;
$actDateTimeSeconds = CRM_Utils_Date::unixTime($values['activity_date_time']);
$totalSeconds = $recontactIntSeconds + $actDateTimeSeconds;
//don't consider completed survey activity
//unless it fulfill recontact interval criteria.
if ($totalSeconds <= time()) {
continue;
}
}
$voterIds[$values['voter_id']] = $values['voter_id'];
}
}
}
//lets dump these ids in tmp table and
//use appropriate join depend on operator.
if (!empty($voterIds)) {
$voterIdCount = count($voterIds);
//create temporary table to store voter ids.
$tempTableName = CRM_Core_DAO::createTempTableName('civicrm_survey_respondent');
CRM_Core_DAO::executeQuery("DROP TEMPORARY TABLE IF EXISTS {$tempTableName}");
$query = "\n CREATE TEMPORARY TABLE {$tempTableName} (\n id int unsigned NOT NULL AUTO_INCREMENT,\n survey_contact_id int unsigned NOT NULL,\n PRIMARY KEY ( id )\n);\n";
CRM_Core_DAO::executeQuery($query);
$batch = 100;
$insertedCount = 0;
do {
$processIds = $voterIds;
$insertIds = array_splice($processIds, $insertedCount, $batch);
if (!empty($insertIds)) {
$insertSQL = "INSERT IGNORE INTO {$tempTableName}( survey_contact_id )\n VALUES (" . implode('),(', $insertIds) . ');';
CRM_Core_DAO::executeQuery($insertSQL);
}
$insertedCount += $batch;
} while ($insertedCount < $voterIdCount);
if ($operator == 'IN') {
$fromClause = " INNER JOIN {$tempTableName} ON ( {$tempTableName}.survey_contact_id = contact_a.id )";
} else {
$fromClause = " LEFT JOIN {$tempTableName} ON ( {$tempTableName}.survey_contact_id = contact_a.id )";
$whereClause = "( {$tempTableName}.survey_contact_id IS NULL )";
}
}
}
$voterClause = array('fromClause' => $fromClause, 'whereClause' => $whereClause);
return $voterClause;
}
示例13: alterDisplay
/**
* Alter display of rows.
*
* Iterate through the rows retrieved via SQL and make changes for display purposes,
* such as rendering contacts as links.
*
* @param array $rows
* Rows generated by SQL, with an array for each row.
*/
public function alterDisplay(&$rows)
{
$entryFound = FALSE;
$activityType = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE);
$activityStatus = CRM_Core_PseudoConstant::activityStatus();
$viewLinks = FALSE;
$context = CRM_Utils_Request::retrieve('context', 'String', $this, FALSE, 'report');
$actUrl = '';
if (CRM_Core_Permission::check('access CiviCRM')) {
$viewLinks = TRUE;
$onHover = ts('View Contact Summary for this Contact');
$onHoverAct = ts('View Activity Record');
}
foreach ($rows as $rowNum => $row) {
// if we have an activity type, format the View Activity link for use in various columns
if ($viewLinks && array_key_exists('civicrm_activity_activity_type_id', $row)) {
// Check for target contact id(s) and use the first contact id in that list for view activity link if found,
// else use source contact id
if (!empty($rows[$rowNum]['civicrm_contact_contact_target_id'])) {
$targets = explode(';', $rows[$rowNum]['civicrm_contact_contact_target_id']);
$cid = $targets[0];
} else {
$cid = $rows[$rowNum]['civicrm_contact_contact_source_id'];
}
$actActionLinks = CRM_Activity_Selector_Activity::actionLinks($row['civicrm_activity_activity_type_id'], CRM_Utils_Array::value('civicrm_activity_source_record_id', $rows[$rowNum]), FALSE, $rows[$rowNum]['civicrm_activity_id']);
$actLinkValues = array('id' => $rows[$rowNum]['civicrm_activity_id'], 'cid' => $cid, 'cxt' => $context);
$actUrl = CRM_Utils_System::url($actActionLinks[CRM_Core_Action::VIEW]['url'], CRM_Core_Action::replace($actActionLinks[CRM_Core_Action::VIEW]['qs'], $actLinkValues), TRUE);
}
if (array_key_exists('civicrm_contact_contact_source', $row)) {
if ($value = $row['civicrm_contact_contact_source_id']) {
if ($viewLinks) {
$url = CRM_Utils_System::url("civicrm/contact/view", 'reset=1&cid=' . $value, $this->_absoluteUrl);
$rows[$rowNum]['civicrm_contact_contact_source_link'] = $url;
$rows[$rowNum]['civicrm_contact_contact_source_hover'] = $onHover;
}
$entryFound = TRUE;
}
}
if (array_key_exists('civicrm_contact_contact_assignee', $row)) {
$assigneeNames = explode(';', $row['civicrm_contact_contact_assignee']);
if ($value = $row['civicrm_contact_contact_assignee_id']) {
$assigneeContactIds = explode(';', $value);
$link = array();
if ($viewLinks) {
foreach ($assigneeContactIds as $id => $value) {
if (isset($value) && isset($assigneeNames[$id])) {
$url = CRM_Utils_System::url("civicrm/contact/view", 'reset=1&cid=' . $value, $this->_absoluteUrl);
$link[] = "<a title='" . $onHover . "' href='" . $url . "'>{$assigneeNames[$id]}</a>";
}
}
$rows[$rowNum]['civicrm_contact_contact_assignee'] = implode('; ', $link);
}
$entryFound = TRUE;
}
}
if (array_key_exists('civicrm_contact_contact_target', $row)) {
$targetNames = explode(';', $row['civicrm_contact_contact_target']);
if ($value = $row['civicrm_contact_contact_target_id']) {
$targetContactIds = explode(';', $value);
$link = array();
if ($viewLinks) {
foreach ($targetContactIds as $id => $value) {
if (isset($value) && isset($targetNames[$id])) {
$url = CRM_Utils_System::url("civicrm/contact/view", 'reset=1&cid=' . $value, $this->_absoluteUrl);
$link[] = "<a title='" . $onHover . "' href='" . $url . "'>{$targetNames[$id]}</a>";
}
}
$rows[$rowNum]['civicrm_contact_contact_target'] = implode('; ', $link);
}
$entryFound = TRUE;
}
}
if (array_key_exists('civicrm_activity_activity_type_id', $row)) {
if ($value = $row['civicrm_activity_activity_type_id']) {
$rows[$rowNum]['civicrm_activity_activity_type_id'] = $activityType[$value];
if ($viewLinks) {
$rows[$rowNum]['civicrm_activity_activity_type_id_link'] = $actUrl;
$rows[$rowNum]['civicrm_activity_activity_type_id_hover'] = $onHoverAct;
}
$entryFound = TRUE;
}
}
if (array_key_exists('civicrm_activity_status_id', $row)) {
if ($value = $row['civicrm_activity_status_id']) {
$rows[$rowNum]['civicrm_activity_status_id'] = $activityStatus[$value];
$entryFound = TRUE;
}
}
if (array_key_exists('civicrm_activity_details', $row) && $this->_outputMode == 'html') {
if ($value = $row['civicrm_activity_details']) {
$fullDetails = $rows[$rowNum]['civicrm_activity_details'];
//.........这里部分代码省略.........
示例14: getContactActivitySelector
/**
* This function is a wrapper for ajax activity selector
*
* @param array $params associated array for params record id.
*
* @return array $contactActivities associated array of contact activities
* @access public
*/
public static function getContactActivitySelector(&$params)
{
// format the params
$params['offset'] = ($params['page'] - 1) * $params['rp'];
$params['rowCount'] = $params['rp'];
$params['sort'] = CRM_Utils_Array::value('sortBy', $params);
$params['caseId'] = NULL;
$context = CRM_Utils_Array::value('context', $params);
// get contact activities
$activities = CRM_Activity_BAO_Activity::getActivities($params);
// add total
$params['total'] = CRM_Activity_BAO_Activity::getActivitiesCount($params);
// format params and add links
$contactActivities = array();
if (!empty($activities)) {
$activityStatus = CRM_Core_PseudoConstant::activityStatus();
// check logged in user for permission
$page = new CRM_Core_Page();
CRM_Contact_Page_View::checkUserPermission($page, $params['contact_id']);
$permissions = array($page->_permission);
if (CRM_Core_Permission::check('delete activities')) {
$permissions[] = CRM_Core_Permission::DELETE;
}
$mask = CRM_Core_Action::mask($permissions);
foreach ($activities as $activityId => $values) {
$contactActivities[$activityId]['activity_type'] = $values['activity_type'];
$contactActivities[$activityId]['subject'] = $values['subject'];
if ($params['contact_id'] == $values['source_contact_id']) {
$contactActivities[$activityId]['source_contact'] = $values['source_contact_name'];
} elseif ($values['source_contact_id']) {
$contactActivities[$activityId]['source_contact'] = CRM_Utils_System::href($values['source_contact_name'], 'civicrm/contact/view', "reset=1&cid={$values['source_contact_id']}");
} else {
$contactActivities[$activityId]['source_contact'] = '<em>n/a</em>';
}
if (isset($values['mailingId']) && !empty($values['mailingId'])) {
$contactActivities[$activityId]['target_contact'] = CRM_Utils_System::href($values['recipients'], 'civicrm/mailing/report/event', "mid={$values['source_record_id']}&reset=1&event=queue&cid={$params['contact_id']}&context=activitySelector");
} elseif (CRM_Utils_Array::value('recipients', $values)) {
$contactActivities[$activityId]['target_contact'] = $values['recipients'];
} elseif (!$values['target_contact_name']) {
$contactActivities[$activityId]['target_contact'] = '<em>n/a</em>';
} elseif (!empty($values['target_contact_name'])) {
$count = 0;
$contactActivities[$activityId]['target_contact'] = '';
foreach ($values['target_contact_name'] as $tcID => $tcName) {
if ($tcID && $count < 5) {
$contactActivities[$activityId]['target_contact'] .= CRM_Utils_System::href($tcName, 'civicrm/contact/view', "reset=1&cid={$tcID}");
$count++;
if ($count) {
$contactActivities[$activityId]['target_contact'] .= "; ";
}
if ($count == 4) {
$contactActivities[$activityId]['target_contact'] .= "(" . ts('more') . ")";
break;
}
}
}
}
if (empty($values['assignee_contact_name'])) {
$contactActivities[$activityId]['assignee_contact'] = '<em>n/a</em>';
} elseif (!empty($values['assignee_contact_name'])) {
$count = 0;
$contactActivities[$activityId]['assignee_contact'] = '';
foreach ($values['assignee_contact_name'] as $acID => $acName) {
if ($acID && $count < 5) {
$contactActivities[$activityId]['assignee_contact'] .= CRM_Utils_System::href($acName, 'civicrm/contact/view', "reset=1&cid={$acID}");
$count++;
if ($count) {
$contactActivities[$activityId]['assignee_contact'] .= "; ";
}
if ($count == 4) {
$contactActivities[$activityId]['assignee_contact'] .= "(" . ts('more') . ")";
break;
}
}
}
}
$contactActivities[$activityId]['activity_date'] = CRM_Utils_Date::customFormat($values['activity_date_time']);
$contactActivities[$activityId]['status'] = $activityStatus[$values['status_id']];
// add class to this row if overdue
$contactActivities[$activityId]['class'] = '';
if (CRM_Utils_Date::overdue(CRM_Utils_Array::value('activity_date_time', $values)) && CRM_Utils_Array::value('status_id', $values) == 1) {
$contactActivities[$activityId]['class'] = 'status-overdue';
} else {
$contactActivities[$activityId]['class'] = 'status-ontime';
}
// build links
$contactActivities[$activityId]['links'] = '';
$accessMailingReport = FALSE;
if (CRM_Utils_Array::value('mailingId', $values)) {
$accessMailingReport = TRUE;
}
$actionLinks = CRM_Activity_Selector_Activity::actionLinks(CRM_Utils_Array::value('activity_type_id', $values), CRM_Utils_Array::value('source_record_id', $values), $accessMailingReport, CRM_Utils_Array::value('activity_id', $values));
//.........这里部分代码省略.........
示例15: _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'));
}
// 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"'));
}
// check if activity type_id is passed in
if (!isset($params['activity_name']) && !isset($params['activity_type_id'])) {
//when name AND id are both absent
return civicrm_create_error(ts('Missing Activity'));
} else {
if (isset($params['activity_name']) && isset($params['activity_type_id'])) {
//when name AND id are both present - check for the match
$activityTypes =& CRM_Core_PseudoConstant::activityType();
$activityId = array_search($params['activity_name'], $activityTypes);
if ($activityId != $params['activity_type_id']) {
return civicrm_create_error(ts('Mismatch in Activity'));
}
} else {
//either name OR id is present
if (isset($params['activity_name'])) {
require_once "CRM/Core/PseudoConstant.php";
$activityTypes =& CRM_Core_PseudoConstant::activityType(true, false, true);
$activityId = array_search($params['activity_name'], $activityTypes);
if (!$activityId) {
return civicrm_create_error(ts('Invalid Activity Name'));
} else {
$params['activity_type_id'] = $activityId;
}
} else {
if (!is_numeric($params['activity_type_id'])) {
return civicrm_create_error(ts('Invalid Activity Type ID'));
} else {
$activityTypes =& CRM_Core_PseudoConstant::activityType();
if (!array_key_exists($params['activity_type_id'], $activityTypes)) {
return civicrm_create_error(ts('Invalid Activity Type ID'));
}
}
}
}
}
// check for activity status is passed in
if (isset($params['status_id']) && !is_numeric($params['status_id'])) {
require_once "CRM/Core/PseudoConstant.php";
$activityStatus =& CRM_Core_PseudoConstant::activityStatus();
$activityStatusId = array_search($params['status_id'], $activityStatus);
if (!$activityStatusId) {
return civicrm_create_error(ts('Invalid Activity Status'));
} else {
$params['status_id'] = $activityStatusId;
}
}
// check for activity duration minutes
if (isset($params['duration_minutes']) && !is_numeric($params['duration_minutes'])) {
return civicrm_create_error(ts('Invalid Activity Duration (in minutes)'));
}
// check for source contact id
if ($addMode && empty($params['source_contact_id'])) {
return civicrm_create_error(ts('Missing Source Contact'));
}
if (isset($params['source_contact_id']) && !is_numeric($params['source_contact_id'])) {
return civicrm_create_error(ts('Invalid Source Contact'));
}
return null;
}