Пример #1
0
 /**
  * Saves blog post in db
  * @access public
  */
 public function save()
 {
     Logger::log("Enter: CNBlogPost::save");
     Logger::log("Calling: CNContent::save");
     parent::save();
     Logger::log("Exit: CNBlogPost::save");
     return;
 }
Пример #2
0
 /**
  * Saves Video in database
  * @access public
  */
 public function save()
 {
     Logger::log("Enter: Video::save");
     Logger::log("Calling: Content::save");
     if ($this->content_id) {
         parent::save();
         // if no permission is set then it is Nobody by default
         $this->file_perm = empty($this->file_perm) ? NONE : $this->file_perm;
         $sql = "UPDATE {videos} SET video_perm = ? WHERE content_id = ?";
         $data = array($this->file_perm, $this->content_id);
         $res = Dal::query($sql, $data);
         if ($this->file_name) {
             $sql = "UPDATE {videos} SET video_file = ? WHERE content_id = ?";
             $data = array($this->file_name, $this->content_id);
             $res = Dal::query($sql, $data);
         }
     } else {
         $this->display_on = 0;
         parent::save();
         if (!$this->file_perm) {
             $this->file_perm = 0;
         }
         $sql = "INSERT INTO {videos} (content_id, video_file, video_perm) VALUES (?, ?, ?)";
         $data = array($this->content_id, $this->file_name, $this->file_perm);
         $res = Dal::query($sql, $data);
     }
     Logger::log("Exit: Video::save");
     return $this->content_id;
 }
Пример #3
0
 /**
  * Saves Question in database
  * @access public
  */
 public function save()
 {
     Logger::log("Enter: Question::save");
     Logger::log("Calling: Content::save");
     $this->created = time();
     $this->changed = time();
     $this->display_on = 0;
     $this->trackbacks = NULL;
     $id = parent::save();
     $this->update_question($id);
     Logger::log("Exit: Question::save");
     return $this->content_id;
 }
Пример #4
0
 public function save()
 {
     Logger::log("Enter: Event::save");
     // check for complete info
     if (empty($this->event_title)) {
         Logger::log(" Throwing exception REQUIRED_PARAMETERS_MISSING | Message: event_title is empty", LOGGER_ERROR);
         throw new CNException(REQUIRED_PARAMETERS_MISSING, 'Please supply an Event Title.');
     }
     $this->title = $this->event_title;
     if (empty($this->start_time)) {
         Logger::log(" Throwing exception REQUIRED_PARAMETERS_MISSING | Message: start_time is empty", LOGGER_ERROR);
         throw new CNException(REQUIRED_PARAMETERS_MISSING, 'Please specify the Start Time.');
     }
     if (empty($this->end_time)) {
         Logger::log(" Throwing exception REQUIRED_PARAMETERS_MISSING | Message: end_time is empty", LOGGER_ERROR);
         throw new CNException(REQUIRED_PARAMETERS_MISSING, 'Please specify the End Time.');
     }
     // serialize event_data for storage
     $event_data = "";
     if (!empty($this->event_data)) {
         $event_data = serialize($this->event_data);
     }
     // make end_time sane (can only be same or after start_time)
     if (strtotime($this->end_time) <= strtotime($this->start_time)) {
         $this->end_time = $this->start_time;
     }
     $this->author_id = $this->user_id;
     $this->body = $this->event_data['description'];
     // are we creating a new one?
     if (!$this->event_id) {
         /*
         if (empty($this->content_id)) {
             Logger::log(" Throwing exception REQUIRED_PARAMETERS_MISSING | Message: content_id is empty", LOGGER_ERROR);
             throw new CNException(REQUIRED_PARAMETERS_MISSING, 'Content id is missing.');
         }
         */
         // do we have a real User set as owner?
         if (!User::user_exist((int) $this->user_id)) {
             Logger::log(" Throwing exception USER_NOT_FOUND | Message: User does not exist", LOGGER_ERROR);
             throw new CNException(USER_NOT_FOUND, 'User does not exist.');
         }
         // save a Content
         parent::save();
         $sql = "INSERT INTO events \n      (content_id, user_id, event_title, start_time, end_time, event_data) \n      VALUES (?, ?, ?, ?, ?, ?)";
         $data = array($this->content_id, $this->user_id, $this->event_title, $this->start_time, $this->end_time, $event_data);
     } else {
         // save as Content
         parent::save();
         $sql = "UPDATE {events} SET " . "event_title = ?, start_time = ?, end_time = ?, event_data = ? " . "WHERE event_id = ?";
         $data = array($this->event_title, $this->start_time, $this->end_time, $event_data, $this->event_id);
     }
     // write to DB
     try {
         Dal::query($sql, $data);
         if (!$this->event_id) {
             // newly created
             $this->event_id = Dal::insert_id();
         } else {
             // update any existing EventAssociations
             EventAssociation::update_assocs_for_event($this);
         }
         // Finally - commit our changes to the DB
         Dal::commit();
     } catch (CNException $e) {
         // roll back database operations and re-throw the exception
         Dal::rollback();
         throw $e;
     }
     Logger::log("Exit: Event::save");
 }
Пример #5
0
 /**
  * Saves Image in database
  * @access public
  */
 public function save()
 {
     Logger::log("Enter: Image::save_image");
     Logger::log("Calling: Content::save");
     //print '<pre>'; print_r($this); exit;
     if ($this->content_id) {
         parent::save();
         // if no permission is set then it is Nobody by default
         $this->file_perm = empty($this->file_perm) ? NONE : $this->file_perm;
         $sql = "UPDATE {images} SET image_perm = ? WHERE content_id = ?";
         $data = array($this->file_perm, $this->content_id);
         $res = Dal::query($sql, $data);
         if ($this->file_name) {
             $sql = "UPDATE {images} SET image_file = ? WHERE content_id = ?";
             $data = array($this->file_name, $this->content_id);
             $res = Dal::query($sql, $data);
         }
     } else {
         $this->display_on = NULL;
         // carefull here this is NOT '0'
         parent::save();
         if (!$this->file_perm) {
             $this->file_perm = 0;
         }
         $sql = "INSERT INTO {images} (content_id, image_file, image_perm) VALUES (?, ?, ?)";
         $data = array($this->content_id, $this->file_name, $this->file_perm);
         $res = Dal::query($sql, $data);
     }
     //print '<pre>'; print_r($this); exit;
     Logger::log("Exit: Image::save_image");
     return $this->content_id;
 }