<?php
// Remove all usertypes other than technical and admin

/**
 * DbPatch makes the following variables available to PHP patches:
 *
 * @var $this       DbPatch_Command_Patch_PHP
 * @var $writer     DbPatch_Core_Writer
 * @var $db         Zend_Db_Adapter_Abstract
 * @var $phpFile    string
 */

$userRows = $db->fetchAll("SELECT * FROM janus__user");
foreach ($userRows as $userRow) {
    $userTypes = unserialize($userRow['type']);
    foreach ($userTypes as $i => $userType) {
        if (!in_array($userType, array('technical', 'admin'))) {
            unset ($userTypes[$i]);
        }
    }
    rsort($userTypes);
    $db->query(
        'UPDATE janus__user SET `type` = ? WHERE uid = ?',
        array(
            serialize($userTypes),
            $userRow['uid'],
        )
    );
}
Remove all rights other than technical and admin
Remove all rights other than technical and admin

git-svn-id: fac53d8b196e0ef1c2775236b39a8c3227ab71b5@1317 528793b8-127e-4309-9901-b74759c7208d
