/**
  * executeDo_add_new_comment 
  * 
  * @access public
  * @return void
  */
 public function executeDoAdd(sfWebRequest $request)
 {
     // Pull associated model
     $record_id = $request->getParameter('record_id');
     $model = $request->getParameter('model');
     $this->record = Doctrine::getTable($model)->find($record_id);
     $commentForm = new CommentForm();
     $commentForm->bind($request->getParameter('comment'));
     // return bound form with errors if form is invalid
     if (!$commentForm->isValid()) {
         return $this->renderPartial('csComments/add_comment', array('commentForm' => $commentForm));
     }
     // save the object
     /* SHOULD USE IMBEDDED FORMS
            Used this hack instead.  Need to fix
            -B.Shaffer
        */
     $commentVals = $commentForm->getValues();
     $commenter = new Commenter();
     $commenter->fromArray($commentVals['Commenter']);
     $commenter->save();
     $comment = new Comment();
     $comment['body'] = $commentVals['body'];
     $comment['Commenter'] = $commenter;
     $comment->save();
     $this->comment = $comment;
     // Pass parent comment id if comment is nested
     $parent_id = $this->getRequestParameter('comment_id');
     $this->record->addComment($this->comment, $parent_id);
     $this->record->save();
 }
Example #2
0
 public function actionComment($callback, $id = 0)
 {
     $id = (int) $id;
     $callback = strip_tags(trim($callback));
     if (!request()->getIsAjaxRequest() || !request()->getIsPostRequest() || empty($callback)) {
         throw new CHttpException(500);
     }
     $data = array();
     $model = new CommentForm();
     $model->attributes = $_POST['CommentForm'];
     $model->content = h($model->content);
     if ($id > 0 && ($quote = Comment::model()->findByPk($id))) {
         $quoteTitle = sprintf(t('comment_quote_title'), $quote->authorName);
         $html = '<fieldset class="beta-comment-quote"><legend>' . $quoteTitle . '</legend>' . $quote->content . '</fieldset>';
         $model->content = $html . $model->content;
     }
     if ($model->validate() && ($comment = $model->save())) {
         $data['errno'] = 0;
         $data['text'] = t('ajax_comment_done');
         $data['html'] = $this->renderPartial('/comment/_one', array('comment' => $comment), true);
         // @todo 反回此条评论的html代码
     } else {
         $data['errno'] = 1;
         $attributes = array_keys($model->getErrors());
         foreach ($attributes as $attribute) {
             $labels[] = $model->getAttributeLabel($attribute);
         }
         $errstr = join(' ', $labels);
         $data['text'] = sprintf(t('ajax_comment_error'), $errstr);
     }
     echo $callback . '(' . json_encode($data) . ')';
     exit(0);
 }
Example #3
0
 public function actionCreate($id = 0, $callback)
 {
     // @todo 暂时无用
     if (!request()->getIsAjaxRequest() || !request()->getIsPostRequest()) {
         throw new CHttpException(500);
     }
     $data = array();
     $model = new CommentForm();
     $model->attributes = $_POST['CommentForm'];
     if ($model->validate() && ($comment = $model->save())) {
         $data['errno'] = 0;
         $data['text'] = t('ajax_comment_done');
         $data['html'] = 'x';
         // @todo 反回此条评论的html代码
     } else {
         $data['errno'] = 1;
         $attributes = array_keys($model->getErrors());
         foreach ($attributes as $attribute) {
             $labels[] = $model->getAttributeLabel($attribute);
         }
         $errstr = join(' ', $labels);
         $data['text'] = sprintf(t('ajax_comment_error'), $errstr);
     }
     echo json_encode($data);
     exit(0);
 }
Example #4
0
 public function run()
 {
     $newComment = $this->createComment();
     $comments = $newComment->getCommentsThree();
     $form = new CommentForm();
     $form->url = $this->url;
     $form->modelName = $this->getModelName();
     $form->modelId = $this->getModelId();
     $form->defineShowRating();
     $this->render('commentsListWidget', array('comments' => $comments, 'newComment' => $newComment, 'form' => $form));
 }
 public function actionUpdatecomment($id)
 {
     //if(!Yii::$app->user->isGuest && Yii::$app->user->identity->role == 'admin'){
     $model = new CommentForm();
     if ($model->load(Yii::$app->request->post())) {
         $comment = CommentsActiveRecord::findOne($id);
         $comment->body = $model->body;
         $comment->save();
     }
     //}
     //return $this->goBack();
 }
Example #6
0
 public function executeFormWidget(dmWebRequest $request)
 {
     $form = new CommentForm();
     if ($request->isMethod('post')) {
         $captcha = array('recaptcha_challenge_field' => $request->getParameter('recaptcha_challenge_field'), 'recaptcha_response_field' => $request->getParameter('recaptcha_response_field'));
         $form->bind(array_merge($request->getParameter($form->getName()), array('captcha' => $captcha)));
         if ($form->isValid()) {
             $form->save();
             $this->getUser()->setFlash('form_saved', true);
             $this->redirectBack();
         }
     }
     $this->forms['Comment'] = $form;
 }
Example #7
0
function customHead()
{
    ?>
        <script type="text/javascript" src="<?php 
    echo osc_current_admin_theme_js_url('jquery.validate.min.js');
    ?>
"></script>
        <?php 
    CommentForm::js_validation(true);
}
Example #8
0
 public function actionWriteComment()
 {
     $model = new CommentForm();
     if (isset($_POST['CommentForm']) && BlockIp::checkAllowIp(Yii::app()->controller->currentUserIpLong)) {
         $model->attributes = $_POST['CommentForm'];
         $model->defineShowRating();
         if ($model->validate() && Comment::checkExist(null, $model->modelName, $model->modelId)) {
             if ($model->modelName == 'News' && !param('enableCommentsForNews', 1) || $model->modelName == 'Apartment' && !param('enableCommentsForApartments', 1) || $model->modelName == 'Menu' && !param('enableCommentsForPages', 0) || $model->modelName == 'Article' && !param('enableCommentsForFaq', 1) || $model->modelName == 'InfoPages' && !param('enableCommentsForPages', 0)) {
                 throw404();
             }
             $comment = new Comment();
             $comment->body = $model->body;
             $comment->parent_id = $model->rel;
             $comment->user_ip = Yii::app()->controller->currentUserIp;
             $comment->user_ip_ip2_long = Yii::app()->controller->currentUserIpLong;
             if ($model->rel == 0) {
                 $comment->rating = $model->rating;
             } else {
                 $comment->rating = -1;
             }
             $comment->model_name = $model->modelName;
             $comment->model_id = $model->modelId;
             if (Yii::app()->user->isGuest) {
                 $comment->user_name = $model->user_name;
                 $comment->user_email = $model->user_email;
             } else {
                 $comment->owner_id = Yii::app()->user->id;
             }
             if (param('commentNeedApproval', 1) && !Yii::app()->user->checkAccess('backend_access')) {
                 $comment->status = Comment::STATUS_PENDING;
                 Yii::app()->user->setFlash('success', Yii::t('module_comments', 'Thank you for your comment. Your comment will be posted once it is approved.'));
             } else {
                 $comment->status = Comment::STATUS_APPROVED;
                 Yii::app()->user->setFlash('success', Yii::t('module_comments', 'Thank you for your comment.'));
             }
             $comment->save(false);
             $this->redirect($model->url);
         }
     }
     $this->render('commentForm', array('model' => $model));
 }
 /**
  * Display the form.
  */
 function display()
 {
     $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
     $reviewAssignment =& $reviewAssignmentDao->getById($this->reviewId);
     $templateMgr =& TemplateManager::getManager();
     $templateMgr->assign('commentType', 'peerReview');
     $templateMgr->assign('pageTitle', 'submission.comments.review');
     $templateMgr->assign('commentAction', 'postPeerReviewComment');
     $templateMgr->assign('commentTitle', strip_tags($this->article->getScientificTitle()));
     $templateMgr->assign('isLocked', isset($reviewAssignment) && $reviewAssignment->getDateCompleted() != null);
     $templateMgr->assign('canEmail', false);
     // Previously, editors could always email.
     $templateMgr->assign('showReviewLetters', $this->roleId == ROLE_ID_EDITOR || $this->roleId == ROLE_ID_SECTION_EDITOR ? true : false);
     $templateMgr->assign('reviewer', ROLE_ID_REVIEWER);
     $templateMgr->assign('hiddenFormParams', array('articleId' => $this->article->getArticleId(), 'reviewId' => $this->reviewId));
     parent::display();
 }
Example #10
0
 /**
  * Display the form.
  */
 function display()
 {
     $reviewAssignmentDao = DAORegistry::getDAO('ReviewAssignmentDAO');
     $reviewAssignment =& $reviewAssignmentDao->getById($this->reviewId);
     $reviewLetters =& $reviewAssignmentDao->getReviewIndexesForRound($this->paper->getPaperId(), $this->paper->getCurrentRound());
     $templateMgr =& TemplateManager::getManager();
     $templateMgr->assign('commentType', 'peerReview');
     $templateMgr->assign('pageTitle', 'submission.comments.review');
     $templateMgr->assign('commentAction', 'postPeerReviewComment');
     $templateMgr->assign('commentTitle', strip_tags($this->paper->getLocalizedTitle()));
     $templateMgr->assign('isLocked', isset($reviewAssignment) && $reviewAssignment->getDateCompleted() != null);
     $templateMgr->assign('canEmail', false);
     // Previously, directors could always email.
     $templateMgr->assign('showReviewLetters', $this->roleId == ROLE_ID_DIRECTOR ? true : false);
     $templateMgr->assign('reviewLetters', $reviewLetters);
     $templateMgr->assign('reviewer', ROLE_ID_REVIEWER);
     $templateMgr->assign('hiddenFormParams', array('paperId' => $this->paper->getPaperId(), 'reviewId' => $this->reviewId));
     parent::display();
 }
 /**
  * Email the comment.
  */
 function email()
 {
     $article = $this->article;
     $roleDao =& DAORegistry::getDAO('RoleDAO');
     $signoffDao =& DAORegistry::getDAO('SignoffDAO');
     $userDao =& DAORegistry::getDAO('UserDAO');
     $journal =& Request::getJournal();
     // Create list of recipients:
     $recipients = array();
     // Copyedit comments are to be sent to the editor, author, and copyeditor,
     // excluding whomever posted the comment.
     $editorAddresses = array();
     $sectionEditorsDao =& DAORegistry::getDAO('SectionEditorsDAO');
     $sectionEditors =& $sectionEditorsDao->getEditorsBySectionId($journal->getId(), $article->getSectionId());
     foreach ($sectionEditors as $sectionEditor) {
         $editorAddresses[$sectionEditor->getEmail()] = $sectionEditor->getFullName();
     }
     // If no editors are currently assigned, send this message to
     // all of the journal's editors.
     if (empty($editorAddresses)) {
         $editors =& $roleDao->getUsersByRoleId(ROLE_ID_EDITOR, $journal->getId());
         while (!$editors->eof()) {
             $editor =& $editors->next();
             $editorAddresses[$editor->getEmail()] = $editor->getFullName();
         }
     }
     // Get copyeditor
     $copySignoff = $signoffDao->getBySymbolic('SIGNOFF_COPYEDITING_INITIAL', ASSOC_TYPE_ARTICLE, $article->getId());
     if ($copySignoff != null && $copySignoff->getUserId() > 0) {
         $copyeditor =& $userDao->getUser($copySignoff->getUserId());
     } else {
         $copyeditor = null;
     }
     // Get author
     $author =& $userDao->getUser($article->getUserId());
     // Choose who receives this email
     if ($this->roleId == ROLE_ID_EDITOR || $this->roleId == ROLE_ID_SECTION_EDITOR) {
         // Then add copyeditor and author
         if ($copyeditor != null) {
             $recipients = array_merge($recipients, array($copyeditor->getEmail() => $copyeditor->getFullName()));
         }
         $recipients = array_merge($recipients, array($author->getEmail() => $author->getFullName()));
     } else {
         if ($this->roleId == ROLE_ID_COPYEDITOR) {
             // Then add editors and author
             $recipients = array_merge($recipients, $editorAddresses);
             if (isset($author)) {
                 $recipients = array_merge($recipients, array($author->getEmail() => $author->getFullName()));
             }
         } else {
             // Then add editors and copyeditor
             $recipients = array_merge($recipients, $editorAddresses);
             if ($copyeditor != null) {
                 $recipients = array_merge($recipients, array($copyeditor->getEmail() => $copyeditor->getFullName()));
             }
         }
     }
     parent::email($recipients);
 }
Example #12
0
            ?>
                                </div>
                            </div>
                            <?php 
        }
        ?>

                            <div class="form-group col-md-12">
                                <label class="control-label" for="body">
                                    <?php 
        _e('Comment', 'osclasswizards');
        ?>
                                </label>
                                <div class="controls textarea">
                                    <?php 
        CommentForm::body_input_textarea();
        ?>
                                </div>
                            </div>
                            <div class="actions col-md-12">
                                <button type="submit" class="btn btn-success">
                                    <?php 
        _e('Send', 'osclasswizards');
        ?>
                                </button>
                            </div>
                        </fieldset>
                    </form>
                </div>
            </div>
        </div>
 /**
  * Функция добавление комментов 
  */
 protected function addComment(&$model)
 {
     if (isset($_POST['CommentForm'])) {
         $commentForm = new CommentForm();
         $commentForm->attributes = $_POST['CommentForm'];
         if ($commentForm->validate()) {
             Yii::app()->user->setState('CommentForm', null);
             $comment = new Comment();
             $comment->attributes = $_POST['CommentForm'];
             $comment->object_type = L::r_item('CommentType', get_class($model));
             $comment->object_id = $model->id;
             $comment->created = date('Y-m-d H:i:s');
             $comment->rating = 0;
             $comment->status = L::r_item('commentStatus', 'new');
             if ($parent = Comment::model()->findbyPk((int) $commentForm->parent)) {
                 $parent->append($comment);
             } else {
                 $comment->saveNode();
             }
             Yii::app()->user->setFlash('comment', array('text' => 'Спасибо за Ваш комментарий', 'class' => 'error'));
             $this->redirect(Yii::app()->request->requestUri . '#comment-' . $comment->id);
         } else {
             Yii::app()->user->setState('CommentForm', $commentForm);
         }
     } else {
         Yii::app()->user->setState('CommentForm', null);
     }
 }
 /**
  * Email the comment.
  */
 function email()
 {
     $roleDao =& DAORegistry::getDAO('RoleDAO');
     $userDao =& DAORegistry::getDAO('UserDAO');
     $journal =& Request::getJournal();
     // Create list of recipients:
     // Editor Decision comments are to be sent to the editor or author,
     // the opposite of whomever wrote the comment.
     $recipients = array();
     if ($this->roleId == ROLE_ID_EDITOR || $this->roleId == ROLE_ID_SECTION_EDITOR) {
         // Then add author
         $user =& $userDao->getUser($this->article->getUserId());
         if ($user) {
             $recipients = array_merge($recipients, array($user->getEmail() => $user->getFullName()));
         }
     } else {
         // Then add editor
         $editAssignmentDao =& DAORegistry::getDAO('EditAssignmentDAO');
         $editAssignments =& $editAssignmentDao->getEditAssignmentsByArticleId($this->article->getId());
         $editorAddresses = array();
         while (!$editAssignments->eof()) {
             $editAssignment =& $editAssignments->next();
             $editorAddresses[$editAssignment->getEditorEmail()] = $editAssignment->getEditorFullName();
         }
         // If no editors are currently assigned to this article,
         // send the email to all editors for the journal
         if (empty($editorAddresses)) {
             $editors =& $roleDao->getUsersByRoleId(ROLE_ID_EDITOR, $journal->getId());
             while (!$editors->eof()) {
                 $editor =& $editors->next();
                 $editorAddresses[$editor->getEmail()] = $editor->getFullName();
             }
         }
         $recipients = array_merge($recipients, $editorAddresses);
     }
     parent::email($recipients);
 }
Example #15
0
 public function _calcRating()
 {
     $form = new CommentForm();
     $form->modelName = $this->model_name;
     $form->defineShowRating();
     if ($form->enableRating && $this->rating != -1) {
         $rating = self::calcRating($this->model_name, $this->model_id);
         $tmp = new $this->model_name();
         $tmp->writeRating($this->model_id, $rating);
     }
 }
 protected function setupInheritance()
 {
     parent::setupInheritance();
     $this->widgetSchema->setNameFormat('comment_fish_event[%s]');
 }
Example #17
0
 /**
  * Email the comment.
  */
 function email()
 {
     $roleDao =& DAORegistry::getDAO('RoleDAO');
     $userDao =& DAORegistry::getDAO('UserDAO');
     $journal =& Request::getJournal();
     // Create list of recipients:
     // Layout comments are to be sent to the editor or layout editor;
     // the opposite of whomever posted the comment.
     $recipients = array();
     if ($this->roleId == ROLE_ID_EDITOR || $this->roleId == ROLE_ID_SECTION_EDITOR) {
         // Then add layout editor
         $signoffDao =& DAORegistry::getDAO('SignoffDAO');
         $layoutSignoff = $signoffDao->getBySymbolic('SIGNOFF_LAYOUT', ASSOC_TYPE_ARTICLE, $this->article->getId());
         // Check to ensure that there is a layout editor assigned to this article.
         if ($layoutSignoff != null && $layoutSignoff->getUserId() > 0) {
             $user =& $userDao->getUser($layoutSignoff->getUserId());
             if ($user) {
                 $recipients = array_merge($recipients, array($user->getEmail() => $user->getFullName()));
             }
         }
     } else {
         // Then add editor
         $editAssignmentDao =& DAORegistry::getDAO('EditAssignmentDAO');
         $editAssignments =& $editAssignmentDao->getEditAssignmentsByArticleId($this->article->getId());
         $editorAddresses = array();
         while (!$editAssignments->eof()) {
             $editAssignment =& $editAssignments->next();
             if ($editAssignment->getCanEdit()) {
                 $editorAddresses[$editAssignment->getEditorEmail()] = $editAssignment->getEditorFullName();
             }
             unset($editAssignment);
         }
         // If no editors are currently assigned to this article,
         // send the email to all editors for the journal
         if (empty($editorAddresses)) {
             $editors =& $roleDao->getUsersByRoleId(ROLE_ID_EDITOR, $journal->getId());
             while (!$editors->eof()) {
                 $editor =& $editors->next();
                 $editorAddresses[$editor->getEmail()] = $editor->getFullName();
             }
         }
         $recipients = array_merge($recipients, $editorAddresses);
     }
     parent::email($recipients);
 }
Example #18
0
 /**
  * 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();
 }
Example #19
0
        $this->number = new IntegerField("Favorite number", 7, array(PhormValidation::Required));
        $this->message = new LargeTextField('Message', 5, 40, array(PhormValidation::Required));
        $this->notify = new BooleanField('Reply notification');
        $this->date = new DateTimeField('Date', array(PhormValidation::Required));
        // Add some help text
        $this->notify->set_help_text('Email me when my comment receives a response.');
        $this->email->set_help_text('We will never give out your email address.');
    }
    public function report()
    {
        var_dump($this->cleaned_data());
    }
}
// Set up the form
$post_id = 42;
$form = new CommentForm(Phorm::POST, false, array('post_id' => $post_id, 'notify' => true));
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr" dir="ltr">
	<head>
		<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
		<title>Comment form</title>
		<script src="../src/javascript/scriptaculous/lib/prototype.js" type="text/javascript"></script>
		<script src="../src/javascript/scriptaculous/src/effects.js" type="text/javascript"></script>
		<script src="../src/javascript/validation.php" type="text/javascript"></script>
		<style type="text/css">
			form .phorm_help {
				margin: 0;
				padding: 2px;
				font-size: 10pt;
				font-style: oblique;
Example #20
0
 public function executeComment(sfWebRequest $request)
 {
     $comment = new Comment();
     $comment->setTicketId($request->getParameter('id'));
     $form = new CommentForm($comment);
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $this->getUser()->setFlash('message', array('success', 'Отлично!', 'Комментарий добавлен.'));
         $comment = $form->save();
         $this->redirect('@tickets-show?id=' . $comment->getTicketId());
     } else {
         //$this->redirect('@tickets-show?id=' . $request->getParameter('id'));
         $this->form = $form;
     }
 }
Example #21
0
 /**
  * Email the comment.
  */
 function email()
 {
     $article = $this->article;
     $roleDao =& DAORegistry::getDAO('RoleDAO');
     $userDao =& DAORegistry::getDAO('UserDAO');
     $journal =& Request::getJournal();
     // Create list of recipients:
     $recipients = array();
     // Copyedit comments are to be sent to the editor, author, and copyeditor,
     // excluding whomever posted the comment.
     // Get editors
     $editAssignmentDao =& DAORegistry::getDAO('EditAssignmentDAO');
     $editAssignments =& $editAssignmentDao->getEditAssignmentsByArticleId($article->getArticleId());
     $editAssignments =& $editAssignments->toArray();
     $editorAddresses = array();
     foreach ($editAssignments as $editAssignment) {
         if ($editAssignment->getCanEdit()) {
             $editorAddresses[$editAssignment->getEditorEmail()] = $editAssignment->getEditorFullName();
         }
     }
     // If no editors are currently assigned, send this message to
     // all of the journal's editors.
     if (empty($editorAddresses)) {
         $editors =& $roleDao->getUsersByRoleId(ROLE_ID_EDITOR, $journal->getJournalId());
         while (!$editors->eof()) {
             $editor =& $editors->next();
             $editorAddresses[$editor->getEmail()] = $editor->getFullName();
         }
     }
     // Get copyeditor
     $copyAssignmentDao =& DAORegistry::getDAO('CopyAssignmentDAO');
     $copyAssignment =& $copyAssignmentDao->getCopyAssignmentByArticleId($article->getArticleId());
     if ($copyAssignment != null && $copyAssignment->getCopyeditorId() > 0) {
         $copyeditor =& $userDao->getUser($copyAssignment->getCopyeditorId());
     } else {
         $copyeditor = null;
     }
     // Get author
     $author =& $userDao->getUser($article->getUserId());
     // Choose who receives this email
     if ($this->roleId == ROLE_ID_EDITOR || $this->roleId == ROLE_ID_SECTION_EDITOR) {
         // Then add copyeditor and author
         if ($copyeditor != null) {
             $recipients = array_merge($recipients, array($copyeditor->getEmail() => $copyeditor->getFullName()));
         }
         $recipients = array_merge($recipients, array($author->getEmail() => $author->getFullName()));
     } else {
         if ($this->roleId == ROLE_ID_COPYEDITOR) {
             // Then add editors and author
             $recipients = array_merge($recipients, $editorAddresses);
             if (isset($author)) {
                 $recipients = array_merge($recipients, array($author->getEmail() => $author->getFullName()));
             }
         } else {
             // Then add editors and copyeditor
             $recipients = array_merge($recipients, $editorAddresses);
             if ($copyeditor != null) {
                 $recipients = array_merge($recipients, array($copyeditor->getEmail() => $copyeditor->getFullName()));
             }
         }
     }
     parent::email($recipients);
 }
Example #22
0
echo $comment['b_enabled'] == 1 ? 'DISABLE' : 'ENABLE';
?>
"><?php 
echo $comment['b_enabled'] == 1 ? __('Disable') : __('Enable');
?>
</a> )
                            </div>
                        </div>
                        <div class="FormElement">
                            <label><div class="FormElementName"><?php 
_e('Comment');
?>
</div></label>
                            <div class="FormElementInput">
                               <?php 
CommentForm::body_input_textarea($comment);
?>
                            </div>
                        </div>

                        <div class="clear50"></div>

                        <div class="FormElement FormButtonsSubmit">
                            <div class="FormElementName"></div>
                            <div class="FormElementInput">
                                <input class="formButton" type="button" onclick="window.location='<?php 
echo osc_admin_base_url(true);
?>
?page=comments';" value="<?php 
_e('Cancel');
?>
Example #23
0
    } else {
        ?>
        <div class="no-comments">
            <?php 
        _e('No comments', 'flatter');
        ?>
        </div>
        <?php 
    }
    ?>
        <?php 
    if (osc_reg_user_post_comments() && osc_is_web_user_logged_in() || !osc_reg_user_post_comments()) {
        ?>
        <!--<ul id="comment_error_list"></ul>-->
        <?php 
        CommentForm::js_validation();
        ?>
        <div class="post-comments">
            <div class="comment clearfix">
                    <div class="pull-left avatar">
                        <?php 
        if (function_exists("profile_picture_show")) {
            ?>
							<?php 
            current_user_picture();
            ?>
                        <?php 
        } else {
            ?>
                            <img class="img-responsive" src="http://www.gravatar.com/avatar/<?php 
            echo md5(strtolower(trim(osc_logged_user_email())));
 /**
  * Email the comment.
  */
 function email()
 {
     $roleDao =& DAORegistry::getDAO('RoleDAO');
     $signoffDao =& DAORegistry::getDAO('SignoffDAO');
     $userDao =& DAORegistry::getDAO('UserDAO');
     $journal =& Request::getJournal();
     // Create list of recipients:
     $recipients = array();
     // Proofread comments are to be sent to the editors, layout editor, proofreader, and author,
     // excluding whomever posted the comment.
     // Get editors
     $editAssignmentDao =& DAORegistry::getDAO('EditAssignmentDAO');
     $editAssignments =& $editAssignmentDao->getEditAssignmentsByArticleId($this->article->getId());
     $editorAddresses = array();
     while (!$editAssignments->eof()) {
         $editAssignment =& $editAssignments->next();
         if ($editAssignment->getCanEdit()) {
             $editorAddresses[$editAssignment->getEditorEmail()] = $editAssignment->getEditorFullName();
         }
         unset($editAssignment);
     }
     // If no editors are currently assigned to this article,
     // send the email to all editors for the journal
     if (empty($editorAddresses)) {
         $editors =& $roleDao->getUsersByRoleId(ROLE_ID_EDITOR, $journal->getId());
         while (!$editors->eof()) {
             $editor =& $editors->next();
             $editorAddresses[$editor->getEmail()] = $editor->getFullName();
         }
     }
     // Get layout editor
     $layoutSignoff = $signoffDao->getBySymbolic('SIGNOFF_LAYOUT', ASSOC_TYPE_ARTICLE, $this->article->getId());
     if ($layoutSignoff != null && $layoutSignoff->getUserId() > 0) {
         $layoutEditor =& $userDao->getUser($layoutSignoff->getUserId());
     } else {
         $layoutEditor = null;
     }
     // Get proofreader
     $proofSignoff = $signoffDao->getBySymbolic('SIGNOFF_PROOFREADING_PROOFREADER', ASSOC_TYPE_ARTICLE, $this->article->getId());
     if ($proofSignoff != null && $proofSignoff->getUserId() > 0) {
         $proofreader =& $userDao->getUser($proofSignoff->getUserId());
     } else {
         $proofreader = null;
     }
     // Get author
     $author =& $userDao->getUser($this->article->getUserId());
     // Choose who receives this email
     if ($this->roleId == ROLE_ID_EDITOR || $this->roleId == ROLE_ID_SECTION_EDITOR) {
         // Then add layout editor, proofreader and author
         if ($layoutEditor != null) {
             $recipients = array_merge($recipients, array($layoutEditor->getEmail() => $layoutEditor->getFullName()));
         }
         if ($proofreader != null) {
             $recipients = array_merge($recipients, array($proofreader->getEmail() => $proofreader->getFullName()));
         }
         if (isset($author)) {
             $recipients = array_merge($recipients, array($author->getEmail() => $author->getFullName()));
         }
     } else {
         if ($this->roleId == ROLE_ID_LAYOUT_EDITOR) {
             // Then add editors, proofreader and author
             $recipients = array_merge($recipients, $editorAddresses);
             if ($proofreader != null) {
                 $recipients = array_merge($recipients, array($proofreader->getEmail() => $proofreader->getFullName()));
             }
             if (isset($author)) {
                 $recipients = array_merge($recipients, array($author->getEmail() => $author->getFullName()));
             }
         } else {
             if ($this->roleId == ROLE_ID_PROOFREADER) {
                 // Then add editors, layout editor, and author
                 $recipients = array_merge($recipients, $editorAddresses);
                 if ($layoutEditor != null) {
                     $recipients = array_merge($recipients, array($layoutEditor->getEmail() => $layoutEditor->getFullName()));
                 }
                 if (isset($author)) {
                     $recipients = array_merge($recipients, array($author->getEmail() => $author->getFullName()));
                 }
             } else {
                 // Then add editors, layout editor, and proofreader
                 $recipients = array_merge($recipients, $editorAddresses);
                 if ($layoutEditor != null) {
                     $recipients = array_merge($recipients, array($layoutEditor->getEmail() => $layoutEditor->getFullName()));
                 }
                 if ($proofreader != null) {
                     $recipients = array_merge($recipients, array($proofreader->getEmail() => $proofreader->getFullName()));
                 }
             }
         }
     }
     parent::email($recipients);
 }
 /**
  * Email the comment.
  */
 function email()
 {
     $roleDao =& DAORegistry::getDAO('RoleDAO');
     $userDao =& DAORegistry::getDAO('UserDAO');
     $conference =& Request::getConference();
     // Create list of recipients:
     // Director Decision comments are to be sent to the director or author,
     // the opposite of whomever wrote the comment.
     $recipients = array();
     if ($this->roleId == ROLE_ID_DIRECTOR || $this->roleId == ROLE_ID_TRACK_DIRECTOR) {
         // Then add author
         $user =& $userDao->getUser($this->paper->getUserId());
         if ($user) {
             $recipients = array_merge($recipients, array($user->getEmail() => $user->getFullName()));
         }
     } else {
         // Then add director
         $editAssignmentDao =& DAORegistry::getDAO('EditAssignmentDAO');
         $editAssignments =& $editAssignmentDao->getEditAssignmentsByPaperId($this->paper->getPaperId());
         $directorAddresses = array();
         while (!$editAssignments->eof()) {
             $editAssignment =& $editAssignments->next();
             $directorAddresses[$editAssignment->getDirectorEmail()] = $editAssignment->getDirectorFullName();
         }
         // If no directors are currently assigned to this paper,
         // send the email to all directors for the conference
         if (empty($directorAddresses)) {
             $directors =& $roleDao->getUsersByRoleId(ROLE_ID_DIRECTOR, $conference->getId());
             while (!$directors->eof()) {
                 $director =& $directors->next();
                 $directorAddresses[$director->getEmail()] = $director->getFullName();
             }
         }
         $recipients = array_merge($recipients, $directorAddresses);
     }
     parent::email($recipients);
 }
 /**
  * I'm tired of writing comments!
  * @return form for Comments
  */
 public function CommentForm()
 {
     $siteconfig = $this->getCurrentSiteConfig();
     $params = $this->getURLParams();
     return CommentForm::create($this, 'CommentForm', $siteconfig, $params);
 }
Example #27
0
        $this->url = new Phorm_Field_URL("Home page", 25, 255);
        $this->number = new Phorm_Field_Integer("Favorite number", 20, 7, array('required'));
        $this->message = new Phorm_Field_Textarea('Message', 5, 40, array('required'));
        $this->notify = new Phorm_Field_Checkbox('Reply notification');
        // Add some help text
        $this->notify->help_text('Email me when my comment receives a response.');
        $this->email->help_text('We will never give out your email address.');
    }
    public function report()
    {
        var_dump($this->cleaned_data());
    }
}
// Set up the form
$post_id = 42;
$form = new CommentForm('post', false, array('post_id' => $post_id, 'notify' => true));
// Check form validity
$valid = $form->is_valid();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
	<head>
		<title>Comment Form example for Phorm</title>
		<link rel="stylesheet" href="assets/style.css" type="text/css" />
	</head>
	<body>
		<h1>Add a comment</h1>
		<?php 
echo $form->open();
?>
        $this->setWidget('body', new sfWidgetFormTextarea());
        $this->setValidator('body', new sfValidatorString(array('min_length' => 12)));
    }
}
$configuration = $configuration->getApplicationConfiguration('frontend', 'test', true, null, $configuration->getEventDispatcher());
sfToolkit::clearDirectory(sfConfig::get('sf_app_cache_dir'));
$enhancer = new sfFormYamlEnhancerTest($configuration->getConfigCache());
// ->enhance()
$t->diag('->enhance()');
$form = new CommentForm();
$form->bind(array('body' => '+1'));
$enhancer->enhance($form);
$t->like($form['body']->renderLabel(), '/Please enter your comment/', '->enhance() enhances labels');
$t->like($form['body']->render(), '/class="comment"/', '->enhance() enhances widgets');
$t->like($form['body']->renderError(), '/You haven\'t written enough/', '->enhance() enhances error messages');
$form = new CommentForm();
$form->bind();
$enhancer->enhance($form);
$t->like($form['body']->renderError(), '/A base required message/', '->enhance() considers inheritance');
class SpecialCommentForm extends CommentForm
{
}
$form = new SpecialCommentForm();
$form->bind();
$enhancer->enhance($form);
$t->like($form['body']->renderLabel(), '/Please enter your comment/', '->enhance() applies parent config');
$form = new BaseForm();
$form->embedForm('comment', new CommentForm());
$form->bind();
$enhancer->enhance($form);
$t->like($form['comment']['body']->renderLabel(), '/Please enter your comment/', '->enhance() enhances embedded forms');
Example #29
0
 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();
 }
Example #30
0
function customHead()
{
    CommentForm::js_validation(true);
}