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());
     }
 }