Example #1
0
 public static function sendWebMail($toUser, $body, $web)
 {
     $user = User::model()->fetchByUid($web["uid"]);
     $password = StringUtil::authCode($web["password"], "DECODE", $user["salt"]);
     $mailer = Yii::createComponent("application.modules.email.extensions.mailer.EMailer");
     $mailer->IsSMTP();
     $mailer->SMTPDebug = 0;
     $mailer->Host = $web["smtpserver"];
     $mailer->Port = $web["smtpport"];
     $mailer->CharSet = "UTF-8";
     if ($web["smtpssl"]) {
         $mailer->SMTPSecure = "ssl";
     }
     $mailer->SMTPAuth = true;
     $mailer->Username = $web["username"];
     $mailer->Password = $password;
     $mailer->setFrom($web["address"], $web["nickname"]);
     foreach (explode(";", $toUser) as $address) {
         $mailer->addAddress($address);
     }
     $mailer->Subject = $body["subject"];
     $mailer->msgHTML($body["content"]);
     $mailer->AltBody = "This is a plain-text message body";
     if (!empty($body["attachmentid"])) {
         $attachs = AttachUtil::getAttachData($body["attachmentid"]);
         $attachUrl = FileUtil::getAttachUrl();
         foreach ($attachs as $attachment) {
             $url = $attachUrl . "/" . $attachment["attachment"];
             if (LOCAL) {
                 $mailer->addAttachment($url, $attachment["filename"]);
             } else {
                 $temp = Ibos::engine()->IO()->file()->fetchTemp($url);
                 $mailer->addAttachment($temp, $attachment["filename"]);
             }
         }
     }
     $status = $mailer->send();
     if ($status) {
         return true;
     } else {
         return $mailer->ErrorInfo;
     }
 }
Example #2
0
 protected function getData($var)
 {
     $data = array();
     $type = isset($var["new"]) ? "new" . $var["type"] : $var["type"];
     switch ($type) {
         case "following":
             $pages = PageUtil::create(1000, WbConst::DEF_LIST_FEED_NUMS);
             if (!empty($var["feedkey"])) {
                 $list = Feed::model()->searchFeed($var["feedkey"], "following", $var["loadId"], $var["nums"], $pages->getOffset());
             } else {
                 $where = "a.isdel = 0 AND " . WbfeedUtil::getViewCondition($this->uid, "a.");
                 if (isset($var["loadId"]) && 0 < $var["loadId"]) {
                     $where .= " AND a.feedid < '" . intval($var["loadId"]) . "'";
                 }
                 if (!empty($var["feedtype"]) && $var["feedtype"] !== "all") {
                     $where .= " AND a.type = '" . $var["feedtype"] . "'";
                 }
                 $list = Feed::model()->getFollowingFeed($where, $var["nums"], $pages->getOffset());
             }
             break;
         case "all":
             $pages = PageUtil::create(WbConst::MAX_VIEW_FEED_NUMS, WbConst::DEF_LIST_FEED_NUMS);
             if (!empty($var["feedkey"])) {
                 $list = Feed::model()->searchFeed($var["feedkey"], "all", $var["loadId"], $var["nums"], $pages->getOffset());
             } else {
                 $where = "isdel = 0 AND " . WbfeedUtil::getViewCondition($this->uid);
                 if (isset($var["loadId"]) && 0 < $var["loadId"]) {
                     $where .= " AND feedid < '" . intval($var["loadId"]) . "'";
                 }
                 if (!empty($var["feedtype"]) && $var["feedtype"] !== "all") {
                     $where .= " AND type = '" . StringUtil::filterCleanHtml($var["feedtype"]) . "'";
                 }
                 $list = Feed::model()->getList($where, $var["nums"], $pages->getOffset());
             }
             break;
         case "movement":
             $pages = PageUtil::create(WbConst::MAX_VIEW_FEED_NUMS, WbConst::DEF_LIST_FEED_NUMS);
             if (!empty($var["feedkey"])) {
                 $list = Feed::model()->searchFeed($var["feedkey"], "movement", $var["loadId"], $var["nums"], $pages->getOffset());
             } else {
                 $where = "isdel = 0 AND " . WbfeedUtil::getViewCondition($this->uid);
                 if (isset($var["loadId"]) && 0 < $var["loadId"]) {
                     $where .= " AND feedid < '" . intval($var["loadId"]) . "'";
                 }
                 if (!empty($var["feedtype"]) && $var["feedtype"] !== "all") {
                     $where .= " AND module = '" . StringUtil::filterCleanHtml($var["feedtype"]) . "'";
                 } else {
                     $where .= " AND module != 'weibo'";
                 }
                 $list = Feed::model()->getList($where, $var["nums"], $pages->getOffset());
             }
             break;
         case "newmovement":
             if (0 < $var["maxId"]) {
                 $where = sprintf("isdel = 0 AND %s AND feedid > %d", WbfeedUtil::getViewCondition($this->uid), intval($var["maxId"]), $this->uid);
                 $list = Feed::model()->getList($where);
                 $data["count"] = count($list);
             }
             break;
         case "newfollowing":
             $where = "a.isdel = 0 AND " . WbfeedUtil::getViewCondition($this->uid, "a.");
             if (0 < $var["maxId"]) {
                 $where .= " AND a.feedid > '" . intval($var["maxId"]) . "'";
                 $list = Feed::model()->getFollowingFeed($where);
                 $data["count"] = count($list);
             }
             break;
         case "newall":
             if (0 < $var["maxId"]) {
                 $where = sprintf("isdel = 0 AND %s AND feedid > %d AND uid <> %d", WbfeedUtil::getViewCondition($this->uid), intval($var["maxId"]), $this->uid);
                 $list = Feed::model()->getList($where);
                 $data["count"] = count($list);
             }
             break;
         default:
             break;
     }
     if (!isset($var["new"])) {
         $pages->route = "home/index";
     }
     if (!empty($list)) {
         $data["firstId"] = $list[0]["feedid"];
         $data["lastId"] = $list[count($list) - 1]["feedid"];
         $feedids = ConvertUtil::getSubByKey($list, "feedid");
         $diggArr = FeedDigg::model()->checkIsDigg($feedids, $this->uid);
         foreach ($list as &$v) {
             switch ($v["module"]) {
                 case "mobile":
                     break;
                 default:
                     $v["from"] = EnvUtil::getFromClient($v["from"], $v["module"]);
                     break;
             }
             if (isset($v["attach_id"][0])) {
                 $_tmp = AttachUtil::getAttachData($v["attach_id"][0]);
                 $v["attach_url"] = FileUtil::getAttachUrl() . "/" . $_tmp[$v["attach_id"][0]]["attachment"];
             }
             if (isset($v["api_source"]["attach"][0]["attach_url"])) {
                 $v["api_source"]["attach_url"] = $v["api_source"]["attach"][0]["attach_url"];
                 unset($v["api_source"]["attach"]);
                 unset($v["api_source"]["source_body"]);
             }
             unset($v["user_info"]);
             unset($v["body"]);
             unset($v["sourceInfo"]);
             unset($v["api_source"]["source_user_info"]);
             unset($v["api_source"]["avatar_big"]);
             unset($v["api_source"]["avatar_middle"]);
             unset($v["api_source"]["avatar_small"]);
             unset($v["api_source"]["source_url"]);
             unset($v["feeddata"]);
         }
         $data["list"] = $list;
         $data["diggArr"] = $diggArr;
     } else {
         $data["list"] = array();
         $data["firstId"] = $data["lastId"] = 0;
     }
     return $data;
 }
Example #3
0
 public function actionFeed()
 {
     $feedid = intval(EnvUtil::getRequest("feedid"));
     $feedInfo = Feed::model()->get($feedid);
     if (!$feedInfo) {
         $this->error(Ibos::lang("Weibo not exists"));
     }
     if ($feedInfo["isdel"] == "1") {
         $this->error(Ibos::lang("No relate weibo"));
         exit;
     }
     if ($feedInfo["from"] == "1") {
         $feedInfo["from"] = EnvUtil::getFromClient(6, $feedInfo["module"], "3G版");
     } else {
         switch ($feedInfo["module"]) {
             case "mobile":
                 break;
             default:
                 $feedInfo["from"] = EnvUtil::getFromClient($feedInfo["from"], $feedInfo["module"]);
                 break;
         }
     }
     if ($feedInfo["type"] === "postimage") {
         $var = unserialize($feedInfo["feeddata"]);
         $feedInfo["image_body"] = $var["body"];
         if (!empty($var["attach_id"])) {
             $attach = AttachUtil::getAttachData($var["attach_id"]);
             $attachUrl = FileUtil::getAttachUrl();
             foreach ($attach as $ak => $av) {
                 $_attach = array("attach_id" => $av["aid"], "attach_name" => $av["filename"], "attach_url" => FileUtil::fileName($attachUrl . "/" . $av["attachment"]), "extension" => StringUtil::getFileExt($av["filename"]), "size" => $av["filesize"]);
                 $_attach["attach_small"] = WbCommonUtil::getThumbImageUrl($av, WbConst::ALBUM_DISPLAY_WIDTH, WbConst::ALBUM_DISPLAY_HEIGHT);
                 $_attach["attach_middle"] = WbCommonUtil::getThumbImageUrl($av, WbConst::WEIBO_DISPLAY_WIDTH, WbConst::WEIBO_DISPLAY_HEIGHT);
                 $feedInfo["attachInfo"][$ak] = $_attach;
             }
         }
     }
     $diggArr = FeedDigg::model()->checkIsDigg($feedid, Ibos::app()->user->uid);
     $data = array("diggArr" => $diggArr, "fd" => $feedInfo, "assetUrl" => Ibos::app()->assetManager->getAssetsUrl("user"), "moduleAssetUrl" => Ibos::app()->assetManager->getAssetsUrl("weibo"), "colleagues" => $this->getRelation("colleague"));
     if (!$this->getIsMe()) {
         $data["bothfollow"] = $this->getRelation("bothfollow");
         $data["secondfollow"] = $this->getRelation("secondfollow");
     }
     $this->setPageState("breadCrumbs", array(array("name" => Ibos::lang("Enterprise weibo"), "url" => $this->createUrl("home/index")), array("name" => $feedInfo["user_info"]["realname"] . Ibos::lang("sbs feed"), "url" => $this->createUrl("personal/index", array("uid" => $this->getUid()))), array("name" => Ibos::lang("Detail"))));
     $this->render("detail", $data, false, array("user.default"));
 }
Example #4
0
 public function actionEdit()
 {
     $op = EnvUtil::getRequest("op");
     $resumeid = EnvUtil::getRequest("resumeid");
     if (empty($op)) {
         $op = "default";
     }
     if (!in_array($op, array("default", "update", "mark", "status")) || empty($resumeid)) {
         $this->error(Ibos::lang("Parameters error", "error"), $this->createUrl("resume/index"));
     }
     if ($op == "default") {
         $detail = ResumeDetail::model()->fetch("resumeid=:resumeid", array(":resumeid" => $resumeid));
         $detail["birthday"] = date("Y-m-d", $detail["birthday"]);
         $detail["status"] = Resume::model()->fetchStatusByResumeid($detail["resumeid"]);
         $avatarid = $detail["avatarid"];
         if (empty($avatarid)) {
             $detail["avatarUrl"] = "";
         } else {
             $avatar = AttachUtil::getAttachData($avatarid);
             $detail["avatarUrl"] = FileUtil::fileName(FileUtil::getAttachUrl() . "/" . $avatar[$avatarid]["attachment"]);
         }
         if (!empty($detail["attachmentid"])) {
             $detail["attach"] = AttachUtil::getAttach($detail["attachmentid"]);
         }
         $data = array("sidebar" => $this->getSidebar(), "resumeDetail" => $detail, "dashboardConfig" => $this->getDashboardConfig(), "uploadConfig" => AttachUtil::getUploadConfig());
         $data["dashboardConfigToJson"] = CJSON::encode($data["dashboardConfig"]);
         $regulars = Regular::model()->fetchAll();
         $data["regulars"] = CJSON::encode($regulars);
         $this->setPageTitle(Ibos::lang("Edit resume"));
         $this->setPageState("breadCrumbs", array(array("name" => Ibos::lang("Recruitment management"), "url" => $this->createUrl("resume/index")), array("name" => Ibos::lang("Talent management"), "url" => $this->createUrl("resume/index")), array("name" => Ibos::lang("Edit resume"))));
         $this->render("edit", $data);
     } else {
         $this->{$op}();
     }
 }
Example #5
0
 public static function getEmailSize($content, $attachmentId = "")
 {
     $tmpfile = "data/emailsize.temp";
     FileUtil::createFile($tmpfile, $content);
     $emailContentSize = FileUtil::fileSize($tmpfile);
     FileUtil::deleteFile($tmpfile);
     $attFileSize = 0;
     if (!empty($attachmentId)) {
         $attach = AttachUtil::getAttachData($attachmentId, false);
         foreach ($attach as $value) {
             $attFileSize += intval($value["filesize"]);
         }
     }
     return intval($emailContentSize + $attFileSize);
 }
Example #6
0
 protected function getListData()
 {
     if (EnvUtil::submitCheck("formhash")) {
         $runid = intval(EnvUtil::getRequest("runid"));
         $flowid = intval(EnvUtil::getRequest("flowid"));
         $userType = EnvUtil::getRequest("usertype");
         $runName = StringUtil::filterCleanHtml(EnvUtil::getRequest("runname"));
         $toid = !empty($_POST["toid"]) ? implode(",", StringUtil::getId($_POST["toid"])) : "";
     } else {
         $runid = 0;
         $userType = $runName = $toid = "";
         $flowid = "all";
     }
     $flowIds = WfQueryUtil::getMyFlowIDs($this->uid);
     if (empty($flowIds)) {
         $flowIds = array(0);
     }
     $condition = array("and", "fr.delflag = 0", array("in", "fr.flowid", $flowIds), array("in", "frp.flag", array(1, 2)), "(frp.opflag = 1 OR frp.topflag = 2)");
     $field = "frp.runid,frp.processid,frp.uid,frp.flag,frp.processtime,frp.flowprocess,fr.attachmentid,fr.focususer,ft.freeother";
     if ($flowid !== "all") {
         $condition[] = "ft.flowid = " . $flowid;
     }
     if (!empty($runid)) {
         $condition[] = "fr.runid = " . $runid;
     }
     if (!empty($runName)) {
         $condition[] = " fr.name LIKE '%{$runName}%'";
     }
     if ($toid != "") {
         if ($userType == "opuser") {
             $condition[] = "frp.uid = {$toid}";
         } else {
             $condition[] = "fr.beginuser = {$toid}";
         }
     }
     $lang = Ibos::getLangSource("workflow.default");
     $count = Ibos::app()->db->createCommand()->select("count(fr.runid)")->from("{{flow_run}} fr")->leftJoin("{{flow_type}} ft", "fr.flowid = ft.flowid")->leftJoin("{{flow_run_process}} frp", "fr.runid = frp.runid")->where($condition)->queryScalar();
     $pages = PageUtil::create($count, $this->getListPageSize());
     $list = Ibos::app()->db->createCommand()->select($field)->from("{{flow_run}} fr")->leftJoin("{{flow_type}} ft", "fr.flowid = ft.flowid")->leftJoin("{{flow_run_process}} frp", "fr.runid = frp.runid")->where($condition)->group("frp.runid")->order("frp.runid DESC")->limit($pages->getLimit())->offset($pages->getOffset())->queryAll();
     foreach ($list as $k => &$rec) {
         $temp = Ibos::app()->db->createCommand()->select("ft.flowid,ft.freeother,fr.name as runName,ft.name as typeName,ft.type,ft.sort")->from("{{flow_type}} ft")->leftJoin("{{flow_run}} fr", "fr.flowid = ft.flowid")->where("fr.runid = " . $rec["runid"])->queryRow();
         if ($temp) {
             $rec = array_merge($rec, $temp);
         } else {
             continue;
         }
         if ($temp["type"] == 1) {
             $fp = FlowProcess::model()->fetchProcess($temp["flowid"], $rec["flowprocess"]);
             if ($fp) {
                 $rec["stepname"] = $fp["name"];
             } else {
                 $rec["stepname"] = $lang["Process steps already deleted"];
             }
         } else {
             $rec["stepname"] = Ibos::lang("Step", "", array("{step}" => $rec["processid"]));
         }
         if ($rec["flag"] == FlowConst::PRCS_UN_RECEIVE) {
             $deliverTime = FlowRunProcess::model()->fetchDeliverTime($rec["runid"], $rec["flowprocess"]);
             if ($deliverTime) {
                 $prcsBeginTime = $deliverTime;
             }
         } else {
             $prcsBeginTime = $rec["processtime"];
         }
         if (!isset($prcsBeginTime) || $prcsBeginTime == 0) {
             $prcsBeginTime = TIMESTAMP;
         }
         $usedTime = TIMESTAMP - $prcsBeginTime;
         $rec["timestr"] = WfCommonUtil::getTime($usedTime, "dhi");
         if (!empty($rec["attachmentid"])) {
             $rec["attachdata"] = AttachUtil::getAttachData($rec["attachmentid"]);
         }
         $rec["focus"] = StringUtil::findIn($this->uid, $rec["focususer"]);
         $rec["user"] = User::model()->fetchByUid($rec["uid"]);
         $rec["key"] = WfCommonUtil::param(array("flowid" => $rec["flowid"], "runid" => $rec["runid"], "processid" => $rec["processid"], "flowprocess" => $rec["flowprocess"]));
         if (empty($rec["user"])) {
             unset($list[$k]);
         }
     }
     return array("list" => $list, "pages" => $pages);
 }
Example #7
0
 public function getFeedInfo($id, $forApi = false)
 {
     $data = CacheUtil::get("feed_info_" . $id);
     if ($data !== false && $forApi === false) {
         return $data;
     }
     $data = Ibos::app()->db->createCommand()->from("{{feed}} a")->leftJoin("{{feed_data}} b", "a.feedid = b.feedid")->where("a.feedid = " . $id)->queryRow();
     $fd = unserialize($data["feeddata"]);
     $userInfo = User::model()->fetchByUid($data["uid"]);
     $data["ctime"] = ConvertUtil::formatDate($data["ctime"], "n月d日H:i");
     $data["content"] = $forApi ? StringUtil::parseForApi($fd["body"]) : $fd["body"];
     $data["realname"] = $userInfo["realname"];
     $data["avatar_big"] = $userInfo["avatar_big"];
     $data["avatar_middle"] = $userInfo["avatar_middle"];
     $data["avatar_small"] = $userInfo["avatar_small"];
     unset($data["feeddata"]);
     if ($data["type"] == "repost") {
         $data["transpond_id"] = $data["rowid"];
         $data["transpond_data"] = $this->getFeedInfo($data["transpond_id"], $forApi);
     }
     if (!empty($fd["attach_id"])) {
         $data["has_attach"] = 1;
         $attach = AttachUtil::getAttachData($fd["attach_id"]);
         $attachUrl = FileUtil::getAttachUrl();
         foreach ($attach as $ak => $av) {
             $_attach = array("attach_id" => $av["aid"], "attach_name" => $av["filename"], "attach_url" => FileUtil::fileName($attachUrl . "/" . $av["attachment"]), "extension" => StringUtil::getFileExt($av["filename"]), "size" => $av["filesize"]);
             if ($data["type"] == "postimage") {
                 $_attach["attach_small"] = WbCommonUtil::getThumbImageUrl($av, WbConst::ALBUM_DISPLAY_WIDTH, WbConst::ALBUM_DISPLAY_HEIGHT);
                 $_attach["attach_middle"] = WbCommonUtil::getThumbImageUrl($av, WbConst::WEIBO_DISPLAY_WIDTH, WbConst::WEIBO_DISPLAY_HEIGHT);
             }
             $data["attach"][] = $_attach;
         }
     } else {
         $data["has_attach"] = 0;
     }
     $data["feedType"] = $data["type"];
     $feedInfo = $this->get($id);
     $data["source_body"] = $feedInfo["body"];
     $data["api_source"] = $feedInfo["api_source"];
     CacheUtil::set("feed_info_" . $id, $data, 60);
     if ($forApi) {
         $data["content"] = StringUtil::realStripTags($data["content"]);
         unset($data["isdel"]);
         unset($data["fromdata"]);
         unset($data["table"]);
         unset($data["rowid"]);
         unset($data["source_body"]);
     }
     return $data;
 }
Example #8
0
 protected function getListData()
 {
     $param = $this->getListFilterParam();
     $field = "fr.runid,fr.name as runName,fr.begintime,fr.endtime,ft.name as typeName,fr.attachmentid,fr.focususer,fr.beginuser,ft.flowid,ft.type,ft.freeother";
     $condition = array("and", "fr.delflag = 0");
     if ($param["flowid"]) {
         $condition[] = "ft.flowid = " . $param["flowid"];
         $isManager = FlowPermission::model()->fetchPermission($this->uid, $param["flowid"], array(0, 1));
     } else {
         $isManager = false;
     }
     if ($param["start"]) {
         $condition[] = "fr.begintime >= " . $param["start"];
     }
     if ($param["end"]) {
         $condition[] = "fr.endtime <= " . $param["end"];
     }
     $flowIds = WfQueryUtil::getMyFlowIDs($this->uid);
     $myRuns = FlowRun::model()->fetchAllMyRunID($this->uid, $param["flowid"]);
     if ($param["scope"] == "none" && Ibos::app()->user->isadministrator != 1) {
         $condition[] = sprintf("(FIND_IN_SET(fr.runid,'%s') OR FIND_IN_SET(ft.flowid,'%s'))", implode(",", $myRuns), implode(",", $flowIds));
     } elseif ($param["scope"] == "start") {
         $beginUser = $this->uid;
     } elseif ($param["scope"] == "handle") {
         $condition[] = array("in", "fr.runid", $myRuns);
     } else {
         if ($param["scope"] == "manage" && Ibos::app()->user->isadministrator != 1) {
             $condition[] = sprintf("FIND_IN_SET('%s',ft.flowid)", implode(",", $flowIds));
         } elseif ($param["scope"] == "focus") {
             $implodeStr = WfCommonUtil::implodeSql($this->uid, "fr.focususer");
             $condition[] = sprintf("fr.focususer = %d%s", $this->uid, $implodeStr);
         } elseif ($param["scope"] == "custom") {
             if (Ibos::app()->user->isadministrator != 1) {
                 $condition[] = sprintf("FIND_IN_SET(ft.flowid,'%s')", implode(",", $flowIds));
             }
             $beginUser = implode(",", StringUtil::getId($param["beginuser"]));
         } elseif (Ibos::app()->user->isadministrator != 1) {
             $this->error(Ibos::lang("Parameters error", "error"));
         }
     }
     if ($param["type"] !== "all") {
         if ($param["type"] == "perform") {
             $condition[] = "fr.endtime = 0";
         } else {
             $condition[] = "fr.endtime != 0";
         }
     }
     if (isset($beginUser)) {
         $condition[] = "fr.beginuser = "******"count(fr.runid)")->from("{{flow_run}} fr")->leftJoin("{{flow_type}} ft", "fr.flowid = ft.flowid")->where($condition)->queryScalar();
     $pages = PageUtil::create($count, $this->getListPageSize());
     $list = Ibos::app()->db->createCommand()->select($field)->from("{{flow_run}} fr")->leftJoin("{{flow_type}} ft", "fr.flowid = ft.flowid")->where($condition)->order("fr.runid DESC")->limit($pages->getLimit())->offset($pages->getOffset())->queryAll();
     foreach ($list as &$rec) {
         if (!empty($rec["attachmentid"])) {
             $rec["attachdata"] = AttachUtil::getAttachData($rec["attachmentid"]);
         }
         $rec["focus"] = StringUtil::findIn($this->uid, $rec["focususer"]);
         $rec["user"] = User::model()->fetchByUid($rec["beginuser"]);
         $rec["key"] = WfCommonUtil::param(array("flowid" => $rec["flowid"], "runid" => $rec["runid"]));
         $rec["begin"] = ConvertUtil::formatDate($rec["begintime"], "n月j日 H:i");
     }
     return array("list" => $list, "pages" => $pages, "advanceOpt" => $isManager || Ibos::app()->user->isadministrator == 1);
 }