From: hickert Date: Thu, 11 Aug 2005 07:55:52 +0000 (+0000) Subject: Userlist shows phone ip / onlinetime if possible and mysql db is reachable, X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=4414d1e46e0c8fb6d6d2d12a9774bf1fa813b11c;p=gosa.git Userlist shows phone ip / onlinetime if possible and mysql db is reachable, git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@1104 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/plugins/admin/users/class_userManagement.inc b/plugins/admin/users/class_userManagement.inc index 4d5eb8c7b..ec1d42213 100644 --- a/plugins/admin/users/class_userManagement.inc +++ b/plugins/admin/users/class_userManagement.inc @@ -682,7 +682,7 @@ class userManagement extends plugin $usrimg =""; $posiximg = ""; $mailimg = ""; - $fonimg = ""; + $fonimg = ""; $faximg = ""; $sambaimg = ""; $empty = ""; @@ -696,14 +696,52 @@ class userManagement extends plugin // Defines Arrays to save User and Templates $tpls = array(); $users= array(); + + // Get Configuration + $a_SETUP = $_SESSION['config']->data['SERVERS']['FON']; + // Connect to DB server + $r_con = @mysql_connect($a_SETUP['SERVER'],$a_SETUP['LOGIN'],$a_SETUP['PASSWORD']); + // Check if we are connected correctly + $r_db=false; + 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){ - + $connected = ""; + $ip_port= ""; + if((in_array("goFonAccount" ,$val['objectClass']))){ + $fonac = preg_replace("/%image%/", "select_phone.png", $fonimg); + $fonac = preg_replace("/%KEY%/", "$key", $fonac); + $fonac = preg_replace("/%title%/", "", $fonac); + + if($r_db){ + $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_notconnected.png", $fonimg); + $fonac = preg_replace("/%KEY%/", "$key", $fonac); + $fonac = preg_replace("/%title%/", $connected, $fonac); + } + } + } + }else{ + $fonac=$empty; + } + // Specify Pics for Extensions if(in_array("posixAccount" ,$val['objectClass'])) $posix = preg_replace("/%KEY%/", "$key", $posiximg); else $posix=$empty; if(in_array("gosaMailAccount" ,$val['objectClass'])) $maila = preg_replace("/%KEY%/", "$key", $mailimg); else $maila=$empty; - if(in_array("goFonAccount" ,$val['objectClass'])) $fonac = preg_replace("/%KEY%/", "$key", $fonimg); else $fonac=$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); else $tpl=$userimg; @@ -718,7 +756,7 @@ class userManagement extends plugin } $field1 = array("string" => sprintf($tpl,$val['dn']),"attach"=>"style='width:20px;align:middle;'"); - $field2 = array("string" => sprintf($editlink,$key,$display),"attach"=>"title='".$val['dn']."'"); + $field2 = array("string" => sprintf($editlink,$key,$display).$ip_port,"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'");