public function main($id, $mode) { global $db, $user, $phpbb_admin_path, $phpbb_root_path, $phpEx, $template, $request, $cache, $auth, $config; $this->db = $db; $this->user = $user; $this->template = $template; $this->request = $request; $this->cache = $cache; $this->auth = $auth; $this->config = $config; $this->phpbb_root_path = $phpbb_root_path; $this->php_ext = $phpEx; $this->default_style = $config['default_style']; $this->styles_path = $this->phpbb_root_path . $this->styles_path_absolute . '/'; $this->u_base_action = append_sid("{$phpbb_admin_path}index.{$this->php_ext}", "i={$id}"); $this->s_hidden_fields = array('mode' => $mode); $this->user->add_lang('acp/styles'); $this->tpl_name = 'acp_styles'; $this->page_title = 'ACP_CAT_STYLES'; $this->mode = $mode; $action = $this->request->variable('action', ''); $post_actions = array('install', 'activate', 'deactivate', 'uninstall'); foreach ($post_actions as $key) { if ($this->request->is_set_post($key)) { $action = $key; } } // The uninstall action uses confirm_box() to verify the validity of the request, // so there is no need to check for a valid token here. if (in_array($action, $post_actions) && $action != 'uninstall') { $is_valid_request = check_link_hash($request->variable('hash', ''), $action) || check_form_key('styles_management'); if (!$is_valid_request) { trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING); } } if ($action != '') { $this->s_hidden_fields['action'] = $action; } $this->template->assign_vars(array('U_ACTION' => $this->u_base_action, 'S_HIDDEN_FIELDS' => build_hidden_fields($this->s_hidden_fields))); // Execute actions switch ($action) { case 'install': $this->action_install(); return; case 'uninstall': $this->action_uninstall(); return; case 'activate': $this->action_activate(); return; case 'deactivate': $this->action_deactivate(); return; case 'details': $this->action_details(); return; default: $this->frontend(); } }
/** * Initialized the survey data if necessary. * * @param unknown $event */ public function submit_post_end($event) { if (!$this->survey->can_create_survey($event['data']['forum_id'])) { return; } if ($this->request->is_set_post('survey_enabled') && ($event['mode'] == 'post' || $event['mode'] == 'edit' && $event['data']['topic_first_post_id'] == $event['data']['post_id'] && $this->survey->is_enabled($event['data']['topic_id']))) { $this->survey->initialize($event['data']['topic_id']); } }
/** * Event: core.posting_modify_submit_post_after * * @param Event $event */ public function posting_modify_submit_post_after($event) { $post_data = $event['post_data']; if ($post_data['topic_status'] == ITEM_UNLOCKED && $this->request->is_set_post('lock_topic')) { if ($this->auth->acl_get('m_lock', $event['forum_id']) || $this->auth->acl_get('f_user_lock', $event['forum_id']) && $this->user->data['is_registered'] && !empty($post_data['topic_poster']) && $this->user->data['user_id'] == $post_data['topic_poster'] && $post_data['topic_status'] == ITEM_UNLOCKED ? true : false) { $topic_data = array($event['post_data']['topic_id'] => $event['post_data']); $this->topic_mover->move_topics($topic_data, 'move_topics_when_locked'); } } }
/** * Process addition or modification of question * * @return array errors */ protected function process_question_addition_or_modification() { if (!check_form_key($this->form_key_name)) { return array($this->user->lang('FORM_INVALID')); } $question_id = self::NEW_QUESTION_ID; if ($this->request->is_set_post('survey-submit-question-modify')) { $question_id = (int) $this->request->variable('question_to_modify', ''); if (!$this->survey->question_exists($question_id)) { return array(); } } $question = array('label' => '', 'example_answer' => '', 'type' => 0, 'random_choice_order' => 0, 'sum_type' => 0, 'sum_by' => '', 'average' => 0, 'cap' => 0); foreach ($question as $key => $value) { $question[$key] = $this->request->variable('question_' . $key, $question[$key], true); } $question = array_map('trim', $question); if ($question['label'] == '') { return array($this->user->lang('SURVEY_INVALID_QUESTION_NO_LABEL')); } if ($this->survey->get_question_id_from_label($question['label'], $question_id) != $question_id) { return array($this->user->lang('SURVEY_QUESTION_ALREADY_ADDED', $question['label'])); } $question['random_choice_order'] = $question['random_choice_order'] ? 1 : 0; $question['average'] = $question['average'] ? 1 : 0; $question['cap'] = $question['cap'] != '' ? $question['cap'] : 0; if (!in_array($question['type'], survey::$QUESTION_TYPES)) { return array($this->user->lang('SURVEY_INVALID_QUESTION_TYPE')); } if (!in_array($question['sum_type'], survey::$QUESTION_SUM_TYPES)) { return array($this->user->lang('SURVEY_INVALID_QUESTION_SUM_TYPE')); } if ($question['sum_type'] == survey::$QUESTION_SUM_TYPES['MATCHING_TEXT'] && $question['sum_by'] == '') { return array($this->user->lang('SURVEY_INVALID_QUESTION_SUM_BY')); } if ($question['sum_type'] != survey::$QUESTION_SUM_TYPES['MATCHING_TEXT']) { $question['sum_by'] = ''; } if ($question['sum_type'] == survey::$QUESTION_SUM_TYPES['NO_SUM']) { $question['average'] = 0; $question['cap'] = 0; } $choices_input = $this->request->variable('question_choices', '', true); $choices = array(); if ($question['type'] == survey::$QUESTION_TYPES['DROP_DOWN_MENU'] || $question['type'] == survey::$QUESTION_TYPES['MULTIPLE_CHOICE']) { if ($choices_input == '') { return array($this->user->lang('SURVEY_INVALID_QUESTION_CHOICES')); } $choices = array_unique(explode(",", $choices_input)); } else { $question['random_choice_order'] = 0; } $choices = array_map('trim', $choices); if ($question_id == self::NEW_QUESTION_ID) { $this->survey->add_question($question, $choices); } else { $this->survey->modify_question($question_id, $question, $choices); } return array(); }
/** * Display new contribution page. * * @return \Symfony\Component\HttpFoundation\Response */ protected function create() { if (!$this->is_owner && !$this->auth->acl_get('u_titania_contrib_submit')) { return $this->helper->needs_auth(); } $this->user->add_lang_ext('phpbb/titania', 'contributions'); $contrib = new \titania_contribution(); $contrib->contrib_user_id = $this->user->data['user_id']; $contrib->author = $this->author; $contrib->get_options(); // Set some main vars up $message = $this->setup_message($contrib); $submit = $this->request->is_set_post('submit'); $preview = $this->request->is_set_post('preview'); $error = array(); $settings = array('type' => $this->request->variable('contrib_type', 0), 'permalink' => $this->request->variable('permalink', '', true), 'categories' => $this->request->variable('contrib_category', array(0)), 'coauthors' => array('active' => $this->request->variable('active_coauthors', '', true), 'nonactive' => $this->request->variable('nonactive_coauthors', '', true)), 'custom' => $this->request->variable('custom_fields', array('' => ''), true)); if ($preview || $submit) { $contrib->post_data($message); $contrib->__set_array(array('contrib_type' => $settings['type'], 'contrib_name_clean' => $settings['permalink'], 'contrib_visible' => 1)); } if ($preview) { $message->preview(); } else { if ($submit) { $authors = $contrib->get_authors_from_usernames(array('active_coauthors' => $settings['coauthors']['active'], 'nonactive_coauthors' => $settings['coauthors']['nonactive'])); $authors['author'] = array($this->user->data['username'] => $this->user->data['user_id']); $error = $contrib->validate($settings['categories'], $authors, $settings['custom']); if (($form_key_error = $message->validate_form_key()) !== false) { $error[] = $form_key_error; } if (empty($error)) { $contrib->set_type($contrib->contrib_type); $contrib->set_custom_fields($settings['custom']); $contrib->contrib_categories = implode(',', $settings['categories']); $contrib->contrib_creation_time = time(); $contrib->submit(); $contrib->set_coauthors($authors['active_coauthors'], $authors['nonactive_coauthors'], true); // Create relations $contrib->put_contrib_in_categories($settings['categories']); if ($this->ext_config->support_in_titania) { $active_authors = array_merge($authors['author'], $authors['active_coauthors']); foreach ($active_authors as $author) { $this->subscriptions->subscribe(TITANIA_SUPPORT, $contrib->contrib_id, $author); } } redirect($contrib->get_url('revision')); } } } // Generate some stuff $this->display->generate_type_select($contrib->contrib_type); $this->display->generate_category_select($settings['categories']); $contrib->assign_details(); $message->display(); foreach ($this->types->get_all() as $type) { $this->display->generate_custom_fields($type->contribution_fields, $settings['custom'], $type->id); } $this->template->assign_vars(array('S_POST_ACTION' => $this->author->get_url('create'), 'S_CREATE' => true, 'S_CAN_EDIT_CONTRIB' => $this->auth->acl_get('u_titania_contrib_submit'), 'CONTRIB_PERMALINK' => $settings['permalink'], 'ERROR_MSG' => !empty($error) ? implode('<br />', $error) : false, 'ACTIVE_COAUTHORS' => $settings['coauthors']['active'], 'NONACTIVE_COAUTHORS' => $settings['coauthors']['nonactive'])); return $this->helper->render('contributions/contribution_manage.html', 'NEW_CONTRIBUTION'); }
/** * Main ACP module. * * @param int $id * @param string $mode */ public function main($id, $mode) { $this->config = $GLOBALS['config']; $this->user = $GLOBALS['user']; $this->phpbb_root_path = $GLOBALS['phpbb_root_path']; $this->request = $GLOBALS['request']; $this->template = $GLOBALS['template']; $this->user->add_lang('acp/common'); $this->user->add_lang_ext('mop/timeago', 'timeago_acp'); // initialize error container $error = ''; // silence scrutinizer warning if ($id) { // do nothing } // use switch for future module expansion cases switch ($mode) { case 'general': $this->tpl_name = 'acp_ta_general'; $this->page_title = $this->user->lang('ACP_TIMEAGO_GENERAL_SETTINGS'); $form_key = 'acp_ta_general'; add_form_key($form_key); if (empty($error) && $this->request->is_set_post('submit')) { if (check_form_key($form_key) === false) { trigger_error($this->user->lang('FORM_INVALID') . adm_back_link($this->u_action), E_USER_WARNING); } $this->config->set('ta_cat', $this->request->variable('ta_cat', 1)); $this->config->set('ta_cat_extended', $this->request->variable('ta_cat_extended', 0)); $this->config->set('ta_viewforum', $this->request->variable('ta_viewforum', 1)); $this->config->set('ta_viewforum_extended', $this->request->variable('ta_viewforum_extended', 0)); $this->config->set('ta_viewtopic', $this->request->variable('ta_viewtopic', 1)); $this->config->set('ta_viewtopic_extended', $this->request->variable('ta_viewtopic_extended', 0)); $this->config->set('ta_timer', $this->request->variable('ta_timer', 0)); trigger_error($this->user->lang('CONFIG_UPDATED') . adm_back_link($this->u_action)); } //end if // set the template variables $this->template->assign_vars(['TA_FORUM_ROOT' => $this->phpbb_root_path, 'TA_CAT' => !empty($this->config['ta_cat']) ? $this->config['ta_cat'] : 0, 'TA_CAT_EXTENDED' => !empty($this->config['ta_cat_extended']) ? true : false, 'TA_VIEWFORUM' => !empty($this->config['ta_viewforum']) ? $this->config['ta_viewforum'] : 0, 'TA_VIEWFORUM_EXTENDED' => !empty($this->config['ta_viewforum_extended']) ? true : false, 'TA_VIEWTOPIC' => !empty($this->config['ta_viewtopic']) ? $this->config['ta_viewtopic'] : 0, 'TA_VIEWTOPIC_EXTENDED' => !empty($this->config['ta_viewtopic_extended']) ? true : false, 'TA_TIMER' => !empty($this->config['ta_timer']) ? $this->config['ta_timer'] : 0, 'U_ACTION' => $this->u_action]); break; default: // obligatory default comment break; } //end switch }
/** * Main ACP module * * @param integer $id * @param string $mode * * @access public * @return void */ public function main($id, $mode) { $this->config = $GLOBALS['config']; $this->user = $GLOBALS['user']; $this->phpbb_root_path = $GLOBALS['phpbb_root_path']; $this->request = $GLOBALS['request']; $this->template = $GLOBALS['template']; $this->user->add_lang('acp/common'); $this->user->add_lang_ext('svennd/simplecount', 'simplecount_var'); // initialize error container $error = ''; // use switch for future module expansion cases switch ($mode) { case 'general': $this->tpl_name = 'acp_sc_general'; $this->page_title = $this->user->lang('ACP_SIMPLECOUNT_GENERAL_SETTINGS'); $form_key = 'acp_sc_general'; add_form_key($form_key); if (empty($error) && $this->request->is_set_post('submit')) { if (check_form_key($form_key) === FALSE) { trigger_error($this->user->lang('FORM_INVALID') . adm_back_link($this->u_action), E_USER_WARNING); } $this->config->set('sc_active', $this->request->variable('sc_active', 1)); $this->config->set('sc_posts', $this->request->variable('sc_posts', 1)); $this->config->set('sc_topics', $this->request->variable('sc_topics', 1)); $this->config->set('sc_clicks', $this->request->variable('sc_clicks', 1)); $this->config->set('sc_viewforum_views', $this->request->variable('sc_viewforum_views', 1)); $this->config->set('sc_index_posts', $this->request->variable('sc_index_posts', 0)); $this->config->set('sc_index_topics', $this->request->variable('sc_index_topics', 0)); $this->config->set('sc_index_users', $this->request->variable('sc_index_users', 0)); trigger_error($this->user->lang('CONFIG_UPDATED') . adm_back_link($this->u_action)); } //end if // set the template variables $this->template->assign_vars(['SC_ACTIVE' => !empty($this->config['sc_active']) ? $this->config['sc_active'] : 0, 'SC_POSTS' => !empty($this->config['sc_posts']) ? $this->config['sc_posts'] : 0, 'SC_TOPICS' => !empty($this->config['sc_topics']) ? $this->config['sc_topics'] : 0, 'SC_CLICKS' => !empty($this->config['sc_clicks']) ? $this->config['sc_clicks'] : 0, 'SC_VIEWFORUM_VIEWS' => !empty($this->config['sc_viewforum_views']) ? $this->config['sc_viewforum_views'] : 0, 'SC_INDEX_POSTS' => !empty($this->config['sc_index_posts']) ? $this->config['sc_index_posts'] : 0, 'SC_INDEX_TOPICS' => !empty($this->config['sc_index_topics']) ? $this->config['sc_index_topics'] : 0, 'SC_INDEX_USERS' => !empty($this->config['sc_index_users']) ? $this->config['sc_index_users'] : 0, 'U_ACTION' => $this->u_action]); break; default: // obligatory default comment break; } //end switch }
/** * Delegates actions to appropriate methods. * * @param string $mode Module mode * @param string $u_action Module URL * @return null */ public function base($mode, $u_action) { if (!in_array($mode, array('items', 'sections'))) { return; } $this->u_action = $u_action; // User wants to unsubscribe? if ($this->request->is_set_post('unsubscribe')) { $this->unsubscribe(); } $this->{"display_{$mode}"}(); add_form_key('ucp_front_subscription'); }
/** * Stores the hookup data given in posting.php if necessary. * * @param unknown $event */ public function submit_post($event) { // Check permissions if (!$this->auth->acl_get('f_hookup', $event['data']['forum_id']) && !$this->auth->acl_get('m_edit', $event['data']['forum_id'])) { return; } // We store only if we are creating a new topic or editing the first post of an existing one if ($event['post_mode'] != 'post' && $event['post_mode'] != 'edit_topic' && $event['post_mode'] != 'edit_first_post') { return; } $sql_data = $event['sql_data']; $hookup_enabled = $this->request->is_set_post('hookup_enabled'); if ($event['post_mode'] == 'edit') { $this->hookup->load_hookup($event['data']['topic_id']); $no_data = empty($this->hookup->hookup_users) && empty($this->hookup->hookup_dates) && empty($this->hookup->hookup_availables); // Only honor user setting on enable/disable if the hookup is inactive or not set if ($this->hookup->hookup_enabled || $no_data) { $hookup_enabled = $this->hookup->hookup_enabled; } } $sql_data[TOPICS_TABLE]['sql'] = array_merge($sql_data[TOPICS_TABLE]['sql'], array('hookup_enabled' => $hookup_enabled, 'hookup_self_invite' => $this->request->is_set_post('hookup_self_invite'), 'hookup_autoreset' => $this->request->is_set_post('hookup_autoreset'))); $event['sql_data'] = $sql_data; }
protected function common_delete($post_id, $undelete = false) { $this->user->add_lang('posting'); // Load the stuff we need $post = $this->load_post($post_id); // Check permissions if (!$undelete && !$post->acl_get('delete') || $undelete && !$post->acl_get('undelete')) { return $this->controller_helper->needs_auth(); } if (confirm_box(true)) { if (!$undelete) { // Delete the post if ($this->request->is_set_post('hard_delete') || $post->post_deleted) { if (!$this->auth->acl_get('u_titania_post_hard_delete')) { return $this->controller_helper->needs_auth(); } $post->hard_delete(); // Try to redirect to the next or previous post $redirect_post_id = \posts_overlord::next_prev_post_id($post->topic_id, $post->post_id); if ($redirect_post_id) { return new RedirectResponse($post->topic->get_url(false, array('p' => $redirect_post_id, '#' => "p{$redirect_post_id}"))); } return new RedirectResponse($post->topic->get_parent_url()); } else { $post->soft_delete(); if ($this->auth->acl_get('u_titania_mod_post_mod')) { // They can see the post, redirect back to it return new RedirectResponse($post->get_url()); } else { // They cannot see the post, try to redirect to the next or previous post $redirect_post_id = \posts_overlord::next_prev_post_id($post->topic_id, $post->post_id); if ($redirect_post_id) { return new RedirectResponse($post->topic->get_url(false, array('p' => $redirect_post_id, '#' => "p{$redirect_post_id}"))); } } } return new RedirectResponse($post->topic->get_url()); } else { $post->undelete(); return new RedirectResponse($post->get_url()); } } else { $s_hard_delete = !$undelete && !$post->post_deleted && $this->auth->acl_get('u_titania_post_hard_delete'); $this->template->assign_var('S_HARD_DELETE', $s_hard_delete); confirm_box(false, !$undelete ? 'DELETE_POST' : 'UNDELETE_POST', '', 'posting/delete_confirm.html'); } return new RedirectResponse($post->get_url()); }
/** * @param \phpbb\event\data $event * * @return \phpbb\event\data $event|null * @throw http_exception */ public function auth_login_session_create_before($event) { if ($this->config['tfa_mode'] == session_helper_interface::MODE_DISABLED) { return $event; } if (isset($event['login'], $event['login']['status']) && $event['login']['status'] == LOGIN_SUCCESS) { // We have a LOGIN_SUCCESS result. if ($this->session_helper->isTfaRequired($event['login']['user_row']['user_id'], $event['admin'], $event['user_row'])) { if (!$this->session_helper->isTfaRegistered($event['login']['user_row']['user_id'])) { // While 2FA is enabled, the user has no methods added. // We simply return and continue the login procedure (The normal way :)), // and will disable all pages until he has added a 2FA key. return $event; } else { $this->session_helper->generate_page($event['login']['user_row']['user_id'], $event['admin'], $event['view_online'], !$this->request->is_set_post('viewonline'), $this->request->variable('redirect', '')); } } } return null; }
/** * Process status changes * @param \phpbb\event\data $event * @param bool $is_member */ protected function process_status($event, $is_member) { $availables = $this->request->variable('available', array(0 => 0)); if (!$this->request->is_set_post('available')) { return array(); } if (!$is_member) { return array($this->user->lang('NO_HOOKUP_MEMBER')); } foreach ($availables as $date_id => $available) { //ignore HOOKUP_UNSET and other invalid values if (!is_numeric($date_id) || !isset($this->hookup->hookup_dates[$date_id]) || !in_array($available, array(hookup::HOOKUP_YES, hookup::HOOKUP_NO, hookup::HOOKUP_MAYBE))) { continue; } $this->hookup->set_user_date($this->user->data['user_id'], $date_id, $available); } $this->hookup->update_available_sums(); $this->hookup->set_user_data($this->user->data['user_id'], 0, $this->request->variable('comment', '', true)); return array(); }
public function posts_merging($event) { $mode = $event['mode']; $subject = $event['subject']; $username = $event['username']; $topic_type = $event['topic_type']; $poll = $event['poll']; $data = $event['data']; $update_message = $event['update_message']; $update_search_index = $event['update_search_index']; $current_time = time(); // Preliminary checks if the post-based post merging option was checked, // and user has permission for merging or ignoring merging $do_not_merge_with_previous = $this->request->is_set_post('posts_merging_option', false) && $this->auth->acl_get('u_postsmerging') && $this->auth->acl_get('u_postsmerging_ignore'); if ($this->auth->acl_get('u_postsmerging') && !$do_not_merge_with_previous && !$this->helper->post_needs_approval($data) && in_array($mode, array('reply', 'quote')) && $this->merge_interval && !$this->helper->excluded_from_merge($data)) { $merge_post_data = $this->helper->get_last_post_data($data); // Do not merge if there's no last post data, the poster is not current user, user is not registered,or // the post is locked, has not yet been approved or allowed merge period has left if (!$merge_post_data || $merge_post_data['poster_id'] != $this->user->data['user_id'] || $merge_post_data['post_edit_locked'] || (int) $merge_post_data['post_visibility'] == ITEM_UNAPPROVED || $current_time - (int) $merge_post_data['topic_last_post_time'] > $this->merge_interval || !$this->user->data['is_registered']) { return; } // Also, don't let user to violate attachments limit by posts merging // In this case, also don't merge posts and return // Exceptions are administrators and forum moderators $num_old_attachments = $this->helper->count_post_attachments((int) $merge_post_data['post_id']); $num_new_attachments = sizeof($data['attachment_data']); $total_attachments_count = $num_old_attachments + $num_new_attachments; if ($total_attachments_count > $this->config['max_attachments'] && !$this->auth->acl_get('a_') && !$this->auth->acl_get('m_', (int) $data['forum_id'])) { return; } $data['post_id'] = (int) $merge_post_data['post_id']; $merge_post_data['post_attachment'] = $total_attachments_count ? 1 : 0; // Decode old message and addon $merge_post_data['post_text'] = $this->helper->prepare_text_for_merge($merge_post_data); $data['message'] = $this->helper->prepare_text_for_merge($data); // Handle inline attachments BBCode in old message if ($num_new_attachments) { $merge_post_data['post_text'] = preg_replace('#\\[attachment=([0-9]+)\\](.*?)\\[\\/attachment\\]#e', "'[attachment='.(\\1 + {$num_new_attachments}).']\\2[/attachment]'", $merge_post_data['post_text']); } // Prepare message separator $separator = (string) $this->config_text->get('posts_merging_separator_text'); $this->user->add_lang_ext('rxu/PostsMerging', 'posts_merging'); // Calculate the time interval $interval = $this->helper->get_time_interval($current_time, $merge_post_data['post_time']); $time = array(); $time[] = $interval->h ? $this->user->lang('D_HOURS', $interval->h) : null; $time[] = $interval->i ? $this->user->lang('D_MINUTES', $interval->i) : null; $time[] = $interval->s ? $this->user->lang('D_SECONDS', $interval->s) : null; // Allow using language variables like {L_LANG_VAR} // Since /e modifier is deprecated since PHP 5.5.0, use new way // But for PHP 5.4.0 only as earlier don't support $this closure in anonymous functions if (version_compare(PHP_VERSION, '5.4.0', '>=')) { $separator = preg_replace_callback('/{L_([A-Z0-9_]+)}/', function ($matches) { return $this->user->lang($matches[1]); }, $separator); } else { $separator = preg_replace('/{L_([A-Z0-9_]+)}/e', "\$this->user->lang('\$1')", $separator); } // Eval linefeeds and generate the separator, time interval included $separator = sprintf(str_replace('\\n', "\n", $separator), implode(' ', $time)); // Merge subject if (!empty($subject) && $subject != $merge_post_data['post_subject'] && $merge_post_data['post_id'] != $merge_post_data['topic_first_post_id']) { $separator .= sprintf($this->user->lang['MERGE_SUBJECT'], $subject); } // Merge posts $merge_post_data['post_text'] = $merge_post_data['post_text'] . $separator . $data['message']; // Make sure the message is safe $this->type_cast_helper->recursive_set_var($merge_post_data['post_text'], '', true); //Prepare post for submit $options = ''; $warn_msg = generate_text_for_storage($merge_post_data['post_text'], $merge_post_data['bbcode_uid'], $merge_post_data['bbcode_bitfield'], $options, $merge_post_data['enable_bbcode'], $merge_post_data['enable_magic_url'], $merge_post_data['enable_smilies']); // If $warn_msg is not empty, the merged message does not conform some restrictions // In this case we simply don't merge and return back to the function submit_post() if (!empty($warn_msg)) { return; } // If this is the first merging for current post, save original post time within the post_created field // Update post time with the current time and submit post to the database $merge_post_data['post_created'] = $merge_post_data['post_created'] ?: $merge_post_data['post_time']; $merge_post_data['post_time'] = $data['post_time'] = $current_time; $this->helper->submit_post_to_database($merge_post_data); // Submit attachments $this->helper->submit_attachments($data); // Update read tracking $this->helper->update_read_tracking($data); // If a username was supplied or the poster is a guest, we will use the supplied username. // Doing it this way we can use "...post by guest-username..." in notifications when // "guest-username" is supplied or ommit the username if it is not. $username = $username !== '' || !$this->user->data['is_registered'] ? $username : $this->user->data['username']; // Send Notifications // Despite the post_id is the same and users who've been already notified // won't be notified again about the same post_id, we send notifications // for new users possibly subscribed to it $notification_data = array_merge($data, array('topic_title' => isset($data['topic_title']) ? $data['topic_title'] : $subject, 'post_username' => $username, 'poster_id' => (int) $data['poster_id'], 'post_text' => $data['message'], 'post_time' => $merge_post_data['post_time'], 'post_subject' => $subject)); $this->notification_manager->add_notifications(array('notification.type.quote', 'notification.type.bookmark', 'notification.type.post'), $notification_data); // Update search index $this->helper->update_search_index($merge_post_data); //Generate redirection URL and redirecting $params = $add_anchor = ''; $params .= '&t=' . $data['topic_id']; $params .= '&p=' . $data['post_id']; $add_anchor = '#p' . $data['post_id']; $url = "{$this->phpbb_root_path}viewtopic.{$this->php_ext}"; $url = append_sid($url, 'f=' . (int) $data['forum_id'] . $params) . $add_anchor; /** * Modify the data for post submitting * * @event rxu.postsmerging.posts_merging_end * @var string mode Variable containing posting mode value * @var string subject Variable containing post subject value * @var string username Variable containing post author name * @var int topic_type Variable containing topic type value * @var array poll Array with the poll data for the post * @var array data Array with the data for the post * @var bool update_message Flag indicating if the post will be updated * @var bool update_search_index Flag indicating if the search index will be updated * @var string url The "Return to topic" URL * @since 2.0.0 */ $vars = array('mode', 'subject', 'username', 'topic_type', 'poll', 'data', 'update_message', 'update_search_index', 'url'); extract($this->phpbb_dispatcher->trigger_event('rxu.postsmerging.posts_merging_end', compact($vars))); redirect($url); } }
public function avatar_crop($avatar_id) { $extension = $this->request->variable('ext', ''); $submit = $this->request->is_set_post('submit'); $prefix = $this->config['avatar_salt'] . '_'; // Calculate new destination $destination = $this->config['avatar_path']; // Adjust destination path (no trailing slash) if (substr($destination, -1, 1) == '/' || substr($destination, -1, 1) == '\\') { $destination = substr($destination, 0, -1); } $destination = str_replace(array('../', '..\\', './', '.\\'), '', $destination); if ($destination && ($destination[0] == '/' || $destination[0] == "\\")) { $destination = ''; } $destination_file = $this->phpbb_root_path . $destination . '/' . $prefix . $avatar_id . '.' . $extension; $destination_old_file = $this->phpbb_root_path . $this->d_edit . '/' . $avatar_id . '.' . $extension; $this->user->setup('ucp'); $this->user->add_lang_ext('bb3mobi/AvatarUpload', 'avatar_upload'); $error = array(); if ($this->user->data['user_id'] != $avatar_id) { trigger_error('NO_AVATAR_USER'); } if (!$extension || !file_exists($destination_old_file)) { trigger_error('NO_AVATAR_FILES'); } if (($image_info = @getimagesize($destination_old_file)) == false) { trigger_error('NO_AVATAR_FILES'); } $avatar_width = $image_info[0]; $avatar_height = $image_info[1]; $params_size = array('x1' => $this->request->variable('x1', 0), 'y1' => $this->request->variable('y1', 0), 'x2' => ceil($this->request->variable('x2', $image_info[0])), 'y2' => ceil($this->request->variable('y2', $image_info[1])), 'w' => floor($this->request->variable('w', $image_info[0])), 'h' => floor($this->request->variable('h', $image_info[1])), 'ext' => (string) $extension); if ($submit) { if ($params_size['w'] < $this->config['avatar_min_width'] || $params_size['x1'] > $avatar_width - $this->config['avatar_max_width']) { $error[] = $this->user->lang['ERROR_AVATAR_W']; } if ($params_size['h'] < $this->config['avatar_min_height'] || $params_size['y1'] > $avatar_height - $this->config['avatar_max_height']) { $error[] = $this->user->lang['ERROR_AVATAR_H']; } if ($params_size['x2'] > $avatar_width || $params_size['x2'] < $this->config['avatar_min_width']) { $error[] = $this->user->lang['ERROR_AVATAR_X2']; } if ($params_size['y2'] > $avatar_height || $params_size['y2'] < $this->config['avatar_min_height']) { $error[] = $this->user->lang['ERROR_AVATAR_Y2']; } } if (!sizeof($error) && $submit) { if ($result = $this->resize($params_size, $this->d_edit, $destination_old_file)) { rename($destination_old_file, $destination_file); // Success! Lets save the result in the database $result = array('user_avatar_type' => AVATAR_UPLOAD, 'user_avatar' => $avatar_id . '_' . time() . '.' . $extension, 'user_avatar_width' => $result['avatar_width'], 'user_avatar_height' => $result['avatar_height']); $sql = 'UPDATE ' . USERS_TABLE . ' SET ' . $this->db->sql_build_array('UPDATE', $result) . ' WHERE user_id = ' . (int) $this->user->data['user_id']; $this->db->sql_query($sql); meta_refresh(3, generate_board_url(), true); $message = $this->user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($this->user->lang['RETURN_INDEX'], '<a href="' . generate_board_url() . '">', '</a>'); trigger_error($message); } } $this->template->assign_vars(array('ERROR' => sizeof($error) ? implode('<br />', $error) : '', 'AVATAR_FILE' => generate_board_url() . '/' . $this->d_edit . '/' . $avatar_id . '.' . $extension, 'IMG_WIDTH' => $image_info[0], 'IMG_HEIGHT' => $image_info[1], 'SIZE_X1' => $params_size['x1'], 'SIZE_X2' => $params_size['x2'], 'SIZE_Y1' => $params_size['y1'], 'SIZE_Y2' => $params_size['y2'], 'SIZE_WIDTH' => $params_size['w'], 'SIZE_HEIGHT' => $params_size['h'], 'S_HIDDEN_FIELDS' => build_hidden_fields(array('ext' => $extension)), 'S_CROP_ACTION' => $this->helper->route("bb3mobi_AvatarUpload_crop", array('avatar_id' => $avatar_id)))); page_header('Avatar crop'); $this->template->set_filenames(array('body' => '@bb3mobi_AvatarUpload/crop_body.html')); page_footer(); }
/** * @{inheritDoc} */ public function approve(\titania_contribution $contrib, \titania_queue $queue, request_interface $request) { if (!$request->is_set_post('style_demo_install')) { return; } $revision = $queue->get_revision(); $this->install_demo($contrib, $revision); }
public function medals_system() { if (!$this->config['medals_active']) { $url = append_sid($this->phpbb_root_path . 'index.' . $this->php_ext); $message = "This mod is not active. <br /><br />Click <a href=\"{$url}\">here</a> to return to the index.<br />"; trigger_error($message); } // Gather post and get variables $mode = $this->request->variable('m', ''); $from = $this->request->variable('f', ''); $user_id = $this->request->variable('u', 0); $usernames = $this->request->variable('add', '', true); $medal_id = $this->request->variable('mid', 0); $med_id = $this->request->variable('med', 0); $submit = $this->request->is_set_post('submit'); $catchoice = $this->request->variable('cat', $this->getfirstcat()); // Dynamic Medal Image creation if ($mode == "mi") { $medal = $this->request->variable('med', ''); $device = $this->request->variable('d', ''); $this->dynamic->create_dynamic_image($medal, $device); exit; } $phpbb_root_path = $this->phpbb_root_path; $phpEx = $this->php_ext; $medals_path = generate_board_url() . '/images/medals'; include $phpbb_root_path . 'includes/functions_posting.' . $phpEx; include $phpbb_root_path . 'includes/functions_display.' . $phpEx; include $phpbb_root_path . 'includes/message_parser.' . $phpEx; $this->config['points_enable'] = isset($this->config['points_enable']) ? $this->config['points_enable'] : 0; $medals = array(); $sql = "SELECT *\n\t\t\tFROM " . $this->tb_medal . "\n\t\t\tORDER BY order_id ASC"; $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { $medals[$row['id']] = array('name' => $row['name'], 'image' => $medals_path . '/' . $row['image'], 'device' => $medals_path . '/devices/' . $row['device'], 'dynamic' => $row['dynamic'], 'parent' => $row['parent'], 'id' => $row['id'], 'number' => $row['number'], 'nominated' => $row['nominated'], 'order_id' => $row['order_id'], 'description' => $row['description'], 'points' => $row['points']); } $this->db->sql_freeresult($result); $sql = "SELECT *\n\t\t\tFROM " . $this->tb_medals_cats . "\n\t\t\tORDER BY order_id ASC"; $result = $this->db->sql_query($sql); $cats = array(); while ($row = $this->db->sql_fetchrow($result)) { $cats[$row['id']] = array('name' => $row['name'], 'id' => $row['id'], 'order_id' => $row['order_id']); $this->template->assign_block_vars('catlinkrow', array('U_CATPAGE' => $this->helper->route('bb3mobi_medals_controller', array('cat' => $row['id'])), 'MEDAL_CAT' => $row['name'])); } $this->db->sql_freeresult($result); generate_smilies('inline', 0); $this->template->assign_vars(array('S_CAN_AWARD_MEDALS' => $this->user->data['user_type'] == USER_FOUNDER || $this->auth->acl_get('u_award_medals') ? true : false, 'S_CAN_NOMINATE_MEDALS' => $this->auth->acl_get('u_nominate_medals') && $user_id != $this->user->data['user_id'] ? true : false, 'U_NOMINATE_PANEL' => $this->helper->route('bb3mobi_medals_controller', array('m' => 'nominate', 'u' => $user_id)), 'U_AWARD_PANEL' => $this->helper->route('bb3mobi_medals_controller', array('m' => 'award', 'u' => $user_id)), 'U_VALIDATE_PANEL' => $this->helper->route('bb3mobi_medals_controller', array('m' => 'validate', 'u' => $user_id)), 'U_AWARDED_PANEL' => $this->helper->route('bb3mobi_medals_controller', array('m' => 'awarded', 'u' => $user_id)))); switch ($mode) { case 'nominate': if ($this->user->data['user_id'] == ANONYMOUS || !$this->auth->acl_get('u_nominate_medals')) { trigger_error($this->user->lang['NO_GOOD_PERMS']); } if ($user_id == 0 || $user_id == ANONYMOUS) { trigger_error('NO_USER_ID'); } if ($user_id == $this->user->data['user_id']) { trigger_error('NOT_SELF'); } $sql = "SELECT *\n\t\t\t\t\t\tFROM " . $this->tb_medals_awarded . "\n\t\t\t\t\t\tWHERE user_id = {$user_id}\n\t\t\t\t\t\tORDER BY medal_id AND nominated"; $result = $this->db->sql_query($sql); $my_medals = array(); while ($row = $this->db->sql_fetchrow($result)) { $awarded_by_me = isset($my_medals[$row['medal_id']]['awarded_by_me']) && $row['nominated'] == 1 ? $my_medals[$row['medal_id']]['awarded_by_me'] : 0; $row['awarded_by_me'] = $this->user->data['user_id'] == $row['awarder_id'] && $awarded_by_me == 0 && $row['nominated'] == 1 ? 1 : $awarded_by_me; $my_medals[$row['medal_id']] = $row; } $this->db->sql_freeresult($result); $sql = "SELECT user_id, username, user_colour\n\t\t\t\t\tFROM " . USERS_TABLE . "\n\t\t\t\t\tWHERE user_id = {$user_id}"; $result = $this->db->sql_query($sql); $row = $this->db->sql_fetchrow($result); $this->db->sql_freeresult($result); $username = get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $row['username']); $medals_options = '<option value=""></option>'; $temp_string = ''; $i = 0; foreach ($cats as $key => $value) { $at_least_one = false; foreach ($medals as $key2 => $value2) { if ($value2['parent'] == $value['id']) { $can_award = false; $my_medals[$value2['id']]['awarded_by_me'] = isset($my_medals[$value2['id']]['awarded_by_me']) ? $my_medals[$value2['id']]['awarded_by_me'] : 0; if ($value2['nominated'] == 1 && $my_medals[$value2['id']]['awarded_by_me'] == 0) { $temp_string .= '<option value="' . $value2['id'] . '">• ' . $value2['name'] . '</option>'; $at_least_one = true; } } } if ($at_least_one) { $medals_options .= '<option value="">' . $value['name'] . '</option>'; $medals_options .= $temp_string; $at_least_one = false; $temp_string = ''; $i++; } } if ($i == 0) { trigger_error(sprintf($this->user->lang['NO_MEDALS_TO_NOMINATE'], append_sid('memberlist.php?mode=viewprofile&u=' . $user_id))); } $medals_arr = 'var medals = new Array();'; $medals_desc_arr = 'var medals_desc = new Array();'; foreach ($medals as $key => $value) { $medals_arr .= 'medals[' . $value['id'] . '] = "' . $value['image'] . '";'; $medals_desc_arr .= 'medals_desc[' . $value['id'] . '] = "' . $value['description'] . '";'; } $medals_arr .= "\n" . $medals_desc_arr . "\n"; $bbcode_status = $this->config['allow_bbcode'] ? true : false; $smilies_status = $bbcode_status && $this->config['allow_smilies'] ? true : false; $img_status = $bbcode_status ? true : false; $url_status = $bbcode_status && $this->config['allow_post_links'] ? true : false; $flash_status = $bbcode_status ? true : false; $quote_status = $bbcode_status ? true : false; display_custom_bbcodes(); $this->template->assign_vars(array('USERNAME' => $username, 'MEDALS' => $medals_options, 'JS' => $medals_arr, 'U_MEDALS_ACTION' => $this->helper->route('bb3mobi_medals_controller', array('m' => 'submit_nomination', 'u' => $user_id)), 'S_BBCODE_ALLOWED' => $bbcode_status, 'S_BBCODE_IMG' => $img_status, 'S_BBCODE_URL' => $url_status, 'S_BBCODE_FLASH' => $flash_status, 'S_BBCODE_QUOTE' => $quote_status)); page_header($this->user->lang['NOMINATE']); $this->template->set_filenames(array('body' => '@bb3mobi_medals/medalcp_nominate.html')); page_footer(); break; case 'submit_nomination': if ($this->user->data['user_id'] == ANONYMOUS || !$this->auth->acl_get('u_nominate_medals')) { trigger_error($this->user->lang['NO_GOOD_PERMS']); } $medal_id = $this->request->variable('medal', 0); if (!$medal_id) { $redirect = $this->helper->route('bb3mobi_medals_controller', array('m' => 'nominate', 'u' => $user_id)); meta_refresh(3, $redirect); trigger_error('NO_MEDAL_ID'); } include_once $phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx; $this->user->add_lang('ucp'); $message = utf8_normalize_nfc($this->request->variable('message', '', true)); if (!strlen($message)) { $return_to = $this->helper->route('bb3mobi_medals_controller', array('m' => 'nominate', 'u' => $user_id)); trigger_error(sprintf($this->user->lang['NO_MEDAL_MSG'], $return_to)); } $sql = "SELECT *\n\t\t\t\t\t\tFROM " . $this->tb_medals_awarded . "\n\t\t\t\t\t\tWHERE user_id = {$user_id} \n\t\t\t\t\t\tAND medal_id = {$medal_id}"; $result = $this->db->sql_query($sql); $row = $this->db->sql_fetchrow($result); $this->db->sql_freeresult($result); if (!$medals[$medal_id]['number'] > 1 && !empty($row)) { trigger_error(sprintf($this->user->lang['CANNOT_AWARD_MULTIPLE'], append_sid('memberlist.php?mode=viewprofile&u=' . $user_id))); } generate_text_for_storage($message, $this->uid, $this->bitfield, $this->m_flags, $this->allow_bbcode, $this->allow_urls, $this->allow_smilies); $sql_ary = array('medal_id' => $medal_id, 'user_id' => $user_id, 'awarder_id' => $this->user->data['user_id'], 'awarder_un' => $this->user->data['username'], 'awarder_color' => $this->user->data['user_colour'], 'nominated' => 1, 'nominated_reason' => $message, 'time' => time(), 'bbuid' => $this->uid, 'bitfield' => $this->bitfield); $sql = 'INSERT INTO ' . $this->tb_medals_awarded . ' ' . $this->db->sql_build_array('INSERT', $sql_ary); $this->db->sql_query($sql); $redirect = append_sid('memberlist.php?mode=viewprofile&u=' . $user_id); meta_refresh(3, $redirect); trigger_error(sprintf($this->user->lang['MEDAL_NOMINATE_GOOD'])); break; case 'award': if ($this->user->data['user_type'] != USER_FOUNDER && !$this->auth->acl_get('u_award_medals')) { trigger_error($this->user->lang['NO_GOOD_PERMS']); } if ($user_id == 0 || $user_id == ANONYMOUS) { trigger_error('NO_USER_ID'); } $sql = "SELECT *\n\t\t\t\t\t\tFROM " . $this->tb_medals_awarded . "\n\t\t\t\t\t\tWHERE user_id = {$user_id}\n\t\t\t\t\t\tORDER BY medal_id AND nominated"; $result = $this->db->sql_query($sql); $my_medals = array(); while ($row = $this->db->sql_fetchrow($result)) { if (isset($my_medals[$row['medal_id']]['count'])) { $row['count'] = $my_medals[$row['medal_id']]['count'] + '1'; } else { $row['count'] = '1'; } $my_medals[$row['medal_id']] = $row; } $this->db->sql_freeresult($result); $sql = "SELECT user_id, username, user_colour\n\t\t\t\t\tFROM " . USERS_TABLE . "\n\t\t\t\t\tWHERE user_id = {$user_id}"; $result = $this->db->sql_query($sql); $row = $this->db->sql_fetchrow($result); $this->db->sql_freeresult($result); $username = get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $row['username']); $medals_options = '<option value=""></option>'; $temp_string = ''; $no_medals = true; foreach ($cats as $key => $value) { $at_least_one = false; foreach ($medals as $key2 => $value2) { if ($value2['parent'] == $value['id']) { $can_award = false; $my_medals[$value2['id']]['count'] = isset($my_medals[$value2['id']]['count']) ? $my_medals[$value2['id']]['count'] : 0; if ($my_medals[$value2['id']]['count'] < $value2['number'] || $medal_id == $value2['id']) { $my_medals[$value2['id']]['nominated'] = isset($my_medals[$value2['id']]['nominated']) ? $my_medals[$value2['id']]['nominated'] : 0; if (isset($my_medals[$value2['id']]) && $my_medals[$value2['id']]['nominated'] == 1) { $value2['name'] .= ' ' . sprintf($this->user->lang['NOMINATED_BY'], $my_medals[$value2['id']]['awarder_un']); } else { if ($value2['nominated']) { $value2['name'] .= ' ' . $this->user->lang['NOMINATABLE']; } } if ($medal_id == $value2['id']) { $temp_string .= '<option value="' . $value2['id'] . '" selected="selected">• ' . $value2['name'] . '</option>'; $sql = "SELECT *\n\t\t\t\t\t\t\t\t\t\tFROM " . $this->tb_medals_awarded . "\n\t\t\t\t\t\t\t\t\t\t\tWHERE id = {$med_id}"; $result = $this->db->sql_query($sql); $row = $this->db->sql_fetchrow($result); $this->db->sql_freeresult($result); $message = generate_text_for_edit($row['nominated_reason'], $row['bbuid'], $this->m_flags); $medal_edit = "&med={$med_id}"; } else { $temp_string .= '<option value="' . $value2['id'] . '">• ' . $value2['name'] . '</option>'; } $at_least_one = true; } } } if ($at_least_one) { $medals_options .= '<option value="">' . $value['name'] . '</option>'; $medals_options .= $temp_string; $at_least_one = false; $temp_string = ''; $no_medals = false; } } $medals_arr = 'var medals = new Array();'; $medals_desc_arr = 'var medals_desc = new Array();'; foreach ($medals as $key => $value) { $medals_arr .= 'medals[' . $value['id'] . '] = "' . $value['image'] . '";'; $medals_desc_arr .= 'medals_desc[' . $value['id'] . '] = "' . $value['description'] . '";'; } $medals_arr .= "\n" . $medals_desc_arr . "\n"; if ($no_medals) { $medals_options = '<option value="">' . $this->user->lang['NO_MEDALS'] . '</option>'; } $bbcode_status = $this->config['allow_bbcode'] ? true : false; $smilies_status = $bbcode_status && $this->config['allow_smilies'] ? true : false; $img_status = $bbcode_status ? true : false; $url_status = $bbcode_status && $this->config['allow_post_links'] ? true : false; $flash_status = $bbcode_status ? true : false; $quote_status = $bbcode_status ? true : false; display_custom_bbcodes(); $message = isset($message['text']) ? $message['text'] : ''; $medal_action = $this->helper->route('bb3mobi_medals_controller', array('m' => 'submit', 'u' => $user_id)); $this->template->assign_vars(array('USERNAME' => $username, 'MEDALS' => $medals_options, 'JS' => $medals_arr, 'U_MEDALS_ACTION' => isset($medal_edit) ? $medal_action . $medal_edit : $medal_action, 'MESSAGE' => $message, 'S_BBCODE_ALLOWED' => $bbcode_status, 'S_BBCODE_IMG' => $img_status, 'S_BBCODE_URL' => $url_status, 'S_BBCODE_FLASH' => $flash_status, 'S_BBCODE_QUOTE' => $quote_status)); page_header($this->user->lang['AWARD_MEDAL']); $this->template->set_filenames(array('body' => '@bb3mobi_medals/medalcp_award_user.html')); page_footer(); break; case 'awarded': $sql = "SELECT user_id, username, user_colour\n\t\t\t\t\tFROM " . USERS_TABLE . "\n\t\t\t\t\tWHERE user_id = {$user_id}"; $result = $this->db->sql_query($sql); $row = $this->db->sql_fetchrow($result); $this->db->sql_freeresult($result); $username = get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $row['username']); $sql3 = "SELECT *\n\t\t\t\t\t\tFROM " . $this->tb_medals_awarded . "\n\t\t\t\t\t\tWHERE user_id = {$user_id}\n\t\t\t\t\t\t\tAND nominated <> 1"; $result3 = $this->db->sql_query($sql3); $s_medals = false; $users_medals = array(); while ($row3 = $this->db->sql_fetchrow($result3)) { $awarder_name = get_username_string('full', $row3['awarder_id'], $row3['awarder_un'], $row3['awarder_color'], $row3['awarder_un']); $nom_message = sprintf($this->user->lang['NOMINATE_MESSAGE'], $awarder_name, $medals[$row3['medal_id']]['name']); // Parse the message and subject $reason = generate_text_for_display($row3['nominated_reason'], $row3['bbuid'], $row3['bitfield'], $this->m_flags); $message = $this->user->lang['AWARDED_BY'] . ' ' . $awarder_name . ' ' . $this->user->format_date($row3['time']) . '<br \\>' . $reason; $this_cat = $cats[$medals[$row3['medal_id']]['parent']]; $users_medals[$this_cat['order_id']]['name'] = $this_cat['name']; $users_medals[$this_cat['order_id']][$medals[$row3['medal_id']]['order_id']][] = array('MEDAL_NAME' => $medals[$row3['medal_id']]['name'], 'MEDAL_IMAGE' => '<img src="' . $medals[$row3['medal_id']]['image'] . '" title="' . $medals[$row3['medal_id']]['name'] . '" alt="' . $medals[$row3['medal_id']]['name'] . '" />', 'MEDAL_REASON' => $message, 'ID' => $row3['id']); $s_medals = true; } $this->db->sql_freeresult($result3); $my_medals_arr = array(); ksort($users_medals); foreach ($users_medals as $key => $value) { ksort($value); foreach ($value as $key2 => $value2) { if ($key2 != 'name') { foreach ($value2 as $key3 => $value3) { $my_medals_arr[] = array($value3, false); } } else { $my_medals_arr[] = array($value2, true); } } } foreach ($my_medals_arr as $key => $value) { if ($value[1]) { $this->template->assign_block_vars('medals', array('MEDAL_NAME' => $value[0], 'IS_CAT' => true)); } else { $u_delete = $this->helper->route('bb3mobi_medals_controller', array('m' => 'delete', 'u' => $user_id, 'med' => $value[0]['ID'])); $this->template->assign_block_vars('medals', array('MEDAL_NAME' => $value[0]['MEDAL_NAME'], 'MEDAL_IMAGE' => $value[0]['MEDAL_IMAGE'], 'MEDAL_REASON' => $value[0]['MEDAL_REASON'], 'U_DELETE' => $u_delete, 'IS_CAT' => false)); } } $this->template->assign_vars(array('USERNAME' => $username, 'U_MEDALS_ACTION' => $this->helper->route('bb3mobi_medals_controller', array('m' => 'submit', 'u' => $user_id)))); page_header($this->user->lang['AWARDED_MEDAL_TO']); $this->template->set_filenames(array('body' => '@bb3mobi_medals/medalcp_awarded_user.html')); page_footer(); break; case 'submit': if ($this->user->data['user_type'] != USER_FOUNDER && !$this->auth->acl_get('u_award_medals')) { trigger_error($this->user->lang['NO_GOOD_PERMS']); } if (!$medal_id) { $redirect = $this->helper->route('bb3mobi_medals_controller', array('m' => 'award', 'u' => $user_id)); meta_refresh(3, $redirect); trigger_error('NO_MEDAL_ID'); } include_once $phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx; $message = utf8_normalize_nfc($this->request->variable('message', '', true)); if (!strlen($message)) { $return_to = $this->helper->route('bb3mobi_medals_controller', array('m' => 'award', 'u' => $user_id)); trigger_error(sprintf($this->user->lang['NO_MEDAL_MSG'], $return_to)); } $username = array(); if (sizeof($user_id) > 1) { foreach ($this->uid as $user_id) { // Change usernames to ids $sql = "SELECT user_id\n\t\t\t\t\t\t\tFROM " . USERS_TABLE . "\n\t\t\t\t\t\t\tWHERE username = {$this->uid}"; $result = $this->db->sql_query($sql); $row = $this->db->sql_fetchrow($result); $this->db->sql_freeresult($result); $username[] = $row['user_id']; } } else { $username[] = $user_id; } foreach ($username as $user_id) { $sql = "SELECT count(*) as count\n\t\t\t\t\t\tFROM " . $this->tb_medals_awarded . "\n\t\t\t\t\t\tWHERE medal_id = {$medal_id}\n\t\t\t\t\t\t\tAND user_id = {$user_id}\n\t\t\t\t\t\t\tAND nominated = 0"; $result = $this->db->sql_query($sql); $row = $this->db->sql_fetchrow($result); $this->db->sql_freeresult($result); if ($row['count'] >= $medals[$medal_id]['number']) { trigger_error(sprintf($this->user->lang['CANNOT_AWARD_MULTIPLE'], append_sid('memberlist.php?mode=viewprofile&u=' . $user_id))); } // Call award_medal function if (isset($med_id)) { $this->award_medal($medals, $medal_id, $user_id, $message, time(), $medals[$medal_id]['points'], $med_id); } else { $this->award_medal($medals, $medal_id, $user_id, $message, time(), $medals[$medal_id]['points']); } } $redirect = append_sid('memberlist.php?mode=viewprofile&u=' . $user_id); meta_refresh(3, $redirect); trigger_error(sprintf($this->user->lang['MEDAL_AWARD_GOOD'])); break; case 'delete': if ($this->user->data['user_type'] != USER_FOUNDER && !$this->auth->acl_get('u_award_medals')) { trigger_error($this->user->lang['NO_GOOD_PERMS']); } if (!$med_id) { trigger_error('NO_MEDAL_ID'); } if (confirm_box(true)) { if ($this->config['points_enable'] == 1) { $sql = "SELECT points\n\t\t\t\t\t\t\tFROM " . $this->tb_medals_awarded . "\n\t\t\t\t\t\t\tWHERE id = {$med_id}\n\t\t\t\t\t\t\tLIMIT 1"; $result = $this->db->sql_query($sql); $row = $this->db->sql_fetchrow($result); $this->db->sql_freeresult($result); $sql = "UPDATE " . USERS_TABLE . " \n\t\t\t\t\t\t\tSET medal_user_points = user_points - " . $row['points'] . "\n\t\t\t\t\t\t\tWHERE user_id = {$user_id}"; $this->db->sql_query($sql); } $sql = "DELETE FROM " . $this->tb_medals_awarded . "\n\t\t\t\t\t\tWHERE id = {$med_id}\n\t\t\t\t\t\tLIMIT 1"; $this->db->sql_query($sql); $redirect = $this->helper->route('bb3mobi_medals_controller', array('m' => 'awarded', 'u' => $user_id)); meta_refresh(3, $redirect); trigger_error(sprintf($this->user->lang['MEDAL_REMOVE_GOOD'])); } else { confirm_box(false, $this->user->lang['MEDAL_REMOVE_CONFIRM'], build_hidden_fields(array('action' => 'delete'))); $redirect = $this->helper->route('bb3mobi_medals_controller', array('m' => 'awarded', 'u' => $user_id)); meta_refresh(1, $redirect); trigger_error(sprintf($this->user->lang['MEDAL_REMOVE_NO'])); } break; case 'approve': if ($this->user->data['user_type'] != USER_FOUNDER && !$this->auth->acl_get('u_award_medals')) { trigger_error($this->user->lang['NO_GOOD_PERMS']); } if (!$med_id) { trigger_error('NO_MEDAL_ID'); } $sql = "SELECT count(*) as count\n\t\t\t\t\t\tFROM " . $this->tb_medals_awarded . "\n\t\t\t\t\t\tWHERE medal_id = {$medal_id}\n\t\t\t\t\t\t AND user_id = {$user_id}\n\t\t\t\t\t\t AND nominated = 0"; $result = $this->db->sql_query($sql); $row = $this->db->sql_fetchrow($result); $this->db->sql_freeresult($result); if ($row['count'] >= $medals[$medal_id]['number']) { $redirect = append_sid('memberlist.php?mode=viewprofile&u=' . $user_id); meta_refresh(3, $redirect); trigger_error(sprintf($this->user->lang['CANNOT_AWARD_MULTIPLE'])); } $sql = "SELECT *\n\t\t\t\t\t\tFROM " . $this->tb_medals_awarded . "\n\t\t\t\t\t\tWHERE id = {$med_id}"; $result = $this->db->sql_query($sql); $row = $this->db->sql_fetchrow($result); $this->db->sql_freeresult($result); $message = generate_text_for_edit($row['nominated_reason'], $row['bbuid'], $this->m_flags); $this->award_medal($medals, $row['medal_id'], $row['user_id'], $message['text'], $row['time'], $medals[$medal_id]['points'], $row['id']); $redirect = $this->helper->route('bb3mobi_medals_controller', array('m' => 'validate', 'u' => $user_id)); meta_refresh(3, $redirect); trigger_error(sprintf($this->user->lang['MEDAL_AWARD_GOOD'])); break; case 'validate': if ($this->user->data['user_type'] != USER_FOUNDER && !$this->auth->acl_get('u_award_medals')) { trigger_error($this->user->lang['NO_GOOD_PERMS']); } $sql = 'SELECT user_id, username, user_colour FROM ' . USERS_TABLE . "\n\t\t\t\t\t\tWHERE user_id = {$user_id}"; $result = $this->db->sql_query($sql); $row = $this->db->sql_fetchrow($result); $this->db->sql_freeresult($result); $username = get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $row['username']); $sql = "SELECT ma.*, m.name\n\t\t\t\t\t\tFROM " . $this->tb_medals_awarded . " as ma, " . $this->tb_medal . " as m\n\t\t\t\t\t\tWHERE ma.user_id = {$user_id}\n\t\t\t\t\t\t AND ma.medal_id = m.id\n\t\t\t\t\t\t AND ma.nominated <> 0"; $result = $this->db->sql_query($sql); $i = 0; while ($row = $this->db->sql_fetchrow($result)) { $awarder_name = get_username_string('full', $row['awarder_id'], $row['awarder_un'], $row['awarder_color'], $row['awarder_un']); $nom_message = sprintf($this->user->lang['NOMINATE_MESSAGE'], $awarder_name, $row['name']); // Parse the message and subject $message = generate_text_for_display($row['nominated_reason'], $row['bbuid'], $row['bitfield'], $this->m_flags); $message = $nom_message . $message; $message = censor_text($message); $message = str_replace("\n", '<br />', $message); $this->uid = $row['bbuid']; $this->bitfield = $row['bitfield']; $u_delete = $this->helper->route('bb3mobi_medals_controller', array('m' => 'delete', 'med' => $row['id'], 'u' => $user_id)); $u_approve = $this->helper->route('bb3mobi_medals_controller', array('m' => 'approve', 'med' => $row['id'], 'mid' => $row['medal_id'], 'u' => $user_id)); $u_m_edit = $this->helper->route('bb3mobi_medals_controller', array('m' => 'award', 'med' => $row['id'], 'mid' => $row['medal_id'], 'u' => $user_id)); $this->template->assign_block_vars('nominations', array('USERNAME' => $awarder_name, 'REASON' => $message, 'U_DELETE' => $u_delete, 'U_APPROVE' => $u_approve, 'U_MEDAL_EDIT' => $u_m_edit)); $i++; } $this->db->sql_freeresult($result); $this->template->assign_vars(array('U_MEDALS_ACTION' => $this->helper->route('bb3mobi_medals_controller', array('m' => 'submit', 'u' => $user_id)), 'NOMINATE_MEDAL' => sprintf($this->user->lang['NOMINATE_USER_LOG'], $username), 'S_ROW_COUNT' => $i)); page_header($this->user->lang['NOMINATE_MEDAL']); $this->template->set_filenames(array('body' => '@bb3mobi_medals/medalcp_nominate_user.html')); page_footer(); break; case 'mnd': if ($this->user->data['user_type'] != USER_FOUNDER && !$this->auth->acl_get('u_award_medals')) { trigger_error($this->user->lang['NO_GOOD_PERMS']); } if (!$med_id) { trigger_error('NO_MEDAL_ID'); } $sql = "DELETE FROM " . $this->tb_medals_awarded . "\n\t\t\t\t\t\tWHERE medal_id = {$med_id}\n\t\t\t\t\t\t\tAND nominated = 1"; $this->db->sql_query($sql); trigger_error(sprintf($this->user->lang['NOMINATIONS_REMOVE_GOOD'], $this->helper->route('bb3mobi_medals_controller'))); // No break; // No break; case 'mn': if ($this->user->data['user_type'] != USER_FOUNDER && !$this->auth->acl_get('u_award_medals')) { trigger_error($this->user->lang['NO_GOOD_PERMS']); } $sql = "SELECT u.username, u.user_colour, ma.*\n\t\t\t\t\t\tFROM " . USERS_TABLE . " u, " . $this->tb_medals_awarded . " ma\n\t\t\t\t\t\tWHERE u.user_id = ma.user_id\n\t\t\t\t\t\t\tAND ma.nominated = 1\n\t\t\t\t\t\t\tAND ma.medal_id = {$med_id}\n\t\t\t\t\t\tORDER BY u.username_clean"; $result = $this->db->sql_query($sql); $users_medals = array(); $i = 1; while ($row = $this->db->sql_fetchrow($result)) { $awarder_name = get_username_string('full', $row['awarder_id'], $row['awarder_un'], $row['awarder_color'], $row['awarder_un']); $users_medals[$i] = array('id' => $row['id'], 'username' => $row['username'], 'user_colour' => $row['user_colour'], 'user_id' => $row['user_id'], 'reason' => $this->user->lang['MEDAL_NOM_BY'] . ' : ' . $awarder_name . '<br />' . $row['nominated_reason'], 'bbuid' => $row['bbuid'], 'bitfield' => $row['bitfield']); $i++; } $this->db->sql_freeresult($result); foreach ($users_medals as $key => $value) { $awarded = get_username_string('full', $value['user_id'], $value['username'], $value['user_colour']); $this->template->assign_block_vars('nominatedrow', array('NOMINATED' => $awarded, 'REASON' => generate_text_for_display($value['reason'], $value['bbuid'], $value['bitfield'], $this->m_flags), 'U_MCP' => "?m=approve&med={$value['id']}&mid={$med_id}&u={$value['user_id']}", 'U_USER_DELETE' => "?m=delete&med={$value['id']}&u={$value['user_id']}")); $nominated_users[$value['user_id']]['user'] = $awarded; $nominated_users[$value['user_id']]['count'] = isset($nominated_users[$value['user_id']]['count']) ? $nominated_users[$value['user_id']]['count'] + '1' : 1; } if (isset($nominated_users)) { $i = 0; $nom_users = ''; foreach ($nominated_users as $key => $value) { if ($i > 0) { $nom_users .= ", "; } $nom_users .= "{$value['user']} ({$value['count']})"; $i++; } } $this->template->assign_vars(array('S_MEDAL_NOM' => true, 'MEDAL_NAME' => $medals[$med_id]['name'], 'MEDAL_DESC' => $medals[$med_id]['description'], 'MEDAL_IMG' => '<img src="' . $medals[$med_id]['image'] . '">', 'MEDAL_AWARDED' => isset($awarded_users) ? $awarded_users : $this->user->lang['NO_MEDALS_ISSUED'], 'NOMINATED_USERS' => isset($nom_users) ? $nom_users : $this->user->lang['NO_MEDALS_NOMINATED'], 'S_DELETE_ALL' => isset($nom_users) ? true : false, 'U_MEDALS_ACTION' => "?m={$mode}d&med={$med_id}", 'U_FIND_USERNAME' => append_sid($phpbb_root_path . 'memberlist.' . $phpEx, 'mode=searchuser&form=post&field=add'))); page_header($this->user->lang['MEDALS_VIEW']); $this->template->set_filenames(array('body' => '@bb3mobi_medals/medals.html')); page_footer(); break; case 'ma': if ($this->user->data['user_type'] != USER_FOUNDER && !$this->auth->acl_get('u_award_medals')) { trigger_error($this->user->lang['NO_GOOD_PERMS']); } if ($submit) { if (!$med_id) { trigger_error('NO_MEDAL_ID'); } $message = utf8_normalize_nfc($this->request->variable('message', '', true)); if (!strlen($message)) { $return_to = $this->helper->route('bb3mobi_medals_controller', array('mode' => $mode, 'med' => $med_id)); trigger_error(sprintf($this->user->lang['NO_MEDAL_MSG'], $return_to)); } $usernames = explode("\n", $usernames); foreach ($usernames as $value) { $username[] = $this->db->sql_escape(utf8_clean_string($value)); } $award_user = $not_award_user = $awarded_user = $no_such_user = array(); // Change usernames to ids $sql = 'SELECT user_id, username, username_clean FROM ' . USERS_TABLE . ' WHERE ' . $this->db->sql_in_set('username_clean', $username); $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { $sql = "SELECT count(*) as number\n\t\t\t\t\t\t\t\tFROM " . $this->tb_medals_awarded . "\n\t\t\t\t\t\t\t\tWHERE medal_id = {$med_id}\n\t\t\t\t\t\t\t\t\tAND user_id = {$row['user_id']}"; $result2 = $this->db->sql_query($sql); $row2 = $this->db->sql_fetchrow($result2); $this->db->sql_freeresult($result2); if ($row2['number'] < $medals[$med_id]['number']) { $award_user[] = $row['user_id']; $awarded_user[] = $row['username_clean']; } } $this->db->sql_freeresult($result); $not_award_user = array_diff($username, $awarded_user); // Call award_medal function $time = time(); if (sizeof($award_user)) { foreach ($award_user as $uid) { $this->award_medal($medals, $med_id, $uid, $message, $time, $medals[$med_id]['points']); } } if (sizeof($not_award_user)) { $redirect = $this->helper->route('bb3mobi_medals_controller', array('mode' => $mode, 'med' => $med_id)); meta_refresh(3, $redirect); trigger_error(sprintf($this->user->lang['NO_USER_SELECTED'], implode(", ", $not_award_user))); } else { $redirect = $this->helper->route('bb3mobi_medals_controller', array('mode' => $mode, 'med' => $med_id)); meta_refresh(3, $redirect); trigger_error($this->user->lang['MEDAL_AWARD_GOOD']); } } $sql = "SELECT u.username, u.user_colour, ma.user_id\n\t\t\t\t\t\tFROM " . USERS_TABLE . " u, " . $this->tb_medals_awarded . " ma\n\t\t\t\t\t\tWHERE u.user_id = ma.user_id\n\t\t\t\t\t\t\tAND ma.nominated = 0\n\t\t\t\t\t\t\tAND ma.medal_id = {$med_id}\n\t\t\t\t\t\tGROUP BY ma.user_id, u.username, ma.medal_id\n\t\t\t\t\t\tORDER BY u.username"; $result = $this->db->sql_query($sql); $users_medals = array(); $i = 1; while ($row = $this->db->sql_fetchrow($result)) { $users_medals[$i] = array('username' => $row['username'], 'user_colour' => $row['user_colour'], 'user_id' => $row['user_id']); $i++; } $this->db->sql_freeresult($result); foreach ($users_medals as $key => $value) { $awarded = get_username_string('full', $value['user_id'], $value['username'], $value['user_colour']); $awarded_users = isset($awarded_users) ? $awarded_users . ', ' . $awarded : $awarded; } $this->template->assign_vars(array('S_MEDAL_AWARD' => true, 'MEDAL_NAME' => $medals[$med_id]['name'], 'MEDAL_DESC' => $medals[$med_id]['description'], 'MEDAL_IMG' => '<img src="' . $medals[$med_id]['image'] . '">', 'MEDAL_AWARDED' => isset($awarded_users) ? $awarded_users : $this->user->lang['NO_MEDALS_ISSUED'], 'U_MEDALS_ACTION' => "?m={$mode}&med={$med_id}", 'U_FIND_USERNAME' => append_sid($phpbb_root_path . 'memberlist.' . $phpEx, 'mode=searchuser&form=post&field=add'))); page_header($this->user->lang['MEDALS_VIEW']); $this->template->set_filenames(array('body' => '@bb3mobi_medals/medals.html')); page_footer(); break; default: $sql = "SELECT u.username, u.user_colour, ma.user_id, ma.medal_id, ma.nominated\n\t\t\t\t\t\tFROM " . USERS_TABLE . " u, " . $this->tb_medals_awarded . " ma\n\t\t\t\t\t\tWHERE u.user_id = ma.user_id\n\t\t\t\t\t\tGROUP BY ma.nominated, ma.user_id, u.username, ma.medal_id\n\t\t\t\t\t\tORDER BY u.username_clean"; $result = $this->db->sql_query($sql); $users_medals = array(); $i = 1; while ($row = $this->db->sql_fetchrow($result)) { $users_medals[$i] = array('username' => $row['username'], 'user_colour' => $row['user_colour'], 'medal_id' => $row['medal_id'], 'user_id' => $row['user_id'], 'nominated' => $row['nominated']); $i++; } $this->db->sql_freeresult($result); $at_least_one_awarded = false; foreach ($cats as $key => $value) { $at_least_one = true; foreach ($medals as $key2 => $value2) { if ($value2['parent'] == $value['id']) { if ($at_least_one) { $at_least_one_awarded = true; $this->template->assign_block_vars('medalrow', array('IS_CAT' => 1, 'MEDAL_CAT' => $value['name'])); $at_least_one = false; } $awarded_users = ''; $nominations = 0; foreach ($users_medals as $key3 => $value3) { if ($value3['medal_id'] == $value2['id'] && $value3['nominated'] == 0) { $awarded = get_username_string('full', $value3['user_id'], $value3['username'], $value3['user_colour']); $awarded_users = $awarded_users ? $awarded_users . ', ' . $awarded : $awarded; } else { if ($value3['medal_id'] == $value2['id'] && $value3['nominated'] == 1) { $nominations++; } } } $u_medal_award = $this->helper->route('bb3mobi_medals_controller', array('m' => 'ma', 'med' => $value2['id'])); $u_medal_ncp = $this->helper->route('bb3mobi_medals_controller', array('m' => 'mn', 'med' => $value2['id'])); $this->template->assign_block_vars('medalrow', array('MEDAL_NAME' => $value2['name'], 'U_MEDAL_AWARD_PANEL' => $u_medal_award, 'MEDAL_IMG' => '<img src="' . $value2['image'] . '">', 'MEDAL_DESC' => $value2['description'], 'MEDAL_AWARDED' => $awarded_users ? $awarded_users : $this->user->lang['NO_MEDALS_ISSUED'], 'NOMINATIONS' => $nominations > 0 ? true : false, 'U_MEDAL_NCP' => $u_medal_ncp, 'MEDAL_DESC' => $value2['description'])); } } } $this->template->assign_vars(array('S_MEDAL_VIEW' => true, 'NO_MEDAL' => $at_least_one_awarded ? 0 : 1)); page_header($this->user->lang['MEDALS_VIEW']); $this->template->set_filenames(array('body' => '@bb3mobi_medals/medals.html')); page_footer(); break; } }
/** * Manage events * * @param mixed $value Value of input * @param string $key Key name * @param int $module_id Module ID * * @return null */ public function manage_events($value, $key, $module_id) { $action = $this->request->variable('action', ''); $action = $this->request->is_set_post('add') ? 'add' : $action; $action = $this->request->is_set_post('save') ? 'save' : $action; $link_id = $this->request->variable('id', 99999999); // 0 will trigger unwanted behavior, therefore we set a number we should never reach $portal_config = obtain_portal_config(); $events = strlen($portal_config['board3_calendar_events_' . $module_id]) >= 1 ? json_decode($portal_config['board3_calendar_events_' . $module_id], true) : array(); // append_sid() adds adm/ already, no need to add it here $u_action = append_sid('index.' . $this->php_ext, 'i=-board3-portal-acp-portal_module&mode=config&module_id=' . $module_id); switch ($action) { // Save changes case 'save': if (!check_form_key('acp_portal')) { trigger_error($this->user->lang['FORM_INVALID'] . adm_back_link($u_action), E_USER_WARNING); } $event_title = $this->request->variable('event_title', '', true); $event_desc = $this->request->variable('event_desc', '', true); $event_start_date = trim($this->request->variable('event_start_date', '')); $event_end_date = trim($this->request->variable('event_end_date', '')); $event_all_day = $this->request->variable('event_all_day', false); // default to false $event_url = $this->request->variable('event_url', ''); $event_permission = $this->request->variable('permission-setting-calendar', array(0 => '')); $groups_ary = array(); // Now get the unix timestamps out of the entered information $start_time = $this->date_to_time($event_start_date); $end_time = !$event_all_day ? $this->date_to_time($event_end_date) : ''; if (!$start_time) { trigger_error($this->user->lang['ACP_PORTAL_CALENDAR_START_INCORRECT'] . adm_back_link($u_action), E_USER_WARNING); } else { if (!$event_all_day && !$end_time) { trigger_error($this->user->lang['ACP_PORTAL_CALENDAR_END_INCORRECT'] . adm_back_link($u_action), E_USER_WARNING); } } if ($end_time <= time() && !($start_time + self::TIME_DAY >= time() && $event_all_day)) { trigger_error($this->user->lang['ACP_PORTAL_CALENDAR_EVENT_PAST'] . adm_back_link($u_action), E_USER_WARNING); } else { if ($end_time < $start_time && !$event_all_day) { trigger_error($this->user->lang['ACP_PORTAL_CALENDAR_EVENT_START_FIRST'] . adm_back_link($u_action), E_USER_WARNING); } } // get groups and check if the selected groups actually exist $sql = 'SELECT group_id FROM ' . GROUPS_TABLE . ' ORDER BY group_id ASC'; $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { $groups_ary[] = $row['group_id']; } $this->db->sql_freeresult($result); $event_permission = array_intersect($event_permission, $groups_ary); $event_permission = implode(',', $event_permission); // Check for errors if (!$event_title) { trigger_error($this->user->lang['NO_EVENT_TITLE'] . adm_back_link($u_action), E_USER_WARNING); } // overwrite already existing events and make sure we don't try to save an event outside of the normal array size of $events if (isset($link_id) && $link_id < sizeof($events)) { $message = $this->user->lang['EVENT_UPDATED']; $events[$link_id] = array('title' => $event_title, 'desc' => $event_desc, 'start_time' => $start_time, 'end_time' => $end_time, 'all_day' => $event_all_day, 'permission' => $event_permission, 'url' => htmlspecialchars_decode($event_url)); $this->log->add('admin', $this->user->data['user_id'], $this->user->data['user_ip'], 'LOG_PORTAL_EVENT_UPDATED', false, array($event_title)); } else { $message = $this->user->lang['EVENT_ADDED']; $events[] = array('title' => $event_title, 'desc' => $event_desc, 'start_time' => $start_time, 'end_time' => $end_time, 'all_day' => $event_all_day, 'permission' => $event_permission, 'url' => $event_url); $this->log->add('admin', $this->user->data['user_id'], $this->user->data['user_ip'], 'LOG_PORTAL_EVENT_ADDED', false, array($event_title)); } $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); $board3_events_array = json_encode($events); set_portal_config('board3_calendar_events_' . $module_id, $board3_events_array); trigger_error($message . adm_back_link($u_action)); break; // Delete link // Delete link case 'delete': if (!isset($link_id) && $link_id >= sizeof($events)) { trigger_error($this->user->lang['NO_EVENT'] . adm_back_link($u_action), E_USER_WARNING); } if (confirm_box(true)) { $cur_event_title = $events[$link_id]['title']; // delete the selected link and reset the array numbering afterwards array_splice($events, $link_id, 1); $events = array_merge($events); $board3_events_array = json_encode($events); set_portal_config('board3_calendar_events_' . $module_id, $board3_events_array); $this->log->add('admin', $this->user->data['user_id'], $this->user->data['user_ip'], 'LOG_PORTAL_EVENT_REMOVED', false, array($cur_event_title)); } else { confirm_box(false, $this->user->lang['CONFIRM_OPERATION'], build_hidden_fields(array('link_id' => $link_id, 'action' => 'delete'))); } break; // Edit or add menu item // Edit or add menu item case 'edit': case 'add': $event_all_day = isset($events[$link_id]['all_day']) && $events[$link_id]['all_day'] == true ? true : false; $date_format = str_replace(array('D '), '', $this->user->data['user_dateformat']); $this->template->assign_vars(array('EVENT_TITLE' => isset($events[$link_id]['title']) && $action != 'add' ? $events[$link_id]['title'] : '', 'EVENT_DESC' => isset($events[$link_id]['desc']) && $action != 'add' ? $events[$link_id]['desc'] : '', 'EVENT_START_DATE' => $action != 'add' ? $this->user->format_date($events[$link_id]['start_time'], $date_format) : '', 'EVENT_END_DATE' => $action != 'add' && !$event_all_day ? $this->user->format_date($events[$link_id]['end_time'], $date_format) : '', 'EVENT_ALL_DAY' => isset($events[$link_id]['all_day']) && $events[$link_id]['all_day'] == true ? true : false, 'EVENT_URL' => isset($events[$link_id]['url']) && $action != 'add' ? $events[$link_id]['url'] : '', 'B3P_U_ACTION' => $u_action . '&id=' . $link_id, 'S_EDIT' => true)); $groups_ary = isset($events[$link_id]['permission']) ? explode(',', $events[$link_id]['permission']) : array(); // get group info from database and assign the block vars $sql = 'SELECT group_id, group_name FROM ' . GROUPS_TABLE . ' ORDER BY group_id ASC'; $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { $this->template->assign_block_vars('permission_setting_calendar', array('SELECTED' => in_array($row['group_id'], $groups_ary) ? true : false, 'GROUP_NAME' => isset($this->user->lang['G_' . $row['group_name']]) ? $this->user->lang['G_' . $row['group_name']] : $row['group_name'], 'GROUP_ID' => $row['group_id'])); } $this->db->sql_freeresult($result); return; } for ($i = 0; $i < sizeof($events); $i++) { $event_all_day = $events[$i]['all_day'] == true ? true : false; $this->template->assign_block_vars('events', array('EVENT_TITLE' => $action != 'add' ? isset($this->user->lang[$events[$i]['title']]) ? $this->user->lang[$events[$i]['title']] : $events[$i]['title'] : '', 'EVENT_DESC' => $action != 'add' ? $events[$i]['desc'] : '', 'EVENT_START' => $action != 'add' ? $this->user->format_date($events[$i]['start_time']) : '', 'EVENT_END' => $action != 'add' && !$event_all_day && !empty($end_time_format) ? $this->user->format_date($events[$i]['end_time']) : '', 'EVENT_URL' => $action != 'add' && isset($events[$i]['url']) && !empty($events[$i]['url']) ? $this->validate_url($events[$i]['url']) : '', 'EVENT_URL_RAW' => $action != 'add' && isset($events[$i]['url']) && !empty($events[$i]['url']) ? $events[$i]['url'] : '', 'U_EDIT' => $u_action . '&action=edit&id=' . $i, 'U_DELETE' => $u_action . '&action=delete&id=' . $i, 'EVENT_ALL_DAY' => $event_all_day)); } }
/** * Bind the values of the request to the form * * @param \phpbb\request\request_interface $request * @return null */ public function bind(\phpbb\request\request_interface $request) { $this->cc_sender = $request->is_set_post('cc_sender'); $this->body = $request->variable('message', '', true); }