Пример #1
0
 public function actionPost()
 {
     if (EnvUtil::submitCheck("formhash")) {
         $return = array("data" => Ibos::lang("Operation succeed", "message"), "IsSuccess" => true);
         if (empty($_POST["touid"])) {
             $return["data"] = Ibos::lang("Message receiver cannot be empty");
             $return["IsSuccess"] = false;
             $this->ajaxReturn($return);
         }
         if (trim(StringUtil::filterCleanHtml($_POST["content"])) == "") {
             $return["data"] = Ibos::lang("Message content cannot be empty");
             $return["IsSuccess"] = false;
             $this->ajaxReturn($return);
         }
         $_POST["touid"] = implode(",", StringUtil::getUid($_POST["touid"]));
         if (isset($_POST["type"])) {
             !in_array($_POST["type"], array(MessageContent::ONE_ON_ONE_CHAT, MessageContent::MULTIPLAYER_CHAT)) && ($_POST["type"] = null);
         } else {
             $_POST["type"] = null;
         }
         $_POST["content"] = StringUtil::filterDangerTag($_POST["content"]);
         $res = MessageContent::model()->postMessage($_POST, Yii::app()->user->uid);
         if ($res) {
             $this->ajaxReturn($return);
         } else {
             $return["IsSuccess"] = false;
             $return["data"] = MessageContent::model()->getError("message");
             $this->ajaxReturn($return);
         }
     }
 }
Пример #2
0
 public static function setPosition($positionId, $users)
 {
     $oldUids = User::model()->fetchUidByPosId($positionId, false);
     $userId = explode(",", trim($users, ","));
     $newUids = StringUtil::getUid($userId);
     $delDiff = array_diff($oldUids, $newUids);
     $addDiff = array_diff($newUids, $oldUids);
     if (!empty($addDiff) || !empty($delDiff)) {
         $updateUser = false;
         $userData = self::loadUser();
         if ($addDiff) {
             foreach ($addDiff as $newUid) {
                 $record = $userData[$newUid];
                 if (empty($record["positionid"])) {
                     User::model()->modify($newUid, array("positionid" => $positionId));
                     $updateUser = true;
                 } elseif (strcmp($record["positionid"], $positionId) !== 0) {
                     PositionRelated::model()->add(array("positionid" => $positionId, "uid" => $newUid), false, true);
                 }
             }
         }
         if ($delDiff) {
             foreach ($delDiff as $diffId) {
                 $record = $userData[$diffId];
                 PositionRelated::model()->delete("`positionid` = :positionid AND `uid` = :uid", array(":positionid" => $positionId, ":uid" => $diffId));
                 if (strcmp($positionId, $record["positionid"]) == 0) {
                     User::model()->modify($diffId, array("positionid" => 0));
                     $updateUser = true;
                 }
             }
         }
         $mainNumber = User::model()->count("`positionid` = :positionid", array(":positionid" => $positionId));
         $auxiliaryNumber = PositionRelated::model()->countByPositionId($positionId);
         Position::model()->modify($positionId, array("number" => (int) $mainNumber + $auxiliaryNumber));
         $updateUser && CacheUtil::update("users");
         OrgUtil::update();
     }
 }
Пример #3
0
 protected function dealWithSpecialParams()
 {
     $_POST["upuid"] = implode(",", StringUtil::getUid($_POST["upuid"]));
     $_POST["deptid"] = implode(",", StringUtil::getId($_POST["deptid"]));
     $_POST["positionid"] = implode(",", StringUtil::getId($_POST["positionid"]));
 }
Пример #4
0
 public static function mergeSearchCondition($search, $uid)
 {
     $condition = "(eb.fromid = {$uid} OR e.toid = {$uid})";
     $keyword = stripcslashes($search["keyword"]);
     $pos = isset($search["pos"]) ? $search["pos"] : "all";
     $folder = isset($search["folder"]) ? $search["folder"] : 0;
     $setAttach = isset($search["attachment"]) && $search["attachment"] !== "-1";
     if ($folder == "allbynoarchive") {
         $queryArchiveId = 0;
         $folder = 0;
     } elseif ($folder == "all") {
         $ids = Yii::app()->setting->get("setting/emailtableids");
         $queryArchiveId = $ids;
         $folder = 0;
     } elseif (strpos($folder, "archive_") !== false) {
         $queryArchiveId = intval(preg_replace("/^archive_(\\d+)/", "", $folder));
         $folder = 0;
     } else {
         $queryArchiveId = 0;
         $folder = intval($folder);
     }
     if (!empty($keyword)) {
         $allPos = $pos == "all";
         $posWhereJoin = $allPos ? " OR " : " AND ";
         $posWhere = "";
         if ($pos == "content" || !empty($pos)) {
             if ($pos == "subject" || $allPos) {
                 $posWhere .= $posWhereJoin . "eb.subject LIKE '%{$keyword}%'";
             }
             if ($pos == "content" || $allPos) {
                 $posWhere .= $posWhereJoin . "eb.content LIKE '%{$keyword}%'";
             }
             if ($pos == "attachment" || $allPos) {
                 $containAttach = isset($search["attachment"]) && $search["attachment"] !== "0";
                 if ($containAttach) {
                     $kwBodyIds = Email::model()->fetchAllBodyIdByKeywordFromAttach($keyword, $condition, $queryArchiveId);
                     if (0 < count($kwBodyIds)) {
                         $posWhere .= $posWhereJoin . "FIND_IN_SET(eb.bodyid,'" . implode(",", $kwBodyIds) . "')";
                     } else {
                         return array("condition" => "1=0", "archiveId" => $queryArchiveId);
                     }
                 } else {
                     return array("condition" => "1=0", "archiveId" => $queryArchiveId);
                 }
             }
             if ($allPos) {
                 $condition .= " AND (" . preg_replace("/^" . $posWhereJoin . "/", "", $posWhere) . ")";
             } else {
                 $condition .= $posWhere;
             }
         }
         if ($folder) {
             if ($folder == 1) {
                 $condition .= " AND (e.fid = 1 AND e.isdel = 0)";
             } elseif ($folder == 3) {
                 $condition .= " AND (eb.issend = 1 AND eb.issenderdel != 1 AND e.isweb=0)";
             } else {
                 $condition .= " AND (e.fid = {$folder} AND e.isdel = 0)";
             }
         }
         if (isset($search["dateRange"]) && $search["dateRange"] !== "-1") {
             $dateRange = intval($search["dateRange"]);
             $endTime = TIMESTAMP;
             $startTime = strtotime("- {$dateRange}day", $endTime);
             $condition .= " AND (eb.sendtime BETWEEN {$startTime} AND {$endTime})";
         }
         if (isset($search["readStatus"]) && $search["readStatus"] !== "-1") {
             $readStatus = intval($search["readStatus"]);
             $condition .= " AND e.isread = {$readStatus}";
         }
         if ($setAttach) {
             if ($search["attachment"] == "0") {
                 $condition .= " AND eb.attachmentid = ''";
             } elseif ($search["attachment"] == "1") {
                 $condition .= " AND eb.attachmentid != ''";
             }
         }
         if (isset($search["sender"]) && !empty($search["sender"])) {
             $sender = StringUtil::getUid($search["sender"]);
             $condition .= " AND eb.fromid = " . implode(",", $sender);
         }
         if (isset($search["recipient"]) && !empty($search["recipient"])) {
             $recipient = StringUtil::getUid($search["recipient"]);
             $condition .= " AND e.toid = " . implode(",", $recipient);
         }
         return array("condition" => $condition, "archiveId" => $queryArchiveId);
     }
 }
Пример #5
0
 protected function getProcessUserList($flowID, $processID = 0, $value = "", $single = false)
 {
     $autoValue = "";
     $ids = array();
     if ($single) {
         $process = FlowProcess::model()->fetchProcess($flowID, $processID);
         $this->getProcessUser($process, $ids);
     } else {
         $allProcess = FlowProcess::model()->fetchAllByFlowId($flowID);
         foreach ($allProcess as $process) {
             $this->getProcessUser($process, $ids);
         }
     }
     if (!empty($ids)) {
         $uids = StringUtil::getUid($ids);
         foreach (User::model()->fetchAllByUids($uids) as $user) {
             $selected = $value == $user["uid"] ? "selected" : "";
             $autoValue .= "<option {$selected} value='" . $user["uid"] . "'>" . $user["realname"] . "</option>";
         }
     }
     return $autoValue;
 }
Пример #6
0
 protected function dealWithSpecialParams()
 {
     $_POST["manager"] = implode(",", StringUtil::getUid($_POST["manager"]));
     $_POST["leader"] = implode(",", StringUtil::getUid($_POST["leader"]));
     $_POST["subleader"] = implode(",", StringUtil::getUid($_POST["subleader"]));
 }