本文整理汇总了PHP中XenForo_Locale::getDefaultTimeZone方法的典型用法代码示例。如果您正苦于以下问题:PHP XenForo_Locale::getDefaultTimeZone方法的具体用法?PHP XenForo_Locale::getDefaultTimeZone怎么用?PHP XenForo_Locale::getDefaultTimeZone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XenForo_Locale
的用法示例。
在下文中一共展示了XenForo_Locale::getDefaultTimeZone方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: regeneratePublicHtml
/**
* @param mixed $overrideMotd set motd pre-cache-update
* @param mixed $unsync if not due to new message set true
*/
public function regeneratePublicHtml($overrideMotd = false, $unsync = false)
{
$viewParams = array();
$options = XenForo_Application::get('options');
$visitor = XenForo_Visitor::getInstance();
if ($options->dark_taigachat_speedmode == 'Disabled') {
return;
}
if ($unsync) {
/** @var XenForo_Model_DataRegistry */
$registryModel = $this->getModelFromCache('XenForo_Model_DataRegistry');
$lastUnsync = $registryModel->get('dark_taigachat_unsync');
if (!empty($lastUnsync) && $lastUnsync > time() - 30) {
return;
}
$registryModel->set('dark_taigachat_unsync', time());
}
// swap timezone to default temporarily
$oldTimeZone = XenForo_Locale::getDefaultTimeZone()->getName();
XenForo_Locale::setDefaultTimeZone($options->guestTimeZone);
$messages = $this->getMessages(array("page" => 1, "perPage" => $options->dark_taigachat_fullperpage, "lastRefresh" => 0));
$messagesMini = $this->getMessages(array("page" => 1, "perPage" => $options->dark_taigachat_sidebarperpage, "lastRefresh" => 0));
$bbCodeParser = new XenForo_BbCode_Parser(XenForo_BbCode_Formatter_Base::create('Base'));
$motd = new XenForo_BbCode_TextWrapper($overrideMotd !== false ? $overrideMotd : $options->dark_taigachat_motd, $bbCodeParser);
$onlineUsersTaiga = $this->getActivityUserList($visitor->toArray());
$viewParams = array('taigachat' => array("messages" => $messages, "sidebar" => false, "editside" => $options->dark_taigachat_editside, "timedisplay" => $options->dark_taigachat_timedisplay, "miniavatar" => $options->dark_taigachat_miniavatar, "lastrefresh" => 0, "numInChat" => $this->getActivityUserCount(), "motd" => $motd, "online" => $onlineUsersTaiga, "route" => $options->dark_taigachat_route, "publichtml" => true, 'canView' => true, 'enabled' => true));
$dep = new Dark_TaigaChat_Dependencies();
$dep->preLoadData();
$viewRenderer = new Dark_TaigaChat_ViewRenderer_JsonInternal($dep, new Zend_Controller_Response_Http(), new Zend_Controller_Request_Http());
if (!file_exists(XenForo_Helper_File::getExternalDataPath() . '/taigachat')) {
XenForo_Helper_File::createDirectory(XenForo_Helper_File::getExternalDataPath() . '/taigachat', true);
}
$innerContent = $viewRenderer->renderView('Dark_TaigaChat_ViewPublic_TaigaChat_List', $viewParams, 'dark_taigachat_list');
$filename = XenForo_Helper_File::getExternalDataPath() . '/taigachat/messages.html';
$yayForNoLocking = mt_rand(0, 10000000);
if (file_put_contents($filename . ".{$yayForNoLocking}.tmp", $innerContent, LOCK_EX) === false) {
throw new XenForo_Exception("Failed writing TaigaChat messages to {$filename}.tmp.{$yayForNoLocking}.tmp");
}
if (!@rename($filename . ".{$yayForNoLocking}.tmp", $filename)) {
@unlink($filename . ".{$yayForNoLocking}.tmp");
}
XenForo_Helper_File::makeWritableByFtpUser($filename);
$viewParams['taigachat']['messages'] = $messagesMini;
$viewParams['taigachat']['sidebar'] = true;
//$viewParams['taigachat']['online'] = null;
$innerContent = $viewRenderer->renderView('Dark_TaigaChat_ViewPublic_TaigaChat_List', $viewParams, 'dark_taigachat_list');
$filename = XenForo_Helper_File::getExternalDataPath() . '/taigachat/messagesmini.html';
if (file_put_contents($filename . ".{$yayForNoLocking}.tmp", $innerContent, LOCK_EX) === false) {
throw new XenForo_Exception("Failed writing TaigaChat messages to {$filename}.{$yayForNoLocking}.tmp");
}
// The only reason this could fail is if the file is being hammered, hence no worries ignoring failure
if (!@rename($filename . ".{$yayForNoLocking}.tmp", $filename)) {
@unlink($filename . ".{$yayForNoLocking}.tmp");
}
XenForo_Helper_File::makeWritableByFtpUser($filename);
// put timezone back to how it was
XenForo_Locale::setDefaultTimeZone($oldTimeZone);
}
示例2: runDailyCleanUp
public static function runDailyCleanUp()
{
$options = XenForo_Application::get('options');
$model = XenForo_Model::create('Dark_TaigaChat_Model_TaigaChat');
if ($options->dark_taigachat_archivethread > 0) {
// swap timezone to default temporarily
$oldTimeZone = XenForo_Locale::getDefaultTimeZone()->getName();
XenForo_Locale::setDefaultTimeZone($options->guestTimeZone);
$messages = array_reverse($model->getMessagesToday());
if (count($messages) > 0) {
$userModel = XenForo_Model::create('XenForo_Model_User');
$post = "";
foreach ($messages as $message) {
$message['message'] = XenForo_Helper_String::autoLinkBbCode($message['message']);
$date = XenForo_Locale::dateTime($message['date'], 'absolute');
if ($message['user_id'] > 0) {
$url = XenForo_Link::convertUriToAbsoluteUri(XenForo_Link::buildPublicLink("members/" . $message['user_id']), true);
$user = "[url='{$url}']{$message['username']}[/url]";
} else {
$user = "[b]{$message['username']}[/b]";
}
$me = substr($message['message'], 0, 3) == '/me';
if ($me) {
$message['message'] = substr($message['message'], 3);
$post .= "{$date} - [i]{$user} {$message['message']}[/i]\r\n";
} else {
$post .= "{$date} - {$user}: {$message['message']}\r\n";
}
}
$username = "TaigaChat";
if ($options->dark_taigachat_archiveuser > 0) {
$user = $userModel->getUserById($options->dark_taigachat_archiveuser);
$username = $user['username'];
}
$writer = XenForo_DataWriter::create('XenForo_DataWriter_DiscussionMessage_Post');
$writer->setOption(XenForo_DataWriter_DiscussionMessage::OPTION_IS_AUTOMATED, true);
$writer->set('user_id', $options->dark_taigachat_archiveuser);
$writer->set('username', $username);
$writer->set('message', $post);
$writer->set('thread_id', $options->dark_taigachat_archivethread);
$writer->save();
}
// put timezone back to how it was
XenForo_Locale::setDefaultTimeZone($oldTimeZone);
}
$model->deleteOldMessages();
}
示例3: _prepareFieldsForTemplate
protected function _prepareFieldsForTemplate($fields)
{
$templateFields = array();
foreach ($fields as $fieldId => $field) {
if ($field['active']) {
if ($field['field_type'] == 'checkbox' || $field['field_type'] == 'select' || $field['field_type'] == 'multiselect' || $field['field_type'] == 'radio' || $field['field_type'] == 'rating') {
if (!is_array($field['field_choices'])) {
$choices = unserialize($field['field_choices']);
}
if (is_array($field['field_value'])) {
$text = '';
foreach ($field['field_value'] as $choiceId) {
$text .= ', ' . $choices[$choiceId];
}
$templateFields[$field['field_name']]['value'] = substr($text, 2);
} else {
if ($field['field_type'] == 'rating' && $field['field_value'] != '') {
$templateFields[$field['field_name']]['value'] = $field['field_value'] . new XenForo_Phrase('lpsf_rating_separator') . XenForo_Application::getOptions()->lpsfRatingMax;
} else {
if (isset($choices[$field['field_value']])) {
$templateFields[$field['field_name']]['value'] = $choices[$field['field_value']];
} else {
$templateFields[$field['field_name']]['value'] = '';
}
}
}
} else {
$templateFields[$field['field_name']]['value'] = htmlspecialchars_decode($field['field_value']);
if (($field['field_type'] == 'date' || $field['field_type'] == 'datetime') && $field['field_value'] != '') {
$dateTime = new DateTime($field['field_value'], XenForo_Locale::getDefaultTimeZone());
}
if ($field['field_type'] == 'date' && isset($dateTime)) {
$templateFields[$field['field_name']]['value'] = XenForo_Locale::date($dateTime, 'absolute');
}
if ($field['field_type'] == 'datetime' && isset($dateTime)) {
$templateFields[$field['field_name']]['value'] = XenForo_Locale::dateTime($dateTime, 'absolute');
}
}
$templateFields[$field['field_name']]['field_type'] = $field['field_type'];
$templateFields[$field['field_name']]['title'] = $field['title']->render();
}
}
return $templateFields;
}
示例4: _prepareThreadSearchCriteria
protected function _prepareThreadSearchCriteria(array $criteria)
{
if (isset($criteria['discussion_open']) && is_array($criteria['discussion_open'])) {
$criteria['discussion_open'] = reset($criteria['discussion_open']);
}
if (isset($criteria['sticky']) && is_array($criteria['sticky'])) {
$criteria['sticky'] = reset($criteria['sticky']);
}
if (!empty($criteria['username'])) {
/* @var $userModel XenForo_Model_User */
$userModel = $this->getModelFromCache('XenForo_Model_User');
$usernames = explode(',', $criteria['username']);
$users = $userModel->getUsersByNames($usernames, array(), $notFound);
$userIds = array();
foreach ($users as $user) {
$userIds[] = $user['user_id'];
}
if ($notFound && !$userIds) {
$userIds[] = -1;
}
unset($criteria['username']);
$criteria['user_id'] = $userIds;
}
foreach (array('last_post_date', 'post_date') as $field) {
if (!empty($criteria["{$field}_start"])) {
$date = new DateTime($criteria["{$field}_start"], XenForo_Locale::getDefaultTimeZone());
$criteria["{$field}_start"] = $date->format('U');
}
if (!empty($criteria["{$field}_end"])) {
$date = new DateTime($criteria["{$field}_end"], XenForo_Locale::getDefaultTimeZone());
$date->setTime(23, 59, 59);
$criteria["{$field}_end"] = $date->format('U');
}
}
foreach (array('reply_count' => 0, 'view_count' => 0, 'first_post_likes' => 0, 'last_post_date' => 1, 'post_date' => 1) as $field => $upperMin) {
$lower = null;
$upper = null;
if (!empty($criteria["{$field}_start"]) && intval($criteria["{$field}_start"])) {
$lower = intval($criteria["{$field}_start"]);
}
if (isset($criteria["{$field}_end"]) && intval($criteria["{$field}_end"]) >= $upperMin) {
$upper = intval($criteria["{$field}_end"]);
}
unset($criteria["{$field}_start"], $criteria["{$field}_end"]);
if ($lower !== null && $upper !== null) {
$criteria[$field] = array('>=<', $lower, $upper);
} else {
if ($lower !== null) {
$criteria[$field] = array('>=', $lower);
} else {
if ($upper !== null) {
$criteria[$field] = array('<=', $upper);
}
}
}
}
foreach (array('title') as $field) {
if (isset($criteria[$field]) && is_string($criteria[$field])) {
$criteria[$field] = trim($criteria[$field]);
}
}
return $criteria;
}
示例5: runDailyCleanUp
public static function runDailyCleanUp()
{
$options = XenForo_Application::get('options');
$model = XenForo_Model::create('Dark_TaigaChat_Model_TaigaChat');
if ($options->dark_taigachat_archivethread > 0) {
// swap timezone to default temporarily
$timeZone = XenForo_Locale::getDefaultTimeZone();
if (!empty($timeZone)) {
$oldTimeZone = XenForo_Locale::getDefaultTimeZone()->getName();
}
XenForo_Locale::setDefaultTimeZone($options->guestTimeZone);
$messages = array_reverse($model->getMessagesToday());
if (count($messages) > 0) {
for ($i = 0; $i < count($messages); $i += $options->dark_taigachat_archive_split) {
$userModel = XenForo_Model::create('XenForo_Model_User');
$post = "";
for ($j = $i; $j < min(count($messages), $i + $options->dark_taigachat_archive_split); $j++) {
//foreach($messages as $message){
$message = $messages[$j];
$message['message'] = XenForo_Helper_String::autoLinkBbCode($message['message']);
$date = XenForo_Locale::dateTime($message['date'], 'absolute');
if ($message['user_id'] > 0) {
$user = "[user={$message['user_id']}]{$message['username']}[/user]";
} else {
$user = "[b]{$message['username']}[/b]";
}
$me = substr($message['message'], 0, 3) == '/me';
if ($me) {
$message['message'] = substr($message['message'], 3);
$post .= "{$date} - [i]{$user} {$message['message']}[/i]\r\n";
} else {
$post .= "{$date} - {$user}: {$message['message']}\r\n";
}
}
if (empty($post)) {
continue;
}
$username = "TaigaChat";
if ($options->dark_taigachat_archiveuser > 0) {
$user = $userModel->getUserById($options->dark_taigachat_archiveuser);
$username = $user['username'];
}
$writer = XenForo_DataWriter::create('XenForo_DataWriter_DiscussionMessage_Post');
$writer->setOption(XenForo_DataWriter_DiscussionMessage::OPTION_IS_AUTOMATED, true);
if (defined('XenForo_DataWriter_DiscussionMessage::OPTION_CHECK_SPAM')) {
$writer->setOption(XenForo_DataWriter_DiscussionMessage::OPTION_CHECK_SPAM, false);
}
$writer->setOption(XenForo_DataWriter_DiscussionMessage::OPTION_MAX_MESSAGE_LENGTH, 0);
$writer->setOption(XenForo_DataWriter_DiscussionMessage::OPTION_MAX_IMAGES, 0);
$writer->setOption(XenForo_DataWriter_DiscussionMessage::OPTION_MAX_MEDIA, 0);
$writer->setOption(XenForo_DataWriter_DiscussionMessage::OPTION_VERIFY_GUEST_USERNAME, false);
$writer->set('user_id', $options->dark_taigachat_archiveuser);
$writer->set('username', $username);
$writer->set('message', $post);
$writer->set('thread_id', $options->dark_taigachat_archivethread);
$writer->save();
}
}
// put timezone back to how it was
if (!empty($oldTimeZone)) {
XenForo_Locale::setDefaultTimeZone($oldTimeZone);
}
}
$model->deleteOldMessages();
}
示例6: prepareLogConditions
public function prepareLogConditions(array $conditions, array &$fetchOptions)
{
$sqlConditions = array();
$db = $this->_getDb();
if (!empty($conditions['user_id'])) {
if (is_array($conditions['user_id'])) {
$sqlConditions[] = 'log.user_id IN (' . $db->quote($conditions['user_id']) . ')';
} else {
$sqlConditions[] = 'log.user_id = ' . $db->quote($conditions['user_id']);
}
}
if (!empty($conditions['thread_id'])) {
if (is_array($conditions['thread_id'])) {
$sqlConditions[] = 'log.thread_id IN (' . $db->quote($conditions['thread_id']) . ')';
} else {
$sqlConditions[] = 'log.thread_id = ' . $db->quote($conditions['thread_id']);
}
}
if (!empty($conditions['node_id'])) {
if (is_array($conditions['node_id'])) {
$sqlConditions[] = 'log.node_id IN (' . $db->quote($conditions['node_id']) . ')';
} else {
$sqlConditions[] = 'log.node_id = ' . $db->quote($conditions['node_id']);
}
}
if (!empty($conditions['id'])) {
if (is_array($conditions['id'])) {
$sqlConditions[] = 'log.id IN (' . $db->quote($conditions['id']) . ')';
} else {
$sqlConditions[] = 'log.id = ' . $db->quote($conditions['id']);
}
}
if (!empty($conditions['up_source'])) {
if (is_array($conditions['up_source'])) {
$sqlConditions[] = 'log.up_source IN (' . $db->quote($conditions['up_source']) . ')';
} else {
$sqlConditions[] = 'log.up_source = ' . $db->quote($conditions['up_source']);
}
}
if (!empty($conditions['up_time']) && is_array($conditions['up_time'])) {
list($operator, $cutOff) = $conditions['up_time'];
$this->assertValidCutOffOperator($operator);
$sqlConditions[] = "log.up_time {$operator} " . $db->quote($cutOff);
}
if (isset($conditions['count_type'])) {
switch ($conditions['count_type']) {
case self::DAILY_COUNT:
$dayStartTimestamps = XenForo_Locale::getDayStartTimestamps();
$today_start = $dayStartTimestamps['today'];
$today_end = $today_start + 24 * 3600;
$sqlConditions[] = "log.up_time BETWEEN '{$today_start}' AND '{$today_end}'";
break;
case self::WEEKLY_COUNT:
$date = new DateTime(mktime(0, 0, 0, date('n'), date('j'), date('Y')) - (date('N') - 1) * 3600 * 24);
$date->setTimezone(XenForo_Locale::getDefaultTimeZone() ? XenForo_Locale::getDefaultTimeZone() : new DateTimeZone('UTC'));
$this_week_start = $date->format('U');
$this_week_end = XenForo_Application::$time;
$sqlConditions[] = "log.up_time BETWEEN '{$this_week_start}' AND '{$this_week_end}'";
break;
case self::MONTHLY_COUNT:
$date = new DateTime(mktime(0, 0, 0, date('m'), 1, date('Y')));
$date->setTimezone(XenForo_Locale::getDefaultTimeZone() ? XenForo_Locale::getDefaultTimeZone() : new DateTimeZone('UTC'));
$this_month_start = $date->format('U');
$this_month_end = XenForo_Application::$time;
$sqlConditions[] = "log.up_time BETWEEN '{$this_month_start}' AND '{$this_month_end}'";
break;
default:
break;
}
}
return $this->getConditionsForClause($sqlConditions);
}
示例7: _doClean
protected static function _doClean($filterName, array $filterOptions, $data, $defaultData)
{
switch ($filterName) {
case self::STRING:
$data = is_scalar($data) ? strval($data) : $defaultData;
if (strlen($data) && !preg_match('/./u', $data)) {
$data = $defaultData;
}
$data = self::cleanString($data);
if (empty($filterOptions['noTrim'])) {
$data = trim($data);
}
break;
case self::NUM:
$data = strval($data) + 0;
break;
case self::UNUM:
$data = strval($data) + 0;
$data = $data < 0 ? $defaultData : $data;
break;
case self::INT:
$data = intval($data);
break;
case self::UINT:
$data = ($data = intval($data)) < 0 ? $defaultData : $data;
break;
case self::FLOAT:
$data = floatval($data);
break;
case self::BOOLEAN:
if ($data === 'n' || $data === 'no' || $data === 'N') {
$data = false;
} else {
$data = (bool) $data;
}
break;
case self::BINARY:
$data = strval($data);
break;
case self::ARRAY_SIMPLE:
if (!is_array($data)) {
$data = $defaultData;
}
$data = self::cleanStringArray($data);
break;
case self::JSON_ARRAY:
if (is_string($data)) {
$data = json_decode($data, true);
}
if (!is_array($data)) {
$data = $defaultData;
}
$data = self::cleanStringArray($data);
break;
case self::DATE_TIME:
if (!$data) {
$data = 0;
} else {
if (is_string($data)) {
$data = trim($data);
if ($data === strval(intval($data))) {
// data looks like an int, treat as timestamp
$data = intval($data);
} else {
if (isset($filterOptions['timeZone'])) {
$tz = $filterOptions['timeZone'];
} else {
$tz = XenForo_Visitor::hasInstance() ? XenForo_Locale::getDefaultTimeZone() : null;
}
try {
$date = new DateTime($data, $tz);
if (!empty($filterOptions['dayEnd'])) {
$date->setTime(23, 59, 59);
}
$data = $date->format('U');
} catch (Exception $e) {
$data = 0;
}
}
}
}
if (!is_int($data)) {
$data = intval($data);
}
break;
default:
if ($filterName instanceof Zend_Validate_Interface) {
if ($filterName->isValid($data) === false) {
$data = $defaultData;
}
} else {
throw new XenForo_Exception("Unknown input type in " . __CLASS__ . "::" . __METHOD__);
}
}
return $data;
}
示例8: actionEditActive
/**
* Displays a form to change the expiration of an upgrade
* or actually changes it.
*
* @return XenForo_ControllerResponse_Abstract
*/
public function actionEditActive()
{
$userUpgradeModel = $this->_getUserUpgradeModel();
$userUpgradeRecordId = $this->_input->filterSingle('user_upgrade_record_id', XenForo_Input::UINT);
$upgradeRecord = $userUpgradeModel->getActiveUserUpgradeRecordById($userUpgradeRecordId);
if (!$upgradeRecord) {
return $this->responseError(new XenForo_Phrase('requested_user_upgrade_not_found'), 404);
}
if ($this->_request->isPost()) {
if ($this->_input->filterSingle('end_type', XenForo_Input::STRING) == 'permanent') {
$endDate = 0;
} else {
$endDate = $this->_input->filterSingle('end_date', XenForo_Input::DATE_TIME);
if ($endDate) {
$dt = new DateTime("@{$endDate}");
$dt->setTimezone(XenForo_Locale::getDefaultTimeZone());
if ($upgradeRecord['end_date']) {
$original = new DateTime("@{$upgradeRecord['end_date']}");
$original->setTimezone(XenForo_Locale::getDefaultTimeZone());
$parts = explode('-', $original->format('G-i-s'));
$dt->setTime(intval($parts[0]), intval($parts[1]), intval($parts[2]));
} else {
$dt->setTime(12, 0, 0);
}
$endDate = $dt->format('U');
}
}
$userUpgradeModel->updateActiveUpgradeEndDate($upgradeRecord['user_upgrade_record_id'], $endDate);
return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, $this->getDynamicRedirect());
} else {
$viewParams = array('upgradeRecord' => $upgradeRecord, 'user' => $this->_getUserModel()->getUserById($upgradeRecord['user_id']), 'upgrade' => $userUpgradeModel->getUserUpgradeById($upgradeRecord['user_upgrade_id']), 'redirect' => $this->getDynamicRedirect());
return $this->responseView('XenForo_ControllerAdmin_UserUpgrade_EditActive', 'user_upgrade_edit_active', $viewParams);
}
}
示例9: prepareUserSearchCriteria
public function prepareUserSearchCriteria(array $criteria)
{
if (isset($criteria['is_banned']) && is_array($criteria['is_banned'])) {
$criteria['is_banned'] = reset($criteria['is_banned']);
}
if (isset($criteria['is_discouraged']) && is_array($criteria['is_discouraged'])) {
$criteria['is_discouraged'] = reset($criteria['is_discouraged']);
}
if (isset($criteria['is_staff']) && is_array($criteria['is_staff'])) {
$criteria['is_staff'] = reset($criteria['is_staff']);
}
foreach (array('register_date', 'last_activity') as $field) {
if (!empty($criteria["{$field}_start"])) {
$date = new DateTime($criteria["{$field}_start"], XenForo_Locale::getDefaultTimeZone());
$criteria["{$field}_start"] = $date->format('U');
}
if (!empty($criteria["{$field}_end"])) {
$date = new DateTime($criteria["{$field}_end"], XenForo_Locale::getDefaultTimeZone());
$date->setTime(23, 59, 59);
$criteria["{$field}_end"] = $date->format('U');
}
}
foreach (array('message_count' => 0, 'trophy_points' => 0, 'register_date' => 1, 'last_activity' => 1) as $field => $upperMin) {
$lower = null;
$upper = null;
if (!empty($criteria["{$field}_start"]) && intval($criteria["{$field}_start"])) {
$lower = intval($criteria["{$field}_start"]);
}
if (isset($criteria["{$field}_end"]) && intval($criteria["{$field}_end"]) >= $upperMin) {
$upper = intval($criteria["{$field}_end"]);
}
unset($criteria["{$field}_start"], $criteria["{$field}_end"]);
if ($lower !== null && $upper !== null) {
$criteria[$field] = array('>=<', $lower, $upper);
} else {
if ($lower !== null) {
$criteria[$field] = array('>=', $lower);
} else {
if ($upper !== null) {
$criteria[$field] = array('<=', $upper);
}
}
}
}
foreach (array('username', 'username2', 'email') as $field) {
if (isset($criteria[$field]) && is_string($criteria[$field])) {
$criteria[$field] = trim($criteria[$field]);
}
}
if (isset($criteria['custom'])) {
if (!empty($criteria['custom']) && is_array($criteria['custom'])) {
$criteria['customFields'] = $criteria['custom'];
if (!empty($criteria['custom_exact']) && is_array($criteria['custom_exact'])) {
$criteria['customFieldsExact'] = $criteria['custom_exact'];
}
}
unset($criteria['custom'], $criteria['custom_exact']);
}
return $criteria;
}
示例10: _getEventsBaseType
protected function _getEventsBaseType($type, array $team, $filterTab)
{
$eventModel = $this->_getEventModel();
$page = max(1, $this->_input->filterSingle('page', XenForo_Input::UINT));
$perPage = 20;
$conditions = array();
$fetchOptions = array('join' => Nobita_Teams_Model_Event::FETCH_TEAM | Nobita_Teams_Model_Event::FETCH_USER, 'page' => $page, 'perPage' => $perPage);
$conditions += $eventModel->getPermissionBasedFetchConditions($team);
if ($filterTab == 'calendar') {
// saving query
return array(array(), 0, 1, 1);
}
$time = XenForo_Application::$time;
$dt = new DateTime('@' . $time);
$dt->setTimeZone(XenForo_Locale::getDefaultTimeZone());
$dt->setTime(0, 0, 0);
$beginDay = $dt->format('U');
$endDay = $dt->setTime(23, 59, 59)->format('U');
switch ($type) {
case 'today':
$conditions = array_merge($conditions, array('event_today' => array($beginDay, $time, $endDay)));
break;
case 'past':
$conditions = array_merge($conditions, array('begin_date' => array("<", $time), 'end_date_lt_or_equal' => array($time, 0)));
break;
case 'upcoming':
default:
$conditions = array_merge($conditions, array('event_upcoming' => array($time, $time, $time)));
break;
}
$events = $eventModel->getEventsTeam($team['team_id'], $conditions, $fetchOptions);
$totalEvents = $eventModel->countEvents($team['team_id'], $conditions);
return array($events, $totalEvents, $page, $perPage);
}