本文整理汇总了PHP中CommentForm::initData方法的典型用法代码示例。如果您正苦于以下问题:PHP CommentForm::initData方法的具体用法?PHP CommentForm::initData怎么用?PHP CommentForm::initData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CommentForm
的用法示例。
在下文中一共展示了CommentForm::initData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add
/**
* Add a comment
* @param $args array
* @param $request Request
*/
function add($args, $request)
{
$articleId = isset($args[0]) ? (int) $args[0] : 0;
$galleyId = isset($args[1]) ? (int) $args[1] : 0;
$parentId = isset($args[2]) ? (int) $args[2] : 0;
$journal =& $request->getJournal();
$commentDao =& DAORegistry::getDAO('CommentDAO');
$publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO');
$publishedArticle =& $publishedArticleDao->getPublishedArticleByArticleId($articleId);
$parent =& $commentDao->getById($parentId, $articleId);
if (isset($parent) && $parent->getSubmissionId() != $articleId) {
$request->redirect(null, null, 'view', array($articleId, $galleyId));
}
$this->validate($request, $articleId);
$this->setupTemplate($request, $publishedArticle, $galleyId, $parent);
// Bring in comment constants
$enableComments = $journal->getSetting('enableComments');
switch ($enableComments) {
case COMMENTS_UNAUTHENTICATED:
break;
case COMMENTS_AUTHENTICATED:
case COMMENTS_ANONYMOUS:
// The user must be logged in to post comments.
if (!$request->getUser()) {
Validation::redirectLogin();
}
break;
default:
// Comments are disabled.
Validation::redirectLogin();
}
import('classes.comment.form.CommentForm');
$commentForm = new CommentForm(null, $articleId, $galleyId, isset($parent) ? $parentId : null);
$commentForm->initData();
if (isset($args[3]) && $args[3] == 'save') {
$commentForm->readInputData();
if ($commentForm->validate()) {
$commentForm->execute();
// Send a notification to associated users
import('classes.notification.NotificationManager');
$notificationManager = new NotificationManager();
$articleDao =& DAORegistry::getDAO('ArticleDAO');
$article =& $articleDao->getArticle($articleId);
$notificationUsers = $article->getAssociatedUserIds();
foreach ($notificationUsers as $userRole) {
$notificationManager->createNotification($request, $userRole['id'], NOTIFICATION_TYPE_USER_COMMENT, $article->getJournalId(), ASSOC_TYPE_ARTICLE, $article->getId());
}
$request->redirect(null, null, 'view', array($articleId, $galleyId, $parentId), array('refresh' => 1));
}
}
$commentForm->display();
}
示例2: add
function add($args)
{
$paperId = isset($args[0]) ? (int) $args[0] : 0;
$galleyId = isset($args[1]) ? (int) $args[1] : 0;
$parentId = isset($args[2]) ? (int) $args[2] : 0;
$conference =& Request::getConference();
$schedConf =& Request::getSchedConf();
$this->validate($paperId);
$paper =& $this->paper;
$parent =& $commentDao->getComment($parentId, $paperId);
if (isset($parent) && $parent->getPaperId() != $paperId) {
Request::redirect(null, null, null, 'view', array($paperId, $galleyId));
}
$this->setupTemplate($paper, $galleyId, $parent);
// Bring in comment constants
$commentDao =& DAORegistry::getDAO('CommentDAO');
$enableComments = $conference->getSetting('enableComments');
$commentsRequireRegistration = $conference->getSetting('commentsRequireRegistration');
$commentsAllowAnonymous = $conference->getSetting('commentsAllowAnonymous');
$closeCommentsDate = $schedConf->getSetting('closeCommentsDate');
$commentsClosed = $schedConf->getSetting('closeComments') ? true : false && strtotime($closeCommentsDate < time());
$enableComments = $enableComments && !$commentsClosed && $paper->getEnableComments();
if (!$enableComments) {
Request::redirect(null, null, 'index');
}
if ($commentsRequireRegistration && !Request::getUser()) {
Validation::redirectLogin();
}
import('comment.form.CommentForm');
$commentForm = new CommentForm(null, $paperId, $galleyId, isset($parent) ? $parentId : null);
$commentForm->initData();
if (isset($args[3]) && $args[3] == 'save') {
$commentForm->readInputData();
if ($commentForm->validate()) {
$commentForm->execute();
// Send a notification to associated users
import('notification.Notification');
$paperDAO =& DAORegistry::getDAO('PaperDAO');
$paper =& $paperDAO->getPaper($paperId);
$notificationUsers = $paper->getAssociatedUserIds();
foreach ($notificationUsers as $userRole) {
$url = Request::url(null, null, null, 'view', array($paperId, $galleyId, $parentId));
Notification::createNotification($userRole['id'], "notification.type.userComment", $paper->getLocalizedTitle(), $url, 1, NOTIFICATION_TYPE_USER_COMMENT);
}
Request::redirect(null, null, null, 'view', array($paperId, $galleyId, $parentId), array('refresh' => 1));
}
}
$commentForm->display();
}