public function actionAdd() { if (!Ibos::app()->request->getIsAjaxRequest()) { $this->error(IBos::lang("Parameters error", "error"), $this->createUrl("schedule/index")); } if (!$this->checkAddPermission()) { $this->ajaxReturn(array("isSuccess" => false, "msg" => Ibos::lang("No permission to add schedule"))); } $getStartTime = EnvUtil::getRequest("CalendarStartTime"); $sTime = empty($getStartTime) ? date("y-m-d h:i", time()) : $getStartTime; $getEndTime = EnvUtil::getRequest("CalendarEndTime"); $eTime = empty($getEndTime) ? date("y-m-d h:i", time()) : $getEndTime; $getTitle = EnvUtil::getRequest("CalendarTitle"); $title = empty($getTitle) ? "" : $getTitle; if ($this->uid != $this->upuid) { $title .= " (" . User::model()->fetchRealnameByUid($this->upuid) . ")"; } $getIsAllDayEvent = EnvUtil::getRequest("IsAllDayEvent"); $isAllDayEvent = empty($getIsAllDayEvent) ? 0 : intval($getIsAllDayEvent); $getCategory = EnvUtil::getRequest("Category"); $category = empty($getCategory) ? -1 : $getCategory; $schedule = array("uid" => $this->uid, "subject" => $title, "starttime" => CalendarUtil::js2PhpTime($sTime), "endtime" => CalendarUtil::js2PhpTime($eTime), "isalldayevent" => $isAllDayEvent, "category" => $category, "uptime" => time(), "upuid" => $this->upuid); $addId = Calendars::model()->add($schedule, true); if ($addId) { $ret["isSuccess"] = true; $ret["msg"] = "success"; $ret["data"] = intval($addId); if ($this->upuid != $this->uid) { $config = array("{sender}" => User::model()->fetchRealnameByUid($this->upuid), "{subject}" => $title, "{url}" => Ibos::app()->urlManager->createUrl("calendar/schedule/index")); Notify::model()->sendNotify($this->uid, "add_calendar_message", $config, $this->upuid); } } else { $ret["isSuccess"] = false; $ret["msg"] = "fail"; } $this->ajaxReturn($ret); }
public function updateSchedule($calendarid, $st, $et, $sj, $cg, $su = null) { $modifyData = array("starttime" => CalendarUtil::js2PhpTime($st), "endtime" => CalendarUtil::js2PhpTime($et), "subject" => $sj, "category" => $cg, "status" => $su); if (is_null($su)) { unset($modifyData["status"]); } $modifyResult = $this->modify($calendarid, $modifyData); if ($modifyResult) { $ret["isSuccess"] = true; $ret["msg"] = "操作成功"; } else { $ret["isSuccess"] = false; $ret["msg"] = "操作失败"; } return $ret; }