Example #1
0
        $params['database'] = $dbName;
    }
    $db = eZDB::instance($dbImpl, $params, true);
    eZDB::setInstance($db);
}
$db->setIsSQLOutputEnabled((bool) $options['sql']);
// Log in admin user
$user = eZUser::fetchByName(isset($options['admin-user']) ? $options['admin-user'] : '******');
if ($user) {
    eZUser::setCurrentlyLoggedInUser($user, $user->attribute('id'));
} else {
    $cli->error('Could not fetch admin user object');
    $script->shutdown(1);
    return;
}
// Take care of script monitoring
$scheduledScript = false;
if (isset($options['scriptid'])) {
    $scheduledScript = eZScheduledScript::fetch($options['scriptid']);
}
// Do the update
if (isset($options['classid'])) {
    updateClass($options['classid'], $scheduledScript);
} else {
    $cli->notice('The classid parameter was not given, will check all classes.');
    foreach (eZContentClass::fetchList(eZContentClass::VERSION_STATUS_MODIFIED, false) as $class) {
        $cli->output('Checking class with ID: ' . $class['id']);
        updateClass($class['id'], $scheduledScript);
    }
}
$script->shutdown();
if (isset($options['admin-user'])) {
    $adminUser = $options['admin-user'];
} else {
    $adminUser = '******';
}
$user = eZUser::fetchByName($adminUser);
if ($user) {
    eZUser::setCurrentlyLoggedInUser($user, $user->attribute('id'));
} else {
    $cli->error('Could not fetch admin user object');
    $script->shutdown(1);
    return;
}
// Take care of script monitoring
$scheduledScript = false;
if (isset($options['scriptid']) and in_array('ezscriptmonitor', eZExtension::activeExtensions()) and class_exists('eZScheduledScript')) {
    $scriptID = $options['scriptid'];
    $scheduledScript = eZScheduledScript::fetch($scriptID);
}
// Do the update
if (isset($options['classid'])) {
    updateClass($options['classid']);
} else {
    $cli->notice('The classid parameter was not given, will check all classes.');
    $classes = eZContentClass::fetchAllClasses(false);
    foreach ($classes as $class) {
        $cli->notice('Checking class ' . $class['id'] . ': ' . $class['name']);
        updateClass($class['id']);
    }
}
$script->shutdown();