예제 #1
0
    /**
     * Injects all commenting module code in other subsystems
     * @param courseCode the course code
     * @param $isEditor
     * @param $uid the user id
     * @return string
     */
    public function put($courseCode, $isEditor, $uid, $always_open = false) {
        global $langComments, $langBlogPostUser, $langSubmit, $themeimg, $langModify, $langDelete,
        $langCommentsDelConfirm, $langCommentsSaveConfirm, $urlServer, $head_content;
        
        //$head_content .= '<link rel="stylesheet" type="text/css" href="'.$urlServer.'modules/comments/style.css">';
        
        $commentsNum = $this->getCommentsNum();

        if (!$always_open) {
            $comments_title = "<button type='button' class='btn btn-primary' data-toggle='modal' data-target='#commentArea-$this->rid'>$langComments (<span id='commentsNum-$this->rid'>$commentsNum</span>)</button>";
            $out = "$comments_title
                    <div class='modal fade' id='commentArea-$this->rid' role='dialog'>
                      <div class='modal-dialog modal-lg'>
                        <div class='modal-content' style='padding:1%'>
                          <div class='modal-header'>
                            <button type='button' class='close' data-dismiss='modal'>&times;</button>
                              <h4 class='modal-title'>$langComments</h4>
                          </div>
                          <div class='modal-body' id='comments-$this->rid'>";
        } else {
            $comments_title = "<h3 id='comments_title'>$langComments (<span id='commentsNum-$this->rid'>$commentsNum</span>)</h3><br>";
            $out = "<div class='commenting'>
                        $comments_title
                    <div class='commentArea' id='commentArea-$this->rid'>
                    <div id='comments-$this->rid'>";
        }
        
        if ($commentsNum != 0) {
            //retrieve comments
            $comments = $this->getCommentsDB();
            foreach ($comments as $comment) {
                if (is_null($courseCode)) { //for the case of personal blog posts comments
                    if (isset($_SESSION['uid']) && ($isEditor || ($comment->getAuthor() == $uid))) { //$isEditor corresponds to blog editor
                        $post_actions = '<div class="pull-right">';
                        $post_actions .= '<a href="javascript:void(0)" onclick="xmlhttpPost(\''.$urlServer.'modules/comments/comments_perso_blog.php\', \'editLoad\', '.$this->rid.', \''.$this->rtype.'\', \'\', '.$comment->getId().')">';
                        $post_actions .= icon('fa-edit', $langModify).'</a> ';
                        $post_actions .= '<a href="javascript:void(0)" onclick="xmlhttpPost(\''.$urlServer.'modules/comments/comments_perso_blog.php\', \'delete\', '.$this->rid.', \''.$this->rtype.'\', \''.$langCommentsDelConfirm.'\', '.$comment->getId().')">';
                        $post_actions .= icon('fa-times', $langDelete).'</a>';
                        $post_actions .='</div>';
                    } else {
                        $post_actions = '';
                    }
                } else {
                    if ($comment->permEdit($isEditor, $uid)) {
                        $post_actions = '<div class="pull-right">';
                        $post_actions .= '<a href="javascript:void(0)" onclick="xmlhttpPost(\''.$urlServer.'modules/comments/comments.php?course='.$courseCode.'\', \'editLoad\', '.$this->rid.', \''.$this->rtype.'\', \'\', '.$comment->getId().')">';
                        $post_actions .= icon('fa-edit', $langModify).'</a> ';
                        $post_actions .= '<a href="javascript:void(0)" onclick="xmlhttpPost(\''.$urlServer.'modules/comments/comments.php?course='.$courseCode.'\', \'delete\', '.$this->rid.', \''.$this->rtype.'\', \''.$langCommentsDelConfirm.'\', '.$comment->getId().')">';
                        $post_actions .= icon('fa-times', $langDelete).'</a>';
                
                        if (abuse_report_show_flag('comment', $comment->getId(), course_code_to_id($courseCode), $isEditor)) {
                            $post_actions .= abuse_report_icon_flag ('comment', $comment->getId(), course_code_to_id($courseCode)); 
                        }
                
                        $post_actions .='</div>';
                    } else {
                        if (abuse_report_show_flag('comment', $comment->getId(), course_code_to_id($courseCode), $isEditor)) {
                            $post_actions = '<div class="pull-right">'.abuse_report_icon_flag ('comment', $comment->getId(), course_code_to_id($courseCode)).'</div>';
                        } else {
                            $post_actions = '';
                        }
                    }
                }           
                $out .= "<div class='row margin-bottom-thin margin-top-thin comment' id='comment-".$comment->getId()."'>
                          <div class='col-xs-12'>
                           <div class='media'>
                            <a class='media-left' href='#'>
                            ". profile_image($comment->getAuthor(), IMAGESIZE_SMALL) ."
                            </a>
                            <div class='media-body bubble'>
                             <div class='label label-success media-heading'>".nice_format($comment->getTime(), true).'</div>'.
                              "<small>".$langBlogPostUser.display_user($comment->getAuthor(), false, false)."</small>".
                               $post_actions
                               ."<div class='margin-top-thin' id='comment_content-".$comment->getId()."'>". q($comment->getContent()) ."</div>
                               </div>
                            </div>
                          </div>
                         </div>";              
            }
        }
        $out .= "</div>";
        
        if (is_null($courseCode)) { //for the case of personal blog posts comments
            if (isset($_SESSION['uid'])) {
                $out .= '<form action="" onsubmit="xmlhttpPost(\''.$urlServer.'modules/comments/comments_perso_blog.php\', \'new\','.$this->rid.', \''.$this->rtype.'\', \''.$langCommentsSaveConfirm.'\'); return false;">';
                $out .= '<textarea class="form-control" name="textarea" id="textarea-'.$this->rid.'" rows="5"></textarea><br/>';
                $out .= '<input class="btn btn-primary" name="send_button" type="submit" value="'.$langSubmit.'" />';
                $out .= '</form>';
            } 
        } else {
            if (Commenting::permCreate($isEditor, $uid, course_code_to_id($courseCode))) {
                $out .= '<form action="" onsubmit="xmlhttpPost(\''.$urlServer.'modules/comments/comments.php?course='.$courseCode.'\', \'new\','.$this->rid.', \''.$this->rtype.'\', \''.$langCommentsSaveConfirm.'\'); return false;">';
                $out .= '<textarea class="form-control" name="textarea" id="textarea-'.$this->rid.'" rows="5"></textarea><br/>';
                $out .= '<input class="btn btn-primary" name="send_button" type="submit" value="'.$langSubmit.'" />';
                $out .= '</form>';
            }
        }
        
        if (!$always_open) {
            $out .= '<div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                     </div>';
            $out .= '</div>';
        }
        
        $out .= '</div>';
        $out .= '</div>';
        
        return $out;
    }
예제 #2
0
require_once 'class.commenting.php';


if ($_POST['rtype'] == 'blogpost') {
    $setting_id = SETTING_BLOG_COMMENT_ENABLE;
} elseif ($_POST['rtype'] == 'course') {
    $setting_id = SETTING_COURSE_COMMENT_ENABLE;
}

if (setting_get($setting_id, $course_id) == 1) {
    //response array
    //[0] -> status, [1] -> message, other positions -> other data 
    $response = array();
    
    if ($_POST['action'] == 'new') {
        if (Commenting::permCreate($is_editor, $uid, $course_id)) {
            $comment = new Comment();
            if ($comment->create($_POST['commentText'], $uid, $_POST['rtype'], intval($_POST['rid']))) {
                $post_actions = '<div class="pull-right">';
                $post_actions .= '<a href="javascript:void(0)" onclick="xmlhttpPost(\''.$urlServer.'modules/comments/comments.php?course='.$course_code.'\', \'editLoad\', '.$_POST['rid'].', \''.$_POST['rtype'].'\', \'\', '.$comment->getId().')">';
                $post_actions .= icon('fa-edit', $langModify).'</a> ';
                $post_actions .= '<a href="javascript:void(0)" onclick="xmlhttpPost(\''.$urlServer.'modules/comments/comments.php?course='.$course_code.'\', \'delete\', '.$_POST['rid'].', \''.$_POST['rtype'].'\', \''.$langCommentsDelConfirm.'\', '.$comment->getId().')">';
                $post_actions .= icon('fa-times', $langDelete).'</a>';
                $post_actions .='</div>';   
                
                $response[0] = 'OK';
                $response[1] = "<div class='alert alert-success'>".$langCommentsSaveSuccess."</div>";
                $response[2] = $comment->getId();
                $response[3] = "
         <div class='row margin-bottom-thin margin-top-thin comment' id='comment-".$comment->getId()."'>
                    <div class='col-xs-12'>
예제 #3
0
 /**
  * Injects all commenting module code in other subsystems
  * @param courseCode the course code
  * @param $isEditor
  * @param $uid the user id
  * @return string
  */
 public function put($courseCode, $isEditor, $uid, $always_open = false)
 {
     global $langComments, $langBlogPostUser, $langSubmit, $themeimg, $langModify, $langDelete, $langCommentsDelConfirm, $langCommentsSaveConfirm, $urlServer, $head_content;
     //$head_content .= '<link rel="stylesheet" type="text/css" href="'.$urlServer.'modules/comments/style.css">';
     $commentsNum = $this->getCommentsNum();
     if (!$always_open) {
         $comments_title = "<a id='comments_title' href='javascript:void(0)' onclick='showComments(\"{$this->rid}\")'>{$langComments} (<span id='commentsNum-{$this->rid}'>{$commentsNum}</span>)</a><br>";
         $comments_display = "style='display:none'";
     } else {
         $comments_title = "<h3 id='comments_title'>{$langComments} (<span id='commentsNum-{$this->rid}'>{$commentsNum}</span>)</h3><br>";
         $comments_display = "";
     }
     //the array is declared in commenting.js
     $out = "<script type='text/javascript'>showCommentArea[{$this->rid}] = false;</script>\r\n                <div class='commenting'>\r\n                    {$comments_title}\r\n                <div class='commentArea' id='commentArea-{$this->rid}' {$comments_display}>\r\n                <div id='comments-{$this->rid}'>";
     if ($commentsNum != 0) {
         //retrieve comments
         $comments = $this->getCommentsDB();
         foreach ($comments as $comment) {
             if ($comment->permEdit($isEditor, $uid)) {
                 $post_actions = '<div class="pull-right">';
                 $post_actions .= '<a href="javascript:void(0)" onclick="xmlhttpPost(\'' . $urlServer . 'modules/comments/comments.php?course=' . $courseCode . '\', \'editLoad\', ' . $this->rid . ', \'' . $this->rtype . '\', \'\', ' . $comment->getId() . ')">';
                 $post_actions .= icon('fa-edit', $langModify) . '</a> ';
                 $post_actions .= '<a href="javascript:void(0)" onclick="xmlhttpPost(\'' . $urlServer . 'modules/comments/comments.php?course=' . $courseCode . '\', \'delete\', ' . $this->rid . ', \'' . $this->rtype . '\', \'' . $langCommentsDelConfirm . '\', ' . $comment->getId() . ')">';
                 $post_actions .= icon('fa-times', $langDelete) . '</a>';
                 $post_actions .= '</div>';
             } else {
                 $post_actions = '';
             }
             $out .= "<div class='row margin-bottom-thin margin-top-thin comment' id='comment-" . $comment->getId() . "'>\r\n            <div class='col-xs-12'>\r\n                <div class='media'>\r\n                    <a class='media-left' href='#'>\r\n                        " . profile_image($comment->getAuthor(), IMAGESIZE_SMALL) . "\r\n                    </a>\r\n                    <div class='media-body bubble'>\r\n                        <div class='label label-success media-heading'>" . nice_format($comment->getTime(), true) . '</div>' . "<small>" . $langBlogPostUser . display_user($comment->getAuthor(), false, false) . "</small>" . $post_actions . "<div class='margin-top-thin' id='comment_content-" . $comment->getId() . "'>" . q($comment->getContent()) . "</div>\r\n                    </div>\r\n                </div>\r\n            </div>\r\n        </div>";
         }
     }
     $out .= "</div>";
     if (Commenting::permCreate($isEditor, $uid, course_code_to_id($courseCode))) {
         $out .= '<form action="" onsubmit="xmlhttpPost(\'' . $urlServer . 'modules/comments/comments.php?course=' . $courseCode . '\', \'new\',' . $this->rid . ', \'' . $this->rtype . '\', \'' . $langCommentsSaveConfirm . '\'); return false;">';
         $out .= '<textarea class="form-control" name="textarea" id="textarea-' . $this->rid . '" rows="5"></textarea><br/>';
         $out .= '<input class="btn btn-primary" name="send_button" type="submit" value="' . $langSubmit . '" />';
         $out .= '</form>';
     }
     $out .= '</div>';
     $out .= '</div>';
     return $out;
 }