Пример #1
0
 public function addReader($docid, $uid)
 {
     if ($this->checkIsRead($docid, $uid) == false) {
         $reader = array("docid" => $docid, "uid" => $uid, "addtime" => TIMESTAMP);
         return OfficialdocReader::model()->add($reader);
     }
 }
Пример #2
0
 private function loadNewDoc($num = 3)
 {
     $uid = Yii::app()->user->uid;
     $allDeptId = Yii::app()->user->alldeptid . "";
     $allPosId = Yii::app()->user->allposid . "";
     $condition = " ( ((deptid='alldept' OR FIND_IN_SET('{$allDeptId}',deptid) 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" => "docid,subject,author,addtime", "condition" => $condition, "order" => "`istop` DESC, `addtime` DESC", "offset" => 0);
     $docs = Officialdoc::model()->fetchAll($criteria);
     $unSign = array();
     $signed = array();
     if (!empty($docs)) {
         foreach ($docs as &$doc) {
             $doc["author"] = User::model()->fetchRealNameByUid($doc["author"]);
             $doc["sign"] = OfficialdocReader::model()->fetchByAttributes(array("docid" => $doc["docid"], "uid" => $uid));
             $doc["isSign"] = empty($doc["sign"]) ? 0 : $doc["sign"]["issign"];
             if ($doc["isSign"] == 0) {
                 $unSign[] = $doc;
             } elseif ($doc["isSign"] == 1) {
                 $signed[] = $doc;
             }
         }
         $docs = array_merge($unSign, $signed);
     }
     if ($num < count($docs)) {
         $docs = array_slice($docs, 0, $num);
     }
     return $docs;
 }
Пример #3
0
 public function countNoSignByUid($uid)
 {
     $isSignIdArr = OfficialdocReader::model()->fetchDocidsByUid($uid);
     $condition = OfficialdocUtil::joinListCondition("nosign", $isSignIdArr);
     $count = $this->count($condition);
     return $count;
 }
Пример #4
0
 public function actionShow()
 {
     $uid = Ibos::app()->user->uid;
     $docid = EnvUtil::getRequest("id");
     $version = EnvUtil::getRequest("version");
     if (empty($docid)) {
         $this->ajaxReturn("", "JSONP");
     }
     $officialDocEntity = new ICOfficialdoc($docid);
     $officialDoc = $officialDocEntity->getAttributes();
     if ($version) {
         $versionData = OfficialdocVersion::model()->fetchByAttributes(array("docid" => $docid, "version" => $version));
         $officialDoc = array_merge($officialDoc, $versionData);
     }
     if (!empty($officialDoc)) {
         if (!OfficialdocUtil::checkReadScope($uid, $officialDoc)) {
             $this->error(Ibos::lang("You do not have permission to read the officialdoc"), $this->createUrl("default/index"));
         }
         $data = ICOfficialdoc::getShowData($officialDoc);
         OfficialdocReader::model()->addReader($docid, $uid);
         Officialdoc::model()->updateClickCount($docid, $data["clickcount"]);
         $page = EnvUtil::getRequest("page");
         $criteria = new CDbCriteria();
         $pages = new CPagination(OfficialdocUtil::getCharacterLength($data["content"]));
         $pages->pageSize = 2000;
         $pages->applyLimit($criteria);
         $tmpContent = OfficialdocUtil::subHtml($data["content"], $pages->getCurrentPage() * $pages->getPageSize(), ($pages->getCurrentPage() + 1) * $pages->getPageSize());
         $data["content"] = $tmpContent;
         if (!empty($page) && $page != 1) {
             $data["content"] = "<div><div style=\"border-bottom:4px solid #e26f50;margin-top:60px;\"></div><div style=\"border-top:1px solid #e26f50;margin-top:4px;\"><div><p style=\"text-align:center;\"></p><div id=\"original-content\" style=\"min-height:400px;font:16px/2 fangsong,simsun;color:#666;\"><table cellspacing=\"0\" cellpadding=\"0\" width=\"95%\" align=\"center\"><tbody><tr><td class=\"p1\"><span><p>" . $tmpContent . "</p>";
             $data["content"] = OfficialdocUtil::subHtml($data["content"], 0, $pages->pageSize * 2);
         }
         $params = array("data" => $data, "pages" => $pages, "dashboardConfig" => Yii::app()->setting->get("setting/docconfig"));
         if ($data["rcid"]) {
             $params["rcType"] = RcType::model()->fetchByPk($data["rcid"]);
         }
     } else {
         $params = "";
     }
     $this->ajaxReturn($params, "JSONP");
 }
Пример #5
0
 public static function getListDatas($datas)
 {
     $listDatas = array();
     $users = Ibos::app()->setting->get("cache/users");
     $uid = Ibos::app()->user->uid;
     $checkTime = 3 * 86400;
     $readDocIds = OfficialdocReader::model()->fetchReadArtIdsByUid($uid);
     $signedDocIds = OfficialdocReader::model()->fetchSignArtIdsByUid($uid);
     foreach ($datas as $data) {
         $data["subject"] = StringUtil::cutStr($data["subject"], 50);
         $data["readStatus"] = in_array($data["docid"], $readDocIds) ? 1 : -1;
         if ($data["readStatus"] === -1 && TIMESTAMP - $checkTime < $data["uptime"]) {
             $data["readStatus"] = 2;
         }
         $data["signNum"] = OfficialdocReader::model()->count("issign = 1 AND docid = {$data["docid"]}");
         $data["signStatus"] = in_array($data["docid"], $signedDocIds) ? 1 : 0;
         $data["author"] = isset($users[$data["author"]]) ? $users[$data["author"]]["realname"] : "";
         $data["uptime"] = empty($data["uptime"]) ? $data["addtime"] : $data["uptime"];
         $data["uptime"] = ConvertUtil::formatDate($data["uptime"], "u");
         $keyword = EnvUtil::getRequest("keyword");
         if (!empty($keyword)) {
             $data["subject"] = preg_replace("|({$keyword})|i", "<span style='color:red'>\$1</span>", $data["subject"]);
         }
         if ($data["ishighlight"] == "1") {
             $highLightStyle = $data["highlightstyle"];
             $hiddenInput = "<input type='hidden' id='{$data["docid"]}_hlstyle' value='{$highLightStyle}'/>";
             $data["subject"] .= $hiddenInput;
             $highLightStyleArr = explode(",", $highLightStyle);
             $color = $highLightStyleArr[1];
             $isB = $highLightStyleArr[0];
             $isI = $highLightStyleArr[2];
             $isU = $highLightStyleArr[3];
             $isB && ($data["subject"] = "<b>{$data["subject"]}</b>");
             $isU && ($data["subject"] = "<u>{$data["subject"]}</u>");
             $fontStyle = "";
             $color != "" && ($fontStyle .= "color:{$color};");
             $isI && ($fontStyle .= "font-style:italic;");
             $fontStyle != "" && ($data["subject"] = "<font style='{$fontStyle}'>{$data["subject"]}</font>");
         }
         $listDatas[] = $data;
     }
     return $listDatas;
 }
Пример #6
0
 private function sign()
 {
     if (Ibos::app()->request->isAjaxRequest) {
         $docid = EnvUtil::getRequest("docid");
         $uid = Ibos::app()->user->uid;
         OfficialdocReader::model()->updateSignByDocid($docid, $uid);
         $this->ajaxReturn(array("isSuccess" => true, "msg" => Ibos::lang("Sign for success"), "signtime" => date("Y年m月d日 H:i", TIMESTAMP)));
     }
 }