[ Index ]

PHP Cross Reference of GlotPress

title

Body

[close]

/scripts/ -> add-admin.php (source)

   1  <?php
   2  require_once dirname( dirname( __FILE__ ) ) . '/gp-load.php';
   3  
   4  class GP_Script_Add_Admin extends GP_CLI {
   5  
   6      var $usage = "<username-to-make-an-admin>";
   7      
   8  	function run() {
   9          if ( empty( $this->args ) ) {
  10              $this->usage();
  11          }
  12          foreach( $this->args as $user_login ) {
  13              $user_to_make_admin = GP::$user->by_login( $user_login );
  14              if ( !$user_to_make_admin ) {
  15                  $this->to_stderr( "User '$user_login' doesn't exist." );
  16                  exit( 1 );
  17              }
  18              if ( !GP::$permission->create( array( 'user_id' => $user_to_make_admin->id, 'action' => 'admin' ) ) ) {
  19                  $this->to_stderr( "Error in making '$user_login' and admin." );
  20                  exit( 2 );
  21              }
  22          }
  23          
  24      }
  25  }
  26  
  27  $gp_script_add_admin = new GP_Script_Add_Admin;
  28  $gp_script_add_admin->run();


Generated: Thu May 24 03:59:35 2012 Hosted by follow the white rabbit.