Exemple #1
0
 private function allowSubscribeTeam($id)
 {
     JTable::addIncludePath(EBLOG_TABLES);
     $team = EasyBlogHelper::getTable('Teamblog', 'Table');
     $team->load($id);
     $acl = EasyBlogACLHelper::getRuleSet();
     $my = JFactory::getUser();
     $gid = EasyBlogHelper::getUserGids();
     return $team->allowSubscription($team->access, $my->id, $team->isMember($my->id, $gid), $acl->rules->allow_subscription);
 }
Exemple #2
0
 public static function getDefaultCategoryId()
 {
     $db = EasyBlogHelper::db();
     $gid = EasyBlogHelper::getUserGids();
     $gids = '';
     if (count($gid) > 0) {
         foreach ($gid as $id) {
             $gids .= empty($gids) ? $db->Quote($id) : ',' . $db->Quote($id);
         }
     }
     $query = 'SELECT a.id';
     $query .= ' FROM `#__easyblog_category` AS a';
     $query .= ' WHERE a.`published` = ' . $db->Quote('1');
     $query .= ' AND a.`default` = ' . $db->Quote('1');
     $query .= ' and a.id not in (';
     $query .= ' 	select id from `#__easyblog_category` as c';
     $query .= ' 	where not exists (';
     $query .= '			select b.category_id from `#__easyblog_category_acl` as b';
     $query .= '				where b.category_id = c.id and b.`acl_id` = ' . $db->Quote(CATEGORY_ACL_ACTION_SELECT);
     $query .= '				and b.type = ' . $db->Quote('group');
     $query .= '				and b.content_id IN (' . $gids . ')';
     $query .= '		)';
     $query .= '	and c.`private` = ' . $db->Quote(CATEGORY_PRIVACY_ACL);
     $query .= '	)';
     $query .= ' AND a.`parent_id` NOT IN (SELECT `id` FROM `#__easyblog_category` AS e WHERE e.`published` = ' . $db->Quote('0') . ' AND e.`parent_id` = ' . $db->Quote('0') . ' )';
     $query .= ' ORDER BY a.`lft` LIMIT 1';
     $db->setQuery($query);
     $result = $db->loadResult();
     return empty($result) ? '0' : $result;
 }
Exemple #3
0
 function allowAclCategory($catId = 0)
 {
     $db = EasyBlogHelper::db();
     $gid = EasyBlogHelper::getUserGids();
     $gids = '';
     if (count($gid) > 0) {
         $temp = array();
         foreach ($gid as $id) {
             $temp[] = $db->quote($id);
         }
         $gids = implode(',', $temp);
     }
     $query = 'SELECT COUNT(1) FROM `#__easyblog_category_acl`';
     $query .= ' WHERE `acl_id` = ' . $db->quote('1');
     $query .= ' AND `status` = ' . $db->quote('1');
     $query .= ' AND `category_id` = ' . $db->quote($catId);
     if ($gids) {
         $query .= ' AND `content_id` IN (' . $gids . ')';
     }
     $db->setQuery($query);
     return $db->loadResult();
 }
Exemple #4
0
 function updateTeamSubscriptionEmail($sid, $userId, $email)
 {
     $config = EasyBlogHelper::getConfig();
     $acl = EasyBlogACLHelper::getRuleSet();
     $my = JFactory::getUser();
     $subscriber = EasyBlogHelper::getTable('TeamSubscription', 'Table');
     $subscriber->load($sid);
     $teamTbl = EasyBlogHelper::getTable('Teamblog', 'Table');
     $teamTbl->load($subscriber->team_id);
     $gid = EasyBlogHelper::getUserGids($userId);
     $isMember = $teamTbl->isMember($userId, $gid);
     if ($teamTbl->allowSubscription($teamTbl->access, $userId, $isMember, $acl->rules->allow_subscription)) {
         $subscriber->user_id = $userId;
         $subscriber->email = $email;
         $subscriber->store();
     }
 }
Exemple #5
0
 function statistic()
 {
     JPluginHelper::importPlugin('easyblog');
     $dispatcher = JDispatcher::getInstance();
     $mainframe = JFactory::getApplication();
     $document = JFactory::getDocument();
     $config = EasyBlogHelper::getConfig();
     $my = JFactory::getUser();
     $acl = EasyBlogACLHelper::getRuleSet();
     $sort = JRequest::getCmd('sort', 'latest');
     $id = JRequest::getInt('id', 0);
     //setting pathway
     $pathway = $mainframe->getPathway();
     $this->setPathway(JText::_('COM_EASYBLOG_TEAMBLOG'), EasyBlogRouter::_('index.php?option=com_easyblog&view=teamblog'));
     $id = JRequest::getInt('id', 0);
     if ($id == 0) {
         echo JText::_('COM_EASYBLOG_TEAMBLOG_INVALID_ID');
         return;
     }
     // set meta tags for teamblog view
     EasyBlogHelper::setMeta($id, META_TYPE_TEAM);
     //stats type
     $statType = JRequest::getString('stat', '');
     $statId = $statType == 'tag' ? JRequest::getString('tagid', '') : JRequest::getString('catid', '');
     $statObject = null;
     if ($statType == 'category') {
         $statObject = EasyBlogHelper::getTable('Category', 'Table');
         $statObject->load($statId);
     } else {
         $statObject = EasyBlogHelper::getTable('Tag', 'Table');
         $statObject->load($statId);
     }
     $team = EasyBlogHelper::getTable('TeamBlog', 'Table');
     $team->load($id);
     $team->avatar = $team->getAvatar();
     $gid = EasyBlogHelper::getUserGids();
     $isMember = $team->isMember($my->id, $gid);
     //check if the logged in user a teammember when the team set to member only.
     if ($team->access == EBLOG_TEAMBLOG_ACCESS_MEMBER) {
         $isMember = $team->isMember($my->id, $gid);
     }
     $team->isMember = $isMember;
     // check if team description is emtpy or not. if yes, show default message.
     if (empty($team->description)) {
         $team->description = JText::_('COM_EASYBLOG_TEAMBLOG_NO_DESCRIPTION');
     }
     //add the pathway for teamblog
     $this->setPathway($team->title, '');
     $tbModel = $this->getModel('TeamBlogs');
     $model = $this->getModel('Blog');
     $blogs = $model->getBlogsBy('teamblog', $team->id);
     $blogs = EasyBlogHelper::formatBlog($blogs);
     $pagination = $model->getPagination();
     //now get the teams info
     $members = $tbModel->getTeamMembers($team->id);
     $teamMembers = EasyBlogHelper::formatTeamMembers($members);
     $isFeatured = EasyBlogHelper::isFeatured('teamblog', $team->id);
     $pageTitle = EasyBlogHelper::getPageTitle($config->get('main_title'));
     $pageNumber = $pagination->get('pages.current');
     $pageText = $pageNumber == 1 ? '' : ' - ' . JText::sprintf('COM_EASYBLOG_PAGE_NUMBER', $pageNumber);
     $document->setTitle($team->title . $pageText . $pageTitle);
     EasyBlogHelper::storeSession($team->id, 'EASYBLOG_TEAMBLOG_ID');
     //var_dump($blogs);exit;
     $tpl = new CodeThemes();
     $tpl->set('team', $team);
     $tpl->set('teamMembers', $teamMembers);
     $tpl->set('data', $blogs);
     $tpl->set('isFeatured', $isFeatured);
     $tpl->set('pagination', $pagination->getPagesLinks());
     $tpl->set('siteadmin', EasyBlogHelper::isSiteAdmin());
     $tpl->set('config', $config);
     $tpl->set('my', $my);
     $tpl->set('acl', $acl);
     $tpl->set('statType', $statType);
     $tpl->set('statObject', $statObject);
     echo $tpl->fetch('blog.teamblogs.php');
 }
 public function getCategoriesHierarchy($useLimit = true)
 {
     $db = EB::db();
     $limit = '10';
     $limitstart = $this->getState('limitstart');
     $search = JRequest::getVar('search', '');
     $gid = EasyBlogHelper::getUserGids();
     $gids = '';
     if (count($gid) > 0) {
         foreach ($gid as $id) {
             $gids .= empty($gids) ? $db->Quote($id) : ',' . $db->Quote($id);
         }
     }
     $query = 'SELECT a.*, ( SELECT COUNT(id) FROM `#__easyblog_category` WHERE `lft` < a.`lft` AND `rgt` > a.`rgt`) AS depth';
     $query .= ' FROM `#__easyblog_category` AS a';
     $query .= ' WHERE a.`published` = ' . $db->Quote('1');
     if (!empty($search)) {
         $query .= ' AND a.`title` LIKE ' . $db->Quote('%' . $search . '%');
     }
     $query .= ' and a.id not in (';
     $query .= ' select id from `#__easyblog_category` as c';
     $query .= ' where not exists (';
     $query .= '		select b.category_id from `#__easyblog_category_acl` as b';
     $query .= '			where b.category_id = c.id and b.`acl_id` = ' . $db->Quote(CATEGORY_ACL_ACTION_SELECT);
     $query .= '			and b.type = ' . $db->Quote('group');
     $query .= '			and b.content_id IN (' . $gids . ')';
     $query .= '      )';
     $query .= ' and c.`private` = ' . $db->Quote(CATEGORY_PRIVACY_ACL);
     $query .= ')';
     $query .= ' AND a.`parent_id` NOT IN (SELECT `id` FROM `#__easyblog_category` AS e WHERE e.`published` = ' . $db->Quote('0') . ' AND e.`parent_id` = ' . $db->Quote('0') . ' )';
     $query .= ' ORDER BY a.`lft`';
     if ($useLimit) {
         $this->_total = $this->_getListCount($query);
         jimport('joomla.html.pagination');
         $this->_pagination = EB::pagination($this->_total, $limitstart, $limit);
         $query .= ' LIMIT ' . $limitstart . ', ' . $limit;
     }
     $db->setQuery($query);
     $result = $db->loadObjectList();
     return $result;
 }
Exemple #7
0
 function updateTeamSubscriptionEmail($sid, $userId, $email)
 {
     $config = EasyBlogHelper::getConfig();
     $acl = EB::acl();
     $my = JFactory::getUser();
     $subscriber = EB::table('Subscriptions');
     $subscriber->load($sid);
     $teamTbl = EB::table('Teamblog');
     $teamTbl->load($subscriber->uid);
     $gid = EasyBlogHelper::getUserGids($userId);
     $isMember = $teamTbl->isMember($userId, $gid);
     if ($teamTbl->allowSubscription($teamTbl->access, $userId, $isMember, $acl->get('allow_subscription'))) {
         $subscriber->user_id = $userId;
         $subscriber->email = $email;
         $subscriber->store();
     }
 }
Exemple #8
0
 /**
  * Retrieves the filter for html tags
  */
 public static function getFilterAttributes()
 {
     $my = JFactory::getUser();
     // @rule: Check for assigned first.
     $filter = self::getFilterRule($my->id, 'assigned');
     // @rule: If assigned doesn't exist, then we revert back to the group.
     if (!$filter) {
         $gids = EasyBlogHelper::getUserGids($my->id);
         foreach ($gids as $gid) {
             $result = self::getFilterRule($gid, 'group');
             if ($result !== false) {
                 $filter = $result;
             }
         }
     }
     if ($filter) {
         $attributes = $filter->get('disallow_attributes');
         $attributes = strtolower($attributes);
         $attributes = explode(',', $attributes);
         return $attributes;
     }
     return array();
 }