当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Event_BAO_Event::validRegistrationDate方法代码示例

本文整理汇总了PHP中CRM_Event_BAO_Event::validRegistrationDate方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Event_BAO_Event::validRegistrationDate方法的具体用法?PHP CRM_Event_BAO_Event::validRegistrationDate怎么用?PHP CRM_Event_BAO_Event::validRegistrationDate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Event_BAO_Event的用法示例。


在下文中一共展示了CRM_Event_BAO_Event::validRegistrationDate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run


//.........这里部分代码省略.........
             require_once 'CRM/Core/OptionGroup.php';
             require_once 'CRM/Core/BAO/Discount.php';
             $discountId = CRM_Core_BAO_Discount::findSet($this->_id, 'civicrm_event');
             if ($discountId) {
                 CRM_Core_OptionGroup::getAssoc(CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Discount', $discountId, 'option_group_id'), $values['feeBlock'], false, 'id');
             } else {
                 CRM_Core_OptionGroup::getAssoc("civicrm_event.amount.{$this->_id}", $values['feeBlock']);
             }
         }
     }
     $params = array('entity_id' => $this->_id, 'entity_table' => 'civicrm_event');
     require_once 'CRM/Core/BAO/Location.php';
     $values['location'] = CRM_Core_BAO_Location::getValues($params, true);
     //retrieve custom field information
     require_once 'CRM/Core/BAO/CustomGroup.php';
     $groupTree =& CRM_Core_BAO_CustomGroup::getTree("Event", $this, $this->_id, 0, $values['event']['event_type_id']);
     CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree);
     $this->assign('action', CRM_Core_Action::VIEW);
     //To show the event location on maps directly on event info page
     $locations =& CRM_Event_BAO_Event::getMapInfo($this->_id);
     if (!empty($locations) && CRM_Utils_Array::value('is_map', $values['event'])) {
         $this->assign('locations', $locations);
         $this->assign('mapProvider', $config->mapProvider);
         $this->assign('mapKey', $config->mapAPIKey);
         $sumLat = $sumLng = 0;
         $maxLat = $maxLng = -400;
         $minLat = $minLng = +400;
         foreach ($locations as $location) {
             $sumLat += $location['lat'];
             $sumLng += $location['lng'];
             if ($location['lat'] > $maxLat) {
                 $maxLat = $location['lat'];
             }
             if ($location['lat'] < $minLat) {
                 $minLat = $location['lat'];
             }
             if ($location['lng'] > $maxLng) {
                 $maxLng = $location['lng'];
             }
             if ($location['lng'] < $minLng) {
                 $minLng = $location['lng'];
             }
         }
         $center = array('lat' => (double) $sumLat / count($locations), 'lng' => (double) $sumLng / count($locations));
         $span = array('lat' => (double) ($maxLat - $minLat), 'lng' => (double) ($maxLng - $minLng));
         $this->assign_by_ref('center', $center);
         $this->assign_by_ref('span', $span);
     }
     require_once 'CRM/Event/BAO/Participant.php';
     $eventFullMessage = CRM_Event_BAO_Participant::eventFull($this->_id);
     if ($eventFullMessage and $noFullMsg == 'false') {
         if (CRM_Utils_Array::value('has_waitlist', $values['event'])) {
             $eventFullMessage = null;
             $statusMessage = CRM_Utils_Array::value('waitlist_text', $values['event'], 'Event is currently full, but you can register and be a part of waiting list.');
         } else {
             $statusMessage = $eventFullMessage;
         }
         CRM_Core_Session::setStatus($statusMessage);
     }
     if (CRM_Utils_Array::value('is_online_registration', $values['event'])) {
         if (CRM_Event_BAO_Event::validRegistrationDate($values['event'], $this->_id)) {
             if (!$eventFullMessage) {
                 $registerText = ts('Register Now');
                 if (CRM_Utils_Array::value('registration_link_text', $values['event'])) {
                     $registerText = $values['event']['registration_link_text'];
                 }
                 //Fixed for CRM-4855
                 if (CRM_Event_BAO_Event::showHideRegistrationLink($values)) {
                     $this->assign('allowRegistration', true);
                 }
                 $this->assign('registerText', $registerText);
             }
             // we always generate urls for the front end in joomla
             if ($action == CRM_Core_Action::PREVIEW) {
                 $url = CRM_Utils_System::url('civicrm/event/register', "id={$this->_id}&reset=1&action=preview", true, null, true, true);
             } else {
                 $url = CRM_Utils_System::url('civicrm/event/register', "id={$this->_id}&reset=1", true, null, true, true);
             }
             if (!$eventFullMessage) {
                 $this->assign('registerURL', $url);
             }
         }
         if ($action == CRM_Core_Action::PREVIEW) {
             $mapURL = CRM_Utils_System::url('civicrm/contact/map/event', "eid={$this->_id}&reset=1&action=preview", true, null, true, true);
         } else {
             $mapURL = CRM_Utils_System::url('civicrm/contact/map/event', "eid={$this->_id}&reset=1", true, null, true, true);
         }
         $this->assign('mapURL', $mapURL);
     }
     // we do not want to display recently viewed items, so turn off
     $this->assign('displayRecent', false);
     // set page title = event title
     CRM_Utils_System::setTitle($values['event']['title']);
     $this->assign('event', $values['event']);
     if (isset($values['feeBlock'])) {
         $this->assign('feeBlock', $values['feeBlock']);
     }
     $this->assign('location', $values['location']);
     parent::run();
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:101,代码来源:EventInfo.php

示例2: updateParticipantStatus

 public function updateParticipantStatus()
 {
     require_once 'CRM/Event/PseudoConstant.php';
     $participantRole = CRM_Event_PseudoConstant::participantRole();
     $pendingStatuses = CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Pending'");
     $expiredStatuses = CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Negative'");
     $waitingStatuses = CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Waiting'");
     //build the required status ids.
     $statusIds = '(' . implode(',', array_merge(array_keys($pendingStatuses), array_keys($waitingStatuses))) . ')';
     $participantDetails = $fullEvents = array();
     $expiredParticipantCount = $waitingConfirmCount = $waitingApprovalCount = 0;
     //get all participant who's status in class pending and waiting
     $query = "SELECT * FROM civicrm_participant WHERE status_id IN {$statusIds} ORDER BY register_date";
     $query = "\n   SELECT  participant.id,\n           participant.contact_id,\n           participant.status_id,\n           participant.register_date,\n           participant.registered_by_id,\n           participant.event_id,\n           event.title as eventTitle,\n           event.registration_start_date,\n           event.registration_end_date,\n           event.end_date,\n           event.expiration_time,\n           event.requires_approval\n     FROM  civicrm_participant participant\nLEFT JOIN  civicrm_event event ON ( event.id = participant.event_id )\n    WHERE  participant.status_id IN {$statusIds}\n     AND   (event.end_date > now() OR event.end_date IS NULL)\n     AND   event.is_active = 1 \n ORDER BY  participant.register_date, participant.id \n";
     $dao = CRM_Core_DAO::executeQuery($query);
     while ($dao->fetch()) {
         $participantDetails[$dao->id] = array('id' => $dao->id, 'event_id' => $dao->event_id, 'status_id' => $dao->status_id, 'contact_id' => $dao->contact_id, 'register_date' => $dao->register_date, 'registered_by_id' => $dao->registered_by_id, 'eventTitle' => $dao->eventTitle, 'registration_start_date' => $dao->registration_start_date, 'registration_end_date' => $dao->registration_end_date, 'end_date' => $dao->end_date, 'expiration_time' => $dao->expiration_time, 'requires_approval' => $dao->requires_approval);
     }
     if (!empty($participantDetails)) {
         //cron 1. move participant from pending to expire if needed
         foreach ($participantDetails as $participantId => $values) {
             //process the additional participant at the time of
             //primary participant, don't process separately.
             if (CRM_Utils_Array::value('registered_by_id', $values)) {
                 continue;
             }
             $expirationTime = CRM_Utils_Array::value('expiration_time', $values);
             if ($expirationTime && array_key_exists($values['status_id'], $pendingStatuses)) {
                 //get the expiration and registration pending time.
                 $expirationSeconds = $expirationTime * 3600;
                 $registrationPendingSeconds = CRM_Utils_Date::unixTime($values['register_date']);
                 // expired registration since registration cross allow confirmation time.
                 if ($expirationSeconds + $registrationPendingSeconds < time()) {
                     //lets get the transaction mechanism.
                     require_once 'CRM/Core/Transaction.php';
                     $transaction = new CRM_Core_Transaction();
                     require_once 'CRM/Event/BAO/Participant.php';
                     $ids = array($participantId);
                     $expiredId = array_search('Expired', $expiredStatuses);
                     $results = CRM_Event_BAO_Participant::transitionParticipants($ids, $expiredId, $values['status_id'], TRUE, TRUE);
                     $transaction->commit();
                     if (!empty($results)) {
                         //diaplay updated participants
                         if (is_array($results['updatedParticipantIds']) && !empty($results['updatedParticipantIds'])) {
                             foreach ($results['updatedParticipantIds'] as $processedId) {
                                 $expiredParticipantCount += 1;
                                 echo "<br /><br />- status updated to: Expired";
                                 //mailed participants.
                                 if (is_array($results['mailedParticipants']) && array_key_exists($processedId, $results['mailedParticipants'])) {
                                     echo "<br />Expiration Mail sent to: {$results['mailedParticipants'][$processedId]}";
                                 }
                             }
                         }
                     }
                 }
             }
         }
         //cron 1 end.
         //cron 2. lets move participants from waiting list to pending status
         foreach ($participantDetails as $participantId => $values) {
             //process the additional participant at the time of
             //primary participant, don't process separately.
             if (CRM_Utils_Array::value('registered_by_id', $values)) {
                 continue;
             }
             if (array_key_exists($values['status_id'], $waitingStatuses) && !array_key_exists($values['event_id'], $fullEvents)) {
                 if ($waitingStatuses[$values['status_id']] == 'On waitlist' && CRM_Event_BAO_Event::validRegistrationDate($values)) {
                     //check the target event having space.
                     require_once 'CRM/Event/BAO/Participant.php';
                     $eventOpenSpaces = CRM_Event_BAO_Participant::eventFull($values['event_id'], TRUE, FALSE);
                     if ($eventOpenSpaces && is_numeric($eventOpenSpaces) || $eventOpenSpaces === NULL) {
                         //get the additional participant if any.
                         $additionalIds = CRM_Event_BAO_Participant::getAdditionalParticipantIds($participantId);
                         $allIds = array($participantId);
                         if (!empty($additionalIds)) {
                             $allIds = array_merge($allIds, $additionalIds);
                         }
                         $pClause = ' participant.id IN ( ' . implode(' , ', $allIds) . ' )';
                         $requiredSpaces = CRM_Event_BAO_Event::eventTotalSeats($values['event_id'], $pClause);
                         //need to check as to see if event has enough speces
                         if ($requiredSpaces <= $eventOpenSpaces || $eventOpenSpaces === NULL) {
                             require_once 'CRM/Core/Transaction.php';
                             $transaction = new CRM_Core_Transaction();
                             require_once 'CRM/Event/BAO/Participant.php';
                             $ids = array($participantId);
                             $updateStatusId = array_search('Pending from waitlist', $pendingStatuses);
                             //lets take a call to make pending or need approval
                             if ($values['requires_approval']) {
                                 $updateStatusId = array_search('Awaiting approval', $waitingStatuses);
                             }
                             $results = CRM_Event_BAO_Participant::transitionParticipants($ids, $updateStatusId, $values['status_id'], TRUE, TRUE);
                             //commit the transaction.
                             $transaction->commit();
                             if (!empty($results)) {
                                 //diaplay updated participants
                                 if (is_array($results['updatedParticipantIds']) && !empty($results['updatedParticipantIds'])) {
                                     foreach ($results['updatedParticipantIds'] as $processedId) {
                                         if ($values['requires_approval']) {
                                             $waitingApprovalCount += 1;
                                             echo "<br /><br />- status updated to: Awaiting approval";
//.........这里部分代码省略.........
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:101,代码来源:ParticipantProcessor.php

示例3: setTemplateEventValues

 /**
  * create the event blocks for upcoming events
  *
  * @return void
  * @access private
  */
 private function setTemplateEventValues()
 {
     $config =& CRM_Core_Config::singleton();
     require_once 'CRM/Event/BAO/Event.php';
     $info = CRM_Event_BAO_Event::getCompleteInfo();
     if ($info) {
         $session =& CRM_Core_Session::singleton();
         // check if registration link should be displayed
         foreach ($info as $id => $event) {
             $info[$id]['onlineRegistration'] = CRM_Event_BAO_Event::validRegistrationDate($event, $session->get('userID'));
         }
         self::setProperty(self::EVENT, 'templateValues', array('eventBlock' => $info));
     }
 }
开发者ID:bhirsch,项目名称:civicrm,代码行数:20,代码来源:Block.php


注:本文中的CRM_Event_BAO_Event::validRegistrationDate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。