Exemple #1
0
 public static function handleListData($data)
 {
     $reminds = AssignmentRemind::model()->fetchAllByUid(Ibos::app()->user->uid);
     foreach ($data as $k => $assignment) {
         $data[$k] = self::handleShowData($assignment);
         $aid = $assignment["assignmentid"];
         $data[$k]["remindtime"] = in_array($aid, array_keys($reminds)) ? $reminds[$aid] : 0;
         if ($assignment["stamp"] != 0) {
             $path = Stamp::model()->fetchIconById($assignment["stamp"]);
             $data[$k]["stampPath"] = FileUtil::fileName(Stamp::STAMP_PATH . $path);
         }
     }
     return $data;
 }
 protected function remind($assignmentId)
 {
     if (EnvUtil::submitCheck("remindsubmit")) {
         if ($this->getIsInstallCalendar()) {
             $uid = Ibos::app()->user->uid;
             $remindTime = strtotime(EnvUtil::getRequest("remindTime"));
             $remindContent = EnvUtil::getRequest("remindContent");
             $calendar = array("subject" => $remindContent, "starttime" => $remindTime, "endtime" => $remindTime + 1800, "uid" => $uid, "upuid" => $uid, "lock" => 1, "category" => 5);
             $oldCalendarids = AssignmentRemind::model()->fetchCalendarids($assignmentId, $uid);
             Calendars::model()->deleteAll(sprintf("uid = %d AND FIND_IN_SET(`calendarid`, '%s')", $uid, implode(",", $oldCalendarids)));
             $cid = Calendars::model()->add($calendar, true);
             AssignmentRemind::model()->deleteAll("assignmentid = {$assignmentId} AND uid = {$uid}");
             AssignmentRemind::model()->add(array("assignmentid" => $assignmentId, "calendarid" => $cid, "remindtime" => $remindTime, "uid" => $uid, "content" => $remindContent));
             $this->ajaxReturn(array("isSuccess" => true, "msg" => Ibos::lang("Operation succeed", "message")));
         } else {
             $this->ajaxReturn(array("isSuccess" => false, "msg" => Ibos::lang("Not installed calendar to support remind")));
         }
     } else {
         $remind = AssignmentRemind::model()->fetch(sprintf("uid = %d AND assignmentid = %d", Ibos::app()->user->uid, $assignmentId));
         $remindtime = empty($remind) ? TIMESTAMP : $remind["remindtime"];
         $params = array("reminddate" => date("Y-m-d", $remindtime), "remindtime" => date("H:i", $remindtime), "content" => empty($remind) ? "" : $remind["content"], "lang" => Ibos::getLangSource("assignment.default"));
         $remindAlias = "application.modules.assignment.views.default.remind";
         $editView = $this->renderPartial($remindAlias, $params, true);
         echo $editView;
     }
 }
Exemple #3
0
 public function actionShow()
 {
     $op = EnvUtil::getRequest("op");
     if (empty($op)) {
         $assignmentId = intval(EnvUtil::getRequest("assignmentId"));
         $checkRes = $this->checkAvailableById($assignmentId);
         if (!$checkRes["isSuccess"]) {
             $this->error($checkRes["msg"], $this->createUrl("unfinished/index"));
         }
         $assignment = Assignment::model()->fetchByPk($assignmentId);
         if (!$this->checkShowPermissions($assignment) && !$this->checkIsSup($assignment)) {
             $this->error(Ibos::lang("You donot have permission to view"), $this->createUrl("unfinished/index"));
         }
         if (!empty($assignment["attachmentid"])) {
             $assignment["attach"] = AttachUtil::getAttach($assignment["attachmentid"]);
         }
         if (!empty($assignment["stamp"])) {
             $assignment["stampUrl"] = Stamp::model()->fetchStampById($assignment["stamp"]);
         }
         $apply = AssignmentApply::model()->fetchByAttributes(array("assignmentid" => $assignmentId));
         $applyData = $this->handleApplyData($assignmentId, $apply);
         $isDesigneeuid = $this->checkIsDesigneeuid($assignment["designeeuid"]);
         $isChargeuid = $this->checkIsChargeuid($assignment["chargeuid"]);
         if ($isChargeuid && $assignment["status"] == 0) {
             Assignment::model()->modify($assignmentId, array("status" => 1));
             $assignment["status"] = 1;
         }
         AssignmentLog::model()->addLog($assignmentId, "view", Ibos::lang("View the assignment"));
         $participantuidArr = explode(",", $assignment["participantuid"]);
         $participantuid = array_filter($participantuidArr, create_function("\$v", "return !empty(\$v);"));
         $reminds = AssignmentRemind::model()->fetchAllByUid(Ibos::app()->user->uid);
         $assignment["remindtime"] = in_array($assignmentId, array_keys($reminds)) ? $reminds[$assignmentId] : 0;
         $params = array("isDesigneeuid" => $isDesigneeuid, "isChargeuid" => $isChargeuid, "designee" => User::model()->fetchByUid($assignment["designeeuid"]), "charge" => User::model()->fetchByUid($assignment["chargeuid"]), "participantCount" => count($participantuid), "participant" => User::model()->fetchRealnamesByUids($participantuid, "、"), "assignment" => AssignmentUtil::handleShowData($assignment), "applyData" => CJSON::encode($applyData));
         $this->setPageTitle(Ibos::lang("See the assignment details"));
         $this->setPageState("breadCrumbs", array(array("name" => Ibos::lang("Assignment"), "url" => $this->createUrl("unfinished/index")), array("name" => Ibos::lang("Assignment details"))));
         $this->render("show", $params);
     } else {
         $this->{$op}();
     }
 }