Пример #1
0
<?php

require_once dirname(__FILE__) . '../../../active_php/base.php';
require_once dirname(__FILE__) . '/config.php';
class UserMigration extends Migration
{
    public function up()
    {
        $this->down();
        $user = $this->create_table('users');
        $user->string('name');
        $user->boolean('is_admin');
        $user->text('profile');
        $user->text('avatar');
        $user->go();
        $this->rename_column('users', 'name', 'name2');
    }
    public function down()
    {
        $this->drop_table('users');
    }
}
$m = new UserMigration();
$m->run();
 /**
  * User Account migration
  *
  * @return boolean
  */
 function beforeAlterField__application_variable__value()
 {
     $aConf = $GLOBALS['_MAX']['CONF'];
     // Encoding changes must be made before remapping the users, because the user migration
     // loses the exact encoding of the language pack (in preparation for UTF-8 only packs)
     $oEncodingMigration = new EncodingMigration();
     $oEncodingMigration->convertEncoding();
     $aUserdata = array('ADMIN' => array('sourceTable' => 'preference', 'primaryKey' => 'agencyid', 'fieldMap' => array('name' => $this->oDBH->quote('Administrator'), 'contact_name' => 'admin_fullname', 'email_address' => 'admin_email', 'username' => 'admin', 'password' => 'admin_pw', 'permissions' => $this->oDBH->quote(0, 'integer')), 'whereAdd' => 'agencyid = 0'), 'MANAGER' => array('sourceTable' => 'agency', 'primaryKey' => 'agencyid', 'fieldMap' => array('name' => 'name', 'contact_name' => 'contact', 'email_address' => 'email', 'username' => 'username', 'password' => 'password', 'permissions' => $this->oDBH->quote(0, 'integer')), 'whereAdd' => 'account_id IS NULL'), 'ADVERTISER' => array('sourceTable' => 'clients', 'primaryKey' => 'clientid', 'fieldMap' => array('name' => 'clientname', 'contact_name' => 'contact', 'email_address' => 'email', 'username' => 'clientusername', 'password' => 'clientpassword', 'permissions' => 'permissions'), 'permissionMap' => array(2 => OA_PERM_BANNER_EDIT, 4 => OA_PERM_BANNER_ADD, 8 => OA_PERM_BANNER_DEACTIVATE, 16 => OA_PERM_BANNER_ACTIVATE)), 'TRAFFICKER' => array('sourceTable' => 'affiliates', 'primaryKey' => 'affiliateid', 'fieldMap' => array('name' => 'name', 'contact_name' => 'contact', 'email_address' => 'email', 'username' => 'username', 'password' => 'password', 'permissions' => 'permissions'), 'permissionMap' => array(2 => OA_PERM_ZONE_LINK, 4 => OA_PERM_ZONE_ADD, 8 => OA_PERM_ZONE_DELETE, 16 => OA_PERM_ZONE_EDIT, 32 => OA_PERM_ZONE_INVOCATION)));
     $oUserMigration = new UserMigration();
     foreach ($aUserdata as $group => $aUser) {
         $result = $oUserMigration->_migrateUsers($group, $aUser);
         if (!$result) {
             return false;
         }
     }
     return $this->beforeAlterField('application_variable', 'value');
 }