示例#1
0
 private function _attList()
 {
     $u = User::getInstance();
     if (isset($this->params['id'])) {
         $id = $this->params['id'];
         try {
             $article = Article::getInstance($id, $this->_board);
             if (!$article->hasEditPerm($u)) {
                 $this->error(ECode::$ARTICLE_NOEDIT);
             }
             $atts = $article->getAttList();
             $this->set("postUrl", "/{$article->ID}");
         } catch (Exception $e) {
             $this->error(ECode::$ARTICLE_NONE);
         }
     } else {
         $atts = Forum::listAttach();
     }
     return $atts;
 }
示例#2
0
 public function delete()
 {
     if (!$this->RequestHandler->isPost()) {
         $this->error(ECode::$SYS_REQUESTERROR);
     }
     $this->_attOpInit();
     $u = User::getInstance();
     if (!isset($this->params['form']['name'])) {
         $this->error(ECode::$ATT_NAMEERROR);
     }
     $attName = strval($this->params['form']['name']);
     try {
         if (isset($this->params['id'])) {
             $id = $this->params['id'];
             $article = Article::getInstance($id, $this->_board);
             if (!$article->hasEditPerm($u)) {
                 $this->error(ECode::$ARTICLE_NOEDIT);
             }
             $attNum = 0;
             foreach ($article->getAttList() as $k => $v) {
                 if ($v['name'] == $attName) {
                     $attNum = intval($k + 1);
                     break;
                 }
             }
             $article->delAttach($attNum);
             $article = Article::getInstance($id, $this->_board);
         } else {
             Forum::delAttach($attName);
             $article = Forum::listAttach();
         }
         $wrapper = Wrapper::getInstance();
         $this->set('data', $wrapper->attachment($article));
         return;
     } catch (ArchiveAttException $e) {
         $msg = $e->getMessage();
     } catch (AttException $e) {
         $msg = $e->getMessage();
     } catch (Exception $e) {
         $this->error();
     }
 }