Example #1
0
 private function processCreateDirectory($objCategory)
 {
     if (empty($_POST['downloads_category_name'])) {
         return;
     } else {
         $name = contrexx_stripslashes($_POST['downloads_category_name']);
     }
     \Cx\Core\Csrf\Controller\Csrf::check_code();
     // check for sufficient permissiosn
     if ($objCategory->getAddSubcategoriesAccessId() && !\Permission::checkAccess($objCategory->getAddSubcategoriesAccessId(), 'dynamic', true) && $objCategory->getOwnerId() != $this->userId) {
         return;
     }
     // parse name and description attributres
     $arrLanguageIds = array_keys(\FWLanguage::getLanguageArray());
     foreach ($arrLanguageIds as $langId) {
         $arrNames[$langId] = $name;
         $arrDescriptions[$langId] = '';
     }
     $objSubcategory = new Category();
     $objSubcategory->setParentId($objCategory->getId());
     $objSubcategory->setActiveStatus(true);
     $objSubcategory->setVisibility($objCategory->getVisibility());
     $objSubcategory->setNames($arrNames);
     $objSubcategory->setDescriptions($arrDescriptions);
     $objSubcategory->setPermissions(array('read' => array('protected' => (bool) $objCategory->getAddSubcategoriesAccessId(), 'groups' => array()), 'add_subcategories' => array('protected' => (bool) $objCategory->getAddSubcategoriesAccessId(), 'groups' => array()), 'manage_subcategories' => array('protected' => (bool) $objCategory->getAddSubcategoriesAccessId(), 'groups' => array()), 'add_files' => array('protected' => (bool) $objCategory->getAddSubcategoriesAccessId(), 'groups' => array()), 'manage_files' => array('protected' => (bool) $objCategory->getAddSubcategoriesAccessId(), 'groups' => array())));
     //
     //            foreach ($this->arrPermissionTypes as $protectionType) {
     //                $arrCategoryPermissions[$protectionType]['protected'] = isset($_POST['downloads_category_'.$protectionType]) && $_POST['downloads_category_'.$protectionType];
     //                $arrCategoryPermissions[$protectionType]['groups'] = !empty($_POST['downloads_category_'.$protectionType.'_associated_groups']) ? array_map('intval', $_POST['downloads_category_'.$protectionType.'_associated_groups']) : array();
     //            }
     //
     //            $objCategory->setPermissionsRecursive(!empty($_POST['downloads_category_apply_recursive']));
     //            $objCategory->setPermissions($arrCategoryPermissions);
     if (!$objSubcategory->store()) {
         $this->arrStatusMsg['error'] = array_merge($this->arrStatusMsg['error'], $objSubcategory->getErrorMsg());
     }
 }
 function getAllCategory()
 {
     $key = 'category';
     $collection = CacheManager::get($key, TRUE);
     if ($collection) {
         return $collection;
     }
     $collection = new Collection();
     $this->connect();
     $result = $this->conn->query("CALL sp_get_all_category()");
     if ($result) {
         //$row = $result->fetch_assoc();
         while ($obj = $result->fetch_object()) {
             $category = new Category();
             $category->setId($obj->Category_id);
             $category->setSubject($obj->Subject);
             $category->setParentId($obj->Parent_id);
             $category->setSectionId($obj->Section_id);
             $category->setParentSubject($obj->Parent_subject);
             $category->setSectionName($obj->Section_name);
             $collection->addItem($category, $obj->Category_id);
         }
         $result->close();
         // for fetch_object()
     }
     //$result->free_result(); // for fetch_assoc()
     $this->close();
     CacheManager::set($key, $collection, TRUE);
     return $collection;
 }