Exemple #1
0
 /**
  * Marks a file for deletion
  *
  * @param   integer  $post_id  The ID of the post which is associated with the attachment
  * @return  void
  */
 public function markForDelete($post_id)
 {
     // Check if they are logged in
     if (User::isGuest()) {
         return;
     }
     // Load attachment object
     $row = new Tables\Attachment($this->database);
     $row->loadByPost($post_id);
     //mark for deletion
     $row->set('status', 2);
     if (!$row->store()) {
         $this->setError($row->getError());
     }
 }
Exemple #2
0
 /**
  * Get a list of attachments in this thread
  *
  * @param   array  $filters Filters to build query from
  * @return  object \Hubzero\Base\ItemList
  */
 public function attachments($rtrn = 'list', $clear = false)
 {
     switch (strtolower($rtrn)) {
         case 'count':
             return $this->attachments('list')->total();
             break;
         case 'first':
             return $this->attachments('list')->first();
             break;
         case 'list':
         case 'results':
         default:
             if (!$this->_cache['attachments'] instanceof ItemList || $clear) {
                 $tbl = new Tables\Attachment($this->_db);
                 if ($results = $tbl->getAttachments($this->get('id'))) {
                     foreach ($results as $key => $result) {
                         $results[$key] = new Attachment($result);
                     }
                 } else {
                     $results = array();
                 }
                 $this->_cache['attachments'] = new ItemList($results);
             }
             return $this->_cache['attachments'];
             break;
     }
 }
Exemple #3
0
 /**
  * Get the state of the entry as either text or numerical value
  *
  * @param   string  $as      Format to return state in [text, number]
  * @param   integer $shorten Number of characters to shorten text to
  * @return  mixed   String or Integer
  */
 public function content($as = 'parsed', $shorten = 0)
 {
     $as = strtolower($as);
     $options = array();
     switch ($as) {
         case 'parsed':
             $content = $this->get('content.parsed', null);
             if ($content === null) {
                 $config = array('option' => 'com_forum', 'scope' => 'forum', 'pagename' => 'forum', 'pageid' => $this->get('thread'), 'filepath' => '', 'domain' => $this->get('thread'));
                 $attach = new Tables\Attachment($this->_db);
                 $content = (string) stripslashes($this->get('comment', ''));
                 $this->importPlugin('content')->trigger('onContentPrepare', array($this->_context, &$this, &$config));
                 $this->set('content.parsed', (string) $this->get('comment', ''));
                 $this->set('content.parsed', $this->get('content.parsed') . $attach->getAttachment($this->get('id'), $this->link('download'), $this->_config));
                 $this->set('comment', $content);
                 return $this->content($as, $shorten);
             }
             $options['html'] = true;
             break;
         case 'clean':
             $content = strip_tags($this->content('parsed'));
             break;
         case 'raw':
         default:
             $content = $this->get('comment');
             $content = preg_replace('/^(<!-- \\{FORMAT:.*\\} -->)/i', '', $content);
             break;
     }
     if ($shorten) {
         $content = String::truncate($content, $shorten, $options);
     }
     return $content;
 }