function remove() { // Check for request forgeries JRequest::checkToken() or jexit('Invalid Token'); $mails = JRequest::getVar('cid', '', 'POST'); $message = ''; $type = 'success'; if (empty($mails)) { $message = JText::_('COM_EASYDISCUSS_NO_MAIL_ID_PROVIDED'); $type = 'error'; } else { $table = DiscussHelper::getTable('MailQueue'); foreach ($mails as $id) { $table->load($id); if (!$table->delete()) { DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_SPOOLS_DELETE_ERROR'), DISCUSS_QUEUE_ERROR); $this->setRedirect('index.php?option=com_easydiscuss&view=spools'); return; } } $message = JText::_('COM_EASYDISCUSS_SPOOLS_EMAILS_DELETED'); } DiscussHelper::setMessageQueue($message, $type); $this->setRedirect('index.php?option=com_easydiscuss&view=spools'); }
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(); }
function getUserTooltip($id, $name) { $profile = DiscussHelper::getTable('Profile'); $profile->load($id); ob_start(); ?> <div> <strong><u><?php echo $name; ?> </u></strong> <img src='<?php echo $profile->getAvatar(); ?> ' width='32' /> </div> <p> <?php echo JText::sprintf('COM_EASYDISCUSS_TOOLTIPS_USER_INFO', $name, $profile->getDateJoined(), $profile->numPostCreated, $profile->numPostAnswered); ?> </p> <?php $content = ob_get_contents(); ob_end_clean(); return $content; }
public function store($updateNulls = false) { if (empty($this->email) && $this->userid) { $user = JFactory::getUser($this->userid); $this->fullname = $user->email(); } if (empty($this->fullname) && $this->userid) { $profile = DiscussHelper::getTable('Profile'); $profile->load($this->userid); $this->fullname = $profile->getName(); } if (empty($this->member)) { $this->member = $this->userid ? 1 : 0; } if (empty($this->interval)) { $this->interval = 'instant'; } if (empty($this->created)) { $this->created = DiscussHelper::getDate()->toMySQL(); } if (empty($this->sent_out)) { $this->sent_out = DiscussHelper::getDate()->toMySQL(); } return parent::store($updateNulls); }
/** * 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(); }
public static function add($userObj, $entityObj, $interval = null, $data) { if (!$userObj instanceof JUser) { return false; } if ($entityObj instanceof DiscussPost) { $type = 'post'; } elseif ($entityObj instanceof DiscussCategory) { $type = 'category'; } else { // $type = 'site' return false; } $email = isset($data['poster_email']) ? $data['poster_email'] : ''; $name = isset($data['poster_name']) ? $data['poster_name'] : ''; $subscribe = DiscussHelper::getTable('Subscribe'); if (empty($userObj->id)) { $subscribe->userid = 0; $subscribe->member = 0; $subscribe->email = $email; $subscribe->fullname = $name; } else { $subscribe->userid = $userObj->id; $subscribe->member = 1; $subscribe->email = $userObj->email; $subscribe->fullname = $userObj->name; } $subscribe->type = $type; $subscribe->cid = $entityObj->id; $subscribe->interval = $interval; return $subscribe->store(); }
/** * Generates a random captcha image * **/ function display($cachable = false, $urlparams = false) { // @TODO: Run some cleaning query here to clear the database. JTable::addIncludePath(DISCUSS_TABLES); $id = JRequest::getInt('captcha-id', ''); $captcha = DiscussHelper::getTable('Captcha'); // clearing the oudated keys. $captcha->clear(); // load the captcha records. $captcha->load($id); if (!$captcha->id) { return false; } // @task: Generate a very random integer and take only 5 chars max. $hash = JString::substr(md5(rand(0, 9999)), 0, 5); $captcha->response = $hash; $captcha->store(); // Captcha width and height $width = 100; $height = 20; $image = ImageCreate($width, $height); $white = ImageColorAllocate($image, 255, 255, 255); $black = ImageColorAllocate($image, 0, 0, 0); $gray = ImageColorAllocate($image, 204, 204, 204); ImageFill($image, 0, 0, $white); ImageString($image, 5, 30, 3, $hash, $black); ImageRectangle($image, 0, 0, $width - 1, $height - 1, $gray); imageline($image, 0, $height / 2, $width, $height / 2, $gray); imageline($image, $width / 2, 0, $width / 2, $height, $gray); header('Content-type: image/jpeg'); ImageJpeg($image); ImageDestroy($image); exit; }
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 display($tpl = null) { $id = JRequest::getInt('id', 0); $badge = DiscussHelper::getTable('Badges'); $badge->load($id); if (!$badge->created) { $date = DiscussHelper::getHelper('Date')->dateWithOffset(DiscussHelper::getDate()->toMySQL()); $badge->created = $date->toMySQL(); } // There could be some errors here. if (JRequest::getMethod() == 'POST') { $badge->bind(JRequest::get('post')); // Description might contain html codes $description = JRequest::getVar('description', '', 'post', 'string', JREQUEST_ALLOWRAW); $badge->description = $description; } $jConfig = DiscussHelper::getJConfig(); $editor = JFactory::getEditor($jConfig->get('editor')); $model = $this->getModel('Badges'); $rules = $model->getRules(); $badges = $this->getBadges(); $this->assign('editor', $editor); $this->assign('badges', $badges); $this->assign('rules', $rules); $this->assign('badge', $badge); parent::display($tpl); }
/** * Get the author html output */ private function getAuthorHTML($authors) { // @TODO: Make this option configurable // This option sets the limit on the number of authors to be displayed in the notification $limit = 3; $html = ''; for ($i = 0; $i < count($authors); $i++) { $profile = DiscussHelper::getTable('Profile'); $profile->load($authors[$i]); $html .= ' <b>' . $profile->getName() . '</b>'; if ($i + 1 == $limit) { // Calculate the balance $balance = count($authors) - ($i + 1); $html .= ' ' . DiscussHelper::getHelper('String')->getNoun('COM_EASYDISCUSS_AND_OTHERS', $balance, true); break; } if (isset($authors[$i + 2])) { $html .= JText::_(','); } else { if (isset($authors[$i + 1])) { $html .= ' ' . JText::_('COM_EASYDISCUSS_AND'); } } } return $html; }
function process() { $view = new EasyDiscussView(); $date = DiscussHelper::getDate(); $now = $date->toMySQL(); $modelSubscribe = $view->getModel('Subscribe'); $subscribers = $modelSubscribe->getSiteSubscribers($this->interval, $now); $total = count($subscribers); if (empty($total)) { return false; } foreach ($subscribers as $subscriber) { $notify = DiscussHelper::getNotification(); $data = array(); $rows = $modelSubscribe->getCreatedPostByInterval($subscriber->sent_out, $now); $posts = array(); if ($rows) { foreach ($rows as $row) { $row['categorylink'] = DiscussRouter::getRoutedURL('index.php?option=com_easydiscuss&view=categorie&layout=listings&category_id=' . $row['category_id'], false, true); $row['link'] = DiscussRouter::getRoutedURL('index.php?option=com_easydiscuss&view=post&id=' . $row['id'], false, true); $row['userlink'] = DiscussRouter::getRoutedURL('index.php?option=com_easydiscuss&view=profile&id=' . $row['user_id'], false, true); $category = DiscussHelper::getTable('Category'); $creator = DiscussHelper::getTable('Profile'); $category->load($row['category_id']); $creator->load($row['user_id']); $row['category'] = $category->getTitle(); $row['avatar'] = $creator->getAvatar(); $row['name'] = $creator->getName(); $row['date'] = DiscussDateHelper::toFormat($row['created'], '%b %e, %Y'); $row['message'] = DiscussHelper::parseContent($row['content']); $posts[] = $row; } } $data['post'] = $posts; $data['total'] = count($data['post']); $data['unsubscribeLink'] = DiscussHelper::getUnsubscribeLink($subscriber, true, true); $subject = $date->toMySQL(); switch (strtoupper($this->interval)) { case 'DAILY': $subject = $date->toFormat('%F'); $data['interval'] = JText::_('today'); break; case 'WEEKLY': $subject = $date->toFormat('%V'); $data['interval'] = JText::_('this week'); break; case 'MONTHLY': $subject = $date->toFormat('%B'); $data['interval'] = JText::_('this month'); break; } if (!empty($data['post'])) { $notify->addQueue($subscriber->email, JText::sprintf('COM_EASYDISCUSS_YOUR_' . $this->interval . '_SUBSCRIPTION', $subject), '', 'email.subscription.site.interval.php', $data); } $subscribe = DiscussHelper::getTable('Subscribe'); $subscribe->load($subscriber->id); $subscribe->sent_out = $now; $subscribe->store(); } }
public function save() { JRequest::checkToken('request') or jexit('Invalid Token'); $mainframe = JFactory::getApplication(); $post = JRequest::get('post'); $ids = isset($post['id']) ? $post['id'] : ''; $starts = isset($post['start']) ? $post['start'] : ''; $ends = isset($post['end']) ? $post['end'] : ''; $titles = isset($post['title']) ? $post['title'] : ''; $removal = isset($post['itemRemove']) ? $post['itemRemove'] : ''; $model = DiscussHelper::getModel('Ranks', true); if (!empty($removal)) { $rids = explode(',', $removal); $model->removeRanks($rids); } if (!empty($ids)) { if (count($ids) > 0) { for ($i = 0; $i < count($ids); $i++) { $data = array(); $data['id'] = $ids[$i]; $data['start'] = $starts[$i]; $data['end'] = $ends[$i]; $data['title'] = $titles[$i]; $ranks = DiscussHelper::getTable('Ranks'); $ranks->bind($data); $ranks->store(); } } //end if } //end if $message = JText::_('COM_EASYDISCUSS_RANKING_SUCCESSFULLY_UPDATED'); DiscussHelper::setMessageQueue($message, DISCUSS_QUEUE_SUCCESS); $mainframe->redirect('index.php?option=com_easydiscuss&view=ranks'); }
public function display($tmpl = null) { $config = DiscussHelper::getConfig(); $jConfig = DiscussHelper::getJConfig(); if (!$config->get('main_rss')) { return; } $filteractive = JRequest::getString('filter', 'allposts'); $sort = JRequest::getString('sort', 'latest'); if ($filteractive == 'unanswered' && ($sort == 'active' || $sort == 'popular')) { //reset the active to latest. $sort = 'latest'; } $doc = JFactory::getDocument(); $doc->link = JRoute::_('index.php?option=com_easydiscuss&view=index'); // Load up the tag $tag = JRequest::getInt('id', 0); $table = DiscussHelper::getTable('Tags'); $table->load($tag); // Set the title of the document $doc->setTitle($table->title); $doc->setDescription(JText::sprintf('COM_EASYDISCUSS_DISCUSSIONS_TAGGED_IN', $table->title)); $postModel = $this->getModel('Posts'); $posts = $postModel->getTaggedPost($tag, $sort, $filteractive); $pagination = $postModel->getPagination('0', $sort, $filteractive); $jConfig = DiscussHelper::getJConfig(); $posts = DiscussHelper::formatPost($posts); foreach ($posts as $row) { // Assign to feed item $title = $this->escape($row->title); $title = html_entity_decode($title); // load individual item creator class $item = new JFeedItem(); $item->title = $title; $item->link = JRoute::_('index.php?option=com_easydiscuss&view=post&id=' . $row->id); $item->description = $row->content; $item->date = DiscussHelper::getDate($row->created)->toMySQL(); if (!empty($row->tags)) { $tagData = array(); foreach ($row->tags as $tag) { $tagData[] = '<a href="' . JRoute::_('index.php?option=com_easydiscuss&view=tags&id=' . $tag->id) . '">' . $tag->title . '</a>'; } $row->tags = implode(', ', $tagData); } else { $row->tags = ''; } $item->category = $row->tags; $item->author = $row->user->getName(); if ($jConfig->get('feed_email') != 'none') { if ($jConfig->get('feed_email') == 'author') { $item->authorEmail = $row->user->email; } else { $item->authorEmail = $jConfig->get('mailfrom'); } } $doc->addItem($item); } }
public function removeLog($command, $userId, $content_id) { $db = DiscussHelper::getDBO(); $table = DiscussHelper::getTable('History'); $query = 'SELECT id' . ' FROM ' . $db->nameQuote('#__discuss_users_history') . ' WHERE ' . $db->nameQuote('command') . '=' . $db->Quote($command) . ' AND ' . $db->nameQuote('user_id') . '=' . $db->Quote($userId) . ' AND ' . $db->nameQuote('content_id') . '=' . $db->Quote($content_id); $db->setQuery($query); $result = $db->loadResult(); $table->delete($result); }
/** * Converts a comment into a discussion reply * * @since 1.0 * @access public * @param string * @return */ public function convert() { JRequest::checkToken('request') or jexit('Invalid Token'); // Get the Joomla app $app = JFactory::getApplication(); // Get the comment id from the request. $id = JRequest::getInt('id'); // Load the comment $comment = DiscussHelper::getTable('Comment'); $comment->load($id); if (!$id || !$comment->id) { // Throw error here. DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_COMMENTS_INVALID_COMMENT_ID_PROVIDED'), DISCUSS_QUEUE_ERROR); $app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss', false)); $app->close(); } // Get the post id from the request. $postId = JRequest::getInt('postId'); $post = DiscussHelper::getTable('Post'); $post->load($postId); if (!$postId || !$post->id) { // Throw error here. DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_COMMENTS_INVALID_POST_ID_PROVIDED'), DISCUSS_QUEUE_ERROR); $app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss', false)); $app->close(); } if (!$comment->canConvert()) { // Throw error here. DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_COMMENTS_NOT_ALLOWED_TO_CONVERT'), DISCUSS_QUEUE_ERROR); $app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=post&id=' . $post->id, false)); $app->close(); } // Create a new reply. $reply = DiscussHelper::getTable('Post'); $reply->title = $post->title; $reply->content = $comment->comment; $reply->published = 1; $reply->created = $comment->created; $reply->parent_id = $post->id; $reply->user_id = $comment->user_id; $reply->user_type = 'member'; $reply->category_id = $post->category_id; $state = $reply->store(); if (!$state) { // Throw error here. DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_COMMENTS_ERROR_SAVING_REPLY'), DISCUSS_QUEUE_ERROR); $app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=post&id=' . $post->id, false)); $app->close(); } // Once the reply is stored, delete the comment $comment->delete(); DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_COMMENTS_SUCCESS_CONVERTED_COMMENT_TO_REPLY'), DISCUSS_QUEUE_SUCCESS); $app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=post&id=' . $post->id, false)); $app->close(); }
public function getAvatar($profile) { $easydiscuss = EB::easydiscuss(); if (!$easydiscuss->exists()) { return false; } $user = DiscussHelper::getTable('Profile'); $user->load($profile->id); $avatar = $user->getAvatar(); return $avatar; }
public function form() { $id = JRequest::getInt('id'); $postTypes = DiscussHelper::getTable('Post_types'); if (!empty($id)) { $postTypes->load($id); } $this->assign('postTypes', $postTypes); // This will go to form.php parent::display(); }
public function getPosterHTML($userId, $options) { $user = DiscussHelper::getTable('Profile'); $user->load($userId); $json = new Services_JSON(); $options = $json->encode($options); $themes = new DiscussThemes(); $themes->set('user', $user); $themes->set('options', $options); return $themes->fetch('tooltip.poster.php'); }
public function getReloadScript($ajax, $captchaId) { JTable::addIncludePath(DISCUSS_TABLES); if (isset($captchaId)) { $ref = DiscussHelper::getTable('Captcha'); $ref->load($captchaId); $ref->delete(); } //return 'eblog.captcha.reload();'; return; }
public function removeAvatar() { // Check for request forgeries JRequest::checkToken('get') or jexit('Invalid Token'); $id = JRequest::getInt('id'); $category = DiscussHelper::getTable('Category'); $category->load($id); $state = $category->removeAvatar(true); DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_CATEGORY_AVATAR_REMOVED'), DISCUSS_QUEUE_SUCCESS); JFactory::getApplication()->redirect('index.php?option=com_easydiscuss&view=category&catid=' . $category->id); }
function deleteFile($id) { $config = DiscussHelper::getConfig(); if (empty($id)) { return false; } $attachment = DiscussHelper::getTable('Attachments'); if (!$attachment->load($id)) { return false; } return $attachment->delete(); }
public function addFav($postId, $userId, $type = 'post') { $date = DiscussHelper::getDate(); $fav = DiscussHelper::getTable('Favourites'); $fav->created_by = $userId; $fav->post_id = $postId; $fav->type = $type; $fav->created = $date->toMySQL(); if (!$fav->store()) { return false; } return true; }
/** * Stores a private message composed by the user. * * @since 3.0 * @access public * @param null */ public function save() { JRequest::checkToken('request') or jexit('Invalid Token'); $config = DiscussHelper::getConfig(); $recipientId = JRequest::getInt('recipient', 0); $app = JFactory::getApplication(); $my = JFactory::getUser(); // Test for valid recipients. if (!$recipientId) { DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_MESSAGING_INVALID_RECIPIENT')); $app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=conversation&layout=compose', false)); $app->close(); } // Do not allow user to send a message to himself, it's crazy. if ($recipientId == $my->id) { DiscussHelper::setMessageQueue(JText::_('You should not start a conversation with your self.')); $app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=conversation&layout=compose', false)); $app->close(); } // Initialize conversation table. $conversation = DiscussHelper::getTable('Conversation'); // Check if this conversation already exist in the system. $state = $conversation->loadByRelation($my->id, $recipientId); if (!$state) { $date = DiscussHelper::getDate()->toMySQL(); $conversation->created = $date; $conversation->created_by = $my->id; $conversation->lastreplied = $date; $conversation->store(); } // Get message from query. $content = JRequest::getVar('message'); // 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 participant to this conversation. $model = DiscussHelper::getModel('Conversation'); $model->addParticipant($conversation->id, $recipientId, $my->id); // Add message map so that recipient can view the message. $model->addMessageMap($conversation->id, $message->id, $recipientId, $my->id); // @TODO: Add notification for recipient to let them know they received a message. // @TODO: Add points for user. // @TODO: Add badge for user. // Set message queue. DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_MESSAGE_SENT')); $app->redirect(DiscussRouter::getMessageRoute($conversation->id, false)); }
function display($tmpl = null) { $config = DiscussHelper::getConfig(); if (!$config->get('main_rss')) { return; } $document = JFactory::getDocument(); $document->link = JRoute::_('index.php?option=com_easydiscuss&view=index'); $document->setTitle($this->escape($document->getTitle())); $sort = JRequest::getString('sort', 'latest'); $filter = JRequest::getString('filter', 'allposts'); $category = JRequest::getInt('category_id', 0); $postModel = $this->getModel('Posts'); $posts = $postModel->getData(true, $sort, null, $filter, $category); $pagination = $postModel->getPagination('0', $sort, $filter, $category); $jConfig = DiscussHelper::getJConfig(); $posts = DiscussHelper::formatPost($posts); require_once DISCUSS_HELPERS . '/parser.php'; foreach ($posts as $row) { // Assign to feed item $title = $this->escape($row->title); $title = html_entity_decode($title); $category = DiscussHelper::getTable('Category'); $category->load($row->category_id); // load individual item creator class $item = new JFeedItem(); //Problems with other language //$item->title = htmlentities( $title ); $item->title = $row->title; $item->link = JRoute::_('index.php?option=com_easydiscuss&view=post&id=' . $row->id); //$row->content = DiscussHelper::parseContent( $row->content ); if ($row->content_type == 'bbcode') { $row->content = DiscussHelper::parseContent($row->content); $row->content = html_entity_decode($row->content); } // Problems with other language //$item->description = htmlentities( $row->content ); $item->description = $row->content; $item->date = DiscussHelper::getDate($row->created)->toMySQL(); $item->author = $row->user->getName(); $item->category = $category->getTitle(); if ($jConfig->get('feed_email') != 'none') { if ($jConfig->get('feed_email') == 'author') { $item->authorEmail = $row->user->user->email; } else { $item->authorEmail = $jConfig->get('mailfrom'); } } $document->addItem($item); } }
function display($tmpl = null) { $config = DiscussHelper::getConfig(); if (!$config->get('main_rss')) { return; } $userid = JRequest::getInt('id', null); $user = JFactory::getUser($userid); $document = JFactory::getDocument(); $document->link = DiscussRouter::_('index.php?option=com_easydiscuss&view=profile&id=' . $user->id); $profile = DiscussHelper::getTable('Profile'); $profile->load($user->id); $document->setTitle($profile->getName()); $document->setDescription($profile->getDescription()); $jConfig = DiscussHelper::getJConfig(); $model = $this->getModel('Posts'); $posts = $model->getPostsBy('user', $profile->id); $posts = DiscussHelper::formatPost($posts); foreach ($posts as $row) { // Assign to feed item $title = $this->escape($row->title); $title = html_entity_decode($title); // load individual item creator class $item = new JFeedItem(); $item->title = $title; $item->link = JRoute::_('index.php?option=com_easydiscuss&view=post&id=' . $row->id); $item->description = $row->content; $item->date = DiscussHelper::getDate($row->created)->toMySQL(); if (!empty($row->tags)) { $tagData = array(); foreach ($row->tags as $tag) { $tagData[] = '<a href="' . JRoute::_('index.php?option=com_easydiscuss&view=tags&id=' . $tag->id) . '">' . $tag->title . '</a>'; } $row->tags = implode(', ', $tagData); } else { $row->tags = ''; } $item->category = $row->tags; $item->author = $row->user->getName(); if ($jConfig->get('feed_email') != 'none') { if ($jConfig->get('feed_email') == 'author') { $item->authorEmail = $row->user->email; } else { $item->authorEmail = $jConfig->get('mailfrom'); } } $document->addItem($item); } }
public function display($tpl = null) { // Initialise variables $doc = JFactory::getDocument(); $doc->addScript(JURI::root() . 'administrator/components/com_easydiscuss/assets/js/admin.js'); // Load front end language file. JFactory::getLanguage()->load('com_easydiscuss', JPATH_ROOT); $postId = JRequest::getInt('id', 0); $parentId = JRequest::getString('pid', ''); $source = JRequest::getVar('source', 'posts'); $post = JTable::getInstance('Posts', 'Discuss'); $post->load($postId); $post->content_raw = $post->content; // Get post's tags $postModel = $this->getModel('Posts'); $post->tags = $postModel->getPostTags($post->id); $post->content = EasyDiscussParser::html2bbcode($post->content); // Select top 20 tags. $tagmodel = $this->getModel('Tags'); $populartags = $tagmodel->getTagCloud('20', 'post_count', 'DESC'); $repliesCnt = $postModel->getPostRepliesCount($post->id); $nestedCategories = DiscussHelper::populateCategories('', '', 'select', 'category_id', $post->category_id, true, true); $config = DiscussHelper::getConfig(); // Get's the creator's name $creatorName = $post->poster_name; if ($post->user_id) { $author = DiscussHelper::getTable('Profile'); $author->load($post->user_id); $creatorName = $author->getName(); } require_once DISCUSS_CLASSES . '/composer.php'; $composer = new DiscussComposer("creating", $post); $this->assignRef('creatorName', $creatorName); $this->assignRef('config', $config); $this->assignRef('post', $post); $this->assignRef('populartags', $populartags); $this->assignRef('repliesCnt', $repliesCnt); $this->assignRef('source', $source); $this->assignRef('parentId', $parentId); $this->assignRef('nestedCategories', $nestedCategories); $this->assignRef('composer', $composer); $this->assign('joomlaversion', DiscussHelper::getJoomlaVersion()); //load require javascript string DiscussHelper::loadString(JRequest::getVar('view')); parent::display($tpl); }
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 preview($blogId) { $ajax = new Ejax(); $mailq = DiscussHelper::getTable('Mailqueue'); $mailq->load($blogId); $options = new stdClass(); $options->title = JText::_('COM_EASYDISCUSS_EMAIL_PREVIEW'); $options->content = $mailq->body; $buttons = array(); $button = new stdClass(); $button->title = JText::_('COM_EASYDISCUSS_OK'); $button->action = 'disjax.closedlg();'; $button->className = 'btn-primary'; $buttons[] = $button; $options->buttons = $buttons; $ajax->dialog($options); $ajax->send(); }
function removeAccess() { $mainframe = JFactory::getApplication(); $user = JFactory::getUser(); $return = DiscussRouter::_('index.php?option=com_easydiscuss&view=profile', false); if ($user->id == 0) { DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_TWITTER_USER_NOT_FOUND'), 'error'); $this->setRedirect($return); } $twitter = DiscussHelper::getTable('Twitter'); if (!$twitter->load($user->id)) { DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_TWITTER_OAUTH_DOESNT_EXIST'), 'error'); $this->setRedirect($return); } $twitter->delete(); DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_TWITTER_REQUIRE_AUTHENTICATION')); $this->setRedirect($return); }
/** * Reload the captcha image. * @param Ejax $ejax Ejax object * @return string The javascript action to reload the image. **/ public function reload($ajax, $captchaId) { $config = DiscussHelper::getConfig(); // If no captcha is enabled, ignore it. if (!$config->get('antispam_easydiscuss_captcha_registered') || !$config->get('antispam_easydiscuss_captcha')) { return true; } // @task: If recaptcha is not enabled, we assume that the built in captcha is used. // Generate a new captcha if (isset($captchaId)) { $ref = DiscussHelper::getTable('Captcha'); $ref->load($captchaId); $ref->delete(); } require_once DISCUSS_CLASSES . DIRECTORY_SEPARATOR . 'captcha.php'; $ajax->script(DiscussCaptchaClasses::getReloadScript($ajax, $captchaId)); return true; }