From e9587e42feb4f4c449dd304606e751131017e904 Mon Sep 17 00:00:00 2001 From: opensides Date: Wed, 2 Nov 2005 21:45:44 +0000 Subject: [PATCH] added to more extension to connectivity pptp and phpscheduleit some more finishing touch to the xls plugin git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@1799 594d385d-05f5-0310-b6e9-bd551577e9d8 --- AUTHORS | 3 +- contrib/gosa.conf | 4 +- contrib/opensides/README.OpenSides | 8 +- contrib/opensides/nagios.README | 6 +- contrib/opensides/phpscheduleit.README | 10 ++ contrib/opensides/pptp.README | 13 ++ contrib/opensides/xls-export.README | 5 +- html/getxls.php | 108 +++++++++++----- .../addons/ldapmanager/class_exportxls.inc | 8 +- .../class_phpscheduleitAccount.inc | 117 ++++++++++++++++++ .../connectivity/class_pptpAccount.inc | 117 ++++++++++++++++++ .../personal/connectivity/phpscheduleit.tpl | 1 + plugins/personal/connectivity/pptp.tpl | 1 + 13 files changed, 362 insertions(+), 39 deletions(-) create mode 100644 contrib/opensides/phpscheduleit.README create mode 100644 contrib/opensides/pptp.README create mode 100644 plugins/personal/connectivity/class_phpscheduleitAccount.inc create mode 100644 plugins/personal/connectivity/class_pptpAccount.inc create mode 100644 plugins/personal/connectivity/phpscheduleit.tpl create mode 100644 plugins/personal/connectivity/pptp.tpl diff --git a/AUTHORS b/AUTHORS index d0ba52ddf..4ec33b383 100644 --- a/AUTHORS +++ b/AUTHORS @@ -18,7 +18,8 @@ documentation and additional help. Fixes for magic_quotes_qpc * Guillaume Delecourt - Setup fixes, nagios tab plugin + Setup fixes, nagios tab plugin, xls addons ldapmanager + pptp connectivity option, phpscheduleit connectivity option * Dan Ellis Sieve lib is taken from him diff --git a/contrib/gosa.conf b/contrib/gosa.conf index 2cf870ffe..ad943ced9 100644 --- a/contrib/gosa.conf +++ b/contrib/gosa.conf @@ -71,8 +71,8 @@ - + @@ -164,6 +164,8 @@ + + diff --git a/contrib/opensides/README.OpenSides b/contrib/opensides/README.OpenSides index 339cfe04b..cfd845342 100644 --- a/contrib/opensides/README.OpenSides +++ b/contrib/opensides/README.OpenSides @@ -7,9 +7,13 @@ goNagios.pl - This script will help you to manage the authentification slapd.conf - The slapd.conf confg for openldap 2.2 -nagios.README - how to add the right entry to make the nagios plugin work +nagios.README - how to make the nagios plugin work -xls-export.README - how to add the right entry to make the xls export xork +pptp.README - how to make the pptp connectivity extension work + +phpscheduleit.README - how to make the phpscheduleit extension work + +xls-export.README - how to make the xls export xork The php_writeexcel library is coming from diff --git a/contrib/opensides/nagios.README b/contrib/opensides/nagios.README index dfcbdbc49..beec8e5a2 100644 --- a/contrib/opensides/nagios.README +++ b/contrib/opensides/nagios.README @@ -1,4 +1,8 @@ -To use the nagios plugin remove the comment in front of nagios in gosa.conf +To use the nagios plugin + +1) Add the nagios schema to your schema directory + +2) Remove the comment in front of nagiosAccount in gosa.conf diff --git a/contrib/opensides/phpscheduleit.README b/contrib/opensides/phpscheduleit.README new file mode 100644 index 000000000..4b634c865 --- /dev/null +++ b/contrib/opensides/phpscheduleit.README @@ -0,0 +1,10 @@ +To use the phpscheduleit connectivity extension + +1) Add the schema phpscheduleit.schema in your schema directory + +2) Remove the comment in front of phpscheduleitAccount in gosa.conf + + + +Guillaume Delecourt +OpenSides November 2005 diff --git a/contrib/opensides/pptp.README b/contrib/opensides/pptp.README new file mode 100644 index 000000000..556e274f4 --- /dev/null +++ b/contrib/opensides/pptp.README @@ -0,0 +1,13 @@ +To use the pptp connectivity extension + +1) Add the pptp.schema to your schema directory + +2) Remove the comment in front of pptpAccount in gosa.conf + + + +Guillaume Delecourt +OpenSides November 2005 + + + diff --git a/contrib/opensides/xls-export.README b/contrib/opensides/xls-export.README index 6cb3e08eb..e9b06069e 100644 --- a/contrib/opensides/xls-export.README +++ b/contrib/opensides/xls-export.README @@ -1,6 +1,7 @@ -To use the xls export addon uncomment the following line in your gosa.conf : +To use the xls export ldapamanager addon uncomment the following line in your gosa.conf : -Guillaume +Guillaume Delecourt +Vincent Seynhaeve OpenSides October 2005 diff --git a/html/getxls.php b/html/getxls.php index b54d38628..b7590a3f8 100644 --- a/html/getxls.php +++ b/html/getxls.php @@ -34,18 +34,29 @@ function dump_ldap ($mode= 0) if($mode == 2){ // Single Entry Export ! $d = base64_decode($_GET['d']); $n = base64_decode($_GET['n']); - // print_r($_GET); $dn=$d.$n; - // echo $dn ; + $date=date('dS \of F Y '); $fname = tempnam("/tmp", "demo.xls"); $workbook=& new writeexcel_workbook($fname); + $title_title=& $workbook->addformat(array( + bold => 1, + color => 'green', + size => 11, + underline => 2, + font => 'Helvetica' + )); + $title_bold=& $workbook->addformat(array( bold => 1, color => 'black', size => 10, font => 'Helvetica' )); + # Create a format for the phone numbers + $f_phone =& $workbook->addformat(); + $f_phone->set_align('left'); + $f_phone->set_num_format('\0#'); switch ($d){ @@ -53,12 +64,15 @@ function dump_ldap ($mode= 0) $user= $ldap->gen_xls($dn,"(objectClass=*)",array("uid","dateOfBirth","gender","givenName","preferredLanguage")); $intitul=array(_("Birthday").":", _("Sexe").":", _("Name")."/"._("Firstname").":",_("Language").":"); + //name of the xls file + $name_section=_("Users"); + $worksheet=& $workbook->addworksheet(_("Users")); - $worksheet->set_column('A:B', 32); - + $worksheet->set_column('A:B', 51); $user_nbr=count($user); - $r=1; + $worksheet->write('A1',_("User List of ").$n._(" on ").$date,$title_title); + $r=3; for($i=1;$i<$user_nbr;$i++) { if($i>1) @@ -69,6 +83,7 @@ function dump_ldap ($mode= 0) { $r++; $worksheet->write('A'.$r,$intitul[$j-1]); + $user[$i][$j]=utf8_decode ($user[$i][$j]); $worksheet->write('B'.$r,$user[$i][$j]); } $worksheet->write('A'.$r++,""); @@ -77,12 +92,17 @@ function dump_ldap ($mode= 0) case "ou=groups,": $groups= $ldap->gen_xls($dn,"(objectClass=*)",array("cn","memberUid"),TRUE,1); $intitul=array(_("Members").":"); + + //name of the xls file + $name_section=_("Groups"); + $worksheet =& $workbook->addworksheet(_("Groups")); - $worksheet->set_column('A:B', 32); + $worksheet->set_column('A:B', 51); //count number of groups $groups_nbr=count($groups); - $r=1; + $worksheet->write('A1',_("Groups of ").$n._(" on ").$date,$title_title); + $r=3; for($i=1;$i<$groups_nbr;$i++) { $worksheet->write('A'.$r++,_("User ID").": ".$groups[$i][0][0],$title_bold); @@ -103,7 +123,6 @@ function dump_ldap ($mode= 0) $intitul=array(_("Description").":",_("User ID").":"); $worksheet =& $workbook->addworksheet(_("Computers")); $worksheet->set_column('A:B', 32); - //count number of computers $computers_nbr=count($computers); $r=1; @@ -116,6 +135,7 @@ function dump_ldap ($mode= 0) { $r++; $worksheet->write('A'.$r,$intitul[$j-1]); + $computers[$i][$j]=utf8_decode ($computers[$i][$j]); $worksheet->write('B'.$r,$computers[$i][$j]); } $worksheet->write('A'.$r++,""); @@ -125,12 +145,16 @@ function dump_ldap ($mode= 0) case "ou=servers,ou=systems,": $servers= $ldap->gen_xls($dn,"(objectClass=*)",array("cn")); $intitul=array(_("Server Name").":"); + //name of the xls file + $name_section=_("Servers"); + $worksheet =& $workbook->addworksheet(_("Servers")); - $worksheet->set_column('A:B', 32); + $worksheet->set_column('A:B', 51); //count number of servers $servers_nbr=count($servers); - $r=1; + $worksheet->write('A1',_("Servers of ").$n._(" on ").$date,$title_title); + $r=3; $worksheet->write('A'.$r++,_("Servers").": ",$title_bold); for($i=1;$i<$servers_nbr;$i++) { @@ -138,6 +162,7 @@ function dump_ldap ($mode= 0) { $r++; $worksheet->write('A'.$r,$intitul[$j]); + $servers[$i][$j]=utf8_decode ($servers[$i][$j]); $worksheet->write('B'.$r,$servers[$i][$j]); } } @@ -147,13 +172,17 @@ function dump_ldap ($mode= 0) $address= $ldap->gen_xls($dn,"(objectClass=*)",array("cn","displayName","facsimileTelephoneNumber","givenName","homePhone","homePostalAddress","initials","l","mail","mobile","o","ou","pager","telephoneNumber","postalAddress","postalCode","sn","st","title")); $intitul=array(_("Common name").":",_("Display Name").":",_("Fax").":",_("Name")."/"._("Firstname").":",_("Home phone").":",_("Home postal address").":",_("Initials").":",_("Location").":",_("Mail address").":",_("Mobile phone").":",_("City").":",_("Postal address").":",_("Pager").":",_("Phone number").":",_("Adress").":",_("Postal code").":",_("Surename").":",_("State").":",_("Function").":"); + + //name of the xls file + $name_section=_("Adressbook"); $worksheet =& $workbook->addworksheet(_("Servers")); - $worksheet->set_column('A:B', 32); + $worksheet->set_column('A:B', 51); //count number of entries $address_nbr=count($address); - $r=1; + $worksheet->write('A1',_("Adressbook of ").$n._(" on ").$date,$title_title); + $r=3; for($i=1;$i<$address_nbr;$i++) { if($i>1) @@ -163,7 +192,8 @@ function dump_ldap ($mode= 0) { $r++; $worksheet->write('A'.$r,$intitul[$j]); - $worksheet->write('B'.$r,$address[$i][$j]); + $address[$i][$j]=utf8_decode ($address[$i][$j]); + $worksheet->write('B'.$r,$address[$i][$j],$f_phone); } $worksheet->write('A'.$r++,""); } @@ -180,7 +210,7 @@ function dump_ldap ($mode= 0) header('Content-type: application/x-msexcel'); // It will be called demo.xls - header('Content-Disposition: attachment; filename="demo.xls"'); + header('Content-Disposition: attachment; filename='.$name_section.".xls"); // The source is in original.xls readfile($fname); @@ -205,7 +235,9 @@ function dump_ldap ($mode= 0) $address= $ldap->gen_xls("dc=addressbook,".$dn,"(objectClass=*)",array("cn","displayName","facsimileTelephoneNumber","givenName","homePhone","homePostalAddress","initials","l","mail","mobile","o","ou","pager","telephoneNumber","postalAddress","postalCode","sn","st","title")); $address_intitul=array("cn",_("DisplayName").":",_("Fax").":",_("Name")."/"._("Firstname").":",_("Phone Number").":",_("Postal Adress").":",_("Initials").":",_("City").":",_("Email address").":",_("mobile").":",_("Organization").":",_("Organizational Unit").":",_("Pager").":",_("Phone Number").":",_("Postal Address").":",_("Postal Code").":",_("Sn").":",_("st").":",_("Title").":"); - + //name of the xls file + $name_section=_("Full"); + $date=date('dS \of F Y '); $fname = tempnam("/tmp", "demo.xls"); $workbook =& new writeexcel_workbook($fname); $worksheet =& $workbook->addworksheet(_("Users")); @@ -214,11 +246,18 @@ function dump_ldap ($mode= 0) $worksheet4 =& $workbook->addworksheet(_("Computers")); $worksheet5 =& $workbook->addworksheet(_("Adressbook")); - $worksheet->set_column('A:B', 32); - $worksheet2->set_column('A:B', 32); - $worksheet3->set_column('A:B', 32); - $worksheet4->set_column('A:B', 32); - $worksheet5->set_column('A:B', 32); + $worksheet->set_column('A:B', 51); + $worksheet2->set_column('A:B', 51); + $worksheet3->set_column('A:B', 51); + $worksheet4->set_column('A:B', 51); + $worksheet5->set_column('A:B', 51); + + $title_title=& $workbook->addformat(array( + bold => 1, + color => 'green', + size => 11, + font => 'Helvetica' + )); $title_bold =& $workbook->addformat(array( bold => 1, @@ -227,10 +266,15 @@ function dump_ldap ($mode= 0) font => 'Helvetica' )); + # Create a format for the phone numbers + $f_phone =& $workbook->addformat(); + $f_phone->set_align('left'); + $f_phone->set_num_format('\0#'); //count number of users $user_nbr=count($user); - $r=1; + $worksheet->write('A1',_("User List of ").$dn._(" on ").$date,$title_title); + $r=3; for($i=1;$i<$user_nbr;$i++) { if($i>1) @@ -240,6 +284,7 @@ function dump_ldap ($mode= 0) { $r++; $worksheet->write('A'.$r,$user_intitul[$j-1]); + $user[$i][$j]=utf8_decode ($user[$i][$j]); $worksheet->write('B'.$r,$user[$i][$j]); } $worksheet->write('A'.$r++,""); @@ -247,7 +292,8 @@ function dump_ldap ($mode= 0) //count number of groups $groups_nbr=count($groups); - $r=1; + $worksheet2->write('A1',_("Groups of ").$dn._(" on ").$date,$title_title); + $r=3; for($i=1;$i<$groups_nbr;$i++) { $worksheet2->write('A'.$r++,_("User ID").": ".$groups[$i][0][0],$title_bold); @@ -265,7 +311,8 @@ function dump_ldap ($mode= 0) //count number of servers $servers_nbr=count($servers); - $r=1; + $worksheet3->write('A1',_("Servers of ").$dn._(" on ").$date,$title_title); + $r=3; $worksheet3->write('A'.$r++,_("Servers").": ",$title_bold); for($i=1;$i<$servers_nbr;$i++) { @@ -273,13 +320,15 @@ function dump_ldap ($mode= 0) { $r++; $worksheet3->write('A'.$r,$servers_intitul[$j]); + $servers[$i][$j]=utf8_decode ($servers[$i][$j]); $worksheet3->write('B'.$r,$servers[$i][$j]); } } //count number of computers $computers_nbr=count($computers); - $r=1; + $worksheet4->write('A1',_("Computers of ").$dn._(" on ").$date,$title_title); + $r=3; for($i=1;$i<$computers_nbr;$i++) { if($i>1) @@ -289,6 +338,7 @@ function dump_ldap ($mode= 0) { $r++; $worksheet4->write('A'.$r,$computers_intitul[$j-1]); + $computers[$i][$j]=utf8_decode ($computers[$i][$j]); $worksheet4->write('B'.$r,$computers[$i][$j]); } $worksheet4->write('A'.$r++,""); @@ -296,7 +346,9 @@ function dump_ldap ($mode= 0) //count number of entries $address_nbr=count($address); - $r=1; + $worksheet5->write('A1',_("Adressbook of ").$dn._(" on ").$date,$title_title); + + $r=3; for($i=1;$i<$address_nbr;$i++) { if($i>1) @@ -306,7 +358,8 @@ function dump_ldap ($mode= 0) { $r++; $worksheet5->write('A'.$r,$address_intitul[$j]); - $worksheet5->write('B'.$r,$address[$i][$j]); + $address[$i][$j]=utf8_decode ($address[$i][$j]); + $worksheet5->write('B'.$r,$address[$i][$j],$f_phone); } $worksheet5->write('A'.$r++,""); } @@ -317,9 +370,8 @@ function dump_ldap ($mode= 0) header('Content-type: application/x-msexcel'); // It will be called demo.xls - header('Content-Disposition: attachment; filename="demo.xls"'); + header('Content-Disposition: attachment; filename='.$name_section.".xls"); - // The PDF source is in original.xl readfile($fname); unlink ($fname); diff --git a/plugins/addons/ldapmanager/class_exportxls.inc b/plugins/addons/ldapmanager/class_exportxls.inc index d41bea08d..f3c1d3cc2 100644 --- a/plugins/addons/ldapmanager/class_exportxls.inc +++ b/plugins/addons/ldapmanager/class_exportxls.inc @@ -4,7 +4,7 @@ class xlsexport extends plugin { /* Definitions */ - var $plHeadline= "XLS export"; + var $plHeadline= "XLS import"; var $plDescription= "This does something"; var $access= ""; @@ -19,7 +19,7 @@ class xlsexport extends plugin $ui= get_userinfo(); $acl= get_permissions ($config->current['BASE'], $ui->subtreeACL); - $acl= get_module_permission($acl, "xlsexport", $config->current['BASE']); + $acl= get_module_permission($acl, "ldifexport", $config->current['BASE']); $this->access= $acl; } @@ -32,7 +32,7 @@ class xlsexport extends plugin /* Check permissions for export */ if ($this->access != '#all#'){ - print_red(_("You've no permission to do XLS exports.")); + print_red(_("You've no permission to do LDAP exports.")); } else { // fill in old vars in the Export form if((isset($_POST['single']))&&(isset($_POST['sfrmgetsingle']))){ @@ -85,7 +85,7 @@ class xlsexport extends plugin print_red (_("Error while exporting the requested entries!")); } } - +// print_r($_POST); // Export a single LDAP entry if(isset($_POST['sfrmgetsingle'])) { diff --git a/plugins/personal/connectivity/class_phpscheduleitAccount.inc b/plugins/personal/connectivity/class_phpscheduleitAccount.inc new file mode 100644 index 000000000..101570562 --- /dev/null +++ b/plugins/personal/connectivity/class_phpscheduleitAccount.inc @@ -0,0 +1,117 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $attributes= array(); + var $objectclasses= array("phpscheduleitAccount"); + + function phpscheduleitAccount ($config, $dn= NULL) + { + plugin::plugin ($config, $dn); + } + + function execute() + { + /* Show tab dialog headers */ + $display= ""; + + /* Show main page */ + $smarty= get_smarty(); + + if ($this->is_account){ + $smarty->assign("phpscheduleitState", "checked"); + } else { + $smarty->assign("phpscheduleitState", ""); + $smarty->assign("wstate", "disabled"); + } + + if ($this->parent != NULL){ + $smarty->assign("tabbed", 1); + } + + $smarty->assign('gosaphpscheduleitACL', chkacl($this->acl, 'gosaphpscheduleit')); + + $display.= $smarty->fetch (get_template_path('phpscheduleit.tpl', TRUE, dirname(__FILE__))); + return ($display); + } + + function remove_from_parent() + { + /* Cancel if there's nothing to do here */ + if (!$this->initially_was_account){ + return; + } + + plugin::remove_from_parent(); + $ldap= $this->config->get_ldap_link(); + + $ldap->cd($this->dn); + @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, + $this->attributes, "Save"); + $ldap->modify($this->attrs); + show_ldap_error($ldap->get_error()); + + /* Optionally execute a command after we're done */ + $this->handle_post_events('remove'); + } + + + /* Save data to object */ + function save_object() + { + /* Do we need to flip is_account state? */ + if (isset($_POST['connectivityTab'])){ + if (isset($_POST['phpscheduleit'])){ + if (!$this->is_account && $_POST['phpscheduleit'] == "B"){ + $this->is_account= TRUE; + } + } else { + $this->is_account= FALSE; + } + } + + plugin::save_object(); + if (isset($_POST["phpscheduleitStatus"])){ + $this->pptpStatus = "disabled"; + } else { + $this->pptpStatus = "enabled"; + } + } + + + /* Save to LDAP */ + function save() + { + plugin::save(); + + /* Write back to ldap */ + $ldap= $this->config->get_ldap_link(); + $ldap->cd($this->dn); + $ldap->modify($this->attrs); + show_ldap_error($ldap->get_error()); + + /* Optionally execute a command after we're done */ + if ($this->initially_was_account == $this->is_account){ + if ($this->is_modified){ + $this->handle_post_events("mofify"); + } + } else { + $this->handle_post_events("add"); + } + + } + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/plugins/personal/connectivity/class_pptpAccount.inc b/plugins/personal/connectivity/class_pptpAccount.inc new file mode 100644 index 000000000..e98bb781a --- /dev/null +++ b/plugins/personal/connectivity/class_pptpAccount.inc @@ -0,0 +1,117 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $attributes= array(); + var $objectclasses= array("pptpServerAccount"); + + function pptpAccount ($config, $dn= NULL) + { + plugin::plugin ($config, $dn); + } + + function execute() + { + /* Show tab dialog headers */ + $display= ""; + + /* Show main page */ + $smarty= get_smarty(); + + if ($this->is_account){ + $smarty->assign("pptpState", "checked"); + } else { + $smarty->assign("pptpState", ""); + $smarty->assign("wstate", "disabled"); + } + + if ($this->parent != NULL){ + $smarty->assign("tabbed", 1); + } + + $smarty->assign('gosapptpACL', chkacl($this->acl, 'gosapptp')); + + $display.= $smarty->fetch (get_template_path('pptp.tpl', TRUE, dirname(__FILE__))); + return ($display); + } + + function remove_from_parent() + { + /* Cancel if there's nothing to do here */ + if (!$this->initially_was_account){ + return; + } + + plugin::remove_from_parent(); + $ldap= $this->config->get_ldap_link(); + + $ldap->cd($this->dn); + @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, + $this->attributes, "Save"); + $ldap->modify($this->attrs); + show_ldap_error($ldap->get_error()); + + /* Optionally execute a command after we're done */ + $this->handle_post_events('remove'); + } + + + /* Save data to object */ + function save_object() + { + /* Do we need to flip is_account state? */ + if (isset($_POST['connectivityTab'])){ + if (isset($_POST['pptp'])){ + if (!$this->is_account && $_POST['pptp'] == "B"){ + $this->is_account= TRUE; + } + } else { + $this->is_account= FALSE; + } + } + + plugin::save_object(); + if (isset($_POST["pptpStatus"])){ + $this->pptpStatus = "disabled"; + } else { + $this->pptpStatus = "enabled"; + } + } + + + /* Save to LDAP */ + function save() + { + plugin::save(); + + /* Write back to ldap */ + $ldap= $this->config->get_ldap_link(); + $ldap->cd($this->dn); + $ldap->modify($this->attrs); + show_ldap_error($ldap->get_error()); + + /* Optionally execute a command after we're done */ + if ($this->initially_was_account == $this->is_account){ + if ($this->is_modified){ + $this->handle_post_events("mofify"); + } + } else { + $this->handle_post_events("add"); + } + + } + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/plugins/personal/connectivity/phpscheduleit.tpl b/plugins/personal/connectivity/phpscheduleit.tpl new file mode 100644 index 000000000..f3ca92638 --- /dev/null +++ b/plugins/personal/connectivity/phpscheduleit.tpl @@ -0,0 +1 @@ +

{if $tabbed eq 1}{/if}{t}PHPscheduleit account{/t}

diff --git a/plugins/personal/connectivity/pptp.tpl b/plugins/personal/connectivity/pptp.tpl new file mode 100644 index 000000000..70e9958a6 --- /dev/null +++ b/plugins/personal/connectivity/pptp.tpl @@ -0,0 +1 @@ +

{if $tabbed eq 1}{/if}{t}PPTP Server account{/t}

-- 2.30.2