1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184
|
<?php
class terminfo extends plugin
{
/* Generic terminal attributes */
var $ghCpuType= "-";
var $ghMemSize= "-";
var $macAddress= "-";
var $ghUsbSupport= "-";
var $ghNetNic= array();
var $ghIdeDev= array();
var $ghScsiDev= array();
var $ghGfxAdapter= "-";
var $ghSoundAdapter= "-";
var $ghInventoryNumber= "-";
var $gotoLastUser= "-";
var $gotoFloppyEnable= "";
var $gotoCdromEnable= "";
/* Needed values and lists */
var $base= "";
var $cn= "";
var $view_logged = FALSE;
/* attribute list for save action */
var $ignore_account= TRUE;
var $attributes= array("cn", "gotoMode", "gotoTerminalPath", "gotoFloppyEnable",
"gotoCdromEnable", "ghInventoryNumber",
"gotoSwapServer", "gotoSyslogServer", "gotoNtpServer",
"ghCpuType", "ghMemSize", "macAddress", "ghUsbSupport",
"ghGfxAdapter", "ghSoundAdapter", "gotoLastUser");
var $objectclasses= array("GOhard");
function __construct(&$config, $dn= NULL, $parent= NULL)
{
plugin::__construct ($config,$dn);
/* Read arrays */
foreach (array("ghNetNic", "ghIdeDev", "ghScsiDev") as $val){
if (!isset($this->attrs[$val])){
continue;
}
for ($i= 0; $i<$this->attrs[$val]['count']; $i++){
array_push($this->$val, $this->attrs[$val][$i]);
}
}
/* Fix USB entry */
if ($this->ghUsbSupport == "true"){
$this->ghUsbSupport= _("present");
}
}
function execute()
{
/* Call parent execute */
plugin::execute();
if($this->is_account && !$this->view_logged){
$this->view_logged = TRUE;
new log("view","terminal/".get_class($this),$this->dn);
}
/* Do we represent a valid terminal? */
if (!$this->is_account && $this->parent === NULL){
return("<img alt=\"\" src=\"images/small-error.png\" align=middle> <b>".
msgPool::noValidExtension(_("terminal"))."</b>");
}
$smarty= get_smarty();
$display= "";
$smarty->assign("ACL",TRUE);
if(!preg_match("/r/",$this->getacl(""))){
$smarty->assign("ACL",FALSE);
}elseif(!is_callable("snmpget")){
$smarty->assign("load", progressbar(0,100,15,true));
$smarty->assign("mem", progressbar(0,100,15,true));
$smarty->assign("swap", progressbar(0,100,15,true));
foreach(array("uptime", "sshd", "X", "saned", "artsd", "cupsd","status","ghNetNic", "ghIdeDev", "ghScsiDev","FloppyDevice", "CdromDevice","active") as $val){
$smarty->assign("$val", "<i>"._("unknown status, SNMP support missing")."</i>");
}
$display ="";
}else
/* Default entry? */
if ($this->cn == "default"){
$display= "<div style='height:150px;'><br><b>";
$display.= _("This is a virtual terminal which has no properties to show here.");
$display.= "</b></div>";
} else {
/* Get template object */
/* Prevent undefined variable .... */
$smarty->assign("load", progressbar(0,100,15,true));
$smarty->assign("mem", progressbar(0,100,15,true));
$smarty->assign("swap", progressbar(0,100,15,true));
/* Check if terminal is online - due to lack of the daemon consider offline */
$smarty->assign("status", _("off-line"));
$smarty->assign("active", "false");
/* Set floppy and cdrom status */
foreach(array("Floppy", "Cdrom") as $val){
$name= "goto".$val."Enable";
if ($this->$name == "YES"){
$status= _("present");
} else {
$status= "-";
}
$smarty->assign($val."Device", $status);
}
/* Show main page */
foreach(array("ghNetNic", "ghIdeDev", "ghScsiDev") as $val){
if (!count($this->$val)){
$this->$val= "-";
}
$smarty->assign($val, $this->$val);
}
}
foreach(array("ghCpuType", "ghMemSize", "macAddress", "ghUsbSupport",
"ghGfxAdapter", "ghSoundAdapter", "gotoLastUser", "ghInventoryNumber") as $val){
$smarty->assign($val, $this->$val);
}
$display= $smarty->fetch (get_template_path('info.tpl', TRUE, dirname(__FILE__)));
return ($display);
}
function remove_from_parent()
{
}
/* Save data to object */
function save_object()
{
plugin::save_object();
}
/* Save to LDAP */
function save()
{
}
/* Return plugin informations for acl handling */
static function plInfo()
{
return (array(
"plShortName" => _("System info"),
"plDescription" => _("System informations"),
"plSelfModify" => FALSE,
"plDepends" => array(),
"plPriority" => 33,
"plSection" => array("administration"),
"plCategory" => array("workstation","server","terminal"),
"plProperties" => array(
array(
"name" => "snmpCommunity",
"type" => "string",
"default" => "",
"description" => _("Name of GOto SNMP community."),
"check" => "gosaProperty::isString",
"migrate" => "",
"group" => "plugin",
"mandatory" => FALSE
)
),
"plProvidedAcls"=> array()
));
}
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>
|