本文整理汇总了PHP中CRM_Utils_Date::unixTime方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_Date::unixTime方法的具体用法?PHP CRM_Utils_Date::unixTime怎么用?PHP CRM_Utils_Date::unixTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Utils_Date
的用法示例。
在下文中一共展示了CRM_Utils_Date::unixTime方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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}";
}
示例2: validRegistrationDate
static function validRegistrationDate(&$values, $contactID)
{
// make sure that we are between registration start date and registration end date
$startDate = CRM_Utils_Date::unixTime(CRM_Utils_Array::value('registration_start_date', $values));
$endDate = CRM_Utils_Date::unixTime(CRM_Utils_Array::value('registration_end_date', $values));
$now = time();
$validDate = true;
if ($startDate && $startDate >= $now) {
$validDate = false;
}
if ($endDate && $endDate < $now) {
$validDate = false;
}
// also check that the user has permission to register for this event
$hasPermission = CRM_Core_Permission::event(CRM_Core_Permission::EDIT, $contactID);
return $validDate && $hasPermission;
}
示例3: validRegistrationDate
/**
* @param $values
*
* @return bool
*/
static function validRegistrationDate(&$values)
{
// make sure that we are between registration start date and registration end date
$startDate = CRM_Utils_Date::unixTime(CRM_Utils_Array::value('registration_start_date', $values));
$endDate = CRM_Utils_Date::unixTime(CRM_Utils_Array::value('registration_end_date', $values));
$eventEnd = CRM_Utils_Date::unixTime(CRM_Utils_Array::value('end_date', $values));
$now = time();
$validDate = TRUE;
if ($startDate && $startDate >= $now) {
$validDate = FALSE;
}
if ($endDate && $endDate < $now) {
$validDate = FALSE;
}
if ($eventEnd && $eventEnd < $now) {
$validDate = FALSE;
}
return $validDate;
}
示例4: 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";
//.........这里部分代码省略.........
示例5: getContributionPageData
/**
* Gets all campaign related data and returns it as a std class.
*
* @param int $contributionPageID
* @param string $widgetID
*
* @return object
*/
public function getContributionPageData($contributionPageID, $widgetID)
{
$config = CRM_Core_Config::singleton();
self::registerRequest($contributionPageID, $widgetID, __FUNCTION__);
$data = new stdClass();
if (empty($contributionPageID) || CRM_Utils_Type::validate($contributionPageID, 'Integer') == NULL) {
$data->is_error = TRUE;
CRM_Core_Error::debug_log_message("{$contributionPageID} is not set");
return $data;
}
$widget = new CRM_Contribute_DAO_Widget();
$widget->contribution_page_id = $contributionPageID;
if (!$widget->find(TRUE)) {
$data->is_error = TRUE;
CRM_Core_Error::debug_log_message("{$contributionPageID} is not found");
return $data;
}
$data->is_error = FALSE;
if (!$widget->is_active) {
$data->is_active = FALSE;
}
$data->is_active = TRUE;
$data->title = $widget->title;
$data->logo = $widget->url_logo;
$data->button_title = $widget->button_title;
$data->button_url = CRM_Utils_System::url('civicrm/contribute/transact', "reset=1&id={$contributionPageID}", TRUE, NULL, FALSE, TRUE);
$data->about = $widget->about;
$query = "\nSELECT count( id ) as count,\n sum( total_amount) as amount\nFROM civicrm_contribution\nWHERE is_test = 0\nAND contribution_status_id = 1\nAND contribution_page_id = %1";
$params = array(1 => array($contributionPageID, 'Integer'));
$dao = CRM_Core_DAO::executeQuery($query, $params);
if ($dao->fetch()) {
$data->num_donors = $dao->count;
$data->money_raised = $dao->amount;
} else {
$data->num_donors = $data->money_raised = 0;
}
$query = "\nSELECT goal_amount, start_date, end_date, is_active\nFROM civicrm_contribution_page\nWHERE id = %1";
$params = array(1 => array($contributionPageID, 'Integer'));
$dao = CRM_Core_DAO::executeQuery($query, $params);
if ($dao->fetch()) {
$data->money_target = $dao->goal_amount;
$data->campaign_start = CRM_Utils_Date::customFormat($dao->start_date, $config->dateformatFull);
$data->campaign_end = CRM_Utils_Date::customFormat($dao->end_date, $config->dateformatFull);
// check for time being between start and end date
$now = time();
if ($dao->start_date) {
$startDate = CRM_Utils_Date::unixTime($dao->start_date);
if ($startDate && $startDate >= $now) {
$data->is_active = FALSE;
}
}
if ($dao->end_date) {
$endDate = CRM_Utils_Date::unixTime($dao->end_date);
if ($endDate && $endDate < $now) {
$data->is_active = FALSE;
}
}
} else {
$data->is_active = FALSE;
}
// if is_active is false, show this link and hide the contribute button
$data->homepage_link = $widget->url_homepage;
// movie clip colors, must be in '0xRRGGBB' format
$data->colors = array();
$hexPrefix = '0x';
$data->colors["title"] = str_replace('#', $hexPrefix, $widget->color_title);
$data->colors["button"] = str_replace('#', $hexPrefix, $widget->color_button);
$data->colors["bar"] = str_replace('#', $hexPrefix, $widget->color_bar);
$data->colors["main_text"] = str_replace('#', $hexPrefix, $widget->color_main_text);
$data->colors["main"] = str_replace('#', $hexPrefix, $widget->color_main);
$data->colors["main_bg"] = str_replace('#', $hexPrefix, $widget->color_main_bg);
$data->colors["bg"] = str_replace('#', $hexPrefix, $widget->color_bg);
// these two have colors as normal hex format
// because they're being used in a CSS object
$data->colors["about_link"] = str_replace('#', $hexPrefix, $widget->color_about_link);
$data->colors["homepage_link"] = str_replace('#', $hexPrefix, $widget->color_homepage_link);
return $data;
}
示例6: run
//.........这里部分代码省略.........
}
}
$default = array();
CRM_Core_DAO::commonRetrieveAll('CRM_Contribute_DAO_ContributionPage', 'id', $pcpInfo['contribution_page_id'], $default, array('start_date', 'end_date'));
require_once "CRM/Contribute/PseudoConstant.php";
$this->assign('pageName', CRM_Contribute_PseudoConstant::contributionPage($pcpInfo['contribution_page_id'], true));
if ($pcpInfo['contact_id'] == $session->get('userID')) {
$owner = $default[$pcpInfo['contribution_page_id']];
$owner['status'] = CRM_Utils_Array::value($pcpInfo['status_id'], $pcpStatus);
$this->assign('owner', $owner);
require_once 'CRM/Contribute/BAO/PCP.php';
$link = CRM_Contribute_BAO_PCP::pcpLinks();
unset($link['all'][CRM_Core_Action::ENABLE]);
$hints = array(CRM_Core_Action::UPDATE => ts('Change the content and appearance of your page'), CRM_Core_Action::DETACH => ts('Send emails inviting your friends to support your campaign!'), CRM_Core_Action::BROWSE => ts('Update your personal contact information'), CRM_Core_Action::DISABLE => ts('De-activate the page (you can re-activate it later)'), CRM_Core_Action::DELETE => ts('Remove the page (this cannot be undone!)'));
CRM_Core_DAO::commonRetrieveAll('CRM_Contribute_DAO_PCPBlock', $pcpInfo['contribution_page_id'], 'entity_id', $blockValues, array('is_tellfriend_enabled'));
$blockId = array_pop($blockValues);
$replace = array('id' => $this->_id, 'block' => $blockId['id']);
if (!CRM_Utils_Array::value('is_tellfriend_enabled', $blockId) || CRM_Utils_Array::value('status_id', $pcpInfo) != $approvedId) {
unset($link['all'][CRM_Core_Action::DETACH]);
}
$this->assign('links', $link['all']);
$this->assign('hints', $hints);
$this->assign('replace', $replace);
}
$honor = CRM_Contribute_BAO_PCP::honorRoll($this->_id);
if ($file_id = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_EntityFile', $this->_id, 'file_id', 'entity_id')) {
$image = '<img src="' . CRM_Utils_System::url('civicrm/file', "reset=1&id={$file_id}&eid={$this->_id}") . '" />';
$this->assign('image', $image);
}
$totalAmount = CRM_Contribute_BAO_PCP::thermoMeter($this->_id);
$achieved = round($totalAmount / $pcpInfo['goal_amount'] * 100, 2);
if ($linkText = CRM_Contribute_BAO_PCP::getPcpBlockStatus($pcpInfo['contribution_page_id'])) {
$linkTextUrl = CRM_Utils_System::url('civicrm/contribute/campaign', "action=add&reset=1&pageId={$pcpInfo['contribution_page_id']}", true, null, true, true);
$this->assign('linkTextUrl', $linkTextUrl);
$this->assign('linkText', $linkText);
}
$this->assign('honor', $honor);
$this->assign('total', $totalAmount ? $totalAmount : '0.0');
$this->assign('achieved', $achieved <= 100 ? $achieved : 100);
if ($achieved <= 100) {
$this->assign('remaining', 100 - $achieved);
}
// make sure that we are between registration start date and registration end date
$startDate = CRM_Utils_Date::unixTime(CRM_Utils_Array::value('start_date', $owner));
$endDate = CRM_Utils_Date::unixTime(CRM_Utils_Array::value('end_date', $owner));
$now = time();
$validDate = true;
if ($startDate && $startDate >= $now) {
$validDate = false;
}
if ($endDate && $endDate < $now) {
$validDate = false;
}
$this->assign('validDate', true);
if ($validDate) {
$contributionText = ts('Contribute Now');
if (CRM_Utils_Array::value('donate_link_text', $pcpInfo)) {
$contributionText = $pcpInfo['donate_link_text'];
}
$this->assign('contributionText', $contributionText);
// we always generate urls for the front end in joomla
if ($action == CRM_Core_Action::PREVIEW) {
$url = CRM_Utils_System::url('civicrm/contribute/transact', "id={$pcpInfo['contribution_page_id']}&pcpId={$this->_id}&reset=1&action=preview", true, null, true, true);
} else {
$url = CRM_Utils_System::url('civicrm/contribute/transact', "id={$pcpInfo['contribution_page_id']}&pcpId={$this->_id}&reset=1", true, null, true, true);
}
$this->assign('contributeURL', $url);
}
// we do not want to display recently viewed items, so turn off
$this->assign('displayRecent', false);
$single = $permission = false;
switch ($action) {
case CRM_Core_Action::BROWSE:
$subForm = 'PCPAccount';
$form = "CRM_Contribute_Form_PCP_{$subForm}";
$single = true;
break;
case CRM_Core_Action::UPDATE:
$subForm = 'Campaign';
$form = "CRM_Contribute_Form_PCP_{$subForm}";
$single = true;
break;
}
$userID = $session->get('userID');
//make sure the user has "administer CiviCRM" permission
//OR has created the PCP
if (CRM_Core_Permission::check('administer CiviCRM') || $userID && CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_PCP', $this->_id, 'contact_id') == $userID) {
$permission = true;
}
if ($single && $permission) {
require_once 'CRM/Core/Controller/Simple.php';
$controller =& new CRM_Core_Controller_Simple($form, $subForm, $action);
$controller->set('id', $this->_id);
$controller->set('single', true);
$controller->process();
return $controller->run();
}
$session->pushUserContext(CRM_Utils_System::url(CRM_Utils_System::currentPath(), 'reset=1&id=' . $this->_id));
parent::run();
}
示例7: 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;
}
示例8: validRegistrationDate
/**
* @param $values
*
* @return bool
*/
public static function validRegistrationDate(&$values)
{
// make sure that we are between registration start date and end dates
// and that if the event has ended, registration is still specifically open
$startDate = CRM_Utils_Date::unixTime(CRM_Utils_Array::value('registration_start_date', $values));
$endDate = CRM_Utils_Date::unixTime(CRM_Utils_Array::value('registration_end_date', $values));
$eventEnd = CRM_Utils_Date::unixTime(CRM_Utils_Array::value('end_date', $values));
$now = time();
$validDate = TRUE;
if ($startDate && $startDate >= $now) {
$validDate = FALSE;
} elseif ($endDate && $endDate < $now) {
$validDate = FALSE;
} elseif ($eventEnd && $eventEnd < $now && !$endDate) {
$validDate = FALSE;
}
return $validDate;
}
示例9: run
//.........这里部分代码省略.........
unset($link['all'][CRM_Core_Action::ENABLE]);
break;
case 0:
unset($link['all'][CRM_Core_Action::DISABLE]);
break;
}
$this->assign('links', $link['all']);
$this->assign('hints', $hints);
$this->assign('replace', $replace);
}
$honor = CRM_PCP_BAO_PCP::honorRoll($this->_id);
$entityFile = CRM_Core_BAO_File::getEntityFile('civicrm_pcp', $this->_id);
if (!empty($entityFile)) {
$fileInfo = reset($entityFile);
$fileId = $fileInfo['fileID'];
$image = '<img src="' . CRM_Utils_System::url('civicrm/file', "reset=1&id={$fileId}&eid={$this->_id}") . '" />';
$this->assign('image', $image);
}
$totalAmount = CRM_PCP_BAO_PCP::thermoMeter($this->_id);
$achieved = round($totalAmount / $pcpInfo['goal_amount'] * 100, 2);
if ($pcpBlock->is_active == 1) {
$linkTextUrl = CRM_Utils_System::url('civicrm/contribute/campaign', "action=add&reset=1&pageId={$pcpInfo['page_id']}&component={$pcpInfo['page_type']}", TRUE, NULL, TRUE, TRUE);
$this->assign('linkTextUrl', $linkTextUrl);
$this->assign('linkText', $pcpBlock->link_text);
}
$this->assign('honor', $honor);
$this->assign('total', $totalAmount ? $totalAmount : '0.0');
$this->assign('achieved', $achieved <= 100 ? $achieved : 100);
if ($achieved <= 100) {
$this->assign('remaining', 100 - $achieved);
}
// make sure that we are between contribution page start and end dates OR registration start date and end dates if they are set
if ($pcpBlock->entity_table == 'civicrm_event') {
$startDate = CRM_Utils_Date::unixTime(CRM_Utils_Array::value('registration_start_date', $pageInfo));
$endDate = CRM_Utils_Date::unixTime(CRM_Utils_Array::value('registration_end_date', $pageInfo));
} else {
$startDate = CRM_Utils_Date::unixTime(CRM_Utils_Array::value('start_date', $pageInfo));
$endDate = CRM_Utils_Date::unixTime(CRM_Utils_Array::value('end_date', $pageInfo));
}
$now = time();
$validDate = TRUE;
if ($startDate && $startDate >= $now) {
$validDate = FALSE;
}
if ($endDate && $endDate < $now) {
$validDate = FALSE;
}
$this->assign('validDate', $validDate);
// form parent page url
if ($action == CRM_Core_Action::PREVIEW) {
$parentUrl = CRM_Utils_System::url($urlBase, "id={$pcpInfo['page_id']}&reset=1&action=preview", TRUE, NULL, TRUE, TRUE);
} else {
$parentUrl = CRM_Utils_System::url($urlBase, "id={$pcpInfo['page_id']}&reset=1", TRUE, NULL, TRUE, TRUE);
}
$this->assign('parentURL', $parentUrl);
if ($validDate) {
$contributionText = ts('Contribute Now');
if (!empty($pcpInfo['donate_link_text'])) {
$contributionText = $pcpInfo['donate_link_text'];
}
$this->assign('contributionText', $contributionText);
// we always generate urls for the front end in joomla
if ($action == CRM_Core_Action::PREVIEW) {
$url = CRM_Utils_System::url($urlBase, "id=" . $pcpBlock->target_entity_id . "&pcpId={$this->_id}&reset=1&action=preview", TRUE, NULL, TRUE, TRUE);
} else {
$url = CRM_Utils_System::url($urlBase, "id=" . $pcpBlock->target_entity_id . "&pcpId={$this->_id}&reset=1", TRUE, NULL, TRUE, TRUE);
示例10: voterClause
function voterClause($params)
{
$voterClause = null;
if (!is_array($params) || empty($params)) {
return $voterClause;
}
$surveyId = CRM_Utils_Array::value('campaign_survey_id', $params);
$interviewerId = CRM_Utils_Array::value('survey_interviewer_id', $params);
$searchVoterFor = CRM_Utils_Array::value('campaign_search_voter_for', $params);
//get the survey activities.
require_once 'CRM/Core/PseudoConstant.php';
$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;
}
}
}
require_once 'CRM/Campaign/BAO/Survey.php';
$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'];
}
}
}
if (!empty($voterIds)) {
$voterClause = "( contact_a.id {$operator} ( " . implode(', ', $voterIds) . ' ) )';
}
}
return $voterClause;
}
示例11: preProcess
//.........这里部分代码省略.........
if ((isset($postProfileType) && $postProfileType == 'Membership' || isset($preProfileType) && $preProfileType == 'Membership') && !$this->_membershipBlock['is_active']) {
CRM_Core_Error::fatal(ts('This page includes a Profile with Membership fields - but the Membership Block is NOT enabled. Please notify the site administrator.'));
}
require_once 'CRM/Pledge/BAO/PledgeBlock.php';
$pledgeBlock = CRM_Pledge_BAO_PledgeBlock::getPledgeBlock($this->_id);
if ($pledgeBlock) {
$this->_values['pledge_block_id'] = CRM_Utils_Array::value('id', $pledgeBlock);
$this->_values['max_reminders'] = CRM_Utils_Array::value('max_reminders', $pledgeBlock);
$this->_values['initial_reminder_day'] = CRM_Utils_Array::value('initial_reminder_day', $pledgeBlock);
$this->_values['additional_reminder_day'] = CRM_Utils_Array::value('additional_reminder_day', $pledgeBlock);
//set pledge id in values
$pledgeId = CRM_Utils_Request::retrieve('pledgeId', 'Positive', $this);
//authenticate pledge user for pledge payment.
if ($pledgeId) {
$this->_values['pledge_id'] = $pledgeId;
self::authenticatePledgeUser();
}
}
$this->set('values', $this->_values);
$this->set('fields', $this->_fields);
}
require_once 'CRM/Contribute/BAO/PCP.php';
$pcpId = CRM_Utils_Request::retrieve('pcpId', 'Positive', $this);
if ($pcpId) {
require_once 'CRM/Core/OptionGroup.php';
$approvedId = CRM_Core_OptionGroup::getValue('pcp_status', 'Approved', 'name');
$prms = array('entity_id' => $this->_values['id'], 'entity_table' => 'civicrm_contribution_page');
require_once 'CRM/Contribute/PseudoConstant.php';
$pcpStatus = CRM_Contribute_PseudoConstant::pcpStatus();
CRM_Core_DAO::commonRetrieve('CRM_Contribute_DAO_PCPBlock', $prms, $pcpBlock);
$prms = array('id' => $pcpId);
CRM_Core_DAO::commonRetrieve('CRM_Contribute_DAO_PCP', $prms, $pcpInfo);
//start and end date of the contribution page
$startDate = CRM_Utils_Date::unixTime(CRM_Utils_Array::value('start_date', $this->_values));
$endDate = CRM_Utils_Date::unixTime(CRM_Utils_Array::value('end_date', $this->_values));
$now = time();
if ($pcpInfo['contribution_page_id'] != $this->_values['id']) {
$statusMessage = ts('This contribution page is not related to the Personal Campaign Page you have just visited. However you can still make a contribution here.');
CRM_Core_Error::statusBounce($statusMessage, CRM_Utils_System::url('civicrm/contribute/transact', "reset=1&id={$this->_values['id']}", false, null, false, true));
} else {
if ($pcpInfo['status_id'] != $approvedId) {
$statusMessage = ts('The Personal Campaign Page you have just visited is currently %1. However you can still support the campaign by making a contribution here.', array(1 => $pcpStatus[$pcpInfo['status_id']]));
CRM_Core_Error::statusBounce($statusMessage, CRM_Utils_System::url('civicrm/contribute/transact', "reset=1&id={$pcpInfo['contribution_page_id']}", false, null, false, true));
} else {
if (!CRM_Utils_Array::value('is_active', $pcpBlock)) {
$statusMessage = ts('Personal Campaign Pages are currently not enabled for this contribution page. However you can still support the campaign by making a contribution here.');
CRM_Core_Error::statusBounce($statusMessage, CRM_Utils_System::url('civicrm/contribute/transact', "reset=1&id={$pcpInfo['contribution_page_id']}", false, null, false, true));
} else {
if (!CRM_Utils_Array::value('is_active', $pcpInfo)) {
$statusMessage = ts('The Personal Campaign Page you have just visited is current inactive. However you can still make a contribution here.');
CRM_Core_Error::statusBounce($statusMessage, CRM_Utils_System::url('civicrm/contribute/transact', "reset=1&id={$pcpInfo['contribution_page_id']}", false, null, false, true));
} else {
if ($startDate && $startDate > $now || $endDate && $endDate < $now) {
$customStartDate = CRM_Utils_Date::customFormat(CRM_Utils_Array::value('start_date', $this->_values));
$customEndDate = CRM_Utils_Date::customFormat(CRM_Utils_Array::value('end_date', $this->_values));
if ($startDate && $endDate) {
$statusMessage = ts('The Personal Campaign Page you have just visited is only active between %1 to %2. However you can still support the campaign by making a contribution here.', array(1 => $customStartDate, 2 => $customEndDate));
CRM_Core_Error::statusBounce($statusMessage, CRM_Utils_System::url('civicrm/contribute/transact', "reset=1&id={$pcpInfo['contribution_page_id']}", false, null, false, true));
} else {
if ($startDate) {
$statusMessage = ts('The Personal Campaign Page you have just visited will be active beginning on %1. However you can still support the campaign by making a contribution here.', array(1 => $customStartDate));
CRM_Core_Error::statusBounce($statusMessage, CRM_Utils_System::url('civicrm/contribute/transact', "reset=1&id={$pcpInfo['contribution_page_id']}", false, null, false, true));
} else {
if ($endDate) {
$statusMessage = ts('The Personal Campaign Page you have just visited is not longer active (as of %1). However you can still support the campaign by making a contribution here.', array(1 => $customEndDate));
CRM_Core_Error::statusBounce($statusMessage, CRM_Utils_System::url('civicrm/contribute/transact', "reset=1&id={$pcpInfo['contribution_page_id']}", false, null, false, true));
示例12: preProcess
//.........这里部分代码省略.........
CRM_Utils_System::redirect($infoUrl);
}
}
$this->set('allowWaitlist', $this->_allowWaitlist);
//check for require requires approval.
$this->_requireApproval = false;
if (CRM_Utils_Array::value('requires_approval', $this->_values['event']) && !$this->_allowConfirmation) {
$this->_requireApproval = true;
}
$this->set('requireApproval', $this->_requireApproval);
// also get the accounting code
if (CRM_Utils_Array::value('contribution_type_id', $this->_values['event'])) {
$this->_values['event']['accountingCode'] = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionType', $this->_values['event']['contribution_type_id'], 'accounting_code');
}
if (isset($this->_values['event']['default_role_id'])) {
require_once 'CRM/Core/OptionGroup.php';
$participant_role = CRM_Core_OptionGroup::values('participant_role');
$this->_values['event']['participant_role'] = $participant_role["{$this->_values['event']['default_role_id']}"];
}
// is the event active (enabled)?
if (!$this->_values['event']['is_active']) {
// form is inactive, die a fatal death
CRM_Core_Error::statusBounce(ts('The event you requested is currently unavailable (contact the site administrator for assistance).'));
}
// is online registration is enabled?
if (!$this->_values['event']['is_online_registration']) {
CRM_Core_Error::statusBounce(ts('Online registration is not currently available for this event (contact the site administrator for assistance).'), $infoUrl);
}
// is this an event template ?
if (CRM_Utils_Array::value('is_template', $this->_values['event'])) {
CRM_Core_Error::statusBounce(ts('Event templates are not meant to be registered.'), $infoUrl);
}
$now = time();
$startDate = CRM_Utils_Date::unixTime(CRM_Utils_Array::value('registration_start_date', $this->_values['event']));
if ($startDate && $startDate >= $now) {
CRM_Core_Error::statusBounce(ts('Registration for this event begins on %1', array(1 => CRM_Utils_Date::customFormat(CRM_Utils_Array::value('registration_start_date', $this->_values['event'])))), $infoUrl);
}
$endDate = CRM_Utils_Date::unixTime(CRM_Utils_Array::value('registration_end_date', $this->_values['event']));
if ($endDate && $endDate < $now) {
CRM_Core_Error::statusBounce(ts('Registration for this event ended on %1', array(1 => CRM_Utils_Date::customFormat(CRM_Utils_Array::value('registration_end_date', $this->_values['event'])))), $infoUrl);
}
// check for is_monetary status
$isMonetary = CRM_Utils_Array::value('is_monetary', $this->_values['event']);
//retrieve custom information
$eventID = $this->_eventId;
$isPayLater = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $eventID, 'is_pay_later');
//check for variour combination for paylater, payment
//process with paid event.
if ($isMonetary && (!$isPayLater || CRM_Utils_Array::value('payment_processor_id', $this->_values['event']))) {
$ppID = CRM_Utils_Array::value('payment_processor_id', $this->_values['event']);
if (!$ppID) {
CRM_Core_Error::statusBounce(ts('A payment processor must be selected for this event registration page, or the event must be configured to give users the option to pay later (contact the site administrator for assistance).'), $infoUrl);
}
require_once 'CRM/Core/BAO/PaymentProcessor.php';
$this->_paymentProcessor = CRM_Core_BAO_PaymentProcessor::getPayment($ppID, $this->_mode);
// make sure we have a valid payment class, else abort
if ($this->_values['event']['is_monetary']) {
if (!$this->_paymentProcessor) {
CRM_Core_Error::fatal(ts('The site administrator must set a Payment Processor for this event in order to use online registration.'));
}
// ensure that processor has a valid config
$payment =& CRM_Core_Payment::singleton($this->_mode, 'Event', $this->_paymentProcessor, $this);
$error = $payment->checkConfig();
if (!empty($error)) {
CRM_Core_Error::fatal($error);
}
示例13: array
static function &signoutDetails($startDate = null, $endDate = null, $isMorning = true, $includeDetails = false, $onlyNotSignedOut = false, $studentID = null, $limit = null)
{
$clauses = array();
if ($startDate && $endDate) {
$clauses[] = "( DATE(s.signout_time) >= {$startDate} OR DATE(s.signin_time) >= {$startDate} ) AND\n ( DATE(s.signout_time) <= {$endDate} OR DATE(s.signin_time) <= {$endDate} ) ";
}
if (!$isMorning) {
$clauses[] = "( is_morning = 0 OR is_morning IS NULL )";
}
if ($onlyNotSignedOut) {
$clauses[] = "( s.signout_time IS NULL )";
}
if ($studentID) {
$studentID = CRM_Utils_Type::escape($studentID, 'Integer');
$clauses[] = "c.id = {$studentID}";
}
$clause = null;
if ($clauses) {
$clause = implode(' AND ', $clauses);
} else {
$clause = "( 1 )";
}
$sql = "\nSELECT c.id, c.display_name,\n s.signout_time, s.signin_time,\n s.class, s.pickup_person_name,\n s.is_morning, s.at_school_meeting,\n v.extended_care_status , s.id as signout_id\nFROM civicrm_value_extended_care_signout s\nINNER JOIN civicrm_contact c ON c.id = s.entity_id\nINNER JOIN civicrm_value_school_information v ON c.id = v.entity_id\nWHERE {$clause}\nORDER BY c.sort_name, signin_time DESC\n";
if ($limit) {
$sql .= " LIMIT 0, {$limit} ";
}
$dao = CRM_Core_DAO::executeQuery($sql);
$freeClasses = array('Volleyball', 'Cross Country', 'Amnesty International', 'SMART', 'Yearbook', 'Basketball Team 3:30-5:00 p.m.', 'Middle School Basketball');
$freeStatus = array('SMART', 'Staff', 'Unlimited');
$summary = array();
while ($dao->fetch()) {
$dao->class = trim($dao->class);
$studentID = $dao->id;
if (!array_key_exists($studentID, $summary)) {
$summary[$studentID] = array('id' => $studentID, 'name' => $dao->display_name, 'blockCharge' => 0, 'doNotCharge' => null);
if ($includeDetails) {
$summary[$studentID]['details'] = array();
}
}
$blockCharge = 0;
$blockMessage = null;
if ($dao->is_morning) {
if (self::chargeMorningBlock($dao->signin_time)) {
$blockCharge = 0.5;
}
$blockMessage = 'Morning extended care';
$dao->signout_time = $dao->signin_time;
} else {
if ($dao->at_school_meeting) {
$blockMessage = 'At School Meeting / Work - No Charge';
} else {
if (in_array($dao->class, $freeClasses)) {
$blockMessage = 'Free Class - No Charge';
} else {
if ($dao->signout_time) {
$blockCode = self::signoutBlock($dao->signout_time);
switch ($blockCode) {
case 1:
break;
case 2:
$blockCharge = 1;
break;
case 3:
$blockCharge = 1.5;
break;
case 4:
default:
$blockCharge = 2.0;
break;
}
} else {
// account for the case where the person is signed in but not signed out
if ($dao->signin_time) {
$blockCharge = 2.0;
$dao->signout_time = $dao->signin_time;
$blockMessage = 'Signed in but did not sign out';
}
}
}
}
}
$summary[$studentID]['blockCharge'] += $blockCharge;
if (in_array($dao->extended_care_status, $freeStatus)) {
$summary[$studentID]['doNotCharge'] = $dao->extended_care_status;
}
if ($includeDetails) {
$summary[$studentID]['details'][$dao->signout_id] = array('charge' => $blockCharge, 'message' => $blockMessage, 'class' => $dao->class, 'pickup' => $dao->pickup_person_name, 'signout' => strftime("%l:%M %p on %a, %b %d", CRM_Utils_Date::unixTime($dao->signout_time)));
}
}
return $summary;
}
示例14: compare_event_dates
/**
* @param $event_in_cart_1
* @param $event_in_cart_2
*
* @return int
*/
public static function compare_event_dates($event_in_cart_1, $event_in_cart_2)
{
$date_1 = CRM_Utils_Date::unixTime($event_in_cart_1->event->start_date);
$date_2 = CRM_Utils_Date::unixTime($event_in_cart_2->event->start_date);
if ($date_1 == $date_2) {
return 0;
}
return $date_1 < $date_2 ? -1 : 1;
}
示例15: sendTransitionParticipantMail
/**
* Send mail and create activity
* when participant status changed.
*
* @param int $participantId
* Participant id.
* @param array $participantValues
* Participant detail values. status id for participants.
* @param array $eventDetails
* Required event details.
* @param array $contactDetails
* Required contact details.
* @param array $domainValues
* Required domain values.
* @param string $mailType
* (eg 'approval', 'confirm', 'expired' ).
*
* @return bool
*/
public static function sendTransitionParticipantMail($participantId, $participantValues, $eventDetails, $contactDetails, &$domainValues, $mailType)
{
//send emails.
$mailSent = FALSE;
//don't send confirmation mail to additional
//since only primary able to confirm registration.
if (!empty($participantValues['registered_by_id']) && $mailType == 'Confirm') {
return $mailSent;
}
$toEmail = CRM_Utils_Array::value('email', $contactDetails);
if ($toEmail) {
$contactId = $participantValues['contact_id'];
$participantName = $contactDetails['display_name'];
//calculate the checksum value.
$checksumValue = NULL;
if ($mailType == 'Confirm' && !$participantValues['registered_by_id']) {
$checksumLife = 'inf';
$endDate = CRM_Utils_Array::value('end_date', $eventDetails);
if ($endDate) {
$checksumLife = (CRM_Utils_Date::unixTime($endDate) - time()) / (60 * 60);
}
$checksumValue = CRM_Contact_BAO_Contact_Utils::generateChecksum($contactId, NULL, $checksumLife);
}
//take a receipt from as event else domain.
$receiptFrom = $domainValues['name'] . ' <' . $domainValues['email'] . '>';
if (!empty($eventDetails['confirm_from_name']) && !empty($eventDetails['confirm_from_email'])) {
$receiptFrom = $eventDetails['confirm_from_name'] . ' <' . $eventDetails['confirm_from_email'] . '>';
}
list($mailSent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate(array('groupName' => 'msg_tpl_workflow_event', 'valueName' => 'participant_' . strtolower($mailType), 'contactId' => $contactId, 'tplParams' => array('contact' => $contactDetails, 'domain' => $domainValues, 'participant' => $participantValues, 'event' => $eventDetails, 'paidEvent' => CRM_Utils_Array::value('is_monetary', $eventDetails), 'isShowLocation' => CRM_Utils_Array::value('is_show_location', $eventDetails), 'isAdditional' => $participantValues['registered_by_id'], 'isExpired' => $mailType == 'Expired', 'isConfirm' => $mailType == 'Confirm', 'checksumValue' => $checksumValue), 'from' => $receiptFrom, 'toName' => $participantName, 'toEmail' => $toEmail, 'cc' => CRM_Utils_Array::value('cc_confirm', $eventDetails), 'bcc' => CRM_Utils_Array::value('bcc_confirm', $eventDetails)));
// 3. create activity record.
if ($mailSent) {
$now = date('YmdHis');
$activityType = 'Event Registration';
$activityParams = array('subject' => $subject, 'source_contact_id' => $contactId, 'source_record_id' => $participantId, 'activity_type_id' => CRM_Core_OptionGroup::getValue('activity_type', $activityType, 'name'), 'activity_date_time' => CRM_Utils_Date::isoToMysql($now), 'due_date_time' => CRM_Utils_Date::isoToMysql($participantValues['register_date']), 'is_test' => $participantValues['is_test'], 'status_id' => 2);
if (is_a(CRM_Activity_BAO_Activity::create($activityParams), 'CRM_Core_Error')) {
CRM_Core_Error::fatal('Failed creating Activity for expiration mail');
}
}
}
return $mailSent;
}