/** * Method that permits to update a comment * * @access private */ private function update() { $action_return = array(); if (VPost::submit() == 'Update Comment') { $comment = new Comment(); $comment->_id = VPost::comment_id(); $comment->_name = VPost::comment_name(); $comment->_email = VPost::comment_email(); $comment->_content = VPost::comment_content(); $comment->_status = VPost::comment_status(); try { $comment->update('_name', 'str'); $comment->update('_email', 'str'); $comment->update('_content', 'str'); $comment->update('_status', 'str'); array_push($action_return, true); } catch (Exception $e) { array_push($action_return, false); } } elseif ((VGet::action() || VPost::apply_action(false)) && in_array(VRequest::action(), $this->_actions) && VRequest::comment_id()) { if (VPost::apply_action(false)) { foreach (VPost::comment_id() as $id) { try { $comment = new Comment(); $comment->_id = $id; $comment->_status = $this->_action_value[VPost::action()]; $comment->update('_status', 'str'); unset($comment); array_push($action_return, true); } catch (Exception $e) { array_push($action_return, false); } } } else { try { $comment = new Comment(); $comment->_id = VGet::comment_id(); $comment->_status = $this->_action_value[VGet::action()]; $comment->update('_status', 'str'); unset($comment); array_push($action_return, true); } catch (Exception $e) { array_push($action_return, false); } } } if (!empty($action_return)) { $this->_action_msg = ActionMessages::update_comment($action_return); } }
/** * Create a comment on a distant website * * @access private */ private function create() { if (VPost::submit(false) && VPost::content(false)) { try { $user = new User(); $user->_id = $this->_user['user_id']; $user->read('_publicname'); $user->read('_email'); $data = array('name' => $user->_publicname, 'email' => $user->_email, 'content' => VPost::content(), 'id' => $this->_content['post']['POST_ID'], 'type' => 'post'); $url = $this->_prefs->_data['timeline'][$this->_key]['url'] . 'admin/index.php?ns=rpc&ctl=comment'; $curl = new Curl(); $curl->_post = true; $curl->_data = $data; $curl->_url = $url; $curl->connect(); $msg = json_decode($curl->_content, true); if ($msg['message'] !== true) { throw new Exception('Error on distant website! ' . $this->_prefs->_data['timeline'][$this->_key]['title'] . ' says "' . $msg['message'] . '"'); } $this->_action_msg = ActionMessages::custom_good('Comment submitted'); } catch (Exception $e) { $this->_action_msg = ActionMessages::custom_wrong($e->getMessage()); } } }
/** * Send mail to webmaster * * @access private */ private function send() { if (VPost::submit(false)) { if (!VPost::c_email() || !VPost::c_object() || !VPost::c_content()) { $this->_result = false; } elseif (!preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9\\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\\._-]+)+\$/", VPost::c_email())) { $this->_result = 'false email'; } else { $mail = new Mail(VPost::recaiver(), VPost::c_object(), VPost::c_content(), VPost::c_email()); $mail->send(); $this->_result = true; } } }