Changeset 2820

Show
Ignore:
Timestamp:
11/17/08 04:39:47 (8 weeks ago)
Author:
rickc
Message:

We neglected to add the admin group to a new installation when we added the admin group on updates to r2264.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/htdocs/system/classes/installhandler.php

    r2814 r2820  
    418418        } 
    419419 
    420         // Let's setup the admin user now. 
     420        // Let's setup the admin user and group now. 
    421421        // But first, let's make sure that no users exist 
    422422        $all_users = Users::get_all(); 
    423423        if ( count( $all_users ) < 1 ) { 
    424             if (! $this->create_admin_user()) { 
     424            $user = $this->create_admin_user(); 
     425            if (! $user ) { 
    425426                $this->theme->assign('form_errors', array('admin_user'=>_t('Problem creating admin user.'))); 
     427                DB::rollback(); 
     428                return false; 
     429            } 
     430            $admin_group = $this->create_admin_group( $user ); 
     431            if( ! $admin_group ) { 
     432                $this->theme->assign('form_errors', array('admin_user'=>_t('Problem creating admin group.'))); 
    426433                DB::rollback(); 
    427434                return false; 
     
    510517     * Creates the administrator user from form information 
    511518     * 
    512      * @return  bool  Creation successful? 
     519     * @return  mixed. the user on success, false on failure 
    513520     */ 
    514521    private function create_admin_user() 
     
    535542 
    536543        // Insert the admin user 
    537         User::create(array ( 
     544        $user = User::create(array ( 
    538545            'username'=>$admin_username, 
    539546            'email'=>$admin_email, 
     
    541548        )); 
    542549 
    543         return true; 
     550        return $user; 
     551    } 
     552 
     553    /** 
     554     * Creates the admin group using the created user 
     555     * 
     556     * @param $user User the administrative user who is installing 
     557     * @return  mixed  the user group on success, false on failure 
     558     */ 
     559    private function create_admin_group( $user ) 
     560    { 
     561        // Create the admin group 
     562        $group = UserGroup::create( array( 'name' => 'admin' ) ); 
     563        if( ! $group ) { 
     564            return false; 
     565        } 
     566        $group->add( $user->id ); 
     567        return $group; 
    544568    } 
    545569 
     
    11921216        } 
    11931217        $admin_group->add( $ids ); 
    1194         $admin_group->update(); 
    11951218 
    11961219        // @TODO: Decide on a set of default admin permissions and give them to the admin group