/** * edit categories for the currently logged in user */ public function edituser() { if (!SecurityUtil::checkPermission('Categories::category', '::', ACCESS_EDIT)) { return LogUtil::registerPermissionError(); } if (!UserUtil::isLoggedIn()) { return LogUtil::registerError($this->__('Error! Editing mode for user-owned categories is only available to users who have logged-in.')); } $allowUserEdit = $this->getVar('allowusercatedit', 0); if (!$allowUserEdit) { return LogUtil::registerError($this->__('Error! User-owned category editing has not been enabled. This feature can be enabled by the site administrator.')); } $userRoot = $this->getVar('userrootcat', 0); if (!$userRoot) { return LogUtil::registerError($this->__('Error! Could not determine the user root node.')); } $userRootCat = CategoryUtil::getCategoryByPath($userRoot); if (!$userRoot) { return LogUtil::registerError($this->__f('Error! The user root node seems to point towards an invalid category: %s.', $userRoot)); } if ($userRootCat == 1) { return LogUtil::registerError($this->__("Error! The root directory cannot be modified in 'user' mode")); } $userCatName = $this->getusercategoryname(); if (!$userCatName) { return LogUtil::registerError($this->__('Error! Cannot determine user category root node name.')); } $thisUserRootCatPath = $userRoot . '/' . $userCatName; $thisUserRootCat = CategoryUtil::getCategoryByPath($thisUserRootCatPath); $dr = null; if (!$thisUserRootCat) { $autoCreate = $this->getVar('autocreateusercat', 0); if (!$autoCreate) { return LogUtil::registerError($this->__("Error! The user root category node for this user does not exist, and the automatic creation flag (autocreate) has not been set.")); } $installer = new Categories_Installer(ServiceUtil::getManager()); $cat = array('id' => '', 'parent_id' => $userRootCat['id'], 'name' => $userCatName, 'display_name' => unserialize($installer->makeDisplayName($userCatName)), 'display_desc' => unserialize($installer->makeDisplayDesc()), 'security_domain' => 'Categories::', 'path' => $thisUserRootCatPath, 'status' => 'A'); $obj = new Categories_DBObject_Category(); $obj->setData($cat); $obj->insert(); // since the original insert can't construct the ipath (since // the insert id is not known yet) we update the object here $obj->update(); $dr = $obj->getID(); $autoCreateDefaultUserCat = $this->getVar('autocreateuserdefaultcat', 0); if ($autoCreateDefaultUserCat) { $userdefaultcatname = $this->getVar('userdefaultcatname', $this->__('Default')); $cat = array('id' => '', 'parent_id' => $dr, 'name' => $userdefaultcatname, 'display_name' => unserialize($installer->makeDisplayName($userdefaultcatname)), 'display_desc' => unserialize($installer->makeDisplayDesc()), 'security_domain' => 'Categories::', 'path' => $thisUserRootCatPath . '/' . $userdefaultcatname, 'status' => 'A'); $obj->setData($cat); $obj->insert(); // since the original insert can't construct the ipath (since // the insert id is not known yet) we update the object here $obj->update(); } } else { $dr = $thisUserRootCat['id']; } $url = ModUtil::url('Categories', 'user', 'edit', array('dr' => $dr)); $this->redirect($url); }