public function getNews($id) { $gUid = Ibos::app()->user->uid; $article = Article::model()->fetchByPk($id); $attribute = ICArticle::getShowData($article); return $attribute; }
public function actionAdd() { $op = EnvUtil::getRequest("op"); $option = empty($op) ? "default" : $op; $routes = array("submit", "default", "checkIsAllowPublish"); if (!in_array($option, $routes)) { $this->error(Ibos::lang("Can not find the path"), $this->createUrl("default/index")); } if ($option == "default") { if (!empty($_GET["catid"])) { $this->catid = $_GET["catid"]; } $allowPublish = ArticleCategory::model()->checkIsAllowPublish($this->catid, Ibos::app()->user->uid); $params = array("categoryOption" => $this->getCategoryOption(), "uploadConfig" => AttachUtil::getUploadConfig(), "dashboardConfig" => $this->getDashboardConfig(), "allowPublish" => $allowPublish); $this->setPageTitle(Ibos::lang("Add Article")); $this->setPageState("breadCrumbs", array(array("name" => Ibos::lang("Information center")), array("name" => Ibos::lang("Article"), "url" => $this->createUrl("default/index")), array("name" => Ibos::lang("Add Article")))); $this->render("add", $params); } elseif ($option == "submit") { if (ICArticle::formCheck($_POST) == false) { $this->error(Ibos::lang("Title do not empty"), $this->createUrl("default/add")); } $uid = Ibos::app()->user->uid; $this->beforeSaveData($_POST); $articleId = $this->addOrUpdateArticle("add", $_POST, $uid); if ($_POST["type"] == parent::ARTICLE_TYPE_PICTURE) { $pidids = $_POST["picids"]; if (!empty($pidids)) { AttachUtil::updateAttach($pidids); $attach = AttachUtil::getAttach($pidids, true, true, false, false, true); $this->addPicture($attach, $articleId); } } $attachmentid = trim($_POST["attachmentid"], ","); if (!empty($attachmentid)) { AttachUtil::updateAttach($attachmentid); Article::model()->modify($articleId, array("attachmentid" => $attachmentid)); } $dashboardConfig = $this->getDashboardConfig(); if (isset($_POST["votestatus"]) && $this->getVoteInstalled() && $dashboardConfig["articlevoteenable"]) { $voteItemType = $_POST["voteItemType"]; $type = $voteItemType == 1 ? "vote" : "imageVote"; if (!empty($voteItemType) && trim($_POST[$type]["subject"]) != "") { $voteId = $this->addOrUpdateVote($_POST[$type], $articleId, $uid, "add"); $this->addVoteItem($_POST[$type], $voteId, $voteItemType); } else { Article::model()->modify($articleId, array("votestatus" => 0)); } } $user = User::model()->fetchByUid($uid); $article = Article::model()->fetchByPk($articleId); $categoryName = ArticleCategory::model()->fetchCateNameByCatid($article["catid"]); if ($article["status"] == "1") { $publishScope = array("deptid" => $article["deptid"], "positionid" => $article["positionid"], "uid" => $article["uid"]); $uidArr = ArticleUtil::getScopeUidArr($publishScope); $config = array("{sender}" => $user["realname"], "{category}" => $categoryName, "{subject}" => $article["subject"], "{content}" => $this->renderPartial("remindcontent", array("article" => $article, "author" => $user["realname"]), true), "{url}" => Ibos::app()->urlManager->createUrl("article/default/index", array("op" => "show", "articleid" => $articleId))); if (0 < count($uidArr)) { Notify::model()->sendNotify($uidArr, "article_message", $config, $uid); } $wbconf = WbCommonUtil::getSetting(true); if (isset($wbconf["wbmovement"]["article"]) && $wbconf["wbmovement"]["article"] == 1) { $publishScope = array("deptid" => $article["deptid"], "positionid" => $article["positionid"], "uid" => $article["uid"]); $data = array("title" => Ibos::lang("Feed title", "", array("{subject}" => $article["subject"], "{url}" => Ibos::app()->urlManager->createUrl("article/default/index", array("op" => "show", "articleid" => $articleId)))), "body" => $article["subject"], "actdesc" => Ibos::lang("Post news"), "userid" => $publishScope["uid"], "deptid" => $publishScope["deptid"], "positionid" => $publishScope["positionid"]); if ($_POST["type"] == self::ARTICLE_TYPE_PICTURE) { $type = "postimage"; $picids = explode(",", $pidids); $data["attach_id"] = array_shift($picids); } else { $type = "post"; } WbfeedUtil::pushFeed(Ibos::app()->user->uid, "article", "article", $articleId, $data, $type); } UserUtil::updateCreditByAction("addarticle", $uid); } elseif ($article["status"] == "2") { $this->SendPending($article, $uid); } $this->success(Ibos::lang("Save succeed", "message"), $this->createUrl("default/index")); } else { $this->{$option}(); } }