protected function beforeSave()
    {
        if (isset($this->formData['grl_parents']) && (! is_array($this->formData['grl_parents']))) {
            $this->formData['grl_parents'] = explode(',', $this->formData['grl_parents']);
        }
        if (isset($this->formData['grl_parents']) && is_array($this->formData['grl_parents'])) {
            $this->formData['grl_parents'] = implode(
                    ',',
                    \Gems_Roles::getInstance()->translateToRoleIds($this->formData['grl_parents'])
                    );
        }

        //Always add nologin privilege to 'nologin' role
        if (isset($this->formData['grl_name']) && $this->formData['grl_name'] == 'nologin') {
            $this->formData['grl_privileges'][] = 'pr.nologin';
        } elseif (isset($this->formData['grl_name']) && $this->formData['grl_name'] !== 'nologin') {
            //Assign islogin to all other roles
            $this->formData['grl_privileges'][] = 'pr.islogin';
        }

        if (isset($this->formData['grl_privileges'])) {
            $this->formData['grl_privileges'] = implode(',', $this->formData['grl_privileges']);
        }
    }
protected function beforeSave()
    {
        if (isset($this->formData['grl_parents']) && (! is_array($this->formData['grl_parents']))) {
            $this->formData['grl_parents'] = explode(',', $this->formData['grl_parents']);
        }
        if (isset($this->formData['grl_parents']) && is_array($this->formData['grl_parents'])) {
            $this->formData['grl_parents'] = implode(
                    ',',
                    \Gems_Roles::getInstance()->translateToRoleIds($this->formData['grl_parents'])
                    );
        }

        //Always add nologin privilege to 'nologin' role
        if (isset($this->formData['grl_name']) && $this->formData['grl_name'] == 'nologin') {
            $this->formData['grl_privileges'][] = 'pr.nologin';
        } elseif (isset($this->formData['grl_name']) && $this->formData['grl_name'] !== 'nologin') {
            //Assign islogin to all other roles
            $this->formData['grl_privileges'][] = 'pr.islogin';
        }

        if (isset($this->formData['grl_privileges'])) {
            $this->formData['grl_privileges'] = implode(',', $this->formData['grl_privileges']);
        }
    }
protected function beforeSave ( ) { if ( isset ( $ this -> formData [ 'grl_parents' ] ) && ( ! is_array ( $ this -> formData [ 'grl_parents' ] ) ) ) { $ this -> formData [ 'grl_parents' ] = explode ( ',' , $ this -> formData [ 'grl_parents' ] ) ; } if ( isset ( $ this -> formData [ 'grl_parents' ] ) && is_array ( $ this -> formData [ 'grl_parents' ] ) ) { $ this -> formData [ 'grl_parents' ] = implode ( ',' , \ Gems_Roles :: getInstance ( ) -> translateToRoleIds ( $ this -> formData [ 'grl_parents' ] ) ) ; } //Always add nologin privilege to 'nologin' role if ( isset ( $ this -> formData [ 'grl_name' ] ) && $ this -> formData [ 'grl_name' ] == 'nologin' ) { $ this -> formData [ 'grl_privileges' ] [ ] = 'pr.nologin' ; } elseif ( isset ( $ this -> formData [ 'grl_name' ] ) && $ this -> formData [ 'grl_name' ] !== 'nologin' ) { //Assign islogin to all other roles $ this -> formData [ 'grl_privileges' ] [ ] = 'pr.islogin' ; } if ( isset ( $ this -> formData [ 'grl_privileges' ] ) ) { $ this -> formData [ 'grl_privileges' ] = implode ( ',' , $ this -> formData [ 'grl_privileges' ] ) ; } }
Perform some actions to the data before it is saved to the database
Perform some actions to the data before it is saved to the database