original_string: 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']);
          }
      }
code: 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']);
          }
      }
code_tokens: 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' ] ) ; } }
docstring: Perform some actions to the data before it is saved to the database
docstring_tokens: Perform some actions to the data before it is saved to the database