Пример #1
0
 function ajaxSubscribe($id)
 {
     $disjax = new disjax();
     $mainframe = JFactory::getApplication();
     $my = JFactory::getUser();
     $tag = DiscussHelper::getTable('Tags');
     $tag->load($id);
     $tpl = new DiscussThemes();
     $tpl->set('tag', $tag);
     $tpl->set('my', $my);
     $html = $tpl->fetch('ajax.subscribe.tag.php');
     $options = new stdClass();
     $options->title = JText::sprintf('COM_EASYDISCUSS_SUBSCRIBE_TO_TAG', $tag->title);
     $options->content = $html;
     $buttons = array();
     $button = new stdClass();
     $button->title = JText::_('COM_EASYDISCUSS_BUTTON_CANCEL');
     $button->action = 'disjax.closedlg();';
     $buttons[] = $button;
     $button = new stdClass();
     $button->title = JText::_('COM_EASYDISCUSS_BUTTON_SUBSCRIBE');
     $button->action = 'discuss.subscribe.tag(' . $tag->id . ')';
     $button->className = 'btn-primary';
     $buttons[] = $button;
     $options->buttons = $buttons;
     $disjax->dialog($options);
     $disjax->send();
 }
Пример #2
0
 function ajaxRemoveSubscription($type = null, $subscribeId = null)
 {
     $ajax = new disjax();
     $my = JFactory::getUser();
     $options = new stdClass();
     $options->title = JText::_('COM_EASYDISCUSS_UNSUBSCRIBE_TO_' . strtoupper($type));
     $buttons = array();
     $button = new stdClass();
     $button->title = JText::_('COM_EASYDISCUSS_BUTTON_OK');
     $button->action = 'disjax.closedlg();';
     $buttons[] = $button;
     $options->buttons = $buttons;
     if ($my->id == 0) {
         $options->content = JText::_('COM_EASYDISCUSS_NOT_ALLOWED_HERE');
         $ajax->dialog($options);
         $ajax->send();
         return;
     }
     $subcription = DiscussHelper::getTable('Subscribe');
     $subcription->load($subscribeId);
     if (empty($subcription->type)) {
         $options->content = JText::_('COM_EASYDISCUSS_UNSUBSCRIPTION_FAILED_NO_RECORD_FOUND');
         $ajax->dialog($options);
         $ajax->send();
         return;
     }
     //check if the id belong to the user or not.
     if (!DiscussHelper::isMySubscription($my->id, $type, $subscribeId)) {
         $options->content = JText::_('COM_EASYDISCUSS_NOT_ALLOWED_HERE');
         $ajax->dialog($options);
         $ajax->send();
         return;
     }
     switch ($type) {
         case 'post':
             $options->content = JText::_('COM_EASYDISCUSS_UNSUBSCRIPTION_POST_SUCCESS');
             break;
         case 'site':
             $options->content = JText::_('COM_EASYDISCUSS_UNSUBSCRIPTION_SITE_SUCCESS');
             break;
         case 'category':
             $options->content = JText::_('COM_EASYDISCUSS_UNSUBSCRIPTION_CATEGORY_SUCCESS');
             break;
         case 'user':
             $options->content = JText::_('COM_EASYDISCUSS_UNSUBSCRIPTION_USER_SUCCESS');
             break;
         default:
             break;
     }
     //perform the unsubcribe
     $subcription->delete();
     $ajax->dialog($options);
     $ajax->send();
     return;
 }
Пример #3
0
 public function ajaxCheckAlias($alias)
 {
     $disjax = new disjax();
     $my = JFactory::getUser();
     // do not let unregistered user
     if ($my->id <= 0) {
         return false;
     }
     // satinize input
     $filter = JFilterInput::getInstance();
     $alias = $filter->clean($alias, 'ALNUM');
     // check for existance
     $db = DiscussHelper::getDBO();
     $query = 'SELECT `alias` FROM `#__discuss_users` WHERE `alias` = ' . $db->quote($alias) . ' ' . 'AND ' . $db->nameQuote('id') . '!=' . $db->Quote($my->id);
     $db->setQuery($query);
     $result = $db->loadResult();
     // prepare output
     if ($result) {
         $html = JText::_('COM_EASYDISCUSS_ALIAS_NOT_AVAILABLE');
         $class = 'failed';
     } else {
         $html = JText::_('COM_EASYDISCUSS_ALIAS_AVAILABLE');
         $class = 'success';
     }
     $options = new stdClass();
     // fill in the value
     $disjax->assign('profile-alias', $alias);
     $disjax->script('EasyDiscuss.$( "#alias-status" ).html("' . $html . '").removeClass("failed").removeClass("success").addClass( "' . $class . '" );');
     $disjax->value('profile-alias', $alias);
     $disjax->send();
 }
Пример #4
0
 public function getMoreVoters($postid = null, $limit = null)
 {
     $disjax = new disjax();
     $voteModel = $this->getModel('votes');
     $total = $voteModel->getTotalVotes($postid);
     if (!empty($total)) {
         $voters = DiscussHelper::getVoters($postid, $limit);
         $msg = JText::sprintf('COM_EASYDISCUSS_VOTES_BY', $voters->voters);
         if ($voters->shownVoterCount < $total) {
             $limit += '5';
             $msg .= '[<a href="javascript:void(0);" onclick="disjax.load(\'post\', \'getMoreVoters\', \'' . $postid . '\', \'' . $limit . '\');">' . JText::_('COM_EASYDISCUSS_MORE') . '</a>]';
         }
         $disjax->assign('dc_reply_voters_' . $postid, $msg);
     }
     $disjax->send();
     return;
 }