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(); }
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; }
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(); }
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(); }
public function sort($sort = null, $filter = null, $categoryId = null) { $ajax = new Disjax(); $mainframe = JFactory::getApplication(); $user = JFactory::getUser(); $config = DiscussHelper::getConfig(); $acl = DiscussHelper::getHelper('ACL'); $activeCategory = DiscussHelper::getTable('Category'); $activeCategory->load($categoryId); //todo: check against the config $showAllPosts = 'all'; $postModel = $this->getModel('Posts'); $posts = $postModel->getData(true, $sort, null, $filter, $categoryId, null, $showAllPosts); $pagination = $postModel->getPagination('0', $sort, $filter, $categoryId, $showAllPosts); $posts = DiscussHelper::formatPost($posts); $nextLimit = DiscussHelper::getListLimit(); if ($nextLimit >= $pagination->total) { $ajax->remove('dc_pagination .pagination-wrap'); } $tpl = new DiscussThemes(); $tpl->set('posts', $posts); $content = $tpl->fetch('main.item.php'); //reset the next start limi $ajax->value('pagination-start', $nextLimit); if ($nextLimit < $pagination->total) { $filterArr = array(); $filterArr['filter'] = $filter; $filterArr['category_id'] = $categoryId; $filterArr['sort'] = $sort; $ajax->assign('dc_pagination', $pagination->getPagesLinks('index', $filterArr, true)); } $ajax->script('discuss.spinner.hide( "index-loading" );'); $ajax->script('EasyDiscuss.$("#pagination-sorting").val("' . $sort . '");'); $ajax->assign('dc_list', $content); $ajax->script('EasyDiscuss.$("#dc_list").show();'); $ajax->script('EasyDiscuss.$("#dc_pagination").show();'); $ajax->send(); }
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; }
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; }