コード例 #1
0
 /**
  * Load the member variables from an array
  * The array can contain the keys 'id', 'parent', 'fields'.  The later of which
  * is an array indexed by field names and which contains the values of the field
  * 
  * @param array $post The post object is passed as a reference
  */
 public function setFromPost($post, $populate_on_set_id = false)
 {
     if (array_key_exists('fields', $post) || is_array($post['fields'])) {
         $fields = $post['fields'];
         if (array_key_exists('username', $fields)) {
             $this->user->username = $fields['username'];
         }
         if (array_key_exists('role', $fields)) {
             list($junk, $role) = array_pad(explode('|', $fields['role'], 2), 2, '');
             $this->user->role = $role;
             if (empty($role)) {
                 $post['fields']['role'] = 'role|';
             }
         }
         foreach ($this->allowedDetails as $detail) {
             if (!array_key_exists($detail, $fields)) {
                 continue;
             }
             $this->user->{$detail} = $fields[$detail];
         }
     }
     parent::setFromPost($post, $populate_on_set_id);
 }