16 ini_set(
'mem_limit',
'-1');
17 error_reporting(E_ALL);
18 if ((php_sapi_name() !=
'cli')) {
19 trigger_error(
"You can only run this script from the command line", E_USER_ERROR);
22 $SYSTEM_ROOT = (isset($_SERVER[
'argv'][1])) ? $_SERVER[
'argv'][1] :
'';
23 if (empty($SYSTEM_ROOT) || !is_dir($SYSTEM_ROOT)) {
24 trigger_error(
"You need to supply the path to the System Root as the first argument", E_USER_ERROR);
27 define(
'SQ_SYSTEM_ROOT', $SYSTEM_ROOT);
28 require_once $SYSTEM_ROOT.
'/core/include/init.inc';
31 $ROOT_NODE = (isset($_SERVER[
'argv'][2])) ? $_SERVER[
'argv'][2] :
'';
32 if (empty($ROOT_NODE)) {
33 trigger_error(
"You need to supply a root node as the second argument", E_USER_ERROR);
38 echo
'Enter the root password for "'.SQ_CONF_SYSTEM_NAME.
'": ';
39 $root_password = rtrim(fgets(STDIN, 4094));
42 $root_user =& $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'root_user');
43 if (!$root_user->comparePassword($root_password)) {
44 echo
"ERROR: The root password entered was incorrect";
47 $GLOBALS[
'SQ_SYSTEM']->setCurrentUser($root_user);
48 $GLOBALS[
'SQ_SYSTEM']->setRunLevel(SQ_RUN_LEVEL_FORCED);
51 $fm = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'funnelback_manager');
53 $user_id = $fm->attr(
'user');
54 if (!empty($user_id)) {
55 $user = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($user_id,
'', TRUE);
58 trigger_error(
"No user asset specified in Matrix", E_USER_ERROR);
63 echo
'APPLYING PERMISSIONS FOR '.$user->name.
"\n";
64 $hh = $GLOBALS[
'SQ_SYSTEM']->getHipoHerder();
66 'permission_changes' => Array(
68 'permission' => SQ_PERMISSION_WRITE,
70 'assetids' => Array($ROOT_NODE),
71 'userid' => $user->id,
72 'previous_access' => NULL,
77 $errors = $hh->freestyleHipo(
'hipo_job_edit_permissions', $vars);
79 if (!empty($errors)) {
80 echo
"... But with errors!\n";
81 foreach ($errors as $error) {
83 $line = array_get_index($error,
'message',
'');
92 $GLOBALS[
'SQ_SYSTEM']->restoreCurrentUser();
93 $GLOBALS[
'SQ_SYSTEM']->restoreRunLevel();