本文整理汇总了PHP中Software::comments_permalink方法的典型用法代码示例。如果您正苦于以下问题:PHP Software::comments_permalink方法的具体用法?PHP Software::comments_permalink怎么用?PHP Software::comments_permalink使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Software
的用法示例。
在下文中一共展示了Software::comments_permalink方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: post_comment
/**
* @fn post_comment
* @short Action method that receives a comment for a software product.
*/
public function post_comment()
{
$conn = Db::get_connection();
if (!$this->request->is_post()) {
$this->redirect_to(array('action' => 'index'));
}
$software = new Software();
if ($software->find_by_id($_POST['software_id']) === FALSE) {
$this->flash(l('No such software'), 'error');
$this->redirect_to(array('action' => 'index'));
}
if (!Email::is_valid($_POST['email'])) {
$this->flash(l('Please enter a valid email address'), 'error');
$this->redirect_to($software->comments_permalink());
}
if (!Antispam::check_math()) {
$this->flash(Antispam::random_comment(), 'error');
$this->redirect_to($software->comments_permalink());
}
// A static class method would be infinitely better...
$comment = new SoftwareComment($_POST);
$comment->created_at = date('Y-m-d H:i:s');
$comment->save();
// Send an email to notify this comment
$email = new SoftwareCommentEmail(array('comment' => $comment, 'name' => $_POST['author'], 'email' => $_POST['email'], 'URL' => $_POST['URL']));
$email->send();
if (isset($_POST['remember_me'])) {
$this->set_credentials($_POST['author'], $_POST['email'], $_POST['URL']);
}
// Expires the cache of Comments feed
$this->expire_cached_page(array('controller' => 'feed', 'action' => 'software_comments', 'id' => $_POST['software_id']));
$this->redirect_to_software_page(array('id' => $_POST['software_id'], 'subview' => 'comments', 'hash' => 'comment-' . $comment->id));
Db::close_connection($conn);
}