/** * On disabling this module on a space, delete all module -> user related content/data. * Method stub is provided by "UserModuleBehavior" * * @param User $user */ public function disableUserModule(User $user) { foreach (LibraryDocument::model()->contentContainer($user)->findAll() as $content) { $content->delete(); } foreach (LibraryLink::model()->contentContainer($user)->findAll() as $content) { $content->delete(); } foreach (LibraryCategory::model()->contentContainer($user)->findAll() as $content) { $content->delete(); } }
/** * Action that renders the view to add a link.<br /> * The request has to provide the id of the category the link should be created in, in the url parameter 'category_id'.<br /> * @see views/library/editCategory.php * @throws CHttpException 404, if the logged in User misses the rights to access this view. */ public function actionAddLink() { $this->checkContainerAccess(); $category_id = (int) Yii::app()->request->getQuery('category_id'); $category = LibraryCategory::model()->findByAttributes(array('id' => $category_id)); $publicCategory = $category->content->isPublic(); $isCreated = false; // access level 0 may neither create nor edit if ($this->accessLevel == 0) { throw new CHttpException(404, Yii::t('LibraryModule.exception', 'You miss the rights to add links!')); } else { $link = new LibraryLink(); if (LibraryCategory::model()->findByAttributes(array('id' => $category_id)) == null) { throw new CHttpException(404, Yii::t('LibraryModule.exception', 'The category you want to create your link in could not be found!')); } if ($this->accessLevel == 1 && $category->content->isPublic()) { throw new CHttpException(404, Yii::t('LibraryModule.exception', 'You miss the rights to add links to public categories!')); } $link->category_id = $category_id; $isCreated = true; } // if form content is sent back, validate and save if (isset($_POST['LibraryLink'])) { $_POST = Yii::app()->input->stripClean($_POST); $link->attributes = $_POST['LibraryLink']; $link->content->container = $this->contentContainer; $link->content->visibility = $category->content->visibility; if ($link->validate()) { $link->save(); $this->redirect(Yii::app()->createUrl('library/library/showlibrary', array($this->guidParamName => $this->contentContainer->guid))); } } // Render link edit form $this->render('editLink', array($this->guidParamName => $this->contentContainer->guid, 'link' => $link, 'isCreated' => $isCreated)); }