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; }
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(); }
public function ajaxSubscribe($id = null) { $disjax = new disjax(); $mainframe = JFactory::getApplication(); $my = JFactory::getUser(); $sitename = $mainframe->getCfg('sitename'); $tpl = new DiscussThemes(); $tpl->set('id', $id); $tpl->set('my', $my); $content = $tpl->fetch('ajax.subscribe.post.php', array('dialog' => true)); $options = new stdClass(); $options->title = JText::_('COM_EASYDISCUSS_SUBSCRIBE_TO_POST'); $options->content = $content; $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.post(' . $id . ')'; $button->className = 'btn-primary'; $buttons[] = $button; $options->buttons = $buttons; $disjax->dialog($options); $disjax->send(); }