Пример #1
0
 public static function handleApproval($datas)
 {
     $allApprovals = Approval::model()->fetchAllSortByPk("id");
     $allCategorys = ArticleCategory::model()->fetchAllSortByPk("catid");
     $artApprovals = ArticleApproval::model()->fetchAllGroupByArtId();
     $backArtIds = ArticleBack::model()->fetchAllBackArtId();
     foreach ($datas as &$art) {
         $art["back"] = in_array($art["articleid"], $backArtIds) ? 1 : 0;
         $art["approval"] = $art["approvalStep"] = array();
         $catid = $art["catid"];
         if (!empty($allCategorys[$catid]["aid"])) {
             $aid = $allCategorys[$catid]["aid"];
             if (!empty($allApprovals[$aid])) {
                 $art["approval"] = $allApprovals[$aid];
             }
         }
         if (!empty($art["approval"])) {
             $art["approvalName"] = !empty($art["approval"]) ? $art["approval"]["name"] : "";
             $art["artApproval"] = isset($artApprovals[$art["articleid"]]) ? $artApprovals[$art["articleid"]] : array();
             $art["stepNum"] = count($art["artApproval"]);
             $step = array();
             foreach ($art["artApproval"] as $artApproval) {
                 $step[$artApproval["step"]] = User::model()->fetchRealnameByUid($artApproval["uid"]);
             }
             for ($i = 1; $i <= $art["approval"]["level"]; $i++) {
                 if ($i <= $art["stepNum"]) {
                     $art["approval"][$i]["approvaler"] = isset($step[$i]) ? $step[$i] : "未知";
                 } else {
                     $levelName = Approval::model()->getLevelNameByStep($i);
                     $approvalUids = $art["approval"][$levelName];
                     $art["approval"][$i]["approvaler"] = User::model()->fetchRealnamesByUids($approvalUids, "、");
                 }
             }
         }
     }
     return $datas;
 }
Пример #2
0
 private function back()
 {
     $uid = Ibos::app()->user->uid;
     $artIds = trim(EnvUtil::getRequest("articleids"), ",");
     $reason = StringUtil::filterCleanHtml(EnvUtil::getRequest("reason"));
     $ids = explode(",", $artIds);
     if (empty($ids)) {
         $this->ajaxReturn(array("isSuccess" => false, "msg" => Ibos::lang("Parameters error", "error")));
     }
     $sender = User::model()->fetchRealnameByUid($uid);
     foreach ($ids as $artId) {
         $art = Article::model()->fetchByPk($artId);
         $categoryName = ArticleCategory::model()->fetchCateNameByCatid($art["catid"]);
         if (!$this->checkIsApprovaler($art, $uid)) {
             $this->ajaxReturn(array("isSuccess" => false, "msg" => Ibos::lang("You do not have permission to verify the article")));
         }
         $config = array("{sender}" => $sender, "{subject}" => $art["subject"], "{category}" => $categoryName, "{content}" => $reason, "{url}" => Ibos::app()->urlManager->createUrl("article/default/index", array("type" => "notallow")));
         Notify::model()->sendNotify($art["author"], "article_back_message", $config, $uid);
         ArticleBack::model()->addBack($artId, $uid, $reason, TIMESTAMP);
     }
     $this->ajaxReturn(array("isSuccess" => true, "msg" => Ibos::lang("Operation succeed", "message")));
 }
Пример #3
0
 public function fetchUnApprovalArtIds($catid, $uid)
 {
     $backArtIds = ArticleBack::model()->fetchAllBackArtId();
     $backArtIdStr = implode(",", $backArtIds);
     $backCondition = empty($backArtIdStr) ? "" : "AND `articleid` NOT IN({$backArtIdStr})";
     if (empty($catid)) {
         $catids = ArticleCategory::model()->fetchAllApprovalCatidByUid($uid);
         $catidStr = implode(",", $catids);
         $condition = "((FIND_IN_SET( `catid`, '{$catidStr}') {$backCondition} ) OR `author` = {$uid})";
     } else {
         $isApproval = ArticleCategory::model()->checkIsApproval($catid, $uid);
         $condition = $isApproval ? "(`catid` = {$catid} {$backCondition} )" : " (`catid` = {$catid} AND `author` = {$uid})";
     }
     $record = $this->fetchAll(array("select" => array("articleid"), "condition" => "`status` = 2 AND " . $condition));
     $artIds = ConvertUtil::getSubByKey($record, "articleid");
     return $artIds;
 }