Exemple #1
0
 function setPermissions()
 {
     $params =& JComponentHelper::getParams('com_k2');
     $user =& JFactory::getUser();
     if ($user->guest) {
         return;
     }
     $K2User = K2HelperPermissions::getK2User($user->id);
     if (!is_object($K2User)) {
         return;
     }
     $K2UserGroup = K2HelperPermissions::getK2UserGroup($K2User->group);
     if (is_null($K2UserGroup)) {
         return;
     }
     $permissions = new JParameter($K2UserGroup->permissions);
     $auth =& JFactory::getACL();
     if (count(JPluginHelper::getPlugin('system', 'jfdatabase')) && JPluginHelper::isEnabled('system', 'jfdatabase')) {
         $params->set('frontendEditing', 0);
     }
     if ($permissions->get('categories') == 'none') {
         return;
     } else {
         if ($permissions->get('categories') == 'all') {
             if ($permissions->get('add') && $permissions->get('frontEdit') && $params->get('frontendEditing')) {
                 $auth->addACL('com_k2', 'add', 'users', $user->usertype, 'category', 'all');
                 $auth->addACL('com_k2', 'tag', 'users', $user->usertype);
                 $auth->addACL('com_k2', 'extraFields', 'users', $user->usertype);
             }
             if ($permissions->get('editOwn') && $permissions->get('frontEdit') && $params->get('frontendEditing')) {
                 $auth->addACL('com_k2', 'editOwn', 'users', $user->usertype, 'item', $user->id);
                 $auth->addACL('com_k2', 'tag', 'users', $user->usertype);
                 $auth->addACL('com_k2', 'extraFields', 'users', $user->usertype);
             }
             if ($permissions->get('editAll') && $permissions->get('frontEdit') && $params->get('frontendEditing')) {
                 $auth->addACL('com_k2', 'editAll', 'users', $user->usertype, 'category', 'all');
                 $auth->addACL('com_k2', 'tag', 'users', $user->usertype);
                 $auth->addACL('com_k2', 'extraFields', 'users', $user->usertype);
             }
             if ($permissions->get('publish') && $permissions->get('frontEdit') && $params->get('frontendEditing')) {
                 $auth->addACL('com_k2', 'publish', 'users', $user->usertype, 'category', 'all');
             }
             if ($permissions->get('comment')) {
                 $auth->addACL('com_k2', 'comment', 'users', $user->usertype, 'category', 'all');
             }
         } else {
             $selectedCategories = $permissions->get('categories', NULL);
             if (is_string($selectedCategories)) {
                 $searchIDs[] = $selectedCategories;
             } else {
                 $searchIDs = $selectedCategories;
             }
             if ($permissions->get('inheritance')) {
                 foreach ($searchIDs as $catid) {
                     $childCategories = K2HelperPermissions::getCategoryChilds($catid);
                     $childIDs = array();
                     foreach ($childCategories as $child) {
                         $childIDs[] = $child;
                     }
                 }
                 $allIDs = @array_merge($searchIDs, $childIDs);
                 $categories = @array_unique($allIDs);
             } else {
                 $categories = $searchIDs;
             }
             if (is_array($categories) && count($categories)) {
                 foreach ($categories as $category) {
                     if ($permissions->get('add') && $permissions->get('frontEdit') && $params->get('frontendEditing')) {
                         $auth->addACL('com_k2', 'add', 'users', $user->usertype, 'category', $category);
                         $auth->addACL('com_k2', 'tag', 'users', $user->usertype);
                         $auth->addACL('com_k2', 'extraFields', 'users', $user->usertype);
                     }
                     if ($permissions->get('editOwn') && $permissions->get('frontEdit') && $params->get('frontendEditing')) {
                         $auth->addACL('com_k2', 'editOwn', 'users', $user->usertype, 'item', $user->id . '|' . $category);
                         $auth->addACL('com_k2', 'tag', 'users', $user->usertype);
                         $auth->addACL('com_k2', 'extraFields', 'users', $user->usertype);
                     }
                     if ($permissions->get('editAll') && $permissions->get('frontEdit') && $params->get('frontendEditing')) {
                         $auth->addACL('com_k2', 'editAll', 'users', $user->usertype, 'category', $category);
                         $auth->addACL('com_k2', 'tag', 'users', $user->usertype);
                         $auth->addACL('com_k2', 'extraFields', 'users', $user->usertype);
                     }
                     if ($permissions->get('publish') && $permissions->get('frontEdit') && $params->get('frontendEditing')) {
                         $auth->addACL('com_k2', 'publish', 'users', $user->usertype, 'category', $category);
                     }
                     if ($permissions->get('comment')) {
                         $auth->addACL('com_k2', 'comment', 'users', $user->usertype, 'category', $category);
                     }
                 }
             }
         }
     }
     return;
 }
Exemple #2
0
 public static function setPermissions()
 {
     $params = K2HelperUtilities::getParams('com_k2');
     $user = JFactory::getUser();
     if ($user->guest) {
         return;
     }
     $K2User = K2HelperPermissions::getK2User($user->id);
     if (!is_object($K2User)) {
         return;
     }
     $K2UserGroup = K2HelperPermissions::getK2UserGroup($K2User->group);
     if (is_null($K2UserGroup)) {
         return;
     }
     $K2Permissions = K2Permissions::getInstance();
     $permissions = K2_JVERSION == '15' ? new JParameter($K2UserGroup->permissions) : new JRegistry($K2UserGroup->permissions);
     $K2Permissions->permissions = $permissions;
     if ($permissions->get('categories') == 'none') {
         return;
     } else {
         if ($permissions->get('categories') == 'all') {
             if ($permissions->get('add') && $permissions->get('frontEdit') && $params->get('frontendEditing')) {
                 $K2Permissions->actions[] = 'add.category.all';
                 $K2Permissions->actions[] = 'tag';
                 $K2Permissions->actions[] = 'extraFields';
             }
             if ($permissions->get('editOwn') && $permissions->get('frontEdit') && $params->get('frontendEditing')) {
                 $K2Permissions->actions[] = 'editOwn.item.' . $user->id;
                 $K2Permissions->actions[] = 'tag';
                 $K2Permissions->actions[] = 'extraFields';
             }
             if ($permissions->get('editAll') && $permissions->get('frontEdit') && $params->get('frontendEditing')) {
                 $K2Permissions->actions[] = 'editAll.category.all';
                 $K2Permissions->actions[] = 'tag';
                 $K2Permissions->actions[] = 'extraFields';
             }
             if ($permissions->get('publish') && $permissions->get('frontEdit') && $params->get('frontendEditing')) {
                 $K2Permissions->actions[] = 'publish.category.all';
             }
             if ($permissions->get('comment')) {
                 $K2Permissions->actions[] = 'comment.category.all';
             }
             if ($permissions->get('editPublished')) {
                 $K2Permissions->actions[] = 'editPublished.category.all';
             }
         } else {
             $selectedCategories = $permissions->get('categories', NULL);
             if (is_string($selectedCategories)) {
                 $searchIDs[] = $selectedCategories;
             } else {
                 $searchIDs = $selectedCategories;
             }
             if ($permissions->get('inheritance')) {
                 $model = K2Model::getInstance('Itemlist', 'K2Model');
                 $categories = $model->getCategoryTree($searchIDs);
             } else {
                 $categories = $searchIDs;
             }
             if (is_array($categories) && count($categories)) {
                 foreach ($categories as $category) {
                     if ($permissions->get('add') && $permissions->get('frontEdit') && $params->get('frontendEditing')) {
                         $K2Permissions->actions[] = 'add.category.' . $category;
                         $K2Permissions->actions[] = 'tag';
                         $K2Permissions->actions[] = 'extraFields';
                     }
                     if ($permissions->get('editOwn') && $permissions->get('frontEdit') && $params->get('frontendEditing')) {
                         $K2Permissions->actions[] = 'editOwn.item.' . $user->id . '.' . $category;
                         $K2Permissions->actions[] = 'tag';
                         $K2Permissions->actions[] = 'extraFields';
                     }
                     if ($permissions->get('editAll') && $permissions->get('frontEdit') && $params->get('frontendEditing')) {
                         $K2Permissions->actions[] = 'editAll.category.' . $category;
                         $K2Permissions->actions[] = 'tag';
                         $K2Permissions->actions[] = 'extraFields';
                     }
                     if ($permissions->get('publish') && $permissions->get('frontEdit') && $params->get('frontendEditing')) {
                         $K2Permissions->actions[] = 'publish.category.' . $category;
                     }
                     if ($permissions->get('comment')) {
                         $K2Permissions->actions[] = 'comment.category.' . $category;
                     }
                     if ($permissions->get('editPublished')) {
                         $K2Permissions->actions[] = 'editPublished.category.' . $category;
                     }
                 }
             }
         }
     }
     return;
 }
Exemple #3
0
 function setPermissions()
 {
     $params =& K2HelperUtilities::getParams('com_k2');
     $user =& JFactory::getUser();
     if ($user->guest) {
         return;
     }
     $K2User = K2HelperPermissions::getK2User($user->id);
     if (!is_object($K2User)) {
         return;
     }
     $K2UserGroup = K2HelperPermissions::getK2UserGroup($K2User->group);
     if (is_null($K2UserGroup)) {
         return;
     }
     $K2Permissions =& K2Permissions::getInstance();
     $permissions = new JParameter($K2UserGroup->permissions);
     $K2Permissions->permissions = $permissions;
     if ($permissions->get('categories') == 'none') {
         return;
     } else {
         if ($permissions->get('categories') == 'all') {
             if ($permissions->get('add') && $permissions->get('frontEdit') && $params->get('frontendEditing')) {
                 $K2Permissions->actions[] = 'add.category.all';
                 $K2Permissions->actions[] = 'tag';
                 $K2Permissions->actions[] = 'extraFields';
             }
             if ($permissions->get('editOwn') && $permissions->get('frontEdit') && $params->get('frontendEditing')) {
                 $K2Permissions->actions[] = 'editOwn.item.' . $user->id;
                 $K2Permissions->actions[] = 'tag';
                 $K2Permissions->actions[] = 'extraFields';
             }
             if ($permissions->get('editAll') && $permissions->get('frontEdit') && $params->get('frontendEditing')) {
                 $K2Permissions->actions[] = 'editAll.category.all';
                 $K2Permissions->actions[] = 'tag';
                 $K2Permissions->actions[] = 'extraFields';
             }
             if ($permissions->get('publish') && $permissions->get('frontEdit') && $params->get('frontendEditing')) {
                 $K2Permissions->actions[] = 'publish.category.all';
             }
             if ($permissions->get('comment')) {
                 $K2Permissions->actions[] = 'comment.category.all';
             }
         } else {
             $selectedCategories = $permissions->get('categories', NULL);
             if (is_string($selectedCategories)) {
                 $searchIDs[] = $selectedCategories;
             } else {
                 $searchIDs = $selectedCategories;
             }
             if ($permissions->get('inheritance')) {
                 JLoader::register('K2ModelItemlist', JPATH_SITE . DS . 'components' . DS . 'com_k2' . DS . 'models' . DS . 'itemlist.php');
                 $categories = K2ModelItemlist::getCategoryTree($searchIDs);
             } else {
                 $categories = $searchIDs;
             }
             if (is_array($categories) && count($categories)) {
                 foreach ($categories as $category) {
                     if ($permissions->get('add') && $permissions->get('frontEdit') && $params->get('frontendEditing')) {
                         $K2Permissions->actions[] = 'add.category.' . $category;
                         $K2Permissions->actions[] = 'tag';
                         $K2Permissions->actions[] = 'extraFields';
                     }
                     if ($permissions->get('editOwn') && $permissions->get('frontEdit') && $params->get('frontendEditing')) {
                         $K2Permissions->actions[] = 'editOwn.item.' . $user->id . '.' . $category;
                         $K2Permissions->actions[] = 'tag';
                         $K2Permissions->actions[] = 'extraFields';
                     }
                     if ($permissions->get('editAll') && $permissions->get('frontEdit') && $params->get('frontendEditing')) {
                         $K2Permissions->actions[] = 'editAll.category.' . $category;
                         $K2Permissions->actions[] = 'tag';
                         $K2Permissions->actions[] = 'extraFields';
                     }
                     if ($permissions->get('publish') && $permissions->get('frontEdit') && $params->get('frontendEditing')) {
                         $K2Permissions->actions[] = 'publish.category.' . $category;
                     }
                     if ($permissions->get('comment')) {
                         $K2Permissions->actions[] = 'comment.category.' . $category;
                     }
                 }
             }
         }
     }
     return;
 }