private function loadNewArticle($num = 3) { $uid = Ibos::app()->user->uid; $allDeptId = Ibos::app()->user->alldeptid . ""; $allPosId = Ibos::app()->user->allposid . ""; $deptCondition = ""; $deptIdArr = explode(",", $allDeptId); if (0 < count($deptIdArr)) { foreach ($deptIdArr as $deptId) { $deptCondition .= "FIND_IN_SET('{$deptId}',deptid) OR "; } $deptCondition = substr($deptCondition, 0, -4); } else { $deptCondition = "FIND_IN_SET('',deptid)"; } $condition = " ( ((deptid='alldept' OR {$deptCondition} OR FIND_IN_SET('{$allPosId}',positionid) OR FIND_IN_SET('{$uid}',uid)) OR (deptid='' AND positionid='' AND uid='') OR (author='{$uid}') OR (approver='{$uid}')) ) AND `status`='1'"; $criteria = array("select" => "articleid,subject,content,addtime,type", "condition" => $condition, "order" => "`istop` DESC, `addtime` DESC", "offset" => 0, "limit" => $num); $articles = Article::model()->fetchAll($criteria); if (!empty($articles)) { foreach ($articles as &$article) { $read = ArticleReader::model()->fetchByAttributes(array("articleid" => $article["articleid"], "uid" => $uid)); $readStatus = $read ? 1 : 0; if ($readStatus) { $article["iconStyle"] = $this->iconReadStyle[$article["type"]]; } else { $article["iconStyle"] = $this->iconNormalStyle[$article["type"]]; } } } return $articles; }
public function getList($type = 1, $catid = 0, $search = "") { $gUid = Ibos::app()->user->uid; $childCatIds = ""; if (!empty($catid)) { $this->catid = $catid; $childCatIds = ArticleCategory::model()->fetchCatidByPid($this->catid, true); } if (!empty($search)) { $this->condition = "subject like '%{$search}%'"; } $articleidArr = ArticleReader::model()->fetchArticleidsByUid(Ibos::app()->user->uid); $this->condition = ArticleUtil::joinListCondition($type, $articleidArr, $childCatIds, $this->condition); $datas = Article::model()->fetchAllAndPage($this->condition); $listData = $datas["datas"]; foreach ($listData as $key => $value) { $value["content"] = StringUtil::cutStr(strip_tags($value["content"]), 30); $listData[$key] = array_filter($value); $listData[$key]["readstatus"] = ArticleReader::model()->checkIsRead($value["articleid"], $gUid); } $return["datas"] = $listData; $return["pages"] = array("pageCount" => $datas["pages"]->getPageCount(), "page" => $datas["pages"]->getCurrentPage(), "pageSize" => $datas["pages"]->getPageSize()); return $return; }
private function getReaderByDeptId() { if (Yii::app()->request->isAjaxRequest) { $articleId = $_POST["articleid"]; $deptId = $_POST["deptid"]; $readerData = ArticleReader::model()->fetchArticleReaderByDeptid($articleId, $deptId); $this->ajaxReturn($readerData); } }
public static function setReadStatus($data, $uid) { if (is_array($data) && 0 < count($data)) { for ($i = 0; $i < count($data); $i++) { $articleid = $data[$i]["articleid"]; if (ArticleReader::model()->checkIsRead($articleid, $uid)) { $data[$i]["readStatus"] = 1; } else { $data[$i]["readStatus"] = 0; } } } return $data; }