/** * * @desc see renderTree() and displayErrors() of this Class * @param object $model RbacController * @param string $context method of item renderer */ public function __construct($model, $context) { $this->colUsername = Yii::app()->controller->module->columnUsername; $this->colUserid = Yii::app()->controller->module->columnUserid; $this->_model = $model; $this->treeFormat = array('groupIn' => '<table id="rbacFolder" ><tr><td>' . "\n", 'groupOut' => '</td></tr></table>' . "\n", 'itemIn' => '<tr><td id="rbacFolder">' . "\n", 'itemOut' => '</td></tr>' . "\n"); $this->_context = $context; $treeBuilder = new RBACTree(); $this->_rbacTree = $treeBuilder->getItemTree(); }
/** * * @desc */ public function actionMove() { $this->checkAccess('RbacViewer', true); if (!empty($_POST)) { $this->checkAccess('RbacEditor', true); $from = isset($_POST['moveFromItem']) ? $_POST['moveFromItem'] : null; $to = isset($_POST['moveToItem']) ? $_POST['moveToItem'] : null; // check only if parent is protected if (in_array($to, $this->protectedItems)) { if (in_array($from, $this->protectedItems)) { $this->messageErrors[] = "Sorry, Item is protected by Controller"; $this->actionIndex(); } } if (!$from || !$to || $from == $to) { $this->messageErrors[] = "Please select Parent- and Childitem and care that they are not same."; $this->actionIndex(); } // default validate $model = new AuthItemChild(); $model->attributes = array('child' => $from, 'parent' => $to); if (!$model->validate()) { $this->messageErrors[] = "Post validation Error. Please mail Siteadmin if this Error returns."; $this->actionIndex(); } // check if branch already exists if ($model->findByAttributes(array('child' => $from, 'parent' => $to)) !== null) { $this->messageErrors[] = "Create Brunch Error: Brunch already exists."; $this->actionIndex(); } // Items exist? $model = new AuthItem(); if (!count($model->findByAttributes(array('name' => $from))) || !count($model->findByAttributes(array('name' => $to)))) { $this->messageErrors[] = "Check Items exists Error. Please mail Siteadmin if this Error returns."; $this->actionIndex(); } // make recursioncheck and move Items $model = new RBACTree(); $model->moveFrom = $from; $model->moveTo = $to; if ($model->checkRecursion()) { $model->moveItem(); $this->messageSuccess[] = "Item {$from} successfull moved to {$to}."; } else { $this->messageErrors[] = "Can't move Selection cause that will produce a Recursion.\n\t\t\t\t<br>If you can't see producing a Recursion, it may help to eject Item before moving it."; $this->actionIndex(); } } $this->actionIndex(); }