diff --git a/gosa-core/plugins/admin/ogroups/class_ogroup.inc b/gosa-core/plugins/admin/ogroups/class_ogroup.inc
index 398eed814d1e04d4f2ae6c7c8dfa32c2d123ac6a..b038bf6611c88396200e9dfa5ca750a9aeddb115 100644 (file)
var $memberList= array();
var $member= array();
var $orig_dn= "";
+ var $orig_cn= "";
+ var $orig_base= "";
var $group_dialog= FALSE;
var $view_logged = FALSE;
+ var $accessTo= array();
+ var $trustModel= "";
+ var $show_ws_dialog = FALSE;
+
+ var $was_trust_account= FALSE;
+
+ /* Already assigned Workstations. Will be hidden in selection.
+ */
+ var $used_workstations = array();
+
/* attribute list for save action */
- var $attributes= array("cn", "description", "gosaGroupObjects","member");
+ var $attributes= array("cn", "description", "gosaGroupObjects","member","accessTo","trustModel");
var $objectclasses= array("top", "gosaGroupOfNames");
function ogroup (&$config, $dn= NULL)
$this->is_account= TRUE;
/* Get global filter config */
- if (!session::is_set("ogfilter")){
+ if (!session::global_is_set("ogfilter")){
$ui= get_userinfo();
$base= get_base_from_people($ui->dn);
$ogfilter= array( "dselect" => $base,
"regex" => "*");
- session::set("ogfilter", $ogfilter);
+ session::global_set("ogfilter", $ogfilter);
}
- $ogfilter= session::get('ogfilter');
+ $ogfilter= session::global_get('ogfilter');
/* Adjust flags */
foreach( array( "U" => "accounts",
$ogfilter[$val]= "";
}
}
- session::set("ogfilter", $ogfilter);
+ session::global_set("ogfilter", $ogfilter);
- if(session::is_set('CurrentMainBase')){
- $this->base = session::get('CurrentMainBase');
+ if(session::global_is_set('CurrentMainBase')){
+ $this->base = global_session::get('CurrentMainBase');
}
/* Set base */
if ($this->dn == "new"){
- $this->base = session::get('CurrentMainBase');
+ $this->base = session::global_get('CurrentMainBase');
} else {
- $this->base= preg_replace("/^[^,]+,".normalizePreg(get_ou("ogroupou"))."/","",$this->dn);
+ $this->base= preg_replace("/^[^,]+,".preg_quote(get_ou("ogroupRDN"), '/')."/","",$this->dn);
+
+ /* Is this account a trustAccount? */
+ if ($this->is_account && isset($this->attrs['trustModel'])){
+ $this->trustModel= $this->attrs['trustModel'][0];
+ $this->was_trust_account= TRUE;
+ } else {
+ $this->was_trust_account= FALSE;
+ $this->trustModel= "";
+ }
+
+ $this->accessTo = array();
+ if ($this->is_account && isset($this->attrs['accessTo'])){
+ for ($i= 0; $i<$this->attrs['accessTo']['count']; $i++){
+ $tmp= $this->attrs['accessTo'][$i];
+ $this->accessTo[$tmp]= $tmp;
+ }
+ }
+ }
+
+ /* Detect all workstations, which are already assigned to an object group
+ - Those objects will be hidden in the add object dialog.
+ - Check() will complain if such a system is assigned to this object group.
+ */
+ $base = $this->config->current['BASE'];
+ $res = get_list("(|(objectClass=gotoWorkstation)(objectClass=gotoTerminal))","none" ,
+ $base, array("dn"),GL_NO_ACL_CHECK|GL_SUBSEARCH);
+ $ws_dns = array();
+ foreach($res as $data){
+ $ws_dns[] = $data['dn'];
+ }
+ $res=get_list("(&(member=*)(objectClass=gosaGroupOfNames))","none",
+ $base, array("dn","member", "gosaGroupObjects"),GL_NO_ACL_CHECK|GL_SUBSEARCH);
+ $this->used_workstations = array();
+ foreach($res as $og){
+ if($og['dn'] == $this->dn) continue;
+ $test = array_intersect($ws_dns,$og['member']);
+ if(($og['gosaGroupObjects'] == "[W]" || $og['gosaGroupObjects'] == "[T]") && count($test)){
+ $this->used_workstations = array_merge($this->used_workstations,$test);
+ }
+ }
+
+ $this->orig_cn = $this->cn;
+ $this->orig_base = $this->base;
+
+ /* Get global filter config */
+ if (!session::global_is_set("sysfilter")){
+ $ui= get_userinfo();
+ $base= get_base_from_people($ui->dn);
+ $sysfilter= array( "depselect" => $base,
+ "regex" => "*");
+ session::global_set("sysfilter", $sysfilter);
}
/* Load member data */
}
}
+ /***********
+ * Trusts
+ ***********/
+
+ /* Add user workstation? */
+ if (isset($_POST["add_ws"])){
+ $this->show_ws_dialog= TRUE;
+ $this->dialog= TRUE;
+ }
+
+ /* Add user workstation? */
+ if (isset($_POST["add_ws_finish"]) && isset($_POST['wslist'])){
+ foreach($_POST['wslist'] as $ws){
+ $this->accessTo[$ws]= $ws;
+ }
+ ksort($this->accessTo);
+ $this->is_modified= TRUE;
+ }
+
+ /* Remove user workstations? */
+ if (isset($_POST["delete_ws"]) && isset($_POST['workstation_list'])){
+ foreach($_POST['workstation_list'] as $name){
+ unset ($this->accessTo[$name]);
+ }
+ $this->is_modified= TRUE;
+ }
+
+ /* Add user workstation finished? */
+ if (isset($_POST["add_ws_finish"]) || isset($_POST["add_ws_cancel"])){
+ $this->show_ws_dialog= FALSE;
+ $this->dialog= FALSE;
+ }
+
+ /* Show ws dialog */
+ if ($this->show_ws_dialog){
+ /* Save data */
+ $sysfilter= session::global_get("sysfilter");
+ foreach( array("depselect", "regex") as $type){
+ if (isset($_POST[$type])){
+ $sysfilter[$type]= $_POST[$type];
+ }
+ }
+ if (isset($_GET['search'])){
+ $s= mb_substr($_GET['search'], 0, 1, "UTF8")."*";
+ if ($s == "**"){
+ $s= "*";
+ }
+ $sysfilter['regex']= $s;
+ }
+ session::global_set("sysfilter", $sysfilter);
+
+ /* Get workstation list */
+ $exclude= "";
+ foreach($this->accessTo as $ws){
+ $exclude.= "(cn=$ws)";
+ }
+ if ($exclude != ""){
+ $exclude= "(!(|$exclude))";
+ }
+ $regex= $sysfilter['regex'];
+ $filter= "(&(|(objectClass=goServer)(objectClass=gotoWorkstation)(objectClass=gotoTerminal))$exclude(cn=*)(cn=$regex))";
+
+ $deps_a = array(get_ou("serverRDN"),
+ get_ou("terminalRDN"),
+ get_ou("workstationRDN"));
+ $res= get_sub_list($filter, array("terminal","server","workstation"), $deps_a, get_ou("systemRDN").$sysfilter['depselect'],
+ array("cn"), GL_SUBSEARCH | GL_SIZELIMIT);
+ $wslist= array();
+ foreach ($res as $attrs){
+ $wslist[]= preg_replace('/\$/', '', $attrs['cn'][0]);
+ }
+ asort($wslist);
+ $smarty->assign("search_image", get_template_path('images/lists/search.png'));
+ $smarty->assign("launchimage", get_template_path('images/lists/action.png'));
+ $smarty->assign("tree_image", get_template_path('images/lists/search-subtree.png'));
+ $smarty->assign("deplist", $this->config->idepartments);
+ $smarty->assign("alphabet", generate_alphabet());
+ foreach( array("depselect", "regex") as $type){
+ $smarty->assign("$type", $sysfilter[$type]);
+ }
+ $smarty->assign("hint", print_sizelimit_warning());
+ $smarty->assign("wslist", $wslist);
+ $smarty->assign("apply", apply_filter());
+ $display= $smarty->fetch (get_template_path('trust_machines.tpl', TRUE, dirname(__FILE__)));
+ return ($display);
+ }
+
+ /***********
+ * Ende - Trusts
+ ***********/
+
+
/* Dialog handling */
if(is_object($this->dialog) && $this->acl_is_moveable()){
/* Must be called before save_object */
if ($this->group_dialog){
/* Save data */
- $ogfilter= session::get("ogfilter");
+ $ogfilter= session::global_get("ogfilter");
foreach( array("dselect", "regex") as $type){
if (isset($_POST[$type])){
$ogfilter[$type]= $_POST[$type];
}
$ogfilter['regex']= $s;
}
- session::set("ogfilter", $ogfilter);
+ session::global_set("ogfilter", $ogfilter);
$this->reload();
- /* Calculate actual groups */
- $smarty->assign("objects", $this->convert_list($this->objects));
+ /* Calculate actual groups / remove entries that are already inside... */
+ $strippedObjects= array();
+ foreach ($this->objects as $key => $value){
+ if (!isset($this->member[$key])){
+ $strippedObjects[$key]= $value;
+ }
+ }
+ $smarty->assign("objects", $this->convert_list($strippedObjects));
/* Show dialog */
$smarty->assign("search_image", get_template_path('images/lists/search.png'));
"T" => msgPool::selectToView(_("groups")),
"C" => (isset($ogfilter['groups']) && ($ogfilter['groups'])),
"L" => sprintf(_("Show %s"),_("groups"))),
- "applications"=> array(
- "T" => msgPool::selectToView(_("applications")),
- "C" => (isset($ogfilter['applications']) && ($ogfilter['applications'])),
- "L" => sprintf(_("Show %s"),_("applications"))),
"servers"=> array(
"T" => msgPool::selectToView(_("servers")),
"C" => (isset($ogfilter['servers']) && ($ogfilter['servers'])),
"T" => msgPool::selectToView(_("phones")),
"C" => (isset($ogfilter['phones']) && ($ogfilter['phones'])),
"L" => sprintf(_("Show %s"),_("phones"))));
+
+ /* Allow selecting applications if we are having a non
+ release managed application storage */
+ if(!$this->IsReleaseManagementActivated()){
+ $ar["applications"] = array(
+ "T" => msgPool::selectToView(_("applications")),
+ "C" => (isset($ogfilter['applications']) && ($ogfilter['applications'])),
+ "L" => sprintf(_("Show %s"),_("applications")));
+ }
+
$smarty->assign("checkboxes",$ar);
$display= $smarty->fetch (get_template_path('ogroup_objects.tpl', TRUE, dirname(__FILE__)));
return ($display);
$smarty->assign("$val", $this->$val);
}
+ /******
+ Trust account
+ ******/
+ $smarty->assign("trusthide", " disabled ");
+ $smarty->assign("trustmodeACL", $this->getacl("trustModel"));
+ if ($this->trustModel == "fullaccess"){
+ $trustmode= 1;
+ // pervent double disable tag in html code, this will disturb our clean w3c html
+ $smarty->assign("trustmode", $this->getacl("trustModel"));
+
+ } elseif ($this->trustModel == "byhost"){
+ $trustmode= 2;
+ $smarty->assign("trusthide", "");
+ } else {
+ // pervent double disable tag in html code, this will disturb our clean w3c html
+ $smarty->assign("trustmode", $this->getacl("trustModel"));
+ $trustmode= 0;
+ }
+ $smarty->assign("trustmode", $trustmode);
+ $smarty->assign("trustmodes", array( 0 => _("disabled"), 1 => _("full access"),
+ 2 => _("allow access to these hosts")));
+
+ $smarty->assign("workstations", $this->accessTo);
+
+ if((count($this->accessTo))==0){
+ $smarty->assign("emptyArrAccess",true);
+ }else{
+ $smarty->assign("emptyArrAccess",false);
+ }
+ /******
+ Ende - Trust account
+ ******/
+
return ($smarty->fetch (get_template_path('generic.tpl', TRUE)));
}
/* Save additional values for possible next step */
if (isset($_POST['ogroupedit'])){
+ /******
+ Trust account
+ ******/
+
+ if($this->acl_is_writeable("trustModel")){
+ if (isset($_POST['trustmode'])){
+ $saved= $this->trustModel;
+ if ($_POST['trustmode'] == "1"){
+ $this->trustModel= "fullaccess";
+ } elseif ($_POST['trustmode'] == "2"){
+ $this->trustModel= "byhost";
+ } else {
+ $this->trustModel= "";
+ }
+ if ($this->trustModel != $saved){
+ $this->is_modified= TRUE;
+ }
+ }
+ }
+ /******
+ Ende Trust account
+ ******/
+
/* Create a base backup and reset the
base directly after calling plugin::save_object();
Base will be set seperatly a few lines below */
$filter = "";
$objectClasses = array();
- $ogfilter = session::get("ogfilter");
+ $ogfilter = session::global_get("ogfilter");
$regex = $ogfilter['regex'];
$ldap= $this->config->get_ldap_link();
$p_f= array("accounts"=> array("OBJ"=>"user", "CLASS"=>"gosaAccount" ,
"DN"=> get_people_ou() ,"ACL" => "users"),
"groups" => array("OBJ"=>"group", "CLASS"=>"posixGroup" ,
- "DN"=> get_groups_ou('ogroupou') ,"ACL" => "groups"),
- "applications" => array("OBJ"=>"application", "CLASS"=>"gosaApplication",
- "DN"=> get_ou('applicationou') ,"ACL" => "application"),
+ "DN"=> get_groups_ou('ogroupRDN') ,"ACL" => "groups"),
"departments" => array("OBJ"=>"department", "CLASS"=>"gosaDepartment" ,
"DN"=> "" ,"ACL" => "department"),
"servers" => array("OBJ"=>"servgeneric", "CLASS"=>"goServer" ,
- "DN"=> get_ou('serverou') ,"ACL" => "server"),
+ "DN"=> get_ou('serverRDN') ,"ACL" => "server"),
"workstations" => array("OBJ"=>"workgeneric", "CLASS"=>"gotoWorkstation",
- "DN"=> get_ou('workstationou') ,"ACL" => "workstation"),
+ "DN"=> get_ou('workstationRDN') ,"ACL" => "workstation"),
"winstations" => array("OBJ"=>"wingeneric", "CLASS"=>"opsiClient",
- "DN"=> get_ou('WINSTATIONS') ,"ACL" => "winstation"),
+ "DN"=> get_ou('SAMBAMACHINEACCOUNTRDN') ,"ACL" => "winstation"),
"terminals" => array("OBJ"=>"termgeneric", "CLASS"=>"gotoTerminal" ,
- "DN"=> get_ou('terminalou') ,"ACL" => "terminal"),
+ "DN"=> get_ou('terminalRDN') ,"ACL" => "terminal"),
"printers" => array("OBJ"=>"printgeneric", "CLASS"=>"gotoPrinter" ,
- "DN"=> get_ou('printerou') ,"ACL" => "printer"),
+ "DN"=> get_ou('printerRDN') ,"ACL" => "printer"),
"phones" => array("OBJ"=>"phoneGeneric", "CLASS"=>"goFonHardware" ,
- "DN"=> get_ou('phoneou') ,"ACL" => "phone"));
+ "DN"=> get_ou('phoneRDN') ,"ACL" => "phone"));
+ /* Allow searching for applications, if we are not using release managed applications
+ */
+ if(!$this->IsReleaseManagementActivated()){
+ $p_f[ "applications"] = array("OBJ"=>"application", "CLASS"=>"gosaApplication",
+ "DN"=> get_ou('applicationRDN') ,"ACL" => "application");
+ }
+
/*###########
Perform search for selected objectClasses & regex to fill list with objects
###########*/
/* fetch results and append them to the list */
foreach($res as $attrs){
+ /* Skip workstations which are already assigned to an object group.
+ */
+ if ($this->gosaGroupObjects == "[W]" || $this->gosaGroupObjects == "[T]"){
+ if(in_array($attrs['dn'],$this->used_workstations)){
+ continue;
+ }
+ }
+
$type= $this->getObjectType($attrs);
$name= $this->getObjectName($attrs);
/* It has failed, add entry with type flag I (Invalid)*/
if (!$ldap->success()){
- $this->memberList[$dn]= array('text' => _("Non existing dn:")." ".@LDAP::fix($dn),"type" => "I");
+ $this->memberList[$dn]= array('text' => _("Non existing dn:")." ".LDAP::fix($dn),"type" => "I");
} else {
function convert_list($input)
{
$temp= "";
- $conv= array( "U" => "select_user.png",
+ $conv= array(
+ "U" => "plugins/generic/images/head.png",
"G" => "plugins/groups/images/groups.png",
"A" => "plugins/ogroups/images/application.png",
"D" => "plugins/departments/images/department.png",
"O" => "plugins/ogroups/images/winstation.png",
"T" => "plugins/ogroups/images/terminal.png",
"F" => "plugins/ogroups/images/phone.png",
- "I" => "images/lists/flag.png",
- "P" => "plugins/ogroups/images/printer.png");
+ "P" => "plugins/ogroups/images/printer.png",
+ "I" => "images/false.png");
foreach ($input as $key => $value){
/* Generate output */
/* Permissions for that base? */
if ($this->base != ""){
- $new_dn= 'cn='.$this->cn.','.get_ou('ogroupou').$this->base;
+ $new_dn= 'cn='.$this->cn.','.get_ou('ogroupRDN').$this->base;
} else {
$new_dn= $this->dn;
}
+ /* Check if we have workstations assigned, that are already assigned to
+ another object group. */
+ if ($this->gosaGroupObjects == "[W]" || $this->gosaGroupObjects == "[T]" ) {
+ $test =array_intersect($this->used_workstations,$this->member);
+ if(count($test)){
+ $str = "";
+ foreach($test as $dn){
+ $str .= "<li>".$dn."</li>";
+ }
+ $message[] = sprintf(_("These systems are already configured by other object groups and cannot be added:")."<br><ul>%s</ul>",$str);
+ }
+ }
$ldap = $this->config->get_ldap_link();
if($this->dn != $new_dn){
$message[]= _("You can combine two different object types at maximum, only!");
}
+ /* Check if we are allowed to create or move this object
+ */
+ if($this->orig_dn == "new" && !$this->acl_is_createable($this->base)){
+ $message[] = msgPool::permCreate();
+ }elseif($this->orig_dn != "new" && $this->base != $this->orig_base && !$this->acl_is_moveable($this->base)){
+ $message[] = msgPool::permMove();
+ }
+
return ($message);
}
/* Move members to target array */
$this->attrs['member'] =array();
foreach ($this->member as $key => $desc){
- $this->attrs['member'][]= @LDAP::fix($key);
+ $this->attrs['member'][]= LDAP::fix($key);
}
$ldap= $this->config->get_ldap_link();
/* New accounts need proper 'dn', propagate it to remaining objects */
if ($this->dn == 'new'){
- $this->dn= 'cn='.$this->cn.','.get_ou('ogroupou').$this->base;
+ $this->dn= 'cn='.$this->cn.','.get_ou('ogroupRDN').$this->base;
}
/* Save data. Using 'modify' implies that the entry is already present, use 'add' for
$ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
}
+ /******
+ Trust accounts
+ ******/
+ $objectclasses= array();
+ foreach ($this->attrs['objectClass'] as $key => $class){
+ if (preg_match('/trustAccount/i', $class)){
+ continue;
+ }
+ $objectclasses[]= $this->attrs['objectClass'][$key];
+ }
+ $this->attrs['objectClass']= $objectclasses;
+ if ($this->trustModel != ""){
+ $this->attrs['objectClass'][]= "trustAccount";
+ $this->attrs['trustModel']= $this->trustModel;
+ $this->attrs['accessTo']= array();
+ if ($this->trustModel == "byhost"){
+ foreach ($this->accessTo as $host){
+ $this->attrs['accessTo'][]= $host;
+ }
+ }
+ } else {
+ if ($this->was_trust_account){
+ $this->attrs['accessTo']= array();
+ $this->attrs['trustModel']= array();
+ }
+ }
+
+ /******
+ Ende - Trust accounts
+ ******/
+
/* Write back to ldap */
$ldap->cd($this->dn);
$this->cleanup();
}
+ function IsReleaseManagementActivated()
+ {
+ /* Check if we should enable the release selection */
+ $tmp = $this->config->search("faiManagement", "CLASS",array('menu','tabs'));
+ if(!empty($tmp)){
+ return(true);
+ }
+ return(false);
+ }
+
+
static function plInfo()
{
return (array(
"cn" => _("Name"),
"base" => _("Base"),
"description" => _("Description"),
+ "trustModel" => _("Sytem trust"),
"member" => _("Member"))
));
}