/** * Quick add project category * * @param void * @return null */ function quick_add_category() { if ($this->request->isSubmitted() && $this->request->isAsyncCall()) { $this->active_category = new Category(); $this->active_category->setAttributes($this->request->post('category')); $this->active_category->setModule($this->active_module); $this->active_category->setController($this); $this->active_category->setProjectId($this->active_project->getId()); $this->active_category->setCreatedBy($this->logged_user); $this->active_category->setState(STATE_VISIBLE); $this->active_category->setVisibility(VISIBILITY_NORMAL); $save = $this->active_category->save(); if ($save && !is_error($save)) { print $this->active_category->getId(); die; } else { $this->serveData($save); } // if } else { $this->httpError(HTTP_ERR_BAD_REQUEST); } // if }
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()); } }