Changeset 2820
- Timestamp:
- 11/17/08 04:39:47 (8 weeks ago)
- Files:
-
- 1 modified
-
trunk/htdocs/system/classes/installhandler.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/htdocs/system/classes/installhandler.php
r2814 r2820 418 418 } 419 419 420 // Let's setup the admin user now.420 // Let's setup the admin user and group now. 421 421 // But first, let's make sure that no users exist 422 422 $all_users = Users::get_all(); 423 423 if ( count( $all_users ) < 1 ) { 424 if (! $this->create_admin_user()) { 424 $user = $this->create_admin_user(); 425 if (! $user ) { 425 426 $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.'))); 426 433 DB::rollback(); 427 434 return false; … … 510 517 * Creates the administrator user from form information 511 518 * 512 * @return bool Creation successful?519 * @return mixed. the user on success, false on failure 513 520 */ 514 521 private function create_admin_user() … … 535 542 536 543 // Insert the admin user 537 User::create(array (544 $user = User::create(array ( 538 545 'username'=>$admin_username, 539 546 'email'=>$admin_email, … … 541 548 )); 542 549 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; 544 568 } 545 569 … … 1192 1216 } 1193 1217 $admin_group->add( $ids ); 1194 $admin_group->update();1195 1218 1196 1219 // @TODO: Decide on a set of default admin permissions and give them to the admin group
