本文整理汇总了PHP中CRM_Core_BAO_ActionSchedule类的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_ActionSchedule类的具体用法?PHP CRM_Core_BAO_ActionSchedule怎么用?PHP CRM_Core_BAO_ActionSchedule使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRM_Core_BAO_ActionSchedule类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preProcess
/**
* Set variables up before form is built.
*
* @return void
*/
public function preProcess()
{
parent::preProcess();
$setTab = CRM_Utils_Request::retrieve('setTab', 'Int', $this, FALSE, 0);
$mapping = CRM_Utils_Array::first(CRM_Core_BAO_ActionSchedule::getMappings(array('id' => $this->_isTemplate ? CRM_Event_ActionMapping::EVENT_TPL_MAPPING_ID : CRM_Event_ActionMapping::EVENT_NAME_MAPPING_ID)));
$reminderList = CRM_Core_BAO_ActionSchedule::getList(FALSE, $mapping, $this->_id);
if ($reminderList && is_array($reminderList)) {
// Add action links to each of the reminders
foreach ($reminderList as &$format) {
$action = CRM_Core_Action::UPDATE + CRM_Core_Action::DELETE;
if ($format['is_active']) {
$action += CRM_Core_Action::DISABLE;
} else {
$action += CRM_Core_Action::ENABLE;
}
$scheduleReminder = new CRM_Admin_Page_ScheduleReminders();
$links = $scheduleReminder->links();
$links[CRM_Core_Action::DELETE]['qs'] .= "&context=event&compId={$this->_id}";
$links[CRM_Core_Action::UPDATE]['qs'] .= "&context=event&compId={$this->_id}";
$format['action'] = CRM_Core_Action::formLink($links, $action, array('id' => $format['id']), ts('more'), FALSE, 'actionSchedule.manage.action', 'ActionSchedule', $this->_id);
}
}
$this->assign('rows', $reminderList);
$this->assign('setTab', $setTab);
$this->assign('component', 'event');
// Update tab "disabled" css class
$this->ajaxResponse['tabValid'] = is_array($reminderList) && count($reminderList) > 0;
$this->setPageTitle(ts('Scheduled Reminder'));
}
示例2: civicrm_api3_action_schedule_create
/**
* Create a new Action Schedule
*
* @param array $params
*
* @return array
*
* {@getfields action_schedule_create}
*/
function civicrm_api3_action_schedule_create($params)
{
if (empty($params['id'])) {
// an update does not require any mandatory parameters
civicrm_api3_verify_one_mandatory($params, NULL, array('title', 'mapping_id', 'entity_status', 'entity_value'));
}
$ids = array();
if (isset($params['id']) && !CRM_Utils_Rule::integer($params['id'])) {
return civicrm_api3_create_error('Invalid value for ID');
}
if (!array_key_exists('name', $params) && !array_key_exists('id', $params)) {
$params['name'] = CRM_Utils_String::munge($params['title']);
}
$actionSchedule = new CRM_Core_BAO_ActionSchedule();
$actionSchedule = CRM_Core_BAO_ActionSchedule::add($params, $ids);
$actSchedule = array();
_civicrm_api3_object_to_array($actionSchedule, $actSchedule[$actionSchedule->id]);
return civicrm_api3_create_success($actSchedule, $params, 'action_schedule', 'create', $actionSchedule);
}
示例3: mappingList1
function mappingList1()
{
$params = array('mappingID');
foreach ($params as $param) {
${$param} = CRM_Utils_Array::value($param, $_POST);
}
if (!$mappingID) {
CRM_Utils_JSON::output(array('error_msg' => 'required params missing.'));
}
$selectionOptions = CRM_Core_BAO_ActionSchedule::getSelection1($mappingID);
extract($selectionOptions);
$elements = array();
foreach ($sel5 as $id => $name) {
$elements['sel5'][] = array('name' => $name, 'value' => $id);
}
$elements['recipientMapping'] = $recipientMapping;
CRM_Utils_JSON::output($elements);
}
示例4: postProcess
/**
* Process the form submission.
*
* @param array $params
* @param string $type
* @param array $linkedEntities
*
* @throws \CiviCRM_API3_Exception
*/
public static function postProcess($params = array(), $type, $linkedEntities = array())
{
//Check entity_id not present in params take it from class variable
if (empty($params['entity_id'])) {
$params['entity_id'] = self::$_entityId;
}
//Process this function only when you get this variable
if ($params['allowRepeatConfigToSubmit'] == 1) {
if (!empty($params['entity_table']) && !empty($params['entity_id']) && $type) {
$params['used_for'] = $type;
if (empty($params['parent_entity_id'])) {
$params['parent_entity_id'] = self::$_parentEntityId;
}
if (!empty($params['schedule_reminder_id'])) {
$params['id'] = $params['schedule_reminder_id'];
} else {
$params['id'] = self::$_scheduleReminderID;
}
//Save post params to the schedule reminder table
$recurobj = new CRM_Core_BAO_RecurringEntity();
$dbParams = $recurobj->mapFormValuesToDB($params);
//Delete repeat configuration and rebuild
if (!empty($params['id'])) {
CRM_Core_BAO_ActionSchedule::del($params['id']);
unset($params['id']);
}
$actionScheduleObj = CRM_Core_BAO_ActionSchedule::add($dbParams);
//exclude dates
$excludeDateList = array();
if (CRM_Utils_Array::value('exclude_date_list', $params) && CRM_Utils_Array::value('parent_entity_id', $params) && $actionScheduleObj->entity_value) {
//Since we get comma separated values lets get them in array
$excludeDates = explode(",", $params['exclude_date_list']);
//Check if there exists any values for this option group
$optionGroupIdExists = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', $type . '_repeat_exclude_dates_' . $params['parent_entity_id'], 'id', 'name');
if ($optionGroupIdExists) {
CRM_Core_BAO_OptionGroup::del($optionGroupIdExists);
}
$optionGroupParams = array('name' => $type . '_repeat_exclude_dates_' . $actionScheduleObj->entity_value, 'title' => $type . ' recursion', 'is_reserved' => 0, 'is_active' => 1);
$opGroup = CRM_Core_BAO_OptionGroup::add($optionGroupParams);
if ($opGroup->id) {
$oldWeight = 0;
$fieldValues = array('option_group_id' => $opGroup->id);
foreach ($excludeDates as $val) {
$optionGroupValue = array('option_group_id' => $opGroup->id, 'label' => CRM_Utils_Date::processDate($val), 'value' => CRM_Utils_Date::processDate($val), 'name' => $opGroup->name, 'description' => 'Used for recurring ' . $type, 'weight' => CRM_Utils_Weight::updateOtherWeights('CRM_Core_DAO_OptionValue', $oldWeight, CRM_Utils_Array::value('weight', $params), $fieldValues), 'is_active' => 1);
$excludeDateList[] = $optionGroupValue['value'];
CRM_Core_BAO_OptionValue::create($optionGroupValue);
}
}
}
//Set type for API
$apiEntityType = explode("_", $type);
if (!empty($apiEntityType[1])) {
$apiType = $apiEntityType[1];
}
//Delete relations if any from recurring entity tables before inserting new relations for this entity id
if ($params['entity_id']) {
//If entity has any pre delete function, consider that first
if (CRM_Utils_Array::value('pre_delete_func', CRM_Core_BAO_RecurringEntity::$_recurringEntityHelper[$params['entity_table']]) && CRM_Utils_Array::value('helper_class', CRM_Core_BAO_RecurringEntity::$_recurringEntityHelper[$params['entity_table']])) {
$preDeleteResult = call_user_func_array(CRM_Core_BAO_RecurringEntity::$_recurringEntityHelper[$params['entity_table']]['pre_delete_func'], array($params['entity_id']));
if (!empty($preDeleteResult)) {
call_user_func(array(CRM_Core_BAO_RecurringEntity::$_recurringEntityHelper[$params['entity_table']]['helper_class'], $preDeleteResult));
}
}
//Ready to execute delete on entities if it has delete function set
if (CRM_Utils_Array::value('delete_func', CRM_Core_BAO_RecurringEntity::$_recurringEntityHelper[$params['entity_table']]) && CRM_Utils_Array::value('helper_class', CRM_Core_BAO_RecurringEntity::$_recurringEntityHelper[$params['entity_table']])) {
//Check if pre delete function has some ids to be deleted
if (!empty(CRM_Core_BAO_RecurringEntity::$_entitiesToBeDeleted)) {
foreach (CRM_Core_BAO_RecurringEntity::$_entitiesToBeDeleted as $eid) {
$result = civicrm_api3(ucfirst(strtolower($apiType)), CRM_Core_BAO_RecurringEntity::$_recurringEntityHelper[$params['entity_table']]['delete_func'], array('sequential' => 1, 'id' => $eid));
if ($result['error']) {
CRM_Core_Error::statusBounce('Error creating recurring list');
}
}
} else {
$getRelatedEntities = CRM_Core_BAO_RecurringEntity::getEntitiesFor($params['entity_id'], $params['entity_table'], FALSE);
foreach ($getRelatedEntities as $key => $value) {
$result = civicrm_api3(ucfirst(strtolower($apiType)), CRM_Core_BAO_RecurringEntity::$_recurringEntityHelper[$params['entity_table']]['delete_func'], array('sequential' => 1, 'id' => $value['id']));
if ($result['error']) {
CRM_Core_Error::statusBounce('Error creating recurring list');
}
}
}
}
// find all entities from the recurring set. At this point we 'll get entities which were not deleted
// for e.g due to participants being present. We need to delete them from recurring tables anyway.
$pRepeatingEntities = CRM_Core_BAO_RecurringEntity::getEntitiesFor($params['entity_id'], $params['entity_table']);
foreach ($pRepeatingEntities as $val) {
CRM_Core_BAO_RecurringEntity::delEntity($val['id'], $val['table'], TRUE);
}
}
$recursion = new CRM_Core_BAO_RecurringEntity();
//.........这里部分代码省略.........
示例5: civicrm_api3_job_send_reminder
/**
* Send the scheduled reminders for all contacts (either for activities or events)
*
* @param array $params (reference ) input parameters
* now - the time to use, in YmdHis format
* - makes testing a bit simpler since we can simulate past/future time
*
* @return boolean true if success, else false
* @static void
* @access public
*
*/
function civicrm_api3_job_send_reminder($params)
{
$lock = new CRM_Core_Lock('civimail.job.EmailProcessor');
if (!$lock->isAcquired()) {
return civicrm_api3_create_error('Could not acquire lock, another EmailProcessor process is running');
}
$result = CRM_Core_BAO_ActionSchedule::processQueue(CRM_Utils_Array::value('now', $params), $params);
$lock->release();
if ($result['is_error'] == 0) {
return civicrm_api3_create_success();
} else {
return civicrm_api3_create_error($result['messages']);
}
}
示例6: browse
/**
* Browse all Scheduled Reminders settings.
*
* @param null $action
*
* @return void
*/
public function browse($action = NULL)
{
// Get list of configured reminders
$reminderList = CRM_Core_BAO_ActionSchedule::getList();
if (is_array($reminderList)) {
// Add action links to each of the reminders
foreach ($reminderList as &$format) {
$action = array_sum(array_keys($this->links()));
if ($format['is_active']) {
$action -= CRM_Core_Action::ENABLE;
} else {
$action -= CRM_Core_Action::DISABLE;
}
$format['action'] = CRM_Core_Action::formLink(self::links(), $action, array('id' => $format['id']), ts('more'), FALSE, 'actionSchedule.manage.action', 'ActionSchedule', $format['id']);
}
}
$this->assign('rows', $reminderList);
}
示例7: postProcess
/**
* Process the form submission.
*/
public function postProcess()
{
if ($this->_action & CRM_Core_Action::DELETE) {
// delete reminder
CRM_Core_BAO_ActionSchedule::del($this->_id);
CRM_Core_Session::setStatus(ts('Selected Reminder has been deleted.'), ts('Record Deleted'), 'success');
if ($this->_context == 'event' && $this->_compId) {
$url = CRM_Utils_System::url('civicrm/event/manage/reminder', "reset=1&action=browse&id={$this->_compId}&component={$this->_context}&setTab=1");
$session = CRM_Core_Session::singleton();
$session->pushUserContext($url);
}
return;
}
$values = $this->controller->exportValues($this->getName());
$bao = $this->parseActionSchedule($values)->save();
// we need to set this on the form so that hooks can identify the created entity
$this->set('id', $bao->id);
$bao->free();
$status = ts("Your new Reminder titled %1 has been saved.", array(1 => "<strong>{$values['title']}</strong>"));
if ($this->_action) {
if ($this->_action & CRM_Core_Action::UPDATE) {
$status = ts("Your Reminder titled %1 has been updated.", array(1 => "<strong>{$values['title']}</strong>"));
}
if ($this->_context == 'event' && $this->_compId) {
$url = CRM_Utils_System::url('civicrm/event/manage/reminder', "reset=1&action=browse&id={$this->_compId}&component={$this->_context}&setTab=1");
$session = CRM_Core_Session::singleton();
$session->pushUserContext($url);
}
}
CRM_Core_Session::setStatus($status, ts('Saved'), 'success');
}
示例8: browse
/**
* Browse all Scheduled Reminders settings.
*
* @param null $action
*
* @return void
*/
public function browse($action = NULL)
{
//CRM-16777: Do not permit access to user, for page 'Administer->Communication->Schedule Reminder',
//when do not have 'administer CiviCRM' permission.
if (!CRM_Core_Permission::check('administer CiviCRM')) {
CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
}
// Get list of configured reminders
$reminderList = CRM_Core_BAO_ActionSchedule::getList();
if (is_array($reminderList)) {
// Add action links to each of the reminders
foreach ($reminderList as &$format) {
$action = array_sum(array_keys($this->links()));
if ($format['is_active']) {
$action -= CRM_Core_Action::ENABLE;
} else {
$action -= CRM_Core_Action::DISABLE;
}
$format['action'] = CRM_Core_Action::formLink(self::links(), $action, array('id' => $format['id']), ts('more'), FALSE, 'actionSchedule.manage.action', 'ActionSchedule', $format['id']);
}
}
$this->assign('rows', $reminderList);
}
示例9: run
public function run($now = NULL)
{
require_once 'CRM/Core/BAO/ActionSchedule.php';
CRM_Core_BAO_ActionSchedule::processQueue($now);
}
示例10: civicrm_api3_job_send_reminder
/**
* Send the scheduled reminders for all contacts (either for activities or events).
*
* @param array $params
* (reference ) input parameters.
* now - the time to use, in YmdHis format
* - makes testing a bit simpler since we can simulate past/future time
*
* @return array
*/
function civicrm_api3_job_send_reminder($params)
{
//note that $params['rowCount' can be overridden by one of the preferred syntaxes ($options['limit'] = x
//It's not clear whether than syntax can be passed in via the UI config - but this keeps the pre 4.4.4 behaviour
// in that case (ie. makes it non-configurable via the UI). Another approach would be to set a default of 0
// in the _spec function - but since that is a deprecated value it seems more contentious than this approach
$params['rowCount'] = 0;
$lock = Civi::lockManager()->acquire('worker.core.ActionSchedule');
if (!$lock->isAcquired()) {
return civicrm_api3_create_error('Could not acquire lock, another ActionSchedule process is running');
}
$result = CRM_Core_BAO_ActionSchedule::processQueue(CRM_Utils_Array::value('now', $params), $params);
$lock->release();
if ($result['is_error'] == 0) {
return civicrm_api3_create_success();
} else {
return civicrm_api3_create_error($result['messages']);
}
}
示例11: getRecipientListing
/**
* @param int $mappingID
* @param $recipientType
*
* @return array
*/
public static function getRecipientListing($mappingID, $recipientType)
{
if (!$mappingID) {
return array();
}
/** @var \Civi\ActionSchedule\Mapping $mapping */
$mapping = CRM_Utils_Array::first(CRM_Core_BAO_ActionSchedule::getMappings(array('id' => $mappingID)));
return $mapping->getRecipientListing($recipientType);
}
示例12: civicrm_api3_job_send_reminder
/**
* Send the scheduled reminders for all contacts (either for activities or events)
*
* @param array $params (reference ) input parameters
* now - the time to use, in YmdHis format
* - makes testing a bit simpler since we can simulate past/future time
*
* @return boolean true if success, else false
* @static void
* @access public
*
*/
function civicrm_api3_job_send_reminder($params)
{
require_once 'CRM/Core/BAO/ActionSchedule.php';
$result = CRM_Core_BAO_ActionSchedule::processQueue(CRM_Utils_Array::value('now', $params));
if ($result['is_error'] == 0) {
return civicrm_api3_create_success();
} else {
return civicrm_api3_create_error($result['messages']);
}
}
示例13: process
/**
* @param CRM_Event_Form_ManageEvent $form
*
* @return array
* @throws Exception
*/
public static function process(&$form)
{
if ($form->getVar('_id') <= 0) {
return NULL;
}
$default = array('link' => NULL, 'valid' => TRUE, 'active' => TRUE, 'current' => FALSE, 'class' => 'ajaxForm');
$tabs = array();
$tabs['settings'] = array('title' => ts('Info and Settings'), 'class' => 'ajaxForm livePage') + $default;
$tabs['location'] = array('title' => ts('Event Location')) + $default;
$tabs['fee'] = array('title' => ts('Fees')) + $default;
$tabs['registration'] = array('title' => ts('Online Registration')) + $default;
if (CRM_Core_Permission::check('administer CiviCRM') || CRM_Event_BAO_Event::checkPermission(NULL, CRM_Core_Permission::EDIT)) {
$tabs['reminder'] = array('title' => ts('Schedule Reminders'), 'class' => 'livePage') + $default;
}
$tabs['conference'] = array('title' => ts('Conference Slots')) + $default;
$tabs['friend'] = array('title' => ts('Tell a Friend')) + $default;
$tabs['pcp'] = array('title' => ts('Personal Campaigns')) + $default;
$tabs['repeat'] = array('title' => ts('Repeat')) + $default;
// Repeat tab must refresh page when switching repeat mode so js & vars will get set-up
if (!$form->_isRepeatingEvent) {
unset($tabs['repeat']['class']);
}
// check if we're in shopping cart mode for events
$enableCart = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::EVENT_PREFERENCES_NAME, 'enable_cart');
if (!$enableCart) {
unset($tabs['conference']);
}
$eventID = $form->getVar('_id');
if ($eventID) {
// disable tabs based on their configuration status
$eventNameMapping = CRM_Utils_Array::first(CRM_Core_BAO_ActionSchedule::getMappings(array('id' => CRM_Event_ActionMapping::EVENT_NAME_MAPPING_ID)));
$sql = "\nSELECT e.loc_block_id as is_location, e.is_online_registration, e.is_monetary, taf.is_active, pcp.is_active as is_pcp, sch.id as is_reminder, re.id as is_repeating_event\nFROM civicrm_event e\nLEFT JOIN civicrm_tell_friend taf ON ( taf.entity_table = 'civicrm_event' AND taf.entity_id = e.id )\nLEFT JOIN civicrm_pcp_block pcp ON ( pcp.entity_table = 'civicrm_event' AND pcp.entity_id = e.id )\nLEFT JOIN civicrm_action_schedule sch ON ( sch.mapping_id = %2 AND sch.entity_value = %1 )\nLEFT JOIN civicrm_recurring_entity re ON ( e.id = re.entity_id AND re.entity_table = 'civicrm_event' )\nWHERE e.id = %1\n";
//Check if repeat is configured
$eventHasParent = CRM_Core_BAO_RecurringEntity::getParentFor($eventID, 'civicrm_event');
$params = array(1 => array($eventID, 'Integer'), 2 => array($eventNameMapping->getId(), 'Integer'));
$dao = CRM_Core_DAO::executeQuery($sql, $params);
if (!$dao->fetch()) {
CRM_Core_Error::fatal();
}
if (!$dao->is_location) {
$tabs['location']['valid'] = FALSE;
}
if (!$dao->is_online_registration) {
$tabs['registration']['valid'] = FALSE;
}
if (!$dao->is_monetary) {
$tabs['fee']['valid'] = FALSE;
}
if (!$dao->is_active) {
$tabs['friend']['valid'] = FALSE;
}
if (!$dao->is_pcp) {
$tabs['pcp']['valid'] = FALSE;
}
if (!$dao->is_reminder) {
$tabs['reminder']['valid'] = FALSE;
}
if (!$dao->is_repeating_event) {
$tabs['repeat']['valid'] = FALSE;
}
}
// see if any other modules want to add any tabs
// note: status of 'valid' flag of any injected tab, needs to be taken care in the hook implementation.
CRM_Utils_Hook::tabset('civicrm/event/manage', $tabs, array('event_id' => $eventID));
$fullName = $form->getVar('_name');
$className = CRM_Utils_String::getClassName($fullName);
$new = '';
// hack for special cases.
switch ($className) {
case 'Event':
$attributes = $form->getVar('_attributes');
$class = strtolower(basename(CRM_Utils_Array::value('action', $attributes)));
break;
case 'EventInfo':
$class = 'settings';
break;
case 'ScheduleReminders':
$class = 'reminder';
break;
default:
$class = strtolower($className);
break;
}
if (array_key_exists($class, $tabs)) {
$tabs[$class]['current'] = TRUE;
$qfKey = $form->get('qfKey');
if ($qfKey) {
$tabs[$class]['qfKey'] = "&qfKey={$qfKey}";
}
}
if ($eventID) {
$reset = !empty($_GET['reset']) ? 'reset=1&' : '';
foreach ($tabs as $key => $value) {
if (!isset($tabs[$key]['qfKey'])) {
//.........这里部分代码省略.........
示例14: recipientListing
/**
* (Scheduled Reminders) Get the list of possible recipient filters.
*
* Ex: GET /civicrm/ajax/recipientListing?mappingID=contribpage&recipientType=
*/
public static function recipientListing()
{
$mappingID = filter_input(INPUT_GET, 'mappingID', FILTER_VALIDATE_REGEXP, array('options' => array('regexp' => '/^[a-zA-Z0-9_\\-]+$/')));
$recipientType = filter_input(INPUT_GET, 'recipientType', FILTER_VALIDATE_REGEXP, array('options' => array('regexp' => '/^[a-zA-Z0-9_\\-]+$/')));
CRM_Utils_JSON::output(array('recipients' => CRM_Utils_Array::toKeyValueRows(CRM_Core_BAO_ActionSchedule::getRecipientListing($mappingID, $recipientType))));
}
示例15: browse
/**
* Browse all events.
*
* @return void
*/
public function browse()
{
Civi::resources()->addStyleFile('civicrm', 'css/searchForm.css', 1, 'html-header');
$this->_sortByCharacter = CRM_Utils_Request::retrieve('sortByCharacter', 'String', $this);
$createdId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, FALSE, 0);
if (strtolower($this->_sortByCharacter) == 'all' || !empty($_POST)) {
$this->_sortByCharacter = '';
$this->set('sortByCharacter', '');
}
$this->_force = $this->_searchResult = NULL;
$this->search();
$params = array();
$this->_force = CRM_Utils_Request::retrieve('force', 'Boolean', $this, FALSE);
$this->_searchResult = CRM_Utils_Request::retrieve('searchResult', 'Boolean', $this);
$whereClause = $this->whereClause($params, FALSE, $this->_force);
$this->pagerAToZ($whereClause, $params);
$params = array();
$whereClause = $this->whereClause($params, TRUE, $this->_force);
// because is_template != 1 would be to simple
$whereClause .= ' AND (is_template = 0 OR is_template IS NULL)';
$this->pager($whereClause, $params);
list($offset, $rowCount) = $this->_pager->getOffsetAndRowCount();
// get all custom groups sorted by weight
$manageEvent = array();
$query = "\n SELECT *\n FROM civicrm_event\n WHERE {$whereClause}\nORDER BY start_date desc\n LIMIT {$offset}, {$rowCount}";
$dao = CRM_Core_DAO::executeQuery($query, $params, TRUE, 'CRM_Event_DAO_Event');
$permissions = CRM_Event_BAO_Event::checkPermission();
//get all campaigns.
$allCampaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE);
// get the list of active event pcps
$eventPCPS = array();
$pcpDao = new CRM_PCP_DAO_PCPBlock();
$pcpDao->entity_table = 'civicrm_event';
$pcpDao->find();
while ($pcpDao->fetch()) {
$eventPCPS[$pcpDao->entity_id] = $pcpDao->entity_id;
}
// check if we're in shopping cart mode for events
$enableCart = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::EVENT_PREFERENCES_NAME, 'enable_cart');
$this->assign('eventCartEnabled', $enableCart);
$mapping = CRM_Utils_Array::first(CRM_Core_BAO_ActionSchedule::getMappings(array('id' => CRM_Event_ActionMapping::EVENT_NAME_MAPPING_ID)));
$eventType = CRM_Core_OptionGroup::values('event_type');
while ($dao->fetch()) {
if (in_array($dao->id, $permissions[CRM_Core_Permission::VIEW])) {
$manageEvent[$dao->id] = array();
$repeat = CRM_Core_BAO_RecurringEntity::getPositionAndCount($dao->id, 'civicrm_event');
$manageEvent[$dao->id]['repeat'] = '';
if ($repeat) {
$manageEvent[$dao->id]['repeat'] = ts('Repeating (%1 of %2)', array(1 => $repeat[0], 2 => $repeat[1]));
}
CRM_Core_DAO::storeValues($dao, $manageEvent[$dao->id]);
// form all action links
$action = array_sum(array_keys($this->links()));
if ($dao->is_active) {
$action -= CRM_Core_Action::ENABLE;
} else {
$action -= CRM_Core_Action::DISABLE;
}
if (!in_array($dao->id, $permissions[CRM_Core_Permission::DELETE])) {
$action -= CRM_Core_Action::DELETE;
}
if (!in_array($dao->id, $permissions[CRM_Core_Permission::EDIT])) {
$action -= CRM_Core_Action::UPDATE;
}
$manageEvent[$dao->id]['action'] = CRM_Core_Action::formLink(self::links(), $action, array('id' => $dao->id), ts('more'), TRUE, 'event.manage.list', 'Event', $dao->id);
$params = array('entity_id' => $dao->id, 'entity_table' => 'civicrm_event', 'is_active' => 1);
$defaults['location'] = CRM_Core_BAO_Location::getValues($params, TRUE);
$manageEvent[$dao->id]['friend'] = CRM_Friend_BAO_Friend::getValues($params);
if (isset($defaults['location']['address'][1]['city'])) {
$manageEvent[$dao->id]['city'] = $defaults['location']['address'][1]['city'];
}
if (isset($defaults['location']['address'][1]['state_province_id'])) {
$manageEvent[$dao->id]['state_province'] = CRM_Core_PseudoConstant::stateProvince($defaults['location']['address'][1]['state_province_id']);
}
//show campaigns on selector.
$manageEvent[$dao->id]['campaign'] = CRM_Utils_Array::value($dao->campaign_id, $allCampaigns);
$manageEvent[$dao->id]['reminder'] = CRM_Core_BAO_ActionSchedule::isConfigured($dao->id, $mapping->getId());
$manageEvent[$dao->id]['is_pcp_enabled'] = CRM_Utils_Array::value($dao->id, $eventPCPS);
$manageEvent[$dao->id]['event_type'] = CRM_Utils_Array::value($manageEvent[$dao->id]['event_type_id'], $eventType);
$manageEvent[$dao->id]['is_repeating_event'] = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_RecurringEntity', $dao->id, 'parent_id', 'entity_id');
// allow hooks to set 'field' value which allows configuration pop-up to show a tab as enabled/disabled
CRM_Utils_Hook::tabset('civicrm/event/manage/rows', $manageEvent, array('event_id' => $dao->id));
}
}
$manageEvent['tab'] = self::tabs($enableCart);
$this->assign('rows', $manageEvent);
$statusTypes = CRM_Event_PseudoConstant::participantStatus(NULL, 'is_counted = 1');
$statusTypesPending = CRM_Event_PseudoConstant::participantStatus(NULL, 'is_counted = 0');
$findParticipants['statusCounted'] = implode(', ', array_values($statusTypes));
$findParticipants['statusNotCounted'] = implode(', ', array_values($statusTypesPending));
$this->assign('findParticipants', $findParticipants);
}