function getList() { $groups = $this->get(); $list = array(); foreach ($groups as $group) { $g = new mGroup(); $g->setByArray($group); $list[] = $g; } return $list; }
function exec($args, $stdin, &$stdout, &$stderr, &$system) { if (!isAdmin()) { $stderr = ucf(i18n("not enough rights to add user to group")); return true; } if (empty($args)) { $stdout = "Usage: gadduser [group] [username]\n"; $stdout .= "Example: gadduser admins admin"; } else { list($groupname, $username) = explode(" ", $args); $user = new mUser(); $user->setByUsername($username); if ($user->id <= 0) { $stderr = ucf(i18n("no user named"))." $username ".i18n("found"); return true; } $group = new mGroup(); $group->setByName($groupname); if ($group->id <= 0) { $stderr = ucf(i18n("no group named"))." $groupname ".i18n("found"); return true; } $user_groups = $user->getGroups(); if (in_array($groupname, $user_groups)) { $stderr = $username." ".i18n("is already a member of")." $groupname"; return true; } $user->groups .= " $groupname"; $user->save(); $stdout = ucf(i18n("added"))." $username ".i18n("to")." $groupname"; } return true; }
function exec($args, $stdin, &$stdout, &$stderr, &$system) { $group = new mGroup(); $groups = $group->getList(); if ($args == "-l") { $stdout .= "total ".count($groups)."\n"; if (count($groups) > 0) { $stdout .= "<table cellspacing=\"0\">"; $stdout .= "<tr class=\"table_title\">"; $stdout .= "<td>Id</td>"; $stdout .= "<td>Name</td>"; $stdout .= "<td>Home</td>"; $stdout .= "<td>Created</td>"; $stdout .= "<td>Description</td>"; $stdout .= "</tr>"; foreach ($groups as $group) { $stdout .= "<tr>"; $stdout .= "<td>".$group->id."</td>"; $stdout .= "<td>".$group->name."</td>"; if ($group->home_id > 0) { $home = new mObject($group->home_id); $stdout .= "<td>".cmd($home->getPath(), "exec=show&node_id=".$home->getNodeId())."</td>"; } else $stdout .= "<td></td>"; $stdout .= "<td>".$group->created."</td>"; $stdout .= "<td>".$group->description."</td>"; $stdout .= "</tr>"; } $stdout .= "</table>"; } } else { foreach ($groups as $group) $stdout .= $group->name." "; } return true; }
function fillCalendars() { $this->calendars = array(); $home_id = $_SESSION['murrix']['user']->home_id; if ($home_id > 0) { $home = new mObject($home_id); $calendar_id = getNode($home->getPath()."/calendar", "eng"); if ($calendar_id > 0) { $name = $home->getName(); $count = 0; while (isset($this->calendars[$name])) { $count++; $name .= $count; } $children = fetch("FETCH node WHERE link:node_top='$calendar_id' AND link:type='sub' AND property:class_name='folder' NODESORTBY property:version SORTBY property:name"); for ($n = 0; $n < count($children); $n++) { $children[$n]->color = colour('light'); $children[$n]->active = true; } $this->calendars[$name] = $children; } } $groups = $_SESSION['murrix']['user']->getGroups(); foreach ($groups as $groupname) { $group = new mGroup(); $group->setByName($groupname); $home_id = $group->home_id; if ($home_id > 0) { $home = new mObject($home_id); $calendar_id = getNode($home->getPath()."/calendar", "eng"); if ($calendar_id > 0) { $name = $home->getName(); $count = 0; while (isset($this->calendars[$name])) { $count++; $name .= $count; } $children = fetch("FETCH node WHERE link:node_top='$calendar_id' AND link:type='sub' AND property:class_name='folder' NODESORTBY property:version SORTBY property:name"); for ($n = 0; $n < count($children); $n++) { $children[$n]->color = colour('light'); $children[$n]->active = true; } $this->calendars[$name] = $children; } } } }
</div> <div class="menu_login"> <center> <div style="display: table-cell; text-align: left"> <? $home_id = $_SESSION['murrix']['user']->home_id; if ($home_id > 0) { $home = new mObject($home_id); echo cmd(img(geticon("home"))." ".ucf($home->getName()), "exec=show&node_id=$home_id")."<br/>"; } $groups = $_SESSION['murrix']['user']->getGroups(); foreach ($groups as $group_name) { $group = new mGroup(); $group->setByName($group_name); $home_id = $group->home_id; if ($home_id > 0) { $home = new mObject($home_id); echo cmd(img(geticon($home->getIcon()))." ".ucf($home->getName()), "exec=show&node_id=$home_id")."<br/>"; } } ?> </div> </center> </div>
function createGroup($name, $description, $create_home = true) { if (!isAdmin) return ucf(i18n("not enough rights to create new group")); if (empty($name)) return ucf(i18n("a name must be specified")); $group = new mGroup(); $group->setByName($name); if ($group->id > 0) return ucf(i18n("a group with that name already exists")); $group->name = $name; $group->description = $description; $ret = $group->save(); if ($create_home && getNode("/root/home/groups/".$name) <= 0) { $home = new mObject(); $home->setClassName("folder"); $home->loadVars(); $home->name = $name; $home->language = $_SESSION['murrix']['language']; $home->rights = "$name=rc"; $home->setVarValue("description", "This is the home of $name"); if ($home->save()) { $home->setMeta("initial_rights", "$name=rwc"); $home_folder = new mObject(getNode("/root/home/groups")); $home->linkWithNode($home_folder->getNodeId()); } else { $message = "Operation unsuccessfull.<br/>"; $message .= "Error output:<br/>"; $message .= $home->getLastError(); return $message; } $group->home_id = $home->getNodeId(); $group->save(); } return $ret; }
function exec($args, $stdin, &$stdout, &$stderr, &$system) { if (!empty($args)) { $args_split = splitArgs($args); list($ug, $path, $recursive) = $args_split; list($username, $groupname) = explode(".", $ug); if ($path{0} != "/") $path = $_SESSION['murrix']['path']."/$path"; $node_id = getNode($path); if ($node_id <= 0) { $stderr = ucf(i18n("no such path"))." $path"; return true; } else $object = new mObject($node_id); $user = new mUser(); $user->setByUsername($username); if ($user->id <= 0) { $stderr = ucf(i18n("no such user")); return true; } $group_id = 0; if (!empty($groupname)) { $group = new mGroup(); $group->setByName($groupname); if ($group->id <= 0) { $stderr = ucf(i18n("no such group")); return true; } $group_id = $group->id; } if (!(isAdmin() || $object->hasRight("write"))) { $stderr .= ucf(i18n("not enough rights to change ownership on"))." ".$object->getPathInTree(); } else { if ($recursive == "-r" || $recursive == "-R") { $stderr = $this->setOwnerOnObjectsRecursive($object, $stdout, $stderr, $user->id, $group_id); } else { $object->setUserId($user->id); if ($group_id > 0) $object->setGroupId($group_id); if ($object->saveCurrent()) $stdout = "";//ucf(i18n("changed ownership successfully on"))." ".$object->getPathInTree(); else $stderr = ucf(i18n("failed to change ownership on"))." ".$object->getPathInTree(); } } } else { $stdout = "Usage: chown [username].[groupname] [path] [-R]\n"; $stdout .= "Example: chown admin.admins /root"; } return true; }