Example #1
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;
     }
 }