Beispiel #1
0
 public function addRecord($plan, $diaryId, $planTime, $uid, $type)
 {
     foreach ($plan as $value) {
         $diaryRecord = array("diaryid" => $diaryId, "content" => htmlspecialchars($value["content"]), "planflag" => $type == "outside" ? 0 : 1, "schedule" => isset($value["schedule"]) ? $value["schedule"] : 0, "plantime" => $planTime, "flag" => isset($value["schedule"]) && $value["schedule"] == 10 ? 1 : 0, "uid" => $uid, "timeremind" => isset($value["timeremind"]) ? $value["timeremind"] : "");
         $rid = $this->add($diaryRecord, true);
         $isInstallCalendar = ModuleUtil::getIsEnabled("calendar");
         if ($isInstallCalendar && isset($value["timeremind"]) && !empty($value["timeremind"])) {
             $timeArr = explode(",", $value["timeremind"]);
             $st = $planTime + $timeArr[0] * 60 * 60;
             $et = $planTime + $timeArr[1] * 60 * 60;
             $calendar = array("subject" => $diaryRecord["content"], "starttime" => $st, "endtime" => $et, "uid" => $uid, "upuid" => $uid, "lock" => 1, "category" => 3, "isfromdiary" => 1);
             $cid = Calendars::model()->add($calendar, true);
             CalendarRecord::model()->add(array("rid" => $rid, "cid" => $cid, "did" => $diaryId));
         }
     }
 }
Beispiel #2
0
 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")));
     }
 }