Пример #1
0
    public function showApproveDialog($id)
    {
        $ajax = new Disjax();
        $options = new stdClass();
        $options->title = JText::_('COM_EASYDISCUSS_DIALOG_MODERATE_TITLE');
        $options->content = '
		<p>' . JText::_('COM_EASYDISCUSS_DIALOG_MODERATE_CONTENT') . '</p>

		<form id="moderate-form" name="moderate" method="post">
			<span class="float-r" id="dialog_loading"></span>
			<input type="hidden" name="option" value="com_easydiscuss" />
			<input type="hidden" name="controller" value="points" />
			<input type="hidden" name="cid[]" value="' . $id . '" />
			<input type="hidden" id="moderate-task" name="task" value="" />
		</form>
';
        $buttons = array();
        $button = new stdClass();
        $button->title = JText::_('COM_EASYDISCUSS_REJECT_BUTTON');
        $button->action = 'admin.post.moderate.unpublish();';
        $buttons[] = $button;
        $button = new stdClass();
        $button->title = JText::_('COM_EASYDISCUSS_APPROVE_BUTTON');
        $button->action = 'admin.post.moderate.publish();';
        $button->className = 'btn-primary';
        $buttons[] = $button;
        $ajax->dialog($options);
        $ajax->send();
    }
Пример #2
0
 public function testParser($server, $port, $service, $ssl, $user, $pass, $validate)
 {
     $ajax = new Disjax();
     // variable check
     if ($server == '' || $port == '' || $user == '' || $pass == '') {
         $result = 'Credentials incomplete.';
         $ajax->assign('test-result', JText::_('Please complete the information'));
         return $ajax->send();
     }
     require_once DISCUSS_CLASSES . '/mailbox.php';
     $result = DiscussMailer::testConnect($server, $port, $service, $ssl, 'INBOX', $user, $pass);
     $ajax->assign('test-result', $result);
     return $ajax->send();
 }
Пример #3
0
 public function delete($id)
 {
     $ajax = new Disjax();
     $user = JFactory::getUser();
     // @rule: Do not allow empty id or guests to delete files.
     if (empty($id) || empty($user->id)) {
         return false;
     }
     $attachment = DiscussHelper::getTable('Attachments');
     $attachment->load($id);
     // Ensure that only post owner or admin can delete it.
     if (!$attachment->deleteable()) {
         return false;
     }
     // Ensure that only post owner or admin can delete it.
     if (!$attachment->delete()) {
         return false;
     }
     $theme = new DiscussThemes();
     $content = JText::_('COM_EASYDISCUSS_ATTACHMENT_DELETED_SUCCESSFULLY');
     $options = new stdClass();
     $options->content = $content;
     $options->title = JText::_('COM_EASYDISCUSS_ATTACHMENT_DELETE_CONFIRMATION_TITLE');
     $buttons = array();
     $button = new stdClass();
     $button->title = JText::_('COM_EASYDISCUSS_BUTTON_CLOSE');
     $button->action = 'disjax.closedlg();';
     $buttons[] = $button;
     $options->buttons = $buttons;
     $ajax->script('EasyDiscuss.$("#attachment-' . $attachment->id . '" ).trigger("itemRemoved").remove();');
     $ajax->dialog($options);
     $ajax->send();
 }
Пример #4
0
 /**
  * Remove a location from a post.
  *
  * @since	3.0
  * @access	public
  */
 public function removeLocation($id)
 {
     $ajax = new Disjax();
     $post = DiscussHelper::getTable('Post');
     $state = $post->load($id);
     $my = JFactory::getUser();
     if (!$id || !$state) {
         echo JText::_('COM_EASYDISCUSS_INVALID_ID');
         return $ajax->send();
     }
     if ($post->user_id != $my->id && !DiscussHelper::isModerator($post->category_id)) {
         echo JText::_('COM_EASYDISCUSS_NOT_ALLOWED_TO_REMOVE_LOCATION_FOR_POST');
         return $ajax->send();
     }
     // Update the address, latitude and longitude of the post.
     $post->address = '';
     $post->latitude = '';
     $post->longitude = '';
     $post->store();
     $content = JText::_('COM_EASYDISCUSS_LOCATION_IS_REMOVED');
     $options = new stdClass();
     $options->content = $content;
     $options->title = JText::_('COM_EASYDISCUSS_DELETE_LOCATION_TITLE');
     $buttons = array();
     $button = new stdClass();
     $button->title = JText::_('COM_EASYDISCUSS_BUTTON_CLOSE');
     $button->action = 'disjax.closedlg();';
     $buttons[] = $button;
     $options->buttons = $buttons;
     $ajax->script('discuss.location.removeHTML("' . $id . '");');
     $ajax->dialog($options);
     return $ajax->send();
 }
Пример #5
0
 public function ajaxSubmitEmail($data)
 {
     $my = JFactory::getUser();
     $djax = new Disjax();
     $post = DiscussStringHelper::ajaxPostToArray($data);
     if ($my->id == 0) {
         $djax->alert(JText::_('COM_EASYDISCUSS_YOU_DO_NOT_HAVE_PERMISION_TO_SUBMIT_REPORT'), JText::_('ERROR'), '450', 'auto');
         $djax->send();
         return;
     }
     // Load language files from front end.
     JFactory::getLanguage()->load('com_easydiscuss', JPATH_ROOT);
     if (empty($post['post_id'])) {
         $djax->alert(JText::_('COM_EASYDISCUSS_INVALID_POST_ID'), JText::_('ERROR'), '450', 'auto');
         $djax->send();
         return;
     }
     $postId = (int) $post['post_id'];
     $emailContent = $post['content'];
     // Prepare email data
     $postTbl = JTable::getInstance('posts', 'Discuss');
     $postTbl->load($postId);
     $moderator = DiscussHelper::getTable('Profile');
     $moderator->load($my->id);
     $creator = JFactory::getUser($postTbl->user_id);
     $date = DiscussHelper::getDate($postTbl->created);
     $emailData = array();
     $emailData['postAuthor'] = $moderator->getName();
     $emailData['postAuthorAvatar'] = $moderator->getAvatar();
     $emailData['postDate'] = $date->toFormat();
     $emailData['postLink'] = JURI::root() . 'index.php?option=com_easydiscuss&view=post&id=' . $postTbl->id;
     $emailData['postTitle'] = $postTbl->title;
     $emailData['messages'] = $emailContent;
     if (!empty($postTbl->parent_id)) {
         $parentTbl = JTable::getInstance('posts', 'Discuss');
         $parentTbl->load($postTbl->parent_id);
         $emailData['postTitle'] = $parentTbl->title;
         $emailData['postLink'] = JURI::root() . 'index.php?option=com_easydiscuss&view=post&id=' . $parentTbl->id;
     }
     $noti = DiscussHelper::getNotification();
     $noti->addQueue($creator->email, JText::sprintf('COM_EASYDISCUSS_REQUIRED_YOUR_ATTENTION', $emailData['postTitle']), '', 'email.report.attention.php', $emailData);
     $djax->assign('report-entry-msg-' . $postId, JText::_('COM_EASYDISCUSS_EMAIL_SENT_TO_AUTHOR'));
     $djax->script('admin.reports.revertEmailForm("' . $postId . '");');
     $djax->send();
     return;
 }
Пример #6
0
 public function deleteAttachment($id)
 {
     require_once JPATH_ROOT . '/components/com_easydiscuss/controllers/attachment.php';
     $disjax = new Disjax();
     $controller = new EasyDiscussControllerAttachment();
     $msg = JText::_('COM_EASYDISCUSS_ATTACHMENT_DELETE_FAILED');
     $msgClass = 'dc_error';
     if ($controller->deleteFile($id)) {
         $msg = JText::_('COM_EASYDISCUSS_ATTACHMENT_DELETE_SUCCESS');
         $msgClass = 'dc_success';
         $disjax->script('EasyDiscuss.$( "#dc-attachments-' . $id . '" ).remove();');
     }
     $disjax->assign('dc_post_notification .msg_in', $msg);
     $disjax->script('EasyDiscuss.$( "#dc_post_notification .msg_in" ).addClass( "' . $msgClass . '" );');
     $disjax->script('EasyDiscuss.$( "#button-delete-att-' . $id . '" ).prop("disabled", false);');
     $disjax->send();
 }
Пример #7
0
    public function customMessage($id)
    {
        $ajax = new Disjax();
        $theme = new DiscussThemes();
        $badgeUser = DiscussHelper::getTable('BadgesUsers');
        $badgeUser->load($id);
        ob_start();
        ?>
		<p><?php 
        echo JText::_('COM_EASYDISCUSS_BADGE_CUSTOM_MESSAGE_DESC');
        ?>
</p>

		<textarea id="customMessage" style="width:98%;height: 100px;" class="mt-20"><?php 
        echo $badgeUser->custom;
        ?>
</textarea>
		<?php 
        $content = ob_get_contents();
        ob_end_clean();
        $options = new stdClass();
        $options->content = $content;
        $options->title = JText::_('Custom Message');
        $buttons = array();
        $button = new stdClass();
        $button->title = JText::_('Close');
        $button->action = 'disjax.closedlg();';
        $buttons[] = $button;
        $button = new stdClass();
        $button->title = JText::_('Submit');
        $button->action = 'saveMessage("' . $id . '" );';
        $button->className = 'btn-primary';
        $buttons[] = $button;
        $options->buttons = $buttons;
        $ajax->dialog($options);
        $ajax->send();
    }
Пример #8
0
 public function filter($viewtype = 'user-post', $profileId = null)
 {
     $ajax = new Disjax();
     $mainframe = JFactory::getApplication();
     $config = DiscussHelper::getConfig();
     $acl = DiscussHelper::getHelper('ACL');
     $sort = 'latest';
     $data = null;
     $pagination = null;
     $model = $this->getModel('Posts');
     $tagsModel = $this->getModel('Tags');
     switch ($viewtype) {
         case 'user-achievements':
             $profile = DiscussHelper::getTable('Profile');
             $profile->load($profileId);
             $data = $profile->getBadges();
             break;
         case 'user-tags':
             $data = $tagsModel->getTagCloud('', '', '', $profileId);
             break;
         case 'user-replies':
             $data = $model->getRepliesFromUser($profileId);
             $pagination = $model->getPagination();
             DiscussHelper::formatPost($data);
             break;
         case 'user-unresolved':
             $data = $model->getUnresolvedFromUser($profileId);
             $pagination = $model->getPagination();
             DiscussHelper::formatPost($data);
             break;
         case 'user-post':
         default:
             if (is_null($profileId)) {
                 break;
             }
             $model = $this->getModel('Posts');
             $data = $model->getPostsBy('user', $profileId);
             $data = DiscussHelper::formatPost($data);
             $pagination = $model->getPagination();
             break;
     }
     // replace the content
     $content = '';
     $tpl = new DiscussThemes();
     $tpl->set('profileId', $profileId);
     if ($viewtype == 'user-post' || $viewtype == 'user-replies' || $viewtype == 'user-unresolved') {
         $nextLimit = DiscussHelper::getListLimit();
         if ($nextLimit >= $pagination->total) {
             // $ajax->remove( 'dc_pagination' );
             $ajax->assign($viewtype . ' #dc_pagination', '');
         }
         $tpl->set('posts', $data);
         $content = $tpl->fetch('main.item.php');
         $ajax->assign($viewtype . ' #dc_list', $content);
         //reset the next start limi
         $ajax->value('pagination-start', $nextLimit);
         if ($nextLimit < $pagination->total) {
             $filterArr = array();
             $filterArr['viewtype'] = $viewtype;
             $filterArr['id'] = $profileId;
             $ajax->assign($viewtype . ' #dc_pagination', $pagination->getPagesLinks('profile', $filterArr, true));
         }
     } else {
         if ($viewtype == 'user-tags') {
             $tpl->set('tagCloud', $data);
             $content = $tpl->fetch('tags.item.php');
             $ajax->assign('discuss-tag-list', $content);
         } else {
             if ($viewtype == 'user-achievements') {
                 $tpl->set('badges', $data);
                 $content = $tpl->fetch('users.achievements.list.php');
                 $ajax->assign('user-achievements', $content);
             }
         }
     }
     $ajax->script('discuss.spinner.hide( "profile-loading" );');
     //$ajax->assign( 'sort-wrapper' , $sort );
     //$ajax->script( 'EasyDiscuss.$("#pagination-filter").val("'.$viewtype.'");');
     $ajax->script('EasyDiscuss.$("#' . $viewtype . '").show();');
     $ajax->script('EasyDiscuss.$("#' . $viewtype . ' #dc_pagination").show();');
     $ajax->send();
 }
Пример #9
0
 /**
  * Ajax Call
  * Sum all votes
  */
 public function ajaxSumVote($postId = null)
 {
     $djax = new Disjax();
     // load model
     $voteModel = $this->getModel('votes');
     $total = $voteModel->sumPostVotes($postId);
     $djax->send();
     return;
 }
Пример #10
0
 public function getTemplate($name = null, $vars = array())
 {
     $theme = new DiscussThemes();
     if (!empty($vars)) {
         foreach ($vars as $key => $value) {
             $theme->set($key, $value);
         }
     }
     $ajax = new Disjax();
     $option = new stdClass();
     $option->content = $theme->fetch($name, array('dialog' => true));
     $ajax->dialog($option);
     $ajax->send();
 }
Пример #11
0
 public function ajaxNoStatusPost($id = null)
 {
     $ajax = new Disjax();
     $config = DiscussHelper::getConfig();
     if (!$id) {
         $ajax->assign('dc_main_notifications', JText::_('COM_EASYDISCUSS_SYSTEM_INVALID_ID'));
         $ajax->script('EasyDiscuss.$( "#dc_main_notifications" ).addClass( "alert alert-error" );');
         $ajax->send();
         return;
     }
     $post = DiscussHelper::getTable('Post');
     $post->load($id);
     $isMine = DiscussHelper::isMine($post->user_id);
     $isAdmin = DiscussHelper::isSiteAdmin();
     $acl = DiscussHelper::getHelper('ACL');
     $isModerator = DiscussHelper::getHelper('Moderator')->isModerator($post->category_id);
     if (!$isMine && !$isAdmin && !$acl->allowed('mark_no_status', '0')) {
         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;
         }
     }
     // Turn on the on-hold status,
     // DISCUSS_POST_STATUS_OFF = 0
     $post->post_status = DISCUSS_POST_STATUS_OFF;
     if (!$post->store()) {
         $ajax->assign('dc_main_notifications', $post->getError());
         $ajax->script('EasyDiscuss.$( "#dc_main_notifications" ).addClass( "alert alert-error" );');
         $ajax->send();
         return;
     }
     // @rule: Add notifications for the thread starter
     $my = JFactory::getUser();
     if ($post->get('user_id') != $my->id) {
         $notification = DiscussHelper::getTable('Notifications');
         $notification->bind(array('title' => JText::sprintf('COM_EASYDISCUSS_NO_STATUS_DISCUSSION_NOTIFICATION_TITLE', $post->title), 'cid' => $post->get('id'), 'type' => 'unhold', 'target' => $post->get('user_id'), 'author' => $my->id, 'permalink' => 'index.php?option=com_easydiscuss&view=post&id=' . $post->get('id')));
         $notification->store();
     }
     // Remove other status
     $ajax->script('EasyDiscuss.$( ".discuss-item" ).removeClass( "is-resolved" );');
     $ajax->script('EasyDiscuss.$( ".postStatus" ).removeClass( "label-post_status" );');
     $ajax->script('EasyDiscuss.$( ".postStatus" ).removeClass( "label-post_status-on-hold" );');
     $ajax->script('EasyDiscuss.$( ".postStatus" ).removeClass( "label-post_status-accept" );');
     $ajax->script('EasyDiscuss.$( ".postStatus" ).removeClass( "label-post_status-working-on" );');
     $ajax->script('EasyDiscuss.$( ".postStatus" ).removeClass( "label-post_status-reject" );');
     $ajax->assign('dc_main_notifications', JText::_('COM_EASYDISCUSS_POST_NO_STATUS'));
     $ajax->script('EasyDiscuss.$( "#dc_main_notifications" ).addClass( "alert alert-success" );');
     $ajax->script('EasyDiscuss.$( ".postStatus" ).html("");');
     $ajax->send();
     return;
 }
Пример #12
0
 /**
  * Retrieve a list of voters from the site in a dialog.
  *
  * @since	3.0
  * @access	public
  * @param	int		The unique id for the poll answer.
  * @return
  */
 public function getVoters($pollId)
 {
     $ajax = new Disjax();
     $poll = DiscussHelper::getTable('Poll');
     $poll->load($pollId);
     $voters = $poll->getVoters();
     $template = new DiscussThemes();
     $template->set('voters', $voters);
     $option = new stdClass();
     $option->title = JText::_('COM_EASYDISCUSS_USERS_WHO_VOTED_THIS_POLL');
     $option->content = $template->fetch('ajax.poll.voters.php', array('dialog' => true));
     $buttons = array();
     $button = new stdClass();
     $button->title = JText::_('COM_EASYDISCUSS_OK');
     $button->action = 'disjax.closedlg();';
     $button->className = 'btn-primary';
     $buttons[] = $button;
     $option->buttons = $buttons;
     $ajax->dialog($option);
     $ajax->send();
 }
Пример #13
0
 /**
  * Save a conversation
  *
  * @since	3.0
  * @access	public
  */
 public function save()
 {
     $config = DiscussHelper::getConfig();
     $app = JFactory::getApplication();
     $my = JFactory::getUser();
     $ajax = new Disjax();
     $content = JRequest::getVar('contents');
     $recipientId = JRequest::getInt('recipient');
     // Test for valid recipients.
     if (!$recipientId) {
         return $ajax->send();
     }
     // Test for empty contents here.
     if (empty($content)) {
         exit;
     }
     // Do not allow user to send a message to himself, it's crazy.
     if ($recipientId == $my->id) {
         echo JText::_('You should not start a conversation with your self.');
         return $ajax->send();
     }
     // Initialize conversation table.
     $conversation = DiscussHelper::getTable('Conversation');
     // Check if this conversation already exist in the system.
     $state = $conversation->loadByRelation($my->id, $recipientId);
     $model = DiscussHelper::getModel('Conversation');
     // If the conversation does not exist, we need to create the conversation and add a recipient.
     if (!$state) {
         $date = DiscussHelper::getDate()->toMySQL();
         $conversation->created = $date;
         $conversation->created_by = $my->id;
         $conversation->lastreplied = $date;
         $conversation->store();
         // Add participant to this conversation.
         $model->addParticipant($conversation->id, $recipientId, $my->id);
     } else {
         // Set last replied date if this is a reply.
         $conversation->lastreplied = DiscussHelper::getDate()->toMySQL();
         $conversation->store();
     }
     // Initialize message table.
     $message = DiscussHelper::getTable('ConversationMessage');
     $message->message = $content;
     $message->conversation_id = $conversation->id;
     $message->created = DiscussHelper::getDate()->toMySQL();
     $message->created_by = $my->id;
     $message->store();
     // Add message map so that recipient can view the message.
     $model->addMessageMap($conversation->id, $message->id, $recipientId, $my->id);
     // Format conversation replies.
     $data = array($message);
     DiscussHelper::formatConversationReplies($data);
     $reply = $data[0];
     // Send notification to the recipient.
     $conversation->notify($reply);
     $options = new stdClass();
     $options->content = JText::_('COM_EASYDISCUSS_CONVERSATION_MESSAGE_SUCCESSFULLY_SENT');
     $options->title = JText::_('COM_EASYDISCUSS_DIALOG_TITLE_NEW_CONVERSATION');
     $buttons = array();
     $button = new stdClass();
     $button->title = JText::_('COM_EASYDISCUSS_BUTTON_CLOSE');
     $button->action = 'disjax.closedlg();';
     $buttons[] = $button;
     $options->buttons = $buttons;
     $options->width = 500;
     $ajax = DiscussHelper::getHelper('Ajax');
     $ajax->resolve($options);
     return $ajax->send();
 }
Пример #14
0
 /**
  * Shows the terms and condition dialog window.
  *
  * @since	3.0
  * @access	public
  */
 public function tnc()
 {
     $config = DiscussHelper::getConfig();
     $disjax = new Disjax();
     $themes = new DiscussThemes();
     $content = $themes->fetch('ajax.terms.php', array('dialog' => true));
     $options = new stdClass();
     $options->title = JText::_('COM_EASYDISCUSS_TERMS_AND_CONDITIONS');
     $options->content = $content;
     $buttons = array();
     $button = new stdClass();
     $button->title = JText::_('COM_EASYDISCUSS_OK');
     $button->action = 'disjax.closedlg();';
     $button->className = 'btn-primary';
     $buttons[] = $button;
     $options->buttons = $buttons;
     $disjax->dialog($options);
     $disjax->send();
     return;
 }
Пример #15
0
 function ajaxAddSubscription($type = 'tag', $email, $name, $interval, $cid = '0')
 {
     $disjax = new Disjax();
     $mainframe = JFactory::getApplication();
     $my = JFactory::getUser();
     $config = DiscussHelper::getConfig();
     $msg = '';
     $msgClass = 'dc_success';
     $subscription_info = array();
     $subscription_info['type'] = $type;
     $subscription_info['userid'] = $my->id;
     $subscription_info['email'] = $email;
     $subscription_info['cid'] = $cid;
     $subscription_info['member'] = $my->id ? '1' : '0';
     $subscription_info['name'] = $my->id ? $my->name : $name;
     $subscription_info['interval'] = $interval;
     //validation
     if (JString::trim($subscription_info['email']) == '') {
         $disjax->script('discuss.spinner.hide( "dialog_loading" );');
         $disjax->assign('dc_subscribe_notification .msg_in', JText::_('COM_EASYDISCUSS_EMAIL_IS_EMPTY'));
         $disjax->script('EasyDiscuss.$( "#dc_subscribe_notification .msg_in" ).addClass( "dc_error" );');
         $disjax->send();
         return;
     }
     if (JString::trim($subscription_info['name']) == '') {
         $disjax->script('discuss.spinner.hide( "dialog_loading" );');
         $disjax->assign('dc_subscribe_notification .msg_in', JText::_('COM_EASYDISCUSS_NAME_IS_EMPTY'));
         $disjax->script('EasyDiscuss.$( "#dc_subscribe_notification .msg_in" ).addClass( "dc_error" );');
         $disjax->send();
         return;
     }
     $model = $this->getModel('Subscribe');
     $sid = '';
     if ($my->id == 0) {
         $sid = $model->isTagSubscribedEmail($subscription_info);
         if ($sid != '') {
             //user found.
             // show message.
             $disjax->script('discuss.spinner.hide( "dialog_loading" );');
             $disjax->assign('dc_subscribe_notification .msg_in', JText::_('COM_EASYDISCUSS_ALREADY_SUBSCRIBED_TO_TAG'));
             $disjax->script('EasyDiscuss.$( "#dc_subscribe_notification .msg_in" ).addClass( "dc_success" );');
             $disjax->send();
             return;
         } else {
             if (!$model->addSubscription($subscription_info)) {
                 $msg = JText::sprintf('COM_EASYDISCUSS_SUBSCRIPTION_FAILED');
                 $msgClass = 'dc_error';
             }
         }
     } else {
         $sid = $model->isTagSubscribedUser($subscription_info);
         if ($sid['id'] != '') {
             // user found.
             // update the email address
             if (!$model->updatePostSubscription($sid['id'], $subscription_info)) {
                 $msg = JText::sprintf('COM_EASYDISCUSS_SUBSCRIPTION_FAILED');
                 $msgClass = 'dc_error';
             }
         } else {
             //add new subscription.
             if (!$model->addSubscription($subscription_info)) {
                 $msg = JText::sprintf('COM_EASYDISCUSS_SUBSCRIPTION_FAILED');
                 $msgClass = 'dc_error';
             }
         }
     }
     $msg = empty($msg) ? JText::_('COM_EASYDISCUSS_SUBSCRIPTION_SUCCESS') : $msg;
     $disjax->script('discuss.spinner.hide( "dialog_loading" );');
     $disjax->assign('dc_subscribe_notification .msg_in', $msg);
     $disjax->script('EasyDiscuss.$( "#dc_subscribe_notification .msg_in" ).addClass( "' . $msgClass . '" );');
     $disjax->send();
     return;
 }