public function update($id)
 {
     $this->commentRepository->findById($id);
     $val = $this->commentRepository->getEditForm($id);
     if (!$val->isValid()) {
         return Redirect::back()->with('errors', $val->getErrors())->withInput();
     }
     if (!$this->commentRepository->update($id, $val->getInputData())) {
         return Redirect::back()->with('errors', $this->commentRepository->errors())->withInput();
     }
     return Redirect::action('AdminCommentsController@index')->with('success', 'Updated');
 }
Exemple #2
0
 public function edit_post()
 {
     $data = $this->data;
     //取得公用數據
     //基本post欄位
     $orderid_Num = $this->input->post('orderid_Num', TRUE);
     $paycheck_status_Num = $this->input->post('paycheck_status_Num', TRUE);
     $product_status_Num = $this->input->post('product_status_Num', TRUE);
     $receive_name_Str = $this->input->post('receive_name_Str', TRUE);
     $receive_phone_Str = $this->input->post('receive_phone_Str', TRUE);
     $receive_time_Str = $this->input->post('receive_time_Str');
     $receive_address_Str = $this->input->post('receive_address_Str');
     $receive_remark_Str = $this->input->post('receive_remark_Str', TRUE);
     $transport_id_Str = $this->input->post('transport_id_Str', TRUE);
     $sendtime_Str = $this->input->post('sendtime_Str', TRUE);
     $order_status_Num = $this->input->post('order_status_Num', TRUE);
     $content_Str = $this->input->post('content_Str', TRUE);
     //建構OrderShop物件,並且更新
     $OrderShop = new OrderShop();
     $OrderShop->construct(array('orderid_Num' => $orderid_Num, 'paycheck_status_Num' => $paycheck_status_Num, 'product_status_Num' => $product_status_Num, 'receive_name_Str' => $receive_name_Str, 'receive_phone_Str' => $receive_phone_Str, 'receive_time_Str' => $receive_time_Str, 'receive_address_Str' => $receive_address_Str, 'receive_remark_Str' => $receive_remark_Str, 'transport_id_Str' => $transport_id_Str, 'sendtime_Str' => $sendtime_Str, 'updatetime_Str' => '', 'order_status_Num' => $order_status_Num));
     $OrderShop->update(array('db_update_Arr' => array('paycheck_status', 'product_status', 'receive_name', 'receive_phone', 'receive_time', 'receive_address', 'receive_remark', 'transport_id', 'sendtime', 'updatetime', 'order_status')));
     if (!empty($content_Str)) {
         $Comment = new Comment();
         $Comment->construct(['uid_Num' => $data['User']->uid_Num, 'typename_Str' => 'order', 'id_Num' => $OrderShop->orderid_Num, 'content_Str' => $content_Str]);
         $Comment->update();
     }
     //送出成功訊息
     $this->load->model('Message');
     $this->Message->show(array('message' => '設定成功', 'url' => 'admin/shop/order_shop/order_shop/tablelist'));
 }
Exemple #3
0
 public function edit_post()
 {
     $data = $this->data;
     //取得公用數據
     $orderid_Num = $this->input->post('orderid_Num', TRUE);
     //基本post欄位
     $pay_account_Str = $this->input->post('pay_account_Str', TRUE);
     $pay_name_Str = $this->input->post('pay_name_Str', TRUE);
     $pay_paytime_Str = $this->input->post('pay_paytime_Str', TRUE);
     $pay_remark_Str = $this->input->post('pay_remark_Str', TRUE);
     $content_Str = $this->input->post('content_Str', TRUE);
     if (!empty($pay_account_Str) && !empty($pay_name_Str) && !empty($pay_paytime_Str)) {
         //建構OrderShop物件,並且更新
         $OrderShop = new OrderShop();
         $OrderShop->construct(array('orderid_Num' => $orderid_Num, 'pay_account_Str' => $pay_account_Str, 'pay_name_Str' => $pay_name_Str, 'pay_paytime_Str' => $pay_paytime_Str, 'pay_remark_Str' => $pay_remark_Str, 'pay_status_Num' => 1));
         $OrderShop->update(array('db_update_Arr' => array('pay_account', 'pay_name', 'pay_paytime', 'pay_remark', 'pay_status')));
     }
     if (!empty($content_Str)) {
         $Comment = new Comment();
         $Comment->construct(['uid_Num' => $data['User']->uid_Num, 'typename_Str' => 'order', 'id_Num' => $orderid_Num, 'content_Str' => $content_Str]);
         $Comment->update();
     }
     //送出成功訊息
     $this->load->model('Message');
     $this->Message->show(array('message' => '設定成功', 'url' => 'admin/user/order_shop/order_shop/tablelist'));
 }
 public function executeUpdate($request)
 {
     $this->prepareUpdate();
     if ($this->getRequest()->getMethod() == sfRequest::POST) {
         $this->form->bind($request->getParameter('comment'));
         if ($this->form->isValid()) {
             $values = $this->form->getValues();
             Comment::update($this->form->getValues(), $this->getUser()->getUser());
         }
     }
     return $this->redirect($this->getRequest()->getReferer());
 }
Exemple #5
0
 public function edit_post()
 {
     $picids_Arr = $this->input->post('picids_Arr');
     $picid_Num = $this->input->post('picid_Num');
     $classids_Arr = $this->input->post('classids_Arr');
     if (!empty($picid_Num)) {
         $PicObj = new PicObj();
         $PicObj->construct_db(array('db_where_Arr' => array('picid_Num' => $picid_Num)));
         $PicObj->class_ClassMetaList = new ObjList();
         $PicObj->class_ClassMetaList->construct_db(array('db_where_or_Arr' => array('classid' => $classids_Arr), 'db_from_Str' => 'class', 'model_name_Str' => 'ClassMeta', 'limitstart_Num' => 0, 'limitcount_Num' => 100));
         $PicObj->updatetime_DateTime = new DateTimeObj();
         $PicObj->updatetime_DateTime->construct();
         if (!empty($classids_Arr[0])) {
             $PicObj->upload_status_Num = 1;
         } else {
             $PicObj->upload_status_Num = 2;
         }
         $PicObj->update();
         if (!empty($comment_content_Str)) {
             $Comment = new Comment();
             $Comment->construct(['uid_Num' => $data['User']->uid_Num, 'typename_Str' => 'pic', 'id_Num' => $PicObj->picid_Num, 'content_Str' => $comment_content_Str]);
             $Comment->update();
         }
         $this->load->model('Message');
         $this->Message->show(array('message' => '設定成功', 'url' => 'admin/base/pic/pic/tablelist'));
     } else {
         if (!empty($picids_Arr)) {
             $PicObjList = new ObjList();
             $PicObjList->construct_db(['db_where_or_Arr' => ['picid' => $picids_Arr], 'model_name_Str' => 'PicObj', 'db_orderby_Arr' => [['prioritynum', 'DESC'], ['updatetime', 'DESC']], 'limitstart_Num' => 0, 'limitcount_Num' => 100]);
             if (!empty($classids_Arr)) {
                 foreach ($PicObjList->obj_Arr as $key => $value_PicObj) {
                     $value_PicObj->set('class_ClassMetaList', ['classids_Arr' => $classids_Arr], 'ClassMetaList');
                     // $value_PicObj->upload_status_Num = 1;
                     $value_PicObj->update();
                 }
             }
             $this->load->model('Message');
             $this->Message->show(array('message' => '設定成功', 'url' => 'admin/base/pic/pic/tablelist'));
         } else {
             $this->load->model('Message');
             $this->Message->show(array('message' => '未知的錯誤', 'url' => 'admin/base/pic/pic/tablelist'));
         }
     }
 }
 /**
  * Migrates the old {@link PageComment} objects to {@link Comment}
  */
 public function requireDefaultRecords()
 {
     parent::requireDefaultRecords();
     if (DB::getConn()->hasTable('PageComment')) {
         $comments = DB::query("SELECT * FROM \"PageComment\"");
         if ($comments) {
             while ($pageComment = $comments->nextRecord()) {
                 // create a new comment from the older page comment
                 $comment = new Comment();
                 $comment->update($pageComment);
                 // set the variables which have changed
                 $comment->BaseClass = 'SiteTree';
                 $comment->URL = isset($pageComment['CommenterURL']) ? $pageComment['CommenterURL'] : "";
                 $comment->write();
             }
         }
         DB::alteration_message("Migrated PageComment to Comment", "changed");
         DB::getConn()->dontRequireTable('PageComment');
     }
 }
Exemple #7
0
 /**
  * 
  */
 public function testCommentInfo()
 {
     // make sure adding info to comment works
     $this->comment->info->test = 'test';
     $this->assertEquals('test', $this->comment->info->test);
     $this->comment->update();
     $test_comment = Comment::get($this->comment->id);
     $this->assertEquals($this->comment->info->test, $test_comment->info->test);
     unset($test_comment);
     // make sure construction works with info
     $new_comment = new Comment();
     $this->assertType('CommentInfo', $new_comment->info);
     $this->assertFalse($new_comment->info->is_key_set());
     $new_comment->info->test = 'test';
     $new_comment->insert();
     $this->assertTrue($new_comment->info->is_key_set());
     $test_comment = Comment::get($new_comment->id);
     $this->assertEquals($new_comment->info->test, $test_comment->info->test);
     $new_comment->delete();
     unset($test_comment);
 }
Exemple #8
0
 static function admin_update_comment()
 {
     if (empty($_POST)) {
         redirect("/admin/?action=manage_comments");
     }
     $comment = new Comment($_POST['id']);
     if (!$comment->editable()) {
         show_403(__("Access Denied"), __("You do not have sufficient privileges to edit this comment.", "comments"));
     }
     $visitor = Visitor::current();
     $status = $visitor->group->can("edit_comment") ? $_POST['status'] : $comment->status;
     $created_at = $visitor->group->can("edit_comment") ? datetime($_POST['created_at']) : $comment->created_at;
     $comment->update($_POST['author'], $_POST['author_email'], $_POST['author_url'], $_POST['body'], $status, $created_at);
     if (isset($_POST['ajax'])) {
         exit("{ \"comment_id\": " . $_POST['id'] . ", \"comment_timestamp\": \"" . $created_at . "\" }");
     }
     if ($_POST['status'] == "spam") {
         Flash::notice(__("Comment updated."), "/admin/?action=manage_spam");
     } else {
         Flash::notice(_f("Comment updated. <a href=\"%s\">View Comment &rarr;</a>", array($comment->post->url() . "#comment_" . $comment->id), "comments"), "/admin/?action=manage_comments");
     }
 }
$comment_text = $comment->_dbo->comment_text;
if (!Permissions::checkPermAndLevel('edit_comments', $comment->_dbo->user_id)) {
    die("Permission denied.");
}
?>

<div class="a_white_pane">
<h1 class="a_title">Edycja komentarza</h1>
</div>

<br />

<?php 
if (!empty($_POST['submit'])) {
    try {
        $comment->update($_POST['comment_title'], $_POST['comment_text']);
        if (!empty($ref)) {
            header("Location: " . $ref);
        }
        $pane = new HTML_MessagePane("upd", $action == "add" ? _ADMIN_GROUP_CREATED : _ADMIN_GROUP_UPDATED, "", "a_ok_pane", "a_ok_pane_hdr");
        $pane->show();
    } catch (Exception2 $e) {
        $pane = new HTML_MessagePane("upd", $e->getMessage(), $e->getDescription(), "a_fail_pane", "a_fail_pane_hdr");
        $pane->show();
    }
}
$form = new HTML_AdminForm("edit_comment_form", "Edycja komentarza", $session->addSID("edit_comment.php"));
$form->addHidden("ref", $ref);
$form->addHidden("cmid", $cmid);
$pane = new HTML_AdminFormPane("p1", "Komentarz");
$field = new HTML_TextField("comment_title", "Tytu³", "", 50, $comment_title);
Exemple #10
0
 $info = array();
 $info["page"] = $_POST['page'];
 $info["editedId"] = isset($_POST['editedId']) ? $_POST['editedId'] : -1;
 $info["page"] = substr($info["page"], strlen(__BASE_PATH__));
 $info["text"] = $_POST['text'];
 $info["referedComment"] = isset($_POST['comment']) ? $_POST['comment'] : 0;
 $pName = isset($_POST['product']) ? $_POST['product'] : "";
 $pVersion = isset($_POST['version']) ? $_POST['version'] : "";
 $fullUser = base64_encode($pName . "_" . $pVersion . "_user");
 $info["sessionUserName"] = $fullUser;
 $info["product"] = $pName;
 $info["version"] = $pVersion;
 $comment = new Comment($dbConnectionInfo, "", $fullUser);
 if ($info['editedId'] > 0) {
     // edit comment
     $result = $comment->update($info);
     if (isset($result['rows']) && $result['rows'] > 0) {
         echo "Comment edited !|" . $result['id'];
     } else {
         if (isset($result['rows'])) {
             echo "Comment not edited!";
         }
     }
 } else {
     // insert comment
     $result = $comment->insert($info);
     if ($result['rows'] > 0) {
         if (isset($ses->{$fullUser})) {
             $user = $ses->{$fullUser};
             $userEmail = $ses->{$fullUser}->email;
             $userName = $ses->{$fullUser}->userName;
Exemple #11
0
		}
		if ( !$comment->delete_rating() ) redirect();
		redirect("#comment".$comment->id);
		break;

	case "remove_comment":
	case "restore_comment":
		Login::access_action("admin");
		action_required_parameters("id");
		$comment = new Comment($_POST['id']);
		if (!$comment->id) {
			warning(_("This comment does not exist."));
			redirect();
		}
		$comment->removed = ($action=="remove_comment");
		$comment->update(["removed"]);
		redirect("#comment".$comment->id);
		break;

	default:
		warning(_("Unknown action"));
		redirect();
	}
}


// $is_propronent means only confirmed proponents
list($supporters, $proponents, $is_supporter, $is_proponent, $is_valid) = $proposal->supporters();


html_head(_("Proposal")." ".$proposal->id, true);
Exemple #12
0
 /**
  *test updating a Comment that doesn't exist
  *
  * @expectedException PDOException
  */
 public function testUpdateInvalidComment()
 {
     // create a Comment and try to update without actually inserting it
     $comment = new Comment(null, $this->trail->getTrailId(), $this->user->getUserId(), $this->VALID_BROWSER, $this->VALID_CREATEDATE, $this->VALID_IPADDRESS, $this->VALID_COMMENTPHOTO, $this->VALID_COMMENTPHOTOTYPE, $this->VALID_COMMENTTEXT);
     $comment->update($this->getPDO());
 }
Exemple #13
0
//$l = Logger::start();
$msg = "";
if (isset($_POST['del'])) {
    $id = intval($_POST['did']);
    $d = Comment::delete($id);
    if ($d) {
        $msg = opmsg("Comment Deleted Successfully", "success");
        redirect_to('managecomments.php');
    } else {
        $msg = opmsg("Comment Not Deleted", "danger");
    }
}
if (isset($_POST['approve'])) {
    $id = intval($_POST['cid']);
    $data['allowed'] = 1;
    $d = Comment::update($id, $data);
    if ($d) {
        $msg = opmsg("Comment Approved Successfully", "success");
        redirect_to('managecomments.php');
    } else {
        $msg = opmsg("Comment Not Approved", "danger");
    }
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
Exemple #14
0
 public function update(Comment $comment)
 {
     if (!$this->validate() | !$comment->validate()) {
         throw new ValidationException();
     }
     $db = DB::conn();
     try {
         $db->begin();
         $db->update('thread', array('title' => $this->title, 'category_id' => $this->category_id), array('id' => $this->id));
         $comment->update();
         $db->commit();
     } catch (PDOException $e) {
         if ($e->errorInfo[1] == self::ERR_CATEGORY) {
             throw new CategoryException();
         }
         $db->rollback();
     }
 }
$user_id = filter_input(INPUT_POST, "user_id");
$thread_id = filter_input(INPUT_POST, "thread_id");
$text = filter_input(INPUT_POST, "text");
$action = $_SERVER['REQUEST_METHOD'];
if ($get_action = filter_input(INPUT_POST, "action")) {
    if ($user_id != $_SESSION['user_id']) {
        header("Location: /bbs/");
        exit;
    }
    $action = filter_input(INPUT_POST, "action");
}
switch ($action) {
    case 'UPDATE':
        //update comment
        $params = array('id' => $comment_id, 'text' => $text);
        $comment->update($params);
        header("Location: /bbs/view/threads?id=" . $thread_id);
        exit;
    case 'POST':
        //new comment
        $user_id = $_SESSION["user_id"];
        $params = array('user_id' => $user_id, 'thread_id' => $thread_id, 'text' => $text);
        $comment->add($params);
        header("Location: /bbs/view/threads?id=" . $thread_id);
        exit;
    case 'DELETE':
        print $comment_id;
        if ($comment_id) {
            //DELETE
            $comment->deleteRow($comment_id);
        }
 public function executeUpdate($request)
 {
     $object = $this->getRequestParameter('object');
     $user = User::getByApiKey($request->getParameter('login_id'), $request->getParameter('api_key'));
     if (!$user) {
         $output = '<rsp stat="fail"><err code="2" msg="login_id and api_key do not match" /></rsp>';
     } elseif ($object == 'application') {
         $form = new ApplicationForm();
         $form->bind(array('id' => $request->getParameter('id'), 'name' => $request->getParameter('name'), 'description' => $request->getParameter('description'), 'source_url' => $request->getParameter('source_url')));
         if ($form->isValid()) {
             $application = Application::update($form->getValues(), $user);
             if ($application) {
                 $output = '<rsp stat="ok">' . $application->getXML() . '</rsp>';
             } else {
                 $output = '<rsp stat="fail"><err code="4" msg="Unable to update application." /></rsp>';
             }
         } else {
             $output = '<rsp stat="fail"><err code="4" msg="' . $form->getErrorSchema() . '" /></rsp>';
         }
     } elseif ($object == 'comment') {
         $form = new CommentForm();
         $application_id = $module_id = $theme_id = null;
         if ($request->getParameter('application_id')) {
             $application_id = $request->getParameter('application_id');
         }
         if ($request->getParameter('module_id')) {
             $module_id = $request->getParameter('module_id');
         }
         if ($request->getParameter('theme_id')) {
             $theme_id = $request->getParameter('theme_id');
         }
         $form->bind(array('comment' => $request->getParameter('comment'), 'application_id' => $application_id, 'module_id' => $module_id, 'theme_id' => $theme_id));
         if ($form->isValid()) {
             $comment = Comment::update($form->getValues(), $user);
             $output = '<rsp stat="ok">' . $comment->getXML() . '</rsp>';
         } else {
             $output = '<rsp stat="fail"><err code="3" msg="' . $form->getErrorSchema() . '" /></rsp>';
         }
     } elseif ($object == 'module') {
         $form = new ModuleForm();
         $form->bind(array('id' => $request->getParameter('id'), 'name' => $request->getParameter('name'), 'description' => $request->getParameter('description'), 'source_url' => $request->getParameter('source_url'), 'application_id' => $request->getParameter('application_id')));
         if ($form->isValid()) {
             $module = Madule::update($form->getValues(), $user);
             if ($module) {
                 $output = '<rsp stat="ok">' . $module->getXML() . '</rsp>';
             } else {
                 $output = '<rsp stat="fail"><err code="4" msg="Unable to update module." /></rsp>';
             }
         } else {
             $output = '<rsp stat="fail"><err code="4" msg="' . $form->getErrorSchema() . '" /></rsp>';
         }
     } elseif ($object == 'theme') {
         $form = new ThemeForm();
         $form->bind(array('id' => $request->getParameter('id'), 'name' => $request->getParameter('name'), 'description' => $request->getParameter('description')), $request->getFiles());
         if ($form->isValid()) {
             $theme = Theme::update($form->getValues(), $user);
             if ($theme) {
                 $output = '<rsp stat="ok">' . $theme->getXML() . '</rsp>';
             } else {
                 $output = '<rsp stat="fail"><err code="5" msg="Unable to update theme." /></rsp>';
             }
         } else {
             $output = '<rsp stat="fail"><err code="5" msg="' . $form->getErrorSchema() . '" /></rsp>';
         }
     } elseif ($object == 'theme_group') {
         $output = '<rsp stat="fail"><err code="6" msg="This object is not supported for update" /></rsp>';
     } elseif ($object == 'user') {
         $form = new UserForm();
         $form->bind(array('id' => $request->getParameter('id'), 'name' => $request->getParameter('name'), 'password' => $request->getParameter('password'), 'password2' => $request->getParameter('password'), 'email' => $request->getParameter('email'), 'role' => null));
         if ($form->isValid()) {
             $update_user = User::update($form->getValues(), $user);
             if ($update_user) {
                 $output = '<rsp stat="ok">' . $update_user->getXML() . '</rsp>';
             } else {
                 $output = '<rsp stat="fail"><err code="7" msg="Unable to update user." /></rsp>';
             }
         } else {
             $output = '<rsp stat="fail"><err code="7" msg="' . $form->getErrorSchema() . '" /></rsp>';
         }
     }
     $this->output = $output;
     $this->setTemplate('index');
 }
Exemple #17
0
     }
     if (empty($requestObject->commentText) === true) {
         throw new InvalidArgumentException("Comment Text cannot be empty", 408);
     }
     // perform the actual put or post
     if ($method === "PUT") {
         $comment = Comment::getCommentByCommentId($pdo, $commentId);
         if ($comment === null) {
             throw new RuntimeException("Comment does not exist", 404);
         }
         if ($_SESSION["user"] !== "S" && $_SESSION["user"]->getUserId() !== $comment->getUserId()) {
             throw new RuntimeException("You may only edit your own comments", 403);
         }
         // trailId, userId, browser, createDate, ipAddress, commentPhoto, commentPhotoType, commentText
         $comment = new Comment($commentId, $comment->getTrailId(), $comment->getUserId(), $comment->getBrowser(), $comment->getCreateDate(), $comment->getIpAddress(), $requestObject->commentPhoto, $requestObject->commentPhotoType, $requestObject->commentText);
         $comment->update($pdo);
         $reply->message = "Comment updated OK";
     } elseif ($method === "POST") {
         $comment = new Comment(null, $requestObject->trailId, $_SESSION["user"]->getUserId(), $browser, new DateTime(), $ipAddress, $requestObject->commentPhoto, $requestObject->commentPhotoType, $requestObject->commentText);
         $comment->insert($pdo);
         $reply->message = "Comment created OK";
     }
 } elseif ($method === "DELETE") {
     verifyXsrf();
     $comment = Comment::getCommentByCommentId($pdo, $commentId);
     if ($comment === null) {
         throw new RuntimeException("Comment does not exist", 404);
     }
     $comment->delete($pdo);
     $reply->message = "Comment deleted OK";
 }
Exemple #18
0
        $vars['messages'] = Notify::read();
        $vars['token'] = Csrf::token();
        $vars['comment'] = Comment::find($id);
        $vars['statuses'] = array('approved' => __('global.approved'), 'pending' => __('global.pending'), 'spam' => __('global.spam'));
        return View::create('comments/edit', $vars)->partial('header', 'partials/header')->partial('footer', 'partials/footer');
    });
    Route::post('admin/comments/edit/(:num)', function ($id) {
        $input = Input::get(array('name', 'email', 'text', 'status'));
        $validator = new Validator($input);
        $validator->check('name')->is_max(3, __('comments.name_missing'));
        $validator->check('text')->is_max(3, __('comments.text_missing'));
        if ($errors = $validator->errors()) {
            Input::flash();
            Notify::error($errors);
            return Response::redirect('admin/comments/edit/' . $id);
        }
        Comment::update($id, $input);
        Notify::success(__('comments.updated'));
        return Response::redirect('admin/comments/' . $input['status']);
    });
    /*
    	Delete Comment
    */
    Route::get('admin/comments/delete/(:num)', function ($id) {
        $comment = Comment::find($id);
        $status = $comment->status;
        $comment->delete();
        Notify::success(__('comments.deleted'));
        return Response::redirect('admin/comments/' . $status);
    });
});