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 185 186 187
|
<?php
class goTerminalServer extends goService{
/* This plugin only writes its objectClass */
var $objectclasses = array("goTerminalServer");
var $attributes = array("goXdmcpIsEnabled","gotoSessionType");
var $StatusFlag = "goTerminalServerStatus";
/* This class can't be assigned twice so it conflicts with itsself */
var $conflicts = array("goTerminalServer");
var $DisplayName = "";
var $dn = NULL;
var $acl;
var $cn = "";
var $goTerminalServerStatus = "";
var $goXdmcpIsEnabled = false;
var $view_logged = FALSE;
var $gotoSessionType = array();
function __construct(&$config,$dn)
{
goService::__construct($config,$dn);
$this->DisplayName = _("Terminal service");
$tmp = array();
if(isset($this->attrs['gotoSessionType'])){
for($i =0; $i < $this->attrs['gotoSessionType']['count'] ; $i++){
$tmp[] = $this->attrs['gotoSessionType'][$i];
}
}
$this->gotoSessionType = $tmp;
#$this->gotoSessionTypes= array("LDM","XDMCP","RDP","CITRIX");
$this->gotoSessionTypes= array("LDM","XDMCP", "SHELL", "RDP", "TELNET");
}
function execute()
{
$smarty = get_smarty();
if($this->is_account && !$this->view_logged){
$this->view_logged = TRUE;
new log("view","server/".get_class($this),$this->dn);
}
$tmp = $this->plinfo();
foreach($tmp['plProvidedAcls'] as $name => $translation){
$smarty->assign($name."ACL",$this->getacl($name));
}
foreach($this->attributes as $attr){
$smarty->assign($attr, set_post($this->$attr));
}
$tmp = array();
foreach($this->gotoSessionTypes as $type){
if(in_array_strict($type,$this->gotoSessionType)){
$tmp[$type] = TRUE;
}else{
$tmp[$type] = FALSE;
}
}
$smarty->assign("gotoSessionTypes", set_post($tmp));
return($smarty->fetch(get_template_path("goTerminalServer.tpl",TRUE,dirname(__FILE__))));
}
function getListEntry()
{
$fields = goService::getListEntry();
$fields['Message'] = _("Terminal service");
#$fields['AllowEdit'] = true;
return($fields);
}
function save()
{
plugin::save();
if(!$this->goXdmcpIsEnabled){
$this->attrs['goXdmcpIsEnabled'] = "0";
}
$this->attrs['gotoSessionType'] = array_values($this->gotoSessionType);
/* Check if this is a new entry ... add/modify */
$ldap = $this->config->get_ldap_link();
$ldap->cat($this->dn,array("objectClass"));
if($ldap->count()){
$ldap->cd($this->dn);
$ldap->modify($this->attrs);
}else{
$ldap->cd($this->dn);
$ldap->add($this->attrs);
}
if (!$ldap->success()){
msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, 0, get_class()));
}
if($this->initially_was_account){
$this->handle_post_events("modify");
new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
}else{
$this->handle_post_events("add");
new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
}
}
function check()
{
$message = plugin::check();
return($message);
}
function save_object()
{
if(isset($_POST['goTerminalServerPosted'])){
plugin::save_object();
$this->gotoSessionType = array();
foreach($this->gotoSessionTypes as $attr){
if(isset($_POST['gotoSessionType_'.$attr])){
$this->gotoSessionType[] = $attr;
}
}
if($this->acl_is_writeable("goXdmcpIsEnabled")){
if(isset($_POST['goXdmcpIsEnabled'])){
$this->goXdmcpIsEnabled = true;
}else{
$this->goXdmcpIsEnabled = false;
}
}
}
}
function PrepareForCopyPaste($obj)
{
plugin::PrepareForCopyPaste($obj);
$tmp = array();
if(isset($obj['gotoSessionType'])){
for($i =0; $i < $obj['gotoSessionType']['count'] ; $i++){
$tmp[] = $obj['gotoSessionType'][$i];
}
}
$this->gotoSessionType = $tmp;
#$this->gotoSessionTypes= array("LDM","XDMCP","RDP","CITRIX");
$this->gotoSessionTypes= array("LDM","XDMCP", "SHELL", "TELNET");
}
/* Return plugin informations for acl handling */
static function plInfo()
{
return (array(
"plShortName" => _("Terminal service"),
"plDescription" => _("Terminal service")." ("._("Services").")",
"plSelfModify" => FALSE,
"plDepends" => array(),
"plPriority" => 87,
"plSection" => array("administration"),
"plRequirements"=> array(
'ldapSchema' => array('goTerminalServer' => '>=2.7'),
'onFailureDisablePlugin' => array(get_class())
),
"plCategory" => array("server"),
"plProvidedAcls"=> array(
"start" => _("Start"),
"stop" => _("Stop"),
"restart" => _("Restart"),
"goXdmcpIsEnabled" => _("Temporary disable login"))
));
}
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>
|