Esempio n. 1
0
 public function display($tpl_block = 'revisions', $show_queue = false, $all_versions = false)
 {
     $ordered_phpbb_versions = versions::order_phpbb_version_list_from_db($this->cache, $this->phpbb_versions, $all_versions);
     // Get rid of the day of the week if it exists in the dateformat
     $old_date_format = phpbb::$user->date_format;
     phpbb::$user->date_format = str_replace('D ', '', phpbb::$user->date_format);
     $install_time = false;
     if ($this->install_time > 0) {
         if ($this->install_time < 60) {
             $install_time = phpbb::$user->lang['INSTALL_LESS_THAN_1_MINUTE'];
         } else {
             $install_time = phpbb::$user->lang('INSTALL_MINUTES', (int) ($this->install_time / 60));
         }
     }
     // ColorizeIt stuff
     $url_colorizeit = '';
     if ($this->revision_status == TITANIA_REVISION_APPROVED && strlen(titania::$config->colorizeit) && $this->contrib && $this->contrib->has_colorizeit()) {
         $url_colorizeit = 'http://' . titania::$config->colorizeit_url . '/custom/' . titania::$config->colorizeit . '.html?id=' . $this->attachment_id . '&amp;sample=' . $this->contrib->clr_sample->get_id();
     }
     phpbb::$template->assign_block_vars($tpl_block, array('REVISION_ID' => $this->revision_id, 'CREATED' => phpbb::$user->format_date($this->revision_time), 'NAME' => $this->revision_name ? censor_text($this->revision_name) : ($this->contrib ? $this->contrib->contrib_name . ' ' . $this->revision_version : ''), 'VERSION' => $this->revision_version, 'VALIDATED_DATE' => $this->validation_date ? phpbb::$user->format_date($this->validation_date) : phpbb::$user->lang['NOT_VALIDATED'], 'REVISION_QUEUE' => $show_queue && $this->revision_queue_id ? $this->controller_helper->route('phpbb.titania.queue.item', array('id' => $this->revision_queue_id)) : '', 'PHPBB_VERSION' => sizeof($ordered_phpbb_versions) == 1 ? $ordered_phpbb_versions[0] : '', 'REVISION_LICENSE' => $this->revision_license ? censor_text($this->revision_license) : ($this->contrib && sizeof($this->contrib->type->license_options) ? phpbb::$user->lang['UNKNOWN'] : ''), 'INSTALL_TIME' => $install_time, 'BBC_HTML_REPLACEMENT' => $this->revision_bbc_html_replace, 'BBC_BBCODE_USAGE' => $this->revision_bbc_bbcode_usage, 'BBC_HELPLINE' => $this->revision_bbc_help_line, 'BBC_DEMO' => $this->revision_bbc_demo, 'INSTALL_LEVEL' => $this->install_level > 0 ? phpbb::$user->lang['INSTALL_LEVEL_' . $this->install_level] : '', 'DOWNLOADS' => isset($this->download_count) ? $this->download_count : 0, 'U_DOWNLOAD' => $this->get_url(), 'U_COLORIZEIT' => $url_colorizeit, 'U_EDIT' => $this->contrib && ($this->contrib->is_author || $this->contrib->is_active_coauthor || $this->contrib->type->acl_get('moderate')) ? $this->contrib->get_url('revision', array('page' => 'edit', 'id' => $this->revision_id)) : '', 'S_USE_QUEUE' => titania::$config->use_queue && $this->contrib->type->use_queue ? true : false, 'S_NEW' => $this->revision_status == TITANIA_REVISION_NEW ? true : false, 'S_APPROVED' => $this->revision_status == TITANIA_REVISION_APPROVED ? true : false, 'S_DENIED' => $this->revision_status == TITANIA_REVISION_DENIED ? true : false, 'S_PULLED_SECURITY' => $this->revision_status == TITANIA_REVISION_PULLED_SECURITY ? true : false, 'S_PULLED_OTHER' => $this->revision_status == TITANIA_REVISION_PULLED_OTHER ? true : false, 'S_REPACKED' => $this->revision_status == TITANIA_REVISION_REPACKED ? true : false, 'S_RESUBMITTED' => $this->revision_status == TITANIA_REVISION_RESUBMITTED ? true : false));
     phpbb::$user->date_format = $old_date_format;
     // Output phpBB versions
     foreach ($ordered_phpbb_versions as $version) {
         phpbb::$template->assign_block_vars($tpl_block . '.phpbb_versions', array('VERSION' => $version));
     }
     // Output translations
     if ($this->translations->get_count()) {
         $message = false;
         $this->translations->parse_attachments($message, false, false, $tpl_block . '.translations', '');
     }
     // Hooks
     titania::$hook->call_hook(array(__CLASS__, __FUNCTION__), $this, $tpl_block);
 }
Esempio n. 2
0
 /**
  * Load revision attachment.
  *
  * @throws \Exception Throws exception if no attachment found.
  * @return null
  */
 protected function load_attachment()
 {
     $this->attachments->configure(TITANIA_CONTRIB, $this->contrib->contrib_id)->load(array($this->revision->attachment_id));
     $this->attachment = $this->attachments->get($this->revision->attachment_id);
     if (!$this->attachment) {
         throw new \Exception($this->user->lang['ERROR_NO_ATTACHMENT']);
     }
 }
Esempio n. 3
0
 /**
  * Get very basic data for loaded attachments.
  *
  * @return array
  */
 public function get_basic_attachment_data()
 {
     $data = array();
     foreach ($this->operator->get_fixed_indices() as $id) {
         $attach = $this->operator->get($id);
         $data[$id] = array('attach_id' => $id, 'real_filename' => $attach->get('real_filename'), 'type' => $this->form_name, 'url' => $attach->get_url(), 'thumb' => $attach->has_thumbnail() ? $attach->get_url(array('thumb' => 1, 'view' => 'inline')) : '');
     }
     return $data;
 }
Esempio n. 4
0
 /**
  * Load attachment.
  *
  * @param int $id		Attachment id.
  * @throws \Exception	Throws exception if attachment does not exist
  *	or cannot be accessed.
  * @return null
  */
 protected function load_attachment($id)
 {
     $id = (int) $id;
     if ($id) {
         $this->attachment = $this->attachments->configure(TITANIA_CONTRIB, 0)->load_from_ids(array($id))->get($id);
     }
     if (!$id || !$this->attachment || !$this->check_attachment_auth()) {
         throw new \Exception('ERROR_NO_ATTACHMENT');
     }
 }
Esempio n. 5
0
 /**
  * Display FAQ item.
  *
  * @param string $contrib_type		Contrib type URL identifier.
  * @param string $contrib			Contrib name clean.
  * @param int $id					FAQ item id
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function display_item($contrib_type, $contrib, $id)
 {
     $this->setup($contrib_type, $contrib);
     $this->load_item($id);
     if ($this->faq->faq_access < $this->access->get_level()) {
         return $this->helper->needs_auth();
     }
     // Increase a FAQ views counter
     $this->faq->increase_views_counter();
     // Tracking
     $this->tracking->track(TITANIA_FAQ, $this->id);
     $message = $this->faq->generate_text_for_display();
     // Grab attachments
     $this->attachments->configure(TITANIA_FAQ, $this->id)->load();
     $parsed_attachments = $this->attachments->parse_attachments($message);
     foreach ($parsed_attachments as $attachment) {
         $this->template->assign_block_vars('attachment', array('DISPLAY_ATTACHMENT' => $attachment));
     }
     $this->template->assign_vars(array('FAQ_SUBJECT' => $this->faq->faq_subject, 'FAQ_TEXT' => $message, 'FAQ_VIEWS' => $this->faq->faq_views, 'S_DETAILS' => true, 'S_ACCESS_TEAMS' => $this->access->is_team($this->faq->faq_access), 'S_ACCESS_AUTHORS' => $this->access->is_author($this->faq->faq_access), 'U_CANONICAL' => $this->faq->get_url(), 'U_EDIT_FAQ' => $this->check_auth('edit') ? $this->faq->get_url('edit') : false));
     $this->assign_vars();
     return $this->helper->render('contributions/contribution_faq.html', $this->faq->faq_subject . ' - ' . $this->contrib->contrib_name);
 }
Esempio n. 6
0
 /**
  * Quick Edit a post
  *
  * @param int $post_id
  * @return JsonResponse
  * @throws http_exception	Throws http_exception when form token is invalid.
  */
 public function quick_edit($post_id)
 {
     if ($this->request->header('X-PHPBB-USING-PLUPLOAD', false)) {
         return $this->edit($post_id);
     }
     $submit = $this->request->is_set_post('submit');
     $full_editor = $this->request->is_set_post('full_editor');
     // AJAX output
     if (!$submit && !$full_editor) {
         $this->user->add_lang('viewtopic');
         // Load the stuff we need
         $post = $this->load_post($post_id);
         // Check permissions
         $this->quick_edit_auth_check($post);
         $post_message = $post->post_text;
         message::decode($post_message, $post->post_text_uid);
         add_form_key('postform');
         $this->template->assign_vars(array('SUBJECT' => $post->post_subject, 'MESSAGE' => $post_message, 'U_QR_ACTION' => $post->get_url('quick_edit')))->set_filenames(array('quick_edit' => 'posting/quickedit_editor.html'));
         return new JsonResponse(array('form' => $this->template->assign_display('quick_edit')));
     }
     if ($full_editor) {
         return $this->edit($post_id);
     }
     // Load the stuff we need
     $post = $this->load_post($post_id);
     // Check permissions
     $this->quick_edit_auth_check($post);
     if (!check_form_key('postform')) {
         throw new http_exception(200, 'FORM_INVALID');
     }
     // Grab some data
     $for_edit = $post->generate_text_for_edit();
     // Set the post text
     $post->post_subject = $this->request->variable('subject', '', true);
     $post->post_text = $this->request->variable('message', '', true);
     // Generate for storage based on previous options
     $post->generate_text_for_storage($for_edit['allow_bbcode'], $for_edit['allow_urls'], $for_edit['allow_smilies']);
     // If u_titania_mod_post_mod permission then no edit info
     // Update edit info if user is editing his post, which is not the last within the topic.
     if (!$this->auth->acl_get('u_titania_mod_post_mod') && $post->topic->topic_last_post_id != $post->post_id) {
         $post->post_edit_time = time();
         $post->post_edit_user = $this->user->data['user_id'];
     }
     // Submit
     $post->submit();
     // Parse the message
     $message = $post->generate_text_for_display();
     // Parse attachments
     $this->attachments->configure($post->post_type, $post->post_id)->load()->parse_attachments($message);
     return new JsonResponse(array('subject' => censor_text($post->post_subject), 'message' => $message));
 }
Esempio n. 7
0
 /**
  * Delete attachments
  *
  * @param array $attachments	Array of attachments
  */
 protected function delete_attachments(array $attachments)
 {
     $this->attachments->store($attachments)->delete_all();
 }
Esempio n. 8
0
 /**
  * Passes details to the template
  *
  * @param bool $simple True to output a simpler version (on the non-main pages)
  */
 public function assign_details($simple = false, $return = false)
 {
     $vars = array('CONTRIB_NAME' => $this->contrib_name, 'CONTRIB_DESC' => $this->generate_text_for_display(), 'CONTRIB_VIEWS' => $this->contrib_views, 'CONTRIB_UPDATE_DATE' => $this->contrib_last_update ? phpbb::$user->format_date($this->contrib_last_update) : '', 'CONTRIB_STATUS' => $this->contrib_status, 'CONTRIB_LIMITED_SUPPORT' => $this->contrib_limited_support, 'CONTRIB_LOCAL_NAME' => $this->contrib_local_name, 'CONTRIB_ISO_CODE' => $this->contrib_iso_code, 'CONTRIB_RATING' => $this->contrib_rating, 'CONTRIB_RATING_COUNT' => $this->contrib_rating_count, 'CONTRIB_RATING_STRING' => $this->rating ? $this->rating->get_rating_string($this->get_url('rate')) : '', 'L_ANNOUNCEMENT_TOPIC' => titania::$config->support_in_titania ? phpbb::$user->lang['ANNOUNCEMENT_TOPIC'] : phpbb::$user->lang['ANNOUNCEMENT_TOPIC_SUPPORT'], 'U_VIEW_DEMO' => $this->contrib_demo, 'S_INTEGRATE_DEMO' => $this->options['demo']);
     // Ignore some stuff before it is submitted else we can cause an error
     if ($this->contrib_id) {
         foreach ($this->type->get_allowed_branches(true, false) as $branch => $name) {
             $release_topic_id = $this->get_release_topic_id($branch);
             if ($release_topic_id) {
                 phpbb::$template->assign_block_vars('announce_topic', array('URL' => phpbb::append_sid('viewtopic', 't=' . $release_topic_id), 'BRANCH' => $name));
             }
         }
         if (!empty($this->download)) {
             $this->assign_download_details();
             $vars = array_merge($vars, array('CONTRIB_DOWNLOADS' => $this->contrib_downloads));
         }
         if ($this->contrib_type == TITANIA_TYPE_BBCODE && !empty($this->download)) {
             $download = reset($this->download);
             $demo_output = $download['revision_bbc_demo'];
             $demo_rendered = false;
             if ($download['revision_status'] == TITANIA_REVISION_APPROVED && !empty($demo_output)) {
                 $demo = $this->type->get_demo()->configure($this->contrib_id, $download['revision_bbc_bbcode_usage'], $download['revision_bbc_html_replace']);
                 $demo_output = $demo->get_demo($demo_output);
                 unset($demo);
                 $demo_rendered = true;
             }
             $vars = array_merge($vars, array('CONTRIB_BBC_HTML_REPLACEMENT' => isset($download['revision_bbc_html_replace']) ? $download['revision_bbc_html_replace'] : '', 'CONTRIB_BBC_BBCODE_USAGE' => isset($download['revision_bbc_bbcode_usage']) ? $download['revision_bbc_bbcode_usage'] : '', 'CONTRIB_BBC_HELPLINE' => isset($download['revision_bbc_help_line']) ? $download['revision_bbc_help_line'] : '', 'CONTRIB_BBC_DEMO' => $demo_output, 'S_CONTRIB_BBC_DEMO_RENDERED' => $demo_rendered));
         }
         $use_queue = titania::$config->use_queue && $this->type->use_queue;
         $u_view_reports = $u_manage = $u_new_revision = $u_queue_discussion = false;
         if ($this->type->acl_get('moderate')) {
             $u_view_reports = $this->controller_helper->route('phpbb.titania.manage.attention.redirect', array('type' => TITANIA_CONTRIB, 'id' => $this->contrib_id));
         }
         if ($this->is_manageable()) {
             $u_manage = $this->get_url('manage');
             if (phpbb::$auth->acl_get('u_titania_contrib_submit')) {
                 $u_new_revision = $this->get_url('revision');
             }
         }
         if ($use_queue && $this->is_manageable('queue_discussion')) {
             $u_queue_discussion = $this->get_url('queue_discussion');
         }
         $vars = array_merge($vars, array('CONTRIB_TYPE' => $this->type->lang, 'CONTRIB_TYPE_ID' => $this->contrib_type, 'CONTRIB_TYPE_CLEAN' => $this->type->url, 'U_CONTRIB_MANAGE' => $u_manage, 'U_NEW_REVISION' => $u_new_revision, 'U_QUEUE_DISCUSSION' => $u_queue_discussion, 'U_VIEW_CONTRIB' => $this->get_url(), 'U_REPORT' => phpbb::$user->data['is_registered'] ? $this->get_url('report') : '', 'U_VIEW_REPORTS' => $u_view_reports, 'S_CONTRIB_NEW' => $this->contrib_status == TITANIA_CONTRIB_NEW ? true : false, 'S_CONTRIB_VALIDATED' => $this->contrib_status == TITANIA_CONTRIB_APPROVED ? true : false, 'S_CONTRIB_CLEANED' => $this->contrib_status == TITANIA_CONTRIB_CLEANED ? true : false, 'S_CONTRIB_DOWNLOAD_DISABLED' => $this->contrib_status == TITANIA_CONTRIB_DOWNLOAD_DISABLED ? true : false, 'S_CONTRIB_HIDDEN' => $this->contrib_status == TITANIA_CONTRIB_HIDDEN ? true : false, 'S_CONTRIB_DISABLED' => $this->contrib_status == TITANIA_CONTRIB_DISABLED ? true : false, 'JS_CONTRIB_TRANSLATION' => !empty($this->contrib_iso_code) ? 'true' : 'false'));
     }
     // Hooks
     titania::$hook->call_hook_ref(array(__CLASS__, __FUNCTION__), $vars, $this);
     // Display real author
     if ($return) {
         $vars['AUTHOR_NAME_FULL'] = $this->author->get_username_string();
     } else {
         $this->author->assign_details();
     }
     if (!$simple && !$return) {
         $active_coauthors = $past_coauthors = array();
         $author_sort = function ($a, $b) {
             return strcmp($a['AUTHOR_NAME'], $b['AUTHOR_NAME']);
         };
         // Display Co-authors
         foreach ($this->coauthors as $user_id => $row) {
             if ($row['active']) {
                 $active_coauthors[] = $this->author->assign_details(true, $row);
             } else {
                 $past_coauthors[] = $this->author->assign_details(true, $row);
             }
         }
         usort($active_coauthors, $author_sort);
         usort($past_coauthors, $author_sort);
         phpbb::$template->assign_block_vars_array('coauthors', $active_coauthors);
         phpbb::$template->assign_block_vars_array('past_coauthors', $past_coauthors);
         // Display Revisions and phpBB versions
         if (sizeof($this->revisions)) {
             $revision = new titania_revision($this);
             $revision->contrib = $this;
             $phpbb_versions = array();
             foreach ($this->revisions as $revision_id => $row) {
                 $revision->__set_array($row);
                 $revision->phpbb_versions = isset($row['phpbb_versions']) ? $row['phpbb_versions'] : array();
                 $revision->translations = isset($row['translations']) ? $revision->set_translations($row['translations']) : array();
                 $revision->display('revisions', $this->type->acl_get('view'), $this->options['all_versions']);
                 $phpbb_versions = array_merge($phpbb_versions, $revision->phpbb_versions);
             }
             unset($revision);
             $ordered_phpbb_versions = versions::order_phpbb_version_list_from_db($this->cache, $phpbb_versions, $this->options['all_versions']);
             if (sizeof($ordered_phpbb_versions) == 1) {
                 phpbb::$template->assign_vars(array('PHPBB_VERSION' => $ordered_phpbb_versions[0]));
             } else {
                 foreach ($ordered_phpbb_versions as $version_row) {
                     phpbb::$template->assign_block_vars('phpbb_versions', array('NAME' => $version_row));
                 }
             }
         }
         // Display Screenshots
         if ($this->screenshots->get_count()) {
             $message = false;
             $this->screenshots->parse_attachments($message, false, false, 'screenshots', true);
         }
         // Display categories
         $category = new titania_category();
         foreach ($this->category_data as $category_row) {
             $category->__set_array($category_row);
             phpbb::$template->assign_block_vars('categories', $category->assign_display(true));
         }
     }
     if ($return) {
         return $vars;
     }
     phpbb::$template->assign_vars($vars);
 }
Esempio n. 9
0
 /**
  * Load attachment
  *
  * @param int $id	Attachment id
  * @return bool	Returns true if the attachment loaded successfully
  */
 protected function load_attachment($id)
 {
     $this->attachment = $this->attachments->configure(TITANIA_CONTRIB, $this->contrib->contrib_id)->load(array((int) $id))->get($id);
     return !empty($this->attachment);
 }