diff --git a/plugins/admin/users/class_userManagement.inc b/plugins/admin/users/class_userManagement.inc
index 7c87e833002d167849e25125a7662471024fc821..fbc3ab56b9cf4df74d5b90d7de1b40ffb2cf73f6 100644 (file)
$this->ui= $ui;
/* Get global filter config */
$this->ui= $ui;
/* Get global filter config */
- if (!is_global("userfilter")){
+ if (!isset($_SESSION["userfilter"])){
$base= get_base_from_people($ui->dn);
$userfilter= array( "mailusers" => "checked",
"unixusers" => "checked",
$base= get_base_from_people($ui->dn);
$userfilter= array( "mailusers" => "checked",
"unixusers" => "checked",
"functionalusers" => "checked",
"depselect" => $base,
"regex" => "*");
"functionalusers" => "checked",
"depselect" => $base,
"regex" => "*");
- register_global("userfilter", $userfilter);
+ $_SESSION["userfilter"] = $userfilter;
}
}
function execute()
{
}
}
function execute()
{
+ /* Call parent execute */
+ plugin::execute();
+
$smarty = get_smarty(); // Smarty instance
$userfilter = get_global("userfilter"); // contains Filter Settings
$s_action = ""; // Contains the action to proceed
$smarty = get_smarty(); // Smarty instance
$userfilter = get_global("userfilter"); // contains Filter Settings
$s_action = ""; // Contains the action to proceed
/* Start for New List Managment */
if(isset($_GET['act'])&&($_GET['act']=="dep_open")){
/* Start for New List Managment */
if(isset($_GET['act'])&&($_GET['act']=="dep_open")){
- $s_action="open";
- $s_entry = base64_decode($_GET['dep_id']);
- $userfilter['depselect']= "".$this->config->departments[trim($s_entry)];
- $this->reload();
+ $s_action="open";
+ $s_entry = base64_decode($_GET['dep_id']);
+ $userfilter['depselect']= "".$this->config->departments[trim($s_entry)];
}
/* Test Posts */
}
/* Test Posts */
$s_entry = preg_replace("/user_chgpw_/i","",$key);
}elseif(preg_match("/dep_root.*/i",$key)){
$s_action="root";
$s_entry = preg_replace("/user_chgpw_/i","",$key);
}elseif(preg_match("/dep_root.*/i",$key)){
$s_action="root";
+ }elseif(preg_match("/userfrom_tpl.*/i",$key)){
+ $s_action="create_user_from_tpl";
+ $s_entry = preg_replace("/userfrom_tpl_/i","",$key);
}
}
}
}
-
+
if((isset($_GET['act']))&&($_GET['act']=="edit_entry")){
if((isset($_GET['act']))&&($_GET['act']=="edit_entry")){
- $s_action ="edit";
+ $s_action = "edit";
$s_entry = $_GET['id'];
}
$s_entry = preg_replace("/_.$/","",$s_entry);
$s_entry = $_GET['id'];
}
$s_entry = preg_replace("/_.$/","",$s_entry);
+ if(preg_match("/.*-.*/",$s_entry)){
+ $s_tab = preg_replace("/^.*-/i","",$s_entry);
+ $s_entry = preg_replace("/-.*$/i","",$s_entry);
+ }else{
+ $s_tab = "user";
+ };
+
/* Department changed? */
if(isset($_POST['depselect']) && $_POST['depselect']){
$userfilter['depselect']= $_POST['depselect'];
/* Department changed? */
if(isset($_POST['depselect']) && $_POST['depselect']){
$userfilter['depselect']= $_POST['depselect'];
- $this->reload();
}
/* Homebutton is posted */
if($s_action=="home"){
$userfilter['depselect']=(preg_replace("/^[^,]+,/","",$this->ui->dn));
$userfilter['depselect']=(preg_replace("/^[^,]+,/","",$userfilter['depselect']));
}
/* Homebutton is posted */
if($s_action=="home"){
$userfilter['depselect']=(preg_replace("/^[^,]+,/","",$this->ui->dn));
$userfilter['depselect']=(preg_replace("/^[^,]+,/","",$userfilter['depselect']));
- $this->reload();
}
if($s_action=="root"){
$userfilter['depselect']=($this->config->current['BASE']);
}
if($s_action=="root"){
$userfilter['depselect']=($this->config->current['BASE']);
- $this->reload();
}
}
}else{
$userfilter['depselect']= $this->config->departments["/"];
}
}else{
$userfilter['depselect']= $this->config->departments["/"];
}
- $this->reload();
}
/* End for new List Managment */
/* Save filter data if we are in the headpage */
if (!isset($this->usertab)){
}
/* End for new List Managment */
/* Save filter data if we are in the headpage */
if (!isset($this->usertab)){
- foreach( array("regex") as $type){
- if (isset($_POST[$type])){
- $userfilter[$type]= $_POST[$type];
- }
+ if (isset($_POST['regexit'])){
+ $userfilter["regex"]= $_POST['regexit'];
}
}
}
}
- if(isset($_POST['regex'])){
+ if(isset($_POST['regexit'])){
foreach( array("functionalusers", "unixusers", "mailusers","sambausers", "proxyusers", "faxusers", "templates", "subsearch") as $type){
if (isset($_POST[$type])) {
$userfilter[$type]= "checked";
foreach( array("functionalusers", "unixusers", "mailusers","sambausers", "proxyusers", "faxusers", "templates", "subsearch") as $type){
if (isset($_POST[$type])) {
$userfilter[$type]= "checked";
$userfilter['regex']= $s;
}
register_global("userfilter", $userfilter);
$userfilter['regex']= $s;
}
register_global("userfilter", $userfilter);
-
+
/* React on user interaction here */
if (($_SERVER["REQUEST_METHOD"] == "POST")||($_SERVER["REQUEST_METHOD"]== "GET")){
/* React on user interaction here */
if (($_SERVER["REQUEST_METHOD"] == "POST")||($_SERVER["REQUEST_METHOD"]== "GET")){
if ($s_action=="edit"){
/* Get 'dn' from posted 'uid', must be unique */
if ($s_action=="edit"){
/* Get 'dn' from posted 'uid', must be unique */
-
+
$this->dn= $this->list[trim($s_entry)]['dn'];
/* Check locking, save current plugin in 'back_plugin', so
$this->dn= $this->list[trim($s_entry)]['dn'];
/* Check locking, save current plugin in 'back_plugin', so
/* Register usertab to trigger edit dialog */
$this->usertab= new usertabs($this->config,
$this->config->data['TABS']['USERTABS'], $this->dn);
/* Register usertab to trigger edit dialog */
$this->usertab= new usertabs($this->config,
$this->config->data['TABS']['USERTABS'], $this->dn);
+ // $_POST[$s_tab]=$s_tab;
+
+ // This would be better
+ $this->usertab->current = $s_tab;
$this->usertab->set_acl($acl);
$_SESSION['objectinfo']= $this->dn;
$this->usertab->set_acl($acl);
$_SESSION['objectinfo']= $this->dn;
return($smarty->fetch(get_template_path('password.tpl', TRUE)));
}
return($smarty->fetch(get_template_path('password.tpl', TRUE)));
}
+ $config= $this->config;
+ $ldap_ui= $this->config->get_ldap_link();
+ if(isset($this->usertab->dn)){
+ $user = ($ldap_ui->fetch($ldap_ui->cat($this->usertab->dn)));
+ }else{
+ $user = ($ldap_ui->fetch($ldap_ui->cat($this->dn)));
+ }
+ if((is_array($user))&&(isset($user['uid']))){
+ $username= $user['uid'][0];
+ }
+
/* Set password, perform required steps */
if ($this->usertab){
if ($this->usertab->password_change_needed()){
$obj= $this->usertab->by_object['user'];
change_password ($this->usertab->dn, $_POST['new_password'],
0, $obj->pw_storage);
/* Set password, perform required steps */
if ($this->usertab){
if ($this->usertab->password_change_needed()){
$obj= $this->usertab->by_object['user'];
change_password ($this->usertab->dn, $_POST['new_password'],
0, $obj->pw_storage);
+ if (isset($config->data['MAIN']['EXTERNALPWDHOOK'])){
+ exec($config->data['MAIN']['EXTERNALPWDHOOK']." ".$username." ".$_POST['new_password'], $resarr);
+ }
+
gosa_log ("Password for '".$this->usertab->dn."' has been changed");
unset($this->usertab);
$this->usertab= NULL;
}
} else {
change_password ($this->dn, $_POST['new_password']);
gosa_log ("Password for '".$this->usertab->dn."' has been changed");
unset($this->usertab);
$this->usertab= NULL;
}
} else {
change_password ($this->dn, $_POST['new_password']);
+ if (isset($config->data['MAIN']['EXTERNALPWDHOOK'])){
+ exec($config->data['MAIN']['EXTERNALPWDHOOK']." ".$username." ".$_POST['new_password'], $resarr);
+ }
+
gosa_log ("Password for '".$this->dn."' has been changed");
}
} else {
gosa_log ("Password for '".$this->dn."' has been changed");
}
} else {
}
/* Generate template list */
}
/* Generate template list */
- if ($s_action=="new"){
+ if (($s_action=="new")||($s_action=="create_user_from_tpl")){
+
$this->templates= array();
$this->templates= array();
+
$ldap= $this->config->get_ldap_link();
$ldap= $this->config->get_ldap_link();
+
+ /* Create list of tempaltes */
foreach ($this->config->departments as $key => $value){
foreach ($this->config->departments as $key => $value){
+
+ /* Get acls from different ou's */
$acl= get_permissions (get_people_ou().$value, $this->ui->subtreeACL);
$acl= get_module_permission($acl, "user", get_people_ou().$value);
$acl= get_permissions (get_people_ou().$value, $this->ui->subtreeACL);
$acl= get_module_permission($acl, "user", get_people_ou().$value);
+
+ /* If creation of a new user is allowed, append this template */
if (chkacl($acl, "create") == ""){
if (chkacl($acl, "create") == ""){
+
+ /* Search all templates from the current dn */
$ldap->cd (get_people_ou().$value);
$ldap->search ("(objectClass=gosaUserTemplate)", array("uid"));
$ldap->cd (get_people_ou().$value);
$ldap->search ("(objectClass=gosaUserTemplate)", array("uid"));
+ /* Append */
if ($ldap->count() != 0){
while ($attrs= $ldap->fetch()){
$this->templates[$ldap->getDN()]=
if ($ldap->count() != 0){
while ($attrs= $ldap->fetch()){
$this->templates[$ldap->getDN()]=
}
}
}
}
}
}
+
+ /* Sort templates */
natcasesort ($this->templates);
reset ($this->templates);
}
/* New user/template request */
natcasesort ($this->templates);
reset ($this->templates);
}
/* New user/template request */
- if (($s_action=="new") || ($s_action=="new_tpl")){
+ if (($s_action=="create_user_from_tpl")||($s_action=="new") || ($s_action=="new_tpl")){
/* By default we set 'dn' to 'new', all relevant plugins will
react on this. */
$this->dn= "new";
/* By default we set 'dn' to 'new', all relevant plugins will
react on this. */
$this->dn= "new";
$this->usertab= new usertabs($this->config,
$this->config->data['TABS']['USERTABS'], $this->dn);
$this->usertab->set_acl(array(':all'));
$this->usertab= new usertabs($this->config,
$this->config->data['TABS']['USERTABS'], $this->dn);
$this->usertab->set_acl(array(':all'));
+ $this->usertab->by_object['user']->base= $userfilter['depselect'];
/* Take care about templates */
if ($s_action=="new_tpl"){
/* Take care about templates */
if ($s_action=="new_tpl"){
}
/* Use template if there are any of them */
}
/* Use template if there are any of them */
- if (count($this->templates) && !isset($_POST['new_template'])){
+
+ if ((count($this->templates) && ($s_action!='new_tpl'))||($s_action=="create_user_from_tpl")){
foreach(array("sn", "givenName", "uid", "got_uid", "templates") as $attr){
$smarty->assign("$attr", $this->$attr);
}
foreach(array("sn", "givenName", "uid", "got_uid", "templates") as $attr){
$smarty->assign("$attr", $this->$attr);
}
- if (isset($_POST['template'])){
- $smarty->assign("template", $_POST['template']);
+ if ($s_action=="create_user_from_tpl"){
+ $smarty->assign("template", $this->dn= $this->list[trim($s_entry)]['dn']);
} else {
} else {
- $smarty->assign("template", "");
+ $smarty->assign("template", "none");
}
$smarty->assign("edit_uid", "");
return($smarty->fetch(get_template_path('template.tpl', TRUE)));
}
}
$smarty->assign("edit_uid", "");
return($smarty->fetch(get_template_path('template.tpl', TRUE)));
}
-
}
/* Continue template editing */
}
/* Continue template editing */
- if (isset($_POST['template_continue']) && $_POST['template'] != 'none' && !isset($_POST['uid'])){
+ if ((isset($_POST['template_continue']) && $_POST['template'] != 'none' && !isset($_POST['uid']))){
$this->sn= $_POST['sn'];
$this->givenName= $_POST['givenName'];
$this->sn= $_POST['sn'];
$this->givenName= $_POST['givenName'];
$this->uid= current($uids);
}
} else {
$this->uid= current($uids);
}
} else {
- $smarty->assign("edit_uid", "");
+ $smarty->assign("edit_uid", "");
$this->uid= "";
}
$this->got_uid= true;
$this->uid= "";
}
$this->got_uid= true;
if (isset($_POST['template_continue']) && $_POST['template'] != 'none' && (isset($_POST['uid']))){
/* Might not be filled if IDGEN is unset */
if (isset($_POST['template_continue']) && $_POST['template'] != 'none' && (isset($_POST['uid']))){
/* Might not be filled if IDGEN is unset */
- $this->sn= $_POST['sn'];
- $this->givenName= $_POST['givenName'];
+ $this->sn = $_POST['sn'];
+ $this->givenName = $_POST['givenName'];
/* Move user supplied data to sub plugins */
/* Move user supplied data to sub plugins */
- $this->uid= $_POST['uid'];
- $this->usertab->uid= $this->uid;
- $this->usertab->sn= $this->sn;
- $this->usertab->givenName= $this->givenName;
- $template_dn= $_POST['template'];
+ $this->uid = $_POST['uid'];
+ $this->usertab->uid = $this->uid;
+ $this->usertab->sn = $this->sn;
+ $this->usertab->givenName = $this->givenName;
+ $template_dn = $_POST['template'];
$this->usertab->adapt_from_template($template_dn);
$this->usertab->adapt_from_template($template_dn);
- $template_base= preg_replace("/^[^,]+,".get_people_ou()."/", '', $template_dn);
+ $template_base = preg_replace("/^[^,]+,".get_people_ou()."/", '', $template_dn);
$this->usertab->by_object['user']->base= $template_base;
/* Set up the users ACL's for this 'dn' */
$acl= get_permissions ($template_base, $this->ui->subtreeACL);
$this->usertab->set_acl($acl);
}
$this->usertab->by_object['user']->base= $template_base;
/* Set up the users ACL's for this 'dn' */
$acl= get_permissions ($template_base, $this->ui->subtreeACL);
$this->usertab->set_acl($acl);
}
+
+ if (isset($_POST['template_continue']) && ($_POST['template'] == 'none')){
+ $this->usertab->by_object['user']->base= $userfilter['depselect'];
+ }
/* Show tab dialog if object is present */
if ($this->usertab){
/* Show tab dialog if object is present */
if ($this->usertab){
/* Prepare departments */
$options= "";
foreach ($this->config->idepartments as $key => $value){
/* Prepare departments */
$options= "";
foreach ($this->config->idepartments as $key => $value){
- if ($userfilter['depselect'] == $key){
- $options.= "<option selected value='$key'>$value</option>";
- } else {
- $options.= "<option value='$key'>$value</option>";
- }
+ if ($userfilter['depselect'] == $key){
+ $options.= "<option selected value='$key'>$value</option>";
+ } else {
+ $options.= "<option value='$key'>$value</option>";
+ }
}
}
-
+
/* NEW LIST MANAGMENT */
$listhead = "<div style='background:#F0F0F9;padding:5px;'>".
/* NEW LIST MANAGMENT */
$listhead = "<div style='background:#F0F0F9;padding:5px;'>".
- " <input type='image' align='middle' src='images/list_back.png' title='"._("Go up one department")."' alt='"._("Up")."' name='dep_back'> ".
- " <input type='image' src='images/list_root.png' align='middle' title='"._("Go to root department")."' name='dep_root' alt='"._("Root")."'> ".
- " <input type='image' align='middle' src='images/list_home.png' title='"._("Go to users department")."' alt='"._("Home")."' name='dep_home'> ".
- " <img src='images/list_seperator.png' align='middle' alt='' height='16' width='1'> ".
- " <input type='image' align='middle' src='images/list_new_user.png' title='"._("Create new user")."' alt='"._("New user")."' name='user_new'> ".
- " <input type='image' align='middle' src='images/list_new.png' title='"._("Create new template")."' alt='"._("New template")."' name='user_tplnew'> ".
- " <img src='images/list_seperator.png' align='middle' alt='' height='16' width='1'> ".
- _("Current base")." <select name='depselect' onChange='mainform.submit()'>$options</select>".
- " <input type='image' src='images/list_submit.png' align='middle' title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'> ".
- "</div>";
+ " <input class='center' type='image' align='middle' src='images/list_back.png' title='"._("Go up one department")."' alt='"._("Up")."' name='dep_back'> ".
+ " <input class='center' type='image' src='images/list_root.png' align='middle' title='"._("Go to root department")."' name='dep_root' alt='"._("Root")."'> ".
+ " <input class='center' type='image' align='middle' src='images/list_home.png' title='"._("Go to users department")."' alt='"._("Home")."' name='dep_home'> ".
+ " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'> ".
+ " <input class='center' type='image' align='middle' src='images/list_new_user.png' title='"._("Create new user")."' alt='"._("New user")."' name='user_new'> ".
+ " <input class='center' type='image' align='middle' src='images/list_new.png' title='"._("Create new template")."' alt='"._("New template")."' name='user_tplnew'> ".
+ " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'> ".
+ _("Current base")." <select name='depselect' onChange='mainform.submit()'>$options</select>".
+ " <input class='center' type='image' src='images/list_submit.png' align='middle' title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'> ".
+ "</div>";
$action= "<input type='image' src='images/edit.png' alt='"._("edit")."' name='user_edit_%KEY%' title='"._("Edit user")."'>";
$action.= "<input type='image' src='images/list_password.png' alt='"._("password")."' name='user_chgpw_%KEY%' title='"._("Change password")."'>";
$action= "<input type='image' src='images/edit.png' alt='"._("edit")."' name='user_edit_%KEY%' title='"._("Edit user")."'>";
$action.= "<input type='image' src='images/list_password.png' alt='"._("password")."' name='user_chgpw_%KEY%' title='"._("Change password")."'>";
- $action.= "<input type='image' src='images/editdelete.png' alt='"._("delete")."' name='user_del_%KEY%' title='"._("Delete user")."'>";
+ $action.= "<input type='image' src='images/edittrash.png' alt='"._("delete")."' name='user_del_%KEY%' title='"._("Delete user")."'>";
- $divlist = new divlist();
+ $divlist = new divlist("userstab");
$divlist->SetHeader(array(
$divlist->SetHeader(array(
- array("string" => " "),
- array("string" => _("Username")." / "._("Department")),
- array("string" => _("Properties")),
- array("string" => _("Actions"), "attach" => "style='border:none'" )));
-
+ array("string" => " ", "attach" => "style='text-align:center;width:20px;'"),
+ array("string" => _("Username")." / "._("Department"), "attach" => "style=''"),
+ array("string" => _("Properties"), "attach" => "style='width:152px;'"),
+ array("string" => _("Actions"), "attach" => "style='width:60px;border-right:0px;text-align:right;'")));
+
$divlist->SetSummary(_("This table displays all users, in the selected tree."));
$divlist->SetSummary(_("This table displays all users, in the selected tree."));
- $divlist->SetEntriesPerPage(20);
+ $divlist->SetEntriesPerPage(0);
// Defining Links
$linkopen = "<a href='?plug=".$_GET['plug']."&act=dep_open&dep_id=%s'>%s</a>";
// Defining Links
$linkopen = "<a href='?plug=".$_GET['plug']."&act=dep_open&dep_id=%s'>%s</a>";
+ /* Insert departments in divlist*/
foreach($this->departments as $key=> $val){
foreach($this->departments as $key=> $val){
- $field1 = array("string" => "<img src='images/folder.png' alt='department'>");
- $field2 = array("string" => sprintf($linkopen,base64_encode($key),$val));
- $field3 = array("string" => " ");
- $field4 = array("string" => " ", "attach" => "style='border:none'");
+ if(!isset($this->config->departments[trim($key)])){
+ $this->config->departments[trim($key)]="";
+ }
+
+ $non_empty="";
+ $keys= str_replace("/","\/",$key);
+ foreach($this->config->departments as $keyd=>$vald ){
+ if(preg_match("/".$keys."\/.*/",$keyd)){
+ $non_empty="full";
+ }
+ }
+
+ $field1 = array("string" => "<img src='images/".$non_empty."folder.png' alt='department'>", "attach" => "style='text-align:center;width:20px;'");
+ $field2 = array("string" => sprintf($linkopen,base64_encode($key),$val), "attach" => "style=''");
+ $field3 = array("string" => " ", "attach" => "style='width:152px;'");
+ $field4 = array("string" => " ", "attach" => "style='width:60px;border-right:0px;text-align:right;'");
+
-
$divlist->AddEntry(array($field1,$field2,$field3,$field4));
}
$divlist->AddEntry(array($field1,$field2,$field3,$field4));
}
- // Pictures for Extensions
- $usrimg = "<img src='images/penguin.png' alt='U' title='"._("GOsa") ."'>";
- $posiximg = "<img src='images/select_user.png' alt='P' title='"._("Posix") ."'>";
- $mailimg = "<img src='images/mailto.png' alt='M' title='"._("Mail") ."'>";
- $fonimg = "<img src='images/select_phone.png' alt='T' title='"._("Phone") ."'>";
- $faximg = "<img src='images/fax_small.png' alt='F' title='"._("Fax") ."'>";
- $sambaimg = "<img src='images/select_winstation.png' alt='S' title='"._("Samba") ."'>";
-
- // Space
- $empty = "<img src='images/empty.png' style='width:16px;height:16px;' alt=''>";
+ /* Pictures for Extensions */
+ $usrimg ="<input type='image' src='images/penguin.png' alt='"._("GOsa")."'
+ name='user_edit_%KEY%-user' title='"._("Edit generic properties")."'>";
+ $posiximg = "<input type='image' src='images/select_user.png' alt='"._("Posix")."'
+ name='user_edit_%KEY%-posixAccount' title='"._("Edit UNIX properties")."'>";
+ $eviroimg = "<input type='image' src='images/smallenv.png' alt='"._("Environment")."'
+ name='user_edit_%KEY%-environment' title='"._("Edit environment properties")."'>";
+ $mailimg = "<input type='image' src='images/mailto.png' alt='"._("Mail")."'
+ name='user_edit_%KEY%-mailAccount' title='"._("Edit mail properties")."'>";
+ $fonimg = "<input type='image' src='images/%image%' alt='"._("Phone")."'
+ name='user_edit_%KEY%-phoneAccount' title='"._("Edit phone properties")."%title%'>";
+ $faximg = "<input type='image' src='images/fax_small.png' alt='"._("Fax")."'
+ name='user_edit_%KEY%-gofaxAccount' title='"._("Edit fax properies")."'>";
+ $sambaimg = "<input type='image' src='images/select_winstation.png' alt='"._("Samba")."'
+ name='user_edit_%KEY%-sambaAccount' title='"._("Edit samba properties")."'>";
+ $tplcreateuserimg = "<input type='image' src='images/list_new.png' alt='"._("Create user from template")."'
+ name='userfrom_tpl_%KEY%' title='"._("Create user with this template")."'>";
+
+ $empty = "<img src='images/empty.png' style='width:16px;height:16px;' alt=''>";
+
// User and Template Images
$userimg = "<img src='images/select_user.png' alt='User' title='%s'>";
$tplimg = "<img src='images/select_template.png' alt='Template' title='%s'>";
// User and Template Images
$userimg = "<img src='images/select_user.png' alt='User' title='%s'>";
$tplimg = "<img src='images/select_template.png' alt='Template' title='%s'>";
-
$editlink = "<a href='?plug=".$_GET['plug']."&id=%s&act=edit_entry'>%s</a>";
$editlink = "<a href='?plug=".$_GET['plug']."&id=%s&act=edit_entry'>%s</a>";
-
+
// Defines Arrays to save User and Templates
$tpls = array();
$users= array();
// Defines Arrays to save User and Templates
$tpls = array();
$users= array();
+ /* Get Configuration for goFon DB (if it is set), to connect to the asterisk tables.
+ * Read Sip Table for specified account (for each user with phoneAccount).
+ * Check the attributes ip port and regseconds.
+ * If regseconds is set and >0 , the phone is logged in.
+ * Else the phone is currently not logged.
+ * If we can't read any Data from the DB or there is no goFon DB specified
+ * show old style without status icons.
+ */
+ $r_db =false;
+ $r_con =false;
+ if (isset($_SESSION['config']->data['SERVERS']['FON'])){
+ $a_SETUP= $_SESSION['config']->data['SERVERS']['FON'];
+ // Connect to DB server
+
+ /*
+ If you want to disable the status pictures, just comment out the next line
+ */
+ $r_con = false;
+ $r_db = false;
+ if(is_callable("mysql_pconnect")){
+ $r_con= @mysql_pconnect($a_SETUP['SERVER'],$a_SETUP['LOGIN'],$a_SETUP['PASSWORD']);
+ // Check if we are connected correctly
+ if($r_con){
+ $r_db = @mysql_select_db($a_SETUP['DB'],$r_con);
+ }
+ }
+ }
+
// Test Every Entry and generate divlist Array
foreach($this->list as $key => $val){
// Test Every Entry and generate divlist Array
foreach($this->list as $key => $val){
+ $connected = ""; // This string represents timestamp or offline status
+ $ip_port = ""; // String that will represent ip : port of the connected phone
+ if((in_array("goFonAccount" ,$val['objectClass']))){
+
+ /* Set defaults */
+ $fonac = preg_replace("/%image%/", "select_phone.png", $fonimg);
+ $fonac = preg_replace("/%KEY%/", "$key", $fonac);
+ $fonac = preg_replace("/%title%/", "", $fonac);
+
+ /* Database connection is ok ?*/
+ if(($r_db)&&(is_callable("mysql_query"))){
+ $res= @mysql_query("SELECT regseconds,name,port,ipaddr FROM ".$a_SETUP['SIP_TABLE']." WHERE (name='".$val['uid'][0]."')");
+ $mysql_entry = @mysql_fetch_row($res);
+ if(is_array($mysql_entry)){
+ if((isset($mysql_entry[0]))&&($mysql_entry[0]>1)){
+ $connected = " | "._("Online")." : ".gmdate("d.m.Y H:i:s",($mysql_entry[0]+(60*60)));
+ $fonac = preg_replace("/%image%/", "select_phone_connected.png", $fonimg);
+ $fonac = preg_replace("/%KEY%/", "$key", $fonac);
+ $fonac = preg_replace("/%title%/", $connected, $fonac);
+ $ip_port= " - ".$mysql_entry[3].":".$mysql_entry[2];
+ }
+ if((isset($mysql_entry[0]))&&($mysql_entry[0]==0)){
+ $connected = " | "._("Offline");
+ $fonac = preg_replace("/%image%/", "select_phone.png", $fonimg);
+ $fonac = preg_replace("/%KEY%/", "$key", $fonac);
+ $fonac = preg_replace("/%title%/", $connected, $fonac);
+ }
+ }
+ }
+ }else{
+ $fonac=$empty;
+ }
+
+
// Specify Pics for Extensions
// Specify Pics for Extensions
- if(in_array("posixAccount" ,$val['objectClass'])) $posix = $posiximg; else $posix=$empty;
- if(in_array("gosaMailAccount" ,$val['objectClass'])) $maila = $mailimg; else $maila=$empty;
- if(in_array("goFonAccount" ,$val['objectClass'])) $fonac = $fonimg; else $fonac=$empty;
- if(in_array("goFaxAccount" ,$val['objectClass'])) $faxac = $faximg; else $faxac=$empty;
- if(in_array("sambaSamAccount" ,$val['objectClass'])) $samba = $sambaimg; else $samba=$empty;
- if(in_array("gosaUserTemplate",$val['objectClass'])) $tpl = $tplimg; else $tpl=$userimg;
-
- // Generate Array to Add
+ if(in_array("posixAccount" ,$val['objectClass'])){
+ $posix = preg_replace("/%KEY%/", "$key", $posiximg);
+ }else{
+ $posix=$empty;
+ }
+
+ if(in_array("gotoEnvironment" ,$val['objectClass'])){
+ $enviro = preg_replace("/%KEY%/", "$key", $eviroimg);
+ }else{
+ $enviro =$empty;
+ }
+
+ if(in_array("gosaMailAccount" ,$val['objectClass'])){
+ $maila = preg_replace("/%KEY%/", "$key", $mailimg);
+ }else{
+ $maila=$empty;
+ }
+
+ if(in_array("goFaxAccount" ,$val['objectClass'])){
+ $faxac = preg_replace("/%KEY%/", "$key", $faximg);
+ }else{
+ $faxac=$empty;
+ }
+
+ if(in_array("sambaSamAccount" ,$val['objectClass'])){
+ $samba = preg_replace("/%KEY%/", "$key", $sambaimg);
+ }else{
+ $samba=$empty;
+ }
+
+ if(in_array("gosaUserTemplate",$val['objectClass'])){
+ $tpl = preg_replace("/%KEY%/", "$key", $tplimg);
+ $s_img_create_from_template = preg_replace("/%KEY%/", "$key", $tplcreateuserimg);
+ }else{
+ $s_img_create_from_template = "";
+ $tpl=$userimg;
+ }
+
+ $usrimg2 = preg_replace("/%KEY%/", "$key", $usrimg);
+
+ // Generate caption for rows
if (isset($val["sn"]) && isset($val["givenName"])){
$display= $val["sn"][0].", ".$val["givenName"][0]." [".$val["uid"][0]."]";
} else {
$display= "[".$val["uid"][0]."]";
}
if (isset($val["sn"]) && isset($val["givenName"])){
$display= $val["sn"][0].", ".$val["givenName"][0]." [".$val["uid"][0]."]";
} else {
$display= "[".$val["uid"][0]."]";
}
- $field1 = array("string" => sprintf($tpl,$val['dn']),"attach"=>"style='width:20px;align:middle;'");
- $field2 = array("string" => sprintf($editlink,$key,$display),"attach"=>"title='".$val['dn']."'");
- $field3 = array("string" => $usrimg." ".$posix." ".$maila." ".$fonac." ".$faxac." ".$samba,"attach" => "style='width:118px;'");
- $field4 = array("string" => preg_replace("/%KEY%/", "$key", $action),"attach" => "style='border:none; text-align:right;width:48px'");
-
+ /* Create each field */
+ $field1 = array("string" => sprintf($tpl,$val['dn']), "attach" => "style='text-align:center;width:20px;'");
+ $field2 = array("string" => sprintf($editlink,$key,$display).$ip_port, "attach" => "style='' title='".$val['dn']."'");
+ $field3 = array("string" => $usrimg2." ".$posix." ".$enviro." ".$maila." ".$fonac." ".$faxac." ".$samba." ".$s_img_create_from_template, "attach" => "style='width:152px;'");
+ $field4 = array("string" => preg_replace("/%KEY%/", "$key", $action),"attach" => "style='width:60px;border-right:0px;text-align:right;'");
+
$add = array($field1,$field2,$field3,$field4);
$add = array($field1,$field2,$field3,$field4);
-
+
// Template or User
if(in_array("gosaUserTemplate",$val['objectClass'])){
$tpls[strtolower( $val['sn']['0'].$val['uid']['0'])]=$add;
// Template or User
if(in_array("gosaUserTemplate",$val['objectClass'])){
$tpls[strtolower( $val['sn']['0'].$val['uid']['0'])]=$add;
$users[strtolower( $val['sn']['0'].$val['uid']['0'])]=$add;
}
}
$users[strtolower( $val['sn']['0'].$val['uid']['0'])]=$add;
}
}
-
+
// Sort Entries
ksort($users);
ksort($tpls);
// Sort Entries
ksort($users);
ksort($tpls);
$smarty->assign("infoimage", get_template_path('images/info.png'));
$smarty->assign("launchimage", get_template_path('images/launch.png'));
$smarty->assign("deplist", $this->config->idepartments);
$smarty->assign("infoimage", get_template_path('images/info.png'));
$smarty->assign("launchimage", get_template_path('images/launch.png'));
$smarty->assign("deplist", $this->config->idepartments);
- foreach( array("depselect", "regex", "functionalusers", "unixusers",
+ foreach( array("depselect", "functionalusers", "unixusers",
"mailusers", "sambausers", "proxyusers",
"faxusers", "templates", "subsearch") as $type){
$smarty->assign("$type", $userfilter[$type]);
}
"mailusers", "sambausers", "proxyusers",
"faxusers", "templates", "subsearch") as $type){
$smarty->assign("$type", $userfilter[$type]);
}
+ $smarty->assign("regex", $userfilter["regex"]);
/* Extend if we are not using javascript */
$smarty->assign("apply", apply_filter());
$smarty->assign("alphabet", generate_alphabet());
$smarty->assign("hint", print_sizelimit_warning());
/* Extend if we are not using javascript */
$smarty->assign("apply", apply_filter());
$smarty->assign("alphabet", generate_alphabet());
$smarty->assign("hint", print_sizelimit_warning());
+ if((is_callable("mysql_close"))&&($r_con)){
+ @mysql_close($r_con);
+ }
return ($smarty->fetch(get_template_path('headpage.tpl', TRUE)));
}
return ($smarty->fetch(get_template_path('headpage.tpl', TRUE)));
}
* We also need to search for the departments
* So we are able to navigate like in konquerer
*/
* We also need to search for the departments
* So we are able to navigate like in konquerer
*/
+
+ /* Create base to search in */
$base2 = preg_replace("/ou=people,/i","",$base);
$base2 = preg_replace("/ou=people,/i","",$base);
+ /* Get all departments within this subtree */
$res3 = get_list2($this->ui->subtreeACL, "(&(|(ou=$regex)(description=$regex))(objectClass=gosaDepartment))",
$res3 = get_list2($this->ui->subtreeACL, "(&(|(ou=$regex)(description=$regex))(objectClass=gosaDepartment))",
- TRUE, $base2, array("ou", "description"), TRUE);
+ TRUE, $base2, array("ou", "description"), TRUE);
$this->departments= array();
$this->departments= array();
+ /* Create array with results */
$tmp = array();
foreach ($res3 as $value){
$tmp[strtolower($value['dn']).$value['dn']]=$value;
}
$tmp = array();
foreach ($res3 as $value){
$tmp[strtolower($value['dn']).$value['dn']]=$value;
}
+
+ /* Sort array */
ksort($tmp);
ksort($tmp);
+
+ /* Create result array */
foreach($tmp as $value){
foreach($tmp as $value){
- if($value["description"][0]!=".."){
+ if(isset($value['description'][0])){
$this->departments[$value['dn']]=convert_department_dn2($value['dn'])." - [".$value["description"][0]."]";
}else{
$this->departments[$value['dn']]=convert_department_dn2($value['dn'])." - [".$value["description"][0]."]";
}else{
- $this->departments[$value['dn']]=$value["description"][0];
+ $this->departments[$value['dn']]=convert_department_dn2($value['dn']);
}
}
/* END NEW LIST MANAGMENT
*/
}
}
/* END NEW LIST MANAGMENT
*/
-
-
+
+
$this->userlist= array();
foreach ($this->list as $value){
$this->userlist= array();
foreach ($this->list as $value){