Пример #1
0
 /**
  * @inheritdoc
  */
 public function disableContentContainer(ContentContainerActiveRecord $container)
 {
     parent::disableContentContainer($container);
     foreach (Category::find()->contentContainer($container)->all() as $content) {
         $content->delete();
     }
     foreach (Link::find()->contentContainer($container)->all() as $content) {
         $content->delete();
     }
 }
Пример #2
0
 public function run()
 {
     $container = $this->contentContainer;
     if (!$container->getSetting('enableWidget', 'linklist')) {
         return;
     }
     $categoryBuffer = Category::find()->contentContainer($this->contentContainer)->orderBy(['sort_order' => SORT_ASC])->all();
     $categories = array();
     $links = array();
     $render = false;
     foreach ($categoryBuffer as $category) {
         $linkBuffer = Link::find()->where(array('category_id' => $category->id))->orderBy(['sort_order' => SORT_ASC])->all();
         // categories are only displayed in the widget if they contain at least one link
         if (!empty($linkBuffer)) {
             $categories[] = $category;
             $links[$category->id] = $linkBuffer;
             $render = true;
         }
     }
     // if none of the categories contains a link, the linklist widget is not rendered.
     if ($render) {
         return $this->render('linklistPanel', array('container' => $container, 'categories' => $categories, 'links' => $links));
     }
 }
 /**
  * Action that deletes a given category.<br />
  * The request has to provide the id of the link to delete in the url parameter 'link_id'.
  * @throws HttpException 404, if the logged in User misses the rights to access this view.
  */
 public function actionDeleteLink()
 {
     $link_id = (int) Yii::$app->request->get('link_id');
     $link = Link::find()->where(array('linklist_link.id' => $link_id))->contentContainer($this->contentContainer)->one();
     if ($link == null) {
         throw new HttpException(404, Yii::t('LinklistModule.base', 'Requested link could not be found.'));
     } else {
         if ($this->accessLevel == 0 || $this->accessLevel == 1 && $link->content->created_by != Yii::$app->user->id) {
             throw new HttpException(404, Yii::t('LinklistModule.base', 'You miss the rights to delete this link!'));
         }
     }
     $link->delete();
     return $this->redirect($this->contentContainer->createUrl('/linklist/linklist/index'));
 }
 public function up()
 {
     $this->renameClass('Link', Link::className());
     $this->renameClass('Category', Category::className());
 }