Exemplo n.º 1
0
 /**
  * Get the rating as an object
  *
  * @return titania_rating
  */
 public function get_screenshots()
 {
     if ($this->screenshots->get_object_type() !== null) {
         return $this->screenshots;
     }
     $this->screenshots->configure(TITANIA_SCREENSHOT, $this->contrib_id)->load();
     return $this->screenshots;
 }
Exemplo 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']);
     }
 }
Exemplo n.º 3
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');
     }
 }
Exemplo n.º 4
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);
 }
Exemplo n.º 5
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));
 }
Exemplo n.º 6
0
 /**
  * Configure uploader
  *
  * @param int $object_type				Parent object type
  * @param int $object_id				Parent object id
  * @param bool $use_plupload			Whether to use Plupload
  * @param bool|int $max_thumbnail_width	(Optional) Max thumbnail width
  * @param bool $set_custom_order		Whether set supports custom order
  * @return $this
  */
 public function configure($object_type, $object_id, $use_plupload = false, $max_thumbnail_width = false, $set_custom_order = false)
 {
     // Set class variables.
     $this->object_type = (int) $object_type;
     $this->object_id = (int) $object_id;
     $this->use_plupload = $use_plupload;
     $this->form_name = 'titania_attachment_' . $this->object_type . '_' . $this->object_id;
     $this->max_thumbnail_width = $max_thumbnail_width;
     $this->set_custom_order = $set_custom_order;
     $upload_dir = $this->ext_config->upload_path . $this->ext_config->upload_directory[$this->object_type] . '/';
     if ($this->use_plupload) {
         $this->plupload->set_upload_directories($upload_dir, $upload_dir . 'plupload');
         $this->plupload->configure_ext($this->ext_config, $this->template, $this->controller_helper->get_current_url(), $this->object_type, 0, $this->get_max_filesize());
     }
     $this->operator->configure($this->object_type, $this->object_id);
     return $this;
 }
Exemplo n.º 7
0
 /**
  * Load the Translations for this revision
  * Stored in $this->translations
  */
 public function load_translations()
 {
     $this->translations->configure(TITANIA_TRANSLATION, $this->revision_id)->load();
 }
Exemplo n.º 8
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);
 }