Subversion Repositories php_users

Rev

Rev 16 | Rev 18 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 16 Rev 17
Line 49... Line 49...
49
class UsersPermissions extends Users {
49
class UsersPermissions extends Users {
50
   
50
   
51
   public function __construct( $customFields = array() ) {
51
   public function __construct( $customFields = array() ) {
52
      parent::__construct( $customFields );
52
      parent::__construct( $customFields );
53
   } // constructor
53
   } // constructor
-
 
54
   
-
 
55
   
-
 
56
   protected function validate( $username, $password, $connection ) {
-
 
57
      if ( parent::validate( $username, $password, $connection ) ) {
-
 
58
         $this->data['permissions'] = $connection->getPermissions( $this->data['id'] );
-
 
59
      }
-
 
60
   }
-
 
61
   
-
 
62
   public function editScreen( $connection ) {
-
 
63
      $divDef = "<div class='category'>\n";
-
 
64
      $return = array();
-
 
65
      $return[] = parent::editScreen( $connection );
-
 
66
      if ( $this->isAdmin() ) {
-
 
67
         $values = $connection->getFullPermissions( $this->workingOn['id'] );
-
 
68
         $category = array();
-
 
69
         foreach ( $values as $thisEntry ) {
-
 
70
            $field = $thisEntry['permission'];
-
 
71
            $temp = sprintf( $this->configuration['html input fields']['boolean'], 
-
 
72
                     $thisEntry['description'],
-
 
73
                     $this->configuration['input prefix'] . $field, 
-
 
74
                     'Place a check here to give the user permission',
-
 
75
                     '',
-
 
76
                     $field
-
 
77
                  );
-
 
78
            
-
 
79
            $category[$thisEntry['category']][] = preg_replace( "/~~$field~~/", $thisEntry['value'] ? 'checked' : '', $temp );
-
 
80
         }
-
 
81
         
-
 
82
         foreach ( $category as $name => $entries ) {
-
 
83
            $return[] = $divDef . "<h3>$name</h3>" . implode( "\n", $entries ) . "</div>";
-
 
84
         }
-
 
85
      }
-
 
86
      return implode( "\n", $return );
-
 
87
   }
-
 
88
   
-
 
89
   protected function addEdit( $connection ) {
-
 
90
      $return = parent::addEdit( $connection );
-
 
91
      
-
 
92
      return $return;
-
 
93
      
-
 
94
      $data = array();
-
 
95
      // now we process all of the permissions
-
 
96
      if ( $return != 'Error' ) {
-
 
97
         foreach ( $this->workingOn['permissions'] as $name => $value ) {
-
 
98
            $htmlFieldName = $this->configuration['input prefix'] . $name;
-
 
99
            if ( $this->workingOn['id'] == -1 || ( isset( $_REQUEST[$htmlFieldName] ) != $this->workingOn[$name] ) ) {
-
 
100
               $data[$name] = isset( $_REQUEST[$htmlFieldName] ) ? 1 : 0;
-
 
101
            }
-
 
102
         } // foreach
-
 
103
         $connection->updatePermissions( $this->workingOn['id'],$data );
-
 
104
      } // if not an error
-
 
105
      return $return;
-
 
106
   } // addEdit
54
 
107
 
55
}
108
}
56
 
109
 
57
?>
110
?>