protected function set_personal_settings() { if ($this->request->is_set_post('submit')) { $gallery_settings = array('watch_own' => $this->request->variable('watch_own', false), 'watch_com' => $this->request->variable('watch_com', false), 'user_allow_comments' => $this->request->variable('allow_comments', false)); $additional_settings = array(); /** * Event set personal settings * * @event phpbbgallery.core.ucp.set_settings_submit * @var array additional_settings array of additional settings * @since 1.2.0 */ $vars = array('additional_settings'); extract($this->dispatcher->trigger_event('phpbbgallery.core.ucp.set_settings_submit', compact($vars))); $gallery_settings = array_merge($gallery_settings, $additional_settings); if (!$this->config['phpbb_gallery_allow_comments'] || !$this->config['phpbb_gallery_comment_user_control']) { unset($gallery_settings['user_allow_comments']); } $this->gallery_user->set_user_id($this->user->data['user_id']); $this->gallery_user->update_data($gallery_settings); meta_refresh(3, $this->u_action); trigger_error($this->user->lang['WATCH_CHANGED'] . '<br /><br />' . sprintf($this->user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>')); } /** * Event no submit personal settings * * @event phpbbgallery.core.ucp.set_settings_nosubmit * @since 1.2.0 */ $this->dispatcher->dispatch('phpbbgallery.core.ucp.set_settings_nosubmit'); $this->template->assign_vars(array('S_PERSONAL_SETTINGS' => true, 'S_UCP_ACTION' => $this->u_action, 'L_TITLE' => $this->user->lang['UCP_GALLERY_SETTINGS'], 'L_TITLE_EXPLAIN' => $this->user->lang['WATCH_NOTE'], 'S_WATCH_OWN' => $this->gallery_user->get_data('watch_own'), 'S_WATCH_COM' => $this->gallery_user->get_data('watch_com'), 'S_ALLOW_COMMENTS' => $this->gallery_user->get_data('user_allow_comments'), 'S_COMMENTS_ENABLED' => $this->config['phpbb_gallery_allow_comments'] && $this->config['phpbb_gallery_comment_user_control'])); }
/** * Generates all the data in the template to show the topics list. * * @param array $topics the topics to display */ private function display_topics($topics) { include_once $this->phpbb_root_path . 'includes/functions_display.' . $this->php_ext; $pagination = $this->pagination; foreach ($topics as $t) { $topic = new topic($t, $this->user, $this->auth, $this->content_visibility, $this->phpbb_root_path, $this->php_ext); // Send vars to template $topic_row = array('FORUM_ID' => $topic->forum_id(), 'TOPIC_ID' => $topic->topic_id(), 'TOPIC_AUTHOR' => $topic->author('username'), 'TOPIC_AUTHOR_COLOUR' => $topic->author('colour'), 'TOPIC_AUTHOR_FULL' => $topic->author('full'), 'FIRST_POST_TIME' => $topic->topic_time(), 'LAST_POST_SUBJECT' => $topic->last_post_subject(), 'LAST_POST_TIME' => $topic->last_post_time(), 'LAST_VIEW_TIME' => $topic->last_view_time(), 'LAST_POST_AUTHOR' => $topic->last_author('username'), 'LAST_POST_AUTHOR_COLOUR' => $topic->last_author('colour'), 'LAST_POST_AUTHOR_FULL' => $topic->last_author('full'), 'REPLIES' => $topic->replies(), 'VIEWS' => $topic->views(), 'TOPIC_TITLE' => $topic->topic_title(), 'TOPIC_TYPE' => $topic->topic_type(), 'FORUM_NAME' => $topic->forum_name(), 'TOPIC_IMG_STYLE' => $topic->img_style(), 'TOPIC_FOLDER_IMG' => $topic->folder_img(), 'TOPIC_FOLDER_IMG_ALT' => $topic->folder_img_alt(), 'TOPIC_ICON_IMG' => '', 'TOPIC_ICON_IMG_WIDTH' => '', 'TOPIC_ICON_IMG_HEIGHT' => '', 'ATTACH_ICON_IMG' => $topic->attach_icon_img(), 'UNAPPROVED_IMG' => $topic->unapproved_img(), 'S_TOPIC_TYPE' => $topic->topic_type(), 'S_USER_POSTED' => $topic->user_posted(), 'S_UNREAD_TOPIC' => $topic->unread_topic(), 'S_TOPIC_REPORTED' => $topic->topic_reported(), 'S_TOPIC_UNAPPROVED' => $topic->topic_unapproved(), 'S_POSTS_UNAPPROVED' => $topic->posts_unapproved(), 'S_TOPIC_DELETED' => $topic->topic_deleted(), 'S_HAS_POLL' => $topic->has_poll(), 'S_POST_ANNOUNCE' => $topic->post_announce(), 'S_POST_GLOBAL' => $topic->post_global(), 'S_POST_STICKY' => $topic->post_sticky(), 'S_TOPIC_LOCKED' => $topic->locked(), 'S_TOPIC_MOVED' => $topic->moved(), 'U_NEWEST_POST' => $topic->newest_post_url(), 'U_LAST_POST' => $topic->last_post_url(), 'U_LAST_POST_AUTHOR' => $topic->last_post_author(), 'U_TOPIC_AUTHOR' => $topic->topic_author(), 'U_VIEW_TOPIC' => $topic->view_topic_url(), 'U_MCP_REPORT' => $topic->mcp_report(), 'U_MCP_QUEUE' => $topic->u_mcp_queue(), 'S_TOPIC_TYPE_SWITCH' => $topic->topic_type_switch()); // create row for event so it is simmilar to the core.viewforum_modify_topicrow $row = $t; /** * Modify the topic data before it is assigned to the template * * @event robertheim.topictags.viewforum_modify_topicrow * @var array row Array with topic data * @var array topic_row Template array with topic data * @since 0.0.13-b1 */ $vars = array('row', 'topic_row'); extract($this->phpbb_dispatcher->trigger_event('robertheim.topictags.viewforum_modify_topicrow', compact($vars))); $this->template->assign_block_vars('topicrow', $topic_row); // mini pagination of posts in topic-rowss $pagination->generate_template_pagination($topic->view_topic_url(), 'topicrow.pagination', 'start', $topic->replies() + 1, $this->config['posts_per_page'], 1, true, true); } // foreach }
/** * Create topic/post visibility SQL for all forums on the board * * Note: Read permissions are not checked. Forums without read permissions * should be in $exclude_forum_ids * * @param $mode string Either "topic" or "post" * @param $exclude_forum_ids array Array of forum ids which are excluded * @param $table_alias string Table alias to prefix in SQL queries * @return string The appropriate combination SQL logic for topic/post_visibility */ public function get_global_visibility_sql($mode, $exclude_forum_ids = array(), $table_alias = '') { $where_sqls = array(); $approve_forums = array_diff(array_keys($this->auth->acl_getf('m_approve', true)), $exclude_forum_ids); $visibility_sql_overwrite = null; /** * Allow changing the result of calling get_global_visibility_sql * * @event core.phpbb_content_visibility_get_global_visibility_before * @var array where_sqls The action the user tried to execute * @var string mode Either "topic" or "post" depending on the query this is being used in * @var array forum_ids Array of forum ids which the posts/topics are limited to * @var string table_alias Table alias to prefix in SQL queries * @var array approve_forums Array of forums where the user has m_approve permissions * @var string visibility_sql_overwrite Forces the function to return an implosion of where_sqls (joined by "OR") * @since 3.1.3-RC1 */ $vars = array('where_sqls', 'mode', 'forum_ids', 'table_alias', 'approve_forums', 'visibility_sql_overwrite'); extract($this->phpbb_dispatcher->trigger_event('core.phpbb_content_visibility_get_global_visibility_before', compact($vars))); if ($visibility_sql_overwrite) { return $visibility_sql_overwrite; } if (sizeof($exclude_forum_ids)) { $where_sqls[] = '(' . $this->db->sql_in_set($table_alias . 'forum_id', $exclude_forum_ids, true) . ' AND ' . $table_alias . $mode . '_visibility = ' . ITEM_APPROVED . ')'; } else { $where_sqls[] = $table_alias . $mode . '_visibility = ' . ITEM_APPROVED; } if (sizeof($approve_forums)) { $where_sqls[] = $this->db->sql_in_set($table_alias . 'forum_id', $approve_forums); return '(' . implode(' OR ', $where_sqls) . ')'; } // There is only one element, so we just return that one return $where_sqls[0]; }
/** * Add a notification * * @param string|array $notification_type_name Type identifier or array of item types (only acceptable if the $data is identical for the specified types) * Note: If you send an array of types, any user who could receive multiple notifications from this single item will only receive * a single notification. If they MUST receive multiple notifications, call this function multiple times instead of sending an array * @param array $data Data specific for this type that will be inserted * @param array $options Optional options to control what notifications are loaded * ignore_users array of data to specify which users should not receive certain types of notifications * @return array Information about what users were notified and how they were notified */ public function add_notifications($notification_type_name, $data, array $options = array()) { $options = array_merge(array('ignore_users' => array()), $options); if (is_array($notification_type_name)) { $notified_users = array(); $temp_options = $options; foreach ($notification_type_name as $type) { $temp_options['ignore_users'] = $options['ignore_users'] + $notified_users; $notified_users += $this->add_notifications($type, $data, $temp_options); } return $notified_users; } $item_id = $this->get_item_type_class($notification_type_name)->get_item_id($data); // find out which users want to receive this type of notification $notify_users = $this->get_item_type_class($notification_type_name)->find_users_for_notification($data, $options); /** * Allow filtering the notify_users array for a notification that is about to be sent. * Here, $notify_users is already filtered by f_read and the ignored list included in the options variable * * @event core.notification_manager_add_notifications * @var string notification_type_name The forum id from where the topic belongs * @var array data Data specific for the notification_type_name used will be inserted * @var array notify_users The array of userid that are going to be notified for this notification. Set to array() to cancel. * @var array options The options that were used when this method was called (read only) * * @since 3.1.3-RC1 */ $vars = array('notification_type_name', 'data', 'notify_users', 'options'); extract($this->phpbb_dispatcher->trigger_event('core.notification_manager_add_notifications', compact($vars))); $this->add_notifications_for_users($notification_type_name, $data, $notify_users); return $notify_users; }
/** * Delete attachments from filesystem */ protected function remove_from_filesystem() { $space_removed = $files_removed = 0; foreach ($this->physical as $file_ary) { if ($this->unlink_attachment($file_ary['filename'], 'file', true) && !$file_ary['is_orphan']) { // Only non-orphaned files count to the file size $space_removed += $file_ary['filesize']; $files_removed++; } if ($file_ary['thumbnail']) { $this->unlink_attachment($file_ary['filename'], 'thumbnail', true); } } /** * Perform additional actions after attachment(s) deletion from the filesystem * * @event core.delete_attachments_from_filesystem_after * @var string mode Variable containing attachments deletion mode, can be: post|message|topic|attach|user * @var mixed ids Array or comma separated list of ids corresponding to the mode * @var bool resync Flag indicating if posts/messages/topics should be synchronized * @var string sql_id The field name to collect/delete data for depending on the mode * @var array post_ids Array with post ids for deleted attachment(s) * @var array topic_ids Array with topic ids for deleted attachment(s) * @var array message_ids Array with private message ids for deleted attachment(s) * @var array physical Array with deleted attachment(s) physical file(s) data * @var int num_deleted The number of deleted attachment(s) from the database * @var int space_removed The size of deleted files(s) from the filesystem * @var int files_removed The number of deleted file(s) from the filesystem * @since 3.1.7-RC1 */ $vars = array('mode', 'ids', 'resync', 'sql_id', 'post_ids', 'topic_ids', 'message_ids', 'physical', 'num_deleted', 'space_removed', 'files_removed'); extract($this->dispatcher->trigger_event('core.delete_attachments_from_filesystem_after', compact($vars))); if ($space_removed || $files_removed) { $this->config->increment('upload_dir_size', $space_removed * -1, false); $this->config->increment('num_files', $files_removed * -1, false); } }
/** * Add a new faq question * * @param string $question Question or language key with the question of the block * @param string $answer Answer or language key with the answer of the block */ public function add_question($question, $answer) { /** * You can use this event to add a question before the current one. * * @event core.help_manager_add_question_before * @var string question Language key of the question * @var string answer Language key of the answer * @since 3.2.0-a1 */ $vars = array('question', 'answer'); extract($this->dispatcher->trigger_event('core.help_manager_add_question_before', compact($vars))); $this->template->assign_block_vars('faq_block.faq_row', array('FAQ_QUESTION' => $this->language->lang($question), 'FAQ_ANSWER' => $this->language->lang($answer))); /** * You can use this event to add a question after the current one. * * @event core.help_manager_add_question_after * @var string question Language key of the question * @var string answer Language key of the answer * @since 3.2.0-a1 */ $vars = array('question', 'answer'); extract($this->dispatcher->trigger_event('core.help_manager_add_question_after', compact($vars))); }
/** * Upload Attachment - filedata is generated here * Uses upload class * * @param string $form_name The form name of the file upload input * @param int $forum_id The id of the forum * @param bool $local Whether the file is local or not * @param string $local_storage The path to the local file * @param bool $is_message Whether it is a PM or not * @param array $local_filedata An file data object created for the local file * * @return array File data array */ public function upload($form_name, $forum_id, $local = false, $local_storage = '', $is_message = false, $local_filedata = array()) { $this->init_files_upload($forum_id, $is_message); $this->file_data['post_attach'] = $local || $this->files_upload->is_valid($form_name); if (!$this->file_data['post_attach']) { $this->file_data['error'][] = $this->language->lang('NO_UPLOAD_FORM_FOUND'); return $this->file_data; } $this->file = $local ? $this->files_upload->handle_upload('files.types.local', $local_storage, $local_filedata) : $this->files_upload->handle_upload('files.types.form', $form_name); if ($this->file->init_error()) { $this->file_data['post_attach'] = false; return $this->file_data; } // Whether the uploaded file is in the image category $is_image = isset($this->extensions[$this->file->get('extension')]['display_cat']) ? $this->extensions[$this->file->get('extension')]['display_cat'] == ATTACHMENT_CATEGORY_IMAGE : false; if (!$this->auth->acl_get('a_') && !$this->auth->acl_get('m_', $forum_id)) { // Check Image Size, if it is an image if ($is_image) { $this->file->upload->set_allowed_dimensions(0, 0, $this->config['img_max_width'], $this->config['img_max_height']); } // Admins and mods are allowed to exceed the allowed filesize if (!empty($this->extensions[$this->file->get('extension')]['max_filesize'])) { $allowed_filesize = $this->extensions[$this->file->get('extension')]['max_filesize']; } else { $allowed_filesize = $is_message ? $this->config['max_filesize_pm'] : $this->config['max_filesize']; } $this->file->upload->set_max_filesize($allowed_filesize); } $this->file->clean_filename('unique', $this->user->data['user_id'] . '_'); // Are we uploading an image *and* this image being within the image category? // Only then perform additional image checks. $this->file->move_file($this->config['upload_path'], false, !$is_image); // Do we have to create a thumbnail? $this->file_data['thumbnail'] = $is_image && $this->config['img_create_thumbnail'] ? 1 : 0; // Make sure the image category only holds valid images... $this->check_image($is_image); if (sizeof($this->file->error)) { $this->file->remove(); $this->file_data['error'] = array_merge($this->file_data['error'], $this->file->error); $this->file_data['post_attach'] = false; return $this->file_data; } $this->fill_file_data(); $filedata = $this->file_data; /** * Event to modify uploaded file before submit to the post * * @event core.modify_uploaded_file * @var array filedata Array containing uploaded file data * @var bool is_image Flag indicating if the file is an image * @since 3.1.0-RC3 */ $vars = array('filedata', 'is_image'); extract($this->phpbb_dispatcher->trigger_event('core.modify_uploaded_file', compact($vars))); $this->file_data = $filedata; unset($filedata); // Check for attachment quota and free space if (!$this->check_attach_quota() || !$this->check_disk_space()) { return $this->file_data; } // Create Thumbnail $this->create_thumbnail(); return $this->file_data; }