Exemple #1
0
 /**
  * Authorise list of userids to topic or category.
  *
  * @param   mixed	$topic		Category or topic.
  * @param   array	$userids	list(allow, deny).
  * @return array
  */
 public function authoriseUsers(KunenaDatabaseObject $topic, array &$userids)
 {
     if (empty($userids)) {
         return array(array(), array());
     }
     $category = $topic->getCategory();
     $userlist = implode(',', $userids);
     $db = JFactory::getDBO();
     $query = "SELECT c.id FROM #__kunena_categories AS c\n\t\t\tINNER JOIN #__community_groups_members AS g ON c.accesstype='jomsocial' AND c.access=g.groupid\n\t\t\tWHERE c.id={$category->id} AND g.approved=1 AND g.memberid IN ({$userlist})";
     $db->setQuery($query);
     $allow = (array) $db->loadColumn();
     $deny = array();
     KunenaError::checkDatabaseError();
     return array($allow, $deny);
 }
Exemple #2
0
 /**
  * Authorise list of userids to topic or category.
  *
  * @param   mixed $topic   Category or topic.
  * @param   array $userids list(allow, deny).
  *
  * @return array
  */
 public function authoriseUsers(KunenaDatabaseObject $topic, array &$userids)
 {
     $allow = $deny = array();
     if (empty($userids)) {
         return array($allow, $deny);
     }
     $category = $topic->getCategory();
     if ($category->accesstype == 'joomla.level') {
         // Check against Joomla access levels
         $groups = $this->getGroupsByViewLevel($category->access);
         $allow = $this->getUsersByGroup($groups, true, $userids);
     } elseif ($category->accesstype == 'joomla.group') {
         if ($category->pub_access <= 0) {
             return array($allow, $deny);
         }
         // Check against Joomla user groups
         $public = $this->getUsersByGroup($category->pub_access, $category->pub_recurse, $userids);
         $admin = $category->admin_access && $category->admin_access != $category->pub_access ? $this->getUsersByGroup($category->admin_access, $category->admin_recurse, $userids) : array();
         $allow = array_merge($public, $admin);
     }
     return array($allow, $deny);
 }
Exemple #3
0
 /**
  * Authorise list of userids to topic or category.
  *
  * @param   mixed $topic   Category or topic.
  * @param   array $userids list(allow, deny).
  *
  * @return array
  */
 public function authoriseUsers(KunenaDatabaseObject $topic, array &$userids)
 {
     $allow = $deny = array();
     if (empty($userids)) {
         return array($allow, $deny);
     }
     $category = $topic->getCategory();
     if ($category->accesstype == 'communitybuilder') {
         $params = array('category' => $category, 'topic' => $topic, 'userids' => $userids, 'allow' => &$allow, 'deny' => &$deny);
         KunenaIntegrationComprofiler::trigger('authoriseUsers', $params);
     }
     return array($allow, $deny);
 }
Exemple #4
0
 /**
  * Authorise list of userids to topic or category.
  *
  * @param	mixed	Category or topic.
  * @param	array	list(allow, deny).
  */
 public function authoriseUsers(KunenaDatabaseObject $topic, array &$userids)
 {
     if (empty($userids)) {
         return;
     }
     $userlist = implode(',', $userids);
     $db = JFactory::getDBO();
     $query = new KunenaDatabaseQuery();
     $query->select('u.id');
     $query->from('#__users AS u');
     $query->where("u.block=0");
     $query->where("u.id IN ({$userlist})");
     $category = $topic->getCategory();
     if ($category->accesstype == 'joomla.level') {
         // Check against Joomla access level
         if ($category->access > 1) {
             // Special users: not in registered group
             $query->where("u.gid!=18");
         }
     } elseif ($category->accesstype == 'joomla.group') {
         // All users are allowed to see Public (0) or All Registered (-1) categories
         if ($category->pub_access <= 0) {
             return array($userids, array());
         }
         // Check against Joomla user groups
         $public = $this->_get_groups($category->pub_access, $category->pub_recurse);
         // Ignore admin_access if pub_access has the same group
         $admin = $category->admin_access != $category->pub_access ? $this->_get_groups($category->admin_access, $category->admin_recurse) : array();
         $groups = implode(',', array_unique(array_merge($public, $admin)));
         if ($groups) {
             $query->join('INNER', "#__core_acl_aro AS a ON u.id=a.value AND a.section_value='users'");
             $query->join('INNER', "#__core_acl_groups_aro_map AS g ON g.aro_id=a.id");
             $query->where("g.group_id IN ({$groups})");
         }
     } else {
         return;
     }
     $db->setQuery($query);
     $allow = (array) $db->loadResultArray();
     $deny = array();
     KunenaError::checkDatabaseError();
     return array($allow, $deny);
 }