コード例 #1
0
 /**
  * save new calendar
  *
  * @access protected
  */
 protected function save()
 {
     global $ilUser;
     include_once './Services/Calendar/classes/class.ilCalendarCategory.php';
     $category = new ilCalendarCategory(0);
     $category->setTitle(ilUtil::stripSlashes($_POST['title']));
     $category->setColor('#' . ilUtil::stripSlashes($_POST['color']));
     $category->setLocationType((int) $_POST['type_rl']);
     $category->setRemoteUrl(ilUtil::stripSlashes($_POST['remote_url']));
     $category->setRemoteUser(ilUtil::stripSlashes($_POST['remote_user']));
     $category->setRemotePass(ilUtil::stripSlashes($_POST['remote_pass']));
     if (isset($_POST['type']) and $_POST['type'] == ilCalendarCategory::TYPE_GLOBAL) {
         $category->setType((int) $_POST['type']);
         $category->setObjId(0);
     } else {
         $category->setType(ilCalendarCategory::TYPE_USR);
         $category->setObjId($ilUser->getId());
     }
     if (!$category->validate()) {
         ilUtil::sendFailure($this->lng->txt('err_check_input'));
         $this->add();
         return false;
     }
     $category->add();
     try {
         if ($category->getLocationType() == ilCalendarCategory::LTYPE_REMOTE) {
             $this->doSynchronisation($category);
         }
     } catch (Exception $e) {
         // Delete calendar if creation failed
         $category->delete();
         ilUtil::sendFailure($e->getMessage());
         $this->manage();
         return true;
     }
     ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
     // $this->ctrl->returnToParent($this);
     $this->manage(true);
 }