/**
  * @brief deletePost 删除一篇文章
  *
  * @return void
  */
 public function deletePost()
 {
     $pid = Request::P('pid');
     // 删除文章
     $post = new PostLibrary();
     $post->deletePost($pid);
     // 删除 Meta 关系
     $meta = new MetaLibrary();
     $meta->setPID($pid);
     $metas = $meta->getMeta();
     foreach ($metas as $m) {
         if ($m['type'] == 1 || $m['type'] == 2) {
             $meta->delRelation($m['mid'], $pid);
         } elseif ($m['type'] == 3) {
             $meta->movRelation($m['mid'], $pid, 1000000000);
         }
     }
     // 删除评论
     $comment = new CommentLibrary();
     $comment->deleteComments($pid);
     $r = array('success' => TRUE);
     Response::ajaxReturn($r);
 }
Пример #2
0
</label></li>
					</ul>
				</li>
				<li>
					<label class="add-post-label"><?php 
    _e('Attachment');
    ?>
</label> <a href="#" onclick="uploadPanel(); return false;" style="font-size:12px;"><?php 
    _e('Upload');
    ?>
</a>
					<ul class="clearfix" id="fsUpload">
					<?php 
    $meta = new MetaLibrary();
    $meta->setType(3);
    $meta->setPID(1000000000);
    $attachments = $meta->getMeta();
    foreach ($attachments as $c) {
        ?>
						<li class="multiline"><label for="attach-<?php 
        echo $c['mid'];
        ?>
"><?php 
        echo $c['name'];
        ?>
</label><a href="#" onclick="insertToEditor('<?php 
        path(array('mid' => $c['mid']), 'Attachment');
        ?>
','<?php 
        echo $c['description'];
        ?>
 /**
  * @brief editPostDo 编辑文章
  *
  * @return void
  */
 private function editPostDo()
 {
     // 验证用户权限
     // 非管理员只能编辑自己的文章
     // 如果原文章属于多个分类,那么编辑者必须拥有所有从属分类的权限
     // 如果原文章不属于任何一个分类(正常情况下不会出现),那么任何人均可以编辑该文章
     if (!Widget::getWidget('User')->isAdmin()) {
         $pid = Request::P('pid');
         $meta = new MetaLibrary();
         $meta->setPID($pid);
         $meta->setType(1);
         $metas = $meta->getMeta(FALSE);
         foreach ($metas as $m) {
             if (!Widget::getWidget('User')->checkPrivilege('POST', $m['mid'])) {
                 Response::ajaxReturn(array('success' => FALSE, 'message' => _t('Permission denied.')));
                 return;
             }
         }
     }
     Widget::initWidget('Post');
     Widget::getWidget('Post')->editPost();
 }