ivanamat / cakephp3-aclmanager

CakePHP 3.x - Acl Manager
MIT License
27 stars 27 forks source link

AclManager/acl/permissions #1

Closed stagistabm closed 8 years ago

stagistabm commented 8 years ago

AclNode::node() - Couldn't find Aros node identified by "Array ( [Aros0.model] => Users [Aros0.foreign_key] => 6 ) "

stagistabm commented 8 years ago

Resolved change the readme table , the auto Increment must be set to 1 for groups and roles


 public function defaults() {
        $conn = ConnectionManager::get('default');
        $stmt1 = $conn->execute('TRUNCATE TABLE aros_acos');
        /*
        $info1 = $stmt1->errorInfo();
        if ($info1 != null && !empty($info1)) {
            $this->log($info1, LOG_ERR);
            $this->Flash->error($info1);
        }
        */
        $stmt2 = $conn->execute('TRUNCATE TABLE acos');
        /*
        $info2 = $stmt2->errorInfo();
        if ($info2 != null && !empty($info2)) {
            $this->log($info2, LOG_ERR);
            $this->Flash->error($info2);
        }
        */
        $stmt3 = $conn->execute('TRUNCATE TABLE aros');
        /*
        $info3 = $stmt3->errorInfo();
        if ($info3 != null && !empty($info3)) {
            $this->log($info3, LOG_ERR);
            $this->Flash->error($info3);
        }
        */
        $this->Flash->success(__("Permissions ACOs and AROs have been dropped"));

        /**
         * Build and count acos
         */
        $this->AclManager->acosBuilder();
        $acos = $this->_getAcos();
        $this->Flash->success(sprintf(__("%d ACOs have been created"), count($acos)));

        /**
         * Build and count aros
         */
        $aros = $this->AclManager->arosBuilder();
        $this->Flash->success(sprintf(__("%d AROs have been created"), $aros));

>         $this->Acl->allow(['Groups' => ['id' => 1]], 'controllers');
>         $this->Flash->success(__("Granted permissions to group with id 1"));
>         $this->Acl->allow(['Roles' => ['id' => 1]], 'controllers');
>         $this->Flash->success(__("Granted permissions to role with id 1"));

        $this->Flash->success(__("Congratulations! Everything has been restored by default!"));

        $this->redirect(["action" => "permissions"]);
    }
ivanamat commented 8 years ago

Thanx @stagistabm I forgot to change the autoincrement on upload sql, next upload i change the autoincrement.

stagistabm commented 8 years ago

great!