From cfbceb2677a4884ab5bd84171a9c6bfd8254c83f Mon Sep 17 00:00:00 2001 From: cajus Date: Fri, 2 Nov 2007 11:12:32 +0000 Subject: [PATCH] Added playground git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6-playground@7713 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa.conf | 119 ++++++++++++++++++++ include/autoload-data.inc | 14 +++ include/autoload.inc | 40 +++++++ include/class_ConfigManager.inc | 86 +++++++++++++++ include/class_LdapAttributeFactory.inc | 3 + include/class_LdapManager.inc | 3 + include/class_LdapObject.inc | 3 + include/class_ObjectList.inc | 145 +++++++++++++++++++++++++ include/class_ObjectListIterator.inc | 78 +++++++++++++ include/class_ObjectListViewport.inc | 120 ++++++++++++++++++++ include/class_Registry.inc | 30 +++++ test | 28 +++++ update-gosa | 81 ++++++++++++++ 13 files changed, 750 insertions(+) create mode 100644 gosa.conf create mode 100644 include/autoload-data.inc create mode 100644 include/autoload.inc create mode 100644 include/class_ConfigManager.inc create mode 100644 include/class_LdapAttributeFactory.inc create mode 100644 include/class_LdapManager.inc create mode 100644 include/class_LdapObject.inc create mode 100644 include/class_ObjectList.inc create mode 100644 include/class_ObjectListIterator.inc create mode 100644 include/class_ObjectListViewport.inc create mode 100644 include/class_Registry.inc create mode 100755 test create mode 100755 update-gosa diff --git a/gosa.conf b/gosa.conf new file mode 100644 index 000000000..c03ca2a98 --- /dev/null +++ b/gosa.conf @@ -0,0 +1,119 @@ +; This is a gosa.conf sample configuration file. All values - except ldap* - can be +; overloaded by an LDAP based configuration. + +;------------------------------------------------------------------------------ + +; GONICUS GmbH configuration. Most features directly in the configuration. + +[gonicus] + +; Location configuration +display-name = "GONICUS GmbH" +language = "de" +timezone = "Europe/Berlin" + +; Basic settings +config = "ou=gosa,ou=configs,ou=systems,dc=gonicus,dc=de" +compile-dir = "/var/spool/gosa" + +; Debugging/Reporting +debug-level = DEBUG_LDAP +visible-errors = true + +; Optimizing +compressed-output = true + +; Session relevant settings +session-lifetime = 4711 +session-restore = true + +; Display relevant settings +list-summary = true +theme = "default" + +; Checks if GOsa should take care about your security. ignore, warn, force are allowed values. +ssl-mode = "ignore" + +; Snapshot objects +enable-snapshots = true +snapshot="ldap://ldap01.gonicus.de/dc=snapshots" +snapshot-admin="cn=ldapadmin,dc=gonicus,dc=de" +snapshot-password="secret" + +; LDAP definition +ldap = "ldap://ldap01.gonicus.de/dc=gonicus,dc=de" +ldap-admin = "cn=ldapadmin,dc=gonicus,dc=de" +ldap-password = "secret" + +ldap2 = "ldap://ldap02.gonicus.de/dc=intranet,dc=gonicus,dc=de" +ldap2-admin = "cn=ldapadmin,dc=intranet,dc=gonicus,dc=de" +ldap2-password = "secret" +ldap2-mode = "tls" + +;------------------------------------------------------------------------------ + +; LHM configuration. Most features in LDAP. + +[lhm] +display-name = "Landeshauptstadt München" +ldap = "ldap://ldap01.muenchen.de/o=Landeshauptstadt München,c=de" +ldap-admin = "cn=ldapadmin,c=de" +ldap-password = "secret" + +;------------------------------------------------------------------------------ + +; Global plugin pre-configuration + +[plugin/generic] +id-gen = "/usr/local/bin/idgen" +strict-ids = true +dn-attribute = "cn" +personal-title-in-dn = false +base = "ou=people" + +[plugin/groups] +rfc2307bis = false +base = "ou=groups" + +[plugin/departments] +honour-unit-tagging = false + +[plugin/unix] +primary-group-filter = false +check = "/usr/local/bin/check_unix.sh" +postcreate = "/usr/local/bin/postcreate_unix.sh" +uid-base = 1000 +gid-base = 1000 +min-id = 100 +;base-hook = + +[plugin/samba] +enable = false +samba-version = 3 +rid-base = 1000 +sid = 0815-4711 +hash-generator = "/usr/bin/mkntpasswd" +id-mapping = true + +[plugin/mail] +mail-method = +cyrus-unix-style = true + +[plugin/password] +use-sasl-for-kerberos = true +disable-methods = "clear,crypt" +default-hash = "md5" +password-minimal-length = 10 +password-minimal-differ = 3 +password-policy-checker = "/usr/local/bin/policy-checker.sh" +allow-auth-by-mail = false + +[plugin/network] +auto-detect = "/usr/local/bin/autodetect.sh" + +[plugin/mailqueue] +queue-script = "/usr/local/bin/queue-script.sh" + +[plugin/environment] +kiosk-path = "/var/spool/kiosk" +ppd-path = "/var/spool/ppds" diff --git a/include/autoload-data.inc b/include/autoload-data.inc new file mode 100644 index 000000000..f8e01599f --- /dev/null +++ b/include/autoload-data.inc @@ -0,0 +1,14 @@ + "include/class_Registry.inc", + "ConfigManagerException" => "include/class_ConfigManager.inc", + "ConfigManager" => "include/class_ConfigManager.inc", + "AutoloadException" => "include/autoload.inc", + "ObjectListException" => "include/class_ObjectList.inc", + "ObjectList" => "include/class_ObjectList.inc", + "ObjectListViewportException" => "include/class_ObjectListViewport.inc", + "ObjectListViewport" => "include/class_ObjectListViewport.inc", + "ObjectListIteratorException" => "include/class_ObjectListIterator.inc", + "ObjectListIterator" => "include/class_ObjectListIterator.inc", +); +?> \ No newline at end of file diff --git a/include/autoload.inc b/include/autoload.inc new file mode 100644 index 000000000..fb5710830 --- /dev/null +++ b/include/autoload.inc @@ -0,0 +1,40 @@ + diff --git a/include/class_ConfigManager.inc b/include/class_ConfigManager.inc new file mode 100644 index 000000000..67061c71a --- /dev/null +++ b/include/class_ConfigManager.inc @@ -0,0 +1,86 @@ +config= parse_ini_file($file, TRUE); + $ret= preg_replace( array('/^.*\nWarning: /', '/\n.*$/'), + array('', ''), + ob_get_contents()); + ob_end_clean(); + + /* Bail out in case of errors */ + if ($ret != ""){ + throw new ConfigManagerException($ret); + } + + echo "Test config and load additional configuration data from LDAP\n"; + #$this->test_config(); + #$this->load_servers(); -> Section servers/...; + #$this->load_plugin_configs(); -> Section pugins/name/value; + + print_r($this->config); + } + + + public function save($file){ + } + + + public function set_section($section_name){ + } + + + public function &get_section(){ + } + + + public function &get_sections(){ + } + + + public function &get_value($section){ + } + + + public function set_value($section, $value){ + } + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/include/class_LdapAttributeFactory.inc b/include/class_LdapAttributeFactory.inc new file mode 100644 index 000000000..5db70014c --- /dev/null +++ b/include/class_LdapAttributeFactory.inc @@ -0,0 +1,3 @@ + diff --git a/include/class_LdapManager.inc b/include/class_LdapManager.inc new file mode 100644 index 000000000..5db70014c --- /dev/null +++ b/include/class_LdapManager.inc @@ -0,0 +1,3 @@ + diff --git a/include/class_LdapObject.inc b/include/class_LdapObject.inc new file mode 100644 index 000000000..5db70014c --- /dev/null +++ b/include/class_LdapObject.inc @@ -0,0 +1,3 @@ + diff --git a/include/class_ObjectList.inc b/include/class_ObjectList.inc new file mode 100644 index 000000000..51d59ec51 --- /dev/null +++ b/include/class_ObjectList.inc @@ -0,0 +1,145 @@ + + \version 1.00 + \date 2007/11/02 + + This class handles the exceptions occuring in ObjectList. + */ +class ObjectListException extends Exception { + public function __construct($message, $code = 0) { + parent::__construct($message, $code); + } +} + + +/*! \brief Implementation for keeping a list of objects + \author Cajus Pollmeier + \version 1.00 + \date 2007/11/02 + + The class ObjectList handles a list of objects found in the database + based on an optional filter modules. This objects can be iterated + directly. + + \sa ObjectListIterator + */ +class ObjectList implements IteratorAggregate { + + /*! + \brief Container for objects + + This variable stores the list of objects. + */ + private $objects; + + /*! + \brief List headline + + String that keeps the desired headline. Returned by ObjectList::getHeadline. + + \sa ObjectList::getHeadline + */ + private $headline; + + /*! + \brief List footer + + String that keeps the desired footer. Returned by ObjectList::getFooter. + + \sa ObjectList::getFooter + */ + private $footer; + + /*! + \brief Config + + Config array that keeps the classes we do lists for, filter information, etc. + */ + private $config; + + + /*! \brief ObjectList constructor + + The ObjectList is initialized by a list of classes we're interested + in. Rest is done by instances of Filter registered in the Registry. + + \param config Config section that is used to configure this ObjectList + \sa Registry + \sa Filter + */ + public function __construct(&$config){ + + /* Save current config */ + $this->config= &$config; + + /* Load and instanciate classes, extract filter, icons, view hooks, etc. */ + $this->load(); + + } + + + /*! \brief Function to initialy load object list + + Internally loads the relevant list of objects depending on eventually + defined filter modules. Handles sorting, too. + */ + private function load(){ + # Crap filling + $this->objects= array( array("i", "Testobjekt mit was auch immer", "UPS"), + array("i", "Noch ein Testobjekt", "UPS"), + array("d", "Ein drittes Testobjekt", "UL")); + $this->headline= "|{16px}|{90%}Name|{64px}Actions|"; + + $this->footer= "Statistical footer"; + } + + + /*! \brief Function to reload object list in case of external changes + + Triggers a reload the relevant list of objects depending on eventually + defined filter modules. Handles sorting, too. + */ + public function reload(){ + } + + + /*! \brief Function to return the iterator object for this class. + + This function is used internally by PHP to produce an iterator. + + \return Iterator object + + \sa ObjectListIterator + */ + public function getIterator() { + return new ObjectListIterator($this->objects); + } + + + /*! \brief Function to get the desired headline + + Return the property of headline to the public world. + + \return headline for current list + */ + public function getHeadline() { + return $this->headline; + } + + + /*! \brief Function to get the desired footer + + Return the property of footer to the public world. + + \return headline for current list + */ + public function getFooter() { + return $this->footer; + } + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/include/class_ObjectListIterator.inc b/include/class_ObjectListIterator.inc new file mode 100644 index 000000000..c1eaddd22 --- /dev/null +++ b/include/class_ObjectListIterator.inc @@ -0,0 +1,78 @@ + + \version 1.00 + \date 2007/11/02 + + The class ObjectList handles a list of objects found in the database + based on an optional filter modules. This objects can be iterated + directly by using this iterator class. + + \sa ObjectList + */ +class ObjectListIterator implements Iterator { + + /*! + \brief Reference container for objects + + This variable stores the list of objects. + */ + private $objects; + + /*! + \brief Iterator position + + Keeps the current position inside our ObjectList + */ + private $position; + + /*! \brief ObjectListIterator constructor + + The ObjectListIterator is initialized by a list of objects from the + ObjectList object. + + \param objects List of objects to be iterated + */ + public function __construct(&$objects){ + $this->objects= &$objects; + } + + + /*! \brief Rewind to the begining of the ObjectList */ + public function rewind(){ + $this->position= 0; + } + + + /*! \brief Check if the next object is valid */ + public function valid() { + return isset($this->objects[$this->position]); + } + + + /*! \brief Return the current key + \return integer Current position + */ + public function key() { + return $this->position; + } + + + /*! \brief Return the current value + \return object Current value + */ + public function current() { + return $this->objects[$this->position]; + } + + + /*! \brief Go to the next index */ + public function next() { + $this->position++; + } + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/include/class_ObjectListViewport.inc b/include/class_ObjectListViewport.inc new file mode 100644 index 000000000..e7ed7911e --- /dev/null +++ b/include/class_ObjectListViewport.inc @@ -0,0 +1,120 @@ + + \version 1.00 + \date 2007/11/02 + + This class handles the exceptions occuring in ObjectListViewport. + */ +class ObjectListViewportException extends Exception { + public function __construct($message, $code = 0) { + parent::__construct($message, $code); + } +} + + +/*! \brief Implementation for ObjectListViewport + \author Cajus Pollmeier + \version 1.00 + \date 2007/11/02 + + This class handles painting of ObjectList objects. + + \sa ObjectList + */ +class ObjectListViewport { + + /*! + \brief Container for objects + + This variable stores the ObjectList object to be displayed. + */ + private $objects; + + + /*! \brief ObjectListViewport constructor + + The ObjectListViewport class renders/handles the ObjectList defined by $config. + + \param config Config section that is used to configure this ObjectListViewport + */ + public function __construct($config){ + + /* Load and instanciate classes, extract filter, icons, view hooks, etc. */ + $this->objects= new ObjectList($config); + } + + /*! \brief Handles _POST / _GET events + + Processes the list of registered plugins to do their eventHandler and adapt + internal objectlist according to this. + */ + public function eventHandler(){ + /* Reloads the list if things have changed interally */ + $this->objects->reload(); + } + + + /*! \brief Renders headline into a string + + Gets the headline description from the ObjectList object and renders it. + + \return HTML rendered headline + */ + private function renderHeadline(){ + return $this->objects->getHeadline()."\n"; + } + + + /*! \brief Renders footer into a string + + Gets the footer description from the ObjectList object and renders it. + + \return HTML rendered footer + */ + private function renderFooter(){ + return $this->objects->getFooter()."\n"; + } + + + /*! \brief Renders entries from the ObjectList iterator into a string + + Gets the entry descriptions from the ObjectList object and renders them. + + \return HTML rendered list entries + */ + private function renderEntry($entry){ + $buffer= "|"; + foreach ($entry as $column){ + $buffer.= "$column|"; + } + $buffer.= "\n"; + + return $buffer; + } + + + /*! \brief Renders complete ObjectList into a string + + \return HTML rendered list + */ + public function render() { + /* Generate fixed headline */ + $buffer= $this->renderHeadline(); + + /* Generate scrollable contents */ + foreach ($this->objects as $value){ + $buffer.= $this->renderEntry($value); + } + + /* Generate footer */ + $buffer.= $this->renderFooter(); + + return ($buffer); + } + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/include/class_Registry.inc b/include/class_Registry.inc new file mode 100644 index 000000000..3d611f619 --- /dev/null +++ b/include/class_Registry.inc @@ -0,0 +1,30 @@ + diff --git a/test b/test new file mode 100755 index 000000000..3b4469d15 --- /dev/null +++ b/test @@ -0,0 +1,28 @@ +#!/usr/bin/php +load("gosa.conf"); + + /* Get a new test instance of ObjectListViewports */ + $vp= new ObjectListViewport(array("dummy", "dummy")); + echo $vp->render(); + +} catch (Exception $e) { + echo "\n-GOsa Exception-----------------------------------------------------------\n\n". + $e->__toString(). + "\n\n--------------------------------------------------------------------------\n\n"; +} + +exit (0); + +?> diff --git a/update-gosa b/update-gosa new file mode 100755 index 000000000..fe2816e44 --- /dev/null +++ b/update-gosa @@ -0,0 +1,81 @@ +#!/usr/bin/php5 + $value){ + fwrite ($handle, " \"$key\" => \"$value\",\n"); +} +fwrite ($handle, ");\n?>"); + +fclose($handle); + +?> -- 2.30.2