public function actionSave() { $uid = Ibos::app()->user->uid; $originalPlan = $planOutside = ""; if (array_key_exists("originalPlan", $_POST)) { $originalPlan = $_POST["originalPlan"]; } if (array_key_exists("planOutside", $_POST)) { $planOutside = array_filter($_POST["planOutside"], create_function("\$v", "return !empty(\$v[\"content\"]);")); } if (!empty($originalPlan)) { foreach ($originalPlan as $key => $value) { DiaryRecord::model()->modify($key, array("schedule" => $value)); } } $shareUidArr = isset($_POST["shareuid"]) ? StringUtil::getId($_POST["shareuid"]) : array(); $diary = array("uid" => $uid, "diarytime" => strtotime($_POST["todayDate"]), "nextdiarytime" => strtotime($_POST["plantime"]), "addtime" => TIMESTAMP, "content" => $_POST["diaryContent"], "shareuid" => implode(",", $shareUidArr), "readeruid" => "", "remark" => "", "attention" => ""); $diaryId = Diary::model()->add($diary, true); if (!empty($planOutside)) { DiaryRecord::model()->addRecord($planOutside, $diaryId, strtotime($_POST["todayDate"]), $uid, "outside"); } $plan = array_filter($_POST["plan"], create_function("\$v", "return !empty(\$v[\"content\"]);")); DiaryRecord::model()->addRecord($plan, $diaryId, strtotime($_POST["plantime"]), $uid, "new"); UserUtil::updateCreditByAction("adddiary", $uid); $this->ajaxReturn($diaryId, "JSONP"); }
public function fetchAllByPlantime($plantime, $uid = 0) { $uid = empty($uid) ? Ibos::app()->user->uid : $uid; $records = DiaryRecord::model()->fetchAll(array("condition" => "plantime=:plantime AND uid=:uid", "order" => "recordid ASC", "params" => array(":plantime" => $plantime, ":uid" => $uid))); return $records; }
public function fetchDiaryRecord($diary) { $data = array(); $todayRecordList = DiaryRecord::model()->fetchAll(array("condition" => "plantime=:plantime AND uid=:uid", "params" => array(":plantime" => $diary["diarytime"], ":uid" => $diary["uid"]), "order" => "recordid ASC")); $data["originalPlanList"] = array(); $data["outsidePlanList"] = array(); foreach ($todayRecordList as $diaryRecord) { if ($diaryRecord["planflag"] == 1) { $data["originalPlanList"][] = $diaryRecord; } else { $data["outsidePlanList"][] = $diaryRecord; } } $recordList = DiaryRecord::model()->fetchAll(array("condition" => "diaryid=:diaryid AND uid=:uid AND planflag=:planflag", "params" => array(":diaryid" => $diary["diaryid"], ":uid" => $diary["uid"], ":planflag" => 1), "order" => "recordid ASC")); $data["tomorrowPlanList"] = $recordList; return $data; }
public function actionDel() { if (Ibos::app()->request->isAjaxRequest) { $diaryids = EnvUtil::getRequest("diaryids"); $uid = Ibos::app()->user->uid; if (empty($diaryids)) { $this->ajaxReturn(array("isSuccess" => false, "msg" => Ibos::lang("Select at least one"))); } $pk = ""; if (strpos($diaryids, ",")) { $diaryids = trim($diaryids, ","); $pk = explode(",", $diaryids); } else { $pk = array($diaryids); } $diarys = Diary::model()->fetchAllByPk($pk); foreach ($diarys as $diary) { if (!ICDiary::checkReadScope($uid, $diary)) { $this->ajaxReturn(array("isSuccess" => false, "msg" => Ibos::lang("You do not have permission to delete the log"))); } } $aids = Diary::model()->fetchAllAidByPks($pk); if ($aids) { AttachUtil::delAttach($aids); } $isInstallCalendar = ModuleUtil::getIsEnabled("calendar"); if ($isInstallCalendar) { Calendars::model()->deleteALL("`calendarid` IN(select `cid` from {{calendar_record}} where FIND_IN_SET(`did`, '{$diaryids}')) "); CalendarRecord::model()->deleteAll("did IN ({$diaryids})"); } Diary::model()->deleteByPk($pk); DiaryRecord::model()->deleteAll("diaryid IN ({$diaryids})"); DiaryStats::model()->deleteAll("diaryid IN ({$diaryids})"); $this->ajaxReturn(array("isSuccess" => true, "msg" => Ibos::lang("Del succeed", "message"))); } }