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()); } }
/** * Set the access level of an article * * @param integer $access Access level to set * @return void */ public function accessTask($access = 0) { // Incoming $id = Request::getInt('id', 0); // Make sure we have an ID to work with if (!$id) { App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller), Lang::txt('COM_STOREFRONT_NO_ID'), 'error'); return; } // Load the article $row = new Category($id); $row->set('access', $access); // Check and store the changes if (!$row->store(true)) { App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller), $row->getError(), 'error'); return; } App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller)); }
public function testAssociateOneToManyPrimaryKey() { $category = new Category(3); $person = new Model_Person(); $person->setName('Bob'); $person->store(); $person_2 = new Model_Person(); $person_2->setName("Barbara"); $person_2->store(); $person_ids = array($person->getPersonId(), $person_2->getPersonId()); $category->associateModel_People($person_ids); $category->store(); $db_person_ids = array_map('current', self::$db->query('SELECT person_id FROM people WHERE category_id = 3')->fetchAllRows()); self::$db->query("DELETE FROM people WHERE person_id > 4"); $this->assertEquals($person_ids, $db_person_ids); }
<?php $s = fRequest::encode('id_section', 'integer'); if ($s != 2) { $category = new Category(); $parent_id = fRequest::encode('parent_id', 'integer'); if ($parent_id != 0) { $category->setId_parent($parent_id); } else { $category->setId_parent(0); } $category->setId_section(fRequest::encode('id_section', 'integer')); $category->setName(fRequest::encode('name', 'string')); try { $category->store(); } catch (Exception $e) { exit("Ha ocurrido un error."); } } else { $category = new EconomicUnitCategory(); $category->setEconomicUnitCategoryName(fRequest::encode('name', 'string')); try { $category->store(); } catch (Exception $e) { die($e->getMessage()); } } exit("1");