Exemple #1
0
 public function compile()
 {
     $config = DiscussHelper::getConfig();
     $less = DiscussHelper::getHelper('less');
     // Force compile
     $less->compileMode = 'force';
     $name = JRequest::getCmd('name', null, 'GET');
     $type = JRequest::getCmd('type', null, 'GET');
     $result = new stdClass();
     if (isset($name) && isset($type)) {
         switch ($type) {
             case "admin":
                 $result = $less->compileAdminStylesheet($name);
                 break;
             case "site":
                 $result = $less->compileSiteStylesheet($name);
                 break;
             case "module":
                 $result = $less->compileModuleStylesheet($name);
                 break;
             default:
                 $result->failed = true;
                 $result->message = "Stylesheet type is invalid.";
         }
     } else {
         $result->failed = true;
         $result->message = "Insufficient parameters provided.";
     }
     header('Content-type: text/javascript; UTF-8');
     echo json_encode($result);
     exit;
 }
 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);
 }
 /**
  * Displays the user's points achievement history
  *
  * @since	2.0
  * @access	public
  */
 public function history($tmpl = null)
 {
     $app = JFactory::getApplication();
     $id = JRequest::getInt('id');
     if (!$id) {
         DiscussHelper::setMessageQueue(JText::_('Unable to locate the id of the user.'), DISCUSS_QUEUE_ERROR);
         $app->redirect('index.php?option=com_easydiscuss');
         $app->close();
     }
     $model = DiscussHelper::getModel('Points', true);
     $history = $model->getPointsHistory($id);
     foreach ($history as $item) {
         $date = DiscussDateHelper::dateWithOffSet($item->created);
         $item->created = $date->toFormat('%A, %b %e %Y');
         $points = DiscussHelper::getHelper('Points')->getPoints($item->command);
         if ($points) {
             if ($points[0]->rule_limit < 0) {
                 $item->class = 'badge-important';
                 $item->points = $points[0]->rule_limit;
             } else {
                 $item->class = 'badge-info';
                 $item->points = '+' . $points[0]->rule_limit;
             }
         } else {
             $item->class = 'badge-info';
             $item->points = '+';
         }
     }
     $theme = new DiscussThemes();
     $theme->set('history', $history);
     echo $theme->fetch('points.history.php');
 }
    public function getnews()
    {
        $ajax = DiscussHelper::getHelper('Ajax');
        $news = DiscussHelper::getRecentNews();
        ob_start();
        if (!$news) {
            echo '<li class="empty">' . JText::_('COM_EASYDISCUSS_NO_NEWS_ITEM') . '</li>';
        } else {
            foreach ($news as $newsItem) {
                $dates = explode('/', $newsItem->date);
                ?>
			<li>
				<span class="updates-news">
					<a href="javascript:void(0);"><?php 
                echo $newsItem->title;
                ?>
</a>
					<span><?php 
                echo $newsItem->desc;
                ?>
</span>
				</span>
				<span class="si-date"><span><?php 
                echo $dates[0];
                ?>
</span>may</span>
				<span class="clear"></span>
			</li>
			<?php 
            }
        }
        $output = ob_get_contents();
        ob_end_clean();
        $ajax->success($output);
    }
 /**
  * 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;
 }
Exemple #6
0
 public function toFormat($format = '%Y-%m-%d %H:%M:%S')
 {
     if (DiscussHelper::getJoomlaVersion() >= '1.6') {
         if (JString::stristr($format, '%') !== false) {
             $format = DiscussHelper::getHelper('date')->strftimeToDate($format);
         }
         return $this->date->format($format);
     } else {
         return $this->date->toFormat($format);
     }
 }
 public function count()
 {
     $my = JFactory::getUser();
     $ajax = DiscussHelper::getHelper('Ajax');
     if ($my->id <= 0) {
         $ajax->fail('User is not logged in.');
         return;
     }
     $model = $this->getModel('Notification');
     $count = $model->getTotalNotifications($my->id);
     $ajax->success($count);
 }
 public function display($tpl = null)
 {
     $my = JFactory::getUser();
     if (!$my->id) {
         DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_PLEASE_LOGIN_FIRST'), 'error');
         JFactory::getApplication()->redirect(DiscussRouter::_('index.php?option=com_easydiscuss', false));
     }
     $model = $this->getModel('Notification');
     $this->setPathway(JText::_('COM_EASYDISCUSS_BREADCRUMBS_NOTIFICATIONS'));
     // Make this configurable?
     $limit = 100;
     $notifications = $model->getNotifications($my->id, false, $limit);
     DiscussHelper::getHelper('Notifications')->format($notifications, true);
     $theme = new DiscussThemes();
     $theme->set('notifications', $notifications);
     echo $theme->fetch('notifications.php');
 }
Exemple #9
0
 public function assign($command, $userId)
 {
     // We don't have to give any badge to guests.
     if (!$userId || $userId == 0) {
         return;
     }
     // @task: Load necessary language files
     JFactory::getLanguage()->load('com_easydiscuss', JPATH_ROOT);
     $config = DiscussHelper::getConfig();
     // If badges is disabled, do not proceed.
     if (!$config->get('main_badges')) {
         return;
     }
     // @task: Compute the count of the history already matches any badge for this user.
     $total = $this->getTotal($command, $userId);
     // @task: Get the badges that is relevant to this command
     $badges = $this->getBadges($command, $userId);
     if (!$badges) {
         return false;
     }
     foreach ($badges as $badge) {
         if ($total >= $badge->rule_limit) {
             $table = DiscussHelper::getTable('BadgesUsers');
             $table->set('badge_id', $badge->id);
             $table->set('user_id', $userId);
             $table->set('created', DiscussHelper::getDate()->toMySQL());
             $table->set('published', 1);
             $table->store();
             // @task: Add a new notification when they earned a new badge.
             $notification = DiscussHelper::getTable('Notifications');
             $notification->bind(array('title' => JText::sprintf('COM_EASYDISCUSS_NEW_BADGE_NOTIFICATION_TITLE', $badge->title), 'cid' => $badge->id, 'type' => DISCUSS_NOTIFICATIONS_BADGE, 'target' => $userId, 'author' => $userId, 'permalink' => 'index.php?option=com_easydiscuss&view=profile&id=' . $userId));
             $notification->store();
             //insert into JS stream.
             if ($config->get('integration_jomsocial_activity_badges', 0)) {
                 $badgeTable = DiscussHelper::getTable('Badges');
                 $badgeTable->load($badge->id);
                 $badgeTable->uniqueId = $table->id;
                 DiscussHelper::getHelper('jomsocial')->addActivityBadges($badgeTable);
             }
         }
     }
     return true;
 }
 public function ajaxResetRank()
 {
     $ajax = DiscussHelper::getHelper('Ajax');
     $userid = JRequest::getInt('userid');
     $config = DiscussHelper::getConfig();
     $db = DiscussHelper::getDBO();
     $table = DiscussHelper::getTable('Ranksusers');
     // $table->load( '', $userid );
     if (!$table->load('', $userid)) {
         $ajax->reject();
         return $ajax->send();
     }
     $table->delete();
     // If after delete but rank still does not update, it might because there are multiple record of ranks in the database record.
     // Because the delete function only delete one record. (In case his db messed up, which contains multiple records.)
     DiscussHelper::getHelper('Ranks')->assignRank($userid, $config->get('main_ranking_calc_type', 'posts'));
     $ajax->resolve();
     return $ajax->send();
 }
 public function __construct(DiscussPost $post, DiscussCategory $category)
 {
     $this->my = JFactory::getUser();
     $this->config = DiscussHelper::getConfig();
     // Creator of the post
     $this->creator = DiscussHelper::getTable('Profile');
     $this->creator->load($post->user_id);
     $this->post = $post;
     $this->parent = null;
     if (!empty($this->post->parent_id)) {
         // we now this item is a reply. let get the parent;
         $parentPost = DiscussHelper::getTable('Post');
         $parentPost->load($this->post->parent_id);
         $this->parent = $parentPost;
     }
     $this->isSiteAdmin = DiscussHelper::isSiteAdmin();
     $this->category = $category;
     $this->acl = DiscussHelper::getHelper('ACL');
     $this->isModerator = DiscussHelper::getHelper('Moderator')->isModerator($this->post->category_id);
 }
 public function diplayRole()
 {
     // Initialise variables
     $mainframe = JFactory::getApplication();
     $roleId = JRequest::getVar('role_id', '');
     $role = DiscussHelper::getTable('Role');
     $role->load($roleId);
     $role->title = JString::trim($role->title);
     $this->role = $role;
     // Set default values for new entries.
     if (empty($role->created_time)) {
         $date = DiscussHelper::getHelper('Date')->dateWithOffSet();
         $role->created_time = $date->toFormat();
         $role->published = true;
     }
     $groups = DiscussHelper::getJoomlaUserGroups();
     // Remove the selected usergroups
     $db = DiscussHelper::getDbo();
     $query = 'SELECT `usergroup_id` FROM `#__discuss_roles`';
     $db->setQuery($query);
     $result = $db->loadResultArray();
     if (!empty($result)) {
         foreach ($groups as $key => $group) {
             if (in_array($group->id, $result) && $group->id != $role->usergroup_id) {
                 unset($groups[$key]);
             }
         }
     }
     $usergroupList = JHTML::_('select.genericlist', $groups, 'usergroup_id', 'class="full-width"', 'id', 'name', $role->usergroup_id);
     $this->assignRef('role', $role);
     $this->assignRef('usergroupList', $usergroupList);
     $colors = array();
     $colors[] = JHTML::_('select.option', 'success', JText::_('COM_EASYDISCUSS_LABEL_COLORCODE_SUCCESS'));
     $colors[] = JHTML::_('select.option', 'warning', JText::_('COM_EASYDISCUSS_LABEL_COLORCODE_WARNING'));
     $colors[] = JHTML::_('select.option', 'important', JText::_('COM_EASYDISCUSS_LABEL_COLORCODE_IMPORTANT'));
     $colors[] = JHTML::_('select.option', 'info', JText::_('COM_EASYDISCUSS_LABEL_COLORCODE_INFO'));
     $colors[] = JHTML::_('select.option', 'inverse', JText::_('COM_EASYDISCUSS_LABEL_COLORCODE_INVERSE'));
     $colorList = JHTML::_('select.genericlist', $colors, 'colorcode', 'class="full-width"', 'value', 'text', $role->colorcode);
     $this->assignRef('colorList', $colorList);
     parent::display('edit');
 }
Exemple #13
0
 public function assign($command, $userId, $post = null)
 {
     // Assign points via EasySocial
     DiscussHelper::getHelper('EasySocial')->assignPoints($command, $userId, $post);
     if (!$userId) {
         return false;
     }
     $points = $this->getPoints($command);
     if (!$points) {
         return false;
     }
     $profile = DiscussHelper::getTable('Profile');
     $profile->load($userId);
     foreach ($points as $point) {
         $profile->addPoint($point->rule_limit);
     }
     $profile->store();
     // ranking
     // DiscussHelper::getHelper( 'ranks' )->assignRank( $userId, 'points' );
     return true;
 }
 public function addFieldOption()
 {
     $ajax = DiscussHelper::getHelper('Ajax');
     $addField = JRequest::getVar('activeType');
     $count = JRequest::getInt('fieldCount');
     if (!empty($id)) {
         //Get previous value
         $field = DiscussHelper::getTable('CustomFields');
         $field->load($id);
     }
     if (empty($addField)) {
         $ajax->reject();
         return $ajax->send();
     }
     switch ($addField) {
         case 'radiobtn':
             $fieldName = 'radioBtnValue[]';
             break;
         case 'checkbox':
             $fieldName = 'checkBoxValue[]';
             break;
         case 'selectlist':
             $fieldName = 'selectValue[]';
             break;
         case 'multiplelist':
             $fieldName = 'multipleValue[]';
             break;
         default:
             break;
     }
     // We need to add 1 from the previous count for the next item
     $count++;
     //We do not want add button for text and textarea
     if ($addField != 'text' || $addField != 'area') {
         //New field
         $html = '<li class="remove' . $addField . '_' . $count . '">' . '<div class="span10 remove' . $addField . '_' . $count . '">' . '<div class="input-append remove' . $addField . '_' . $count . '">' . '<input type="text" class="input-full ' . $addField . '" id="' . $addField . '_' . $count . '" name="' . $fieldName . '" value="" />' . '<button type="button" id="' . $count . '" class="btn btn-danger btn-customfield-remove" name="Remove" data-removetype="' . $addField . '"><i class="icon-remove"></i></button>' . '</div>' . '</div>' . '</li>';
     }
     $ajax->resolve($html, $count);
     return $ajax->send();
 }
Exemple #15
0
 public static function validateUserType($usertype)
 {
     $config = DiscussHelper::getConfig();
     $acl = DiscussHelper::getHelper('ACL', '0');
     switch ($usertype) {
         case 'guest':
             $enable = $acl->allowed('add_reply', 0);
             break;
         case 'twitter':
             $enable = $config->get('integration_twitter_enable');
             break;
         case 'facebook':
             $enable = $config->get('integration_facebook_enable1');
             break;
         case 'linkedin':
             $enable = $config->get('integration_linkedin_enable1');
             break;
         default:
             $enable = false;
     }
     return $enable;
 }
 public function form()
 {
     $id = JRequest::getInt('id', 0);
     $this->addPathway('Home', 'index.php?option=com_easydiscuss');
     $this->addPathway('Points', 'index.php?option=com_easydiscuss&view=points');
     $point = DiscussHelper::getTable('Points');
     $point->load($id);
     if ($point->id) {
         $this->addPathway(JText::_('COM_EASYDISCUSS_PATHWAY_EDIT_POINT'));
     } else {
         $this->addPathway(JText::_('COM_EASYDISCUSS_PATHWAY_NEW_POINT'));
     }
     if (!$point->created) {
         $date = DiscussHelper::getHelper('Date')->dateWithOffset(DiscussHelper::getDate()->toMySQL());
         $point->created = $date->toMySQL();
     }
     $model = $this->getModel('Points');
     $rules = $model->getRules();
     $this->assign('rules', $rules);
     $this->assign('point', $point);
     parent::display();
 }
 function display($tpl = null)
 {
     //initialise variables
     $document = JFactory::getDocument();
     $user = JFactory::getUser();
     $config = DiscussHelper::getConfig();
     $mainframe = JFactory::getApplication();
     $acl = DiscussHelper::getHelper('ACL');
     $filteractive = JRequest::getString('filter', 'allposts');
     $query = JRequest::getString('query', '');
     $sort = JRequest::getString('sort', 'latest');
     $category = JRequest::getInt('category_id', 0);
     $postModel = $this->getModel('Posts');
     $featuredposts = '';
     $featuredpostsHTML = '';
     $showFeaturedPost = true;
     $posts = $postModel->getData(true, $sort, null, $filteractive, $category, null, $showFeaturedPost);
     $pagination = $postModel->getPagination('0', $sort, $filteractive, $category, $showFeaturedPost);
     $posts = DiscussHelper::formatPost($posts);
     $concatCode = DiscussHelper::getJConfig()->getValue('sef') ? '?' : '&';
     $document->addHeadLink(JRoute::_('index.php?option=com_easydiscuss&view=featured') . $concatCode . 'format=feed&type=rss', 'alternate', 'rel', array('type' => 'application/rss+xml', 'title' => 'RSS 2.0'));
     $document->addHeadLink(JRoute::_('index.php?option=com_easydiscuss&view=featured') . $concatCode . 'format=feed&type=atom', 'alternate', 'rel', array('type' => 'application/atom+xml', 'title' => 'Atom 1.0'));
     $rssLink = DiscussHelper::getHelper('Feeds')->getFeedURL('index.php?option=com_easydiscuss&view=featured');
     $tpl = new DiscussThemes();
     $tpl->set('rssLink', $rssLink);
     $filterBar = '';
     $tpl->set('acl', $acl);
     $tpl->set('posts', $posts);
     $tpl->set('paginationType', DISCUSS_QUESTION_TYPE);
     $tpl->set('parent_id', 0);
     $tpl->set('pagination', $pagination);
     $tpl->set('sort', $sort);
     $tpl->set('filter', $filteractive);
     $tpl->set('filterbar', $filterBar);
     $tpl->set('query', $query);
     $tpl->set('config', $config);
     echo $tpl->fetch('featured.php');
 }
Exemple #18
0
 public static function getLikeHTML($row, $position = 'vertical')
 {
     $config = DiscussHelper::getConfig();
     if (!$config->get('integration_facebook_like')) {
         return '';
     }
     $document = JFactory::getDocument();
     $language = $document->getLanguage();
     $language = explode('-', $language);
     if (count($language) != 2) {
         $language = array('en', 'GB');
     }
     $layout = $config->get('integration_facebook_like_layout');
     $faces = $config->get('integration_facebook_like_faces') ? 'true' : 'false';
     $width = $config->get('integration_facebook_like_width');
     $verb = $config->get('integration_facebook_like_verb');
     $theme = $config->get('integration_facebook_like_theme');
     $send = $config->get('integration_facebook_like_send') ? 'true' : 'false';
     $height = $faces == 'true' ? '70' : '30';
     $locale = $language[0] . '_' . JString::strtoupper($language[1]);
     $fb = DiscussHelper::getHelper('Facebook');
     $fb->addOpenGraph($row);
     $url = DiscussRouter::getRoutedURL('index.php?option=com_easydiscuss&view=post&id=' . $row->id, true, true);
     $html = '';
     if ($position == 'horizontal') {
         $layout = 'button_count';
     } else {
         $layout = 'box_count';
     }
     $html = '<div class="social-button facebook-like">';
     if ($config->get('integration_facebook_scripts')) {
         $html .= '<div id="fb-root"></div><script src="https://connect.facebook.net/' . $locale . '/all.js#xfbml=1"></script>';
     }
     $html .= '<fb:like href="' . $url . '" send="' . $send . '" layout="' . $layout . '" action="' . $verb . '" ';
     $html .= 'locale="' . $locale . '" colorscheme="' . $theme . '" show_faces="' . $faces . '" style="height: ' . $height . ';" height="' . $height . '"></fb:like>';
     $html .= '</div>';
     return $html;
 }
 public function remove()
 {
     $my = JFactory::getUser();
     $ajax = DiscussHelper::getHelper('ajax');
     $config = DiscussHelper::getConfig();
     // Get the post.
     $postId = JRequest::getInt('postid');
     $post = DiscussHelper::getTable('Post');
     $post->load($postId);
     // Is this a reply?
     if ($post->isReply()) {
         $ajax->reject();
         return $ajax->send();
     }
     // Is the backend option enabled?
     if (!$config->get('main_favorite')) {
         // show error msg
         $ajax->reject();
         return $ajax->send();
     }
     // Is it a valid user?
     if (!$my->id) {
         $ajax->reject();
         return $ajax->send();
     }
     // Get favourite table
     $favModel = DiscussHelper::getModel('Favourites');
     $result = $favModel->removeFav($post->id, $my->id);
     if (!$result) {
         $ajax->reject();
         return $ajax->send();
     }
     // Update JomSocial Status
     // code..
     $ajax->resolve($postId);
     return $ajax->send();
 }
 public function form()
 {
     $app = JFactory::getApplication();
     $id = JRequest::getInt('id', '');
     $field = DiscussHelper::getTable('CustomFields');
     $field->load($id);
     $this->addPathway('Home', 'index.php?option=com_easydiscuss');
     $this->addPathway('Custom Fields', 'index.php?option=com_easydiscuss&view=customfields');
     $field->title = JString::trim($field->title);
     $this->id = $field;
     if (!$field) {
         JToolBarHelper::title(JText::_('COM_EASYDISCUSS_ADD_NEW_CUSTOMFIELDS'), 'customs');
         $this->addPathway('New Field', '');
     } else {
         JToolBarHelper::title(JText::_('COM_EASYDISCUSS_EDITING_CUSTOMFIELDS'), 'customs');
         $this->addPathway('Editing Field', '');
     }
     JHTML::_('behavior.modal');
     // Set default values for new entries.
     if (empty($field->created_time)) {
         $date = DiscussHelper::getHelper('Date')->dateWithOffSet();
         $field->created_time = $date->toFormat();
         $field->published = true;
     }
     $customAclItems = JTable::getInstance('CustomFieldsACL', 'Discuss');
     $customFieldsAcl = $customAclItems->getCustomFieldsACL();
     $assignedGroupACL = $field->getAssignedACL('group');
     $assignedUserACL = $field->getAssignedACL('user');
     $joomlaGroups = DiscussHelper::getJoomlaUserGroups();
     $this->assignRef('field', $field);
     $this->assignRef('assignedGroupACL', $assignedGroupACL);
     $this->assignRef('assignedUserACL', $assignedUserACL);
     $this->assignRef('customFieldsAcl', $customFieldsAcl);
     $this->assignRef('joomlaGroups', $joomlaGroups);
     parent::display();
 }
Exemple #21
0
 /**
  * Sends an auto post request to social networks such as Facebook, Twitter etc.
  *
  * @since	3.0
  * @access	public
  * @param	null
  * @return	boolean	True if success, false otherwise.
  */
 public function autopost()
 {
     // Only allow post that are really published.
     if (!$this->published) {
         return false;
     }
     $category = DiscussHelper::getTable('Category');
     $category->load($this->category_id);
     // Only allow post that are posted in a public category.
     if (!$category->canPublicAccess()) {
         return false;
     }
     $config = DiscussHelper::getConfig();
     // Set generic callback URL.
     $callback = DiscussRouter::getRoutedUrl('index.php?option=com_easydiscuss&view=post&id=' . $this->id, false, true);
     // These are the default social sites which we need to ping.
     $sites = array('facebook', 'twitter');
     foreach ($sites as $site) {
         if ($config->get('main_autopost_' . $site)) {
             $oauth = DiscussHelper::getTable('OAuth');
             $state = $oauth->loadByType($site);
             // Determine if this discussion is already shared on the social site.
             $oauthPost = DiscussHelper::getTable('OauthPosts');
             $shared = $oauthPost->exists($this->id, $oauth->id);
             if (!$shared && $state && !empty($oauth->access_token)) {
                 $consumer = DiscussHelper::getHelper('OAuth')->getConsumer($site, $config->get('main_autopost_' . $site . '_id'), $config->get('main_autopost_' . $site . '_secret'), $callback);
                 // Set access token for the social site.
                 $consumer->setAccess($oauth->access_token);
                 // Try to share the post to the site.
                 $status = $consumer->share($this);
                 // @TODO: Add error logging when something fail here.
                 // When the psot is shared we need to keep a record of this to prevent from sending duplicate updates.
                 $oauthPost->post_id = $this->id;
                 $oauthPost->oauth_id = $oauth->id;
                 $oauthPost->store();
             }
         }
     }
 }
					<?php 
if ($captcha = $this->getRecaptcha()) {
    ?>
					<div class="control-group">
						<div class="respond-recaptcha mt-10"><?php 
    echo $captcha;
    ?>
</div>
					</div>
					<?php 
} else {
    if (DiscussHelper::getHelper('Captcha')->showCaptcha()) {
        ?>
						<?php 
        echo DiscussHelper::getHelper('Captcha')->getHTML();
        ?>
					<?php 
    }
}
?>

					<div class="fd-cf">
						<div class="pull-left">
							<a href="<?php 
echo DiscussRouter::_('index.php?option=com_easydiscuss&view=post&id=' . $post->parent_id);
?>
" class="btn btn-medium btn-danger"><?php 
echo JText::_('COM_EASYDISCUSS_BUTTON_CANCEL');
?>
</a>
" rel="ed-tooltip" data-placement="top" data-original-title="<?php 
        echo $this->escape($user->getName());
        ?>
">
					<?php 
        if ($system->config->get('layout_avatar')) {
            ?>
					<span class="discuss-avatar avatar-circle">
						<img src="<?php 
            echo $user->getAvatar();
            ?>
" alt="<?php 
            echo $this->escape($user->getName());
            ?>
"<?php 
            echo DiscussHelper::getHelper('EasySocial')->getPopbox($user->id);
            ?>
 />
					</span>
					<?php 
        } else {
            ?>
						<?php 
            echo $this->escape($user->getName());
            ?>
					<?php 
        }
        ?>
				</a>
			</li>
			<?php 
Exemple #24
0
                ?>
								<?php 
                if ($config->get('layout_avatar')) {
                    ?>
									<a href="<?php 
                    echo $post->reply->getLink();
                    ?>
" class="pull-left ml-5" title="<?php 
                    echo $post->reply->getName();
                    ?>
">
										<img src="<?php 
                    echo $post->reply->getAvatar();
                    ?>
" alt="<?php 
                    echo DiscussHelper::getHelper('String')->escape($post->reply->getName());
                    ?>
" />
									</a>
									<?php 
                }
                ?>
								<?php 
            } else {
                ?>
									<?php 
                echo $post->reply->poster_name;
                ?>
								<?php 
            }
            ?>
</li>
					<?php 
            $day = $reply->daydiff;
        } else {
            if ($day != $reply->daydiff) {
                if ($reply->daydiff == 0) {
                    ?>
							<li class="divider small today"><?php 
                    echo JText::_('COM_EASYDISCUSS_CONVERSATION_SEPARATOR_TODAY');
                    ?>
</li>
						<?php 
                } else {
                    ?>
							<li class="divider small"><?php 
                    echo DiscussHelper::getHelper('Date')->getLapsedTime($reply->created);
                    ?>
</li>
						<?php 
                }
                $day = $reply->daydiff;
            }
        }
        ?>

				<?php 
        echo $this->loadTemplate('conversation.read.item.php', array('reply' => $reply));
        ?>
			<?php 
    }
    ?>
Exemple #26
0
 public static function validateCaptcha($data)
 {
     require_once DISCUSS_CLASSES . '/recaptcha.php';
     require_once DISCUSS_CLASSES . '/captcha.php';
     $config = DiscussHelper::getConfig();
     if ($config->get('antispam_easydiscuss_captcha')) {
         // If captcha is not enforced, we should allow this to bypass
         if (!DiscussHelper::getHelper('Captcha')->showCaptcha()) {
             return true;
         }
         $discussCaptcha = new stdClass();
         $discussCaptcha->captchaResponse = JRequest::getVar('captcha-response');
         $discussCaptcha->captchaId = JRequest::getInt('captcha-id');
         $state = DiscussHelper::getHelper('Captcha')->verify($discussCaptcha);
         return $state;
     }
     if (!DiscussRecaptcha::isRequired()) {
         return true;
     }
     $obj = DiscussRecaptcha::recaptcha_check_answer($config->get('antispam_recaptcha_private'), $_SERVER['REMOTE_ADDR'], $data['recaptcha_challenge_field'], $data['recaptcha_response_field']);
     if ($obj->is_valid) {
         return true;
     }
     return false;
 }
 private function mapKunenaItem($kItem, &$item, $parent = null)
 {
     $content = $this->getKunenaMessage($kItem);
     $hits = isset($kItem->threadhits) ? $kItem->threadhits : $kItem->hits;
     $lastreplied = isset($kItem->threadlastreplied) ? $kItem->threadlastreplied : $kItem->time;
     $item->set('content', $content);
     $subject = $kItem->subject;
     if (!$parent && $kItem->threadsubject) {
         $subject = $kItem->threadsubject;
     }
     $item->set('title', $subject);
     $item->set('category_id', $this->getNewCategory($kItem));
     $item->set('user_id', $kItem->userid);
     $item->set('user_type', DISCUSS_POSTER_MEMBER);
     $item->set('hits', $hits);
     $item->set('created', DiscussHelper::getDate($kItem->time)->toMySQL());
     $item->set('modified', DiscussHelper::getDate($kItem->time)->toMySQL());
     $item->set('replied', DiscussHelper::getDate($lastreplied)->toMySQL());
     $item->set('poster_name', $kItem->name);
     $item->set('ip', $kItem->ip);
     $item->set('content_type', 'bbcode');
     $item->set('parent_id', 0);
     // @task: If this is a child post, we definitely have the item's id.
     if ($parent) {
         $item->set('parent_id', $parent->id);
     }
     $item->set('islock', $kItem->locked);
     $item->set('poster_email', $kItem->email);
     $state = $kItem->hold == 0 ? DISCUSS_ID_PUBLISHED : DISCUSS_ID_UNPUBLISHED;
     $item->set('published', $state);
     if (!$kItem->userid) {
         $item->set('user_type', DISCUSS_POSTER_GUEST);
     }
     $item->store();
     // @task: Get attachments
     $files = $this->getKunenaAttachments($kItem);
     if ($files) {
         foreach ($files as $kAttachment) {
             $attachment = DiscussHelper::getTable('Attachments');
             $attachment->set('uid', $item->id);
             $attachment->set('size', $kAttachment->size);
             $attachment->set('title', $kAttachment->filename);
             $attachment->set('type', $item->getType());
             $attachment->set('published', DISCUSS_ID_PUBLISHED);
             $attachment->set('mime', $kAttachment->filetype);
             // Regenerate the path
             $isJoomla30 = DiscussHelper::isJoomla30();
             if ($isJoomla30) {
                 // JUtility::getHash is deprecated
                 $path = JApplication::getHash($kAttachment->filename . DiscussHelper::getDate()->toMySQL());
             } else {
                 $path = JUtility::getHash($kAttachment->filename . DiscussHelper::getDate()->toMySQL());
             }
             $attachment->set('path', $path);
             // Copy files over.
             $config = DiscussHelper::getConfig();
             $folderPath = DISCUSS_MEDIA . '/' . trim($config->get('attachment_path'), DIRECTORY_SEPARATOR);
             $storage = $folderPath . '/' . $path;
             $kStorage = JPATH_ROOT . '/' . rtrim($kAttachment->folder, '/') . '/' . $kAttachment->filename;
             // create folder if it not exists
             if (!JFolder::exists($folderPath)) {
                 JFolder::create($folderPath);
                 JFile::copy(DISCUSS_ROOT . '/index.html', $path . '/index.html');
             }
             if (JFile::exists($kStorage)) {
                 JFile::copy($kStorage, $storage);
                 if (DiscussHelper::getHelper('Image')->isImage($kAttachment->filename)) {
                     require_once DISCUSS_CLASSES . '/simpleimage.php';
                     $image = new SimpleImage();
                     @$image->load($kStorage);
                     @$image->resizeToFill(160, 120);
                     @$image->save($storage . '_thumb', $image->image_type);
                 }
             }
             // @task: Since Kunena does not store this, we need to generate the own creation timestamp.
             $attachment->set('created', DiscussHelper::getDate()->toMySQL());
             $attachment->store();
         }
     }
     //perform cleanup
     $this->added('com_kunena', $item->id, $kItem->id, 'post');
 }
Exemple #28
0
            ?>
									<a href="<?php 
            echo $post->reply->getLink();
            ?>
" class="pull-left discuss-avatar avatar-circle ml-5" title="<?php 
            echo $post->reply->getName();
            ?>
">
										<img src="<?php 
            echo $post->reply->getAvatar();
            ?>
" alt="<?php 
            echo $this->escape($post->reply->getName());
            ?>
"<?php 
            echo DiscussHelper::getHelper('EasySocial')->getPopbox($post->reply->id);
            ?>
 />
									</a>
									<?php 
        }
        ?>
									<?php 
    } else {
        ?>
										<?php 
        echo $post->reply->poster_name;
        ?>
									<?php 
    }
    ?>
			<?php 
if ($system->config->get('layout_category_stats')) {
    ?>
			<span class="pull-left"><i class="icon-columns"></i> <?php 
    echo JText::_('COM_EASYDISCUSS_TOTAL_POSTS');
    ?>
: <?php 
    echo $category->getPostCount();
    ?>
</span>
			<?php 
}
?>

			<?php 
$moderatorHTML = DiscussHelper::getHelper('Moderator')->showModeratorNameHTML($category->id);
?>
			<?php 
if ($system->config->get('layout_show_moderators') && $moderatorHTML !== false && !empty($moderatorHTML)) {
    ?>
			<span>
				<i class="icon-user"></i> <?php 
    echo $moderatorHTML;
    ?>
			</span>
			<?php 
}
?>
			&nbsp;
		</div>
 public function display($tpl = null)
 {
     // Initialise variables
     $doc = JFactory::getDocument();
     $my = JFactory::getUser();
     $config = DiscussHelper::getConfig();
     $app = JFactory::getApplication();
     $registry = DiscussHelper::getRegistry();
     $categoryId = JRequest::getInt('category_id', 0);
     // Perform redirection if there is a category_id in the index view.
     if (!empty($categoryId)) {
         $app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=categories&layout=listings&category_id=' . $categoryId, false));
         $app->close();
     }
     // Try to detect if there's any category id being set in the menu parameter.
     $activeMenu = $app->getMenu()->getActive();
     if ($activeMenu && !$categoryId) {
         // Load menu params to the registry.
         $registry->loadString($activeMenu->params);
         if ($registry->get('category_id')) {
             $categoryId = $registry->get('category_id');
         }
     }
     // Get the current logged in user's access.
     $acl = DiscussHelper::getHelper('ACL');
     // Todo: Perhaps we should fix the confused naming of filter and sort to type and sort
     $filter = JRequest::getString('filter', $registry->get('filter'));
     $sort = JRequest::getString('sort', $registry->get('sort'));
     // Get the pagination limit
     $limit = $registry->get('limit');
     $limit = $limit == '-2' ? DiscussHelper::getListLimit() : $limit;
     $limit = $limit == '-1' ? DiscussHelper::getJConfig()->get('list_limit') : $limit;
     // Add view to this page.
     $this->logView();
     // set page title.
     DiscussHelper::setPageTitle();
     // Set the meta of the page.
     DiscussHelper::setMeta();
     // Add rss feed into headers
     DiscussHelper::getHelper('Feeds')->addHeaders('index.php?option=com_easydiscuss&view=index');
     // Get list of categories on the site.
     $catModel = $this->getModel('Categories');
     // Pagination is by default disabled.
     $pagination = false;
     // Get the model.
     $postModel = DiscussHelper::getModel('Posts');
     // Get a list of accessible categories
     $cats = $this->getAccessibleCategories($categoryId);
     // Get featured posts from this particular category.
     $featured = array();
     if ($config->get('layout_featuredpost_frontpage')) {
         $options = array('pagination' => false, 'category' => $cats, 'sort' => $sort, 'filter' => $filter, 'limit' => $config->get('layout_featuredpost_limit', $limit), 'featured' => true);
         $featured = $postModel->getDiscussions($options);
         if (is_null($featured)) {
             $featured = array();
         }
     }
     // Get normal discussion posts.
     $options = array('sort' => $sort, 'category' => $cats, 'filter' => $filter, 'limit' => $limit, 'featured' => false);
     $posts = $postModel->getDiscussions($options);
     if (is_null($posts)) {
         $posts = array();
     }
     $authorIds = array();
     $topicIds = array();
     $tmpPostsArr = array_merge($featured, $posts);
     if (count($tmpPostsArr) > 0) {
         foreach ($tmpPostsArr as $tmpArr) {
             $authorIds[] = $tmpArr->user_id;
             $topicIds[] = $tmpArr->id;
         }
     }
     $pagination = $postModel->getPagination(0, 'latest', '', $cats, false);
     $postLoader = EDC::getTable('Posts');
     $postLoader->loadBatch($topicIds);
     $postTagsModel = EDC::getModel('PostsTags');
     $postTagsModel->setPostTagsBatch($topicIds);
     $model = EDC::getModel('Posts');
     $lastReplyUser = $model->setLastReplyBatch($topicIds);
     // Reduce SQL queries by pre-loading all author object.
     $authorIds = array_merge($lastReplyUser, $authorIds);
     $authorIds = array_unique($authorIds);
     // Initialize the list of user's so we run lesser sql queries.
     $profile = EDC::getTable('Profile');
     $profile->init($authorIds);
     // Format featured entries.
     $featured = EDC::formatPost($featured, false, true);
     // Format normal entries
     $posts = EDC::formatPost($posts, false, true);
     // Get unread count
     $unreadCount = $model->getUnreadCount($cats, false);
     // Get unresolved count
     // Change the "all" to TRUE or FALSE to include/exclude featured post count
     $unresolvedCount = $model->getUnresolvedCount('', $cats, '', 'all');
     // Get resolved count
     $resolvedCount = $model->getTotalResolved();
     // Get unanswered count
     $unansweredCount = EDC::getUnansweredCount($cats, true);
     // Get assigned post count that isn't answered yet.
     $assignedCount = 0;
     if (EDC::isSiteAdmin() || EDC::isModerator()) {
         $assignedModel = EDC::getModel('Assigned');
         $assignedCount = $assignedModel->getTotalUnresolved();
     }
     $activeFilter = $config->get('layout_frontpage_sorting');
     // Let's render the layout now.
     $theme = new DiscussThemes();
     $theme->set('assignedCount', $assignedCount);
     $theme->set('activeFilter', $activeFilter);
     $theme->set('activeSort', $sort);
     $theme->set('categories', $categoryId);
     $theme->set('unreadCount', $unreadCount);
     $theme->set('unansweredCount', $unansweredCount);
     $theme->set('resolvedCount', $resolvedCount);
     $theme->set('unresolvedCount', $unresolvedCount);
     $theme->set('posts', $posts);
     $theme->set('featured', $featured);
     $theme->set('pagination', $pagination);
     echo $theme->fetch('frontpage.index.php');
 }