本文整理汇总了PHP中phpbb\request\request_interface::is_set方法的典型用法代码示例。如果您正苦于以下问题:PHP request_interface::is_set方法的具体用法?PHP request_interface::is_set怎么用?PHP request_interface::is_set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类phpbb\request\request_interface
的用法示例。
在下文中一共展示了request_interface::is_set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: viewforum_get_topic_ids_data
/**
* Event: core.viewforum_get_topic_ids_data
*/
public function viewforum_get_topic_ids_data($event)
{
$custom_sorting = array('by' => $this->user->data['user_topic_sortby_type'], 'order' => $this->user->data['user_topic_sortby_dir']);
// Forum-specific sorting
if ($event['forum_data']['sort_topics_by'] != $this->default_sort_by) {
$custom_sorting = array('by' => $event['forum_data']['sort_topics_by'], 'order' => $event['forum_data']['sort_topics_order']);
} else {
if ($this->user->data['is_registered'] && !$this->user->data['is_bot'] && $this->config['kasimi.sorttopics.ucp_enabled'] && $this->user->data['sort_topics_by_created_time']) {
$custom_sorting['by'] = 'c';
}
}
// Temporary sorting if the user used the options at the bottom of viewforum
if ($this->request->is_set('sk')) {
$custom_sorting['by'] = $this->request->variable('sk', '');
}
if ($this->request->is_set('sd')) {
$custom_sorting['order'] = $this->request->variable('sd', '');
}
$this->inject_created_time_select_option('S_SELECT_SORT_KEY', $custom_sorting['by'], 'S_SELECT_SORT_DIR', $custom_sorting['order']);
// Bail out if we don't need to adjust sorting
if ($custom_sorting['by'] == $this->sort_key && $custom_sorting['order'] == $this->sort_dir) {
return;
}
// This forum requires custom topic sorting, let's get our hands dirty
$sort_by_sql = array('a' => 't.topic_first_poster_name', 't' => array('t.topic_last_post_time', 't.topic_last_post_id'), 'c' => array('t.topic_time', 't.topic_id'), 'r' => $this->auth->acl_get('m_approve', $event['forum_data']['forum_id']) ? 't.topic_posts_approved + t.topic_posts_unapproved + t.topic_posts_softdeleted' : 't.topic_posts_approved', 's' => 't.topic_title', 'v' => 't.topic_views');
$sort_sql = $sort_by_sql[$custom_sorting['by']];
$direction = $custom_sorting['order'] == 'd' ? 'DESC' : 'ASC';
$sql_sort_order = (is_array($sort_sql) ? implode(' ' . $direction . ', ', $sort_sql) : $sort_sql) . ' ' . $direction;
$sql_ary = $event['sql_ary'];
$store_reverse = $event['store_reverse'];
$sql_ary['ORDER_BY'] = 't.topic_type ' . (!$store_reverse ? 'DESC' : 'ASC') . ', ' . $sql_sort_order;
$event['sql_sort_order'] = $sql_sort_order;
$event['sql_ary'] = $sql_ary;
}
示例2: show_results
/**
* Perform search and output results.
*
* @param string $sort_url Base sort url.
* @return \Symfony\Component\HttpFoundation\Response
*/
protected function show_results($sort_url)
{
// Setup the sort tool
$this->sort->set_defaults($this->config['posts_per_page'])->request();
// Do the search
$results = $this->query_index();
// Grab the users
\users_overlord::load_users($results['user_ids']);
$this->display->assign_global_vars();
$this->assign_doc_vars($results['documents']);
$this->assign_result_vars($this->sort->total);
$parameters = array();
$expected_parameters = array('versions' => array(array(''), false), 'c' => array(array(0), false), 'sc' => array(false, false), 'keywords' => array('', true), 'sf' => array('', false), 'author' => array('', true), 'u' => array(0, false), 'type' => array(0, false), 'contrib' => array(0, false));
foreach ($expected_parameters as $name => $properties) {
if ($this->request->is_set($name)) {
list($default_value, $multibyte) = $properties;
$value = $this->request->variable($name, $default_value, $multibyte);
// Clean up URL by not including default values.
if ($value !== $default_value) {
$parameters[$name] = $value;
}
}
}
$this->sort->build_pagination($sort_url, $parameters);
return $this->helper->render('search_results.html', $this->user->lang['SEARCH']);
}
示例3: toggle_edit_mode
protected function toggle_edit_mode()
{
$edit_mode = $this->request->variable($this->config['cookie_name'] . '_sm_edit_mode', false, false, \phpbb\request\request_interface::COOKIE);
if ($this->request->is_set('edit_mode')) {
$edit_mode = $this->request->variable('edit_mode', false);
$this->user->set_cookie('sm_edit_mode', $edit_mode, 0);
}
return $edit_mode;
}
示例4: process_submit
/**
* Processes all actions
*
* @return array errors
*/
protected function process_submit()
{
if (!$this->request->is_set($this->action_name)) {
return array();
}
$action = $this->request->variable($this->action_name, '');
if (!$this->survey->enabled) {
return array($this->user->lang('SURVEY_IS_DISABLED'));
}
$can_manage = $this->survey->can_manage($this->user->data['user_id']);
if (!$can_manage && preg_match("/^(config_change|close|reopen|question_addition_or_modification|question_deletion|question_load_modify|delete|disable)\$/", $action)) {
return array($this->user->lang('NO_AUTH_OPERATION'));
}
if ($this->survey->is_closed() && !$can_manage) {
return array($this->user->lang('SURVEY_IS_CLOSED'));
}
if ($action == "config_change") {
return $this->process_config_change();
}
if ($action == "reopen") {
if (!$this->survey->is_closed()) {
return array($this->user->lang('SURVEY_IS_NOT_CLOSED'));
}
return $this->process_reopen();
}
if ($action == "close") {
if ($this->survey->is_closed()) {
return array($this->user->lang('SURVEY_IS_CLOSED', $this->user->format_date($this->survey->settings['stop_time'])));
}
return $this->process_close();
}
if ($action == "entry_deletion") {
return $this->process_entry_deletion();
}
if ($action == "entry_modification") {
return $this->process_entry_modification();
}
if ($action == "question_addition_or_modification") {
return $this->process_question_addition_or_modification();
}
if ($action == "question_deletion") {
return $this->process_question_deletion();
}
if ($action == "question_load_modify") {
return $this->process_question_load_modify();
}
if ($action == "disable") {
return $this->process_disable();
}
if ($action == "delete") {
return $this->process_delete();
}
return array();
}
示例5: confirm_action
/**
* Confirm tool action.
*
* @return bool Returns true if confirmed, false otherwise.
*/
protected function confirm_action()
{
$submit = $this->request->is_set('submit');
$hash = $this->request->variable('hash', '');
if (confirm_box(true) || $submit && check_link_hash($hash, 'titania_manage')) {
return true;
} else {
confirm_box(false, $this->user->lang('CONFIRM_TOOL_ACTION'));
return false;
}
}
示例6: prepend_breadcrump
/**
* - Add "Forum" to navbar when we are not on the forum page (viewforum/viewtopic)
* - Add "Forum" to the breadcrump when viewing forum page (viewforum/viewtopic)
*/
public function prepend_breadcrump()
{
$u_viewforum = $this->phpbb_container->get('controller.helper')->route('blitze_sitemaker_forum');
// Add "Forum" to breadcrump menu when viewing forum pages (viewforum/viewtopic/posting)
if ($this->request->is_set('f')) {
$this->template->alter_block_array('navlinks', array('FORUM_NAME' => $this->user->lang('FORUM'), 'U_VIEW_FORUM' => $u_viewforum));
} else {
if ($this->user->page['page'] !== 'app.' . $this->php_ext . '/forum') {
$this->template->assign_vars(array('S_PT_SHOW_FORUM_NAV' => true, 'U_PT_VIEWFORUM' => $u_viewforum));
}
}
}
示例7: viewforum_get_topic_ids_data
/**
* Apply custom sorting to SQL query
*
* @param $event
*/
public function viewforum_get_topic_ids_data($event)
{
$this->sort_options_source = 'default';
$this->custom_sort_key = $this->user->data['user_topic_sortby_type'];
$this->custom_sort_dir = $this->user->data['user_topic_sortby_dir'];
if ($event['forum_data']['sort_topics_by'] != $this->default_sort_by) {
// Forum-specific sorting
$this->sort_options_source = 'forum';
$this->custom_sort_key = $event['forum_data']['sort_topics_by'];
$this->custom_sort_dir = $event['forum_data']['sort_topics_order'];
} else {
if ($this->user->data['is_registered'] && $this->config['kasimi.sorttopics.ucp_enabled'] && $this->user->data['sort_topics_by_created_time']) {
// UCP-specific sorting by created time
$this->sort_options_source = 'ucp';
$this->custom_sort_key = 'c';
}
}
// Temporary sorting if the user used the options at the bottom of viewforum
if ($this->request->is_set('sk')) {
$this->sort_options_source = 'request';
$this->custom_sort_key = $this->request->variable('sk', $this->custom_sort_key);
$this->custom_sort_dir = $this->request->variable('sd', $this->custom_sort_dir);
}
$this->inject_created_time_select_option('S_SELECT_SORT_KEY', $this->custom_sort_key, 'S_SELECT_SORT_DIR', $this->custom_sort_dir);
// Bail out if we don't need to adjust sorting
if ($this->custom_sort_key == $this->sort_key && $this->custom_sort_dir == $this->sort_dir) {
return;
}
// This forum requires custom topic sorting, let's get our hands dirty
$sort_by_sql = array('a' => 't.topic_first_poster_name', 't' => array('t.topic_last_post_time', 't.topic_last_post_id'), 'c' => array('t.topic_time', 't.topic_id'), 'r' => $this->auth->acl_get('m_approve', $event['forum_data']['forum_id']) ? 't.topic_posts_approved + t.topic_posts_unapproved + t.topic_posts_softdeleted' : 't.topic_posts_approved', 's' => 't.topic_title', 'v' => 't.topic_views');
$store_reverse = $event['store_reverse'];
if ($store_reverse) {
$direction = $this->custom_sort_dir == 'd' ? 'ASC' : 'DESC';
} else {
$direction = $this->custom_sort_dir == 'd' ? 'DESC' : 'ASC';
}
if (is_array($sort_by_sql[$this->custom_sort_key])) {
$sql_sort_order = implode(' ' . $direction . ', ', $sort_by_sql[$this->custom_sort_key]) . ' ' . $direction;
} else {
$sql_sort_order = $sort_by_sql[$this->custom_sort_key] . ' ' . $direction;
}
$sql_ary = $event['sql_ary'];
$sql_ary['ORDER_BY'] = 't.topic_type ' . (!$store_reverse ? 'DESC' : 'ASC') . ', ' . $sql_sort_order;
$event['sql_sort_order'] = $sql_sort_order;
$event['sql_ary'] = $sql_ary;
$rootref =& $this->template_context->get_root_ref();
if ($this->sort_options_source == 'request' && $this->custom_sort_key == 'c') {
$rootref['U_VIEW_FORUM'] .= '&sk=c';
}
}
示例8: get_plupload_response_data
/**
* Get data to return in Plupload request.
*
* @return array
*/
public function get_plupload_response_data()
{
if ($this->get_errors()) {
return array('jsonrpc' => '2.0', 'id' => 'id', 'error' => array('code' => 100, 'message' => implode('<br />', $this->get_errors())));
}
$data = array_values($this->get_basic_attachment_data());
if ($this->request->is_set('delete_file')) {
return $data;
}
$result = array('data' => array_values($this->get_basic_attachment_data()));
if ($this->uploaded) {
$result['download_url'] = $this->get_uploaded_attachment()->get_url();
}
return $result;
}
示例9: link_account_auth_link
/**
* Performs the account linking for auth_link
*
* @param array $link_data The same variable given to {@see \phpbb\auth\provider\provider_interface::link_account}
* @param string $service_name The name of the service being used in
* linking.
* @return string|null Returns a language constant (string) if an error is
* encountered, or null on success.
*/
protected function link_account_auth_link(array $link_data, $service_name)
{
$storage = new \phpbb\auth\provider\oauth\token_storage($this->db, $this->user, $this->auth_provider_oauth_token_storage_table);
$query = 'i=ucp_auth_link&mode=auth_link&link=1&oauth_service=' . strtolower($link_data['oauth_service']);
$service_credentials = $this->service_providers[$service_name]->get_service_credentials();
$scopes = $this->service_providers[$service_name]->get_auth_scope();
$service = $this->get_service(strtolower($link_data['oauth_service']), $storage, $service_credentials, $query, $scopes);
if ($this->request->is_set('code', \phpbb\request\request_interface::GET)) {
$this->service_providers[$service_name]->set_external_service_provider($service);
$unique_id = $this->service_providers[$service_name]->perform_auth_login();
// Insert into table, they will be able to log in after this
$data = array('user_id' => $this->user->data['user_id'], 'provider' => strtolower($link_data['oauth_service']), 'oauth_provider_id' => $unique_id);
$this->link_account_perform_link($data);
} else {
$url = $service->getAuthorizationUri();
header('Location: ' . $url);
}
}
示例10: versions
/**
* @return void
*/
public function versions()
{
$action = $this->request->variable('action', '');
$id = $this->request->variable('id', 0);
switch ($action) {
case 'order':
$this->orderVersions($id, $this->request->variable('up', false));
break;
case 'add':
$this->addVersion();
break;
case 'active':
$this->activate($id, $this->request->is_set('active'));
case 'addRelease':
$this->createNewRelease();
break;
default:
$this->versionsIndex();
}
}
示例11: _get_users_votes
/**
* @param int $topic_id
* @return array
*/
private function _get_users_votes($topic_id)
{
$cur_voted_id = array();
if ($this->user->data['is_registered']) {
$sql = 'SELECT poll_option_id
FROM ' . POLL_VOTES_TABLE . '
WHERE topic_id = ' . $topic_id . '
AND vote_user_id = ' . $this->user->data['user_id'];
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result)) {
$cur_voted_id[] = $row['poll_option_id'];
}
$this->db->sql_freeresult($result);
} else {
// Cookie based guest tracking ... I don't like this but hum ho
// it's oft requested. This relies on "nice" users who don't feel
// the need to delete cookies to mess with results.
if ($this->request->is_set($this->config['cookie_name'] . '_poll_' . $topic_id, \phpbb\request\request_interface::COOKIE)) {
$cur_voted_id = explode(',', $this->request->variable($this->config['cookie_name'] . '_poll_' . $topic_id, '', true, \phpbb\request\request_interface::COOKIE));
$cur_voted_id = array_map('intval', $cur_voted_id);
}
}
return $cur_voted_id;
}
示例12: parse_parameters
/**
* Parses parameters found in $request, which is an instance of
* \phpbb\request\request_interface.
*
* It is expected to have a key f whose value is id of the forum to be pruned.
*
* @param \phpbb\request\request_interface $request Request object.
*
* @return null
*/
public function parse_parameters(\phpbb\request\request_interface $request)
{
$this->forum_data = null;
if ($request->is_set('f')) {
$forum_id = $request->variable('f', 0);
$sql = 'SELECT forum_id, prune_next, enable_prune, prune_days, prune_viewed, forum_flags, prune_freq
FROM ' . FORUMS_TABLE . "\n\t\t\t\tWHERE forum_id = {$forum_id}";
$result = $this->db->sql_query($sql);
$row = $this->db->sql_fetchrow($result);
$this->db->sql_freeresult($result);
if ($row) {
$this->forum_data = $row;
}
}
}
示例13: process_set_activedate
/**
* Processes hookup set activedate requests
*
* @param \phpbb\event\data $event
* @param bool $is_owner
*/
protected function process_set_activedate($event, $is_owner)
{
$set_active_set = $this->request->is_set('set_active', \phpbb\request\request_interface::POST) || $this->request->is_set('set_active', \phpbb\request\request_interface::GET);
$set_active = $this->request->variable('set_active', 0);
if (!$set_active_set) {
return array();
}
if (!$is_owner) {
return array($this->user->lang('NOT_AUTH_HOOKUP'));
}
if ($set_active && !isset($this->hookup->hookup_dates[$set_active])) {
trigger_error('NO_DATE');
}
$active_date_formatted = $set_active != 0 ? $this->user->format_date($this->hookup->hookup_dates[$set_active]['date_time']) : '-';
$topic_id = $event['topic_id'];
$forum_id = $event['forum_id'];
$viewtopic_url = append_sid("{$this->phpbb_root_path}viewtopic.{$this->phpEx}?f={$forum_id}&t={$topic_id}");
if (confirm_box(true)) {
$title_prefix = $this->request->variable('title_prefix', false);
$send_email = $this->request->variable('send_email', false);
$post_reply = $this->request->variable('post_reply', false);
$topic_data = $event['topic_data'];
$new_title = preg_replace('#^(\\[.+?\\] )?#', $set_active != 0 ? '[' . $this->user->format_date($this->hookup->hookup_dates[$set_active]['date_time'], $this->user->lang['HOOKUP_DATEFORMAT_TITLE']) . '] ' : '', $event['topic_data']['topic_title']);
/**
* Perform additional actions when active date is set
*
* @event gn36.hookup.set_activedate_confirmed
* @var bool title_prefix User wants to have a title prefix added
* @var bool send_email User wants E-Mails to be sent
* @var bool post_reply User wants to post a reply to the topic
* @var int set_active Date selected as active (0 means reset of active date)
* @var string new_title The new topic title that will be present after the update
* @var int topic_id ID of the topic of the hookup
* @var int forum_id ID of the forum the topic is in
* @var array topic_data Topic data as received from core.viewtopic_assign_template_vars_before
* @since 1.0.0-dev
*/
$vars = array('title_prefix', 'send_email', 'post_reply', 'set_active', 'new_title', 'topic_id', 'forum_id', 'topic_data');
extract($this->phpbb_dispatcher->trigger_event('gn36.hookup.set_activedate_confirmed', compact($vars)));
//insert active date (short format) into topic title. this will use language
//and timezone of the "active maker" but the alternative would be
//to query the HOOKUP_DATES table every time we need the topic title
if ($set_active == 0 || $title_prefix) {
$sql = 'UPDATE ' . TOPICS_TABLE . '
SET hookup_active_date = ' . (int) $set_active . ",\n\t\t\t\t\t\t\ttopic_title = '" . $this->db->sql_escape($new_title) . "'\n\t\t\t\t\t\t\t\t\tWHERE topic_id = {$topic_id}";
$this->db->sql_query($sql);
$sql = "UPDATE " . POSTS_TABLE . "\n\t\t\t\t\t\tSET post_subject='" . $this->db->sql_escape($new_title) . "'\n\t\t\t\t\t\t\t\tWHERE post_id = {$event['topic_data']['topic_first_post_id']}";
$this->db->sql_query($sql);
} else {
//only set hookup_active_date
$sql = 'UPDATE ' . TOPICS_TABLE . '
SET hookup_active_date = ' . (int) $set_active . "\n\t\t\t\t\t\t\t\tWHERE topic_id = {$topic_id}";
$this->db->sql_query($sql);
}
//notify all members about active date
if ($set_active && $send_email && !empty($this->hookup->hookup_users)) {
if ($this->messenger == null) {
include_once $this->phpbb_root_path . 'includes/functions_messenger.' . $this->phpEx;
$this->messenger = new \messenger();
}
$messenger = $this->messenger;
$title_without_date = preg_replace('#^(\\[.+?\\] )#', '', $event['topic_data']['topic_title']);
$sql = 'SELECT u.user_id, u.username, u.user_lang, u.user_dateformat, u.user_email, u.user_jabber, u.user_notify_type
FROM ' . USERS_TABLE . " u\n\t\t\t\t\tWHERE " . $this->db->sql_in_set('user_id', array_keys($this->hookup->hookup_users));
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result)) {
$messenger->template('@gn36_hookup/hookup_active_date', $row['user_lang']);
$messenger->to($row['user_email'], $row['username']);
$messenger->im($row['user_jabber'], $row['username']);
$messenger->assign_vars(array('USERNAME' => $row['username'], 'TOPIC_TITLE' => $title_without_date, 'U_TOPIC' => generate_board_url() . "/viewtopic.{$this->phpEx}?f={$forum_id}&t={$topic_id}", 'ACTIVE_DATE' => $this->user->format_date($this->hookup->hookup_dates[$set_active]['date_time'], $row['user_dateformat']), 'ACTIVE_DATE_SHORT' => $this->user->format_date($this->hookup->hookup_dates[$set_active]['date_time'], $this->user->lang['HOOKUP_DATEFORMAT'])));
$messenger->send($row['user_notify_type']);
}
$this->db->sql_freeresult($result);
$messenger->save_queue();
}
//post reply to this topic. Again this can only be in the "active maker"s language
if ($set_active && $post_reply) {
$message = $this->user->lang['SET_ACTIVE_POST_TEMPLATE'];
$message = str_replace('{ACTIVE_DATE}', $this->user->format_date($this->hookup->hookup_dates[$set_active]['date_time'], $this->user->lang['HOOKUP_DATEFORMAT_POST']), $message);
//TODO: functions_post_oo!
//$post = new post($topic_id);
//$post->post_text = $message;
//$post->submit();
}
meta_refresh(3, $viewtopic_url);
$message = ($set_active != 0 ? sprintf($this->user->lang['ACTIVE_DATE_SET'], $active_date_formatted) : $this->user->lang['ACTIVE_DATE_UNSET']) . '<br /><br />' . sprintf($this->user->lang['RETURN_TOPIC'], '<a href="' . $viewtopic_url . '">', '</a>');
trigger_error($message);
} else {
$s_hidden_fields = build_hidden_fields(array('t' => $topic_id, 'set_active' => $set_active));
if ($set_active != 0) {
confirm_box(false, sprintf($this->user->lang['SET_ACTIVE_CONFIRM'], $active_date_formatted), $s_hidden_fields, '@gn36_hookup/hookup_active_date_confirm.html');
} else {
confirm_box(false, 'UNSET_ACTIVE', $s_hidden_fields);
}
//.........这里部分代码省略.........
示例14: process_set_activedate
/**
* Processes hookup set activedate requests
*
* @param \phpbb\event\data $event
* @param bool $is_owner
*/
protected function process_set_activedate($event, $is_owner)
{
$set_active_set = $this->request->is_set('set_active', \phpbb\request\request_interface::POST) || $this->request->is_set('set_active', \phpbb\request\request_interface::GET);
$set_active = $this->request->variable('set_active', 0);
if (!$set_active_set) {
return array();
}
if (!$is_owner) {
return array($this->user->lang('NOT_AUTH_HOOKUP'));
}
if ($set_active && !isset($this->hookup->hookup_dates[$set_active])) {
trigger_error('NO_DATE');
}
$active_date_formatted = '-';
if ($set_active != 0) {
$active_date_formatted = $this->user->format_date($this->hookup->hookup_dates[$set_active]['date_time']);
if ($this->hookup->hookup_dates[$set_active]['text'] != null) {
$active_date_formatted = $this->hookup->hookup_dates[$set_active]['text'];
}
}
$topic_id = $event['topic_id'];
$forum_id = $event['forum_id'];
$viewtopic_url = append_sid("{$this->phpbb_root_path}viewtopic.{$this->phpEx}?f={$forum_id}&t={$topic_id}");
if (confirm_box(true)) {
$title_prefix = $this->request->variable('title_prefix', false);
$send_email = $this->request->variable('send_email', false);
$post_reply = $this->request->variable('post_reply', false);
$topic_data = $event['topic_data'];
$new_string = '';
if ($set_active != 0) {
if ($this->hookup->hookup_dates[$set_active]['text'] != null) {
$new_string = '[' . $this->hookup->hookup_dates[$set_active]['text'] . '] ';
} else {
$new_string = '[' . $this->user->format_date($this->hookup->hookup_dates[$set_active]['date_time'], $this->user->lang['HOOKUP_DATEFORMAT_TITLE']) . '] ';
}
}
$new_title = preg_replace('#^(\\[.+?\\] )?#', $new_string, $event['topic_data']['topic_title']);
/**
* Perform additional actions when active date is set
*
* @event gn36.hookup.set_activedate_confirmed
* @var bool title_prefix User wants to have a title prefix added
* @var bool send_email User wants E-Mails to be sent
* @var bool post_reply User wants to post a reply to the topic
* @var int set_active Date selected as active (0 means reset of active date)
* @var string new_title The new topic title that will be present after the update
* @var int topic_id ID of the topic of the hookup
* @var int forum_id ID of the forum the topic is in
* @var array topic_data Topic data as received from core.viewtopic_assign_template_vars_before
* @since 1.0.0-a1
*/
$vars = array('title_prefix', 'send_email', 'post_reply', 'set_active', 'new_title', 'topic_id', 'forum_id', 'topic_data');
extract($this->phpbb_dispatcher->trigger_event('gn36.hookup.set_activedate_confirmed', compact($vars)));
//insert active date (short format) into topic title. this will use language
//and timezone of the "active maker" but the alternative would be
//to query the HOOKUP_DATES table every time we need the topic title
if ($set_active == 0 || $title_prefix) {
$sql = 'UPDATE ' . TOPICS_TABLE . '
SET hookup_active_date = ' . (int) $set_active . ",\n\t\t\t\t\t\t\ttopic_title = '" . $this->db->sql_escape($new_title) . "'\n\t\t\t\t\t\t\t\t\tWHERE topic_id = {$topic_id}";
$this->db->sql_query($sql);
$sql = "UPDATE " . POSTS_TABLE . "\n\t\t\t\t\t\tSET post_subject='" . $this->db->sql_escape($new_title) . "'\n\t\t\t\t\t\t\t\tWHERE post_id = {$event['topic_data']['topic_first_post_id']}";
$this->db->sql_query($sql);
} else {
//only set hookup_active_date
$sql = 'UPDATE ' . TOPICS_TABLE . '
SET hookup_active_date = ' . (int) $set_active . "\n\t\t\t\t\t\t\t\tWHERE topic_id = {$topic_id}";
$this->db->sql_query($sql);
}
$this->hookup->update_available_sums();
//notify all members about active date
if (!empty($this->hookup->hookup_users)) {
if ($set_active) {
$notify_data = array('user_id' => $this->user->data['user_id'], 'date_id' => $set_active, 'date' => $this->hookup->hookup_dates[$set_active]['date_time'], 'text' => $this->hookup->hookup_dates[$set_active]['text'], 'topic_title' => $event['topic_data']['topic_title'], 'topic_id' => $event['topic_id'], 'forum_id' => $event['forum_id'], 'yes' => $this->hookup->hookup_available_sums[$set_active][\gn36\hookup\functions\hookup::HOOKUP_YES], 'no' => $this->hookup->hookup_available_sums[$set_active][\gn36\hookup\functions\hookup::HOOKUP_NO], 'maybe' => $this->hookup->hookup_available_sums[$set_active][\gn36\hookup\functions\hookup::HOOKUP_MAYBE]);
$this->notification_manager->add_notifications('gn36.hookup.notification.type.active_date_set', $notify_data);
$this->notification_manager->update_notifications('gn36.hookup.notification.type.active_date_set', $notify_data);
$this->notification_manager->delete_notifications('gn36.hookup.notification.type.active_date_reset', $event['topic_id']);
} else {
$notify_data = array('user_id' => $this->user->data['user_id'], 'topic_title' => isset($new_title) ? $new_title : $event['topic_data']['topic_title'], 'topic_id' => $event['topic_id'], 'forum_id' => $event['forum_id']);
$this->notification_manager->delete_notifications('gn36.hookup.notification.type.active_date_set', $event['topic_id']);
$this->notification_manager->add_notifications('gn36.hookup.notification.type.active_date_reset', $notify_data);
$this->notification_manager->update_notifications('gn36.hookup.notification.type.active_date_reset', $notify_data);
}
}
//post reply to this topic. Again this can only be in the "active maker"s language
if ($set_active && $post_reply) {
$message = $this->user->lang['SET_ACTIVE_POST_TEMPLATE'];
$active_date = $this->user->format_date($this->hookup->hookup_dates[$set_active]['date_time'], $this->user->lang['HOOKUP_DATEFORMAT_POST']);
if ($this->hookup->hookup_dates[$set_active]['text'] != null) {
$active_date = $this->hookup->hookup_dates[$set_active]['text'];
}
$message = str_replace('{ACTIVE_DATE}', $active_date, $message);
//TODO: functions_post_oo!
//$post = new post($topic_id);
//$post->post_text = $message;
//.........这里部分代码省略.........
示例15: get_template_side
/**
* {@inheritdoc}
*/
public function get_template_side($module_id)
{
$portal_config = obtain_portal_config();
// 0 = Sunday first - 1 = Monday first. ;-)
if ($this->config['board3_sunday_first_' . $module_id]) {
$this->mini_cal_fdow = 0;
} else {
$this->mini_cal_fdow = 1;
}
// get the calendar month
$this->mini_cal_month = 0;
if ($this->request->is_set('m' . $module_id)) {
$this->mini_cal_month = $this->request->variable('m' . $module_id, 0);
}
// initialise some variables
$this->time = $this->user->create_datetime();
$now = phpbb_gmgetdate($this->time->getTimestamp() + $this->time->getOffset());
$today_timestamp = $now[0];
$mini_cal_today = date('Ymd', $today_timestamp);
$this->stamp = (int) $today_timestamp;
$s_cal_month = $this->mini_cal_month != 0 ? $this->mini_cal_month . ' month' : $mini_cal_today;
$this->get_month($s_cal_month);
$mini_cal_count = $this->mini_cal_fdow;
$mini_cal_this_year = $this->dateYYYY;
$mini_cal_this_month = $this->dateMM;
$mini_cal_month_days = $this->daysMonth;
// output our general calendar bits
$down = $this->mini_cal_month - 1;
$up = $this->mini_cal_month + 1;
$prev_month = '<a href="' . $this->modules_helper->route('board3_portal_controller') . "?m{$module_id}={$down}#minical{$module_id}" . '" rel="nofollow"><span class="portal-arrow-left-icon" title="' . $this->user->lang['VIEW_PREVIOUS_MONTH'] . '"></span></a>';
$next_month = '<a href="' . $this->modules_helper->route('board3_portal_controller') . "?m{$module_id}={$up}#minical{$module_id}" . '" rel="nofollow"><span class="portal-arrow-right-icon" title="' . $this->user->lang['VIEW_NEXT_MONTH'] . '"></span></a>';
$this->template->assign_block_vars('minical', array('S_SUNDAY_FIRST' => $this->config['board3_sunday_first_' . $module_id] ? true : false, 'L_MINI_CAL_MONTH' => ($this->config['board3_long_month_' . $module_id] ? $this->user->lang['mini_cal']['long_month'][$this->day[0][1]] : $this->user->lang['mini_cal']['month'][$this->day[0][1]]) . " " . $this->day[0][2], 'L_MINI_CAL_SUN' => '<span style="color: ' . $this->config['board3_calendar_sunday_color_' . $module_id] . ';">' . $this->user->lang['mini_cal']['day'][1] . '</span>', 'L_MINI_CAL_MON' => $this->user->lang['mini_cal']['day'][2], 'L_MINI_CAL_TUE' => $this->user->lang['mini_cal']['day'][3], 'L_MINI_CAL_WED' => $this->user->lang['mini_cal']['day'][4], 'L_MINI_CAL_THU' => $this->user->lang['mini_cal']['day'][5], 'L_MINI_CAL_FRI' => $this->user->lang['mini_cal']['day'][6], 'L_MINI_CAL_SAT' => $this->user->lang['mini_cal']['day'][7], 'U_PREV_MONTH' => $prev_month, 'U_NEXT_MONTH' => $next_month, 'S_DISPLAY_EVENTS' => $this->config['board3_display_events_' . $module_id] ? true : false, 'MODULE_ID' => $module_id));
// output the days for the current month
for ($i = 0; $i < $mini_cal_month_days;) {
// is this the first day of the week?
if ($mini_cal_count == $this->mini_cal_fdow) {
$this->template->assign_block_vars('minical.mini_cal_row', array('MODULE_ID' => $module_id));
}
// is this a valid weekday?
if ($mini_cal_count == $this->day[$i][3]) {
$mini_cal_this_day = $this->day[$i][0];
$d_mini_cal_today = $mini_cal_this_year . ($mini_cal_this_month <= 9 ? '0' . $mini_cal_this_month : $mini_cal_this_month) . ($mini_cal_this_day <= 9 ? '0' . $mini_cal_this_day : $mini_cal_this_day);
$mini_cal_day = $mini_cal_today == $d_mini_cal_today ? '<span style="font-weight: bold; color: ' . $this->config['board3_calendar_today_color_' . $module_id] . ';">' . $mini_cal_this_day . '</span>' : $mini_cal_this_day;
$this->template->assign_block_vars('minical.mini_cal_row.mini_cal_days', array('MINI_CAL_DAY' => $mini_cal_count == 0 ? '<span style="color: ' . $this->config['board3_calendar_sunday_color_' . $module_id] . ';">' . $mini_cal_day . '</span>' : $mini_cal_day));
$i++;
} else {
$this->template->assign_block_vars('minical.mini_cal_row.mini_cal_days', array('MINI_CAL_DAY' => ' '));
}
// is this the last day of the week?
if ($mini_cal_count == self::DAYS_PER_WEEK) {
// if so then reset the count
$mini_cal_count = 0;
} else {
// otherwise increment the count
$mini_cal_count++;
}
}
// fill table with empty strings
while ($mini_cal_count <= self::DAYS_PER_WEEK) {
$this->template->assign_block_vars('minical.mini_cal_row.mini_cal_days', array('MINI_CAL_DAY' => ' '));
$mini_cal_count++;
}
/*
* Let's start displaying the events
* make sure we only display events in the future
*/
$events = json_decode($portal_config['board3_calendar_events_' . $module_id], true);
if (!empty($events) && $this->config['board3_display_events_' . $module_id]) {
$time_ary = array();
// we sort the $events array by the start time
foreach ($events as $key => $cur_event) {
$time_ary[$key] = $cur_event['start_time'];
}
array_multisort($time_ary, SORT_NUMERIC, $events);
$groups_ary = get_user_groups();
foreach ($events as $key => $cur_event) {
if ($cur_event['start_time'] + $this->time->getOffset() >= $today_timestamp || $cur_event['end_time'] + $this->time->getOffset() >= $today_timestamp || $cur_event['start_time'] + $this->time->getOffset() + self::TIME_DAY >= $today_timestamp && $cur_event['all_day']) {
$cur_permissions = explode(',', $cur_event['permission']);
$permission_check = array_intersect($groups_ary, $cur_permissions);
if (!empty($permission_check) || $cur_event['permission'] == '') {
// check if this is an external link
if (isset($cur_event['url']) && strpos($cur_event['url'], generate_board_url()) === false) {
$is_external = true;
} else {
$is_external = false;
}
/**
* Current events
*
* Events are treated as current if the following is met:
* - We have an all day event and the start of that event is less than 1 day (86400 seconds) away
* - We have a normal event with a start that is less then 1 day away and that hasn't ended yet
*/
if ($cur_event['start_time'] + $this->time->getOffset() - $today_timestamp <= self::TIME_DAY && $cur_event['all_day'] || $cur_event['start_time'] + $this->time->getOffset() - $today_timestamp <= self::TIME_DAY && $cur_event['end_time'] + $this->time->getOffset() >= $today_timestamp) {
$this->template->assign_block_vars('minical.cur_events', array('EVENT_URL' => isset($cur_event['url']) && $cur_event['url'] != '' ? $this->validate_url($cur_event['url']) : '', 'EVENT_TITLE' => $cur_event['title'], 'START_TIME' => $this->user->format_date($cur_event['start_time']), 'END_TIME' => !empty($cur_event['end_time']) ? $this->user->format_date($cur_event['end_time']) : false, 'EVENT_DESC' => isset($cur_event['desc']) && $cur_event['desc'] != '' ? $cur_event['desc'] : '', 'ALL_DAY' => $cur_event['all_day'] ? true : false, 'MODULE_ID' => $module_id, 'EVENT_URL_NEW_WINDOW' => $is_external && $this->config['board3_events_url_new_window_' . $module_id] ? true : false));
} else {
$this->template->assign_block_vars('minical.upcoming_events', array('EVENT_URL' => isset($cur_event['url']) && $cur_event['url'] != '' ? $this->validate_url($cur_event['url']) : '', 'EVENT_TITLE' => $cur_event['title'], 'START_TIME' => $this->user->format_date($cur_event['start_time']), 'END_TIME' => !$cur_event['all_day'] ? $this->user->format_date($cur_event['end_time']) : '', 'EVENT_DESC' => isset($cur_event['desc']) && $cur_event['desc'] != '' ? $cur_event['desc'] : '', 'ALL_DAY' => $cur_event['start_time'] - $cur_event['end_time'] == 1 ? true : false, 'MODULE_ID' => $module_id, 'EVENT_URL_NEW_WINDOW' => $is_external && $this->config['board3_events_url_new_window_' . $module_id] ? true : false));
//.........这里部分代码省略.........