Example #1
0
 /**
  * Store attachments
  *
  * @param   boolean  $updateNulls
  * @return  void
  */
 public function store($updateNulls = false)
 {
     $result = parent::store($updateNulls);
     if (!$result) {
         return false;
     }
     if (isset($this->attachmentNames) && count($this->attachmentNames) > 0) {
         // save the attachments
         foreach ($this->attachmentNames as $nm) {
             // delete old attachment
             // find old file and remove it from file system
             $file = new File($this->_db);
             $file->loadByComment($this->id);
             if ($file->id) {
                 if (!$file->deleteFile()) {
                     $this->setError($file->getError());
                     continue;
                 }
             }
             $file->filename = $nm;
             $file->comment_id = $this->id;
             if (!$file->store()) {
                 $this->setError($file->getError());
                 continue;
             }
         }
     }
     return true;
 }