Example #1
0
 /**
  * Ajax Call
  * Set as unresolve
  */
 public function unresolve($postId = null)
 {
     $ajax = new Disjax();
     if (empty($postId)) {
         $ajax->assign('dc_main_notifications .msg_in', JText::_('COM_EASYDISCUSS_SYSTEM_INVALID_ID'));
         $ajax->script('EasyDiscuss.$( "#reports-msg .msg_in" ).addClass( "alert alert-error" );');
         $ajax->send();
         $ajax->success();
         return;
     }
     $post = DiscussHelper::getTable('Post');
     $post->load($postId);
     $isMine = DiscussHelper::isMine($post->user_id);
     $isAdmin = DiscussHelper::isSiteAdmin();
     $isModerator = DiscussHelper::getHelper('Moderator')->isModerator($post->category_id);
     if (!$isMine && !$isAdmin) {
         if (!$isModerator) {
             $ajax->assign('dc_main_notifications', JText::_('COM_EASYDISCUSS_SYSTEM_INSUFFICIENT_PERMISSIONS'));
             $ajax->script('EasyDiscuss.$( "#dc_main_notifications" ).addClass( "alert alert-error" );');
             $ajax->send();
             return;
         }
     }
     //update isresolve flag
     $post->isresolve = DISCUSS_ENTRY_UNRESOLVED;
     if (!$post->store()) {
         $ajax->assign('dc_main_notifications .msg_in', $post->getError());
         $ajax->script('EasyDiscuss.$( "#dc_main_notifications .msg_in" ).addClass( "alert alert-error" );');
         $ajax->send();
         $ajax->success();
         return;
     }
     // now we clear off all the accepted answers.
     $post->clearAccpetedReply();
     // Clear resolved buttons.
     $ajax->script('EasyDiscuss.$(".discuss-status #post_unresolve_link").remove();');
     //$ajax->assign( 'dc_main_notifications .msg_in' , JText::_('COM_EASYDISCUSS_ENTRY_UNRESOLVED') );
     $ajax->assign('dc_main_notifications', JText::_('COM_EASYDISCUSS_ENTRY_UNRESOLVED'));
     $ajax->script('EasyDiscuss.$( "#dc_main_notifications .msg_in" ).addClass( "dc_success" );');
     $ajax->script('EasyDiscuss.$( "#title_' . $postId . ' span.resolved" ).remove();');
     // Update the state of the item and remove 'is-resolved'
     $ajax->script('EasyDiscuss.$(".discussQuestion").removeClass("is-resolved");');
     // For flatt theme
     $ajax->script('EasyDiscuss.$( ".discuss-action-bar" ).removeClass("is-resolved");');
     $ajax->send();
     $ajax->success();
     return;
 }