/** * Insert a new post into the database * * @access private */ private function create() { if ($this->check_post_data()) { $this->_post->_author = $this->_user['user_id']; //we set this here because it's specific to the creation try { //check if permalink already used $to_read['table'] = 'post'; $to_read['columns'] = array('post_permalink'); $to_read['condition_columns'][':p'] = 'post_permalink'; $to_read['condition_select_types'][':p'] = '='; $to_read['condition_values'][':p'] = $this->_post->_permalink; $to_read['value_types'][':p'] = 'str'; $perm = $this->_db->read($to_read); if (!empty($perm)) { throw new Exception('Generated permalink already in use. Please change your post title!'); } $this->_post->create(); $this->_action_msg = ActionMessages::new_post_create(true); $this->_action = 'to_update'; Session::monitor_activity('created a new article named: "' . $this->_post->_title . '" (status: ' . $this->_post->_status . ')'); } catch (Exception $e) { $this->_action_msg = ActionMessages::new_post_create($e->getMessage()); $this->_action = 'to_insert'; } } else { $this->_action = 'to_insert'; } }