本文整理汇总了PHP中Comment::findById方法的典型用法代码示例。如果您正苦于以下问题:PHP Comment::findById方法的具体用法?PHP Comment::findById怎么用?PHP Comment::findById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Comment
的用法示例。
在下文中一共展示了Comment::findById方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testProcessDisapprove
/**
* testProcessDisapprove
*
* @return void
*/
public function testProcessDisapprove()
{
$data['Comment'] = array('1' => 1, '2' => 0);
$this->Comment->process('disapprove', $data);
$comment = $this->Comment->findById(1);
$this->assertEqual($comment['Comment']['approved'], 0);
}
示例2: actionDeleteComment
public function actionDeleteComment()
{
if (empty($_POST['id']) || !App::isAdmin()) {
return $this->redirect('/article');
}
$currentArticleUrl = Article::findById(Comment::findById($_POST['id'])->article_id)->url;
Comment::deleteComment($_POST['id']);
$this->redirect('/article/show/' . $currentArticleUrl);
}
示例3: edit
function edit($id = null)
{
if (is_null($id)) {
redirect(get_url('plugin/comment'));
}
if (!($comment = Comment::findById($id))) {
Flash::set('error', __('comment not found!'));
redirect(get_url('plugin/comment'));
}
// check if trying to save
if (get_request_method() == 'POST') {
return $this->_edit($id);
}
// display things...
$this->display('comment/views/edit', array('action' => 'edit', 'comment' => $comment));
}
示例4: unapprove
function unapprove($id)
{
// find the user to unapprove
if ($comment = Comment::findById($id)) {
$comment->is_approved = 0;
if ($comment->save()) {
Flash::set('success', __('Comment has been unapproved!'));
Observer::notify('comment_after_unapprove', $comment);
}
} else {
Flash::set('error', __('Comment not found!'));
}
redirect(get_url('plugin/comment'));
}
示例5: deleteComment
public static function deleteComment($id)
{
$comment = Comment::findById($id);
$comment->delete();
}
示例6: destroy
public function destroy($id)
{
$this->commentRepository->findById($id)->delete();
return Redirect::action('AdminCommentsController@index');
}
示例7: comment_save
/**
* Executed through the Observer system each time a page is found.
*
* @global <type> $__CMS_CONN__
* @param Page $page The object instance for the page that was found.
* @return <type> Nothing.
*/
function comment_save(&$page)
{
// Check if we need to save a comment
if (!isset($_POST['comment'])) {
return;
}
$data = $_POST['comment'];
if (is_null($data)) {
return;
}
$captcha = Plugin::getSetting('use_captcha', 'comment');
if ($captcha && $captcha == '1') {
if (isset($data['secure'])) {
if ($data['secure'] == "" or empty($data['secure']) or $data['secure'] != $_SESSION['security_number']) {
return;
}
} else {
return;
}
}
if ($page->comment_status != Comment::OPEN) {
return;
}
if (!isset($data['author_name']) or trim($data['author_name']) == '') {
return;
}
if (!isset($data['author_email']) or trim($data['author_email']) == '') {
return;
}
if (!preg_match('/[^\\x00-\\x20()<>@,;:\\".[\\]\\x7f-\\xff]+(?:\\.[^\\x00-\\x20()<>@,;:\\".[\\]\\x7f-\\xff]+)*\\@[^\\x00-\\x20()<>@,;:\\".[\\]\\x7f-\\xff]+(?:\\.[^\\x00-\\x20()<>@,;:\\".[\\]\\x7f-\\xff]+)+/i', $data['author_email'])) {
return;
}
if (!isset($data['body']) or trim($data['body']) == '') {
return;
}
use_helper('Kses');
$allowed_tags = array('a' => array('href' => array(), 'title' => array()), 'abbr' => array('title' => array()), 'acronym' => array('title' => array()), 'b' => array(), 'blockquote' => array('cite' => array()), 'br' => array(), 'code' => array(), 'em' => array(), 'i' => array(), 'p' => array(), 'strike' => array(), 'strong' => array());
$auto_approve_comment = Plugin::getSetting('auto_approve_comment', 'comment');
// Check for and correct problems with website link
if (isset($data['author_link']) && $data['author_link'] !== '') {
if (strpos($data['author_link'], 'http://') !== 0 && strpos($data['author_link'], 'https://') !== 0) {
$data['author_link'] = 'http://' . $data['author_link'];
}
}
global $__CMS_CONN__;
$sql = 'INSERT INTO ' . TABLE_PREFIX . 'comment (page_id, author_name, author_email, author_link, ip, body, is_approved, created_on) VALUES (' . '\'' . $page->id . '\', ' . $__CMS_CONN__->quote(strip_tags($data['author_name'])) . ', ' . $__CMS_CONN__->quote(strip_tags($data['author_email'])) . ', ' . $__CMS_CONN__->quote(strip_tags($data['author_link'])) . ', ' . $__CMS_CONN__->quote($data['author_ip']) . ', ' . $__CMS_CONN__->quote(kses($data['body'], $allowed_tags)) . ', ' . $__CMS_CONN__->quote($auto_approve_comment) . ', ' . $__CMS_CONN__->quote(date('Y-m-d H:i:s')) . ')';
$__CMS_CONN__->exec($sql);
// @todo FIXME - If code above used Comment object for saving data there would be
// no need to reload it from database. Using lastInsertId() is unrealiable anyway.
$comment_id = Record::lastInsertId();
$comment = Comment::findById($comment_id);
Observer::notify('comment_after_add', $comment);
if (Plugin::isEnabled('statistics_api')) {
$event = array('event_type' => 'comment_added', 'description' => __('A comment was added.'), 'ipaddress' => $comment->ip, 'username' => $comment->author_name);
Observer::notify('stats_comment_after_add', $event);
}
}