diff --git a/.gitignore b/.gitignore index 81e6038..10a1f20 100644 --- a/.gitignore +++ b/.gitignore @@ -1,14 +1,29 @@ .buildpath .project +.gitmodules .settings/ +.gitmodules application/configs/application.ini -library/Doctrine/ -library/Smarty/ -library/ZFDebug/ -library/Zend/ +application/configs/application.ini.old +library/Twitter +library/Bootstrap-Zend-Framework.git +library/Bootstrap-Zend-Framework +library/Doctrine +library/OSS-Framework.git +library/Smarty +library/ZFDebug +library/Zend public/.htaccess var/log/[1-9]* +var/log/vimbadmin.log* var/templates_c/[a-zA-Z0-9%]* var/session/sess_* +var/tmp library/Minify/ - +*~ +composer.lock +vendor/[a-zA-Z0-9]* +vimbadmin.sublime-project +vimbadmin.sublime-workspace +vimbadmin3.sublime-project +vimbadmin3.sublime-workspace diff --git a/CHANGELOG b/CHANGELOG index c3be066..98d8e1e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,207 +1,4 @@ -Please see CHANGELOG.md for the change log from >= v3.0.0. -2.2.3 2014-02-11 - - upd: Add support for modern crypt() algorithms, with random salt. - Merge pull request #57 from andrewd-sterling/local-mod - - fix: Setting the quota for a mailbox will consider a set maxquota of the - domain; Merge pull request #38 from peterschen/master +# Version 3 - A Work in Progress -2.2.2 2012-10-10 - - upd: Better detection of HTTPS on Nginx (see issue #19, thanks @f8bar) - - fix: issue #24 Smarty tag issue with trailing spaces - - fix: issue #26 regarding character encoding - - fix: issue #27 which reports a syntax error - -2.2.1 2012-05-24 - - add: Full support for Dovecot passwords via Dovecot admin binary. - See: https://github.com/opensolutions/ViMbAdmin/wiki/Password-Schemes - - upd: JQuery, Bootstrap and Chosen - - fix: Data table bug - - fix: typo (from dustinfarris) - -2.2.0 2012-04-05 - - fix: access restrictions - previous implementation would have broken SMTP - auth if one was using it. Added access_restriction_type to - application.ini.dist. - See: https://github.com/opensolutions/ViMbAdmin/wiki/POP3-IMAP-Access-Restriction - - - IMPORTANT: this update requires a database migration - See: https://github.com/opensolutions/ViMbAdmin/wiki/Update-Instructions - -2.1.0 2012-04-03 - - IMPORTANT: this update requires a database migration - See: https://github.com/opensolutions/ViMbAdmin/wiki/Update-Instructions - - - add: Mailbox access restriction allowing for POP3 only / IMAP only / both - See: https://github.com/opensolutions/ViMbAdmin/wiki/POP3-IMAP-Access-Restriction - - add: "allow_access_restriction" to application.ini to enable access - restiction options - - add: "migration_version" to application.ini.dist - only used for new - installs - - add: Doctrine migration tables now that we have had out first migration - - upd: freshly pressed CSS/JS (version 12) - - fix: formatting in add/edit mailbox dialog - -2.0.8 2012-03-06 - - fix: Accidently commited testing code causing issue #10. Fixed. - - fix: Better Smarty 3.1 integration. - - fix: Options in bin/minify-options.php to work with updated version - - add: Popover to add alias to explain / highlight domain aliases - - fix: issue with Add Alias dialog with no domain selected - -2.0.7 2012-03-05 - - add: https://github.com/opensolutions/Minify used instead of local - version - - fix: Removed trunk Smarty 3 and replaced it with tagged 3.0.9 as 3.1 - has incompatibilities. You may need to execute the following: - - $ cd library/Smarty - $ svn switch http://smarty-php.googlecode.com/svn/tags/Smarty_3_0_9/distribution/libs - -2.0.6 - - add: Remove the horrible changed IP die() message and just present the - login screen - -2.0.5 2012-03-05 - - fix: Some issues in JS causing errors and also affeting dialogs. - -2.0.4 2012-03-01 - - add: Now using groups of icons for actions rather than buttons - - add: Tooltips added with small delay for all icon actions - - add: Tooltips moved to Bootstrap and now only on table elements which - have been shortened. - - fix: Improvements to model dialogs. - - add: Cookie is now used to remember the number of items to show in - DataTables. - -2.0.3 2012-02-29 - - fix: Page titles made consistent with menu text - - add: Selecting a domain from the domain list (by clicking logs, mailboxes - and aliases for example) makes the domain 'sticky' as you browse - through the application with the option to clear it by going back to - domains or a page title clear button. - - add: Minimum mailbox password length can be specified in application.ini - addressing issue #8 - - fix: Fix issue #9 by skipping IP check if action is logout. - -2.0.2 2012-02-27 - Major UI overhaul. Frontend is now using Bootstrap from Twitter providing an altogether - prettier, sleeker, consistent and more professional look and feel. A number of small new - features and bugs fixes. No database schema changes. - -0.3.5 2011-09-28 - - add: allow new installers to opt out of the 'new install' developer - pingback and display a message that it exists on the setup page - -0.3.4 2011-09-06 - - fix: https://github.com/opensolutions/ViMbAdmin/issues/3 - - add: Support new mailbox password hashes: crypt, sha1 and salted sha1 and md5 - (old issue 9 from Google Code: http://code.google.com/p/vimbadmin/issues/detail?id=9) - - fix: Changes in 0.3.2 prevented wildcard aliases - - add: MD5-CRYPT hashing used by, for example, Dovecot. This addresses: - http://code.google.com/p/vimbadmin/issues/detail?id=6 - -0.3.3 2011-09-02 - - fix: Critical regression introduced in 0.3.2 preventing the editing of - aliases - -0.3.2 2011-09-01 - - fix: https://github.com/opensolutions/ViMbAdmin/issues/1 - - add: optional parameter in application.ini (skipVersionCheck) to - tell ViMbAdmin to skip the version check on login - See: https://github.com/opensolutions/ViMbAdmin/issues/2 - - fix: we now check for duplicate mailboxes (and aliases) rather - than letting Doctrine throw exceptions for uniqueness - constraints. Thanks maysara for the bug report. - - fix: validate new aliases and mailboxes which was not being done - previously - -0.3.1 2011-08-23 - - Forgot to update changelog got 0.3 release. - -0.3 2011-08-23 - - Changes required for the migration to GitHub. No new features / bugfixes - or functionality. - -0.2.6 2011-08-08 - - fix: trim passwords at login and when entered by an admin - - fix: could not edit aliases - -0.2.5 2011-05-23 - - add: CSS code for demo system at http://www.opensolutions.ie/vimbadmin/ - - add: new favicon based on logo from Limeworks Australia - http://www.limeworks.com.au - - fix: issue #5 in vimbadmin: mktime throws a strict error (r61) - - fix: issue #8 in vimbadmin: Cannot add alias from Mailbox view (r66) - - fix: the autocomplete functionality (used on the Edit / Add Alias page) (r63) - - fix: the possible "Fatal error: spl_autoload() ... Class Doctrine_Event could not be loaded in Doctrine_Record ..." (r64) - - fix: the "inArray" JavaScript validator functionality was broken (r65) - - upd: jQuery 1.5.2 - - upd: jQuery Validation 1.8.0 - - fix: add StringToLower filter to domain, mailbox and alias forms - - -0.2.4 2011-04-07 - - add: new logo thanks to Limeworks Australia - http://www.limeworks.com.au - - upd: new login screen design with new logo - - -0.2.3 2011-03-30 - - fix: critical bug fix preventing email being sent during first use set up - (will only have affected those choosing a random password) - - -0.2.2 2011-03-29 - - add: version checking (once per day per super) and alerting - - add: version displayed in the footer - - fix: adding mailbox alias - - fix: edit alias - - fix: fatal error when listing aliases - - -0.2.1 2011-03-25 - - upd: it is possible now to add domains to admins through the - Administrators->Domains screen - - upd: checkbox to include/exclude mailbox aliases on the Maliboxes->Aliases - and Aliases pages - - fix: the DataTables search was searching in the columns of the buttons too, - providing fake results - - -0.2 2011-03-24 - - upd: IMPORTANT!!! IN THE APPLICATION.INI YOU HAVE TO RENAME THE OPTION - "likeForLikeAliases" TO "mailboxAliases"! - - add: display the link to mailbox password change on the login page - - add: "defaults.table.entries" in application.ini controls the default number - of rows displayed in tables - IMPORTANT!!! IN THE APPLICATION.INI YOU HAVE TO ADD THE NEW OPTION - "defaults.table.entries" and set it to one of 10, 25, 50, 100 - See application.ini.dist for an example. - - add: when adding a new mailbox, the domain is pre-selected - - add: when adding an email alias, it can pre-fill the "local part" and "domain" - fields, depending on which page the "Add Alias" button was clicked on - - add: a few extra checks added when adding a new email alias - - add: can add a new email alias in the "Aliases of [emailaddress]" popup window - - fix: DataTables was floating above the page header on page scroll - - fix: on the Domain List page the sorting by Mailboxes and Aliases did not use - the numeric values, fixed by using Allan Jardine's DataTables sorting plugin - - fix: some typos in texts - - fix: clicking the "Add xyz" buttons at the top of the tables caused a sorting - on that coulumn, which didn't make any sense at all - - upd: less text in the footer, so ViMbAdmin hopefully fits on an 1024x768 screen - - upd: jQuery UI 1.8.11 - - upd: ColorBox v1.3.16 - - upd: DataTables 1.7.6 - - -0.1.2 2011-03-22 - - fix: issue #3 https://code.google.com/p/vimbadmin/issues/detail?id=3 - - -0.1.1 2011-03-15 - - fix: issue with single quotes vs double quotes in application.ini - - add: allow for more informative display of errors - - -0.1 2011-03-10 - - initial release +Please see version 2 for now: https://github.com/opensolutions/ViMbAdmin diff --git a/README.md b/README.md index e2950d9..6032be9 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,50 @@ +# WORK IN PROGRESS + +Please Ignore for Now. + +| +| +| +| +| +| +| +| +| +| +| +| +| +| +| +| +| +| +| +| +| +| +| +| +| +| +| +| +| +| +| +| + + ViMbAdmin :: Virtual Mailbox Administration ============================================ -The **ViMbAdmin** project (*vim-be-admin*) provides an web based virtual mailbox -administration system to allow mail administrators to easily manage domains, mailboxes -and aliases. +The **ViMbAdmin** project (*vim-be-admin*) provides a web based virtual mailbox administration system to allow mail administrators to easily manage domains, mailboxes and aliases. -**ViMbAdmin** was written in PHP using our own web application framework which includes -the Zend Framework, the Doctrine ORM and the Smarty templating system with JQuery and Bootstrap. +**ViMbAdmin** was written in PHP using our own web application framework which includes the Zend Framework, the Doctrine ORM and the Smarty templating system with JQuery and Bootstrap. -**ViMbAdmin** is hosted on its own GitHub project page where you can find documentation, -browse the source code and access our Git repository. We have also set up a Google Groups -discussion group or you can follow the [blog posts](http://www.barryodonovan.com/index.php/category/vimbadmin-2) on our MD's personal site. +**ViMbAdmin** is hosted on its own GitHub project page where you can find documentation, browse the source code and access our Git repository. We have also set up a Google Groups discussion group or you can follow the [blog posts](http://www.barryodonovan.com/index.php/category/vimbadmin-2) on our MD's personal site. * Lead Author: [Barry O'Donovan](http://www.barryodonovan.com) (founder and MD of Open Solutions) @@ -52,14 +85,14 @@ Please see the following links for more information: * [Open Solutions' ViMbAdmin page](http://www.opensolutions.ie/open-source/vimbadmin) (with screenshots); * [Live demo](http://www.opensolutions.ie/vimbadmin); -* [GitHub project page](https://github.com/opensolutions/ViMbAdmin); +* [GitHub project page](https://github.com/opensolutions/ViMbAdmin3); * Various [blog posts](http://www.barryodonovan.com/index.php/category/vimbadmin-2);, -* [GitHub wiki](https://github.com/opensolutions/ViMbAdmin/wiki) +* [GitHub wiki](https://github.com/opensolutions/ViMbAdmin3/wiki) Copyright, License and Redistribution -------------------------------------- -Copyright (c) 2011 - 2012 [Open Source Solutions Limited](http://www.opensolutions.ie/), Dublin, Ireland. +Copyright (c) 2011 - 2014 [Open Source Solutions Limited](http://www.opensolutions.ie/), Dublin, Ireland. **ViMbAdmin** is free software: you can redistribute it and/or modify it under the terms of the [GNU General Public License](http://www.gnu.org/licenses/gpl-3.0-standalone.html) as published by diff --git a/application/Bootstrap.php b/application/Bootstrap.php index 169b9da..fe3410a 100644 --- a/application/Bootstrap.php +++ b/application/Bootstrap.php @@ -53,4 +53,36 @@ protected function _initViMbAdminAutoLoader() $autoloader->registerNamespace( 'ViMbAdmin' ); } + + /** + * Register the OSS library autoloader + * + * This function ensures that classes from library/OSS are automatically + * loaded from the subdirectories where subdirectories are indicated by + * underscores in the same manner as Zend. + * + */ + protected function _initOSSAutoLoader() + { + $autoloader = Zend_Loader_Autoloader::getInstance(); + $autoloader->registerNamespace( 'OSS' ); + } + + /** + * Load the database resource before the session resource is loaded. + * + * We're currently using the Zend session handler for storing sessions + * in MySQL. For this, we need to ensure the DB is initialised before + * the session resource is loaded. + */ + protected function _initDbAutoForSessions() + { + // load the DB resource if it is required by the session + if( isset( $this->getOptions()['resources']['session']['saveHandler']['class'] ) + && $this->getOptions()['resources']['session']['saveHandler']['class'] == 'Zend_Session_SaveHandler_DbTable' ) + { + $this->bootstrap('db'); + } + } + } diff --git a/application/Entities/Admin.php b/application/Entities/Admin.php new file mode 100644 index 0000000..2fef62d --- /dev/null +++ b/application/Entities/Admin.php @@ -0,0 +1,501 @@ +Admin = new \Doctrine\Common\Collections\ArrayCollection(); + $this->Logs = new \Doctrine\Common\Collections\ArrayCollection(); + $this->Domains = new \Doctrine\Common\Collections\ArrayCollection(); + } + + /** + * Set username + * + * @param string $username + * @return Admin + */ + public function setUsername($username) + { + $this->username = $username; + + return $this; + } + + /** + * Get username + * + * @return string + */ + public function getUsername() + { + return $this->username; + } + + /** + * Utility function to get the user's email (which is the username) + * + * @return string + */ + public function getEmail() + { + return $this->getUsername(); + } + + /** + * Utility function to get the user's "formatted name" as required by some OSS functions + * + * @return string + */ + public function getFormattedName() + { + return $this->getUsername(); + } + + + + /** + * Set password + * + * @param string $password + * @return Admin + */ + public function setPassword($password) + { + $this->password = $password; + + return $this; + } + + /** + * Get password + * + * @return string + */ + public function getPassword() + { + return $this->password; + } + + /** + * Set super + * + * @param boolean $super + * @return Admin + */ + public function setSuper($super) + { + $this->super = $super; + + return $this; + } + + /** + * Get super + * + * @return boolean + */ + public function getSuper() + { + return $this->super; + } + + /** + * Alias fot getSuper + * + * @return boolean + */ + public function isSuper() + { + return $this->getSuper(); + } + + /** + * Set active + * + * @param boolean $active + * @return Admin + */ + public function setActive($active) + { + $this->active = $active; + + return $this; + } + + /** + * Get active + * + * @return boolean + */ + public function getActive() + { + return $this->active; + } + + /** + * Set created + * + * @param \DateTime $created + * @return Admin + */ + public function setCreated($created) + { + $this->created = $created; + + return $this; + } + + /** + * Get created + * + * @return \DateTime + */ + public function getCreated() + { + return $this->created; + } + + /** + * Set modified + * + * @param \DateTime $modified + * @return Admin + */ + public function setModified($modified) + { + $this->modified = $modified; + + return $this; + } + + /** + * Get modified + * + * @return \DateTime + */ + public function getModified() + { + return $this->modified; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Add Admin + * + * @param Entities\AdminPreference $admin + * @return Admin + */ + public function addAdmin(\Entities\AdminPreference $admin) + { + $this->Admin[] = $admin; + + return $this; + } + + /** + * Remove Admin + * + * @param Entities\AdminPreference $admin + */ + public function removeAdmin(\Entities\AdminPreference $admin) + { + $this->Admin->removeElement($admin); + } + + /** + * Get Admin + * + * @return Doctrine\Common\Collections\Collection + */ + public function getAdmin() + { + return $this->Admin; + } + + /** + * Add Logs + * + * @param Entities\Log $logs + * @return Admin + */ + public function addLog(\Entities\Log $logs) + { + $this->Logs[] = $logs; + + return $this; + } + + /** + * Remove Logs + * + * @param Entities\Log $logs + */ + public function removeLog(\Entities\Log $logs) + { + $this->Logs->removeElement($logs); + } + + /** + * Get Logs + * + * @return Doctrine\Common\Collections\Collection + */ + public function getLogs() + { + return $this->Logs; + } + + /** + * Add Domains + * + * @param Entities\Domain $domains + * @return Admin + */ + public function addDomain(\Entities\Domain $domains) + { + $this->Domains[] = $domains; + + return $this; + } + + /** + * Remove Domains + * + * @param Entities\Domain $domains + */ + public function removeDomain(\Entities\Domain $domains) + { + $this->Domains->removeElement($domains); + } + + /** + * Get Domains + * + * @return Doctrine\Common\Collections\Collection + */ + public function getDomains() + { + return $this->Domains; + } + /** + * @var \Doctrine\Common\Collections\ArrayCollection + */ + private $Preferences; + + + /** + * Add Preferences + * + * @param Entities\AdminPreference $preferences + * @return Admin + */ + public function addPreference(\Entities\AdminPreference $preferences) + { + $this->Preferences[] = $preferences; + + return $this; + } + + /** + * Remove Preferences + * + * @param Entities\AdminPreference $preferences + */ + public function removePreference(\Entities\AdminPreference $preferences) + { + $this->Preferences->removeElement($preferences); + } + + /** + * Get Preferences + * + * @return Doctrine\Common\Collections\Collection + */ + public function getPreferences() + { + return $this->Preferences; + } + + + /** + * Check to see if this user is linked to a given domain (does not check for super - see below) + * + * This function is slightly misnamed as it does not check if your are a super admin (`isSuper()`) + * but rather whether you are linked to a domain or not. So a use case in practice would be: + * + * if( $admin->isSuper() || $admin->canManageDomain( $domain ) ) ...; + * + * + * @param \Entities\Domain $domain The domain object + * @return boolean + */ + public function canManageDomain( $domain ) + { + foreach( $this->getDomains() as $d ) + if( $domain->getId() == $d->getId() ) + return true; + + return false; + } + + + /** + * Add Preferences + * + * @param Entities\AdminPreference $preferences + * @return Admin + */ + public function addAdminPreference(\Entities\AdminPreference $preferences) + { + $this->Preferences[] = $preferences; + return $this; + } + /** + * @var \Doctrine\Common\Collections\Collection + */ + private $RememberMes; + + + /** + * Add RememberMes + * + * @param \Entities\RememberMe $rememberMes + * @return Admin + */ + public function addRememberMe(\Entities\RememberMe $rememberMes) + { + $this->RememberMes[] = $rememberMes; + + return $this; + } + + /** + * Remove RememberMes + * + * @param \Entities\RememberMe $rememberMes + */ + public function removeRememberMe(\Entities\RememberMe $rememberMes) + { + $this->RememberMes->removeElement($rememberMes); + } + + /** + * Get RememberMes + * + * @return \Doctrine\Common\Collections\Collection + */ + public function getRememberMes() + { + return $this->RememberMes; + } + /** + * @var \Doctrine\Common\Collections\Collection + */ + private $Archives; + + + /** + * Add Archives + * + * @param \Entities\Archive $archives + * @return Admin + */ + public function addArchive(\Entities\Archive $archives) + { + $this->Archives[] = $archives; + + return $this; + } + + /** + * Remove Archives + * + * @param \Entities\Archive $archives + */ + public function removeArchive(\Entities\Archive $archives) + { + $this->Archives->removeElement($archives); + } + + /** + * Get Archives + * + * @return \Doctrine\Common\Collections\Collection + */ + public function getArchives() + { + return $this->Archives; + } +} diff --git a/application/Entities/AdminPreference.php b/application/Entities/AdminPreference.php new file mode 100644 index 0000000..7179a40 --- /dev/null +++ b/application/Entities/AdminPreference.php @@ -0,0 +1,223 @@ +attribute = $attribute; + + return $this; + } + + /** + * Get attribute + * + * @return string + */ + public function getAttribute() + { + return $this->attribute; + } + + /** + * Set ix + * + * @param integer $ix + * @return AdminPreference + */ + public function setIx($ix) + { + $this->ix = $ix; + + return $this; + } + + /** + * Get ix + * + * @return integer + */ + public function getIx() + { + return $this->ix; + } + + /** + * Set op + * + * @param string $op + * @return AdminPreference + */ + public function setOp($op) + { + $this->op = $op; + + return $this; + } + + /** + * Get op + * + * @return string + */ + public function getOp() + { + return $this->op; + } + + /** + * Set value + * + * @param string $value + * @return AdminPreference + */ + public function setValue($value) + { + $this->value = $value; + + return $this; + } + + /** + * Get value + * + * @return string + */ + public function getValue() + { + return $this->value; + } + + /** + * Set expire + * + * @param integer $expire + * @return AdminPreference + */ + public function setExpire($expire) + { + $this->expire = $expire; + + return $this; + } + + /** + * Get expire + * + * @return integer + */ + public function getExpire() + { + return $this->expire; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set Preferences + * + * @param Entities\Admin $preferences + * @return AdminPreference + */ + public function setPreferences(\Entities\Admin $preferences = null) + { + $this->Preferences = $preferences; + + return $this; + } + + /** + * Get Preferences + * + * @return Entities\Admin + */ + public function getPreferences() + { + return $this->Preferences; + } + /** + * @var Entities\Admin + */ + private $Admin; + + + /** + * Set Admin + * + * @param Entities\Admin $admin + * @return AdminPreference + */ + public function setAdmin(\Entities\Admin $admin = null) + { + $this->Admin = $admin; + + return $this; + } + + /** + * Get Admin + * + * @return Entities\Admin + */ + public function getAdmin() + { + return $this->Admin; + } +} diff --git a/application/Entities/Alias.php b/application/Entities/Alias.php new file mode 100644 index 0000000..429a936 --- /dev/null +++ b/application/Entities/Alias.php @@ -0,0 +1,242 @@ +address = $address; + + return $this; + } + + /** + * Get address + * + * @return string + */ + public function getAddress() + { + return $this->address; + } + + /** + * Set goto + * + * @param string $goto + * @return Alias + */ + public function setGoto($goto) + { + $this->goto = $goto; + + return $this; + } + + /** + * Get goto + * + * @return string + */ + public function getGoto() + { + return $this->goto; + } + + /** + * Set active + * + * @param boolean $active + * @return Alias + */ + public function setActive($active) + { + $this->active = $active; + + return $this; + } + + /** + * Get active + * + * @return boolean + */ + public function getActive() + { + return $this->active; + } + + /** + * Set created + * + * @param \DateTime $created + * @return Alias + */ + public function setCreated($created) + { + $this->created = $created; + + return $this; + } + + /** + * Get created + * + * @return \DateTime + */ + public function getCreated() + { + return $this->created; + } + + /** + * Set modified + * + * @param \DateTime $modified + * @return Alias + */ + public function setModified($modified) + { + $this->modified = $modified; + + return $this; + } + + /** + * Get modified + * + * @return \DateTime + */ + public function getModified() + { + return $this->modified; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set Domain + * + * @param Entities\Domain $domain + * @return Alias + */ + public function setDomain(\Entities\Domain $domain = null) + { + $this->Domain = $domain; + + return $this; + } + + /** + * Get Domain + * + * @return Entities\Domain + */ + public function getDomain() + { + return $this->Domain; + } + /** + * @var \Doctrine\Common\Collections\Collection + */ + private $Preferences; + + /** + * Constructor + */ + public function __construct() + { + $this->Preferences = new \Doctrine\Common\Collections\ArrayCollection(); + } + + /** + * Add Preferences + * + * @param \Entities\AliasPreference $preferences + * @return Alias + */ + public function addPreference(\Entities\AliasPreference $preferences) + { + $this->Preferences[] = $preferences; + + return $this; + } + + /** + * Remove Preferences + * + * @param \Entities\AliasPreference $preferences + */ + public function removePreference(\Entities\AliasPreference $preferences) + { + $this->Preferences->removeElement($preferences); + } + + /** + * Get Preferences + * + * @return \Doctrine\Common\Collections\Collection + */ + public function getPreferences() + { + return $this->Preferences; + } +} diff --git a/application/Entities/AliasPreference.php b/application/Entities/AliasPreference.php new file mode 100644 index 0000000..6735c50 --- /dev/null +++ b/application/Entities/AliasPreference.php @@ -0,0 +1,195 @@ +attribute = $attribute; + + return $this; + } + + /** + * Get attribute + * + * @return string + */ + public function getAttribute() + { + return $this->attribute; + } + + /** + * Set ix + * + * @param integer $ix + * @return AliasPreference + */ + public function setIx($ix) + { + $this->ix = $ix; + + return $this; + } + + /** + * Get ix + * + * @return integer + */ + public function getIx() + { + return $this->ix; + } + + /** + * Set op + * + * @param string $op + * @return AliasPreference + */ + public function setOp($op) + { + $this->op = $op; + + return $this; + } + + /** + * Get op + * + * @return string + */ + public function getOp() + { + return $this->op; + } + + /** + * Set value + * + * @param string $value + * @return AliasPreference + */ + public function setValue($value) + { + $this->value = $value; + + return $this; + } + + /** + * Get value + * + * @return string + */ + public function getValue() + { + return $this->value; + } + + /** + * Set expire + * + * @param integer $expire + * @return AliasPreference + */ + public function setExpire($expire) + { + $this->expire = $expire; + + return $this; + } + + /** + * Get expire + * + * @return integer + */ + public function getExpire() + { + return $this->expire; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set Alias + * + * @param \Entities\Alias $alias + * @return AliasPreference + */ + public function setAlias(\Entities\Alias $alias = null) + { + $this->Alias = $alias; + + return $this; + } + + /** + * Get Alias + * + * @return \Entities\Alias + */ + public function getAlias() + { + return $this->Alias; + } +} diff --git a/application/Entities/Archive.php b/application/Entities/Archive.php new file mode 100644 index 0000000..3eae2f5 --- /dev/null +++ b/application/Entities/Archive.php @@ -0,0 +1,470 @@ + "Pending Archive", + self::STATUS_ARCHIVING => "Archiving", + self::STATUS_ARCHIVED => "Archived", + self::STATUS_PENDING_RESTORE => "Pending Restore", + self::STATUS_RESTORING => "Restoring", + self::STATUS_RESTORED => "Restored", + self::STATUS_PENDING_DELETE => "Pending Delete", + self::STATUS_DELETING => "Deleting", + self::STATUS_DELETED => "Deleted" + + ]; + + /** + * @var string + */ + private $username; + + /** + * @var string + */ + private $status; + + /** + * @var \DateTime + */ + private $archived_at; + + /** + * @var \DateTime + */ + private $status_changed_at; + + /** + * @var string + */ + private $homedir_server; + + /** + * @var string + */ + private $homedir_file; + + /** + * @var integer + */ + private $homedir_orig_size; + + /** + * @var integer + */ + private $homedir_size; + + /** + * @var string + */ + private $maildir_server; + + /** + * @var string + */ + private $maildir_file; + + /** + * @var integer + */ + private $maildir_orig_size; + + /** + * @var integer + */ + private $maildir_size; + + /** + * @var string + */ + private $data; + + /** + * @var integer + */ + private $id; + + /** + * @var \Entities\Domain + */ + private $Domain; + + /** + * @var \Entities\Admin + */ + private $ArchivedBy; + + + /** + * Set username + * + * @param string $username + * @return Archive + */ + public function setUsername($username) + { + $this->username = $username; + + return $this; + } + + /** + * Get username + * + * @return string + */ + public function getUsername() + { + return $this->username; + } + + /** + * Set status + * + * @param string $status + * @return Archive + */ + public function setStatus($status) + { + $this->status = $status; + + return $this; + } + + /** + * Get status + * + * @return string + */ + public function getStatus() + { + return $this->status; + } + + /** + * Set archived_at + * + * @param \DateTime $archivedAt + * @return Archive + */ + public function setArchivedAt($archivedAt) + { + $this->archived_at = $archivedAt; + + return $this; + } + + /** + * Get archived_at + * + * @return \DateTime + */ + public function getArchivedAt() + { + return $this->archived_at; + } + + /** + * Set status_changed_at + * + * @param \DateTime $statusChangedAt + * @return Archive + */ + public function setStatusChangedAt($statusChangedAt) + { + $this->status_changed_at = $statusChangedAt; + + return $this; + } + + /** + * Get status_changed_at + * + * @return \DateTime + */ + public function getStatusChangedAt() + { + return $this->status_changed_at; + } + + /** + * Set homedir_server + * + * @param string $homedirServer + * @return Archive + */ + public function setHomedirServer($homedirServer) + { + $this->homedir_server = $homedirServer; + + return $this; + } + + /** + * Get homedir_server + * + * @return string + */ + public function getHomedirServer() + { + return $this->homedir_server; + } + + /** + * Set homedir_file + * + * @param string $homedirFile + * @return Archive + */ + public function setHomedirFile($homedirFile) + { + $this->homedir_file = $homedirFile; + + return $this; + } + + /** + * Get homedir_file + * + * @return string + */ + public function getHomedirFile() + { + return $this->homedir_file; + } + + /** + * Set homedir_orig_size + * + * @param integer $homedirOrigSize + * @return Archive + */ + public function setHomedirOrigSize($homedirOrigSize) + { + $this->homedir_orig_size = $homedirOrigSize; + + return $this; + } + + /** + * Get homedir_orig_size + * + * @return integer + */ + public function getHomedirOrigSize() + { + return $this->homedir_orig_size; + } + + /** + * Set homedir_size + * + * @param integer $homedirSize + * @return Archive + */ + public function setHomedirSize($homedirSize) + { + $this->homedir_size = $homedirSize; + + return $this; + } + + /** + * Get homedir_size + * + * @return integer + */ + public function getHomedirSize() + { + return $this->homedir_size; + } + + /** + * Set maildir_server + * + * @param string $maildirServer + * @return Archive + */ + public function setMaildirServer($maildirServer) + { + $this->maildir_server = $maildirServer; + + return $this; + } + + /** + * Get maildir_server + * + * @return string + */ + public function getMaildirServer() + { + return $this->maildir_server; + } + + /** + * Set maildir_file + * + * @param string $maildirFile + * @return Archive + */ + public function setMaildirFile($maildirFile) + { + $this->maildir_file = $maildirFile; + + return $this; + } + + /** + * Get maildir_file + * + * @return string + */ + public function getMaildirFile() + { + return $this->maildir_file; + } + + /** + * Set maildir_orig_size + * + * @param integer $maildirOrigSize + * @return Archive + */ + public function setMaildirOrigSize($maildirOrigSize) + { + $this->maildir_orig_size = $maildirOrigSize; + + return $this; + } + + /** + * Get maildir_orig_size + * + * @return integer + */ + public function getMaildirOrigSize() + { + return $this->maildir_orig_size; + } + + /** + * Set maildir_size + * + * @param integer $maildirSize + * @return Archive + */ + public function setMaildirSize($maildirSize) + { + $this->maildir_size = $maildirSize; + + return $this; + } + + /** + * Get maildir_size + * + * @return integer + */ + public function getMaildirSize() + { + return $this->maildir_size; + } + + /** + * Set data + * + * @param string $data + * @return Archive + */ + public function setData($data) + { + $this->data = $data; + + return $this; + } + + /** + * Get data + * + * @return string + */ + public function getData() + { + return $this->data; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set Domain + * + * @param \Entities\Domain $domain + * @return Archive + */ + public function setDomain(\Entities\Domain $domain = null) + { + $this->Domain = $domain; + + return $this; + } + + /** + * Get Domain + * + * @return \Entities\Domain + */ + public function getDomain() + { + return $this->Domain; + } + + /** + * Set ArchivedBy + * + * @param \Entities\Admin $archivedBy + * @return Archive + */ + public function setArchivedBy(\Entities\Admin $archivedBy = null) + { + $this->ArchivedBy = $archivedBy; + + return $this; + } + + /** + * Get ArchivedBy + * + * @return \Entities\Admin + */ + public function getArchivedBy() + { + return $this->ArchivedBy; + } +} diff --git a/application/Entities/DatabaseVersion.php b/application/Entities/DatabaseVersion.php new file mode 100644 index 0000000..570c93c --- /dev/null +++ b/application/Entities/DatabaseVersion.php @@ -0,0 +1,111 @@ +version = $version; + + return $this; + } + + /** + * Get version + * + * @return integer + */ + public function getVersion() + { + return $this->version; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + /** + * @var string + */ + private $name; + + /** + * @var \DateTime + */ + private $applied_on; + + + /** + * Set name + * + * @param string $name + * @return DatabaseVersion + */ + public function setName($name) + { + $this->name = $name; + + return $this; + } + + /** + * Get name + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Set applied_on + * + * @param \DateTime $appliedOn + * @return DatabaseVersion + */ + public function setAppliedOn($appliedOn) + { + $this->applied_on = $appliedOn; + + return $this; + } + + /** + * Get applied_on + * + * @return \DateTime + */ + public function getAppliedOn() + { + return $this->applied_on; + } +} diff --git a/application/Entities/DirectoryEntry.php b/application/Entities/DirectoryEntry.php new file mode 100644 index 0000000..d98cd5f --- /dev/null +++ b/application/Entities/DirectoryEntry.php @@ -0,0 +1,839 @@ +businessCategory = $businessCategory; + + return $this; + } + + /** + * Get businessCategory + * + * @return string + */ + public function getBusinessCategory() + { + return $this->businessCategory; + } + + /** + * Set carLicense + * + * @param string $carLicense + * @return DirectoryEntry + */ + public function setCarLicense($carLicense) + { + $this->carLicense = $carLicense; + + return $this; + } + + /** + * Get carLicense + * + * @return string + */ + public function getCarLicense() + { + return $this->carLicense; + } + + /** + * Set departmentNumber + * + * @param string $departmentNumber + * @return DirectoryEntry + */ + public function setDepartmentNumber($departmentNumber) + { + $this->departmentNumber = $departmentNumber; + + return $this; + } + + /** + * Get departmentNumber + * + * @return string + */ + public function getDepartmentNumber() + { + return $this->departmentNumber; + } + + /** + * Set displayName + * + * @param string $displayName + * @return DirectoryEntry + */ + public function setDisplayName($displayName) + { + $this->displayName = $displayName; + + return $this; + } + + /** + * Get displayName + * + * @return string + */ + public function getDisplayName() + { + return $this->displayName; + } + + /** + * Set employeeNumber + * + * @param string $employeeNumber + * @return DirectoryEntry + */ + public function setEmployeeNumber($employeeNumber) + { + $this->employeeNumber = $employeeNumber; + + return $this; + } + + /** + * Get employeeNumber + * + * @return string + */ + public function getEmployeeNumber() + { + return $this->employeeNumber; + } + + /** + * Set employeeType + * + * @param string $employeeType + * @return DirectoryEntry + */ + public function setEmployeeType($employeeType) + { + $this->employeeType = $employeeType; + + return $this; + } + + /** + * Get employeeType + * + * @return string + */ + public function getEmployeeType() + { + return $this->employeeType; + } + + /** + * Set homePhone + * + * @param string $homePhone + * @return DirectoryEntry + */ + public function setHomePhone($homePhone) + { + $this->homePhone = $homePhone; + + return $this; + } + + /** + * Get homePhone + * + * @return string + */ + public function getHomePhone() + { + return $this->homePhone; + } + + /** + * Set homePostalAddress + * + * @param string $homePostalAddress + * @return DirectoryEntry + */ + public function setHomePostalAddress($homePostalAddress) + { + $this->homePostalAddress = $homePostalAddress; + + return $this; + } + + /** + * Get homePostalAddress + * + * @return string + */ + public function getHomePostalAddress() + { + return $this->homePostalAddress; + } + + /** + * Set initials + * + * @param string $initials + * @return DirectoryEntry + */ + public function setInitials($initials) + { + $this->initials = $initials; + + return $this; + } + + /** + * Get initials + * + * @return string + */ + public function getInitials() + { + return $this->initials; + } + + /** + * Set jpegPhoto + * + * @param \stdClass $jpegPhoto + * @return DirectoryEntry + */ + public function setJpegPhoto($jpegPhoto) + { + $this->jpegPhoto = $jpegPhoto; + + return $this; + } + + /** + * Get jpegPhoto + * + * @return \stdClass + */ + public function getJpegPhoto() + { + return $this->jpegPhoto; + } + + /** + * Set labeledURI + * + * @param string $labeledURI + * @return DirectoryEntry + */ + public function setLabeledURI($labeledURI) + { + $this->labeledURI = $labeledURI; + + return $this; + } + + /** + * Get labeledURI + * + * @return string + */ + public function getLabeledURI() + { + return $this->labeledURI; + } + + /** + * Set mail + * + * @param string $mail + * @return DirectoryEntry + */ + public function setMail($mail) + { + $this->mail = $mail; + + return $this; + } + + /** + * Get mail + * + * @return string + */ + public function getMail() + { + return $this->mail; + } + + /** + * Set manager + * + * @param string $manager + * @return DirectoryEntry + */ + public function setManager($manager) + { + $this->manager = $manager; + + return $this; + } + + /** + * Get manager + * + * @return string + */ + public function getManager() + { + return $this->manager; + } + + /** + * Set mobile + * + * @param string $mobile + * @return DirectoryEntry + */ + public function setMobile($mobile) + { + $this->mobile = $mobile; + + return $this; + } + + /** + * Get mobile + * + * @return string + */ + public function getMobile() + { + return $this->mobile; + } + + /** + * Set o + * + * @param string $o + * @return DirectoryEntry + */ + public function setO($o) + { + $this->o = $o; + + return $this; + } + + /** + * Get o + * + * @return string + */ + public function getO() + { + return $this->o; + } + + /** + * Set pager + * + * @param string $pager + * @return DirectoryEntry + */ + public function setPager($pager) + { + $this->pager = $pager; + + return $this; + } + + /** + * Get pager + * + * @return string + */ + public function getPager() + { + return $this->pager; + } + + /** + * Set preferredLanguage + * + * @param string $preferredLanguage + * @return DirectoryEntry + */ + public function setPreferredLanguage($preferredLanguage) + { + $this->preferredLanguage = $preferredLanguage; + + return $this; + } + + /** + * Get preferredLanguage + * + * @return string + */ + public function getPreferredLanguage() + { + return $this->preferredLanguage; + } + + /** + * Set roomNumber + * + * @param string $roomNumber + * @return DirectoryEntry + */ + public function setRoomNumber($roomNumber) + { + $this->roomNumber = $roomNumber; + + return $this; + } + + /** + * Get roomNumber + * + * @return string + */ + public function getRoomNumber() + { + return $this->roomNumber; + } + + /** + * Set secretary + * + * @param string $secretary + * @return DirectoryEntry + */ + public function setSecretary($secretary) + { + $this->secretary = $secretary; + + return $this; + } + + /** + * Get secretary + * + * @return string + */ + public function getSecretary() + { + return $this->secretary; + } + + /** + * Set personalTitle + * + * @param string $personalTitle + * @return DirectoryEntry + */ + public function setPersonalTitle($personalTitle) + { + $this->personalTitle = $personalTitle; + + return $this; + } + + /** + * Get personalTitle + * + * @return string + */ + public function getPersonalTitle() + { + return $this->personalTitle; + } + + /** + * Set sn + * + * @param string $sn + * @return DirectoryEntry + */ + public function setSn($sn) + { + $this->sn = $sn; + + return $this; + } + + /** + * Get sn + * + * @return string + */ + public function getSn() + { + return $this->sn; + } + + /** + * Set ou + * + * @param string $ou + * @return DirectoryEntry + */ + public function setOu($ou) + { + $this->ou = $ou; + + return $this; + } + + /** + * Get ou + * + * @return string + */ + public function getOu() + { + return $this->ou; + } + + /** + * Set title + * + * @param string $title + * @return DirectoryEntry + */ + public function setTitle($title) + { + $this->title = $title; + + return $this; + } + + /** + * Get title + * + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * Set facsimileTelephoneNumber + * + * @param string $facsimileTelephoneNumber + * @return DirectoryEntry + */ + public function setFacsimileTelephoneNumber($facsimileTelephoneNumber) + { + $this->facsimileTelephoneNumber = $facsimileTelephoneNumber; + + return $this; + } + + /** + * Get facsimileTelephoneNumber + * + * @return string + */ + public function getFacsimileTelephoneNumber() + { + return $this->facsimileTelephoneNumber; + } + + /** + * Set givenName + * + * @param string $givenName + * @return DirectoryEntry + */ + public function setGivenName($givenName) + { + $this->givenName = $givenName; + + return $this; + } + + /** + * Get givenName + * + * @return string + */ + public function getGivenName() + { + return $this->givenName; + } + + /** + * Set telephoneNumber + * + * @param string $telephoneNumber + * @return DirectoryEntry + */ + public function setTelephoneNumber($telephoneNumber) + { + $this->telephoneNumber = $telephoneNumber; + + return $this; + } + + /** + * Get telephoneNumber + * + * @return string + */ + public function getTelephoneNumber() + { + return $this->telephoneNumber; + } + + /** + * Set vimb_created + * + * @param \DateTime $vimbCreated + * @return DirectoryEntry + */ + public function setVimbCreated($vimbCreated) + { + $this->vimb_created = $vimbCreated; + + return $this; + } + + /** + * Get vimb_created + * + * @return \DateTime + */ + public function getVimbCreated() + { + return $this->vimb_created; + } + + /** + * Set vimb_update + * + * @param \DateTime $vimbUpdate + * @return DirectoryEntry + */ + public function setVimbUpdate($vimbUpdate) + { + $this->vimb_update = $vimbUpdate; + + return $this; + } + + /** + * Get vimb_update + * + * @return \DateTime + */ + public function getVimbUpdate() + { + return $this->vimb_update; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set Mailbox + * + * @param \Entities\Mailbox $mailbox + * @return DirectoryEntry + */ + public function setMailbox(\Entities\Mailbox $mailbox) + { + $this->Mailbox = $mailbox; + + return $this; + } + + /** + * Get Mailbox + * + * @return \Entities\Mailbox + */ + public function getMailbox() + { + return $this->Mailbox; + } +} diff --git a/application/Entities/Domain.php b/application/Entities/Domain.php new file mode 100644 index 0000000..8ffe28b --- /dev/null +++ b/application/Entities/Domain.php @@ -0,0 +1,837 @@ +Mailboxes = new \Doctrine\Common\Collections\ArrayCollection(); + $this->Aliases = new \Doctrine\Common\Collections\ArrayCollection(); + $this->Logs = new \Doctrine\Common\Collections\ArrayCollection(); + $this->Admins = new \Doctrine\Common\Collections\ArrayCollection(); + } + + /** + * Set domain + * + * @param string $domain + * @return Domain + */ + public function setDomain($domain) + { + $this->domain = $domain; + + return $this; + } + + /** + * Get domain + * + * @return string + */ + public function getDomain() + { + return $this->domain; + } + + /** + * Set description + * + * @param string $description + * @return Domain + */ + public function setDescription($description) + { + $this->description = $description; + + return $this; + } + + /** + * Get description + * + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * Get aliases + * + * @return integer + */ + public function getAliases() + { + return $this->Aliases; + } + + /** + * Get mailboxes + * + * @return integer + */ + public function getMailboxes() + { + return $this->Mailboxes; + } + + /** + * Set quota + * + * @param integer $quota + * @return Domain + */ + public function setQuota($quota) + { + $this->quota = $quota; + + return $this; + } + + /** + * Get quota + * + * @return integer + */ + public function getQuota() + { + return $this->quota; + } + + /** + * Set transport + * + * @param string $transport + * @return Domain + */ + public function setTransport($transport) + { + $this->transport = $transport; + + return $this; + } + + /** + * Get transport + * + * @return string + */ + public function getTransport() + { + return $this->transport; + } + + /** + * Set backupmx + * + * @param boolean $backupmx + * @return Domain + */ + public function setBackupmx($backupmx) + { + $this->backupmx = $backupmx; + + return $this; + } + + /** + * Get backupmx + * + * @return boolean + */ + public function getBackupmx() + { + return $this->backupmx; + } + + /** + * Set active + * + * @param boolean $active + * @return Domain + */ + public function setActive($active) + { + $this->active = $active; + + return $this; + } + + /** + * Get active + * + * @return boolean + */ + public function getActive() + { + return $this->active; + } + + /** + * Set homedir + * + * @param string $homedir + * @return Domain + */ + public function setHomedir($homedir) + { + $this->homedir = $homedir; + + return $this; + } + + /** + * Get homedir + * + * @return string + */ + public function getHomedir() + { + return $this->homedir; + } + + /** + * Set maildir + * + * @param string $maildir + * @return Domain + */ + public function setMaildir($maildir) + { + $this->maildir = $maildir; + + return $this; + } + + /** + * Get maildir + * + * @return string + */ + public function getMaildir() + { + return $this->maildir; + } + + /** + * Set uid + * + * @param integer $uid + * @return Domain + */ + public function setUid($uid) + { + $this->uid = $uid; + + return $this; + } + + /** + * Get uid + * + * @return integer + */ + public function getUid() + { + return $this->uid; + } + + /** + * Set gid + * + * @param integer $gid + * @return Domain + */ + public function setGid($gid) + { + $this->gid = $gid; + + return $this; + } + + /** + * Get gid + * + * @return integer + */ + public function getGid() + { + return $this->gid; + } + + /** + * Set created + * + * @param \DateTime $created + * @return Domain + */ + public function setCreated($created) + { + $this->created = $created; + + return $this; + } + + /** + * Get created + * + * @return \DateTime + */ + public function getCreated() + { + return $this->created; + } + + /** + * Set modified + * + * @param \DateTime $modified + * @return Domain + */ + public function setModified($modified) + { + $this->modified = $modified; + + return $this; + } + + /** + * Get modified + * + * @return \DateTime + */ + public function getModified() + { + return $this->modified; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Add Mailboxes + * + * @param Entities\Mailbox $mailboxes + * @return Domain + */ + public function addMailbox(\Entities\Mailbox $mailboxes) + { + $this->Mailboxes[] = $mailboxes; + + return $this; + } + + /** + * Remove Mailboxes + * + * @param Entities\Mailbox $mailboxes + */ + public function removeMailbox(\Entities\Mailbox $mailboxes) + { + $this->Mailboxes->removeElement($mailboxes); + } + + /** + * Add Aliases + * + * @param Entities\Alias $aliases + * @return Domain + */ + public function addAlias(\Entities\Alias $aliases) + { + $this->Aliases[] = $aliases; + + return $this; + } + + /** + * Remove Aliases + * + * @param Entities\Alias $aliases + */ + public function removeAlias(\Entities\Alias $aliases) + { + $this->Aliases->removeElement($aliases); + } + + /** + * Add Logs + * + * @param Entities\Log $logs + * @return Domain + */ + public function addLog(\Entities\Log $logs) + { + $this->Logs[] = $logs; + + return $this; + } + + /** + * Remove Logs + * + * @param Entities\Log $logs + */ + public function removeLog(\Entities\Log $logs) + { + $this->Logs->removeElement($logs); + } + + /** + * Get Logs + * + * @return Doctrine\Common\Collections\Collection + */ + public function getLogs() + { + return $this->Logs; + } + + /** + * Add Admins + * + * @param Entities\Admin $admins + * @return Domain + */ + public function addAdmin(\Entities\Admin $admins) + { + $this->Admins[] = $admins; + + return $this; + } + + /** + * Remove Admins + * + * @param Entities\Admin $admins + */ + public function removeAdmin(\Entities\Admin $admins) + { + $this->Admins->removeElement($admins); + } + + /** + * Get Admins + * + * @return Doctrine\Common\Collections\Collection + */ + public function getAdmins() + { + return $this->Admins; + } + + + + /** + * Set max_aliases + * + * @param integer $maxAliases + * @return Domain + */ + public function setMaxAliases($maxAliases) + { + $this->max_aliases = $maxAliases; + + return $this; + } + + /** + * Get max_aliases + * + * @return integer + */ + public function getMaxAliases() + { + return $this->max_aliases; + } + + /** + * Set max_mailboxes + * + * @param integer $maxMailboxes + * @return Domain + */ + public function setMaxMailboxes($maxMailboxes) + { + $this->max_mailboxes = $maxMailboxes; + + return $this; + } + + /** + * Get max_mailboxes + * + * @return integer + */ + public function getMaxMailboxes() + { + return $this->max_mailboxes; + } + + + + /** + * Set max_quota + * + * @param integer $maxQuota + * @return Domain + */ + public function setMaxQuota($maxQuota) + { + $this->max_quota = $maxQuota; + + return $this; + } + + /** + * Get max_quota + * + * @return integer + */ + public function getMaxQuota() + { + return $this->max_quota; + } + + + + /** + * Set alias_count + * + * @param bigint $aliasCount + * @return Domain + */ + public function setAliasCount($aliasCount) + { + $this->alias_count = $aliasCount; + return $this; + } + + /** + * Get alias_count + * + * @return bigint + */ + public function getAliasCount() + { + return $this->alias_count; + } + + /** + * Increase alias_count + * + * @return void + */ + public function increaseAliasCount() + { + $this->alias_count += 1; + } + + /** + * Decrease alias_count + * + * @return void + */ + public function decreaseAliasCount() + { + if( $this->alias_count > 0 ) + $this->alias_count -= 1; + } + + + + /** + * Set mailbox_count + * + * @param bigint $mailboxCount + * @return Domain + */ + public function setMailboxCount($mailboxCount) + { + $this->mailbox_count = $mailboxCount; + return $this; + } + + /** + * Get mailbox_count + * + * @return bigint + */ + public function getMailboxCount() + { + return $this->mailbox_count; + } + + /** + * Increase mailbox_count + * + * @return void + */ + public function increaseMailboxCount() + { + $this->mailbox_count += 1; + } + + /** + * Decrease mailbox_count + * + * @return void + */ + public function decreaseMailboxCount() + { + if( $this->mailbox_count > 0 ) + $this->mailbox_count -= 1; + } + + /** + * Add Mailboxes + * + * @param \Entities\Mailbox $mailboxes + * @return Domain + */ + public function addMailboxe(\Entities\Mailbox $mailboxes) + { + $this->Mailboxes[] = $mailboxes; + + return $this; + } + + /** + * Remove Mailboxes + * + * @param \Entities\Mailbox $mailboxes + */ + public function removeMailboxe(\Entities\Mailbox $mailboxes) + { + $this->Mailboxes->removeElement($mailboxes); + } + + /** + * Add Aliases + * + * @param \Entities\Alias $aliases + * @return Domain + */ + public function addAliase(\Entities\Alias $aliases) + { + $this->Aliases[] = $aliases; + + return $this; + } + + /** + * Remove Aliases + * + * @param \Entities\Alias $aliases + */ + public function removeAliase(\Entities\Alias $aliases) + { + $this->Aliases->removeElement($aliases); + } + /** + * @var \Doctrine\Common\Collections\Collection + */ + private $Preferences; + + + /** + * Add Preferences + * + * @param \Entities\DomainPreference $preferences + * @return Domain + */ + public function addPreference(\Entities\DomainPreference $preferences) + { + $this->Preferences[] = $preferences; + + return $this; + } + + /** + * Remove Preferences + * + * @param \Entities\DomainPreference $preferences + */ + public function removePreference(\Entities\DomainPreference $preferences) + { + $this->Preferences->removeElement($preferences); + } + + /** + * Get Preferences + * + * @return \Doctrine\Common\Collections\Collection + */ + public function getPreferences() + { + return $this->Preferences; + } + /** + * @var \Doctrine\Common\Collections\Collection + */ + private $Archives; + + + /** + * Add Archives + * + * @param \Entities\Archive $archives + * @return Domain + */ + public function addArchive(\Entities\Archive $archives) + { + $this->Archives[] = $archives; + + return $this; + } + + /** + * Remove Archives + * + * @param \Entities\Archive $archives + */ + public function removeArchive(\Entities\Archive $archives) + { + $this->Archives->removeElement($archives); + } + + /** + * Get Archives + * + * @return \Doctrine\Common\Collections\Collection + */ + public function getArchives() + { + return $this->Archives; + } +} diff --git a/application/Entities/DomainPreference.php b/application/Entities/DomainPreference.php new file mode 100644 index 0000000..a97006e --- /dev/null +++ b/application/Entities/DomainPreference.php @@ -0,0 +1,195 @@ +attribute = $attribute; + + return $this; + } + + /** + * Get attribute + * + * @return string + */ + public function getAttribute() + { + return $this->attribute; + } + + /** + * Set ix + * + * @param integer $ix + * @return DomainPreference + */ + public function setIx($ix) + { + $this->ix = $ix; + + return $this; + } + + /** + * Get ix + * + * @return integer + */ + public function getIx() + { + return $this->ix; + } + + /** + * Set op + * + * @param string $op + * @return DomainPreference + */ + public function setOp($op) + { + $this->op = $op; + + return $this; + } + + /** + * Get op + * + * @return string + */ + public function getOp() + { + return $this->op; + } + + /** + * Set value + * + * @param string $value + * @return DomainPreference + */ + public function setValue($value) + { + $this->value = $value; + + return $this; + } + + /** + * Get value + * + * @return string + */ + public function getValue() + { + return $this->value; + } + + /** + * Set expire + * + * @param integer $expire + * @return DomainPreference + */ + public function setExpire($expire) + { + $this->expire = $expire; + + return $this; + } + + /** + * Get expire + * + * @return integer + */ + public function getExpire() + { + return $this->expire; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set Domain + * + * @param \Entities\Domain $domain + * @return DomainPreference + */ + public function setDomain(\Entities\Domain $domain = null) + { + $this->Domain = $domain; + + return $this; + } + + /** + * Get Domain + * + * @return \Entities\Domain + */ + public function getDomain() + { + return $this->Domain; + } +} diff --git a/application/Entities/Log.php b/application/Entities/Log.php new file mode 100644 index 0000000..faaaee3 --- /dev/null +++ b/application/Entities/Log.php @@ -0,0 +1,191 @@ +action = $action; + + return $this; + } + + /** + * Get action + * + * @return string + */ + public function getAction() + { + return $this->action; + } + + /** + * Set data + * + * @param string $data + * @return Log + */ + public function setData($data) + { + $this->data = $data; + + return $this; + } + + /** + * Get data + * + * @return string + */ + public function getData() + { + return $this->data; + } + + /** + * Set timestamp + * + * @param \DateTime $timestamp + * @return Log + */ + public function setTimestamp($timestamp) + { + $this->timestamp = $timestamp; + + return $this; + } + + /** + * Get timestamp + * + * @return \DateTime + */ + public function getTimestamp() + { + return $this->timestamp; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set Admin + * + * @param Entities\Admin $admin + * @return Log + */ + public function setAdmin(\Entities\Admin $admin = null) + { + $this->Admin = $admin; + + return $this; + } + + /** + * Get Admin + * + * @return Entities\Admin + */ + public function getAdmin() + { + return $this->Admin; + } + + /** + * Set Domain + * + * @param Entities\Domain $domain + * @return Log + */ + public function setDomain(\Entities\Domain $domain = null) + { + $this->Domain = $domain; + + return $this; + } + + /** + * Get Domain + * + * @return Entities\Domain + */ + public function getDomain() + { + return $this->Domain; + } +} diff --git a/application/Entities/Mailbox.php b/application/Entities/Mailbox.php new file mode 100644 index 0000000..dde9d06 --- /dev/null +++ b/application/Entities/Mailbox.php @@ -0,0 +1,744 @@ +Preferences = new \Doctrine\Common\Collections\ArrayCollection(); + } + + /** + * Set username + * + * @param string $username + * @return Mailbox + */ + public function setUsername($username) + { + $this->username = $username; + + return $this; + } + + /** + * Get username + * + * @return string + */ + public function getUsername() + { + return $this->username; + } + + /** + * Set password + * + * @param string $password + * @return Mailbox + */ + public function setPassword($password) + { + $this->password = $password; + + return $this; + } + + /** + * Get password + * + * @return string + */ + public function getPassword() + { + return $this->password; + } + + /** + * Set name + * + * @param string $name + * @return Mailbox + */ + public function setName($name) + { + $this->name = $name; + + return $this; + } + + /** + * Get name + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Set alt_email + * + * @param string $altEmail + * @return Mailbox + */ + public function setAltEmail($altEmail) + { + $this->alt_email = $altEmail; + + return $this; + } + + /** + * Get alt_email + * + * @return string + */ + public function getAltEmail() + { + return $this->alt_email; + } + + /** + * Set quota + * + * @param integer $quota + * @return Mailbox + */ + public function setQuota($quota) + { + $this->quota = $quota; + + return $this; + } + + /** + * Get quota + * + * @return integer + */ + public function getQuota() + { + return $this->quota; + } + + /** + * Set local_part + * + * @param string $localPart + * @return Mailbox + */ + public function setLocalPart($localPart) + { + $this->local_part = $localPart; + + return $this; + } + + /** + * Get local_part + * + * @return string + */ + public function getLocalPart() + { + return $this->local_part; + } + + /** + * Set active + * + * @param boolean $active + * @return Mailbox + */ + public function setActive($active) + { + $this->active = $active; + + return $this; + } + + /** + * Get active + * + * @return boolean + */ + public function getActive() + { + return $this->active; + } + + /** + * Set access_restriction + * + * @param string $accessRestriction + * @return Mailbox + */ + public function setAccessRestriction($accessRestriction) + { + $this->access_restriction = $accessRestriction; + + return $this; + } + + /** + * Get access_restriction + * + * @return string + */ + public function getAccessRestriction() + { + return $this->access_restriction; + } + + /** + * Set homedir + * + * @param string $homedir + * @return Mailbox + */ + public function setHomedir($homedir) + { + $this->homedir = $homedir; + + return $this; + } + + /** + * Get homedir + * + * @return string + */ + public function getHomedir() + { + return $this->homedir; + } + + /** + * Set maildir + * + * @param string $maildir + * @return Mailbox + */ + public function setMaildir($maildir) + { + $this->maildir = $maildir; + + return $this; + } + + /** + * Get maildir + * + * @return string + */ + public function getMaildir() + { + return $this->maildir; + } + + /** + * Get maildir + * + * @return string + */ + public function getCleanedMaildir() + { + return self::cleanMaildir( $this->getMaildir() ); + } + + /** + * Set uid + * + * @param integer $uid + * @return Mailbox + */ + public function setUid($uid) + { + $this->uid = $uid; + + return $this; + } + + /** + * Get uid + * + * @return integer + */ + public function getUid() + { + return $this->uid; + } + + /** + * Set gid + * + * @param integer $gid + * @return Mailbox + */ + public function setGid($gid) + { + $this->gid = $gid; + + return $this; + } + + /** + * Get gid + * + * @return integer + */ + public function getGid() + { + return $this->gid; + } + + /** + * Set created + * + * @param \DateTime $created + * @return Mailbox + */ + public function setCreated($created) + { + $this->created = $created; + + return $this; + } + + /** + * Get created + * + * @return \DateTime + */ + public function getCreated() + { + return $this->created; + } + + /** + * Set modified + * + * @param \DateTime $modified + * @return Mailbox + */ + public function setModified($modified) + { + $this->modified = $modified; + + return $this; + } + + /** + * Get modified + * + * @return \DateTime + */ + public function getModified() + { + return $this->modified; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Add Preferences + * + * @param Entities\MailboxPreference $preferences + * @return Mailbox + */ + public function addPreference(\Entities\MailboxPreference $preferences) + { + $this->Preferences[] = $preferences; + + return $this; + } + + /** + * Remove Preferences + * + * @param Entities\MailboxPreference $preferences + */ + public function removePreference(\Entities\MailboxPreference $preferences) + { + $this->Preferences->removeElement($preferences); + } + + /** + * Get Preferences + * + * @return Doctrine\Common\Collections\Collection + */ + public function getPreferences() + { + return $this->Preferences; + } + + /** + * @var Entities\Domain + */ + private $Domain; + + + /** + * Set Domain + * + * @param Entities\Domain $domain + * @return Mailbox + */ + public function setDomain(\Entities\Domain $domain = null) + { + $this->Domain = $domain; + + return $this; + } + + /** + * Get Domain + * + * @return Entities\Domain + */ + public function getDomain() + { + return $this->Domain; + } + + /** + * Add Preferences + * + * @param Entities\MailboxPreference $preferences + * @return Mailbox + */ + public function addMailboxPreference(\Entities\MailboxPreference $preferences) + { + $this->Preferences[] = $preferences; + return $this; + } + + /** + * Set the maildir + * + * Replaces the following characters in the $maildir parameter: + * + * %u - the local part of the username (email address) + * %d - the domain part of the username (email address) + * %m - the username (email address) + * + * FIXME refactor formatMaildir/Homedir() + * FIXME allow for multiple storage formats including uniform hashing + * + * @param string $maildir The maildir format + * @return string The newly created maildir (also set in the object) + */ + public function formatMaildir( $maildir = '' ) + { + $this->setMaildir( self::substitute( $this->getUsername(), $maildir ) ); + return $this->getMaildir(); + } + + /** + * Set the homedir + * + * Replaces the following characters in the $homedir parameter: + * + * %u - the local part of the username (email address) + * %d - the domain part of the username (email address) + * %m - the username (email address) + * + * FIXME refactor formatMaildir/Homedir() + * FIXME allow for multiple storage formats including uniform hashing + * + * @param string $homedir The homedir format + * @return string The newly created homedir (also set in the object) + */ + public function formatHomedir( $homedir = '' ) + { + $this->setHomedir( self::substitute( $this->getUsername(), $homedir ) ); + return $this->getHomedir(); + } + + /** + * Replaces the following characters in the $str parameter: + * + * %u - the local part of the username (email address) + * %d - the domain part of the username (email address) + * %m - the username (email address) + * + * @param string $email An email address used to extract the domain name + * @param string $str The format string + * @return string The newly created maildir (also set in the object) + */ + public static function substitute( $email, $str ) + { + list( $un, $dn ) = explode( '@', $email ); + + $str = str_replace ( '%u', $un, $str ); + $str = str_replace ( '%d', $dn, $str ); + $str = str_replace ( '%m', $email, $str ); + + return $str; + } + + /** + * Set homedir_size + * + * @param integer $homedirSize + * @return Mailbox + */ + public function setHomedirSize($homedirSize) + { + $this->homedir_size = $homedirSize; + + return $this; + } + + /** + * Get homedir_size + * + * @return integer + */ + public function getHomedirSize() + { + return $this->homedir_size; + } + + /** + * Set maildir_size + * + * @param integer $maildirSize + * @return Mailbox + */ + public function setMaildirSize($maildirSize) + { + $this->maildir_size = $maildirSize; + + return $this; + } + + /** + * Get maildir_size + * + * @return integer + */ + public function getMaildirSize() + { + return $this->maildir_size; + } + + /** + * Set size_at + * + * @param \DateTime $sizeAt + * @return Mailbox + */ + public function setSizeAt($sizeAt) + { + $this->size_at = $sizeAt; + + return $this; + } + + /** + * Get size_at + * + * @return \DateTime + */ + public function getSizeAt() + { + return $this->size_at; + } + + /** + * Clean a maildir string into a standard filesystem path + * + * For example, turns: ''maildir:/srv/vmail/example.com/jbloggs/mail:LAYOUT=fs'' + * into: /srv/vmail/example.com/jbloggs/mail + * + * @param string $maildir The maildir string + * @return string The path from $maildir + */ + public static function cleanMaildir( $maildir ) + { + // typical maildir that needs to be cleaned: + // maildir:/srv/vmail/example.com/jbloggs/mail:LAYOUT=fs + if( substr( $maildir, 0, 8 ) == 'maildir:' ) + $maildir = substr( $maildir, 8 ); + + if( substr( $maildir, strrpos( $maildir, ':' ) + 1, 6 ) == 'LAYOUT' ) + $maildir = substr( $maildir, 0, strrpos( $maildir, ':' ) ); + + return $maildir; + } + /** + * @var \Entities\DirectoryEntry + */ + private $DirectoryEntry; + + + /** + * Set DirectoryEntry + * + * @param \Entities\DirectoryEntry $directoryEntry + * @return Mailbox + */ + public function setDirectoryEntry(\Entities\DirectoryEntry $directoryEntry = null) + { + $this->DirectoryEntry = $directoryEntry; + + return $this; + } + + /** + * Get DirectoryEntry + * + * @return \Entities\DirectoryEntry + */ + public function getDirectoryEntry() + { + return $this->DirectoryEntry; + } + /** + * @var boolean + */ + private $delete_pending; + + + /** + * Set delete_pending + * + * @param boolean $deletePending + * + * @return Mailbox + */ + public function setDeletePending($deletePending) + { + $this->delete_pending = $deletePending; + + return $this; + } + + /** + * Get delete_pending + * + * @return boolean + */ + public function getDeletePending() + { + return $this->delete_pending; + } +} diff --git a/application/Entities/MailboxPreference.php b/application/Entities/MailboxPreference.php new file mode 100644 index 0000000..6e5ab3c --- /dev/null +++ b/application/Entities/MailboxPreference.php @@ -0,0 +1,195 @@ +attribute = $attribute; + + return $this; + } + + /** + * Get attribute + * + * @return string + */ + public function getAttribute() + { + return $this->attribute; + } + + /** + * Set ix + * + * @param integer $ix + * @return MailboxPreference + */ + public function setIx($ix) + { + $this->ix = $ix; + + return $this; + } + + /** + * Get ix + * + * @return integer + */ + public function getIx() + { + return $this->ix; + } + + /** + * Set op + * + * @param string $op + * @return MailboxPreference + */ + public function setOp($op) + { + $this->op = $op; + + return $this; + } + + /** + * Get op + * + * @return string + */ + public function getOp() + { + return $this->op; + } + + /** + * Set value + * + * @param string $value + * @return MailboxPreference + */ + public function setValue($value) + { + $this->value = $value; + + return $this; + } + + /** + * Get value + * + * @return string + */ + public function getValue() + { + return $this->value; + } + + /** + * Set expire + * + * @param integer $expire + * @return MailboxPreference + */ + public function setExpire($expire) + { + $this->expire = $expire; + + return $this; + } + + /** + * Get expire + * + * @return integer + */ + public function getExpire() + { + return $this->expire; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set Mailbox + * + * @param Entities\Mailbox $mailbox + * @return MailboxPreference + */ + public function setMailbox(\Entities\Mailbox $mailbox = null) + { + $this->Mailbox = $mailbox; + + return $this; + } + + /** + * Get Mailbox + * + * @return Entities\Mailbox + */ + public function getMailbox() + { + return $this->Mailbox; + } +} diff --git a/application/Entities/RememberMe.php b/application/Entities/RememberMe.php new file mode 100644 index 0000000..4da3ca6 --- /dev/null +++ b/application/Entities/RememberMe.php @@ -0,0 +1,224 @@ +userhash = $userhash; + + return $this; + } + + /** + * Get userhash + * + * @return string + */ + public function getUserhash() + { + return $this->userhash; + } + + /** + * Set ckey + * + * @param string $ckey + * @return RememberMe + */ + public function setCkey($ckey) + { + $this->ckey = $ckey; + + return $this; + } + + /** + * Get ckey + * + * @return string + */ + public function getCkey() + { + return $this->ckey; + } + + /** + * Set original_ip + * + * @param string $originalIp + * @return RememberMe + */ + public function setOriginalIp($originalIp) + { + $this->original_ip = $originalIp; + + return $this; + } + + /** + * Get original_ip + * + * @return string + */ + public function getOriginalIp() + { + return $this->original_ip; + } + + /** + * Set expires + * + * @param \DateTime $expires + * @return RememberMe + */ + public function setExpires($expires) + { + $this->expires = $expires; + + return $this; + } + + /** + * Get expires + * + * @return \DateTime + */ + public function getExpires() + { + return $this->expires; + } + + /** + * Set created + * + * @param \DateTime $created + * @return RememberMe + */ + public function setCreated($created) + { + $this->created = $created; + + return $this; + } + + /** + * Get created + * + * @return \DateTime + */ + public function getCreated() + { + return $this->created; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set User + * + * @param \Entities\Admin $user + * @return RememberMe + */ + public function setUser(\Entities\Admin $user = null) + { + $this->User = $user; + + return $this; + } + + /** + * Get User + * + * @return \Entities\Admin + */ + public function getUser() + { + return $this->User; + } + /** + * @var \DateTime + */ + private $last_used; + + + /** + * Set last_used + * + * @param \DateTime $lastUsed + * @return RememberMe + */ + public function setLastUsed($lastUsed) + { + $this->last_used = $lastUsed; + + return $this; + } + + /** + * Get last_used + * + * @return \DateTime + */ + public function getLastUsed() + { + return $this->last_used; + } + +} diff --git a/application/Proxies/__CG__EntitiesAdmin.php b/application/Proxies/__CG__EntitiesAdmin.php new file mode 100644 index 0000000..8825efb --- /dev/null +++ b/application/Proxies/__CG__EntitiesAdmin.php @@ -0,0 +1,708 @@ +__initializer__ = $initializer; + $this->__cloner__ = $cloner; + } + + + + + + + + /** + * + * @return array + */ + public function __sleep() + { + if ($this->__isInitialized__) { + return array('__isInitialized__', 'username', 'password', 'super', 'active', 'created', 'modified', 'id', 'Admin', 'Logs', 'Domains', 'Preferences', 'RememberMes', 'Archives', '_className', '_preferenceClassName', '_cache', '_namespace'); + } + + return array('__isInitialized__', 'username', 'password', 'super', 'active', 'created', 'modified', 'id', 'Admin', 'Logs', 'Domains', 'Preferences', 'RememberMes', 'Archives', '_className', '_preferenceClassName', '_cache', '_namespace'); + } + + /** + * + */ + public function __wakeup() + { + if ( ! $this->__isInitialized__) { + $this->__initializer__ = function (Admin $proxy) { + $proxy->__setInitializer(null); + $proxy->__setCloner(null); + + $existingProperties = get_object_vars($proxy); + + foreach ($proxy->__getLazyProperties() as $property => $defaultValue) { + if ( ! array_key_exists($property, $existingProperties)) { + $proxy->$property = $defaultValue; + } + } + }; + + } + } + + /** + * + */ + public function __clone() + { + $this->__cloner__ && $this->__cloner__->__invoke($this, '__clone', array()); + } + + /** + * Forces initialization of the proxy + */ + public function __load() + { + $this->__initializer__ && $this->__initializer__->__invoke($this, '__load', array()); + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __isInitialized() + { + return $this->__isInitialized__; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __setInitialized($initialized) + { + $this->__isInitialized__ = $initialized; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __setInitializer(\Closure $initializer = null) + { + $this->__initializer__ = $initializer; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __getInitializer() + { + return $this->__initializer__; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __setCloner(\Closure $cloner = null) + { + $this->__cloner__ = $cloner; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific cloning logic + */ + public function __getCloner() + { + return $this->__cloner__; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + * @static + */ + public function __getLazyProperties() + { + return self::$lazyPropertiesDefaults; + } + + + /** + * {@inheritDoc} + */ + public function setUsername($username) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setUsername', array($username)); + + return parent::setUsername($username); + } + + /** + * {@inheritDoc} + */ + public function getUsername() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getUsername', array()); + + return parent::getUsername(); + } + + /** + * {@inheritDoc} + */ + public function getEmail() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getEmail', array()); + + return parent::getEmail(); + } + + /** + * {@inheritDoc} + */ + public function getFormattedName() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getFormattedName', array()); + + return parent::getFormattedName(); + } + + /** + * {@inheritDoc} + */ + public function setPassword($password) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setPassword', array($password)); + + return parent::setPassword($password); + } + + /** + * {@inheritDoc} + */ + public function getPassword() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getPassword', array()); + + return parent::getPassword(); + } + + /** + * {@inheritDoc} + */ + public function setSuper($super) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setSuper', array($super)); + + return parent::setSuper($super); + } + + /** + * {@inheritDoc} + */ + public function getSuper() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getSuper', array()); + + return parent::getSuper(); + } + + /** + * {@inheritDoc} + */ + public function isSuper() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'isSuper', array()); + + return parent::isSuper(); + } + + /** + * {@inheritDoc} + */ + public function setActive($active) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setActive', array($active)); + + return parent::setActive($active); + } + + /** + * {@inheritDoc} + */ + public function getActive() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getActive', array()); + + return parent::getActive(); + } + + /** + * {@inheritDoc} + */ + public function setCreated($created) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setCreated', array($created)); + + return parent::setCreated($created); + } + + /** + * {@inheritDoc} + */ + public function getCreated() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getCreated', array()); + + return parent::getCreated(); + } + + /** + * {@inheritDoc} + */ + public function setModified($modified) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setModified', array($modified)); + + return parent::setModified($modified); + } + + /** + * {@inheritDoc} + */ + public function getModified() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getModified', array()); + + return parent::getModified(); + } + + /** + * {@inheritDoc} + */ + public function getId() + { + if ($this->__isInitialized__ === false) { + return parent::getId(); + } + + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getId', array()); + + return parent::getId(); + } + + /** + * {@inheritDoc} + */ + public function addAdmin(\Entities\AdminPreference $admin) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'addAdmin', array($admin)); + + return parent::addAdmin($admin); + } + + /** + * {@inheritDoc} + */ + public function removeAdmin(\Entities\AdminPreference $admin) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'removeAdmin', array($admin)); + + return parent::removeAdmin($admin); + } + + /** + * {@inheritDoc} + */ + public function getAdmin() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getAdmin', array()); + + return parent::getAdmin(); + } + + /** + * {@inheritDoc} + */ + public function addLog(\Entities\Log $logs) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'addLog', array($logs)); + + return parent::addLog($logs); + } + + /** + * {@inheritDoc} + */ + public function removeLog(\Entities\Log $logs) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'removeLog', array($logs)); + + return parent::removeLog($logs); + } + + /** + * {@inheritDoc} + */ + public function getLogs() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getLogs', array()); + + return parent::getLogs(); + } + + /** + * {@inheritDoc} + */ + public function addDomain(\Entities\Domain $domains) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'addDomain', array($domains)); + + return parent::addDomain($domains); + } + + /** + * {@inheritDoc} + */ + public function removeDomain(\Entities\Domain $domains) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'removeDomain', array($domains)); + + return parent::removeDomain($domains); + } + + /** + * {@inheritDoc} + */ + public function getDomains() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getDomains', array()); + + return parent::getDomains(); + } + + /** + * {@inheritDoc} + */ + public function addPreference(\Entities\AdminPreference $preferences) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'addPreference', array($preferences)); + + return parent::addPreference($preferences); + } + + /** + * {@inheritDoc} + */ + public function removePreference(\Entities\AdminPreference $preferences) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'removePreference', array($preferences)); + + return parent::removePreference($preferences); + } + + /** + * {@inheritDoc} + */ + public function getPreferences() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getPreferences', array()); + + return parent::getPreferences(); + } + + /** + * {@inheritDoc} + */ + public function canManageDomain($domain) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'canManageDomain', array($domain)); + + return parent::canManageDomain($domain); + } + + /** + * {@inheritDoc} + */ + public function addAdminPreference(\Entities\AdminPreference $preferences) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'addAdminPreference', array($preferences)); + + return parent::addAdminPreference($preferences); + } + + /** + * {@inheritDoc} + */ + public function addRememberMe(\Entities\RememberMe $rememberMes) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'addRememberMe', array($rememberMes)); + + return parent::addRememberMe($rememberMes); + } + + /** + * {@inheritDoc} + */ + public function removeRememberMe(\Entities\RememberMe $rememberMes) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'removeRememberMe', array($rememberMes)); + + return parent::removeRememberMe($rememberMes); + } + + /** + * {@inheritDoc} + */ + public function getRememberMes() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getRememberMes', array()); + + return parent::getRememberMes(); + } + + /** + * {@inheritDoc} + */ + public function addArchive(\Entities\Archive $archives) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'addArchive', array($archives)); + + return parent::addArchive($archives); + } + + /** + * {@inheritDoc} + */ + public function removeArchive(\Entities\Archive $archives) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'removeArchive', array($archives)); + + return parent::removeArchive($archives); + } + + /** + * {@inheritDoc} + */ + public function getArchives() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getArchives', array()); + + return parent::getArchives(); + } + + /** + * {@inheritDoc} + */ + public function loadPreference($attribute, $index = 0, $includeExpired = false) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'loadPreference', array($attribute, $index, $includeExpired)); + + return parent::loadPreference($attribute, $index, $includeExpired); + } + + /** + * {@inheritDoc} + */ + public function hasPreference($attribute, $index = 0, $includeExpired = false) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'hasPreference', array($attribute, $index, $includeExpired)); + + return parent::hasPreference($attribute, $index, $includeExpired); + } + + /** + * {@inheritDoc} + */ + public function getPreference($attribute, $index = 0, $includeExpired = false) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getPreference', array($attribute, $index, $includeExpired)); + + return parent::getPreference($attribute, $index, $includeExpired); + } + + /** + * {@inheritDoc} + */ + public function setPreference($attribute, $value, $operator = '=', $expires = 0, $index = 0) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setPreference', array($attribute, $value, $operator, $expires, $index)); + + return parent::setPreference($attribute, $value, $operator, $expires, $index); + } + + /** + * {@inheritDoc} + */ + public function addIndexedPreference($attribute, $value, $operator = '=', $expires = 0, $max = 0) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'addIndexedPreference', array($attribute, $value, $operator, $expires, $max)); + + return parent::addIndexedPreference($attribute, $value, $operator, $expires, $max); + } + + /** + * {@inheritDoc} + */ + public function cleanExpiredPreferences($asOf = NULL, $attribute = NULL) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'cleanExpiredPreferences', array($asOf, $attribute)); + + return parent::cleanExpiredPreferences($asOf, $attribute); + } + + /** + * {@inheritDoc} + */ + public function deletePreference($attribute, $index = NULL) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'deletePreference', array($attribute, $index)); + + return parent::deletePreference($attribute, $index); + } + + /** + * {@inheritDoc} + */ + public function expungePreferences() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'expungePreferences', array()); + + return parent::expungePreferences(); + } + + /** + * {@inheritDoc} + */ + public function getIndexedPreference($attribute, $withIndex = false, $ignoreExpired = true) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getIndexedPreference', array($attribute, $withIndex, $ignoreExpired)); + + return parent::getIndexedPreference($attribute, $withIndex, $ignoreExpired); + } + + /** + * {@inheritDoc} + */ + public function getAssocPreference($attribute, $index = NULL, $ignoreExpired = true) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getAssocPreference', array($attribute, $index, $ignoreExpired)); + + return parent::getAssocPreference($attribute, $index, $ignoreExpired); + } + + /** + * {@inheritDoc} + */ + public function deleteAssocPreference($attribute, $index = NULL) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'deleteAssocPreference', array($attribute, $index)); + + return parent::deleteAssocPreference($attribute, $index); + } + + /** + * {@inheritDoc} + */ + public function _getPreferences() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, '_getPreferences', array()); + + return parent::_getPreferences(); + } + +} diff --git a/application/Proxies/__CG__EntitiesAdminPreference.php b/application/Proxies/__CG__EntitiesAdminPreference.php new file mode 100644 index 0000000..5f9b16c --- /dev/null +++ b/application/Proxies/__CG__EntitiesAdminPreference.php @@ -0,0 +1,345 @@ +__initializer__ = $initializer; + $this->__cloner__ = $cloner; + } + + + + + + + + /** + * + * @return array + */ + public function __sleep() + { + if ($this->__isInitialized__) { + return array('__isInitialized__', 'attribute', 'ix', 'op', 'value', 'expire', 'id', 'Preferences', 'Admin'); + } + + return array('__isInitialized__', 'attribute', 'ix', 'op', 'value', 'expire', 'id', 'Preferences', 'Admin'); + } + + /** + * + */ + public function __wakeup() + { + if ( ! $this->__isInitialized__) { + $this->__initializer__ = function (AdminPreference $proxy) { + $proxy->__setInitializer(null); + $proxy->__setCloner(null); + + $existingProperties = get_object_vars($proxy); + + foreach ($proxy->__getLazyProperties() as $property => $defaultValue) { + if ( ! array_key_exists($property, $existingProperties)) { + $proxy->$property = $defaultValue; + } + } + }; + + } + } + + /** + * + */ + public function __clone() + { + $this->__cloner__ && $this->__cloner__->__invoke($this, '__clone', array()); + } + + /** + * Forces initialization of the proxy + */ + public function __load() + { + $this->__initializer__ && $this->__initializer__->__invoke($this, '__load', array()); + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __isInitialized() + { + return $this->__isInitialized__; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __setInitialized($initialized) + { + $this->__isInitialized__ = $initialized; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __setInitializer(\Closure $initializer = null) + { + $this->__initializer__ = $initializer; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __getInitializer() + { + return $this->__initializer__; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __setCloner(\Closure $cloner = null) + { + $this->__cloner__ = $cloner; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific cloning logic + */ + public function __getCloner() + { + return $this->__cloner__; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + * @static + */ + public function __getLazyProperties() + { + return self::$lazyPropertiesDefaults; + } + + + /** + * {@inheritDoc} + */ + public function setAttribute($attribute) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setAttribute', array($attribute)); + + return parent::setAttribute($attribute); + } + + /** + * {@inheritDoc} + */ + public function getAttribute() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getAttribute', array()); + + return parent::getAttribute(); + } + + /** + * {@inheritDoc} + */ + public function setIx($ix) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setIx', array($ix)); + + return parent::setIx($ix); + } + + /** + * {@inheritDoc} + */ + public function getIx() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getIx', array()); + + return parent::getIx(); + } + + /** + * {@inheritDoc} + */ + public function setOp($op) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setOp', array($op)); + + return parent::setOp($op); + } + + /** + * {@inheritDoc} + */ + public function getOp() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getOp', array()); + + return parent::getOp(); + } + + /** + * {@inheritDoc} + */ + public function setValue($value) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setValue', array($value)); + + return parent::setValue($value); + } + + /** + * {@inheritDoc} + */ + public function getValue() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getValue', array()); + + return parent::getValue(); + } + + /** + * {@inheritDoc} + */ + public function setExpire($expire) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setExpire', array($expire)); + + return parent::setExpire($expire); + } + + /** + * {@inheritDoc} + */ + public function getExpire() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getExpire', array()); + + return parent::getExpire(); + } + + /** + * {@inheritDoc} + */ + public function getId() + { + if ($this->__isInitialized__ === false) { + return parent::getId(); + } + + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getId', array()); + + return parent::getId(); + } + + /** + * {@inheritDoc} + */ + public function setPreferences(\Entities\Admin $preferences = NULL) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setPreferences', array($preferences)); + + return parent::setPreferences($preferences); + } + + /** + * {@inheritDoc} + */ + public function getPreferences() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getPreferences', array()); + + return parent::getPreferences(); + } + + /** + * {@inheritDoc} + */ + public function setAdmin(\Entities\Admin $admin = NULL) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setAdmin', array($admin)); + + return parent::setAdmin($admin); + } + + /** + * {@inheritDoc} + */ + public function getAdmin() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getAdmin', array()); + + return parent::getAdmin(); + } + +} diff --git a/application/Proxies/__CG__EntitiesAlias.php b/application/Proxies/__CG__EntitiesAlias.php new file mode 100644 index 0000000..20e20b2 --- /dev/null +++ b/application/Proxies/__CG__EntitiesAlias.php @@ -0,0 +1,488 @@ +__initializer__ = $initializer; + $this->__cloner__ = $cloner; + } + + + + + + + + /** + * + * @return array + */ + public function __sleep() + { + if ($this->__isInitialized__) { + return array('__isInitialized__', 'address', 'goto', 'active', 'created', 'modified', 'id', 'Domain', 'Preferences', '_className', '_preferenceClassName', '_cache', '_namespace'); + } + + return array('__isInitialized__', 'address', 'goto', 'active', 'created', 'modified', 'id', 'Domain', 'Preferences', '_className', '_preferenceClassName', '_cache', '_namespace'); + } + + /** + * + */ + public function __wakeup() + { + if ( ! $this->__isInitialized__) { + $this->__initializer__ = function (Alias $proxy) { + $proxy->__setInitializer(null); + $proxy->__setCloner(null); + + $existingProperties = get_object_vars($proxy); + + foreach ($proxy->__getLazyProperties() as $property => $defaultValue) { + if ( ! array_key_exists($property, $existingProperties)) { + $proxy->$property = $defaultValue; + } + } + }; + + } + } + + /** + * + */ + public function __clone() + { + $this->__cloner__ && $this->__cloner__->__invoke($this, '__clone', array()); + } + + /** + * Forces initialization of the proxy + */ + public function __load() + { + $this->__initializer__ && $this->__initializer__->__invoke($this, '__load', array()); + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __isInitialized() + { + return $this->__isInitialized__; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __setInitialized($initialized) + { + $this->__isInitialized__ = $initialized; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __setInitializer(\Closure $initializer = null) + { + $this->__initializer__ = $initializer; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __getInitializer() + { + return $this->__initializer__; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __setCloner(\Closure $cloner = null) + { + $this->__cloner__ = $cloner; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific cloning logic + */ + public function __getCloner() + { + return $this->__cloner__; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + * @static + */ + public function __getLazyProperties() + { + return self::$lazyPropertiesDefaults; + } + + + /** + * {@inheritDoc} + */ + public function setAddress($address) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setAddress', array($address)); + + return parent::setAddress($address); + } + + /** + * {@inheritDoc} + */ + public function getAddress() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getAddress', array()); + + return parent::getAddress(); + } + + /** + * {@inheritDoc} + */ + public function setGoto($goto) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setGoto', array($goto)); + + return parent::setGoto($goto); + } + + /** + * {@inheritDoc} + */ + public function getGoto() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getGoto', array()); + + return parent::getGoto(); + } + + /** + * {@inheritDoc} + */ + public function setActive($active) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setActive', array($active)); + + return parent::setActive($active); + } + + /** + * {@inheritDoc} + */ + public function getActive() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getActive', array()); + + return parent::getActive(); + } + + /** + * {@inheritDoc} + */ + public function setCreated($created) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setCreated', array($created)); + + return parent::setCreated($created); + } + + /** + * {@inheritDoc} + */ + public function getCreated() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getCreated', array()); + + return parent::getCreated(); + } + + /** + * {@inheritDoc} + */ + public function setModified($modified) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setModified', array($modified)); + + return parent::setModified($modified); + } + + /** + * {@inheritDoc} + */ + public function getModified() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getModified', array()); + + return parent::getModified(); + } + + /** + * {@inheritDoc} + */ + public function getId() + { + if ($this->__isInitialized__ === false) { + return parent::getId(); + } + + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getId', array()); + + return parent::getId(); + } + + /** + * {@inheritDoc} + */ + public function setDomain(\Entities\Domain $domain = NULL) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setDomain', array($domain)); + + return parent::setDomain($domain); + } + + /** + * {@inheritDoc} + */ + public function getDomain() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getDomain', array()); + + return parent::getDomain(); + } + + /** + * {@inheritDoc} + */ + public function addPreference(\Entities\AliasPreference $preferences) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'addPreference', array($preferences)); + + return parent::addPreference($preferences); + } + + /** + * {@inheritDoc} + */ + public function removePreference(\Entities\AliasPreference $preferences) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'removePreference', array($preferences)); + + return parent::removePreference($preferences); + } + + /** + * {@inheritDoc} + */ + public function getPreferences() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getPreferences', array()); + + return parent::getPreferences(); + } + + /** + * {@inheritDoc} + */ + public function loadPreference($attribute, $index = 0, $includeExpired = false) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'loadPreference', array($attribute, $index, $includeExpired)); + + return parent::loadPreference($attribute, $index, $includeExpired); + } + + /** + * {@inheritDoc} + */ + public function hasPreference($attribute, $index = 0, $includeExpired = false) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'hasPreference', array($attribute, $index, $includeExpired)); + + return parent::hasPreference($attribute, $index, $includeExpired); + } + + /** + * {@inheritDoc} + */ + public function getPreference($attribute, $index = 0, $includeExpired = false) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getPreference', array($attribute, $index, $includeExpired)); + + return parent::getPreference($attribute, $index, $includeExpired); + } + + /** + * {@inheritDoc} + */ + public function setPreference($attribute, $value, $operator = '=', $expires = 0, $index = 0) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setPreference', array($attribute, $value, $operator, $expires, $index)); + + return parent::setPreference($attribute, $value, $operator, $expires, $index); + } + + /** + * {@inheritDoc} + */ + public function addIndexedPreference($attribute, $value, $operator = '=', $expires = 0, $max = 0) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'addIndexedPreference', array($attribute, $value, $operator, $expires, $max)); + + return parent::addIndexedPreference($attribute, $value, $operator, $expires, $max); + } + + /** + * {@inheritDoc} + */ + public function cleanExpiredPreferences($asOf = NULL, $attribute = NULL) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'cleanExpiredPreferences', array($asOf, $attribute)); + + return parent::cleanExpiredPreferences($asOf, $attribute); + } + + /** + * {@inheritDoc} + */ + public function deletePreference($attribute, $index = NULL) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'deletePreference', array($attribute, $index)); + + return parent::deletePreference($attribute, $index); + } + + /** + * {@inheritDoc} + */ + public function expungePreferences() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'expungePreferences', array()); + + return parent::expungePreferences(); + } + + /** + * {@inheritDoc} + */ + public function getIndexedPreference($attribute, $withIndex = false, $ignoreExpired = true) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getIndexedPreference', array($attribute, $withIndex, $ignoreExpired)); + + return parent::getIndexedPreference($attribute, $withIndex, $ignoreExpired); + } + + /** + * {@inheritDoc} + */ + public function getAssocPreference($attribute, $index = NULL, $ignoreExpired = true) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getAssocPreference', array($attribute, $index, $ignoreExpired)); + + return parent::getAssocPreference($attribute, $index, $ignoreExpired); + } + + /** + * {@inheritDoc} + */ + public function deleteAssocPreference($attribute, $index = NULL) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'deleteAssocPreference', array($attribute, $index)); + + return parent::deleteAssocPreference($attribute, $index); + } + + /** + * {@inheritDoc} + */ + public function _getPreferences() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, '_getPreferences', array()); + + return parent::_getPreferences(); + } + +} diff --git a/application/Proxies/__CG__EntitiesAliasPreference.php b/application/Proxies/__CG__EntitiesAliasPreference.php new file mode 100644 index 0000000..9ce88f4 --- /dev/null +++ b/application/Proxies/__CG__EntitiesAliasPreference.php @@ -0,0 +1,323 @@ +__initializer__ = $initializer; + $this->__cloner__ = $cloner; + } + + + + + + + + /** + * + * @return array + */ + public function __sleep() + { + if ($this->__isInitialized__) { + return array('__isInitialized__', 'attribute', 'ix', 'op', 'value', 'expire', 'id', 'Alias'); + } + + return array('__isInitialized__', 'attribute', 'ix', 'op', 'value', 'expire', 'id', 'Alias'); + } + + /** + * + */ + public function __wakeup() + { + if ( ! $this->__isInitialized__) { + $this->__initializer__ = function (AliasPreference $proxy) { + $proxy->__setInitializer(null); + $proxy->__setCloner(null); + + $existingProperties = get_object_vars($proxy); + + foreach ($proxy->__getLazyProperties() as $property => $defaultValue) { + if ( ! array_key_exists($property, $existingProperties)) { + $proxy->$property = $defaultValue; + } + } + }; + + } + } + + /** + * + */ + public function __clone() + { + $this->__cloner__ && $this->__cloner__->__invoke($this, '__clone', array()); + } + + /** + * Forces initialization of the proxy + */ + public function __load() + { + $this->__initializer__ && $this->__initializer__->__invoke($this, '__load', array()); + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __isInitialized() + { + return $this->__isInitialized__; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __setInitialized($initialized) + { + $this->__isInitialized__ = $initialized; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __setInitializer(\Closure $initializer = null) + { + $this->__initializer__ = $initializer; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __getInitializer() + { + return $this->__initializer__; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __setCloner(\Closure $cloner = null) + { + $this->__cloner__ = $cloner; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific cloning logic + */ + public function __getCloner() + { + return $this->__cloner__; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + * @static + */ + public function __getLazyProperties() + { + return self::$lazyPropertiesDefaults; + } + + + /** + * {@inheritDoc} + */ + public function setAttribute($attribute) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setAttribute', array($attribute)); + + return parent::setAttribute($attribute); + } + + /** + * {@inheritDoc} + */ + public function getAttribute() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getAttribute', array()); + + return parent::getAttribute(); + } + + /** + * {@inheritDoc} + */ + public function setIx($ix) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setIx', array($ix)); + + return parent::setIx($ix); + } + + /** + * {@inheritDoc} + */ + public function getIx() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getIx', array()); + + return parent::getIx(); + } + + /** + * {@inheritDoc} + */ + public function setOp($op) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setOp', array($op)); + + return parent::setOp($op); + } + + /** + * {@inheritDoc} + */ + public function getOp() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getOp', array()); + + return parent::getOp(); + } + + /** + * {@inheritDoc} + */ + public function setValue($value) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setValue', array($value)); + + return parent::setValue($value); + } + + /** + * {@inheritDoc} + */ + public function getValue() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getValue', array()); + + return parent::getValue(); + } + + /** + * {@inheritDoc} + */ + public function setExpire($expire) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setExpire', array($expire)); + + return parent::setExpire($expire); + } + + /** + * {@inheritDoc} + */ + public function getExpire() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getExpire', array()); + + return parent::getExpire(); + } + + /** + * {@inheritDoc} + */ + public function getId() + { + if ($this->__isInitialized__ === false) { + return parent::getId(); + } + + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getId', array()); + + return parent::getId(); + } + + /** + * {@inheritDoc} + */ + public function setAlias(\Entities\Alias $alias = NULL) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setAlias', array($alias)); + + return parent::setAlias($alias); + } + + /** + * {@inheritDoc} + */ + public function getAlias() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getAlias', array()); + + return parent::getAlias(); + } + +} diff --git a/application/Proxies/__CG__EntitiesArchive.php b/application/Proxies/__CG__EntitiesArchive.php new file mode 100644 index 0000000..101a8cb --- /dev/null +++ b/application/Proxies/__CG__EntitiesArchive.php @@ -0,0 +1,521 @@ +__initializer__ = $initializer; + $this->__cloner__ = $cloner; + } + + + + + + + + /** + * + * @return array + */ + public function __sleep() + { + if ($this->__isInitialized__) { + return array('__isInitialized__', 'ARCHIVE_STATUS', 'username', 'status', 'archived_at', 'status_changed_at', 'homedir_server', 'homedir_file', 'homedir_orig_size', 'homedir_size', 'maildir_server', 'maildir_file', 'maildir_orig_size', 'maildir_size', 'data', 'id', 'Domain', 'ArchivedBy'); + } + + return array('__isInitialized__', 'ARCHIVE_STATUS', 'username', 'status', 'archived_at', 'status_changed_at', 'homedir_server', 'homedir_file', 'homedir_orig_size', 'homedir_size', 'maildir_server', 'maildir_file', 'maildir_orig_size', 'maildir_size', 'data', 'id', 'Domain', 'ArchivedBy'); + } + + /** + * + */ + public function __wakeup() + { + if ( ! $this->__isInitialized__) { + $this->__initializer__ = function (Archive $proxy) { + $proxy->__setInitializer(null); + $proxy->__setCloner(null); + + $existingProperties = get_object_vars($proxy); + + foreach ($proxy->__getLazyProperties() as $property => $defaultValue) { + if ( ! array_key_exists($property, $existingProperties)) { + $proxy->$property = $defaultValue; + } + } + }; + + } + } + + /** + * + */ + public function __clone() + { + $this->__cloner__ && $this->__cloner__->__invoke($this, '__clone', array()); + } + + /** + * Forces initialization of the proxy + */ + public function __load() + { + $this->__initializer__ && $this->__initializer__->__invoke($this, '__load', array()); + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __isInitialized() + { + return $this->__isInitialized__; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __setInitialized($initialized) + { + $this->__isInitialized__ = $initialized; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __setInitializer(\Closure $initializer = null) + { + $this->__initializer__ = $initializer; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __getInitializer() + { + return $this->__initializer__; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __setCloner(\Closure $cloner = null) + { + $this->__cloner__ = $cloner; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific cloning logic + */ + public function __getCloner() + { + return $this->__cloner__; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + * @static + */ + public function __getLazyProperties() + { + return self::$lazyPropertiesDefaults; + } + + + /** + * {@inheritDoc} + */ + public function setUsername($username) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setUsername', array($username)); + + return parent::setUsername($username); + } + + /** + * {@inheritDoc} + */ + public function getUsername() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getUsername', array()); + + return parent::getUsername(); + } + + /** + * {@inheritDoc} + */ + public function setStatus($status) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setStatus', array($status)); + + return parent::setStatus($status); + } + + /** + * {@inheritDoc} + */ + public function getStatus() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getStatus', array()); + + return parent::getStatus(); + } + + /** + * {@inheritDoc} + */ + public function setArchivedAt($archivedAt) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setArchivedAt', array($archivedAt)); + + return parent::setArchivedAt($archivedAt); + } + + /** + * {@inheritDoc} + */ + public function getArchivedAt() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getArchivedAt', array()); + + return parent::getArchivedAt(); + } + + /** + * {@inheritDoc} + */ + public function setStatusChangedAt($statusChangedAt) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setStatusChangedAt', array($statusChangedAt)); + + return parent::setStatusChangedAt($statusChangedAt); + } + + /** + * {@inheritDoc} + */ + public function getStatusChangedAt() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getStatusChangedAt', array()); + + return parent::getStatusChangedAt(); + } + + /** + * {@inheritDoc} + */ + public function setHomedirServer($homedirServer) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setHomedirServer', array($homedirServer)); + + return parent::setHomedirServer($homedirServer); + } + + /** + * {@inheritDoc} + */ + public function getHomedirServer() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getHomedirServer', array()); + + return parent::getHomedirServer(); + } + + /** + * {@inheritDoc} + */ + public function setHomedirFile($homedirFile) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setHomedirFile', array($homedirFile)); + + return parent::setHomedirFile($homedirFile); + } + + /** + * {@inheritDoc} + */ + public function getHomedirFile() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getHomedirFile', array()); + + return parent::getHomedirFile(); + } + + /** + * {@inheritDoc} + */ + public function setHomedirOrigSize($homedirOrigSize) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setHomedirOrigSize', array($homedirOrigSize)); + + return parent::setHomedirOrigSize($homedirOrigSize); + } + + /** + * {@inheritDoc} + */ + public function getHomedirOrigSize() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getHomedirOrigSize', array()); + + return parent::getHomedirOrigSize(); + } + + /** + * {@inheritDoc} + */ + public function setHomedirSize($homedirSize) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setHomedirSize', array($homedirSize)); + + return parent::setHomedirSize($homedirSize); + } + + /** + * {@inheritDoc} + */ + public function getHomedirSize() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getHomedirSize', array()); + + return parent::getHomedirSize(); + } + + /** + * {@inheritDoc} + */ + public function setMaildirServer($maildirServer) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setMaildirServer', array($maildirServer)); + + return parent::setMaildirServer($maildirServer); + } + + /** + * {@inheritDoc} + */ + public function getMaildirServer() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getMaildirServer', array()); + + return parent::getMaildirServer(); + } + + /** + * {@inheritDoc} + */ + public function setMaildirFile($maildirFile) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setMaildirFile', array($maildirFile)); + + return parent::setMaildirFile($maildirFile); + } + + /** + * {@inheritDoc} + */ + public function getMaildirFile() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getMaildirFile', array()); + + return parent::getMaildirFile(); + } + + /** + * {@inheritDoc} + */ + public function setMaildirOrigSize($maildirOrigSize) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setMaildirOrigSize', array($maildirOrigSize)); + + return parent::setMaildirOrigSize($maildirOrigSize); + } + + /** + * {@inheritDoc} + */ + public function getMaildirOrigSize() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getMaildirOrigSize', array()); + + return parent::getMaildirOrigSize(); + } + + /** + * {@inheritDoc} + */ + public function setMaildirSize($maildirSize) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setMaildirSize', array($maildirSize)); + + return parent::setMaildirSize($maildirSize); + } + + /** + * {@inheritDoc} + */ + public function getMaildirSize() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getMaildirSize', array()); + + return parent::getMaildirSize(); + } + + /** + * {@inheritDoc} + */ + public function setData($data) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setData', array($data)); + + return parent::setData($data); + } + + /** + * {@inheritDoc} + */ + public function getData() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getData', array()); + + return parent::getData(); + } + + /** + * {@inheritDoc} + */ + public function getId() + { + if ($this->__isInitialized__ === false) { + return parent::getId(); + } + + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getId', array()); + + return parent::getId(); + } + + /** + * {@inheritDoc} + */ + public function setDomain(\Entities\Domain $domain = NULL) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setDomain', array($domain)); + + return parent::setDomain($domain); + } + + /** + * {@inheritDoc} + */ + public function getDomain() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getDomain', array()); + + return parent::getDomain(); + } + + /** + * {@inheritDoc} + */ + public function setArchivedBy(\Entities\Admin $archivedBy = NULL) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setArchivedBy', array($archivedBy)); + + return parent::setArchivedBy($archivedBy); + } + + /** + * {@inheritDoc} + */ + public function getArchivedBy() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getArchivedBy', array()); + + return parent::getArchivedBy(); + } + +} diff --git a/application/Proxies/__CG__EntitiesDatabaseVersion.php b/application/Proxies/__CG__EntitiesDatabaseVersion.php new file mode 100644 index 0000000..808bb9b --- /dev/null +++ b/application/Proxies/__CG__EntitiesDatabaseVersion.php @@ -0,0 +1,257 @@ +__initializer__ = $initializer; + $this->__cloner__ = $cloner; + } + + + + + + + + /** + * + * @return array + */ + public function __sleep() + { + if ($this->__isInitialized__) { + return array('__isInitialized__', 'version', 'id', 'name', 'applied_on'); + } + + return array('__isInitialized__', 'version', 'id', 'name', 'applied_on'); + } + + /** + * + */ + public function __wakeup() + { + if ( ! $this->__isInitialized__) { + $this->__initializer__ = function (DatabaseVersion $proxy) { + $proxy->__setInitializer(null); + $proxy->__setCloner(null); + + $existingProperties = get_object_vars($proxy); + + foreach ($proxy->__getLazyProperties() as $property => $defaultValue) { + if ( ! array_key_exists($property, $existingProperties)) { + $proxy->$property = $defaultValue; + } + } + }; + + } + } + + /** + * + */ + public function __clone() + { + $this->__cloner__ && $this->__cloner__->__invoke($this, '__clone', array()); + } + + /** + * Forces initialization of the proxy + */ + public function __load() + { + $this->__initializer__ && $this->__initializer__->__invoke($this, '__load', array()); + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __isInitialized() + { + return $this->__isInitialized__; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __setInitialized($initialized) + { + $this->__isInitialized__ = $initialized; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __setInitializer(\Closure $initializer = null) + { + $this->__initializer__ = $initializer; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __getInitializer() + { + return $this->__initializer__; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __setCloner(\Closure $cloner = null) + { + $this->__cloner__ = $cloner; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific cloning logic + */ + public function __getCloner() + { + return $this->__cloner__; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + * @static + */ + public function __getLazyProperties() + { + return self::$lazyPropertiesDefaults; + } + + + /** + * {@inheritDoc} + */ + public function setVersion($version) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setVersion', array($version)); + + return parent::setVersion($version); + } + + /** + * {@inheritDoc} + */ + public function getVersion() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getVersion', array()); + + return parent::getVersion(); + } + + /** + * {@inheritDoc} + */ + public function getId() + { + if ($this->__isInitialized__ === false) { + return (int) parent::getId(); + } + + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getId', array()); + + return parent::getId(); + } + + /** + * {@inheritDoc} + */ + public function setName($name) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setName', array($name)); + + return parent::setName($name); + } + + /** + * {@inheritDoc} + */ + public function getName() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getName', array()); + + return parent::getName(); + } + + /** + * {@inheritDoc} + */ + public function setAppliedOn($appliedOn) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setAppliedOn', array($appliedOn)); + + return parent::setAppliedOn($appliedOn); + } + + /** + * {@inheritDoc} + */ + public function getAppliedOn() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getAppliedOn', array()); + + return parent::getAppliedOn(); + } + +} diff --git a/application/Proxies/__CG__EntitiesDirectoryEntry.php b/application/Proxies/__CG__EntitiesDirectoryEntry.php new file mode 100644 index 0000000..5f9303c --- /dev/null +++ b/application/Proxies/__CG__EntitiesDirectoryEntry.php @@ -0,0 +1,829 @@ +__initializer__ = $initializer; + $this->__cloner__ = $cloner; + } + + + + + + + + /** + * + * @return array + */ + public function __sleep() + { + if ($this->__isInitialized__) { + return array('__isInitialized__', 'businessCategory', 'carLicense', 'departmentNumber', 'displayName', 'employeeNumber', 'employeeType', 'homePhone', 'homePostalAddress', 'initials', 'jpegPhoto', 'labeledURI', 'mail', 'manager', 'mobile', 'o', 'pager', 'preferredLanguage', 'roomNumber', 'secretary', 'personalTitle', 'sn', 'ou', 'title', 'facsimileTelephoneNumber', 'givenName', 'telephoneNumber', 'vimb_created', 'vimb_update', 'id', 'Mailbox'); + } + + return array('__isInitialized__', 'businessCategory', 'carLicense', 'departmentNumber', 'displayName', 'employeeNumber', 'employeeType', 'homePhone', 'homePostalAddress', 'initials', 'jpegPhoto', 'labeledURI', 'mail', 'manager', 'mobile', 'o', 'pager', 'preferredLanguage', 'roomNumber', 'secretary', 'personalTitle', 'sn', 'ou', 'title', 'facsimileTelephoneNumber', 'givenName', 'telephoneNumber', 'vimb_created', 'vimb_update', 'id', 'Mailbox'); + } + + /** + * + */ + public function __wakeup() + { + if ( ! $this->__isInitialized__) { + $this->__initializer__ = function (DirectoryEntry $proxy) { + $proxy->__setInitializer(null); + $proxy->__setCloner(null); + + $existingProperties = get_object_vars($proxy); + + foreach ($proxy->__getLazyProperties() as $property => $defaultValue) { + if ( ! array_key_exists($property, $existingProperties)) { + $proxy->$property = $defaultValue; + } + } + }; + + } + } + + /** + * + */ + public function __clone() + { + $this->__cloner__ && $this->__cloner__->__invoke($this, '__clone', array()); + } + + /** + * Forces initialization of the proxy + */ + public function __load() + { + $this->__initializer__ && $this->__initializer__->__invoke($this, '__load', array()); + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __isInitialized() + { + return $this->__isInitialized__; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __setInitialized($initialized) + { + $this->__isInitialized__ = $initialized; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __setInitializer(\Closure $initializer = null) + { + $this->__initializer__ = $initializer; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __getInitializer() + { + return $this->__initializer__; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __setCloner(\Closure $cloner = null) + { + $this->__cloner__ = $cloner; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific cloning logic + */ + public function __getCloner() + { + return $this->__cloner__; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + * @static + */ + public function __getLazyProperties() + { + return self::$lazyPropertiesDefaults; + } + + + /** + * {@inheritDoc} + */ + public function setBusinessCategory($businessCategory) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setBusinessCategory', array($businessCategory)); + + return parent::setBusinessCategory($businessCategory); + } + + /** + * {@inheritDoc} + */ + public function getBusinessCategory() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getBusinessCategory', array()); + + return parent::getBusinessCategory(); + } + + /** + * {@inheritDoc} + */ + public function setCarLicense($carLicense) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setCarLicense', array($carLicense)); + + return parent::setCarLicense($carLicense); + } + + /** + * {@inheritDoc} + */ + public function getCarLicense() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getCarLicense', array()); + + return parent::getCarLicense(); + } + + /** + * {@inheritDoc} + */ + public function setDepartmentNumber($departmentNumber) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setDepartmentNumber', array($departmentNumber)); + + return parent::setDepartmentNumber($departmentNumber); + } + + /** + * {@inheritDoc} + */ + public function getDepartmentNumber() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getDepartmentNumber', array()); + + return parent::getDepartmentNumber(); + } + + /** + * {@inheritDoc} + */ + public function setDisplayName($displayName) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setDisplayName', array($displayName)); + + return parent::setDisplayName($displayName); + } + + /** + * {@inheritDoc} + */ + public function getDisplayName() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getDisplayName', array()); + + return parent::getDisplayName(); + } + + /** + * {@inheritDoc} + */ + public function setEmployeeNumber($employeeNumber) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setEmployeeNumber', array($employeeNumber)); + + return parent::setEmployeeNumber($employeeNumber); + } + + /** + * {@inheritDoc} + */ + public function getEmployeeNumber() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getEmployeeNumber', array()); + + return parent::getEmployeeNumber(); + } + + /** + * {@inheritDoc} + */ + public function setEmployeeType($employeeType) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setEmployeeType', array($employeeType)); + + return parent::setEmployeeType($employeeType); + } + + /** + * {@inheritDoc} + */ + public function getEmployeeType() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getEmployeeType', array()); + + return parent::getEmployeeType(); + } + + /** + * {@inheritDoc} + */ + public function setHomePhone($homePhone) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setHomePhone', array($homePhone)); + + return parent::setHomePhone($homePhone); + } + + /** + * {@inheritDoc} + */ + public function getHomePhone() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getHomePhone', array()); + + return parent::getHomePhone(); + } + + /** + * {@inheritDoc} + */ + public function setHomePostalAddress($homePostalAddress) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setHomePostalAddress', array($homePostalAddress)); + + return parent::setHomePostalAddress($homePostalAddress); + } + + /** + * {@inheritDoc} + */ + public function getHomePostalAddress() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getHomePostalAddress', array()); + + return parent::getHomePostalAddress(); + } + + /** + * {@inheritDoc} + */ + public function setInitials($initials) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setInitials', array($initials)); + + return parent::setInitials($initials); + } + + /** + * {@inheritDoc} + */ + public function getInitials() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getInitials', array()); + + return parent::getInitials(); + } + + /** + * {@inheritDoc} + */ + public function setJpegPhoto($jpegPhoto) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setJpegPhoto', array($jpegPhoto)); + + return parent::setJpegPhoto($jpegPhoto); + } + + /** + * {@inheritDoc} + */ + public function getJpegPhoto() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getJpegPhoto', array()); + + return parent::getJpegPhoto(); + } + + /** + * {@inheritDoc} + */ + public function setLabeledURI($labeledURI) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setLabeledURI', array($labeledURI)); + + return parent::setLabeledURI($labeledURI); + } + + /** + * {@inheritDoc} + */ + public function getLabeledURI() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getLabeledURI', array()); + + return parent::getLabeledURI(); + } + + /** + * {@inheritDoc} + */ + public function setMail($mail) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setMail', array($mail)); + + return parent::setMail($mail); + } + + /** + * {@inheritDoc} + */ + public function getMail() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getMail', array()); + + return parent::getMail(); + } + + /** + * {@inheritDoc} + */ + public function setManager($manager) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setManager', array($manager)); + + return parent::setManager($manager); + } + + /** + * {@inheritDoc} + */ + public function getManager() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getManager', array()); + + return parent::getManager(); + } + + /** + * {@inheritDoc} + */ + public function setMobile($mobile) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setMobile', array($mobile)); + + return parent::setMobile($mobile); + } + + /** + * {@inheritDoc} + */ + public function getMobile() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getMobile', array()); + + return parent::getMobile(); + } + + /** + * {@inheritDoc} + */ + public function setO($o) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setO', array($o)); + + return parent::setO($o); + } + + /** + * {@inheritDoc} + */ + public function getO() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getO', array()); + + return parent::getO(); + } + + /** + * {@inheritDoc} + */ + public function setPager($pager) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setPager', array($pager)); + + return parent::setPager($pager); + } + + /** + * {@inheritDoc} + */ + public function getPager() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getPager', array()); + + return parent::getPager(); + } + + /** + * {@inheritDoc} + */ + public function setPreferredLanguage($preferredLanguage) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setPreferredLanguage', array($preferredLanguage)); + + return parent::setPreferredLanguage($preferredLanguage); + } + + /** + * {@inheritDoc} + */ + public function getPreferredLanguage() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getPreferredLanguage', array()); + + return parent::getPreferredLanguage(); + } + + /** + * {@inheritDoc} + */ + public function setRoomNumber($roomNumber) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setRoomNumber', array($roomNumber)); + + return parent::setRoomNumber($roomNumber); + } + + /** + * {@inheritDoc} + */ + public function getRoomNumber() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getRoomNumber', array()); + + return parent::getRoomNumber(); + } + + /** + * {@inheritDoc} + */ + public function setSecretary($secretary) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setSecretary', array($secretary)); + + return parent::setSecretary($secretary); + } + + /** + * {@inheritDoc} + */ + public function getSecretary() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getSecretary', array()); + + return parent::getSecretary(); + } + + /** + * {@inheritDoc} + */ + public function setPersonalTitle($personalTitle) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setPersonalTitle', array($personalTitle)); + + return parent::setPersonalTitle($personalTitle); + } + + /** + * {@inheritDoc} + */ + public function getPersonalTitle() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getPersonalTitle', array()); + + return parent::getPersonalTitle(); + } + + /** + * {@inheritDoc} + */ + public function setSn($sn) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setSn', array($sn)); + + return parent::setSn($sn); + } + + /** + * {@inheritDoc} + */ + public function getSn() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getSn', array()); + + return parent::getSn(); + } + + /** + * {@inheritDoc} + */ + public function setOu($ou) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setOu', array($ou)); + + return parent::setOu($ou); + } + + /** + * {@inheritDoc} + */ + public function getOu() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getOu', array()); + + return parent::getOu(); + } + + /** + * {@inheritDoc} + */ + public function setTitle($title) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setTitle', array($title)); + + return parent::setTitle($title); + } + + /** + * {@inheritDoc} + */ + public function getTitle() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getTitle', array()); + + return parent::getTitle(); + } + + /** + * {@inheritDoc} + */ + public function setFacsimileTelephoneNumber($facsimileTelephoneNumber) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setFacsimileTelephoneNumber', array($facsimileTelephoneNumber)); + + return parent::setFacsimileTelephoneNumber($facsimileTelephoneNumber); + } + + /** + * {@inheritDoc} + */ + public function getFacsimileTelephoneNumber() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getFacsimileTelephoneNumber', array()); + + return parent::getFacsimileTelephoneNumber(); + } + + /** + * {@inheritDoc} + */ + public function setGivenName($givenName) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setGivenName', array($givenName)); + + return parent::setGivenName($givenName); + } + + /** + * {@inheritDoc} + */ + public function getGivenName() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getGivenName', array()); + + return parent::getGivenName(); + } + + /** + * {@inheritDoc} + */ + public function setTelephoneNumber($telephoneNumber) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setTelephoneNumber', array($telephoneNumber)); + + return parent::setTelephoneNumber($telephoneNumber); + } + + /** + * {@inheritDoc} + */ + public function getTelephoneNumber() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getTelephoneNumber', array()); + + return parent::getTelephoneNumber(); + } + + /** + * {@inheritDoc} + */ + public function setVimbCreated($vimbCreated) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setVimbCreated', array($vimbCreated)); + + return parent::setVimbCreated($vimbCreated); + } + + /** + * {@inheritDoc} + */ + public function getVimbCreated() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getVimbCreated', array()); + + return parent::getVimbCreated(); + } + + /** + * {@inheritDoc} + */ + public function setVimbUpdate($vimbUpdate) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setVimbUpdate', array($vimbUpdate)); + + return parent::setVimbUpdate($vimbUpdate); + } + + /** + * {@inheritDoc} + */ + public function getVimbUpdate() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getVimbUpdate', array()); + + return parent::getVimbUpdate(); + } + + /** + * {@inheritDoc} + */ + public function getId() + { + if ($this->__isInitialized__ === false) { + return parent::getId(); + } + + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getId', array()); + + return parent::getId(); + } + + /** + * {@inheritDoc} + */ + public function setMailbox(\Entities\Mailbox $mailbox) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setMailbox', array($mailbox)); + + return parent::setMailbox($mailbox); + } + + /** + * {@inheritDoc} + */ + public function getMailbox() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getMailbox', array()); + + return parent::getMailbox(); + } + +} diff --git a/application/Proxies/__CG__EntitiesDomain.php b/application/Proxies/__CG__EntitiesDomain.php new file mode 100644 index 0000000..2f7dbb3 --- /dev/null +++ b/application/Proxies/__CG__EntitiesDomain.php @@ -0,0 +1,983 @@ +__initializer__ = $initializer; + $this->__cloner__ = $cloner; + } + + + + + + + + /** + * + * @return array + */ + public function __sleep() + { + if ($this->__isInitialized__) { + return array('__isInitialized__', 'domain', 'description', 'quota', 'transport', 'backupmx', 'active', 'homedir', 'maildir', 'uid', 'gid', 'created', 'modified', 'id', 'max_quota', 'max_aliases', 'max_mailboxes', 'alias_count', 'mailbox_count', 'Mailboxes', 'Aliases', 'Logs', 'Admins', 'Preferences', 'Archives', '_className', '_preferenceClassName', '_cache', '_namespace'); + } + + return array('__isInitialized__', 'domain', 'description', 'quota', 'transport', 'backupmx', 'active', 'homedir', 'maildir', 'uid', 'gid', 'created', 'modified', 'id', 'max_quota', 'max_aliases', 'max_mailboxes', 'alias_count', 'mailbox_count', 'Mailboxes', 'Aliases', 'Logs', 'Admins', 'Preferences', 'Archives', '_className', '_preferenceClassName', '_cache', '_namespace'); + } + + /** + * + */ + public function __wakeup() + { + if ( ! $this->__isInitialized__) { + $this->__initializer__ = function (Domain $proxy) { + $proxy->__setInitializer(null); + $proxy->__setCloner(null); + + $existingProperties = get_object_vars($proxy); + + foreach ($proxy->__getLazyProperties() as $property => $defaultValue) { + if ( ! array_key_exists($property, $existingProperties)) { + $proxy->$property = $defaultValue; + } + } + }; + + } + } + + /** + * + */ + public function __clone() + { + $this->__cloner__ && $this->__cloner__->__invoke($this, '__clone', array()); + } + + /** + * Forces initialization of the proxy + */ + public function __load() + { + $this->__initializer__ && $this->__initializer__->__invoke($this, '__load', array()); + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __isInitialized() + { + return $this->__isInitialized__; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __setInitialized($initialized) + { + $this->__isInitialized__ = $initialized; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __setInitializer(\Closure $initializer = null) + { + $this->__initializer__ = $initializer; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __getInitializer() + { + return $this->__initializer__; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __setCloner(\Closure $cloner = null) + { + $this->__cloner__ = $cloner; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific cloning logic + */ + public function __getCloner() + { + return $this->__cloner__; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + * @static + */ + public function __getLazyProperties() + { + return self::$lazyPropertiesDefaults; + } + + + /** + * {@inheritDoc} + */ + public function setDomain($domain) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setDomain', array($domain)); + + return parent::setDomain($domain); + } + + /** + * {@inheritDoc} + */ + public function getDomain() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getDomain', array()); + + return parent::getDomain(); + } + + /** + * {@inheritDoc} + */ + public function setDescription($description) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setDescription', array($description)); + + return parent::setDescription($description); + } + + /** + * {@inheritDoc} + */ + public function getDescription() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getDescription', array()); + + return parent::getDescription(); + } + + /** + * {@inheritDoc} + */ + public function getAliases() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getAliases', array()); + + return parent::getAliases(); + } + + /** + * {@inheritDoc} + */ + public function getMailboxes() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getMailboxes', array()); + + return parent::getMailboxes(); + } + + /** + * {@inheritDoc} + */ + public function setQuota($quota) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setQuota', array($quota)); + + return parent::setQuota($quota); + } + + /** + * {@inheritDoc} + */ + public function getQuota() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getQuota', array()); + + return parent::getQuota(); + } + + /** + * {@inheritDoc} + */ + public function setTransport($transport) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setTransport', array($transport)); + + return parent::setTransport($transport); + } + + /** + * {@inheritDoc} + */ + public function getTransport() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getTransport', array()); + + return parent::getTransport(); + } + + /** + * {@inheritDoc} + */ + public function setBackupmx($backupmx) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setBackupmx', array($backupmx)); + + return parent::setBackupmx($backupmx); + } + + /** + * {@inheritDoc} + */ + public function getBackupmx() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getBackupmx', array()); + + return parent::getBackupmx(); + } + + /** + * {@inheritDoc} + */ + public function setActive($active) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setActive', array($active)); + + return parent::setActive($active); + } + + /** + * {@inheritDoc} + */ + public function getActive() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getActive', array()); + + return parent::getActive(); + } + + /** + * {@inheritDoc} + */ + public function setHomedir($homedir) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setHomedir', array($homedir)); + + return parent::setHomedir($homedir); + } + + /** + * {@inheritDoc} + */ + public function getHomedir() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getHomedir', array()); + + return parent::getHomedir(); + } + + /** + * {@inheritDoc} + */ + public function setMaildir($maildir) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setMaildir', array($maildir)); + + return parent::setMaildir($maildir); + } + + /** + * {@inheritDoc} + */ + public function getMaildir() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getMaildir', array()); + + return parent::getMaildir(); + } + + /** + * {@inheritDoc} + */ + public function setUid($uid) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setUid', array($uid)); + + return parent::setUid($uid); + } + + /** + * {@inheritDoc} + */ + public function getUid() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getUid', array()); + + return parent::getUid(); + } + + /** + * {@inheritDoc} + */ + public function setGid($gid) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setGid', array($gid)); + + return parent::setGid($gid); + } + + /** + * {@inheritDoc} + */ + public function getGid() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getGid', array()); + + return parent::getGid(); + } + + /** + * {@inheritDoc} + */ + public function setCreated($created) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setCreated', array($created)); + + return parent::setCreated($created); + } + + /** + * {@inheritDoc} + */ + public function getCreated() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getCreated', array()); + + return parent::getCreated(); + } + + /** + * {@inheritDoc} + */ + public function setModified($modified) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setModified', array($modified)); + + return parent::setModified($modified); + } + + /** + * {@inheritDoc} + */ + public function getModified() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getModified', array()); + + return parent::getModified(); + } + + /** + * {@inheritDoc} + */ + public function getId() + { + if ($this->__isInitialized__ === false) { + return parent::getId(); + } + + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getId', array()); + + return parent::getId(); + } + + /** + * {@inheritDoc} + */ + public function addMailbox(\Entities\Mailbox $mailboxes) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'addMailbox', array($mailboxes)); + + return parent::addMailbox($mailboxes); + } + + /** + * {@inheritDoc} + */ + public function removeMailbox(\Entities\Mailbox $mailboxes) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'removeMailbox', array($mailboxes)); + + return parent::removeMailbox($mailboxes); + } + + /** + * {@inheritDoc} + */ + public function addAlias(\Entities\Alias $aliases) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'addAlias', array($aliases)); + + return parent::addAlias($aliases); + } + + /** + * {@inheritDoc} + */ + public function removeAlias(\Entities\Alias $aliases) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'removeAlias', array($aliases)); + + return parent::removeAlias($aliases); + } + + /** + * {@inheritDoc} + */ + public function addLog(\Entities\Log $logs) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'addLog', array($logs)); + + return parent::addLog($logs); + } + + /** + * {@inheritDoc} + */ + public function removeLog(\Entities\Log $logs) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'removeLog', array($logs)); + + return parent::removeLog($logs); + } + + /** + * {@inheritDoc} + */ + public function getLogs() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getLogs', array()); + + return parent::getLogs(); + } + + /** + * {@inheritDoc} + */ + public function addAdmin(\Entities\Admin $admins) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'addAdmin', array($admins)); + + return parent::addAdmin($admins); + } + + /** + * {@inheritDoc} + */ + public function removeAdmin(\Entities\Admin $admins) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'removeAdmin', array($admins)); + + return parent::removeAdmin($admins); + } + + /** + * {@inheritDoc} + */ + public function getAdmins() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getAdmins', array()); + + return parent::getAdmins(); + } + + /** + * {@inheritDoc} + */ + public function setMaxAliases($maxAliases) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setMaxAliases', array($maxAliases)); + + return parent::setMaxAliases($maxAliases); + } + + /** + * {@inheritDoc} + */ + public function getMaxAliases() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getMaxAliases', array()); + + return parent::getMaxAliases(); + } + + /** + * {@inheritDoc} + */ + public function setMaxMailboxes($maxMailboxes) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setMaxMailboxes', array($maxMailboxes)); + + return parent::setMaxMailboxes($maxMailboxes); + } + + /** + * {@inheritDoc} + */ + public function getMaxMailboxes() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getMaxMailboxes', array()); + + return parent::getMaxMailboxes(); + } + + /** + * {@inheritDoc} + */ + public function setMaxQuota($maxQuota) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setMaxQuota', array($maxQuota)); + + return parent::setMaxQuota($maxQuota); + } + + /** + * {@inheritDoc} + */ + public function getMaxQuota() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getMaxQuota', array()); + + return parent::getMaxQuota(); + } + + /** + * {@inheritDoc} + */ + public function setAliasCount($aliasCount) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setAliasCount', array($aliasCount)); + + return parent::setAliasCount($aliasCount); + } + + /** + * {@inheritDoc} + */ + public function getAliasCount() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getAliasCount', array()); + + return parent::getAliasCount(); + } + + /** + * {@inheritDoc} + */ + public function increaseAliasCount() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'increaseAliasCount', array()); + + return parent::increaseAliasCount(); + } + + /** + * {@inheritDoc} + */ + public function decreaseAliasCount() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'decreaseAliasCount', array()); + + return parent::decreaseAliasCount(); + } + + /** + * {@inheritDoc} + */ + public function setMailboxCount($mailboxCount) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setMailboxCount', array($mailboxCount)); + + return parent::setMailboxCount($mailboxCount); + } + + /** + * {@inheritDoc} + */ + public function getMailboxCount() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getMailboxCount', array()); + + return parent::getMailboxCount(); + } + + /** + * {@inheritDoc} + */ + public function increaseMailboxCount() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'increaseMailboxCount', array()); + + return parent::increaseMailboxCount(); + } + + /** + * {@inheritDoc} + */ + public function decreaseMailboxCount() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'decreaseMailboxCount', array()); + + return parent::decreaseMailboxCount(); + } + + /** + * {@inheritDoc} + */ + public function addMailboxe(\Entities\Mailbox $mailboxes) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'addMailboxe', array($mailboxes)); + + return parent::addMailboxe($mailboxes); + } + + /** + * {@inheritDoc} + */ + public function removeMailboxe(\Entities\Mailbox $mailboxes) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'removeMailboxe', array($mailboxes)); + + return parent::removeMailboxe($mailboxes); + } + + /** + * {@inheritDoc} + */ + public function addAliase(\Entities\Alias $aliases) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'addAliase', array($aliases)); + + return parent::addAliase($aliases); + } + + /** + * {@inheritDoc} + */ + public function removeAliase(\Entities\Alias $aliases) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'removeAliase', array($aliases)); + + return parent::removeAliase($aliases); + } + + /** + * {@inheritDoc} + */ + public function addPreference(\Entities\DomainPreference $preferences) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'addPreference', array($preferences)); + + return parent::addPreference($preferences); + } + + /** + * {@inheritDoc} + */ + public function removePreference(\Entities\DomainPreference $preferences) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'removePreference', array($preferences)); + + return parent::removePreference($preferences); + } + + /** + * {@inheritDoc} + */ + public function getPreferences() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getPreferences', array()); + + return parent::getPreferences(); + } + + /** + * {@inheritDoc} + */ + public function addArchive(\Entities\Archive $archives) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'addArchive', array($archives)); + + return parent::addArchive($archives); + } + + /** + * {@inheritDoc} + */ + public function removeArchive(\Entities\Archive $archives) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'removeArchive', array($archives)); + + return parent::removeArchive($archives); + } + + /** + * {@inheritDoc} + */ + public function getArchives() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getArchives', array()); + + return parent::getArchives(); + } + + /** + * {@inheritDoc} + */ + public function loadPreference($attribute, $index = 0, $includeExpired = false) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'loadPreference', array($attribute, $index, $includeExpired)); + + return parent::loadPreference($attribute, $index, $includeExpired); + } + + /** + * {@inheritDoc} + */ + public function hasPreference($attribute, $index = 0, $includeExpired = false) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'hasPreference', array($attribute, $index, $includeExpired)); + + return parent::hasPreference($attribute, $index, $includeExpired); + } + + /** + * {@inheritDoc} + */ + public function getPreference($attribute, $index = 0, $includeExpired = false) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getPreference', array($attribute, $index, $includeExpired)); + + return parent::getPreference($attribute, $index, $includeExpired); + } + + /** + * {@inheritDoc} + */ + public function setPreference($attribute, $value, $operator = '=', $expires = 0, $index = 0) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setPreference', array($attribute, $value, $operator, $expires, $index)); + + return parent::setPreference($attribute, $value, $operator, $expires, $index); + } + + /** + * {@inheritDoc} + */ + public function addIndexedPreference($attribute, $value, $operator = '=', $expires = 0, $max = 0) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'addIndexedPreference', array($attribute, $value, $operator, $expires, $max)); + + return parent::addIndexedPreference($attribute, $value, $operator, $expires, $max); + } + + /** + * {@inheritDoc} + */ + public function cleanExpiredPreferences($asOf = NULL, $attribute = NULL) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'cleanExpiredPreferences', array($asOf, $attribute)); + + return parent::cleanExpiredPreferences($asOf, $attribute); + } + + /** + * {@inheritDoc} + */ + public function deletePreference($attribute, $index = NULL) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'deletePreference', array($attribute, $index)); + + return parent::deletePreference($attribute, $index); + } + + /** + * {@inheritDoc} + */ + public function expungePreferences() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'expungePreferences', array()); + + return parent::expungePreferences(); + } + + /** + * {@inheritDoc} + */ + public function getIndexedPreference($attribute, $withIndex = false, $ignoreExpired = true) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getIndexedPreference', array($attribute, $withIndex, $ignoreExpired)); + + return parent::getIndexedPreference($attribute, $withIndex, $ignoreExpired); + } + + /** + * {@inheritDoc} + */ + public function getAssocPreference($attribute, $index = NULL, $ignoreExpired = true) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getAssocPreference', array($attribute, $index, $ignoreExpired)); + + return parent::getAssocPreference($attribute, $index, $ignoreExpired); + } + + /** + * {@inheritDoc} + */ + public function deleteAssocPreference($attribute, $index = NULL) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'deleteAssocPreference', array($attribute, $index)); + + return parent::deleteAssocPreference($attribute, $index); + } + + /** + * {@inheritDoc} + */ + public function _getPreferences() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, '_getPreferences', array()); + + return parent::_getPreferences(); + } + +} diff --git a/application/Proxies/__CG__EntitiesDomainPreference.php b/application/Proxies/__CG__EntitiesDomainPreference.php new file mode 100644 index 0000000..3c51f3f --- /dev/null +++ b/application/Proxies/__CG__EntitiesDomainPreference.php @@ -0,0 +1,323 @@ +__initializer__ = $initializer; + $this->__cloner__ = $cloner; + } + + + + + + + + /** + * + * @return array + */ + public function __sleep() + { + if ($this->__isInitialized__) { + return array('__isInitialized__', 'attribute', 'ix', 'op', 'value', 'expire', 'id', 'Domain'); + } + + return array('__isInitialized__', 'attribute', 'ix', 'op', 'value', 'expire', 'id', 'Domain'); + } + + /** + * + */ + public function __wakeup() + { + if ( ! $this->__isInitialized__) { + $this->__initializer__ = function (DomainPreference $proxy) { + $proxy->__setInitializer(null); + $proxy->__setCloner(null); + + $existingProperties = get_object_vars($proxy); + + foreach ($proxy->__getLazyProperties() as $property => $defaultValue) { + if ( ! array_key_exists($property, $existingProperties)) { + $proxy->$property = $defaultValue; + } + } + }; + + } + } + + /** + * + */ + public function __clone() + { + $this->__cloner__ && $this->__cloner__->__invoke($this, '__clone', array()); + } + + /** + * Forces initialization of the proxy + */ + public function __load() + { + $this->__initializer__ && $this->__initializer__->__invoke($this, '__load', array()); + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __isInitialized() + { + return $this->__isInitialized__; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __setInitialized($initialized) + { + $this->__isInitialized__ = $initialized; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __setInitializer(\Closure $initializer = null) + { + $this->__initializer__ = $initializer; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __getInitializer() + { + return $this->__initializer__; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __setCloner(\Closure $cloner = null) + { + $this->__cloner__ = $cloner; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific cloning logic + */ + public function __getCloner() + { + return $this->__cloner__; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + * @static + */ + public function __getLazyProperties() + { + return self::$lazyPropertiesDefaults; + } + + + /** + * {@inheritDoc} + */ + public function setAttribute($attribute) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setAttribute', array($attribute)); + + return parent::setAttribute($attribute); + } + + /** + * {@inheritDoc} + */ + public function getAttribute() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getAttribute', array()); + + return parent::getAttribute(); + } + + /** + * {@inheritDoc} + */ + public function setIx($ix) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setIx', array($ix)); + + return parent::setIx($ix); + } + + /** + * {@inheritDoc} + */ + public function getIx() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getIx', array()); + + return parent::getIx(); + } + + /** + * {@inheritDoc} + */ + public function setOp($op) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setOp', array($op)); + + return parent::setOp($op); + } + + /** + * {@inheritDoc} + */ + public function getOp() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getOp', array()); + + return parent::getOp(); + } + + /** + * {@inheritDoc} + */ + public function setValue($value) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setValue', array($value)); + + return parent::setValue($value); + } + + /** + * {@inheritDoc} + */ + public function getValue() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getValue', array()); + + return parent::getValue(); + } + + /** + * {@inheritDoc} + */ + public function setExpire($expire) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setExpire', array($expire)); + + return parent::setExpire($expire); + } + + /** + * {@inheritDoc} + */ + public function getExpire() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getExpire', array()); + + return parent::getExpire(); + } + + /** + * {@inheritDoc} + */ + public function getId() + { + if ($this->__isInitialized__ === false) { + return parent::getId(); + } + + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getId', array()); + + return parent::getId(); + } + + /** + * {@inheritDoc} + */ + public function setDomain(\Entities\Domain $domain = NULL) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setDomain', array($domain)); + + return parent::setDomain($domain); + } + + /** + * {@inheritDoc} + */ + public function getDomain() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getDomain', array()); + + return parent::getDomain(); + } + +} diff --git a/application/Proxies/__CG__EntitiesLog.php b/application/Proxies/__CG__EntitiesLog.php new file mode 100644 index 0000000..0307617 --- /dev/null +++ b/application/Proxies/__CG__EntitiesLog.php @@ -0,0 +1,301 @@ +__initializer__ = $initializer; + $this->__cloner__ = $cloner; + } + + + + + + + + /** + * + * @return array + */ + public function __sleep() + { + if ($this->__isInitialized__) { + return array('__isInitialized__', 'action', 'data', 'timestamp', 'id', 'Admin', 'Domain'); + } + + return array('__isInitialized__', 'action', 'data', 'timestamp', 'id', 'Admin', 'Domain'); + } + + /** + * + */ + public function __wakeup() + { + if ( ! $this->__isInitialized__) { + $this->__initializer__ = function (Log $proxy) { + $proxy->__setInitializer(null); + $proxy->__setCloner(null); + + $existingProperties = get_object_vars($proxy); + + foreach ($proxy->__getLazyProperties() as $property => $defaultValue) { + if ( ! array_key_exists($property, $existingProperties)) { + $proxy->$property = $defaultValue; + } + } + }; + + } + } + + /** + * + */ + public function __clone() + { + $this->__cloner__ && $this->__cloner__->__invoke($this, '__clone', array()); + } + + /** + * Forces initialization of the proxy + */ + public function __load() + { + $this->__initializer__ && $this->__initializer__->__invoke($this, '__load', array()); + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __isInitialized() + { + return $this->__isInitialized__; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __setInitialized($initialized) + { + $this->__isInitialized__ = $initialized; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __setInitializer(\Closure $initializer = null) + { + $this->__initializer__ = $initializer; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __getInitializer() + { + return $this->__initializer__; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __setCloner(\Closure $cloner = null) + { + $this->__cloner__ = $cloner; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific cloning logic + */ + public function __getCloner() + { + return $this->__cloner__; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + * @static + */ + public function __getLazyProperties() + { + return self::$lazyPropertiesDefaults; + } + + + /** + * {@inheritDoc} + */ + public function setAction($action) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setAction', array($action)); + + return parent::setAction($action); + } + + /** + * {@inheritDoc} + */ + public function getAction() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getAction', array()); + + return parent::getAction(); + } + + /** + * {@inheritDoc} + */ + public function setData($data) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setData', array($data)); + + return parent::setData($data); + } + + /** + * {@inheritDoc} + */ + public function getData() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getData', array()); + + return parent::getData(); + } + + /** + * {@inheritDoc} + */ + public function setTimestamp($timestamp) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setTimestamp', array($timestamp)); + + return parent::setTimestamp($timestamp); + } + + /** + * {@inheritDoc} + */ + public function getTimestamp() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getTimestamp', array()); + + return parent::getTimestamp(); + } + + /** + * {@inheritDoc} + */ + public function getId() + { + if ($this->__isInitialized__ === false) { + return parent::getId(); + } + + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getId', array()); + + return parent::getId(); + } + + /** + * {@inheritDoc} + */ + public function setAdmin(\Entities\Admin $admin = NULL) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setAdmin', array($admin)); + + return parent::setAdmin($admin); + } + + /** + * {@inheritDoc} + */ + public function getAdmin() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getAdmin', array()); + + return parent::getAdmin(); + } + + /** + * {@inheritDoc} + */ + public function setDomain(\Entities\Domain $domain = NULL) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setDomain', array($domain)); + + return parent::setDomain($domain); + } + + /** + * {@inheritDoc} + */ + public function getDomain() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getDomain', array()); + + return parent::getDomain(); + } + +} diff --git a/application/Proxies/__CG__EntitiesMailbox.php b/application/Proxies/__CG__EntitiesMailbox.php new file mode 100644 index 0000000..65579a0 --- /dev/null +++ b/application/Proxies/__CG__EntitiesMailbox.php @@ -0,0 +1,840 @@ +__initializer__ = $initializer; + $this->__cloner__ = $cloner; + } + + + + + + + + /** + * + * @return array + */ + public function __sleep() + { + if ($this->__isInitialized__) { + return array('__isInitialized__', 'username', 'password', 'name', 'alt_email', 'quota', 'local_part', 'active', 'access_restriction', 'homedir', 'maildir', 'uid', 'gid', 'created', 'modified', 'id', 'Preferences', 'homedir_size', 'maildir_size', 'size_at', 'Domain', 'DirectoryEntry', 'delete_pending', '_className', '_preferenceClassName', '_cache', '_namespace'); + } + + return array('__isInitialized__', 'username', 'password', 'name', 'alt_email', 'quota', 'local_part', 'active', 'access_restriction', 'homedir', 'maildir', 'uid', 'gid', 'created', 'modified', 'id', 'Preferences', 'homedir_size', 'maildir_size', 'size_at', 'Domain', 'DirectoryEntry', 'delete_pending', '_className', '_preferenceClassName', '_cache', '_namespace'); + } + + /** + * + */ + public function __wakeup() + { + if ( ! $this->__isInitialized__) { + $this->__initializer__ = function (Mailbox $proxy) { + $proxy->__setInitializer(null); + $proxy->__setCloner(null); + + $existingProperties = get_object_vars($proxy); + + foreach ($proxy->__getLazyProperties() as $property => $defaultValue) { + if ( ! array_key_exists($property, $existingProperties)) { + $proxy->$property = $defaultValue; + } + } + }; + + } + } + + /** + * + */ + public function __clone() + { + $this->__cloner__ && $this->__cloner__->__invoke($this, '__clone', array()); + } + + /** + * Forces initialization of the proxy + */ + public function __load() + { + $this->__initializer__ && $this->__initializer__->__invoke($this, '__load', array()); + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __isInitialized() + { + return $this->__isInitialized__; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __setInitialized($initialized) + { + $this->__isInitialized__ = $initialized; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __setInitializer(\Closure $initializer = null) + { + $this->__initializer__ = $initializer; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __getInitializer() + { + return $this->__initializer__; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __setCloner(\Closure $cloner = null) + { + $this->__cloner__ = $cloner; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific cloning logic + */ + public function __getCloner() + { + return $this->__cloner__; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + * @static + */ + public function __getLazyProperties() + { + return self::$lazyPropertiesDefaults; + } + + + /** + * {@inheritDoc} + */ + public function setUsername($username) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setUsername', array($username)); + + return parent::setUsername($username); + } + + /** + * {@inheritDoc} + */ + public function getUsername() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getUsername', array()); + + return parent::getUsername(); + } + + /** + * {@inheritDoc} + */ + public function setPassword($password) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setPassword', array($password)); + + return parent::setPassword($password); + } + + /** + * {@inheritDoc} + */ + public function getPassword() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getPassword', array()); + + return parent::getPassword(); + } + + /** + * {@inheritDoc} + */ + public function setName($name) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setName', array($name)); + + return parent::setName($name); + } + + /** + * {@inheritDoc} + */ + public function getName() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getName', array()); + + return parent::getName(); + } + + /** + * {@inheritDoc} + */ + public function setAltEmail($altEmail) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setAltEmail', array($altEmail)); + + return parent::setAltEmail($altEmail); + } + + /** + * {@inheritDoc} + */ + public function getAltEmail() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getAltEmail', array()); + + return parent::getAltEmail(); + } + + /** + * {@inheritDoc} + */ + public function setQuota($quota) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setQuota', array($quota)); + + return parent::setQuota($quota); + } + + /** + * {@inheritDoc} + */ + public function getQuota() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getQuota', array()); + + return parent::getQuota(); + } + + /** + * {@inheritDoc} + */ + public function setLocalPart($localPart) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setLocalPart', array($localPart)); + + return parent::setLocalPart($localPart); + } + + /** + * {@inheritDoc} + */ + public function getLocalPart() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getLocalPart', array()); + + return parent::getLocalPart(); + } + + /** + * {@inheritDoc} + */ + public function setActive($active) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setActive', array($active)); + + return parent::setActive($active); + } + + /** + * {@inheritDoc} + */ + public function getActive() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getActive', array()); + + return parent::getActive(); + } + + /** + * {@inheritDoc} + */ + public function setAccessRestriction($accessRestriction) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setAccessRestriction', array($accessRestriction)); + + return parent::setAccessRestriction($accessRestriction); + } + + /** + * {@inheritDoc} + */ + public function getAccessRestriction() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getAccessRestriction', array()); + + return parent::getAccessRestriction(); + } + + /** + * {@inheritDoc} + */ + public function setHomedir($homedir) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setHomedir', array($homedir)); + + return parent::setHomedir($homedir); + } + + /** + * {@inheritDoc} + */ + public function getHomedir() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getHomedir', array()); + + return parent::getHomedir(); + } + + /** + * {@inheritDoc} + */ + public function setMaildir($maildir) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setMaildir', array($maildir)); + + return parent::setMaildir($maildir); + } + + /** + * {@inheritDoc} + */ + public function getMaildir() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getMaildir', array()); + + return parent::getMaildir(); + } + + /** + * {@inheritDoc} + */ + public function getCleanedMaildir() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getCleanedMaildir', array()); + + return parent::getCleanedMaildir(); + } + + /** + * {@inheritDoc} + */ + public function setUid($uid) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setUid', array($uid)); + + return parent::setUid($uid); + } + + /** + * {@inheritDoc} + */ + public function getUid() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getUid', array()); + + return parent::getUid(); + } + + /** + * {@inheritDoc} + */ + public function setGid($gid) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setGid', array($gid)); + + return parent::setGid($gid); + } + + /** + * {@inheritDoc} + */ + public function getGid() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getGid', array()); + + return parent::getGid(); + } + + /** + * {@inheritDoc} + */ + public function setCreated($created) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setCreated', array($created)); + + return parent::setCreated($created); + } + + /** + * {@inheritDoc} + */ + public function getCreated() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getCreated', array()); + + return parent::getCreated(); + } + + /** + * {@inheritDoc} + */ + public function setModified($modified) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setModified', array($modified)); + + return parent::setModified($modified); + } + + /** + * {@inheritDoc} + */ + public function getModified() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getModified', array()); + + return parent::getModified(); + } + + /** + * {@inheritDoc} + */ + public function getId() + { + if ($this->__isInitialized__ === false) { + return parent::getId(); + } + + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getId', array()); + + return parent::getId(); + } + + /** + * {@inheritDoc} + */ + public function addPreference(\Entities\MailboxPreference $preferences) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'addPreference', array($preferences)); + + return parent::addPreference($preferences); + } + + /** + * {@inheritDoc} + */ + public function removePreference(\Entities\MailboxPreference $preferences) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'removePreference', array($preferences)); + + return parent::removePreference($preferences); + } + + /** + * {@inheritDoc} + */ + public function getPreferences() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getPreferences', array()); + + return parent::getPreferences(); + } + + /** + * {@inheritDoc} + */ + public function setDomain(\Entities\Domain $domain = NULL) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setDomain', array($domain)); + + return parent::setDomain($domain); + } + + /** + * {@inheritDoc} + */ + public function getDomain() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getDomain', array()); + + return parent::getDomain(); + } + + /** + * {@inheritDoc} + */ + public function addMailboxPreference(\Entities\MailboxPreference $preferences) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'addMailboxPreference', array($preferences)); + + return parent::addMailboxPreference($preferences); + } + + /** + * {@inheritDoc} + */ + public function formatMaildir($maildir = '') + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'formatMaildir', array($maildir)); + + return parent::formatMaildir($maildir); + } + + /** + * {@inheritDoc} + */ + public function formatHomedir($homedir = '') + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'formatHomedir', array($homedir)); + + return parent::formatHomedir($homedir); + } + + /** + * {@inheritDoc} + */ + public function setHomedirSize($homedirSize) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setHomedirSize', array($homedirSize)); + + return parent::setHomedirSize($homedirSize); + } + + /** + * {@inheritDoc} + */ + public function getHomedirSize() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getHomedirSize', array()); + + return parent::getHomedirSize(); + } + + /** + * {@inheritDoc} + */ + public function setMaildirSize($maildirSize) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setMaildirSize', array($maildirSize)); + + return parent::setMaildirSize($maildirSize); + } + + /** + * {@inheritDoc} + */ + public function getMaildirSize() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getMaildirSize', array()); + + return parent::getMaildirSize(); + } + + /** + * {@inheritDoc} + */ + public function setSizeAt($sizeAt) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setSizeAt', array($sizeAt)); + + return parent::setSizeAt($sizeAt); + } + + /** + * {@inheritDoc} + */ + public function getSizeAt() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getSizeAt', array()); + + return parent::getSizeAt(); + } + + /** + * {@inheritDoc} + */ + public function setDirectoryEntry(\Entities\DirectoryEntry $directoryEntry = NULL) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setDirectoryEntry', array($directoryEntry)); + + return parent::setDirectoryEntry($directoryEntry); + } + + /** + * {@inheritDoc} + */ + public function getDirectoryEntry() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getDirectoryEntry', array()); + + return parent::getDirectoryEntry(); + } + + /** + * {@inheritDoc} + */ + public function setDeletePending($deletePending) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setDeletePending', array($deletePending)); + + return parent::setDeletePending($deletePending); + } + + /** + * {@inheritDoc} + */ + public function getDeletePending() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getDeletePending', array()); + + return parent::getDeletePending(); + } + + /** + * {@inheritDoc} + */ + public function loadPreference($attribute, $index = 0, $includeExpired = false) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'loadPreference', array($attribute, $index, $includeExpired)); + + return parent::loadPreference($attribute, $index, $includeExpired); + } + + /** + * {@inheritDoc} + */ + public function hasPreference($attribute, $index = 0, $includeExpired = false) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'hasPreference', array($attribute, $index, $includeExpired)); + + return parent::hasPreference($attribute, $index, $includeExpired); + } + + /** + * {@inheritDoc} + */ + public function getPreference($attribute, $index = 0, $includeExpired = false) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getPreference', array($attribute, $index, $includeExpired)); + + return parent::getPreference($attribute, $index, $includeExpired); + } + + /** + * {@inheritDoc} + */ + public function setPreference($attribute, $value, $operator = '=', $expires = 0, $index = 0) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setPreference', array($attribute, $value, $operator, $expires, $index)); + + return parent::setPreference($attribute, $value, $operator, $expires, $index); + } + + /** + * {@inheritDoc} + */ + public function addIndexedPreference($attribute, $value, $operator = '=', $expires = 0, $max = 0) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'addIndexedPreference', array($attribute, $value, $operator, $expires, $max)); + + return parent::addIndexedPreference($attribute, $value, $operator, $expires, $max); + } + + /** + * {@inheritDoc} + */ + public function cleanExpiredPreferences($asOf = NULL, $attribute = NULL) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'cleanExpiredPreferences', array($asOf, $attribute)); + + return parent::cleanExpiredPreferences($asOf, $attribute); + } + + /** + * {@inheritDoc} + */ + public function deletePreference($attribute, $index = NULL) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'deletePreference', array($attribute, $index)); + + return parent::deletePreference($attribute, $index); + } + + /** + * {@inheritDoc} + */ + public function expungePreferences() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'expungePreferences', array()); + + return parent::expungePreferences(); + } + + /** + * {@inheritDoc} + */ + public function getIndexedPreference($attribute, $withIndex = false, $ignoreExpired = true) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getIndexedPreference', array($attribute, $withIndex, $ignoreExpired)); + + return parent::getIndexedPreference($attribute, $withIndex, $ignoreExpired); + } + + /** + * {@inheritDoc} + */ + public function getAssocPreference($attribute, $index = NULL, $ignoreExpired = true) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getAssocPreference', array($attribute, $index, $ignoreExpired)); + + return parent::getAssocPreference($attribute, $index, $ignoreExpired); + } + + /** + * {@inheritDoc} + */ + public function deleteAssocPreference($attribute, $index = NULL) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'deleteAssocPreference', array($attribute, $index)); + + return parent::deleteAssocPreference($attribute, $index); + } + + /** + * {@inheritDoc} + */ + public function _getPreferences() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, '_getPreferences', array()); + + return parent::_getPreferences(); + } + +} diff --git a/application/Proxies/__CG__EntitiesMailboxPreference.php b/application/Proxies/__CG__EntitiesMailboxPreference.php new file mode 100644 index 0000000..a4b698b --- /dev/null +++ b/application/Proxies/__CG__EntitiesMailboxPreference.php @@ -0,0 +1,323 @@ +__initializer__ = $initializer; + $this->__cloner__ = $cloner; + } + + + + + + + + /** + * + * @return array + */ + public function __sleep() + { + if ($this->__isInitialized__) { + return array('__isInitialized__', 'attribute', 'ix', 'op', 'value', 'expire', 'id', 'Mailbox'); + } + + return array('__isInitialized__', 'attribute', 'ix', 'op', 'value', 'expire', 'id', 'Mailbox'); + } + + /** + * + */ + public function __wakeup() + { + if ( ! $this->__isInitialized__) { + $this->__initializer__ = function (MailboxPreference $proxy) { + $proxy->__setInitializer(null); + $proxy->__setCloner(null); + + $existingProperties = get_object_vars($proxy); + + foreach ($proxy->__getLazyProperties() as $property => $defaultValue) { + if ( ! array_key_exists($property, $existingProperties)) { + $proxy->$property = $defaultValue; + } + } + }; + + } + } + + /** + * + */ + public function __clone() + { + $this->__cloner__ && $this->__cloner__->__invoke($this, '__clone', array()); + } + + /** + * Forces initialization of the proxy + */ + public function __load() + { + $this->__initializer__ && $this->__initializer__->__invoke($this, '__load', array()); + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __isInitialized() + { + return $this->__isInitialized__; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __setInitialized($initialized) + { + $this->__isInitialized__ = $initialized; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __setInitializer(\Closure $initializer = null) + { + $this->__initializer__ = $initializer; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __getInitializer() + { + return $this->__initializer__; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __setCloner(\Closure $cloner = null) + { + $this->__cloner__ = $cloner; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific cloning logic + */ + public function __getCloner() + { + return $this->__cloner__; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + * @static + */ + public function __getLazyProperties() + { + return self::$lazyPropertiesDefaults; + } + + + /** + * {@inheritDoc} + */ + public function setAttribute($attribute) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setAttribute', array($attribute)); + + return parent::setAttribute($attribute); + } + + /** + * {@inheritDoc} + */ + public function getAttribute() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getAttribute', array()); + + return parent::getAttribute(); + } + + /** + * {@inheritDoc} + */ + public function setIx($ix) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setIx', array($ix)); + + return parent::setIx($ix); + } + + /** + * {@inheritDoc} + */ + public function getIx() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getIx', array()); + + return parent::getIx(); + } + + /** + * {@inheritDoc} + */ + public function setOp($op) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setOp', array($op)); + + return parent::setOp($op); + } + + /** + * {@inheritDoc} + */ + public function getOp() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getOp', array()); + + return parent::getOp(); + } + + /** + * {@inheritDoc} + */ + public function setValue($value) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setValue', array($value)); + + return parent::setValue($value); + } + + /** + * {@inheritDoc} + */ + public function getValue() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getValue', array()); + + return parent::getValue(); + } + + /** + * {@inheritDoc} + */ + public function setExpire($expire) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setExpire', array($expire)); + + return parent::setExpire($expire); + } + + /** + * {@inheritDoc} + */ + public function getExpire() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getExpire', array()); + + return parent::getExpire(); + } + + /** + * {@inheritDoc} + */ + public function getId() + { + if ($this->__isInitialized__ === false) { + return parent::getId(); + } + + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getId', array()); + + return parent::getId(); + } + + /** + * {@inheritDoc} + */ + public function setMailbox(\Entities\Mailbox $mailbox = NULL) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setMailbox', array($mailbox)); + + return parent::setMailbox($mailbox); + } + + /** + * {@inheritDoc} + */ + public function getMailbox() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getMailbox', array()); + + return parent::getMailbox(); + } + +} diff --git a/application/Proxies/__CG__EntitiesRememberMe.php b/application/Proxies/__CG__EntitiesRememberMe.php new file mode 100644 index 0000000..ee42b4d --- /dev/null +++ b/application/Proxies/__CG__EntitiesRememberMe.php @@ -0,0 +1,345 @@ +__initializer__ = $initializer; + $this->__cloner__ = $cloner; + } + + + + + + + + /** + * + * @return array + */ + public function __sleep() + { + if ($this->__isInitialized__) { + return array('__isInitialized__', 'userhash', 'ckey', 'original_ip', 'expires', 'created', 'id', 'User', 'last_used'); + } + + return array('__isInitialized__', 'userhash', 'ckey', 'original_ip', 'expires', 'created', 'id', 'User', 'last_used'); + } + + /** + * + */ + public function __wakeup() + { + if ( ! $this->__isInitialized__) { + $this->__initializer__ = function (RememberMe $proxy) { + $proxy->__setInitializer(null); + $proxy->__setCloner(null); + + $existingProperties = get_object_vars($proxy); + + foreach ($proxy->__getLazyProperties() as $property => $defaultValue) { + if ( ! array_key_exists($property, $existingProperties)) { + $proxy->$property = $defaultValue; + } + } + }; + + } + } + + /** + * + */ + public function __clone() + { + $this->__cloner__ && $this->__cloner__->__invoke($this, '__clone', array()); + } + + /** + * Forces initialization of the proxy + */ + public function __load() + { + $this->__initializer__ && $this->__initializer__->__invoke($this, '__load', array()); + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __isInitialized() + { + return $this->__isInitialized__; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __setInitialized($initialized) + { + $this->__isInitialized__ = $initialized; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __setInitializer(\Closure $initializer = null) + { + $this->__initializer__ = $initializer; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __getInitializer() + { + return $this->__initializer__; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __setCloner(\Closure $cloner = null) + { + $this->__cloner__ = $cloner; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific cloning logic + */ + public function __getCloner() + { + return $this->__cloner__; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + * @static + */ + public function __getLazyProperties() + { + return self::$lazyPropertiesDefaults; + } + + + /** + * {@inheritDoc} + */ + public function setUserhash($userhash) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setUserhash', array($userhash)); + + return parent::setUserhash($userhash); + } + + /** + * {@inheritDoc} + */ + public function getUserhash() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getUserhash', array()); + + return parent::getUserhash(); + } + + /** + * {@inheritDoc} + */ + public function setCkey($ckey) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setCkey', array($ckey)); + + return parent::setCkey($ckey); + } + + /** + * {@inheritDoc} + */ + public function getCkey() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getCkey', array()); + + return parent::getCkey(); + } + + /** + * {@inheritDoc} + */ + public function setOriginalIp($originalIp) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setOriginalIp', array($originalIp)); + + return parent::setOriginalIp($originalIp); + } + + /** + * {@inheritDoc} + */ + public function getOriginalIp() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getOriginalIp', array()); + + return parent::getOriginalIp(); + } + + /** + * {@inheritDoc} + */ + public function setExpires($expires) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setExpires', array($expires)); + + return parent::setExpires($expires); + } + + /** + * {@inheritDoc} + */ + public function getExpires() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getExpires', array()); + + return parent::getExpires(); + } + + /** + * {@inheritDoc} + */ + public function setCreated($created) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setCreated', array($created)); + + return parent::setCreated($created); + } + + /** + * {@inheritDoc} + */ + public function getCreated() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getCreated', array()); + + return parent::getCreated(); + } + + /** + * {@inheritDoc} + */ + public function getId() + { + if ($this->__isInitialized__ === false) { + return parent::getId(); + } + + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getId', array()); + + return parent::getId(); + } + + /** + * {@inheritDoc} + */ + public function setUser(\Entities\Admin $user = NULL) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setUser', array($user)); + + return parent::setUser($user); + } + + /** + * {@inheritDoc} + */ + public function getUser() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getUser', array()); + + return parent::getUser(); + } + + /** + * {@inheritDoc} + */ + public function setLastUsed($lastUsed) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setLastUsed', array($lastUsed)); + + return parent::setLastUsed($lastUsed); + } + + /** + * {@inheritDoc} + */ + public function getLastUsed() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getLastUsed', array()); + + return parent::getLastUsed(); + } + +} diff --git a/application/Repositories/Admin.php b/application/Repositories/Admin.php new file mode 100644 index 0000000..8262199 --- /dev/null +++ b/application/Repositories/Admin.php @@ -0,0 +1,52 @@ +getEntityManager()->createQuery( + "SELECT COUNT( a.id ) FROM \\Entities\\Admin a" + ) + ->getSingleScalarResult(); + } + + /** + * Finds all admins who are not assigned with domain. + * + * Finds all admins and iterate through then making an array of 'id' => 'username' + * If admin inactive username will be append by '(inactive)' then we iterate + * through domain admins and removing all array elements which id is already in domain admins list. + * + * @param \Entities\Domain $domain Domain to look for admins + * @retun array + */ + public function getNotAssignedForDomain( $domain ) + { + $adminNames = []; + foreach( $this->findBy( [ "super" => false ] ) as $admin ) + $adminNames[ $admin->getId() ] = $admin->getActive() ? $admin->getUsername() : $admin->getUsername() . " (inactive)"; + + foreach( $domain->getAdmins() as $admin ) + if( isset( $adminNames[ $admin->getId() ] ) ) + unset( $adminNames[ $admin->getId() ] ); + + return $adminNames; + } +} diff --git a/application/Repositories/AdminPreference.php b/application/Repositories/AdminPreference.php new file mode 100644 index 0000000..4402f1c --- /dev/null +++ b/application/Repositories/AdminPreference.php @@ -0,0 +1,15 @@ +getEntityManager()->createQueryBuilder() + ->select( 'a' ) + ->from( '\\Entities\\Alias', 'a' ) + ->where( 'a.goto = ?1' ) + ->setParameter( 1, $mailbox->getUsername() ); + + if( !$ima ) + $qb->andWhere( 'a.address != a.goto' ); + + if( !$admin->isSuper() ) + { + $qb->leftJoin( 'a.Domain', 'd' ) + ->leftJoin( 'd.DomainAdmin', 'da' ) + ->andWhere( 'da.Admin = ?2' ) + ->leftJoin( 'd.Admins', 'd2a' ) + ->andWhere( 'd2a = ?2' ) + ->setParameter( 2, $admin ); + } + + return $qb->getQuery()->getResult(); + } + + /** + * Loads aliases with mailbox. + * + * Selects aliases where address not equal to goto, and goto not equals to + * mailbox username, but goto has mailbox username. If admin is not super + * then it checks if admin have have linked with domain. + * + * @param \Entities\Mailbox $mailbox Mailbox for alias filtering. + * @param \Entities\Admin $admin Admin for checking privileges. + * @return \Entities\Alias[] + */ + public function loadWithMailbox( $mailbox, $admin ) + { + $qb = $this->getEntityManager()->createQueryBuilder() + ->select( 'a' ) + ->from( '\\Entities\\Alias', 'a' ) + ->where( 'a.address != a.goto' ) + ->andWhere( 'a.goto != ?1' ) + ->andWhere( 'a.goto like ?2' ) + ->setParameter( 1, $mailbox->getUsername() ) + ->setParameter( 2, '%' . $mailbox->getUsername() . '%'); + + if( !$admin->isSuper() ) + { + $qb->leftJoin( 'a.Domain', 'd' ) + ->leftJoin( 'd.DomainAdmin', 'da' ) + ->andWhere( 'da.username = ?3' ) + ->setParameter( 3, $admin->getUsername() ); + } + + return $qb->getQuery()->getResult(); + } + + /** + * Load aliases for alias list . + * + * Loads aliases for alias list, if admin is not super, it will select aliases + * only from domains which are linked with admin. If domain is set it will select + * aliases only for given domain, and if ima set to false then it will select all + * aliases where goto not equal to address that mean non mailbox aliases. + * + * @param \Entities\Admin $admin Admin for filtering mailboxes. + * @param \Entities\Domain $domain Domain for filtering mailboxes. + * @param bool $ima Include mailbox aliases flag. + * @return array + */ + public function loadForAliasList( $admin, $domain = null, $ima = false ) + { + $qb = $this->getEntityManager()->createQueryBuilder() + ->select( 'a.id as id , a.address as address, a.goto as goto, a.active as active, d.domain as domain' ) + ->from( '\\Entities\\Alias', 'a' ) + ->join( 'a.Domain', 'd' ); + + if( !$admin->isSuper() ) + $qb->join( 'd.Admins', 'd2a' ) + ->where( 'd2a = ?1' ) + ->setParameter( 1, $admin ); + + if( $domain ) + $qb->andWhere( 'a.Domain = ?2' ) + ->setParameter( 2, $domain ); + + if( !$ima ) + $qb->andWhere( "a.address != a.goto" ); + return $qb->getQuery()->getArrayResult(); + } + + /** + * Return filtered alias data array + * + * Use filter to filter aliases by address or goto or domain. If filter + * starts with * it will be replaced with % to meet sql requirements. At + * the end % will be added to all strings. So filter 'man' will bicome + * 'man%' and will look for man, manual and iffilter '*man' it wil bicome + * '%man%' and will look for records like human, humanity, man, manual. + * + * @param string $filter Flter for mailboxes + * @param \Entities\Admin $admin Admin for filtering mailboxes. + * @param \Entities\Domain $domain Domain for filtering mailboxes. + * @param bool $ima Include mailbox aliases flag. + * @return array + */ + public function filterForAliasList( $filter, $admin, $domain = null, $ima = false ) + { + $filter = str_replace ( "'" , "" , $filter ); + + if( strpos( $filter, "*" ) === 0 ) + $filter = '%' . substr( $filter, 1 ); + + $qb = $this->getEntityManager()->createQueryBuilder() + ->select( 'a.id as id , a.address as address, a.goto as goto, a.active as active, d.domain as domain' ) + ->from( '\\Entities\\Alias', 'a' ) + ->join( 'a.Domain', 'd' ) + ->where( "( a.goto LIKE '{$filter}%' OR a.address LIKE '{$filter}%' OR d.domain LIKE '{$filter}%')" ); + + if( !$admin->isSuper() ) + $qb->join( 'd.Admins', 'd2a' ) + ->andWhere( 'd2a = ?1' ) + ->setParameter( 1, $admin ); + + if( $domain ) + $qb->andWhere( 'm.Domain = ?2' ) + ->setParameter( 2, $domain ); + + if( !$ima ) + $qb->andWhere( "a.address != a.goto" ); + + return $qb->getQuery()->getArrayResult(); + } +} diff --git a/application/Repositories/AliasPreference.php b/application/Repositories/AliasPreference.php new file mode 100644 index 0000000..0dfb407 --- /dev/null +++ b/application/Repositories/AliasPreference.php @@ -0,0 +1,15 @@ +getEntityManager()->createQueryBuilder() + ->select( 'a.id as id , a.username as username, a.status as status, d.domain as domain' ) + ->from( '\\Entities\\Archive', 'a' ) + ->join( 'a.Domain', 'd' ); + + if( !$admin->isSuper() ) + $qb->join( 'd.Admins', 'd2a' ) + ->where( 'd2a.Admin = ?1' ) + ->setParameter( 1, $admin ); + + if( $domain ) + $qb->andWhere( 'a.Domain = ?2' ) + ->setParameter( 2, $domain ); + + return $qb->getQuery()->getArrayResult(); + } +} diff --git a/application/Repositories/DatabaseVersion.php b/application/Repositories/DatabaseVersion.php new file mode 100644 index 0000000..cbb2fbf --- /dev/null +++ b/application/Repositories/DatabaseVersion.php @@ -0,0 +1,15 @@ +isSuper() ) + $dql .= " LEFT JOIN d.Admins d2a WHERE d2a = ?1"; + + $dql .= " ORDER BY d.domain ASC"; + + $q = $this->getEntityManager()->createQuery( $dql ); + + if( !$admin->isSuper() ) + $q->setParameter( 1, $admin ); + + return $q->execute(); + } + + /** + * Load as array for admin + * + * Its used to get domains names in mailbox add-edit drop down list. + * It also can be used as loadForDomainList function. + * It calls loadForDomain iterates thought domains and it can return + * two types of arrays: id => name, or id => [ domain data ] + * + * @param \Entities\Admin $admin + * @para bool $onlyNames Type of array if set to true only names will be returned, else all data. + * @return array + */ + public function loadForAdminAsArray( $admin, $onlyNames = false ) + { + $array = []; + + if( $onlyNames ) + { + foreach( $this->loadForAdmin( $admin ) as $domain ) + $array[ $domain->getId() ] = $domain->getDomain(); + + } + else + { + foreach( $this->loadForAdmin( $admin ) as $domain ) + { + $array[ $domain->getId() ] = [ + 'domain' => $domain->getDomain(), + 'description' => $domain->getDescription(), + 'max_aliaseses' => $domain->getMaxAliases(), + 'alias_count' => $domain->getAliasesCount(), + 'max_mailboxes' => $domain->getMaxMailboxes(), + 'alias_mailbox' => $domain->getMailboxCount(), + 'max_quota' => $domain->getMaxQuota(), + 'quota' => $domain->getQuota(), + 'transport' => $domain->getTransport(), + 'active' => $domain->getActive(), + 'homedir' => $domain->getHomedir(), + 'maildir' => $domain->getMaildir(), + 'uid' => $domain->getUid(), + 'gid' => $domain->getGid() + + ]; + } + } + return $array; + } + + /** + * Load data for domains list + * + * Loads information for domains list. + * + * @param \Entities\Admin $admin + * @return array + */ + public function loadForDomainList( $admin ) + { + $dql = "SELECT d.id AS id, d.domain AS name, d.alias_count AS aliases, d.mailbox_count AS mailboxes, + d.max_aliases AS maxaliases, d.max_mailboxes AS maxmailboxes, SUM( m.maildir_size ) AS mailboxes_size, + d.max_quota AS maxquota, d.quota AS quota, d.transport AS transport, d.backupmx AS backupmx, + d.active AS active, d.created AS created, m.delete_pending AS delete_pending + FROM \\Entities\\Domain d LEFT JOIN d.Mailboxes m"; + + // FIXME a.address != a.goto + + if( !$admin->isSuper() ) + $dql .= " LEFT JOIN d.Admins d2a WHERE d2a = ?1"; + + $dql .= " GROUP BY d.id ORDER BY d.domain ASC"; + + $q = $this->getEntityManager()->createQuery( $dql ); + + if( !$admin->isSuper() ) + $q->setParameter( 1, $admin ); + + return $q->getArrayResult(); + } + + /** + * Load data for domains list + * + * Loads information for domains list. + * + * @param string $filter + * @param \Entities\Admin $admin + * @return array + */ + public function filterForDomainList( $filter, $admin ) + { + $filter = str_replace ( "'" , "" , $filter ); + + if( strpos( $filter, "*" ) === 0 ) + $filter = '%' . substr( $filter, 1 ); + + $dql = "SELECT d.id AS id, d.domain AS name, d.alias_count AS aliases, d.mailbox_count AS mailboxes, + d.max_aliases AS maxaliases, d.max_mailboxes AS maxmailboxes, SUM( m.maildir_size ) AS mailboxes_size, + d.max_quota AS maxquota, d.quota AS quota, d.transport AS transport, d.backupmx AS backupmx, + d.active AS active, d.created AS created + FROM \\Entities\\Domain d LEFT JOIN d.Mailboxes m + WHERE ( d.domain LIKE '{$filter}%' OR d.transport LIKE '{$filter}%' OR d.created LIKE '{$filter}%' )"; + + if( !$admin->isSuper() ) + $dql .= " LEFT JOIN d.Admins d2a WHERE d2a = ?1"; + + $dql .= " GROUP BY d.id ORDER BY d.domain ASC"; + + $q = $this->getEntityManager()->createQuery( $dql ); + + if( !$admin->isSuper() ) + $q->setParameter( 1, $admin ); + + return $q->getArrayResult(); + } + + + /** + * Convenience function to purge all associations of a domain and the domain + * + * @param \Entities\Domain $domain The domain object + */ + public function purge( $domain ) + { + $this->purgeMailboxes( $domain ); + $this->purgeAliases( $domain ); + $this->purgeLogs( $domain ); + $this->purgeDomainAdmins( $domain ); + + $this->getEntityManager()->remove( $domain ); + $this->getEntityManager()->flush(); + } + + /** + * Purge all mailboxes of a domain + * + * @param $domain \Entities\Domain The domain to purge the mailboxes of + * @return int The number of records deleted + */ + public function purgeMailboxes( $domain ) + { + return $this->getEntityManager()->createQuery( + "DELETE FROM \\Entities\\Mailbox m WHERE m.Domain = ?1" + ) + ->setParameter( 1, $domain ) + ->execute(); + } + + /** + * Purge all alaises of a domain + * + * @param $domain \Entities\Domain The domain to purge the aliases of + * @return int The number of records deleted + */ + public function purgeAliases( $domain ) + { + return $this->getEntityManager()->createQuery( + "DELETE FROM \\Entities\\Alias m WHERE m.Domain = ?1" + ) + ->setParameter( 1, $domain ) + ->execute(); + } + + /** + * Purge all logs of a domain + * + * @param $domain \Entities\Domain The domain to purge the logs of + * @return int The number of logs deleted + */ + public function purgeLogs( $domain ) + { + return $this->getEntityManager()->createQuery( + "DELETE FROM \\Entities\\Log m WHERE m.Domain = ?1" + ) + ->setParameter( 1, $domain ) + ->execute(); + } + + /** + * Purge all links to admins for a domain + * + * Requires a flush() + * + * @param $domain \Entities\Domain The domain to purge the admin links of + * @return int The number of links deleted + */ + public function purgeDomainAdmins( $domain ) + { + foreach( $domain->getAdmins() as $a ) + $domain->removeAdmin( $a ); + } + + /** + * Finds all domains which are not assigned with admin. + * + * Finds all domains and iterate through then making an array of 'id' => 'domain' + * If domain inactive domain name will be append by '(inactive)' then we iterate + * through admin domains and removing all array elements which id is already in admin domains list. + * + * @param \Entities\Admin $admin Admin to look for not assign domains + * @retun array + */ + public function getNotAssignedForAdmin( $admin ) + { + $domainNames = []; + foreach( $this->findAll() as $domain ) + $domainNames[ $domain->getId() ] = $domain->getActive() ? $domain->getDomain() : $domain->getDomain() . " (inactive)"; + + foreach( $admin->getDomains() as $domain ) + if( isset( $domainNames[ $domain->getId() ] ) ) + unset( $domainNames[ $domain->getId() ] ); + + return $domainNames; + } + +} diff --git a/application/Repositories/DomainPreference.php b/application/Repositories/DomainPreference.php new file mode 100644 index 0000000..b48d5ba --- /dev/null +++ b/application/Repositories/DomainPreference.php @@ -0,0 +1,15 @@ +getEntityManager()->createQueryBuilder() + ->select( 'l.id as id , l.action as action, l.data as data, l.timestamp as timestamp, a.username as admin, d.domain as domain' ) + ->from( '\\Entities\\Log', 'l' ) + ->leftJoin( 'l.Domain', 'd' ) + ->join( 'l.Admin', 'a' ); + + if( $admin ) + $qb->join( 'd.Admins', 'd2a' ) + ->where( 'd2a = ?1' ) + ->setParameter( 1, $admin ); + + if( $domain ) + $qb->andWhere( 'l.Domain = ?2' ) + ->setParameter( 2, $domain ); + + return $qb->getQuery()->getArrayResult(); + } +} diff --git a/application/Repositories/Mailbox.php b/application/Repositories/Mailbox.php new file mode 100644 index 0000000..336b0a8 --- /dev/null +++ b/application/Repositories/Mailbox.php @@ -0,0 +1,258 @@ +getEntityManager()->createQueryBuilder() + ->select( 'm' ) + ->from( '\\Entities\\Mailbox', 'm' ); + + if( !$admin->isSuper() ) + $qb->join( 'm.Domain', 'd' ) + ->join( 'd.Admins', 'd2a' ) + ->where( 'd2a.Admin = ?1' ) + ->setParameter( 1, $admin ); + + return $qb->getQuery()->getResult(); + } + + /** + * Load mailboxes for mailbox list . + * + * If admin is super he gets all mailboxes. + * + * @param \Entities\Admin $admin Admin for filtering mailboxes. + * @param \Entities\Domain $domain Domain for filtering mailboxes. + * @return array + */ + public function loadForMailboxList( $admin, $domain = null ) + { + $qb = $this->getEntityManager()->createQueryBuilder() + ->select( 'm.id as id, m.username as username, m.name as name, m.active as active, m.maildir_size as maildir_size, + m.homedir_size as homedir_size, m.size_at as size_at, m.quota as quota, d.domain as domain, m.delete_pending' ) + ->from( '\\Entities\\Mailbox', 'm' ) + ->where( 'm.delete_pending = 0' ) + ->join( 'm.Domain', 'd' ); + + if( !$admin->isSuper() ) + $qb->join( 'd.Admins', 'd2a' ) + ->andWhere( 'd2a.Admin = ?1' ) + ->setParameter( 1, $admin ); + + if( $domain ) + $qb->andWhere( 'm.Domain = ?2' ) + ->setParameter( 2, $domain ); + + return $qb->getQuery()->getArrayResult(); + } + + /** + * Return filtered mailboxes data array + * + * Use filter to filter mailboxes by username or name or domain. If filter + * starts with * it will be replaced with % to meet sql requirements. At + * the end % will be added to all strings. So filter 'man' will bicome + * 'man%' and will look for man, manual and iffilter '*man' it wil bicome + * '%man%' and will look for records like human, humanity, man, manual. + * + * @param string $filter Flter for mailboxes + * @param \Entities\Admin $admin Admin for filtering mailboxes. + * @param \Entities\Domain $domain Domain for filtering mailboxes. + * @return array + */ + public function filterForMailboxList( $filter, $admin, $domain = null ) + { + $filter = str_replace ( "'" , "" , $filter ); + + if( strpos( $filter, "*" ) === 0 ) + $filter = '%' . substr( $filter, 1 ); + + $qb = $this->getEntityManager()->createQueryBuilder() + ->select( 'm.id as id, m.username as username, m.name as name, m.active as active, m.maildir_size as maildir_size, + m.homedir_size as homedir_size, m.size_at as size_at, m.quota as quota, d.domain as domain, m.delete_pending' ) + ->from( '\\Entities\\Mailbox', 'm' ) + ->join( 'm.Domain', 'd' ) + ->where( "m.delete_pending = 0 AND ( m.username LIKE '{$filter}%' OR m.name LIKE '{$filter}%' OR d.domain LIKE '{$filter}%' )" ); + + if( !$admin->isSuper() ) + $qb->join( 'd.Admins', 'd2a' ) + ->andWhere( 'd2a = ?1' ) + ->setParameter( 1, $admin ); + + if( $domain ) + $qb->andWhere( 'm.Domain = ?2' ) + ->setParameter( 2, $domain ); + + return $qb->getQuery()->getArrayResult(); + } + + /** + * Load mailboxes usernmae list. + * + * If admin is super he gets all mailboxes. + * + * @param \Entities\Admin $admin Admin for filtering mailboxes. + * @param \Entities\Domain $domain Domain for filtering mailboxes. + * @return array + */ + public function loadUsernameList( $admin, $domain = null ) + { + $qb = $this->getEntityManager()->createQueryBuilder() + ->select( 'm.id as id , m.username as username' ) + ->from( '\\Entities\\Mailbox', 'm' ) + ->join( 'm.Domain', 'd' ); + + if( !$admin->isSuper() ) + $qb->join( 'd.Admins', 'd2a' ) + ->where( 'd2a.Admin = ?1' ) + ->setParameter( 1, $admin ); + + if( $domain ) + $qb->andWhere( 'm.Domain = ?2' ) + ->setParameter( 2, $domain ); + + $data = $qb->getQuery()->getArrayResult(); + $result = []; + foreach( $data as $row ) + $result[ $row['id'] ] = $row['username']; + return $result; + } + + + /** + * Check if mailbox is unique. + * + * Splits given email to local part and domain ant count all mailboxes + * with these parameters. If count is 0 then function returns true else false. + * + * @param string $email Email to check + * @return bool + */ + public function isUnique( $email ) + { + list( $lpart, $domain ) = explode( '@', $email ); + + $qb = $this->getEntityManager()->createQueryBuilder() + ->select( 'count( m.id )' ) + ->from( '\\Entities\\Mailbox', 'm' ) + ->join( 'm.Domain', 'd' ) + ->where( 'm.local_part = ?1' ) + ->andWhere( 'd.domain = ?2' ) + ->setParameter( 1, $lpart ) + ->setParameter( 2, $domain ); + + return $qb->getQuery()->getSingleScalarResult() > 0 ? false : true; + } + + /** + * Purges mailbox + * + * Remove all mailbox preferences. + * Remove all mailbox aliases with their preferences and decrease alias count in domain. + * Remove mailbox entry for multi alias with multi addresses. + * Remove actual mailbox and decrease mailbox count i domain. + * Returns false if privileges not allowed and true if removed. + * + * @param \Entities\Mailbox $mailbox Mailbox to purge + * @param \Entities\Admin $admin Admin which purging mailbox for privilege validation. + * @param bool $removeMailbox If true, also remove the Mailbox entity. If false, purge everything but this entity. + * @return bool + */ + public function purgeMailbox( $mailbox, $admin, $removeMailbox = true ) + { + if( !$admin->isSuper() && !$mailbox->getDomain()->getAdmins()->contains( $admin ) ) + return false; + + $aliases = $this->getEntityManager()->getRepository( "\\Entities\\Alias" )->loadForMailbox( $mailbox, $admin, true ); + $inAliases = $this->getEntityManager()->getRepository( "\\Entities\\Alias" )->loadWithMailbox( $mailbox, $admin ); + + foreach( $mailbox->getPreferences() as $pref ) + $this->getEntityManager()->remove( $pref ); + + //this won't delete the alias entry where address == goto + foreach( $aliases as $alias ) + { + $this->_removeAlias( $alias ); + } + + foreach( $inAliases as $alias ) + { + $gotos = explode( ',', $alias->getGoto() ); + + foreach( $gotos as $key => $goto ) + { + $gotos[ $key ] = $goto = trim( $goto ); + + if( ( $goto == $mailbox->getUsername() ) || ( $goto == '' ) ) + unset( $gotos[ $key ] ); + } + + if( sizeof( $gotos ) == 0 ) + $this->_removeAlias( $alias ); + else + $alias->setGoto( implode( ',', $gotos ) ); + } + + if( $removeMailbox ) + $this->getEntityManager()->remove( $mailbox ); + + $mailbox->getDomain()->decreaseMailboxCount(); + + return true; + } + + /** + * Removes alias + * + * Removes alias and its preferences also decrease domains alias count + * if alias goto field is not equal to alias address field. + * + * @param /Entities/Alias $alias Alias to remove. + * @return bool + */ + private function _removeAlias( $alias ) + { + foreach( $alias->getPreferences() as $pref ) + $this->getEntityManager()->remove( $pref ); + + $this->getEntityManager()->remove( $alias ); + + if( $alias->getGoto() != $alias->getAddress() ) + $alias->getDomain()->decreaseAliasCount(); + } + + /** + * Find all mailboxes pending deletion. + * + * @return \Entities\Mailbox[] + */ + public function pendingDelete() + { + return $this->getEntityManager()->createQueryBuilder() + ->select( 'm' ) + ->from( '\\Entities\\Mailbox', 'm' ) + ->where( 'm.delete_pending = 1' ) + ->getQuery() + ->getResult(); + } + +} diff --git a/application/Repositories/MailboxPreference.php b/application/Repositories/MailboxPreference.php new file mode 100644 index 0000000..d051cf4 --- /dev/null +++ b/application/Repositories/MailboxPreference.php @@ -0,0 +1,58 @@ +getEntityManager()->createQueryBuilder() + ->select( 'mp.value' ) + ->from( '\\Entities\\MailboxPreference', 'mp' ) + ->where( 'mp.attribute = ?1' ) + ->setParameter( 1, $attribute ); + + if( !$admin->isSuper() ) + $qb->join( 'mp.Mailbox', 'm' ) + ->join( 'm.Domain', 'd' ) + ->join( 'd.DomainToAdmin', 'd2a' ) + ->where( 'd2a.Admin = ?1' ) + ->setParameter( 1, $admin ); + + $data = $qb->getQuery() + ->useResultCache( true, 3600, self::VALUES_CACHE_KEY . '_' . $admin->getId() . '_' . $attribute ) + ->getScalarResult(); + + $values = []; + foreach( $data as $value ) + if( !in_array( $value['value'], $values ) ) + $values[] = $value['value']; + + return $values; + } + +} diff --git a/application/Repositories/RememberMe.php b/application/Repositories/RememberMe.php new file mode 100644 index 0000000..d85eeb4 --- /dev/null +++ b/application/Repositories/RememberMe.php @@ -0,0 +1,45 @@ +getEntityManager() + ->createQuery( 'SELECT r, u FROM \\Entities\\RememberMe r JOIN r.User u WHERE r.userhash = ?1 AND r.ckey = ?2' ) + ->setParameter( 1, $userhash ) + ->setParameter( 2, $key ) + ->getOneOrNullResult(); + } + + + + /** + * Delete all RememberMe entries for a given user + * + * @param \Entities\User $user The user to delete all RememberMe entries for + * @return int The number of entries removed + */ + public function deleteForUser( $user ) + { + return $this->getEntityManager()->createQuery( "DELETE \\Entities\\RememberMe me WHERE me.User = ?1" ) + ->setParameter( 1, $user ) + ->execute(); + } +} diff --git a/application/configs/addressbook.ini.dist b/application/configs/addressbook.ini.dist new file mode 100644 index 0000000..db83a24 --- /dev/null +++ b/application/configs/addressbook.ini.dist @@ -0,0 +1,71 @@ +;; +;; Address Book plugin configuration +;; + +[production] + +;;ldap connection parameters +ldap_uri = "ldap://10.20.30.40" +ldap_rdn = "cn=admin,dc=example,dc=com" +ldap_pass = "xxx" +ldap_dir = "ou=people,dc=example,dc=com" + +;;organisation name +organisation = "Example Organisation Name" + +;;objectClass name +;; also it can be an arrays if needed +;; +objectClass = "inetOrgPerson" + +;; +;;Fields witch be included in dn formating for user ldap entry +dn.items.0 = "mail" + +;; +;;it will appended in user dn +;; +;;So it will create dn such as: +;; cn=Joe Bloggs,ou=Development,dc=example,dc=com +default.dn.end = "ou=people,dc=example,dc=com" + +;; Parameters mapping +;; +mapping.department = "ou" +mapping.department_id = "departmentNumber" +mapping.ext_no = "telephoneNumber" +mapping.d_dial = "telephoneNumber" +mapping.mobile = "mobile" +mapping.grade = "title" +mapping.section = "title" +mapping.grade_id = "employeeType" +mapping.id = "uid" + +;; +;; if separator isset then paramter will be string seprated by seprator +;; but not an array +separator.title = "," + +;; +;; Configurations for making LDAP settings details. +;; +settings.hostname = "abook.example.com" +settings.name = "Example Corporate Directory" +settings.use_ssl = true +settings.advanced.maxHit = 10000 +settings.advanced.scope = "Subtree" +settings.advanced.filter = "(objectclass=*)" +settings.advanced.login = "Simple" + +;;;;;;;;;; +;; Configurations for DavMail syncronization script +;; +maildav.server.url = "http://davmail.example.com" +maildav.server.port = 1080 +maildav.tmp.path = "~/tmp" +maildav.domain.src = "example.com" +maildav.domain.dst = "example.net" +maildav.davical.server = "cal.example.com" +maildav.default.addressbook_name = "address-book" + +[development : production] diff --git a/application/configs/application.ini.dist b/application/configs/application.ini.dist index 54ba4a0..ff3baf8 100644 --- a/application/configs/application.ini.dist +++ b/application/configs/application.ini.dist @@ -7,49 +7,115 @@ ;; ;; IMPORTANT: Review and change all options in [user] ;; +;; ** This is for ViMbAdmin V3 and later ** +;; +;; See: https://github.com/opensolutions/ViMbAdmin3/wiki/Configuration [user] - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; Enter a random string here to add salt to admin accounts -securitysalt = "" +; Installation Keys and Salts +; +; During installation, you will be prompted to enter strings here. This +; is to verify that you are in fact the person authorised to complete the +; installation as well as provide security for cookies and passwords. + +securitysalt = "" +resources.auth.oss.rememberme.salt = "" +defaults.mailbox.password_salt = "" + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; When installing for the first time, it may be useful to set the following ; to 1 BUT ensure you set it to zero again in a production system -resources.frontController.params.displayExceptions = 0 + +phpSettings.display_startup_errors = 1 +phpSettings.display_errors = 1 +resources.frontController.params.displayExceptions = 1 + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; Default values used when created domains -; 0 means unlimited (i.e. a user can create unlimited aliases, or a user has no quota limit) +;; +;; You database and caching connection. +;; + +resources.doctrine2.connection.options.driver = 'pdo_mysql' +resources.doctrine2.connection.options.dbname = 'vimbadmin' +resources.doctrine2.connection.options.user = 'vimbadmin' +resources.doctrine2.connection.options.password = 'xxx' +resources.doctrine2.connection.options.host = 'localhost' + +;; Doctrine2 requires Memcache for maximum efficency. Without Memcache +;; it can be highly inefficient and will slow page requests down. +;; +;; You are strongly advised to install memcache and comment ArrayCache +;; here and uncomment MemcacheCache. +;; + +resources.doctrine2cache.type = 'ArrayCache' +;resources.doctrine2cache.type = 'MemcacheCache' +;resources.doctrine2cache.memcache.servers.0.host = '127.0.0.1' +resources.doctrine2cache.namespace = 'ViMbAdmin3' + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; Default values used when creating domains +; +; See: https://github.com/opensolutions/ViMbAdmin3/wiki/Configuration +; See: https://github.com/opensolutions/ViMbAdmin3/wiki/Quotas + defaults.domain.quota = 0 defaults.domain.maxquota = 0 defaults.domain.transport = "virtual" defaults.domain.aliases = 0 defaults.domain.mailboxes = 0 +defaults.quota.multiplier = 'MB' + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Use server side filtering to reduce pagination time on client side +;; Defaults to off / false +defaults.server_side.pagination.enable = false +defaults.server_side.pagination.min_search_str = 3 +defaults.server_side.pagination.max_result_cnt = 500 + +;; Separate configuration for domain list +defaults.server_side.pagination.domain.enable = false +defaults.server_side.pagination.domain.min_search_str = 3 +defaults.server_side.pagination.domain.max_result_cnt = 500 + +; The number of rows displayed in the tables +; must be one of these: 10, 25, 50, 100 +defaults.table.entries = 50 + + + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Options for the display of domain and mailbox sizes +;; +;; See: https://github.com/opensolutions/ViMbAdmin3/wiki/Mailbox-Sizes +;; +;; Enable or disable display of sizes. Default: disabled + +defaults.list_size.disabled = true + +;; Maildir size units. By default: KB. One of B, KB, MB or GB. +defaults.list_size.multiplier = 'GB' + + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Default values for creating mailboxes -; This sets the uid and gid columns in the mailbox table to the below valies +; This sets the uid and gid columns in the mailbox table to the below values defaults.mailbox.uid = 2000 defaults.mailbox.gid = 2000 -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; Allow admins to dictate whether a user can use BOTH, IMAP ONLY, POP3 ONLY when creating mailboxes -; -; Must be supported by your POP3/IMAP server. -; -; See https://github.com/opensolutions/ViMbAdmin/wiki/POP3-IMAP-Access-Restriction for documentation -; -allow_access_restriction = false - -; specify the options which should be allowed for access restrictions -access_restriction_type.smtp = "SMTP" -access_restriction_type.imap = "IMAP" -access_restriction_type.pop3 = "POP3" ; Set the homedir and maildir values in the mailbox table where the ; following substitutions apply: @@ -58,33 +124,28 @@ access_restriction_type.pop3 = "POP3" ; %u -> user part of email address ; $m -> full email address ; -defaults.mailbox.maildir = "%d/%u/" -defaults.mailbox.homedir = "/home/vmail/" +; +; http://wiki2.dovecot.org/VirtualUsers/Home + +defaults.mailbox.maildir = "maildir:/srv/vmail/%d/%u/mail:LAYOUT=fs" +defaults.mailbox.homedir = "/srv/vmail/%d/%u" ;minimum mailbox password length defaults.mailbox.min_password_length = 8 ; The password hashing function to use. Set to one of: ; -; "plain" - password stored as clear text -; "md5" - password hashed using MD5 without salt (PHP md5()) -; "md5.salted" - password hashed using MD5 with salt (see below) -; "crypt" - standard DES hash (compatible with MySQL ENCRYPT and courier - be sure to -; set a two character hash below -; "crypt:md5" - standard MD5 hash with random seed -; "crypt:blowfish" - Blowfish hash with random seed (not in mainline glibc; added in some Linux distributions) -; "crypt:sha256" - standard sha-256 hash (requires glibc 2.7 or newer). Equivalent to dovecot:SHA256-CRYPT -; "crypt:sha512" - standard sha-512 hash (requires glibc 2.7 or newer). Equivalent to dovecot:SHA256-CRYPT -; "md5.crypt" - MD5 based salted password hash nowadays commonly used in /etc/shadow. -; (compatible with Dovecot) Requires min 8 character hash below. -; "sha1" - password hashed using sha1 without salt -; "sha1.salted" - password hashed using sha1 with salt defined below -; "dovecot:XXX" - call the Dovecot password generator (see next option below) and use the +; "plain" - password stored as clear text +; "md5" - password hashed using MD5 without salt (PHP md5()) +; "md5.salted" - password hashed using MD5 with salt (see below) +; "sha1" - password hashed using sha1 without salt +; "sha1.salted" - password hashed using sha1 with salt defined below +; "crypt:XXX" - call the PHP crypt function (with random salt) where XXX is one of: md5, blowfish, sha256, sha512 +; "dovecot:XXX" - call the Dovecot password generator (see next option below) and use the ; scheme specified by XXX. To see available schemes, use 'dovecotpw -l' ; or 'doveadm pw -l' -defaults.mailbox.password_scheme = "md5" - +defaults.mailbox.password_scheme = "crypt:md5" ; The path to (and initial option(s) if necessary) the Dovecot password generator. Typical ; values may be something like: @@ -94,42 +155,79 @@ defaults.mailbox.password_scheme = "md5" defaults.mailbox.dovecot_pw_binary = "/usr/bin/doveadm pw" -; A hash to use when storing passwords. Typically used with "crypt" -; which only uses the first two characters and includes this in the -; final hash. For other schemes such as md5.salted then your mail system -; will also need to know and use this hash (or use Dovecot for authentication) -defaults.mailbox.password_hash = "ChangeMePlease" + +;; A "mailbox alias" will, for example add the following entry to +;; the alias table for a mailbox: name@example.com +;; +;; name@example.com -> name@example.com +;; +;; This is required for aliasing an entire domain. If in doubt, leave it enabled. +mailboxAliases = 1 + + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; See: https://github.com/opensolutions/ViMbAdmin3/wiki/Archiving-Mailboxes + +server_id = 1 + +;;Archive options +binary.path.chown_R = "/bin/chown -R" +binary.path.tar_cf = "/bin/tar -cf" +binary.path.tar_xf = "/bin/tar -xf" +binary.path.bzip2_q = "/bin/bzip2 -q" +binary.path.bunzip2_q = "/bin/bunzip2 -q" +binary.path.rm_rf = "/bin/rm -rf" + +archive.path = "/srv/archives" + + + + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; Export Mailbox Settings +; +; See: ; See: https://github.com/opensolutions/ViMbAdmin3/wiki/Export-Settings +; +defaults.export_settings.disabled = true + +;; Export settings alowed subnets +defaults.export_settings.allowed_subnet[] = "10." +defaults.export_settings.allowed_subnet[] = "192.168." -; The number of rows displayed in the tables -; must be one of these: 10, 25, 50, 100 -defaults.table.entries = 25 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; Settings email default values. ;; -;; Smae substituions apply as for maildir above. See (and edit) the -;; following file to see how the below are used: +;; Substituions are as follows: +;; +;; %d -> domain part of email address +;; %u -> user part of email address +;; $m -> full email address +;; +;; See (and skin) the following file to see how the below are used: ;; ;; views/mailbox/email/settings.phtml ;; server.smtp.enabled = 1 -server.smtp.host = "smtp.%d" +server.smtp.host = "mail.%d" server.smtp.user = "%m" -server.smtp.port = "25" +server.smtp.port = "465" server.smtp.crypt = "SSL" server.pop3.enabled = 1 -server.pop3.host = "pop3.%d" +server.pop3.host = "gpo.%d" server.pop3.user = "%m" server.pop3.port = "995" server.pop3.crypt = "SSL" server.imap.enabled = 1 -server.imap.host = "imap.%d" +server.imap.host = "gpo.%d" server.imap.user = "%m" server.imap.port = "993" server.imap.crypt = "SSL" @@ -139,22 +237,40 @@ server.webmail.host = "https://webmail.%d" server.webmail.user = "%m" + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;; Identity + +identity.orgname = "Example Limited" +identity.name = "Example Support Team" +identity.email = "support@example.com" +identity.autobot.name = "ViMbAdmin Autobot" +identity.autobot.email = "autobot@example.com" +identity.mailer.name = "ViMbAdmin Autobot" +identity.mailer.email = "do-not-reply@example.com" + +identity.sitename = "ViMbAdmin" +identity.siteurl = "https://www.example.com/vimbadmin/" + + ;; ;; All mails and correspondance will come from the following;; server.email.name = "ViMbAdmin Administrator" -server.email.address = "vimbadmin@example.com" +server.email.address = "support@example.com" + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; -;; A "mailbox alias" will, for example add the following entry to -;; the alias table for a mailbox: name@example.com +;; Skinning ;; -;; name@example.com -> name@example.com +;; You can skin ViMbAdmin pages if you wish. ;; -;; This is required for aliasing an entire domain. If in doubt, leave it enabled. -mailboxAliases = 1 +;; See: https://github.com/opensolutions/ViMbAdmin3/wiki/Skinning + +; resources.smarty.skin = "myskin" + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -164,40 +280,14 @@ mailboxAliases = 1 ;; Ensure you have a working mail server configuration so the system can ;; send emails: ;; -resources.mailer.smtphost = "smtp.example.com" +resources.mailer.smtphost = "localhost" ;resources.mailer.username = "" -;resources.mailer.password = "96" +;resources.mailer.password = "" ;resources.mailer.auth = "" ;resources.mailer.ssl = "" ;resources.mailer.port = "25" -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;; You database connection. -;; -;; See: http://www.doctrine-project.org/projects/orm/1.2/docs/manual/introduction-to-connections/en -;; -;; phptype(dbsyntax)://username:password@protocol+hostspec/database?option=value -;; -;; Most variations are allowed: -;; -;; phptype://username:password@protocol+hostspec:110//usr/db_file.db -;; phptype://username:password@hostspec/database -;; phptype://username:password@hostspec -;; phptype://username@hostspec -;; phptype://hostspec/database -;; phptype://hostspec -;; phptype:///database -;; phptype:///database?option=value&anotheroption=anothervalue -;; phptype(dbsyntax) -;; phptype -;; -;; phptype is typically one of: mysqli, mysql, pgsql, sqlite, mssql -;; - -; resources.doctrine.connection_string = "phptype://username:password@host/database" - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; @@ -208,14 +298,14 @@ resources.mailer.smtphost = "smtp.example.com" ;; It is useful to use the email logger to be alerted of serious errors. ;; -resources.logger.enabled = 0 +ondemand_resources.logger.enabled = 1 -;resources.logger.writers.email.from = vimbadmin@example.com -;resources.logger.writers.email.to = sysadmins@example.com -;resources.logger.writers.email.prefix = "ViMbAdmin_Error" -;resources.logger.writers.email.level = 3 +;ondemand_resources.logger.writers.email.from = "admin@example.com" +;ondemand_resources.logger.writers.email.to = "admin@example.com" +;ondemand_resources.logger.writers.email.prefix = "ViMbAdmin_Error" +;ondemand_resources.logger.writers.email.level = 3 -;resources.logger.writers.stream.level = 7 +ondemand_resources.logger.writers.stream.level = 7 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -248,29 +338,225 @@ skipVersionCheck = 0 skipInstallPingback = 0 -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + + + + + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; Allow admins to dictate whether a user can use BOTH, IMAP ONLY, +; POP3 ONLY when creating mailboxes. +; +; Must be supported by your POP3/IMAP server. +; +; See https://github.com/opensolutions/ViMbAdmin/wiki/POP3-IMAP-Access-Permissions +; for documentation. +; +; This is handled via a plugin +; + +vimbadmin_plugins.AccessPermissions.disabled = false + +; specify the options which should be allowed for access restrictions +vimbadmin_plugins.AccessPermissions.type.SMTP = "SMTP" +vimbadmin_plugins.AccessPermissions.type.IMAP = "IMAP" +vimbadmin_plugins.AccessPermissions.type.POP3 = "POP3" +vimbadmin_plugins.AccessPermissions.type.SIEVE = "SIEVE" + + + + + + + + + + + + + + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; Proceed onwards with caution. ;; ;; The above [user] params are the may ones of consequence. ;; -[production : user] -phpSettings.display_startup_errors = 0 -phpSettings.display_errors = 0 +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; Allows to add additional information. +; +; This is handled via a plugin +; + +vimbadmin_plugins.AccessPermissions.disabled = false +vimbadmin_plugins.Jabber.disabled = true +vimbadmin_plugins.DirectoryEntry.disabled = true +vimbadmin_plugins.SharedMailbox.disabled = true +vimbadmin_plugins.SOGo.disabled = true + + +vimbadmin_plugins.AdditionalInfo.disabled = true +vimbadmin_plugins.Addressbook.disabled = true +vimbadmin_plugins.Calendar.disabled = true +vimbadmin_plugins.RoundCube.disabled = true + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;; Disabling directory entry subform element +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +vimbadmin_plugins.DirectoryEntry.disabled_elements.JpegPhoto = true +vimbadmin_plugins.DirectoryEntry.disabled_elements.Mail = true +vimbadmin_plugins.DirectoryEntry.disabled_elements.PreferredLanguage = true +vimbadmin_plugins.DirectoryEntry.disabled_elements.Secretary = true + +vimbadmin_plugins.DirectoryEntry.disabled_elements.PersonalTitle = false +vimbadmin_plugins.DirectoryEntry.disabled_elements.GivenName = false +vimbadmin_plugins.DirectoryEntry.disabled_elements.Sn = false +vimbadmin_plugins.DirectoryEntry.disabled_elements.DisplayName = false +vimbadmin_plugins.DirectoryEntry.disabled_elements.Initials = false +vimbadmin_plugins.DirectoryEntry.disabled_elements.BusinesCategory = false +vimbadmin_plugins.DirectoryEntry.disabled_elements.EmployeeType = false +vimbadmin_plugins.DirectoryEntry.disabled_elements.Title = false +vimbadmin_plugins.DirectoryEntry.disabled_elements.DepartmentNumber = false +vimbadmin_plugins.DirectoryEntry.disabled_elements.Ou = false +vimbadmin_plugins.DirectoryEntry.disabled_elements.RoomNumber = false +vimbadmin_plugins.DirectoryEntry.disabled_elements.O = false +vimbadmin_plugins.DirectoryEntry.disabled_elements.CarLicense = false +vimbadmin_plugins.DirectoryEntry.disabled_elements.EmployeeNumber = false +vimbadmin_plugins.DirectoryEntry.disabled_elements.HomePhone = false +vimbadmin_plugins.DirectoryEntry.disabled_elements.TelephoneNumber = false +vimbadmin_plugins.DirectoryEntry.disabled_elements.Mobile = false +vimbadmin_plugins.DirectoryEntry.disabled_elements.Pager = false +vimbadmin_plugins.DirectoryEntry.disabled_elements.FacsimileTelephoneNumber = false +vimbadmin_plugins.DirectoryEntry.disabled_elements.HomePostalAddress = false +vimbadmin_plugins.DirectoryEntry.disabled_elements.LabeledUri = false +vimbadmin_plugins.DirectoryEntry.disabled_elements.Manager = false + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; Mailbox AdditionalInfo plugin elements +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + +;;Additional text messages for plugin. +AdditionalInfo.mailbox.formPreBlurb = "

NB: Do not edit the following. It is sync'd on a nightly basis ..." + +; First Name +vimbadmin_plugins.AdditionalInfo.elements.id.type = "Zend_Form_Element_Text" +vimbadmin_plugins.AdditionalInfo.elements.id.options.required = false +vimbadmin_plugins.AdditionalInfo.elements.id.options.label = "LDAP Id" + +; First Name +vimbadmin_plugins.AdditionalInfo.elements.first_name.type = "Zend_Form_Element_Text" +vimbadmin_plugins.AdditionalInfo.elements.first_name.options.required = false +vimbadmin_plugins.AdditionalInfo.elements.first_name.options.label = "First Name" + +; Last Name +vimbadmin_plugins.AdditionalInfo.elements.second_name.type = "Zend_Form_Element_Text" +vimbadmin_plugins.AdditionalInfo.elements.second_name.options.required = false +vimbadmin_plugins.AdditionalInfo.elements.second_name.options.label = "Last Name" + +; Grade +vimbadmin_plugins.AdditionalInfo.elements.grade.type = "Zend_Form_Element_Text" +vimbadmin_plugins.AdditionalInfo.elements.grade.options.required = false +vimbadmin_plugins.AdditionalInfo.elements.grade.options.label = "Grade" + +; Grade Id +vimbadmin_plugins.AdditionalInfo.elements.grade_id.type = "Zend_Form_Element_Text" +vimbadmin_plugins.AdditionalInfo.elements.grade_id.options.required = false +vimbadmin_plugins.AdditionalInfo.elements.grade_id.options.label = "Grade Id" +vimbadmin_plugins.AdditionalInfo.elements.grade_id.options.validators.digits[] = 'Digits' +vimbadmin_plugins.AdditionalInfo.elements.grade_id.options.validators.digits[] = true + +; Department +vimbadmin_plugins.AdditionalInfo.elements.department.type = "Zend_Form_Element_Text" +vimbadmin_plugins.AdditionalInfo.elements.department.options.required = false +vimbadmin_plugins.AdditionalInfo.elements.department.options.label = "Department" + +; Department Id +vimbadmin_plugins.AdditionalInfo.elements.department_id.type = "Zend_Form_Element_Text" +vimbadmin_plugins.AdditionalInfo.elements.department_id.options.required = false +vimbadmin_plugins.AdditionalInfo.elements.department_id.options.label = "Department Id" +vimbadmin_plugins.AdditionalInfo.elements.department_id.options.validators.digits[] = 'Digits' +vimbadmin_plugins.AdditionalInfo.elements.department_id.options.validators.digits[] = true + +; Section +vimbadmin_plugins.AdditionalInfo.elements.section.type = "Zend_Form_Element_Text" +vimbadmin_plugins.AdditionalInfo.elements.section.options.required = false +vimbadmin_plugins.AdditionalInfo.elements.section.options.label = "Section" + +; Extension Number +vimbadmin_plugins.AdditionalInfo.elements.ext_no.type = "Zend_Form_Element_Text" +vimbadmin_plugins.AdditionalInfo.elements.ext_no.options.required = false +vimbadmin_plugins.AdditionalInfo.elements.ext_no.options.label = "Extension Number" +vimbadmin_plugins.AdditionalInfo.elements.ext_no.options.validators.digits[] = 'Digits' +vimbadmin_plugins.AdditionalInfo.elements.ext_no.options.validators.digits[] = true +vimbadmin_plugins.AdditionalInfo.elements.ext_no.options.validators.length[] = 'StringLength' +vimbadmin_plugins.AdditionalInfo.elements.ext_no.options.validators.length[] = false +vimbadmin_plugins.AdditionalInfo.elements.ext_no.options.validators.length.range[] = 4 +vimbadmin_plugins.AdditionalInfo.elements.ext_no.options.validators.length.range[] = 4 +;;to disable autocomplete functionality +vimbadmin_plugins.AdditionalInfo.elements.ext_no.options.autocomplete = 'off' + +; Direct Dial +vimbadmin_plugins.AdditionalInfo.elements.d_dial.type = "Zend_Form_Element_Text" +vimbadmin_plugins.AdditionalInfo.elements.d_dial.options.required = false +vimbadmin_plugins.AdditionalInfo.elements.d_dial.options.label = "Direct Dial" +vimbadmin_plugins.AdditionalInfo.elements.d_dial.options.autocomplete = 'off' + +; Mobile +vimbadmin_plugins.AdditionalInfo.elements.mobile.type = "Zend_Form_Element_Text" +vimbadmin_plugins.AdditionalInfo.elements.mobile.options.required = false +vimbadmin_plugins.AdditionalInfo.elements.mobile.options.label = "Mobile" +vimbadmin_plugins.AdditionalInfo.elements.mobile.options.autocomplete = 'off' + +;;;;;;; +;; Aliases additional information +;; +; First Name +vimbadmin_plugins.AdditionalInfo.alias.elements.name.type = "Zend_Form_Element_Text" +vimbadmin_plugins.AdditionalInfo.alias.elements.name.options.required = false +vimbadmin_plugins.AdditionalInfo.alias.elements.name.options.label = "Name" + +; Extension Number +vimbadmin_plugins.AdditionalInfo.alias.elements.ext_no.type = "Zend_Form_Element_Text" +vimbadmin_plugins.AdditionalInfo.alias.elements.ext_no.options.required = false +vimbadmin_plugins.AdditionalInfo.alias.elements.ext_no.options.label = "Extension Number" +vimbadmin_plugins.AdditionalInfo.alias.elements.ext_no.options.validators.digits[] = 'Digits' +vimbadmin_plugins.AdditionalInfo.alias.elements.ext_no.options.validators.digits[] = true +vimbadmin_plugins.AdditionalInfo.alias.elements.ext_no.options.validators.length[] = 'StringLength' +vimbadmin_plugins.AdditionalInfo.alias.elements.ext_no.options.validators.length[] = false +vimbadmin_plugins.AdditionalInfo.alias.elements.ext_no.options.validators.length.range[] = 4 +vimbadmin_plugins.AdditionalInfo.alias.elements.ext_no.options.validators.length.range[] = 4 +vimbadmin_plugins.AdditionalInfo.alias.elements.ext_no.options.autocomplete = 'off' + +; Direct Dial +vimbadmin_plugins.AdditionalInfo.alias.elements.d_dial.type = "Zend_Form_Element_Text" +vimbadmin_plugins.AdditionalInfo.alias.elements.d_dial.options.required = false +vimbadmin_plugins.AdditionalInfo.alias.elements.d_dial.options.label = "Direct Dial" +vimbadmin_plugins.AdditionalInfo.alias.elements.d_dial.options.autocomplete = 'off' + + +[production : user] includePaths.library = APPLICATION_PATH "/../library" -includePaths.library = APPLICATION_PATH "/../library/Doctrine" +includePaths.osslibrary = APPLICATION_PATH "/../vendor/opensolutions/oss-framework/src/" + bootstrap.path = APPLICATION_PATH "/Bootstrap.php" bootstrap.class = "Bootstrap" appnamespace = "ViMbAdmin" temporary_directory = APPLICATION_PATH "/../var/tmp" +pluginPaths.OSS_Resource = APPLICATION_PATH "/../vendor/opensolutions/oss-framework/src/OSS/Resource" pluginPaths.ViMbAdmin_Resource = APPLICATION_PATH "/../library/ViMbAdmin/Resource" mini_js = 1 @@ -278,51 +564,84 @@ mini_css = 1 alias_autocomplete_min_length = 2 -resources.router.routes.changepass.route = "/change-password" -resources.router.routes.changepass.defaults.module = "default" -resources.router.routes.changepass.defaults.controller = "auth" -resources.router.routes.changepass.defaults.action = "change-password" - -resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers" -resources.doctrine.data_fixtures_path = APPLICATION_PATH "/../doctrine/data/fixtures" -resources.doctrine.models_path = APPLICATION_PATH "/models" -resources.doctrine.migrations_path = APPLICATION_PATH "/../doctrine/migrations" -resources.doctrine.sql_path = APPLICATION_PATH "/../doctrine/data/sql" -resources.doctrine.yaml_schema_path = APPLICATION_PATH "/../doctrine/schema" -resources.doctrine.generate_models_options.generateTableClasses = true -resources.doctrine.extensions_path = APPLICATION_PATH "/../library/DoctrineExtensions" -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; Database schema migration version - DO NOT CHANGE -migration_version = 2 - -resources.namespace.checkip = 1 - -resources.auth = 1 +resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers" +resources.frontController.moduleDirectory = APPLICATION_PATH "/modules" +resources.modules[] = + + +; doctrine2 +resources.doctrine2.models_path = APPLICATION_PATH +resources.doctrine2.proxies_path = APPLICATION_PATH "/Proxies" +resources.doctrine2.repositories_path = APPLICATION_PATH +resources.doctrine2.xml_schema_path = APPLICATION_PATH "/../doctrine2/xml" +resources.doctrine2.autogen_proxies = 0 +resources.doctrine2.logger = 1 +resources.doctrine2.models_namespace = "Entities" +resources.doctrine2.proxies_namespace = "Proxies" +resources.doctrine2.repositories_namespace = "Repositories" + + +resources.doctrine2cache.autoload_method = "composer" +;resources.doctrine2cache.type = 'ArrayCache' +;resources.doctrine2cache.type = 'MemcacheCache' +;resources.doctrine2cache.memcache.servers.0.host = '127.0.0.1' +;resources.doctrine2cache.memcache.servers.0.port = '11211' +;resources.doctrine2cache.memcache.servers.0.persistent = false +;resources.doctrine2cache.memcache.servers.0.weight = 1 +;resources.doctrine2cache.memcache.servers.0.timeout = 1 +;resources.doctrine2cache.memcache.servers.0.retry_int = 15 + +; resources.doctrine2cache.memcache.servers.1.host = 'xxx' +; resources.doctrine2cache.memcache.servers.2.host = 'yyy' + +resources.namespace.checkip = 0 + +resources.auth.enabled = 1 +resources.auth.oss.adapter = "OSS_Auth_Doctrine2Adapter" +resources.auth.oss.pwhash = "bcrypt" +resources.auth.oss.hash_cost = 9 +resources.auth.oss.entity = "\\Entities\\Admin" +resources.auth.oss.disabled.lost-username = 1 +resources.auth.oss.disabled.lost-password = 0 + +resources.auth.oss.rememberme.enabled = 1 +resources.auth.oss.rememberme.timeout = 2592000 +resources.auth.oss.rememberme.secure = true + +resources.auth.oss.lost_password.use_captcha = true resources.session.save_path = APPLICATION_PATH "/../var/session" resources.session.use_only_cookies = true resources.session.remember_me_seconds = 3600 +resources.session.name = 'VIMBADMIN3' -resources.logger.writers.stream.path = APPLICATION_PATH "/../var/log" -resources.logger.writers.stream.owner = www-data -resources.logger.writers.stream.group = www-data +ondemand_resources.logger.writers.stream.path = APPLICATION_PATH "/../var/log" +ondemand_resources.logger.writers.stream.owner = www-data +ondemand_resources.logger.writers.stream.group = www-data +ondemand_resources.logger.writers.stream.mode = single +ondemand_resources.logger.writers.stream.logname = vimbadmin.log ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Smarty View ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -resources.view.enabled = 0 + resources.smarty.enabled = 1 resources.smarty.templates = APPLICATION_PATH "/views" +; resources.smarty.skin = "myskin" resources.smarty.compiled = APPLICATION_PATH "/../var/templates_c" resources.smarty.cache = APPLICATION_PATH "/../var/cache" resources.smarty.config = APPLICATION_PATH "/configs/smarty" resources.smarty.plugins[] = APPLICATION_PATH "/../library/ViMbAdmin/Smarty/functions" -resources.smarty.plugins[] = APPLICATION_PATH "/../library/Smarty/plugins" -resources.smarty.plugins[] = APPLICATION_PATH "/../library/Smarty/sysplugins" +resources.smarty.plugins[] = APPLICATION_PATH "/../vendor/opensolutions/oss-framework/src/OSS/Smarty/functions" +resources.smarty.plugins[] = APPLICATION_PATH "/../vendor/smarty/smarty/distribution/libs/plugins" +resources.smarty.plugins[] = APPLICATION_PATH "/../vendor/smarty/smarty/distribution/libs/sysplugins" resources.smarty.debugging = 0 + + + [development : production] mini_js = 0 @@ -332,8 +651,3 @@ phpSettings.display_startup_errors = 1 phpSettings.display_errors = 1 resources.frontController.params.displayExceptions = 1 -resources.logger.writers.firebug.enabled = 1 -resources.logger.writers.firebug.level = 7 - -resources.view.debugging = true -resources.smarty.debugging = true diff --git a/application/configs/davical.ini.dist b/application/configs/davical.ini.dist new file mode 100644 index 0000000..c950cdf --- /dev/null +++ b/application/configs/davical.ini.dist @@ -0,0 +1,47 @@ +;; +;; davical plugin configuration +;; + +[production] + +servers.davicalsrv1.name = "https://cal.example.com" +servers.davicalsrv1.dbname = "davical" +servers.davicalsrv1.user = "davical_app" +servers.davicalsrv1.password = "xxx" +servers.davicalsrv1.host = "127.0.0.1" +servers.davicalsrv1.port = "5432" +servers.davicalsrv1.driver = "pdo_pgsql" + +;; The following is for creating shared calanders +;; +;; It will be created automatically + +shared_resource.username = "davical-shared-resources@example.com" +shared_resource.password = "xxx" +shared_resource.fullname = "Example Shared Resources" +shared_resource.email = "admin@example.com" +shared_resource.active = 1 +shared_resource.updated = "now()" + + +;; Calanders are created and named in the UI +;; +;; If true, the UI will be preset to create the following named calanders: + +auto_create = true +auto.work = "Work" + +;;;;;;;;;; +;; Configurations for DavMail syncronization script +;; +maildav.server.url = "http://example.com" +maildav.server.port = 1080 +maildav.tmp.path = "/var/tmp" +maildav.default.calendar_name = "work" +maildav.domain.src = "example.com" +maildav.domain.dst = "example.net" + + +[development : production] + + diff --git a/application/configs/jabber.ini.dist b/application/configs/jabber.ini.dist new file mode 100644 index 0000000..0e63df9 --- /dev/null +++ b/application/configs/jabber.ini.dist @@ -0,0 +1,30 @@ +;; +;; Jabber plugin configuration +;; + +[production] + +servers.1.name = "Exampple Staff Instant Messaging Server" +servers.1.auto = true +servers.1.useSQLview = true +servers.1.dbal.dbname = "jabberd2" +servers.1.dbal.user = "jabberd2" +servers.1.dbal.password = "xxx" +servers.1.dbal.host = "localhost" +servers.1.dbal.driver = "pdo_mysql" + + +servers.1.settingsPreBlurb = "You should be able to configure most clients with just your +Jabber ID as above. If not, you can try manually setting the +following:" + +servers.1.settingsPostBlurb = "Contact us for assistance if you have any difficulty." + +servers.1.server = "im.example.com" +servers.1.port = 5222 +servers.1.ssl = false +servers.1.tls = true +servers.1.resource = "Thunderbird" + + +[development : production] diff --git a/application/configs/roundcube.ini.dist b/application/configs/roundcube.ini.dist new file mode 100644 index 0000000..348c098 --- /dev/null +++ b/application/configs/roundcube.ini.dist @@ -0,0 +1,22 @@ +;; +;; roundcube plugin configuration +;; + +[production] + +; database parameters +servers.dbal.dbname = "roundcubemail" +servers.dbal.user = "roundcube" +servers.dbal.password = "xxx" +servers.dbal.host = "localhost" +servers.dbal.driver = "pdo_mysql" + +servers.davical.address = "https://cal.example.com" + +;;;;;; +;; key for password encryption +;; + +auth.key = "xxx" + +[development : production] diff --git a/application/configs/sogo.ini.dist b/application/configs/sogo.ini.dist new file mode 100644 index 0000000..bddcb7f --- /dev/null +++ b/application/configs/sogo.ini.dist @@ -0,0 +1,33 @@ +;; +;; roundcube plugin configuration +;; + +[production] + +; database parameters +servers.dbal.dbname = "sogo" +servers.dbal.user = "sogo" +servers.dbal.password = "xxx" +servers.dbal.host = "localhost" +servers.dbal.driver = "pdo_mysql" + +user_profile.default.SOGoTimeZone = "Europe/Dublin" +user_profile.default.SOGoLanguage = "English" +user_profile.default.SOGoShorDateFormat = "%d/%m/%Y" +user_profile.default.SOGoLongDateFormat = "%A, %d %B, %Y" +user_profile.default.SOGoTimeFormat = "%H:%M" +user_profile.default.SOGoFirstDayOfWeek = "0" +user_profile.auxiliaryImap.default.encryption = "ssl" +user_profile.auxiliaryImap.default.server = "gpo.example.com" + +sogo.server.uri = "https://webmail.example.com/SOGo" +sogo.defaults.calendar_name = "personal" +sogo.defaults.contacts_name = "personal" + +maildav.server.url = "http://10.20.30.40" +maildav.server.port = 1080 +maildav.tmp.path = "/var/tmp" +maildav.domain.src = "example.com" +maildav.domain.dst = "example.net" + +[development : production] diff --git a/application/models/MailboxTable.php b/application/controllers/AdditionalInfoController.php similarity index 68% rename from application/models/MailboxTable.php rename to application/controllers/AdditionalInfoController.php index 343c047..962aa14 100644 --- a/application/models/MailboxTable.php +++ b/application/controllers/AdditionalInfoController.php @@ -7,7 +7,7 @@ * project which provides an easily manageable web based virtual * mailbox administration system. * - * Copyright (c) 2011 Open Source Solutions Limited + * Copyright (c) 2011 - 2014 Open Source Solutions Limited * * ViMbAdmin is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,28 +26,29 @@ * 147 Stepaside Park, Stepaside, Dublin 18, Ireland. * Barry O'Donovan * - * @copyright Copyright (c) 2011 Open Source Solutions Limited + * @copyright Copyright (c) 2011 - 2014 Open Source Solutions Limited * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License, version 3 (GPLv3) * @author Open Source Solutions Limited * @author Barry O'Donovan - * @author Roland Huszti */ /** + * The admin controller. + * * @package ViMbAdmin - * @subpackage Models + * @subpackage Controllers */ -class MailboxTable extends Doctrine_Table +class AdditionalInfoController extends ViMbAdmin_Controller_Action { /** - * Returns an instance of this class. - * - * @return object MailboxTable + * Gets autocomplete data array */ - public static function getInstance() + public function typeaheadAction() { - return Doctrine_Core::getTable( 'Mailbox' ); + Zend_Controller_Action_HelperBroker::removeHelper( 'viewRenderer' ); + $values = $this->getD2EM()->getRepository( "\\Entities\\MailboxPreference" )->loadPrefrenceValuesByAttribute( 'xpiInfo.' . $this->getParam( "type" ), $this->getAdmin() ); + echo json_encode( $values ); } } diff --git a/application/controllers/AdminController.php b/application/controllers/AdminController.php index 0125bcd..259104f 100644 --- a/application/controllers/AdminController.php +++ b/application/controllers/AdminController.php @@ -7,7 +7,7 @@ * project which provides an easily manageable web based virtual * mailbox administration system. * - * Copyright (c) 2011 Open Source Solutions Limited + * Copyright (c) 2011 - 2014 Open Source Solutions Limited * * ViMbAdmin is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,11 +26,10 @@ * 147 Stepaside Park, Stepaside, Dublin 18, Ireland. * Barry O'Donovan * - * @copyright Copyright (c) 2011 Open Source Solutions Limited + * @copyright Copyright (c) 2011 - 2014 Open Source Solutions Limited * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License, version 3 (GPLv3) * @author Open Source Solutions Limited * @author Barry O'Donovan - * @author Roland Huszti */ /** @@ -53,15 +52,11 @@ class AdminController extends ViMbAdmin_Controller_Action */ public function preDispatch() { - // if an ajax request, remove the view help - if( substr( $this->getRequest()->getParam( 'action' ), 0, 4 ) == 'ajax' ) - $this->_helper->viewRenderer->setNoRender( true ); - - if( $this->getRequest()->getParam( 'action' ) != 'password' ) + if( $this->getRequest()->getActionName() != 'password' ) $this->authorise( true ); // must be a super admin - if( $this->_targetAdmin ) - $this->view->targetAdmin = $this->_targetAdmin; + if( $this->getTargetAdmin() ) + $this->view->targetAdmin = $this->getTargetAdmin(); } @@ -70,7 +65,7 @@ public function preDispatch() */ public function indexAction() { - $this->_forward( 'list' ); + $this->forward( 'list' ); } @@ -79,412 +74,327 @@ public function indexAction() */ public function listAction() { - $this->view->admins = Doctrine_Query::create() - ->from( 'Admin' ) - ->fetchArray(); + $this->view->admins = $this->getD2EM()->getRepository( "\\Entities\\Admin" )->findAll(); } - - /** - * Toggles the active flag. Prints 'ok' on success or 'ko' otherwise to stdout. + /** + * Adds a new admin or superadmin to the system. Optionally it can send a welcome email. */ - public function ajaxToggleActiveAction() + public function addAction() { - if ( ( !$this->_targetAdmin ) || ( $this->getAdmin()->id == $this->_targetAdmin->id ) ) - return print 'ko'; + $this->view->form = $form = new ViMbAdmin_Form_Admin_AddEdit(); + $form->removeElement( 'salt' ); - $this->_targetAdmin['active'] = !$this->_targetAdmin['active']; - $this->_targetAdmin->save(); + if( $this->getRequest()->isPost() && $form->isValid( $_POST ) ) + { + $this->_targetAdmin = new \Entities\Admin(); + + $this->getD2EM()->persist( $this->getTargetAdmin() ); + $form->assignFormToEntity( $this->getTargetAdmin(), $this, false ); + $this->getTargetAdmin()->setCreated( new \DateTime() ); + + $password = $this->getTargetAdmin()->getPassword(); + $this->getTargetAdmin()->setPassword( + OSS_Auth_Password::hash( + $password, + $this->_options['resources']['auth']['oss'] + ) + ); + + $this->log( + \Entities\Log::ACTION_ADMIN_ADD, + "{$this->getAdmin()->getFormattedName()} added admin {$this->getTargetAdmin()->getFormattedName()}" + ); + + $this->getD2EM()->flush(); + + if( $form->getValue( 'welcome_email' ) ) + { + $mailer = $this->getMailer(); + $mailer->setSubject( 'ViMbAdmin :: Your New Administrator Account' ); + $mailer->addTo( $this->getTargetAdmin()->getUsername() ); + $mailer->setFrom( + $this->_options['server']['email']['address'], + $this->_options['server']['email']['name'] + ); - LogTable::log( 'ADMIN_TOGGLE_ACTIVE', - "Set {$this->_targetAdmin['username']} set " . ( $this->_targetAdmin['active'] ? '' : 'de' ) . "active", - $this->getAdmin(), null - ); + $this->view->username = $this->getTargetAdmin()->getUsername(); + $this->view->password = $form->getValue( 'password' ); + $mailer->setBodyText( $this->view->render( 'admin/email/new_admin.phtml' ) ); + + try + { + $mailer->send(); + } + catch( Exception $e ) + { + $this->getLogger()->debug( $e->getTraceAsString() ); + $this->addMessage( 'Could not send welcome email', OSS_Message::ALERT ); + } + } - print 'ok'; + $this->addMessage( _( 'You have successfully added a new administrator to the system.' ), OSS_Message::SUCCESS ); + $this->_redirect( 'admin/list' ); + } } /** - * Toggles the super flag. Prints 'ok' on success or 'ko' otherwise to stdout. + * Toggles the active flag. Prints 'ok' on success or 'ko' otherwise to stdout. */ - public function ajaxToggleSuperAction() + public function ajaxToggleActiveAction() { - if( ( !$this->_targetAdmin ) || ( $this->getAdmin()->id == $this->_targetAdmin->id ) ) - return print 'ko'; + if( !$this->getTargetAdmin() || $this->getAdmin()->getId() == $this->getTargetAdmin()->getId() ) + print 'ko'; - $this->_targetAdmin['super'] = !$this->_targetAdmin['super']; - $this->_targetAdmin->save(); + $this->getTargetAdmin()->setActive( !$this->getTargetAdmin()->getActive() ); + $this->getTargetAdmin()->setModified( new \DateTime() ); - LogTable::log( 'ADMIN_TOGGLE_SUPER', - "Set {$this->_targetAdmin['username']} with super = " . ( $this->_targetAdmin['super'] ? '1' : '0' ), - $this->getAdmin(), null + $this->log( + $this->getTargetAdmin()->getActive() ? \Entities\Log::ACTION_ADMIN_ACTIVATE : \Entities\Log::ACTION_ADMIN_DEACTIVATE, + "{$this->getAdmin()->getFormattedName()} " . ( $this->getTargetAdmin()->getActive() ? 'activated' : 'deactivated' ) . " admin {$this->getTargetAdmin()->getFormattedName()}" ); + $this->getD2EM()->flush(); print 'ok'; } /** - * Purges an admin with all of the related entries all across the tables. Prints 'ok' - * on success or 'ko' otherwise to stdout. + * Toggles the super flag. Prints 'ok' on success or 'ko' otherwise to stdout. */ - public function ajaxPurgeAction() + public function ajaxToggleSuperAction() { - if( !$this->_targetAdmin ) - return print 'ko'; + if( !$this->getTargetAdmin() || $this->getAdmin()->getId() == $this->getTargetAdmin()->getId() ) + print 'ko'; - if( $this->getAdmin()->id == $this->_targetAdmin->id ) - { - // cannot purge yourself! - return print 'ko:' . _( 'You cannot purge yourself.' ); - } + $this->getTargetAdmin()->setSuper( !$this->getTargetAdmin()->getSuper() ); + $this->getTargetAdmin()->setModified( new \DateTime() ); - Doctrine_Query::create() - ->delete() - ->from( 'Log' ) - ->where( 'username = ?', $this->_targetAdmin['username'] ) - ->execute(); - - Doctrine_Query::create() - ->delete() - ->from( 'DomainAdmin' ) - ->where( 'username = ?', $this->_targetAdmin['username'] ) - ->execute(); - - LogTable::log( 'ADMIN_PURGE', - "Purged {$this->_targetAdmin['username']}", - $this->getAdmin(), null + $this->log( + $this->getTargetAdmin()->getSuper() ? \Entities\Log::ACTION_ADMIN_SUPER : \Entities\Log::ACTION_ADMIN_NORMAL, + "{$this->getAdmin()->getFormattedName()} set admin {$this->getTargetAdmin()->getFormattedName()} as " .( $this->getTargetAdmin()->getSuper() ? 'super' : 'normal' ) ); - $this->_targetAdmin->delete(); - + $this->getD2EM()->flush(); print 'ok'; } - /** - * Lists the domains of which the admin administers. + * Set the password for an admin, and optionally send an email to him/her with the new password. */ - public function domainsAction() + public function passwordAction() { - $this->view->domainAdmins = Doctrine_Query::create() - ->from( 'DomainAdmin' ) - ->where( 'username = ?', $this->_targetAdmin['username'] ) - ->execute(); - } + if( !$this->getTargetAdmin() ) + { + $this->addMessage( 'Invalid or non-existent admin.', OSS_Message::ERROR ); + $this->redirect( 'admin/list' ); + } + $this->view->targetAdmin = $this->getTargetAdmin(); + $self = false; + if( $this->getTargetAdmin()->getId() == $this->getAdmin()->getId() ) + $self = true; - /** - * Adds a new domain to the admin. - */ - public function addDomainAction() - { - $this->view->modal = $modal = $this->_getParam( 'modal', false ); - - if( !$this->_targetAdmin ) + if( !$this->authorise( true, null, false ) && !$self )// if not superadmin, and admin id is not self id { - $this->addMessage( _( 'Invalid or missing admin id.' ), ViMbAdmin_Message::ERROR ); - return false; - } + $this->getLogger()->alert( sprintf( 'Admin %s tried to set the password for %s but has no sufficient privileges.', + $this->getAdmin()->getUsername(), + $this->getTargetAdmin()->getUsername() ), + OSS_Message::ALERT + ); - $adminDomains = DomainAdminTable::getAllowedDomains( $this->_targetAdmin ); - $allDomains = DomainTable::getDomains( $this->_admin ); - $remainingDomains = array_diff( $allDomains, $adminDomains ); + $this->addMessage( _( 'You have insufficient privileges for this task.' ), OSS_Message::ERROR ); + $this->redirect( 'admin/list' ); + } - $form = new ViMbAdmin_Form_Admin_AddDomain( null, $remainingDomains, $this->_targetAdmin ); + if( $self ) + $this->view->form = $form = new ViMbAdmin_Form_Admin_ChangePassword(); + else + $this->view->form = $form = new ViMbAdmin_Form_Admin_Password(); - if( $this->getRequest()->isPost() && !$modal ) + if( $this->getRequest()->isPost() && $form->isValid( $_POST ) ) { - if( $form->isValid( $_POST ) ) + + if( $self ) { - $domainId = $form->getValue( 'domain' ); - $domain = Doctrine::getTable( 'Domain' )->find( $domainId ); - - if( !$domain ) - $this->addMessage( _( 'Invalid or missing domain id.' ), ViMbAdmin_Message::ERROR ); - elseif( array_key_exists( $domainId, $adminDomains ) ) - $this->addMessage( _( 'This domain is already assigned to the admin.' ), ViMbAdmin_Message::ERROR ); - else + if( !OSS_Auth_Password::verify( $form->getValue( 'current_password' ), $this->getTargetAdmin()->getPassword(), $this->getOptions()['resources']['auth']['oss'] ) ) { - $domain->addAdmin( $this->_targetAdmin ); - - unset( $remainingDomains[ $domainId ] ); - $form = new ViMbAdmin_Form_Admin_AddDomain( null, $remainingDomains, $this->_targetAdmin ); - $this->addMessage( _( 'You have successfully assigned a domain to the admin.' ), ViMbAdmin_Message::SUCCESS ); + $form->getElement( 'current_password')->addError( 'Invalid password.' ); + return; } + } - if( $this->_getParam( 'helper', true ) ) - { + $this->getTargetAdmin()->setPassword( + OSS_Auth_Password::hash( + $form->getValue( 'password'), + $this->_options['resources']['auth']['oss'] + ) + ); - $this->_redirect( 'admin/domains/aid/' . $form->getValue( 'adminId' ) ); + if( !$self ) + { + $this->log( + \Entities\Log::ACTION_ADMIN_PW_CHANGE, + "{$this->getAdmin()->getFormattedName()} changed password for admin {$this->getTargetAdmin()->getFormattedName()}" + ); + } + + $this->getD2EM()->flush(); + + if( $form->getValue( 'email' ) ) + { + $mailer = $this->getMailer(); + $mailer->setSubject( _( 'ViMbAdmin :: New Password' ) ); + $mailer->setFrom( $this->_options['server']['email']['address'], $this->_options['server']['email']['name'] ); + $mailer->addTo( $this->getTargetAdmin()->getUsername() ); + + $this->view->newPassword = $form->getValue( 'password' ); + $mailer->setBodyText( $this->view->render( 'admin/email/change_password.phtml' ) ); + + try + { + $mailer->send(); } - else + catch( Zend_Mail_Exception $e ) { - $this->_helper->viewRenderer->setNoRender( true ); - print 'ok'; - return; + $this->getLogger()->debug( $e->getTraceAsString() ); + $this->addMessage( _( 'Sending the change password email failed.' ), OSS_Message::INFO ); } } - } - - if( sizeof( $remainingDomains ) == 0 ) - $this->addMessage( _( 'There is no domain to assign to this admin.' ), ViMbAdmin_Message::INFO ); + if( !$self ) + $this->addMessage( "You have successfully changed the user's password.", OSS_Message::SUCCESS ); + else + $this->addMessage( "You have successfully changed your password.", OSS_Message::SUCCESS ); - if( !$this->_getParam( 'helper', true ) ) - $this->view->modal = true; + $this->redirect( 'admin/list' ); + } - $this->view->form = $form; } /** - * Removes an admin from a domain, so he/she won't be able to administer it any more. + * Purges an admin with all of the related entries all across the tables. Prints 'ok' + * on success or 'ko' otherwise to stdout. */ - public function ajaxRemoveDomainAction() + public function purgeAction() { - if( !$this->_targetAdmin ) - return print 'ko'; - - if( !( $domain = $this->loadDomain( $this->_getParam( 'domain' ) ) ) ) - return print 'ko'; - - Doctrine_Query::create() - ->delete() - ->from( 'DomainAdmin' ) - ->where( 'domain = ?', $domain['domain'] ) - ->andWhere( 'username = ?', $this->_targetAdmin['username'] ) - ->execute(); - - LogTable::log( 'ADMIN_DOMAIN_REMOVE', - "Removed {$this->_targetAdmin['username']} as an admin of {$domain['domain']}", - $this->getAdmin(), $domain + if( !$this->getTargetAdmin() ) + { + $this->addMessage( 'Invalid or non-existent admin.', OSS_Message::ERROR ); + $this->redirect( 'admin/list' ); + } + + if( $this->getAdmin()->getId() == $this->getTargetAdmin()->getId() ) + { + $this->addMessage( 'You cannot purge yourself.', OSS_Message::ERROR ); + $this->redirect( 'admin/list' ); + } + + foreach( $this->getTargetAdmin()->getPreferences() as $pref ) + $this->getD2EM()->remove( $pref ); + + foreach( $this->getTargetAdmin()->getLogs() as $log ) + $this->getD2EM()->remove( $log ); + + foreach( $this->getTargetAdmin()->getDomains() as $domain ) + $domain->removeAdmin( $this->getTargetAdmin() ); + + $this->getD2EM()->remove( $this->getTargetAdmin() ); + + $this->log( + \Entities\Log::ACTION_ADMIN_PURGE, + "{$this->getAdmin()->getFormattedName()} purged admin {$this->getTargetAdmin()->getFormattedName()}" ); + $this->getD2EM()->flush(); - print 'ok'; + $this->addMEssage( 'You have successfully purged the admin record.', OSS_Message::SUCCESS ); + $this->redirect( 'admin/list' ); } /** - * Set the password for an admin, and optionally send an email to him/her with the new password. + * Lists the domains of which the admin administers. */ - public function passwordAction() + public function domainsAction() { - $this->view->modal = $modal = $this->_getParam( 'modal', false ); - - if( !$this->_targetAdmin ) + if( !$this->getTargetAdmin() ) { - - if( $this->_getParam( 'helper', true ) ) - { - $this->addMessage( _( 'Invalid or non-existent admin.' ), ViMbAdmin_Message::ERROR ); - $this->_redirect( 'admin/list' ); - } - else - { - $this->_helper->viewRenderer->setNoRender( true ); - print 'error_none'; - } + $this->addMessage( 'Invalid or non-existent admin.', OSS_Message::ERROR ); + $this->redirect( 'admin/list' ); } - if( ( !$this->authorise( true, null, false ) ) && // if not superadmin, and - ( $this->_targetAdmin->id != $this->getAdmin()->id ) // admin id is not self id - ) - { - $this->getLogger()->alert( - _( 'Admin' ) . ' ' . - $this->_admin->username . ' ' . - _( 'tried to set the password for ' ) . ' ' . - $this->_targetAdmin->username . ' , ' . - _( 'but has no sufficient privileges.' ), - ViMbAdmin_Message::ALERT - ); + $this->view->targetAdmin = $this->getTargetAdmin(); + } - if( $this->_getParam( 'helper', true ) ) - { - $this->addMessage( _( 'You have insufficient privileges for this task.' ), ViMbAdmin_Message::ERROR ); - $this->_redirect( 'admin/list' ); - } - else - { - $this->_helper->viewRenderer->setNoRender( true ); - print 'error_inpr'; - } + /** + * Adds a new domain to the admin. + */ + public function assignDomainAction() + { + if( !$this->getTargetAdmin() ) + { + $this->addMessage( _( 'Invalid or missing admin id.' ), OSS_Message::ERROR ); + $this->redirect( 'admin/list' ); } + $this->view->targetAdmin = $this->getTargetAdmin(); + + $remainingDomains = $this->getD2EM()->getRepository( '\\Entities\\Domain' )->getNotAssignedForAdmin( $this->getTargetAdmin() ); + $this->view->form = $form = new ViMbAdmin_Form_Admin_AssignDomain(); + $form->getElement( "domain" )->setMultiOptions( $remainingDomains ); - - if( $this->_targetAdmin->id == $this->getAdmin()->id ) - $form = new ViMbAdmin_Form_Admin_ChangePassword(); - else - $form = new ViMbAdmin_Form_Admin_Password(); - - if( $this->getRequest()->isPost() && !$modal ) + if( $this->getRequest()->isPost() && $form->isValid( $_POST ) ) { - if( $form->isValid( $_POST ) ) - { + $this->_domain = $this->loadDomain( $form->getValue( 'domain' ) ); - $add = true; - if( $this->_targetAdmin->id == $this->getAdmin()->id ) - { - if( $this->getAdmin()->checkPassword( $form->getValue( 'current_password'), $this->_options['securitysalt'] ) == false ) - { - $form->getElement( 'current_password')->addError( 'Invalid password.' ); - $add = false; - } - } - - if( $add ) - { - $this->_targetAdmin->setPassword( $form->getValue( 'password' ), $this->_options['securitysalt'], true ); - - if( $form->getValue( 'email' ) ) - { - $mailer = new Zend_Mail( 'UTF-8' ); - $mailer->setSubject( _( 'ViMbAdmin :: New Password' ) ); - $mailer->setFrom( $this->_options['server']['email']['address'], $this->_options['server']['email']['name'] ); - $mailer->addTo( $this->_targetAdmin->username ); - - $this->view->newPassword = $form->getValue( 'password' ); - $mailer->setBodyText( $this->view->render( 'admin/email/change_password.phtml' ) ); - - try - { - $mailer->send(); - } - catch( Zend_Mail_Exception $vException ) - { - $this->getLogger()->debug( $vException->getTraceAsString() ); - - if( $this->_getParam( 'helper', true ) ) - { - $this->addMessage( _( 'Sending the change password email failed.' ), ViMbAdmin_Message::INFO ); - $this->_redirect( 'admin/list' ); - } - else - { - $this->_helper->viewRenderer->setNoRender( true ); - print 'error_email'; - } - } - } - - LogTable::log( 'ADMIN_PW_CHANGE', - "Changed password of {$this->_targetAdmin['username']}", - $this->getAdmin(), null - ); - - - if( $this->_getParam( 'helper', true ) ) - { - if( $this->_targetAdmin->id != $this->getAdmin()->id ) - $this->addMessage( _( "You have successfully changed the user's password." ), ViMbAdmin_Message::SUCCESS ); - else - $this->addMessage( _( "You have successfully changed your password." ), ViMbAdmin_Message::SUCCESS ); - - $this->_redirect( 'admin/list' ); - } - else - { - $this->_helper->viewRenderer->setNoRender( true ); - if( $this->_targetAdmin->id != $this->getAdmin()->id ) - echo "ok_user"; - else - echo "ok_self"; - } - - - } + if( $this->getTargetAdmin()->getDomains()->contains( $this->getDomain() ) ) + $this->addMessage( _( 'This domain is already assigned to the admin.' ), OSS_Message::ERROR ); + else + { + $this->getTargetAdmin()->addDomain( $this->getDomain() ); + $this->log( + \Entities\Log::ACTION_ADMIN_TO_DOMAIN_ADD, + "{$this->getAdmin()->getFormattedName()} added admin {$this->getTargetAdmin()->getFormattedName()} to domain {$this->getDomain()->getDomain()}" + ); + $this->getD2EM()->flush(); + $this->addMessage( 'You have successfully assigned a domain to the admin.', OSS_Message::SUCCESS ); } - } - if( !$this->_getParam( 'helper', true ) ) - $this->view->modal = true; + $this->redirect( 'admin/domains/aid/' . $this->getTargetAdmin()->getId() ); + } - $this->view->form = $form; + if( sizeof( $remainingDomains ) == 0 ) + $this->addMessage( 'There are no domains to assign to this administrator.', OSS_Message::INFO ); } /** - * Adds a new admin or superadmin to the system. Optionally it can send a welcome email. + * Removes an admin from a domain, so he/she won't be able to administer it any more. */ - public function addAction() + public function removeDomainAction() { - $form = new ViMbAdmin_Form_Admin_Edit(); - $form->removeElement( 'salt' ); - - $this->view->modal = $modal = $this->_getParam( 'modal', false ); - - if( $this->getRequest()->isPost() && !$modal ) + if( !$this->getTargetAdmin() ) { - if( $form->isValid( $_POST ) ) - { - $adminModel = new Admin(); - $adminModel->fromArray( $form->getValues() ); - $adminModel->setPassword( $form->getValue( 'password' ), $this->_options['securitysalt'], false ); - $adminModel->save(); - - LogTable::log( 'ADMIN_ADD', - "Added new " . ( $adminModel['super'] ? 'super ' : '' ) . "admin {$adminModel['username']}", - $this->getAdmin() - ); - - if( $form->getValue( 'welcome_email' ) ) - { - try - { - $mailer = new Zend_Mail( 'UTF-8' ); - $mailer->setSubject( _( 'ViMbAdmin :: Your New Administrator Account' ) ); - $mailer->addTo( $adminModel->username ); - $mailer->setFrom( - $this->_options['server']['email']['address'], - $this->_options['server']['email']['name'] - ); - - $this->view->username = $adminModel->username; - $this->view->password = $form->getValue( 'password' ); - - $mailer->setBodyText( $this->view->render( 'admin/email/new_admin.phtml' ) ); - - $mailer->send(); - } - catch( Exception $e ) - { - $this->getLogger()->debug( $e->getTraceAsString() ); - $this->addMessage( _( 'You have successfully added a new administrator to the system.' ), ViMbAdmin_Message::SUCCESS ); - $this->addMessage( _( 'Could not send welcome email' ), ViMbAdmin_Message::ALERT ); - if( $this->_getParam( 'helper', true ) ) - { - $this->_redirect( 'admin/list' ); - } - else - { - $this->_helper->viewRenderer->setNoRender( true ); - echo 'ok'; - return; - } - } - } - - $this->addMessage( _( 'You have successfully added a new administrator to the system.' ), ViMbAdmin_Message::SUCCESS ); + $this->addMessage( _( 'Invalid or missing admin id.' ), OSS_Message::ERROR ); + $this->redirect( 'admin/list' ); + } - if( $this->_getParam( 'helper', true ) ) - { - $this->_redirect( 'admin/list' ); - } - else - { - $this->_helper->viewRenderer->setNoRender( true ); - echo "ok"; - } - } + if( !$this->getDomain() ) + { + $this->addMessage( _( 'Invalid or missing domain id.' ), OSS_Message::ERROR ); + $this->redirect( 'admin/domains/aid/' . $this->getTargetAdmin()->getId() ); } - if( !$this->_getParam( 'helper', true ) ) - $this->view->modal = true; + $this->getTargetAdmin()->removeDomain( $this->getDomain() ); + $this->log( + \Entities\Log::ACTION_ADMIN_TO_DOMAIN_REMOVE, + "{$this->getAdmin()->getFormattedName()} removed admin {$this->getTargetAdmin()->getFormattedName()} from domain {$this->getDomain()->getDomain()}" + ); - $this->view->form = $form; + $this->getD2EM()->flush(); + $this->addMessage( 'You have successfully removed the admin from domain '. $this->getDomain()->getDomain(), OSS_Message::SUCCESS ); + $this->redirect( 'admin/domains/aid/' . $this->getTargetAdmin()->getId() ); } - } diff --git a/application/controllers/AliasController.php b/application/controllers/AliasController.php index bd42db5..4735409 100644 --- a/application/controllers/AliasController.php +++ b/application/controllers/AliasController.php @@ -7,7 +7,7 @@ * project which provides an easily manageable web based virtual * mailbox administration system. * - * Copyright (c) 2011 Open Source Solutions Limited + * Copyright (c) 2011 - 2014 Open Source Solutions Limited * * ViMbAdmin is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,7 +26,7 @@ * 147 Stepaside Park, Stepaside, Dublin 18, Ireland. * Barry O'Donovan * - * @copyright Copyright (c) 2011 Open Source Solutions Limited + * @copyright Copyright (c) 2011 - 2014 Open Source Solutions Limited * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License, version 3 (GPLv3) * @author Open Source Solutions Limited * @author Barry O'Donovan @@ -39,9 +39,15 @@ * @package ViMbAdmin * @subpackage Controllers */ -class AliasController extends ViMbAdmin_Controller_Action +class AliasController extends ViMbAdmin_Controller_PluginAction { + /** + * Local store for the form + * @var ViMbAdmin_Form_Alias_AddEdit + */ + private $aliasForm = null; + /** * Most actions in this object will require a domain object to edit / act on. * @@ -55,16 +61,17 @@ public function preDispatch() { $this->authorise(); - // if an ajax request, remove the view help - if( substr( $this->getRequest()->getParam( 'action' ), 0, 4 ) == 'ajax' ) - $this->_helper->viewRenderer->setNoRender( true ); - - if( $this->_getParam( 'unset', false ) ) - unset( $this->_session->domain ); - else + if( $this->getRequest()->getActionName() == "list" || $this->getRequest()->getActionName() == "index" ) { - if( isset( $this->_session->domain) && $this->_session->domain ) - $this->_domain = $this->_session->domain; + if( $this->getParam( 'unset', false ) ) + unset( $this->getSessionNamespace()->domain ); + else + { + if( isset( $this->getSessionNamespace()->domain ) && $this->getSessionNamespace()->domain ) + $this->_domain = $this->getSessionNamespace()->domain; + else if( $this->getDomain() ) + $this->getSessionNamespace()->domain = $this->getDomain(); + } } } @@ -80,308 +87,383 @@ public function indexAction() /** * Lists the aliases available to the admin and/or domain. Superadmin can see all. + * + * $this->view->alias_actions allow to append aliases list action buttons. %id% will be replaced by + * alias id form the list. below is example array which creates edit alias button, and another button + * with drop down options for edit alias. Only one drop down button can be defined per button group, + * and it always be appended at the end. + * $actions = [ + * [ //Simple link button + * 'tagName' => 'a', //Mandatory parameter for element type. + * 'href' => OSS_Utils::genUrl( "alias", "edit" ) . "/alid/%id%", //Url for action + * 'title' => "Edit", + * 'class' => "btn btn-mini have-tooltip", //Class for css options. + * 'id' => "test-%id%", //If setting id id must have %id% which will be replaced by original mailbox id to avoid same ids. + * 'child' => [ //Mandatory element if is not array it will be shown as text. + * 'tagName' => "i", //Mandatory option if child is array to define element type + * 'class' => "icon-pencil" //Icon class + * ], + * ], + * [ //Drop down button + * 'tagName' => 'span', //Mandatory parameter for element type + * 'title' => "Settings", + * 'class' => "btn btn-mini have-tooltip dropdown-toggle", //Class dropdown-toggle is mandatory for drop down button + * 'data-toggle' => "dropdown", //data-toggle attribute is mandatory for drop down button + * 'id' => "cog-%id%", + * 'style' => "max-height: 15px;", + * 'child' => [ + * 'tagName' => "i", + * 'class' => "icon-cog" + * ], + * 'menu' => [ //menu array is mandatory then defining drop down button + * [ + * 'id' => "menu-edit-%id%", //Not mandatory attribute but if is set %id% should be use to avoid same ids. + * 'text' => " Edit", //Mandatory for display action text + * 'url' => OSS_Utils::genUrl( "alias", "edit" ) . "/alid/%id%" //Mandatory to redirect the action. + * ] + * ] + * ] + * ]; + * */ public function listAction() - { - $includeMailboxAliases = $this->_getParam( 'ima', 0 ); - $this->view->includeMailboxAliases = $includeMailboxAliases; - $this->view->domainModel = $this->_domain; - $this->view->domain = 0; - - $q = Doctrine_Query::create() - ->select( '*' ) - ->from( 'Alias a' ); - - if( !$includeMailboxAliases ) - $q->where( 'a.address != a.goto' ); - - if( $this->_domain ) - { - // already authorised in preDispatch() - $q->andWhere( 'a.domain = ?', $this->_domain['domain'] ); - $this->view->domain = $this->_session->domain = $this->_domain; - } - else if( !$this->getAdmin()->isSuper() ) - { - // if we're not a super admin and we don't have a specific domain, only load allowed - $q->leftJoin( 'a.Domain d' ) - ->leftJoin( 'd.DomainAdmin da' ) - ->andWhere( 'da.username = ?', $this->getAdmin()->username ); - } + { + //Include mailbox aliases + $this->view->ima = $ima = $this->_getParam( 'ima', 0 ); + $this->view->domain = $this->getDomain(); + if( isset( $this->_options['defaults']['server_side']['pagination']['enable'] ) && $this->_options['defaults']['server_side']['pagination']['enable'] ) + $this->view->aliases = []; + else + $this->view->aliases = $this->getD2EM()->getRepository( "\\Entities\\Alias" )->loadForAliasList( $this->getAdmin(), $this->getDomain(), $ima ); - $this->view->aliases = $q->fetchArray(); - $q->free(); } - /** - * Toggles the active property of an alias. Prints 'ok' on success or 'ko' otherwise to stdout. + * This action is used then server side pagination is turned on. It will look + * for alias data by filter passed and return json_array if aliases was found + * or ko if it was not successful. Return array max size is also defined in application.ini. */ - public function ajaxToggleActiveAction() + public function listSearchAction() { - if( !$this->_alias ) - return print 'ko'; - - $this->_alias['active'] = !$this->_alias['active']; - $this->_alias->save(); - - LogTable::log( 'ALIAS_TOGGLE_ACTIVE', - "Set {$this->_alias['address']} " . ( $this->_alias['active'] ? '' : 'de' ) . "active", - $this->getAdmin(), $this->_alias['domain'] - ); - - print 'ok'; + Zend_Controller_Action_HelperBroker::removeHelper( 'viewRenderer' ); + if( !isset( $this->_options['defaults']['server_side']['pagination']['enable'] ) || !$this->_options['defaults']['server_side']['pagination']['enable'] ) + echo "ko"; + else + { + $strl_len = isset( $this->_options['defaults']['server_side']['pagination']['min_search_str'] ) ? $this->_options['defaults']['server_side']['pagination']['min_search_str'] : 3; + $search = $this->_getParam( "search", false ); + $this->view->ima = $ima = $this->_getParam( 'ima', 0 ); + if( $search && strlen( $search ) >= $strl_len ) + { + $aliases = $this->getD2EM()->getRepository( "\\Entities\\Alias" )->filterForAliasList( $search, $this->getAdmin(), $this->getDomain(), $ima ); + $max_cnt = isset( $this->_options['defaults']['server_side']['pagination']['max_result_cnt'] ) ? $this->_options['defaults']['server_side']['pagination']['max_result_cnt'] : false; + if( $aliases && ( !$max_cnt || $max_cnt >= count( $aliases ) ) ) + echo json_encode( $aliases ); + else + echo "ko"; + } + else + echo "ko"; + } } - /** - * Deletes an alias. Prints 'ok' on success or 'ko' otherwise to stdout. + * Instantiate / get the alias add-edit form + * @return ViMbAdmin_Form_Mailbox_AddEdit */ - public function ajaxDeleteAction() + public function getAliasForm() { - if( !$this->_alias ) - return print 'ko'; + if( $this->aliasForm == null ) + { + $form = new ViMbAdmin_Form_Alias_AddEdit(); - $this->_alias->delete(); + // populate the domain dropdown with the possible domains for this user + $form->getElement( "domain" )->setMultiOptions( + [ "" => "" ] + $this->getD2EM()->getRepository( "\\Entities\\Domain" )->loadForAdminAsArray( $this->getAdmin(), true ) + ); - LogTable::log( 'ALIAS_DELETE', - "Deleted {$this->_alias['address']}", - $this->getAdmin(), $this->_alias['domain'] - ); + // if we have a default / preferred domain, set it as selected in the form + if( $this->getDomain() ) + $form->getElement( 'domain' )->setValue( $this->getDomain()->getId() ); - print 'ok'; - } + if( $this->isEdit() ) + { + $form->assignEntityToForm( $this->getAlias(), $this, $this->isEdit() ); + $form->removeElement( 'local_part' ); + $form->removeElement( 'domain' ); + } + $this->view->form = $this->aliasForm = $form; + + // call plugins + $this->notify( 'alias', 'add', 'formPostProcess', $this ); + } + + return $this->aliasForm; + } /** - * Edit an alias. + * Add an alias. */ - public function editAction() + public function addAction() { - $this->view->modal = $modal = $this->_getParam( 'modal', false ); - - $this->view->operation = "Edit"; - if( !$this->_alias ) // no alias id passed so adding + if( !$this->getAlias() ) { - $this->view->operation = "Add"; - $this->_alias = new Alias(); + $this->isEdit = $this->view->isEdit = false; + $form = $this->getAliasForm(); - if( $this->_domain ) - $this->view->domainModel = $this->_domain; + $this->_alias = new \Entities\Alias(); + $this->getD2EM()->persist( $this->getAlias() ); + $this->getAlias()->setCreated( new \DateTime() ); } else { - // if editing, then use that domain - $this->view->domainModel = $this->_alias['Domain']; + $this->isEdit = $this->view->isEdit = true; + $this->view->alias = $this->getAlias(); + + $form = $this->getAliasForm(); + $form->assignEntityToForm( $this->getAlias(), $this, $this->isEdit() ); } + + $this->view->domainList = $domainList = $this->getD2EM()->getRepository( "\\Entities\\Domain" )->loadForAdminAsArray( $this->getAdmin(), true ); - $this->view->aliasModel = $this->_alias; + if( $this->getDomain() ) + { + $this->view->domain = $this->getDomain(); + if( $form->getElement( 'domain' ) ) + $form->getElement( 'domain' )->setValue( $this->getDomain()->getId() ); + } - $domainList = DomainTable::getDomains( $this->getAdmin() ); - $this->view->domainList = $domainList; + if( $this->getMailbox() ) + $this->view->defaultGoto = "{$this->getMailbox()->getLocalPart()}@{$this->getDomain()->getDomain()}"; + + $this->view->alias = $this->getAlias(); + $this->view->emails = $this->_autocompleteArray(); - $editForm = new ViMbAdmin_Form_Alias_Edit( null, $domainList ); + $this->notify( 'alias', 'add', 'addPrepare', $this ); - if( $this->getRequest()->isPost() && !$modal ) + if( $this->getRequest()->isPost() ) { - if( $this->_alias['id'] ) // editing - { - $editForm->removeElement( 'local_part' ); - $editForm->removeElement( 'domain' ); - } + $this->notify( 'alias', 'add', 'addPrevalidate', $this ); - if( $editForm->isValid( $_POST ) ) + if( $form->isValid( $_POST ) ) { - $postValues = $editForm->getValues(); - - if( isset( $postValues['domain'] ) ) - { - $this->_domain = $this->loadDomain( $postValues['domain'] ); - } + $this->notify( 'alias', 'add', 'addPostvalidate', $this ); - if( !$this->_domain || !$this->authorise( false, $this->_domain, false ) ) - { - $this->addMessage( _( "Invalid, unauthorised or non-existent domain." ), ViMbAdmin_Message::ERROR ); - $this->_redirect( $this->getRequest()->getPathInfo() ); - } + $form->assignFormToEntity( $this->getAlias(), $this, $this->isEdit() ); + + if( !$this->_setGotos( $form ) ) + return; - if( !$this->_alias['id'] ) // adding + if( !$this->isEdit() ) // adding { - $alias = Doctrine::getTable( 'Alias' )->findOneByAddress( "{$postValues['local_part']}@{$this->_domain['domain']}" ); - - if( $alias ) + // do we have available aliases? + if( !$this->getAdmin()->isSuper() && $this->getDomain()->getMaxaliases() != 0 + && $this->getDomain->getAliasCount() >= $this->getDomain()->getMaxAliases() + ) { - if( $this->_options['mailboxAliases'] ) - { - if( $alias->address == $alias->goto ) - { - $this->addMessage( - _( 'A mailbox alias exists for' ) . " {$postValues['local_part']}@{$this->_domain['domain']}", - ViMbAdmin_Message::ERROR - ); - } - else - { - $this->addMessage( - _( 'Alias already exists for' ) . " {$postValues['local_part']}@{$this->_domain['domain']}", - ViMbAdmin_Message::ERROR - ); - } - } - else - { - $this->addMessage( - _( 'Alias already exists for' ) . " {$postValues['local_part']}@{$this->_domain['domain']}", - ViMbAdmin_Message::ERROR - ); - } - - $this->_redirect( $this->getRequest()->getPathInfo() ); + $this->addMessage( _( 'You have used all of your allocated aliases.' ), OSS_Message::ERROR ); + $this->redirect( "alias/list" ); } - } - if( !$postValues['goto'] ) - { - $editForm->getElement( 'goto' )->addError( _( 'You must have at least one goto address.' ) ); + if( !$this->getDomain() || $this->getDomain()->getId() != $form->getValue( 'domain' ) ) + $this->_domain = $this->loadDomain( $form->getValue( 'domain' ) ); + + $this->getAlias()->setDomain( $this->getDomain() ); + $this->getAlias()->setActive( 1 ); + + if( !$this->_setAddress( $form ) ) + return; } else - { - // is the alias valid (allowing for wildcard domains (i.e. with no local part) - if( !$this->_alias['id'] && $postValues['local_part'] != '' && !Zend_Validate::is( "{$postValues['local_part']}@{$this->_domain['domain']}", 'EmailAddress', array( 1, null ) ) ) - $editForm->getElement( 'local_part' )->addError( _( 'Invalid email address.' ) ); + $this->getAlias()->setModified( new \DateTime() ); - foreach( $postValues['goto'] as $key => $oneGoto ) - { - $oneGoto = trim( $oneGoto ); - - if( $oneGoto == '') - unset( $postValues['goto'][ $key ] ); - else - { - if( !Zend_Validate::is( $oneGoto, 'EmailAddress', array( 1, null ) ) ) - $editForm->getElement( 'goto' )->addError( 'Invalid email address(es).' ); - } - } + if( !$this->isEdit() && $this->getAlias()->getAddress() != $this->getAlias()->getGoto() ) + $this->getDomain()->setAliasCount( $this->getDomain()->getAliasCount() + 1 ); - if( !$postValues['goto'] ) - $editForm->getElement( 'goto' )->addError( 'You must have at least one goto address.' ); + $this->log( + $this->isEdit() ? \Entities\Log::ACTION_ALIAS_EDIT : \Entities\Log::ACTION_ALIAS_ADD, + "{$this->getAdmin()->getFormattedName()} " . ( $this->isEdit() ? ' edited' : ' added' ) . " alias {$this->getAlias()->getAddress()}" + ); - if( !$editForm->getElement( 'goto' )->hasErrors() - && ( $editForm->getElement( 'local_part' ) === null || !$editForm->getElement( 'local_part' )->hasErrors() ) ) - { - $this->_alias->fromArray( $postValues ); - - if( !$this->_alias['id'] ) // NOT editing - { - // do we have available mailboxes? - if( !$this->getAdmin()->isSuper() && - $this->_domain['aliases'] != 0 && - ( $this->_domain->countAliases() >= $this->_domain['aliases'] ) - ) - { - $this->_helper->viewRenderer->setNoRender( true ); - $this->addMessage( _( 'You have used all of your allocated aliases.' ), ViMbAdmin_Message::ERROR ); - return print $this->view->render( 'close_colorbox_reload_parent.phtml'); - } - - $this->_alias['domain'] = $this->_domain['domain']; - $this->_alias['address'] = "{$postValues['local_part']}@{$this->_domain['domain']}"; - - LogTable::log( 'ALIAS_ADD', - "Added {$this->_alias['address']} -> {$this->_alias['goto']}", - $this->getAdmin(), $this->_alias['domain'] - ); - } - else - { - LogTable::log( 'ALIAS_EDIT', - "Edited {$this->_alias['address']} -> {$this->_alias['goto']}", - $this->getAdmin(), $this->_alias['domain'] - ); - } - - $this->_alias['goto'] = implode( ',', array_unique( $postValues['goto'] ) ); - - $this->_alias->save(); - - $this->addMessage( _( "You have successfully added/edited the alias." ), ViMbAdmin_Message::SUCCESS ); - - if( $this->_getParam( 'helper', true ) ) - { - if( $this->_domain ) - $this->_redirect( 'alias/list/did/' . $this->_domain['id'] ); - else - $this->_redirect( 'alias/list' ); - } - else - { - $this->_helper->viewRenderer->setNoRender( true ); - print 'ok'; - } - } + $this->notify( 'alias', 'add', 'addPreflush', $this ); + $this->getD2EM()->flush(); + $this->notify( 'alias', 'add', 'addPostflush', $this ); - } + if( $this->getParam( "did", false ) ) + $this->getSessionNamespace()->domain = $this->getDomain(); + + $this->addMessage( _( "You have successfully added/edited the alias." ), OSS_Message::SUCCESS ); + $this->redirect( 'alias/list' ); } } - else - { - if( $this->_domain ) - { - $this->view->domain = $this->_domain; - $editForm->getElement( 'domain' )->setValue( $this->_domain['id'] ); - } + } - if( $this->_mailbox ) - $this->view->defaultGoto = "{$this->_mailbox->local_part}@{$this->_mailbox->Domain->domain}"; + /** + * Edit an alias. + */ + public function editAction() + { + $this->forward( "add" ); + } - if( $this->_alias['id'] ) // editing - { - $editForm->setDefaults( $this->_alias->toArray() ); - $editForm - ->getElement( 'local_part' ) - ->setValue( str_replace("@{$this->_alias['domain']}", '', $this->_alias['address'] ) ) - ->setAttrib( 'disabled', 'disabled' ); + /** + * Toggles the active property of an alias. Prints 'ok' on success or 'ko' otherwise to stdout. + */ + public function ajaxToggleActiveAction() + { + if( !$this->getAlias() ) + print 'ko'; - $editForm - ->getElement( 'domain' ) - ->setValue( $this->_alias->Domain['id'] ) - ->setAttrib( 'disabled', 'disabled' ); - } + $this->getAlias()->setActive( !$this->getAlias()->getActive() ); + $this->getAlias()->setModified( new \DateTime() ); + + $this->log( + $this->getAlias()->getActive() ? \Entities\Log::ACTION_ALIAS_ACTIVATE : \Entities\Log::ACTION_ALIAS_DEACTIVATE, + "{$this->getAdmin()->getFormattedName()} " . ( $this->getAlias()->getActive() ? 'activated' : 'deactivated' ) . " alias {$this->getAlias()->getAddress()}" + ); + $this->notify( 'alias', 'toggleActive', 'preflush', $this, [ 'active' => $this->getAlias()->getActive() ] ); + $this->getD2EM()->flush(); + $this->notify( 'alias', 'toggleActive', 'postflush', $this, [ 'active' => $this->getAlias()->getActive() ] ); + print 'ok'; + } + + + /** + * Deletes an alias. Prints 'ok' on success or 'ko' otherwise to stdout. + */ + public function deleteAction() + { + if( !$this->getAlias() ) + print 'ko'; + + foreach( $this->getAlias()->getPreferences() as $pref ) + $this->getD2EM()->remove( $pref ); + + $this->notify( 'alias', 'delete', 'preRemove', $this ); + $this->getD2EM()->remove( $this->getAlias() ); + if( $this->getAlias()->getAddress() != $this->getAlias()->getGoto() ) + $this->getDomain()->setAliasCount( $this->getDomain()->getAliasCount() - 1 ); + + $this->log( + \Entities\Log::ACTION_ALIAS_DELETE, + "{$this->getAdmin()->getFormattedName()} removed alias {$this->getAlias()->getAddress()}" + ); + + $this->notify( 'alias', 'delete', 'preFlush', $this ); + $this->getD2EM()->flush(); + $this->notify( 'alias', 'delete', 'postFlush', $this ); + + $this->addMessage( 'Alias has bean removed successfully', OSS_Message::SUCCESS ); + $this->redirect( 'alias/list' ); + } + + /** + * Sets goto to alias + * + * Parse goto value form field. If its empty return false and set error message. + * Function goes trough all goto address and if one of got addresses is not valid + * set error to form and return false. If everything is ok it return true. Gotos + * Is set to alias even the false is return to return goto addresses to end user. + * + * + * @param ViMbAdmin_Form_Alias_AddEdit $form Alias form + * @return bool + */ + private function _setGotos( $form ) + { + if( !$form->getValue( 'goto' ) ) + { + $form->getElement( 'goto' )->addError( _( 'You must have at least one goto address.' ) ); + $this->getAlias()->setGoto( "" ); + return false; } + else + { + $gotos = $form->getValue( 'goto' ); + $this->getAlias()->setGoto( implode( ',', array_unique( $gotos ) ) ); + foreach( $gotos as $key => $goto ) + { + $goto = trim( $goto ); - if( !$this->_getParam( 'helper', true ) ) - $this->view->modal = true; + if( $goto == '') + unset( $gotos[ $key ] ); + else + { + if( !Zend_Validate::is( $goto, 'EmailAddress', array( 1, null ) ) ) + { + $form->getElement( 'goto' )->addError( 'Invalid email address(es).' ); + return false; + } + } + } - $this->view->emails = $this->_autocompleteArray(); + if( count( $gotos ) == 0 ) + { + $form->getElement( 'goto' )->addError( 'You must have at least one goto address.' ); + return false; + } + $this->getAlias()->setGoto( implode( ',', array_unique( $gotos ) ) ); - $this->view->editForm = $editForm; + } + return true; } /** - * The Ajax function providing JSON data for the jQuery UI Autocomplete on adding/editing aliases. + * Sets address to alias + * + * Checks if local part and domain makes a valid address, or it is only domain address. + * If yes then it checks if its unique address, if yes address set to alias and return true. + * All other cases message is set to form and return false. + * + * @param ViMbAdmin_Form_Alias_AddEdit $form Alias form + * @return bool */ - private function _autocompleteArray() + private function _setAddress( $form ) { - $query = Doctrine_Query::create() - ->select( 'a.address' ) - ->from( 'Alias a' ); + $address = sprintf( "%s@%s", $form->getValue( 'local_part'), $this->getDomain()->getDomain() ); - if( !$this->getAdmin()->isSuper() ) + // is the alias valid (allowing for wildcard domains (i.e. with no local part) + if( $form->getValue( "local_part" ) && !Zend_Validate::is( "{$address}", 'EmailAddress', array( 1, null ) ) ) { - $query->leftJoin( 'a.Domain d' ) - ->leftJoin( 'd.DomainAdmin da' ) - ->andWhere( 'da.username = ?', $this->getAdmin()->username ) - ->andWhere( 'd.domain = da.domain' ); + $form->getElement( 'local_part' )->addError( _( 'Invalid email address.' ) ); + return false; } + + $alias = $this->getD2EM()->getRepository( "\\Entities\\Alias" )->findOneBy( ["address" => $address ] ); + if( $alias ) + { + if( $this->_options['mailboxAliases'] ) + { + if( $alias->getAddress() == $alias->getGoto() ) + $msg = _( 'A mailbox alias exists for' ) . " {$address}"; + else + $msg = _( 'Alias already exists for' ) . " {$address}"; + } + else + $msg = _( 'Alias already exists for' ) . " {$address}"; + + $this->addMessage( $msg, OSS_Message::ERROR ); - $temp = $query->fetchArray(); + //check if it works correctly. + return false; + } + $this->getAlias()->setAddress( $address ); + return true; + } - $addresses = array(); + /** + * The Ajax function providing JSON data for the jQuery UI Autocomplete on adding/editing aliases. + */ + private function _autocompleteArray() + { + $aliases = $this->getD2EM()->getRepository( "\\Entities\\Alias" )->loadForAliasList( $this->getAdmin(), null, true ); + $addresses = []; - foreach( $temp as $oneAddress ) - $addresses[] = $oneAddress['address']; + foreach( $aliases as $alias ) + $addresses[] = $alias['address']; return json_encode( $addresses ); } diff --git a/application/controllers/ArchiveController.php b/application/controllers/ArchiveController.php new file mode 100644 index 0000000..fc4806b --- /dev/null +++ b/application/controllers/ArchiveController.php @@ -0,0 +1,984 @@ +. + * + * Open Source Solutions Limited T/A Open Solutions + * 147 Stepaside Park, Stepaside, Dublin 18, Ireland. + * Barry O'Donovan + * + * @copyright Copyright (c) 2011 - 2014 Open Source Solutions Limited + * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License, version 3 (GPLv3) + * @author Open Source Solutions Limited + * @author Barry O'Donovan + * @author Roland Huszti + */ + +/** + * The mailbox controller. + * + * @package ViMbAdmin + * @subpackage Controllers + */ +class ArchiveController extends ViMbAdmin_Controller_PluginAction +{ + /** + * Most actions in this object will require a domain object to edit / act on. + * + * This method will look for an 'id' parameter and, if set, will + * try to load the domain model and authorise the user to edit / act on + * it. + * + * @see Zend_Controller_Action::preDispatch() + */ + public function preDispatch() + { + if( $this->getRequest()->getActionName() != 'cli-restore-pendings' && + $this->getRequest()->getActionName() != 'cli-delete-pendings' && + $this->getRequest()->getActionName() != 'cli-archive-pendings' && + !$this->getDomain() + ) + $this->authorise(); + + if( $this->getRequest()->getActionName() == "list" || $this->getRequest()->getActionName() == "index" ) + { + if( $this->getParam( 'unset', false ) ) + unset( $this->getSessionNamespace()->domain ); + else + { + if( isset( $this->getSessionNamespace()->domain ) && $this->getSessionNamespace()->domain ) + $this->_domain = $this->getSessionNamespace()->domain; + else if( $this->getDomain() ) + $this->getSessionNamespace()->domain = $this->getDomain(); + } + } + } + + + /** + * Jumps to list action. + */ + public function indexAction() + { + $this->forward( 'list' ); + } + + /** + * Lists all archives available to the admin (superadmin sees all) or to the specified domain. + */ + public function listAction() + { + $this->view->archives = $this->getD2EM()->getRepository( "\\Entities\\Archive" )->loadForArchiveList( $this->getAdmin(), $this->getDomain() ); + $this->view->statuses = \Entities\Archive::$ARCHIVE_STATUS; + $this->view->allowCancel = [ \Entities\Archive::STATUS_PENDING_ARCHIVE, \Entities\Archive::STATUS_PENDING_RESTORE, \Entities\Archive::STATUS_PENDING_DELETE ]; + $this->view->allowDelete = [ \Entities\Archive::STATUS_ARCHIVED ]; + $this->view->allowRestore = [ \Entities\Archive::STATUS_ARCHIVED ]; + } + + /** + * Creates archive entry and purges a mailbox from the system, with all the related entries in other tables. + * After add status archive status is archive pending + */ + public function addAction() + { + if( !$this->getMailbox() ) + return $this->forward( 'list' ); + + $this->view->mailbox = $this->getMailbox(); + $this->view->aliases = $this->getD2EM()->getRepository( "\\Entities\\Alias" )->loadForMailbox( $this->getMailbox(), $this->getAdmin() ); + $this->view->inAliases = $this->getD2EM()->getRepository( "\\Entities\\Alias" )->loadWithMailbox( $this->getMailbox(), $this->getAdmin() ); + + if( isset( $_POST['archive'] ) && ( $_POST['archive'] == 'archive' ) ) + { + $this->notify( 'archive', 'add', 'preSerialize', $this ); + + $data = $this->_serialzeMailbox( $this->getMailbox() ); + + $archive = new \Entities\Archive(); + $archive->setArchivedBy( $this->getAdmin() ); + $archive->setArchivedAt( new \DateTime() ); + $archive->setDomain( $this->getMailbox()->getDomain() ); + $archive->setUsername( $this->getMailbox()->getUsername() ); + $archive->setStatus( \Entities\Archive::STATUS_PENDING_ARCHIVE ); + $archive->setStatusChangedAt( new \DateTime() ); + $archive->setData( $data ); + $this->getD2EM()->persist( $archive ); + + try{ + $this->notify( 'archive', 'add', 'preFlushAdd', $this ); + $this->getD2EM()->flush(); + $this->notify( 'archive', 'add', 'postFlushAdd', $this ); + } + catch( Exception $e ) + { + $this->getLogger()->err( "ArchiveController::addAction() : " . $e->getMessage() ); + $this->addMessage( _( 'This mailbox was not marked for archival.' ), OSS_Message::ERROR ); + $this->redirect( 'mailbox/list' ); + } + + $this->notify( 'archive', 'add', 'prePurge', $this ); + $this->getD2EM()->getRepository( "\\Entities\\Mailbox" )->purgeMailbox( $this->getMailbox(), $this->getAdmin() ); + + $this->notify( 'archive', 'add', 'preFlushPurge', $this, [ 'mailbox' => $this->getMailbox() ] ); + $this->getD2EM()->flush(); + $this->notify( 'archive', 'add', 'postFlushPurge', $this, [ 'mailbox' => $this->getMailbox() ] ); + + $this->addMessage( _( 'This mailbox has been marked for archival. You will be notified by email when this is complete.' ), OSS_Message::SUCCESS ); + $this->redirect( 'mailbox/list' ); + + } + } + + /** + * Cancels archive pending status to previous. + */ + public function cancelAction() + { + if( $this->getArchive()->getStatus() == \Entities\Archive::STATUS_PENDING_ARCHIVE ) + { + $result = $this->_archiveStateChange( $this->getArchive(), \Entities\Archive::STATUS_ARCHIVED, \Entities\Archive::STATUS_PENDING_ARCHIVE ); + if( $result ) + { + try{ + $data = $this->_unserialzeMailbox( $this->getArchive()->getData() ); + $this->getD2EM()->flush(); + } + catch( Exception $e ) + { + $this->addMessage( "Pending was was not canceled.", OSS_Message::ERROR ); + $this->redirect( 'archive/list' ); + } + + $archive = $this->getD2EM()->getRepository( "\\Entities\\Archive" )->find( $this->getArchive()->getId() ); + $this->getD2EM()->remove( $archive ); + $this->notify( 'archive', 'cancel', 'preFlushRestore', $this ); + $this->getD2EM()->flush(); + $this->notify( 'archive', 'cancel', 'postFlushRestore', $this, $data ); + $this->addMessage( "Pending archive was canceled successfully.", OSS_Message::SUCCESS ); + $this->notify( 'archive', 'cancel', 'mailboxRestored', $this, $data ); + } + else + $this->addMessage( "State was changed during canceling. Cancel action cannot be performed at this state.", OSS_Message::INFO ); + + } + else if( $this->getArchive()->getStatus() == \Entities\Archive::STATUS_PENDING_RESTORE ) + { + $result = $this->_archiveStateChange( $this->getArchive(), \Entities\Archive::STATUS_ARCHIVED, \Entities\Archive::STATUS_PENDING_RESTORE ); + if( $result ) + $this->addMessage( "Pending restore was canceled successfully.", OSS_Message::SUCCESS ); + else + $this->addMessage( "State was changed during canceling. Cancel action cannot be performed at this state.", OSS_Message::INFO ); + } + else if( $this->getArchive()->getStatus() == \Entities\Archive::STATUS_PENDING_DELETE ) + { + $result = $this->_archiveStateChange( $this->getArchive(), \Entities\Archive::STATUS_ARCHIVED, \Entities\Archive::STATUS_PENDING_DELETE ); + if( $result ) + { + if( !$this->getArchive()->getHomedirServer() ) + $this->getArchive()->setStatus( \Entities\Archive::STATUS_PENDING_ARCHIVE ); + + $this->addMessage( "Pending delete was canceled successfully.", OSS_Message::SUCCESS ); + } + else + $this->addMessage( "State was changed during canceling. Cancel action cannot be performed at this state.", OSS_Message::INFO ); + } + else + $this->addMessage( "Cancel action cannot be performed at this state.", OSS_Message::INFO ); + + $this->getD2EM()->flush(); + $this->redirect( 'archive/list' ); + } + + /** + * Sets archive status to delete pending + */ + public function deleteAction() + { + if( $this->getArchive()->getStatus() == \Entities\Archive::STATUS_PENDING_ARCHIVE ) + { + $result = $this->_archiveStateChange( $this->getArchive(), \Entities\Archive::STATUS_PENDING_DELETE, \Entities\Archive::STATUS_PENDING_ARCHIVE ); + if( $result ) + $this->addMessage( "Archive status changed to delete pending.", OSS_Message::SUCCESS ); + else + $this->addMessage( "State was changed during deletion. Delete action cannot be performed at this state.", OSS_Message::INFO ); + + } + else if( $this->getArchive()->getStatus() == \Entities\Archive::STATUS_ARCHIVED ) + { + $result = $this->_archiveStateChange( $this->getArchive(), \Entities\Archive::STATUS_PENDING_DELETE, \Entities\Archive::STATUS_ARCHIVED ); + if( $result ) + $this->addMessage( "Archive status changed to delete pending.", OSS_Message::SUCCESS ); + else + $this->addMessage( "State was changed during deletion. Delete action cannot be performed at this state.", OSS_Message::INFO ); + } + else + $this->addMessage( "Restore action cannot be performed at this state.", OSS_Message::INFO ); + + $this->getD2EM()->flush(); + $this->redirect( 'archive/list' ); + } + + /** + * Sets archive status to restore pending + */ + public function restoreAction() + { + if( $this->getArchive()->getStatus() == \Entities\Archive::STATUS_ARCHIVED ) + { + $result = $this->_archiveStateChange( $this->getArchive(), \Entities\Archive::STATUS_PENDING_RESTORE, \Entities\Archive::STATUS_ARCHIVED ); + if( $result ) + $this->addMessage( "Archive status changed to restore pending.", OSS_Message::SUCCESS ); + else + $this->addMessage( "State was changed during restore. Restore action cannot be performed at this state.", OSS_Message::INFO ); + } + else + $this->addMessage( "Restore action cannot be performed at this state.", OSS_Message::INFO ); + + $this->getD2EM()->flush(); + $this->redirect( 'archive/list' ); + } + + /** + * Create archive files to archive entry and set state to archived + */ + public function cliArchivePendingsAction() + { + $archives = $this->getD2EM()->getRepository( "\\Entities\\Archive" )->findBy( [ 'status' => \Entities\Archive::STATUS_PENDING_ARCHIVE ] ); + $uow = $this->getD2EM()->getUnitOfWork(); + + if( !count( $archives ) && $this->getParam( 'verbose' ) ) + { + echo "No pending archives found.\n"; + return; + } + + $archivedir = $this->_options['archive']['path']; + + if( !is_dir( $archivedir ) ) + { + $this->getLogger()->notice( "ArchiveController::cliArchivePendingsAction - archive directory {$archivedir} does not exist!" ); + echo "ERROR: Archive directory {$archivedir} does not exist!\n"; + return; + } + + foreach( $archives as $archive ) + { + //Locking archive by setting it status to archiving + $result = $this->_archiveStateChange( $archive, \Entities\Archive::STATUS_ARCHIVING, \Entities\Archive::STATUS_PENDING_ARCHIVE ); + if( !$result ) + continue; + + $data = unserialize( $archive->getData() ); + if( !isset( $data['mailbox']['params'] ) || !isset( $data['mailbox']['className'] ) ) + continue; + + if( $this->getParam( 'verbose' ) ) echo "\nArchiving {$data['mailbox']['params']['username']}... "; + + $mparams = $data['mailbox']['params']; + $homedir = $mparams['homedir']; + $maildir = \Entities\Mailbox::cleanMaildir( $mparams['maildir'] ); + $home_orig_size = $this->_checkSize( $homedir ); + if( $home_orig_size === false ) + $home_orig_size = 0; + + if( $homedir != $maildir && $home_orig_size != 0 ) + { + $mail_orig_size = $this->_checkSize( $maildir ); + if( $mail_orig_size === false ) + $mail_orig_size = 0; + } + else + $mail_orig_size = 0; + + if( $home_orig_size == 0 ) + { + $htar_name = false; + $mtar_name = false; + $mtar_size = 0; + $htar_suze = 0; + } + else if( $homedir != $maildir ) + { + $mtar_name = sprintf( "maildir-%d", $archive->getId() ); + $htar_name = sprintf( "homedir-%d", $archive->getId() ); + + $mtar_size = $this->_tarDirectory( $archivedir, $mtar_name, $maildir ); + if( $mtar_size === false ) + continue; + + $htar_size = $this->_tarDirectory( $archivedir, $htar_name, $homedir ); + if( $htar_size === false ) + continue;; + } + else + { + $htar_name = sprintf( "homedir-%d", $archive->getId() ); + + $htar_size = $this->_tarDirectory( $archivedir, $htar_name, $homedir ); + if( $htar_size === false ) + continue; + + $mtar_name = false; + $mtar_size = 0; + } + + $archive->setHomedirServer( $this->_options['server_id'] ); + $archive->setMaildirServer( $this->_options['server_id'] ); + + $archive->setHomedirOrigSize( $home_orig_size ); + if( $htar_name ) + { + $archive->setHomedirFile( sprintf( "%s/%s.tar", $archivedir, $htar_name ) ); + $archive->setHomedirSize( $htar_size ); + } + + $archive->setMaildirOrigSize( $mail_orig_size ); + if( $mtar_name ) + { + $archive->setMaildirSize( $mtar_size ); + $archive->setMaildirFile( sprintf( "%s/%s.tar", $archivedir, $mtar_name ) ); + } + + if( $this->getParam( 'verbose' ) ) + { + echo " DONE\n"; + echo " - Original home directory size: {$home_orig_size}\n"; + echo " - Archived home directory size: {$htar_size}\n"; + if( $homedir != $maildir ) + { + echo " - Original mail directory size: {$mail_orig_size}\n"; + echo " - Archived mail directory size: {$mtar_size}\n"; + } + } + + $archive->setStatus( \Entities\Archive::STATUS_ARCHIVED ); + $archive->setStatusChangedAt( new \DateTime() ); + $this->getD2EM()->flush(); + $this->_notifyAdmin( $archive->getArchivedBy(), "archive/email/archive-ready.txt", "Mailbox archived", $data['mailbox']['params']['username'] ); + if( $this->getParam( 'verbose' ) ) echo "\n"; + } + } + + /** + * Delete archives with status pending delete. Removes archive entry and archives. + */ + public function cliDeletePendingsAction() + { + $archives = $this->getD2EM()->getRepository( "\\Entities\\Archive" )->findBy( [ 'status' => \Entities\Archive::STATUS_PENDING_DELETE ] ); + foreach( $archives as $archive ) + { + //Locking archive by setting it status to deleting + $result = $this->_archiveStateChange( $archive, \Entities\Archive::STATUS_DELETING, \Entities\Archive::STATUS_PENDING_DELETE ); + if( !$result ) + continue; + + if( $archive->getHomedirFile() ) + { + if( file_exists( $archive->getHomedirFile() . ".bz2" ) ) + unlink( $archive->getHomedirFile() . ".bz2" ); + else if( file_exists( $archive->getHomedirFile() ) ) + unlink( $archive->gethomedirFile() ); + } + + if( $archive->getMaildirFile() ) + { + if( file_exists( $archive->getMaildirFile() . ".bz2" ) ) + unlink( $archive->getMaildirFile() . ".bz2" ); + else if( file_exists( $archive->getMaildirFile() ) ) + unlink( $archive->getMaildirFile() ); + } + $this->notify( 'archive', 'deletePendings', 'preRemove', $this ); + $this->getD2EM()->remove( $archive ); + $this->notify( 'archive', 'deletePendings', 'postRemove', $this, [ 'username' => $archive->getUsername() ] ); + } + $this->getD2EM()->flush(); + } + + /** + * Restore archived files and unserialize mailbox. Removes archive entry + */ + public function cliRestorePendingsAction() + { + $archives = $this->getD2EM()->getRepository( "\\Entities\\Archive" )->findBy( + [ 'status' => \Entities\Archive::STATUS_PENDING_RESTORE ] + ); + + if( !count( $archives ) && $this->getParam( 'verbose' ) ) + { + echo "No pending archives for restoration found.\n"; + return; + } + + foreach( $archives as $archive ) + { + //Locking archive by setting it status to restoring + if( !$this->_archiveStateChange( $archive, \Entities\Archive::STATUS_RESTORING, \Entities\Archive::STATUS_PENDING_RESTORE ) ) + continue; + + $data = unserialize( $archive->getData() ); + + if( !isset( $data['mailbox']['params'] ) || !isset( $data['mailbox']['className'] ) ) + { + $this->getLogger()->alert( "Bad archive parameters for {$data['mailbox']['params']['username']}" ); + continue; + } + + $mparams = $data['mailbox']['params']; + $homedir = $mparams['homedir']; + $maildir = \Entities\Mailbox::cleanMaildir( $mparams['maildir'] ); + + if( $this->getParam( 'verbose' ) ) echo "\nRestoring archive for {$data['mailbox']['params']['username']}... "; + + if( $archive->getHomedirFile() ) + { + if( !$this->_untarDir( $archive->getHomedirFile(), $homedir ) ) + { + $this->getLogger()->notice( "ArchiveController::cliRestorePendingsAction - could not untar homedir for {$data['mailbox']['params']['username']}" ); + continue; + } + unlink( $archive->getHomedirFile() ); + + + if( $maildir != $homedir && !$this->_untarDir( $archive->getMaildirFile(), $maildir ) ) + { + $this->getLogger()->notice( "ArchiveController::cliRestorePendingsAction - could not untar maildir for {$data['mailbox']['params']['username']}" ); + continue; + } + unlink( $archive->getMaildirFile() ); + } + + if( $this->getParam( 'verbose' ) ) echo "DONE\n"; + + $data = $this->_unserialzeMailbox( $archive->getData() ); + + $this->notify( 'archive', 'restorePendings', 'preFlushRestore', $this ); + $this->getD2EM()->flush(); + $this->notify( 'archive', 'restorePendings', 'postFlushRestore', $this, $data['mailbox'] ); + + $this->_notifyAdmin( $archive->getArchivedBy(), "archive/email/archive-restored.txt", "Mailbox restored", + $data['mailbox']->getUsername() ); + + $this->getD2EM()->remove( $this->getD2EM()->getRepository( "\\Entities\\Archive" )->find( $archive->getId() ) ); + $this->getD2EM()->flush(); + + + $this->notify( 'archive', 'restorePendings', 'restored', $this, $data['mailbox'] ); + + if( $this->getParam( 'verbose' ) ) echo "\n"; + } + } + + /** + * Notifies administrator. + * + * Send notification email for admin about archive created or restore state change. + * + * @param \Entities\Admin $admin Admin to notify + * @param string $viescript Path to tar file + * @param string $subject Destination file + * @param string $musername Archived / restored mailbox username + * @return void + */ + private function _notifyAdmin( $admin, $viewScript, $subject, $musername ) + { + if( !$admin ) + { + $this->getLogger()->debug( "ArchiveController: Admin was not found admin notification failed. " ); + return false; + } + + $mailer = $this->getMailer(); + $mailer->setFrom( $this->_options['identity']['autobot']['email'], $this->_options['identity']['autobot']['name'] ) + ->addTo( $admin->getUsername(), "ViMbAdmin Administrator" ) + ->setSubject( $this->_options['identity']['sitename'] . " - " . $subject ); + + $this->view->mailbox = $musername; + $mailer->setBodyText( $this->view->render( $viewScript ) ); + $mailer->send(); + } + + /** + * Untar directory + * + * Untars mailbox homedir or maildir. + * + * First function looks for bz2 file and if it finds it runs bunzip2 command to get tar file + * if bz2 exist and bunzip2 fails it return false. Then it checks if tar file exist on + * provided path if not returns false. If exists calls _exctractTar function and if it fails + * returns false. If tar was extracted function chown privileges to default mailbox uid and gid. + * Function returns true even if chown was not successfully. + * + * @param string $tarPath Path to tar file + * @param string $destinatiom Destination file + * @return int|bool + */ + private function _untarDir( $tarPath, $destination ) + { + if( file_exists( $tarPath . ".bz2" ) ) + { + $command = sprintf( "%s %s.bz2", $this->_options['binary']['path']['bunzip2_q'], $tarPath ); + exec( $command, $output, $result ); + if( !$result === 0 ) + { + $this->getLogger->debug( "bunzip2 failed path '{$tarPath}.bz2' not found" ); + return false; + } + } + + if( !file_exists( $tarPath ) ) + { + $this->getLogger->debug( "'{$tarPath}' was not found for extracting tar" ); + return false; + } + + $result = $this->_exctractTar( $tarPath, $destination, $this->_options['defaults']['mailbox']['uid'], $this->_options['defaults']['mailbox']['gid'] ); + if( !$result ) + return false; + + return true; + } + + + /** + * Extracts tar to destination + * + * Extracting tar file to given destination + * + * @param string $tarPath Path to tar file + * @param string $destination Destination file + * @param int $uid User id to set owner. + * @param int $gid Group id to set owner. + * @return bool + */ + private function _exctractTar( $tarPath, $destination, $uid, $gid ) + { + $rdest = substr( $destination, 0, strrpos( $destination, "/" ) ); + + if( !is_dir( $rdest ) ) + $this-> _makedirOwned( $rdest, $uid, $gid ); + + $command = sprintf( "%s %s -C %s", $this->_options['binary']['path']['tar_xf'], $tarPath, $rdest ); + exec( $command, $ouput, $result ); + + $command = sprintf( "%s %d:%d %s", $this->_options['binary']['path']['chown_R'], + $uid, $gid, $destination + ); + exec( $command, $output, $result1 ); + if( $result1 !== 0 ) + $this->getLogger->debug( "chown command for '{$destiantion}' failed" ); + + if( $result === 0 && is_dir( $destination ) ) + return true; + else + return false; + } + + /** + * Make directory owned by $uid and $gid. + * + * It checks if previously directory exists if not it call _makedirOwned reucrsively. + * if exists then returns. It creates directory wiht 0755 privileges and changes owner + * to $uid:$gid. + * + * @params string $path Path to create folder + * @param int $uid User id to set owner. + * @param int $gid Group id to set owner. + * @return void + */ + private function _makedirOwned( $path, $uid, $gid ) + { + if( strrpos( $path, "/" ) <= 1 ) + return; + + $rpath = substr( $path, 0, strrpos( $path, "/" ) ); + + if( !is_dir( $rpath ) ) + $this->_makedirOwned( $rpath, $uid, $gid ); + + mkdir( $path, 0755 ); + $command = sprintf( "%s %d:%d %s", $this->_options['binary']['path']['chown_R'], + $uid, $gid, $path + ); + exec( $command, $output, $result ); + if( $result !== 0 ) + $this->getLogger->debug( "chown command for '{$path}' failed" ); + + } + + /** + * Creates tar for directory + * + * Creates tar, removes directory and calls bzip2 on tar file. + * Returns tar size before bzip2 call or false if tar command was not successful. + * + * @param string $archivedir Path where to store archive. + * @param string $tarName Name for tar file + * @param string $pat Path to folder for tar. + * @return int|bool + */ + private function _tarDirectory( $archivedir, $tarName, $path ) + { + $size = $this->_createTar( $archivedir, $tarName, $path ); + if( $size == false ) + $this->getLogger()->err( "Cannot create tar for path '{$path}'" ); + + $command = sprintf( "%s %s", $this->_options['binary']['path']['rm_rf'], $path ); + exec( $command, $output, $result ); + if( $result !== 0 ) + $this->getLogger()->debug( "Cannot remove '{$path}'" ); + + $command = sprintf( "%s %s/%s.tar", $this->_options['binary']['path']['bzip2_q'], $archivedir, $tarName ); + exec( $command, $output, $result ); + if( $result !== 0 ) + $this->getLogger()->debug( "bzip2 failed for '{$path}'" ); + + return $size; + } + + /** + * Creates tar file for given path. + * + * If $fullPath set to true than tar will be created with full directory tree, else + * it will include only last folder fro given path. For example if path /usr/local/test/ + * and $fullPath is true tar will contain usr, local, test folders, else it will contain + * only test folder. + * + * Return tar size in bytes if command executed successfully, otherwise it return false. + * + * @param string $archiveDir Directory for putting archived tar files + * @param string $tarName Name of tar file. + * @param string $path Path to directory to tar. + * @param bool $fullPath Include full file tree in tar + * @return int|bool + */ + private function _createTar( $archiveDir, $tarName, $path, $fullPath = false ) + { + if( !is_dir( $archiveDir ) ) + mkdir( $archiveDir, 0755, true ); + + if( $fullPath ) + { + $command = sprintf( "%s %s/%s.tar %s 2>&1", + $this->_options['binary']['path']['tar_cf'], + $archiveDir, $tarName, + $path + ); + } + else + { + $dir = substr( $path, strrpos( $path, "/" ) + 1 ); + $command = sprintf( "cd %s/../\n%s %s/%s.tar %s 2>&1", + $path, $this->_options['binary']['path']['tar_cf'], + $archiveDir, $tarName, $dir + ); + } + exec( $command, $ouput, $result ); + + if( $result === 0 ) + return $this->_checkSize( sprintf( "%s/%s.tar", $archiveDir, $tarName ) ); + else + return false; + } + + /** + * Check file or directory size. + * + * Function checks if given path is directory if it is then it runs du -sh command + * result is filtered to bytes and function returns int. Else it checks if path is not + * file if it is it return filesize. If it was not directory or file function returns false. + * + * NOTICE: Directory size is sum of all subdirectories and file sizes inside recursively. + * + * @param string $path Path to file or directory for checking the file. + * @return int|bool + */ + private function _checkSize( $path ) + { + if( is_dir( $path ) ) + return OSS_DiskUtils::du( $path ); + else if( file_exists( $path ) ) + return filesize( $path ); + else + return false; + } + + /** + * Set archive state and return true or false. + * + * Executes DQL to update archive to new state but only if expected state is there. + * + * @param \Entities\Archive $archive Archive to change state + * @param string $newState Ne state for archive + * @param string $stateExcpected State which expected to be in archive when changing + * @return bool + */ + private function _archiveStateChange( $archive, $newState, $stateExcpected ) + { + $query = $this->getD2EM()->createQuery( + sprintf( "UPDATE \\Entities\\Archive a SET a.status = '%s', a.status_changed_at = '%s' WHERE a.status = '%s' AND a.id = %d", + $newState, + date( "Y-m-d H:i:s" ), + $stateExcpected, + $archive->getId() + ) + ); + + return $query->getResult() != 1 ? false : true; + } + + /** + * Serialize mailbox and aliases related with mailbox entities + * + * First it serialize mailbox, then mailbox preferences. Then it iterates through all aliases where + * goto equals to mailbox email and serialize them with their preferences. Then it iterates through + * all aliases where goto field includes mailbox email and serialize them with their preferences. + * + * Returns serialized array which have structure like this: + * [ + * 'mailbox' => [ 'classNme' => "entity class name", "params" => array( serialized mailbox array ) ], + * 'mailbox_preferneces' => + * [ + * 0 => [ 'classNme' => "entity class name", "params" => array( serialized mailbox array ) ], + * ... + * n => [ 'classNme' => "entity class name", "params" => array( serialized mailbox array ) ], + * ] + * 'aliases' => + * [ + * 0 => [ 'classNme' => "entity class name", "params" => array( serialized mailbox array ) ], + * ... + * n => [ 'classNme' => "entity class name", "params" => array( serialized mailbox array ) ], + * ] + * 'aliases_prefrences'=> + * [ + * 'alias_key' => + * [ + * 0 => [ 'classNme' => "entity class name", "params" => array( serialized mailbox array ) ], + * ... + * n => [ 'classNme' => "entity class name", "params" => array( serialized mailbox array ) ], + * ], + * 'alias_key2' ..... + * ] + * 'inAliases' => + * [ + * 0 => [ 'classNme' => "entity class name", "params" => array( serialized mailbox array ) ], + * ... + * n => [ 'classNme' => "entity class name", "params" => array( serialized mailbox array ) ], + * ] + * 'inAliases_prefrences'=> + * [ + * 'alias_key' => + * [ + * 0 => [ 'classNme' => "entity class name", "params" => array( serialized mailbox array ) ], + * ... + * n => [ 'classNme' => "entity class name", "params" => array( serialized mailbox array ) ], + * ], + * 'alias_key2' ..... + * ] + * ] + * + * @param /Entities/Mailbox $mailbox Mailbox entity to serialize + * @return string Serialize mailbox. + */ + private function _serialzeMailbox( $mailbox ) + { + $data = []; + $serializer = new OSS_Doctrine2_EntitySerializer( $this->getD2EM() ); + + $data['mailbox'] = [ "className" => get_class( $mailbox ), "params" => $serializer->toArray( $mailbox ) ]; + + foreach( $mailbox->getPreferences() as $pref ) + $data['mailbox_prefrences'][] = [ "className" => get_class( $pref ), "params" => $serializer->toArray( $pref ) ]; + + /* + + The code to archive aliases is buggy right now so we've disabled this. + + $aliases = $this->getD2EM()->getRepository( "\\Entities\\Alias" )->loadForMailbox( $mailbox, $this->getAdmin(), true ); + foreach( $aliases as $key => $alias ) + { + $data['aliases'][$key] = [ "className" => get_class( $alias ), "params" => $serializer->toArray( $alias ) ]; + foreach( $alias->getPreferences() as $pref ) + $data['alias_prefrences'][$key][] = [ "className" => get_class( $pref ), "params" => $serializer->toArray( $pref ) ]; + } + + $inAliases = $this->getD2EM()->getRepository( "\\Entities\\Alias" )->loadWithMailbox( $mailbox, $this->getAdmin() ); + foreach( $inAliases as $key => $alias ) + { + $data['inAliases'][$key] = [ "className" => get_class( $alias ), "params" => $serializer->toArray( $alias ) ]; + foreach( $alias->getPreferences() as $pref ) + $data['inAliases_prefrences'][$key][] = [ "className" => get_class( $pref ), "params" => $serializer->toArray( $pref ) ]; + + } + + */ + return serialize( $data ); + } + + /** + * Unserialize archive data serialized structure. + * + * Function unserialize data array. And by create mailbox object form parameters. + * Then it creates mailbox preferences. Create aliases and their preferences, iterates + * through inAliases and if aliases exists append their got field by mailbox email. + * Then it persists mailbox and aliases set their domains, increase domain mailbox / alias counters. + * Persist all preferences. + * + * Returns restored mailbox and aliases array. Array format: + * + * $return = [ 'mailbox' => $mailbox + * 'aliases' => [ + * 1 => $alias1, + * 2 => $alias2, + * ..... + * ] + * ] + * + * @param string $data Serialized mailbox structure from archive data field. + * @return array; + */ + private function _unserialzeMailbox( $data ) + { + $debug = $this->getParam( 'debug', false ); + $this->getD2EM()->flush(); + $data = unserialize( $data ); + + if( $debug ) echo "[DEBUG] Unserialising {$data['mailbox']['params']['username']}\n"; + $params = $data['mailbox']['params']; + + $mailbox = new \Entities\Mailbox; + $mailbox->setUsername( $params['username'] ); + $mailbox->setPassword( $params['password'] ); + $mailbox->setName( $params['name'] ); + $mailbox->setAltEmail( $params['alt_email'] ); + $mailbox->setQuota( $params['quota'] ); + $mailbox->setLocalPart( $params['local_part'] ); + $mailbox->setActive( $params['active'] ); + $mailbox->setAccessRestriction( $params['access_restriction'] ); + $mailbox->setHomeDir( $params['homedir'] ); + $mailbox->setMailDir( $params['maildir'] ); + $mailbox->setUid( $params['uid'] ); + $mailbox->setGid( $params['gid'] ); + $mailbox->setHomedirSize( $params['homedir_size'] ); + $mailbox->setMaildirSize( $params['maildir_size'] ); + $mailbox->setCreated( new \DateTime( $params['created']['date'] ) ); + $mailbox->setSizeAt( new \DateTime( $params['size_at']['date'] ) ); + $mailbox->setModified( new \DateTime() ); + + if( !( $domain = $this->getD2EM()->getRepository( "\\Entities\\Domain" )->find( $params['domain']['id'] ) ) ) + { + $this->getLogger()->alert( "ArchiveController::_unserialzeMailbox -> domain not found for {$data['mailbox']['params']['username']}" ); + throw new ViMbAdmin_Exception( "Domain was not found" ); + } + + $mailbox->setDomain( $domain ); + $this->getD2EM()->persist( $mailbox ); + $this->getD2EM()->flush(); + + if( isset( $data['mailbox_prefrences'] ) ) + { + if( $debug ) echo "[DEBUG] Unserialising preferences for {$data['mailbox']['params']['username']}\n"; + foreach( $data['mailbox_prefrences'] as $mprefs ) + { + $pr = $this->getD2EM()->getUnitOfWork()->createEntity( $mprefs['className'], $mprefs['params'] ); + $pr->setMailbox( $mailbox ); + if( $debug ) echo "[DEBUG] {$pr->getAttribute()} {$pr->getOp()} {$pr->getValue()}\n"; + $this->getD2EM()->persist( $pr ); + $this->getD2EM()->flush(); + } + } + + if( isset( $this->_options['mailboxAliases'] ) && $this->_options['mailboxAliases'] ) + { + $alias = new \Entities\Alias; + $alias->setAddress( $mailbox->getUsername() ); + $alias->setGoto( $mailbox->getUsername() ); + $alias->setActive( 1 ); + $alias->setCreated( new \Datetime() ); + $alias->setDomain( $domain ); + $this->getD2EM()->persist( $alias ); + $this->getD2EM()->flush(); + } + + /* + + The code to archive aliases is buggy right now so we've disabled this. + + if( isset( $data["aliases"] ) ) + { + if( $debug ) echo "[DEBUG] Unserialising aliases for {$data['mailbox']['params']['username']}\n"; + foreach( $data["aliases"] as $idx => $dalias ) + { + if( !isset( $dalias['params'] ) || !isset( $dalias['className'] ) ) + continue; + + $uow->clear(); + $alias = $uow->createEntity( $dalias['className'], $dalias['params'] ); + $alias->setCreated( new \DateTime( $dalias['params']['created']['date'] ) ); + $alias->setModified( new \DateTime() ); + $domains[] = $dalias['params']['domain']['id']; + $newEnts[] = $alias; + + if( $debug ) echo "[DEBUG] {$alias->getAddress()} => {$alias->getGoto()}\n"; + + if( isset( $data["alias_prefrences"][$idx] ) ) + { + foreach( $data["alias_prefrences"][$idx] as $ap ) + { + if( !isset( $ap['params'] ) || !isset( $ap['className'] ) ) + continue; + + $uow->clear(); + $pr = $uow->createEntity( $ap['className'], $ap['params'] ); + $pr->setAlias( $alias ); + $newprefs[] = $pr; + if( $debug ) echo "[DEBUG] {$pr->getAttribute()} {$pr->getOp()} {$pr->getValue()}\n"; + } + } + } + } + + if( isset( $data["inAliases"] ) ) + { + if( $debug ) echo "[DEBUG] Unserialising 'in' aliases for {$data['mailbox']['params']['username']}\n"; + + foreach( $data["inAliases"] as $idx => $dalias ) + { + if( !isset( $dalias['params'] ) || !isset( $dalias['className'] ) ) + continue; + + $params = $dalias['params']; + $alias = $this->getD2EM()->getRepository( "\\Entities\\Alias" )->find( $params['id'] ); + + //FIXME: Now we skipping if alias was removed. + if( $alias ) + { + $alias->setGoto( $alias->getGoto() . "," . $mailbox->getUsername() ); + if( $debug ) echo "[DEBUG] {$alias->getAddress()} => {$alias->getGoto()}\n"; + } + } + } + */ + + if( $debug ) echo "\n"; + return [ 'mailbox' => $mailbox, 'aliases' => [] ]; + } +} diff --git a/application/controllers/AuthController.php b/application/controllers/AuthController.php index 3e8874e..896061c 100644 --- a/application/controllers/AuthController.php +++ b/application/controllers/AuthController.php @@ -7,7 +7,7 @@ * project which provides an easily manageable web based virtual * mailbox administration system. * - * Copyright (c) 2011 Open Source Solutions Limited + * Copyright (c) 2011 - 2014 Open Source Solutions Limited * * ViMbAdmin is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,7 +26,7 @@ * 147 Stepaside Park, Stepaside, Dublin 18, Ireland. * Barry O'Donovan * - * @copyright Copyright (c) 2011 Open Source Solutions Limited + * @copyright Copyright (c) 2011 - 2014 Open Source Solutions Limited * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License, version 3 (GPLv3) * @author Open Source Solutions Limited * @author Barry O'Donovan @@ -41,185 +41,46 @@ */ class AuthController extends ViMbAdmin_Controller_Action { + use OSS_Controller_Trait_Auth; /** - * Jumps to login action. + * A pre-login function allow and pre-login processing / checks. + * Override if you need to add functionality. */ - public function indexAction() + protected function _preLogin() { - $this->_forward( 'login' ); + if( $this->getD2EM()->getRepository( '\\Entities\\Admin' )->getCount() == 0 ) + $this->_redirect( 'auth/setup' ); } - /** - * Display the login box or process a login on submission. + * Get the login form + * + * @return ViMbAdmin_Form_Auth_Login The login form */ - public function loginAction() + protected function _getFormLogin() { - if( $this->getAuth()->getIdentity() ) - { - $this->addMessage( _( 'You are already logged in.' ), ViMbAdmin_Message::INFO ); - $this->_redirect( 'domain/list' ); - } - - // make sure we have some users - if( AdminTable::getCount() == 0 ) - $this->_redirect( 'auth/setup' ); - - $auth = Zend_Auth::getInstance(); - - $loginForm = new ViMbAdmin_Form_Auth_Login; - - if( $this->getRequest()->isPost() && $loginForm->isValid( $_POST ) ) - { - try - { - $authAdapter = new ViMbAdmin_Auth_DoctrineAdapter( - $loginForm->getValue( 'username' ), - AdminTable::hashPassword( $loginForm->getValue( 'password' ), $this->_options[ 'securitysalt' ] ) - ); - - $result = $auth->authenticate( $authAdapter ); - - switch( $result->getCode() ) - { - case Zend_Auth_Result::SUCCESS: - $identity = $auth->getIdentity(); - $this->getLogger()->info( "Admin {$identity['username']} logged in" ); - $this->_redirect( 'domain/list' ); - break; - - default: - $this->addMessages( $result->getMessages(), ViMbAdmin_Message::ERROR ); - $this->getLogger()->debug( - "Bad login for {$loginForm->getValue( 'username' )}: " - . implode( ' -- ', $result->getMessages() ) - ); - break; - } - } - catch( Zend_Auth_Adapter_Exception $e ) - { - $this->getLogger()->err( "Exception in AuthController::loginAction: " . $e->getMessage() ); - $this->addMessage( - _( "System error during login - please see system logs or contact your system administrator." ), - ViMbAdmin_Message::ERROR - ); - } - } - - $this->view->loggedOut = $this->_getParam( 'out', false ); - $this->view->loginForm = $loginForm; + return new ViMbAdmin_Form_Auth_Login(); } - /** - * Logs the user out, clears the identity and the session. + * Get the lost password form + * + * @return ViMbAdmin_Form_Auth_LostPassword The login form */ - public function logoutAction() + protected function _getFormLostPassword() { - if( $this->getAuth()->getIdentity() ) - $this->getLogger()->debug( _( 'Admin' ) . ' ' . $this->getAdmin()->username . ' ' . _( 'logged out' ) . '.' ); - - $this->getAuth()->clearIdentity(); - $this->getSession()->unsetAll(); - Zend_Session::destroy( true, true ); - - $this->_redirect( 'auth/login/out/1' ); + return new ViMbAdmin_Form_Auth_LostPassword(); } - /** - * Asks for a username (email) and sends a password reset token to the address. If the parameter "rid" - * exists (click on link in email) and the RID is valid then sets the admin's password to random and emails - * it to him/her, so he/she can log in and re-set the password if desired. + * Get the reset password form + * + * @return ViMbAdmin_Form_Auth_ResetPassword The login form */ - public function passwordResetAction() + protected function _getFormResetPassword() { - $rid = $this->_getParam( 'rid', false ); - - if( !$rid ) - { - $resetForm = new ViMbAdmin_Form_Auth_PasswordReset; - - if( $this->getRequest()->isPost() && $resetForm->isValid( $_POST ) ) - { - $username = $resetForm->getValue( 'username' ); - - $adminModel = Doctrine_Query::create() - ->from( 'Admin' ) - ->where( 'username = ?', $username ) - ->fetchOne(); - - if( !$adminModel ) - { - $this->addMessage( _( 'User does not exist.' ), ViMbAdmin_Message::ERROR ); - } - else - { - $tokenModel = TokenTable::addToken( $adminModel, 'PASSWORD_RESET', null, null ); - - $mailer = new Zend_Mail( 'UTF-8' ); - $mailer->setSubject( _( 'ViMbAdmin :: Password Reset' ) ); - $mailer->addTo( $adminModel->username ); - $mailer->setFrom( - $this->_options['server']['email']['address'], - $this->_options['server']['email']['name'] - ); - - $this->view->tokenModel = $tokenModel; - $this->view->adminModel = $adminModel; - - $mailer->setBodyText( $this->view->render( 'auth/email/password_reset.phtml' ) ); - - $mailer->send(); - - $this->addMessage( _( 'We have sent you an email with further details.' ), ViMbAdmin_Message::SUCCESS ); - $this->_redirect( 'auth/login' ); - } - } - - $this->view->resetForm = $resetForm; - } - elseif( strlen( $rid ) != 32 ) - { - $this->addMessage( _( 'Invalid token.' ), ViMbAdmin_Message::ERROR ); - } - else - { - $tokenModel = Doctrine::getTable( 'Token' )->findOneByRid( $rid ); - - if( !$tokenModel ) - { - $this->addMessage( _( 'Invalid token.' ), ViMbAdmin_Message::ERROR ); - } - else - { - $password = TokenTable::createRandomString( 10 ); - - $tokenModel->Admin->setPassword( $password, $this->_options['securitysalt'], true ); - - $mailer = new Zend_Mail( 'UTF-8' ); - $mailer->setSubject( _( 'ViMbAdmin :: Password Reset' ) ); - $mailer->setFrom( - $this->_options['server']['email']['address'], - $this->_options['server']['email']['name'] - ); - - $mailer->addTo( $tokenModel->Admin->username ); - - $this->view->password = $password; - - $mailer->setBodyText( $this->view->render( 'auth/email/new_password.phtml' ) ); - - $mailer->send(); - - TokenTable::deleteTokens( $tokenModel->Admin, 'PASSWORD_RESET' ); - - $this->addMessage( _( 'We have sent you an email with further details.' ), ViMbAdmin_Message::SUCCESS ); - $this->_redirect( 'auth/login' ); - } - } + return new ViMbAdmin_Form_Auth_ResetPassword(); } @@ -228,41 +89,56 @@ public function passwordResetAction() */ public function changePasswordAction() { - $form = new ViMbAdmin_Form_Mailbox_Password( $this->_options['defaults']['mailbox']['min_password_length'] ); + $form = new ViMbAdmin_Form_Mailbox_Password(); + + if( isset( $this->_options['defaults']['mailbox']['min_password_length'] ) ) + $form->setMinPasswordLength( $this->_options['defaults']['mailbox']['min_password_length'] ); if( $this->getRequest()->isPost() && $form->isValid( $_POST ) ) { - $mailbox = Doctrine_Query::create() - ->from( 'Mailbox' ) - ->where( 'username = ?', $form->getValue( 'username' ) ) - ->fetchOne(); + $mailbox = $this->getD2EM()->getRepository( '\\Entities\\Mailbox' )->findOneBy( ['username' => $form->getValue( 'username' ) ] ); if( !$mailbox ) { - $this->addMessage( _( 'Invalid username or password.' ), ViMbAdmin_Message::ERROR ); + $this->addMessage( _( 'Invalid username or password.' ), OSS_Message::ERROR ); } else { - $cPassword = $mailbox['password']; - if( $cPassword == $mailbox->hashPassword( - $this->_options['defaults']['mailbox']['password_scheme'], - $form->getValue( 'current_password' ), - $this->_options['defaults']['mailbox']['password_hash'] + if( OSS_Auth_Password::verify( + $form->getValue( 'current_password' ), $mailbox->getPassword(), + [ + 'pwhash' => $this->_options['defaults']['mailbox']['password_scheme'], + 'pwsalt' => isset( $this->_options['defaults']['mailbox']['password_salt'] ) + ? $this->_options['defaults']['mailbox']['password_salt'] : null, + 'pwdovecot' => isset( $this->_options['defaults']['mailbox']['dovecot_pw_binary'] ) + ? $this->_options['defaults']['mailbox']['dovecot_pw_binary'] : null, + 'username' => $form->getValue( 'username' ) + ] ) ) { - $mailbox->hashPassword( - $this->_options['defaults']['mailbox']['password_scheme'], - $form->getValue( 'new_password' ), - $this->_options['defaults']['mailbox']['password_hash'] + $mailbox->setPassword( + OSS_Auth_Password::hash( + $form->getValue( 'new_password' ), + [ + 'pwhash' => $this->_options['defaults']['mailbox']['password_scheme'], + 'pwsalt' => isset( $this->_options['defaults']['mailbox']['password_salt'] ) + ? $this->_options['defaults']['mailbox']['password_salt'] : null, + 'pwdovecot' => isset( $this->_options['defaults']['mailbox']['dovecot_pw_binary'] ) + ? $this->_options['defaults']['mailbox']['dovecot_pw_binary'] : null, + 'username' => $form->getValue( 'username' ) + + ] + ) ); - $mailbox->save(); - $this->addMessage( _( 'You have successfully changed your password.' ), ViMbAdmin_Message::SUCCESS ); + + $this->getD2EM()->flush(); + $this->addMessage( _( 'You have successfully changed your password.' ), OSS_Message::SUCCESS ); $this->_redirect( 'auth/login' ); } else - $this->addMessage( _( 'Invalid username or password.' ), ViMbAdmin_Message::ERROR ); + $this->addMessage( _( 'Invalid username or password.' ), OSS_Message::ERROR ); } } @@ -272,30 +148,30 @@ public function changePasswordAction() public function setupAction() { - $form = new ViMbAdmin_Form_Admin_Edit; - $form->removeElement( 'active' ); - $form->removeElement( 'super' ); - $form->removeElement( 'welcome_email' ); + if( $this->getD2EM()->getRepository( '\\Entities\\Admin' )->getCount() != 0 ) + { + $this->addMessage( _( "Admins already exist in the system." ), OSS_Message::INFO ); + $this->_redirect( 'auth/login' ); + } if( $this->getAuth()->getIdentity() ) { - $this->addMessage( _( 'You are already logged in.' ), ViMbAdmin_Message::INFO ); + $this->addMessage( _( 'You are already logged in.' ), OSS_Message::INFO ); $this->_redirect( 'domain/list' ); } - if( $this->_options['securitysalt'] == '' ) - { - $charSet = 'abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'; - $randomSalt = substr( str_shuffle( "{$charSet}{$charSet}" ), 0, 31 ); // please note this is not UTF-8 compatible + $this->view->form = $form = new ViMbAdmin_Form_Admin_AddEdit(); + $form->removeElement( 'active' ); + $form->removeElement( 'super' ); + $form->removeElement( 'welcome_email' ); + if( !isset( $this->_options['securitysalt'] ) || strlen( $this->_options['securitysalt'] ) != 64 ) + { $this->view->saltSet = false; - $this->view->randomSalt = $randomSalt; + $randomSalt = $this->view->randomSalt = OSS_String::salt( 64 ); $form->getElement( 'salt' )->setValue( $randomSalt ); - } - elseif( !AdminTable::isEmpty() ) - { - $this->addMessage( _( "Admins already exist in the system." ), ViMbAdmin_Message::INFO ); - $this->_redirect( 'auth/login' ); + $this->view->rememberSalt = OSS_String::salt( 64 ); + $this->view->passwordSalt = OSS_String::salt( 64 ); } else { @@ -305,68 +181,82 @@ public function setupAction() { if( $form->getElement( 'salt' )->getValue() != $this->_options['securitysalt'] ) { - $this->addMessage( _( "Incorrect security salt provided. Please copy and paste it from the application.ini file." ), ViMbAdmin_Message::INFO ); + $this->addMessage( _( "Incorrect security salt provided. Please copy and paste it from the application.ini file." ), OSS_Message::INFO ); } else { - $admin = new Admin(); - $admin['username'] = $form->getValue( 'username' ); - $admin->setPassword( $form->getValue( 'password' ), $this->_options['securitysalt'], false ); - $admin->super = true; - $admin->active = true; - $admin->save(); - + $admin = new \Entities\Admin(); + $admin->setUsername( $form->getValue( 'username' ) ); + $admin->setPassword( + OSS_Auth_Password::hash( $form->getValue( 'password' ), $this->_options['resources']['auth']['oss'] ) + ); + $admin->setSuper( true ); + $admin->setActive( true ); + $admin->setCreated( new \DateTime() ); + $admin->setModified( new \DateTime() ); + $this->getD2EM()->persist( $admin ); + // we need to populate the Doctine migration table - $migration = new MigrationVersion(); - $migration['version'] = $this->_options['migration_version']; - $migration->save(); + $dbversion = new \Entities\DatabaseVersion(); + $dbversion->setVersion( ViMbAdmin_Version::DBVERSION ); + $dbversion->setName( ViMbAdmin_Version::DBVERSION_NAME ); + $dbversion->setAppliedOn( new \DateTime() ); + $this->getD2EM()->persist( $dbversion ); + + $this->getD2EM()->flush(); try { - $mailer = new Zend_Mail( 'UTF-8' ); + $mailer = $this->getMailer(); $mailer->setSubject( _( 'ViMbAdmin :: Your New Administrator Account' ) ); - $mailer->addTo( $admin['username'] ); + $mailer->addTo( $admin->getUsername() ); $mailer->setFrom( $this->_options['server']['email']['address'], $this->_options['server']['email']['name'] ); - $this->view->username = $admin['username']; + $this->view->username = $admin->getUsername(); $this->view->password = $form->getValue( 'password' ); $mailer->setBodyText( $this->view->render( 'admin/email/new_admin.phtml' ) ); $mailer->send(); } - catch( Exception $e ) - {} + catch( Zend_Mail_Exception $e ) + { + $this->addMessage( _( 'Could not send welcome email to the new administrator. + Please ensure you have configured a mail relay server in your application.ini.' ), OSS_Message::ALERT ); + } - $this->addMessage( _( 'Your administrator account has been added. Please log in below.' ), ViMbAdmin_Message::SUCCESS ); + $this->addMessage( _( 'Your administrator account has been added. Please log in below.' ), OSS_Message::SUCCESS ); } if( !( isset( $this->_options['skipInstallPingback'] ) && $this->_options['skipInstallPingback'] ) ) { - // Try and track new installs to see if it is worthwhile continueing development - include_once( APPLICATION_PATH . '/../public/PiwikTracker.php' ); - - if( class_exists( 'PiwikTracker' ) ) + try { - if( $_SERVER['HTTPS'] == 'on' ) - PiwikTracker::$URL = 'https://stats.opensolutions.ie/'; - else - PiwikTracker::$URL = 'http://stats.opensolutions.ie/'; - - $piwikTracker = new PiwikTracker( $idSite = 5 ); - $piwikTracker->doTrackPageView( 'Nes Install Completed' ); - $piwikTracker->doTrackGoal( $idGoal = 1, $revenue = 0 ); + // Try and track new installs to see if it is worthwhile continueing development + include_once( APPLICATION_PATH . '/../public/PiwikTracker.php' ); + + if( class_exists( 'PiwikTracker' ) ) + { + if( isset( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] == 'on' ) + PiwikTracker::$URL = 'https://stats.opensolutions.ie/'; + else + PiwikTracker::$URL = 'http://stats.opensolutions.ie/'; + + $piwikTracker = new PiwikTracker( $idSite = 5 ); + $piwikTracker->doTrackPageView( 'New V3 Install Completed' ); + $piwikTracker->doTrackGoal( $idGoal = 2, $revenue = 1 ); + } } + catch( Exception $e ){} } - $this->_helper->viewRenderer->setNoRender( true ); $this->_redirect( 'auth/login' ); } } - $this->view->form = $form; } - } + + diff --git a/application/controllers/DomainController.php b/application/controllers/DomainController.php index cf40422..81dfebd 100644 --- a/application/controllers/DomainController.php +++ b/application/controllers/DomainController.php @@ -7,7 +7,7 @@ * project which provides an easily manageable web based virtual * mailbox administration system. * - * Copyright (c) 2011 Open Source Solutions Limited + * Copyright (c) 2011 - 2014 Open Source Solutions Limited * * ViMbAdmin is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,7 +26,7 @@ * 147 Stepaside Park, Stepaside, Dublin 18, Ireland. * Barry O'Donovan * - * @copyright Copyright (c) 2011 Open Source Solutions Limited + * @copyright Copyright (c) 2011 - 2014 Open Source Solutions Limited * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License, version 3 (GPLv3) * @author Open Source Solutions Limited * @author Barry O'Donovan @@ -42,7 +42,6 @@ class DomainController extends ViMbAdmin_Controller_Action { - /** * Most actions in this object will require a domain object to edit / act on. * @@ -54,11 +53,7 @@ class DomainController extends ViMbAdmin_Controller_Action */ public function preDispatch() { - $this->authorise(); - - // if an ajax request, remove the view help - if( substr( $this->getRequest()->getParam( 'action' ), 0, 4 ) == 'ajax' ) - $this->_helper->viewRenderer->setNoRender( true ); + $this->authorise(); // ensure we are logged in } @@ -67,7 +62,7 @@ public function preDispatch() */ public function indexAction() { - $this->_forward( 'list' ); + $this->forward( 'list' ); } @@ -76,24 +71,48 @@ public function indexAction() */ public function listAction() { + if( isset( $this->getSessionNamespace()->domain ) ) + unset( $this->getSessionNamespace()->domain ); + + if( !isset( $this->_options['defaults']['server_side']['pagination']['domain']['enable'] ) || !$this->_options['defaults']['server_side']['pagination']['domain']['enable'] ) + $this->view->domains = $this->getD2EM()->getRepository( '\\Entities\\Domain' )->loadForDomainList( $this->getAdmin() ); + else + $this->view->domains = []; - if( isset( $this->_session->domain ) ) - unset( $this->_session->domain ); - + if( isset( $this->_options['defaults']['list_size']['disabled'] ) && !$this->_options['defaults']['list_size']['disabled'] ) + { + if( isset( $this->_options['defaults']['list_size']['multiplier'] ) && isset( OSS_Filter_FileSize::$SIZE_MULTIPLIERS[ $this->_options['defaults']['list_size']['multiplier'] ] ) ) + $size_multiplier = $this->_options['defaults']['list_size']['multiplier']; + else + $size_multiplier = OSS_Filter_FileSize::SIZE_KILOBYTES; - $query = Doctrine_Query::create() - ->select( 'd.*' ) - ->from( 'Domain d' ); + $this->view->size_multiplier = $size_multiplier; + $this->view->multiplier = OSS_Filter_FileSize::$SIZE_MULTIPLIERS[ $size_multiplier ]; + } + } - if( !$this->getAdmin()->isSuper() ) + public function listSearchAction() + { + Zend_Controller_Action_HelperBroker::removeHelper( 'viewRenderer' ); + if( !isset( $this->_options['defaults']['server_side']['pagination']['domain']['enable'] ) || !$this->_options['defaults']['server_side']['pagination']['domain']['enable'] ) + echo "ko"; + else { - $query->leftJoin( 'DomainAdmin da' ) - ->where( 'da.username = ?', $this->getAdmin()->username ) - ->andWhere( 'da.domain = d.domain' ); + $strl_len = isset( $this->_options['defaults']['server_side']['pagination']['domain']['min_search_str'] ) ? $this->_options['defaults']['server_side']['pagination']['domain']['min_search_str'] : 3; + $search = $this->_getParam( "search", false ); + $this->view->ima = $ima = $this->_getParam( 'ima', 0 ); + if( $search && strlen( $search ) >= $strl_len ) + { + $domains = $this->getD2EM()->getRepository( "\\Entities\\Domain" )->filterForDomainList( $search, $this->getAdmin() ); + $max_cnt = isset( $this->_options['defaults']['server_side']['pagination']['domain']['max_result_cnt'] ) ? $this->_options['defaults']['server_side']['pagination']['domain']['max_result_cnt'] : false; + if( $domains && ( !$max_cnt || $max_cnt >= count( $domains ) ) ) + echo json_encode( $domains ); + else + echo "ko"; + } + else + echo "ko"; } - - $this->view->domains = $query->execute(); - $query->free(); } @@ -103,221 +122,180 @@ public function listAction() public function ajaxToggleActiveAction() { if( !$this->_domain ) - return print 'ko'; - - $this->_domain['active'] = !$this->_domain['active']; - $this->_domain->save(); - - LogTable::log( 'DOMAIN_TOGGLE_ACTIVE', - "Set " . ( $this->_domain['active'] ? '' : 'de' ) . "active", - $this->getAdmin(), $this->_domain + print 'ko'; + + $this->getDomain()->setActive( !$this->getDomain()->getActive() ); + $this->getDomain()->setModified( new DateTime() ); + + $this->log( + $this->getDomain()->getActive() ? \Entities\Log::ACTION_DOMAIN_ACTIVATE : \Entities\Log::ACTION_DOMAIN_DEACTIVATE, + "{$this->getAdmin()->getFormattedName()} " . ( $this->getDomain()->getActive() ? 'activated' : 'deactivated' ) . " domain {$this->getDomain()->getDomain()}" ); + + $this->getD2EM()->flush(); print 'ok'; } /** - * Edit a domain. + * Add / edit a domain. */ - public function editAction() + public function addAction() { - $editForm = new ViMbAdmin_Form_Domain_Edit(); - $this->view->modal = $modal = $this->_getParam( 'modal', false ); + $form = $this->view->form = new ViMbAdmin_Form_Domain_AddEdit(); + if( isset( $this->_options['defaults']['quota']['multiplier'] ) ) + $form->setFilterFileSizeMultiplier( $this->_options['defaults']['quota']['multiplier'] ); - if( !$this->_domain ) + $this->view->quota_multiplier = $form->getFilterFileSizeMultiplier(); + + if( !$this->getDomain() ) { - $this->view->operation = 'Add'; - $this->_domain = new Domain(); + $this->view->isEdit = $isEdit = false; + $this->_domain = new \Entities\Domain(); + $this->getDomain()->setAliasCount( 0 ); + $this->getDomain()->setMailboxCount( 0 ); + $this->getDomain()->setCreated( new DateTime() ); + $this->getD2EM()->persist( $this->_domain ); // set defaults - $this->_domain['mailboxes'] = $this->_options['defaults']['domain']['mailboxes']; - $this->_domain['aliases'] = $this->_options['defaults']['domain']['aliases']; - $this->_domain['transport'] = $this->_options['defaults']['domain']['transport']; - $this->_domain['quota'] = $this->_options['defaults']['domain']['quota']; - $this->_domain['maxquota'] = $this->_options['defaults']['domain']['maxquota']; + + $form->getElement( 'max_mailboxes' )->setValue( $this->_options['defaults']['domain']['mailboxes'] ); + $form->getElement( 'max_aliases' )->setValue( $this->_options['defaults']['domain']['aliases'] ); + $form->getElement( 'transport' )->setValue( $this->_options['defaults']['domain']['transport'] ); + $form->getElement( 'quota' )->setValue( $this->_options['defaults']['domain']['quota'] ); + $form->getElement( 'max_quota' )->setValue( $this->_options['defaults']['domain']['maxquota'] ); } else { - $this->view->operation = 'Edit'; - - $editForm - ->getElement( 'domain' ) + $this->view->isEdit = $isEdit = true; + $form->assignEntityToForm( $this->getDomain(), $this, $isEdit ); + $form->getElement( 'domain' ) ->setAttrib( 'readonly', 'readonly' ) ->setRequired( false ) - ->removeValidator( 'DoctrineUniqueness' ); + ->removeValidator( 'OSSDoctrine2Uniqueness' ); } - $this->view->domainModel = $this->_domain; + $this->view->domain = $this->getDomain(); - if( $this->getRequest()->isPost() && !$modal ) + if( $this->getRequest()->isPost() && $form->isValid( $_POST ) ) { - if( $editForm->isValid( $_POST ) ) - { - $this->_domain->fromArray( $editForm->getValues() ); - $this->_domain->save(); - - LogTable::log( ( $this->view->operation == 'Add' ? 'DOMAIN_ADD' : 'DOMAIN_EDIT' ), - print_r( $this->_domain->toArray(), true ), - $this->getAdmin(), $this->_domain - ); + $form->assignFormToEntity( $this->getDomain(), $this, $isEdit ); - $this->addMessage( _( "You have successfully added/edited the domain record." ), ViMbAdmin_Message::SUCCESS ); + if( $isEdit ) + $this->getDomain()->setModified( new \DateTime() ); - if( $this->_getParam( 'helper', true ) ) - { - $this->_redirect( 'domain/list' ); - } - else - { - $this->_helper->viewRenderer->setNoRender( true ); - print 'ok'; - } - } // if valid post - else - { - if( !$this->_getParam( 'helper', true ) ) - { - $this->view->modal = true; - } - } + $this->log( + $isEdit ? \Entities\Log::ACTION_DOMAIN_EDIT : \Entities\Log::ACTION_DOMAIN_ADD, + "{$this->getAdmin()->getFormattedName()} " . ( $isEdit ? ' edited' : ' added' ) . " domain {$this->getDomain()->getDomain()}" + ); + + $this->getD2EM()->flush(); + + $this->addMessage( _( "You have successfully added/edited the domain record." ), OSS_Message::SUCCESS ); + $this->redirect( 'domain/list' ); } - else - { - $editForm->setDefaults( $this->_domain->toArray() ); - } - - $this->view->editForm = $editForm; } + public function editAction() + { + $this->forward( 'add' ); + } /** * Lists the domain admins. */ public function adminsAction() { - if( !$this->_domain ) - return $this->_forward( 'list' ); + if( !$this->getDomain() ) + { + $this->addMessage( 'Invalid or non-existent domain.', OSS_Message::ERROR ); + $this->redirect( 'domain/list' ); + } $this->authorise( true ); // must be a super admin - - $this->view->domainModel = $this->_domain; - - $alreadyAssigned = array(); - - foreach( $this->_domain->DomainAdmin as $da ) - $alreadyAssigned[] = $da->Admin->id; - - $this->view->adminList = Doctrine_Query::create() - ->from( 'Admin' ) - ->where( 'super = 0' ) - ->whereNotIn( 'id', $alreadyAssigned ) - ->orderBy( 'username asc' ) - ->fetchArray(); + $this->view->domain = $this->getDomain(); } /** * Remove a domain admin. Prints 'ok' on success or 'ko' otherwise to stdout. */ - public function ajaxRemoveAdminAction() + public function removeAdminAction() { - if( !$this->_targetAdmin || !$this->_domain ) - return print 'ko'; + if( !$this->getDomain() ) + { + $this->addMessage( _( 'Invalid or missing admin id.' ), OSS_Message::ERROR ); + $this->redirect( 'domain/list' ); + }else if( !$this->getTargetAdmin() ) + { + $this->addMessage( _( 'Invalid or missing domain id.' ), OSS_Message::ERROR ); + $this->redirect( 'domain/admins/did/' . $this->getDomain()->getId() ); + } $this->authorise( true ); // must be a super admin - Doctrine_Query::create() - ->delete() - ->from( 'DomainAdmin' ) - ->where( 'domain = ?', $this->_domain['domain'] ) - ->andWhere( 'username = ?', $this->_targetAdmin['username'] ) - ->execute(); - - LogTable::log( 'DOMAIN_REMOVE_ADMIN', - "Removed {$this->_targetAdmin['username']}", - $this->getAdmin(), $this->_domain + $this->getTargetAdmin()->removeDomain( $this->getDomain() ); + $this->log( + \Entities\Log::ACTION_ADMIN_TO_DOMAIN_REMOVE, + "{$this->getAdmin()->getFormattedName()} removed admin {$this->getTargetAdmin()->getFormattedName()} from domain {$this->getDomain()->getDomain()}" ); - print 'ok'; + $this->getD2EM()->flush(); + $this->addMessage( 'You have successfully removed the domain from admin '. $this->getTargetAdmin()->getUsername(), OSS_Message::SUCCESS ); + $this->redirect( 'domain/admins/did/' . $this->getDomain()->getId() ); } - /** * Add a domain admin. Prints 'ok' on success or 'ko' otherwise to stdout. */ - public function ajaxAddAdminAction() + public function assignAdminAction() { - if( !$this->_targetAdmin || !$this->_domain ) - return print 'ko'; // 'ok' we just don't do anything + if( !$this->getDomain() ) + { + $this->addMessage( _( 'Invalid or missing domain id.' ), OSS_Message::ERROR ); + $this->redirect( 'doamin/list' ); + } + $this->view->domain = $this->getDomain(); $this->authorise( true ); // must be a super admin - $adminAlready = Doctrine_Query::create() - ->from( 'DomainAdmin' ) - ->where( 'domain = ?', $this->_domain['domain'] ) - ->andWhere( 'username = ?', $this->_targetAdmin['username'] ) - ->fetchArray(); + $remainingAdmins = $this->getD2em()->getRepository( "\\Entities\\Admin" )->getNotAssignedForDomain( $this->getDomain() ); + + $this->view->form = $form = new ViMbAdmin_Form_Domain_AssignAdmin(); + $form->getElement( "admin" )->setMultiOptions( $remainingAdmins ); - if( sizeof( $adminAlready ) == 0 ) // not already assigned + if( $this->getRequest()->isPost() && $form->isValid( $_POST ) ) { - $domainAdmin = new DomainAdmin; - $domainAdmin['domain'] = $this->_domain['domain']; - $domainAdmin['username'] = $this->_targetAdmin['username']; - $domainAdmin->save(); - } + $this->_targetAdmin = $this->loadAdmin( $form->getValue( 'admin' ) ); - LogTable::log( 'DOMAIN_ADD_ADMIN', - "Added {$this->_targetAdmin['username']}", - $this->getAdmin(), $this->_domain - ); + if( $this->getDomain()->getAdmins()->contains( $this->getTargetAdmin() ) ) + $this->addMessage( _( 'This admin is already assigned to the domain.' ), OSS_Message::ERROR ); + else + { + $this->getTargetAdmin()->addDomain( $this->getDomain() ); + $this->log( + \Entities\Log::ACTION_ADMIN_TO_DOMAIN_ADD, + "{$this->getAdmin()->getFormattedName()} added admin {$this->getTargetAdmin()->getFormattedName()} to domain {$this->getDomain()->getDomain()}" + ); + $this->getD2EM()->flush(); + $this->addMessage( 'You have successfully assigned a admin to the domain.', OSS_Message::SUCCESS ); + } - $this->addMessage( _( 'You have successfully added an admin to this domain.' ), ViMbAdmin_Message::SUCCESS ); - print 'ok'; + $this->redirect( 'domain/admins/did/' . $this->getDomain()->getId() ); + } + if( sizeof( $remainingAdmins ) == 0 ) + $this->addMessage( 'There are no administrators to assign to this domain.', OSS_Message::INFO ); } - /** * Purges a mailbox, removes all the related entries from the other tables. - * Prints 'ok' on success or 'ko' otherwise to stdout. */ - public function ajaxPurgeAction() + public function purgeAction() { $this->authorise( true ); - - Doctrine_Query::create() - ->delete() - ->from( 'Mailbox' ) - ->where( 'domain = ?', $this->_domain['domain'] ) - ->execute(); - - Doctrine_Query::create() - ->delete() - ->from( 'Log' ) - ->where( 'domain = ?', $this->_domain['domain'] ) - ->execute(); - - Doctrine_Query::create() - ->delete() - ->from( 'DomainAdmin' ) - ->where( 'domain = ?', $this->_domain['domain'] ) - ->execute(); - - Doctrine_Query::create() - ->delete() - ->from( 'Alias' ) - ->where( 'domain = ?', $this->_domain['domain'] ) - ->execute(); - - $this->_domain->delete(); - - LogTable::log( 'DOMAIN_PURGE', - "Purged {$this->_domain['domain']}", - $this->getAdmin(), null - ); - - print 'ok'; + $this->getD2EM()->getRepository( '\\Entities\\Domain' )->purge( $this->getDomain() ); + $this->redirect( 'domain/list' ); } - } diff --git a/application/controllers/ErrorController.php b/application/controllers/ErrorController.php index 480ee0c..6473f7f 100644 --- a/application/controllers/ErrorController.php +++ b/application/controllers/ErrorController.php @@ -7,7 +7,7 @@ * project which provides an easily manageable web based virtual * mailbox administration system. * - * Copyright (c) 2011 Open Source Solutions Limited + * Copyright (c) 2011 - 2014 Open Source Solutions Limited * * ViMbAdmin is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,7 +26,7 @@ * 147 Stepaside Park, Stepaside, Dublin 18, Ireland. * Barry O'Donovan * - * @copyright Copyright (c) 2011 Open Source Solutions Limited + * @copyright Copyright (c) 2011 - 2014 Open Source Solutions Limited * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License, version 3 (GPLv3) * @author Open Source Solutions Limited * @author Barry O'Donovan @@ -41,72 +41,5 @@ */ class ErrorController extends ViMbAdmin_Controller_Action { - - /** - * The default error handler action - */ - public function errorAction() - { - $this->getLogger()->debug( "\n" ); - - $this->getLogger()->debug('ErrorController::errorAction()'); - $this->getLogger()->warn('ERROR'); - - $except = $this->getResponse()->getException(); - - $this->getLogger()->debug( $except[0]->getMessage() . ' ' . _( 'on line' ) . ' ' . $except[0]->getLine() . ' ' . _( 'of file' ) . ' ' . $except[0]->getFile() ); - $this->getLogger()->debug( $except[0]->getTraceAsString() ); - $this->getLogger()->debug( "HTTP_HOST : {$_SERVER['HTTP_HOST']}" ); - $this->getLogger()->debug( "HTTP_USER_AGENT: {$_SERVER['HTTP_USER_AGENT']}" ); - $this->getLogger()->debug( "HTTP_COOKIE: {$_SERVER['HTTP_COOKIE']}" ); - $this->getLogger()->debug( "REMOTE_PORT: {$_SERVER['REMOTE_PORT']}" ); - $this->getLogger()->debug( "REQUEST_METHOD: {$_SERVER['REQUEST_METHOD']}" ); - $this->getLogger()->debug( "REQUEST_URI: {$_SERVER['REQUEST_URI']}" ); - $this->getLogger()->debug( "\n" ); - - $this->getResponse()->setBody('OK: 0'); - - if ( isset( $this->view ) ) - { - $errors = $this->_getParam( 'error_handler' ); - - $this->getResponse()->clearBody(); - //ob_clean(); - - switch( $errors->type ) - { - case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER: - case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION: - // 404 error -- controller or action not found - $this->getResponse() - ->setRawHeader( 'HTTP/1.1 404 Not Found' ); - - $this->addMessage( _( 'The requested URL or page does not exist.' ), ViMbAdmin_Message::ERROR ); - Zend_Controller_Action_HelperBroker::removeHelper('viewRenderer'); - $this->view->display( 'error/error-404.phtml' ); - break; - - default: - // application error - if ( isset( $errors->exception ) ) - $exception = $errors->exception; - elseif ( Zend_Registry::isRegistered( 'exception' ) ) - $exception = Zend_Registry::get( 'exception' ); - - $this->getLogger()->crit( _( 'Uncaught Exception causing fatal error' ) . ': ' . $exception->getMessage() ); - break; - } - } - - // conditionally display exceptions - if( $this->getInvokeArg( 'displayExceptions' ) ) - $this->view->exception = $exception; - else - $this->view->exception = false; - - $this->view->request = $errors->request; - - return true; - } - + use OSS_Controller_Trait_Error; } diff --git a/application/controllers/ExportSettingsController.php b/application/controllers/ExportSettingsController.php new file mode 100644 index 0000000..168d48e --- /dev/null +++ b/application/controllers/ExportSettingsController.php @@ -0,0 +1,201 @@ +. + * + * Open Source Solutions Limited T/A Open Solutions + * 147 Stepaside Park, Stepaside, Dublin 18, Ireland. + * Barry O'Donovan + * + * @copyright Copyright (c) 2011 - 2014 Open Source Solutions Limited + * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License, version 3 (GPLv3) + * @author Open Source Solutions Limited + * @author Barry O'Donovan + * @author Roland Huszti + */ + +/** + * The mailbox controller. + * + * @package ViMbAdmin + * @subpackage Controllers + */ +class ExportSettingsController extends ViMbAdmin_Controller_PluginAction +{ + + public function thunderbirdAction() + { + if( !isset( $this->_options['defaults']['export_settings']['disabled'] ) || $this->_options['defaults']['export_settings']['disabled'] ) + $this->redirect( "error/404" ); + + if( isset( $this->_options['defaults']['export_settings']['allowed_subnet'] ) ) + { + $ip = $_SERVER['REMOTE_ADDR']; + $valid = false; + foreach( $this->_options['defaults']['export_settings']['allowed_subnet'] as $pattern ) + { + if( substr( $ip, 0, strlen( $pattern ) ) == $pattern ) + { + $valid = true; + break; + } + } + + if( !$valid ) + $this->redirect( "error/404" ); + } + else + { + // no seriously - you must restrict by IP address + $this->redirect( "error/404" ); + } + + if( !$this->getParam( 'email', false ) ) + throw new ViMbAdmin_Exception( "Unable to load mailbox. No mailbox id was given." ); + $this->_mailbox = $this->loadMailboxByUsername( $this->getParam( 'email' ), false, false ); + + $urlUsername= urlencode( $this->getMailbox()->getUsername() ); + + $data = ""; + $data .= "//Identity\n"; + $data .= "defaultPref(\"mail.identity.id1.overrideGlobal_Pref\", false);\n"; + $data .= "defaultPref(\"mail.identity.id1.fullName\", \"{$this->getMailbox()->getName()}\");\n"; + $data .= "defaultPref(\"mail.identity.id1.useremail\", \"{$this->getMailbox()->getUsername()}\");\n"; + $data .= "defaultPref(\"mail.identity.id1.use_custom_prefs\", true);\n"; + $data .= "defaultPref(\"mail.identity.id1.smtpServer\", \"smtp1\");\n"; + $data .= "defaultPref(\"mail.identity.id1.organization\", \"{$this->_options['identity']['orgname']}\");\n"; + $data .= "defaultPref(\"mail.identity.id1.doBcc\", false);\n"; + $data .= "defaultPref(\"mail.identity.id1.compose_html\", true);\n"; + if( $this->getMailbox()->getName() ) + $data .= "defaultPref(\"mail.identity.id1.htmlSigText\", \"Kind regards,\\n{$this->getMailbox()->getName()}\\n\\n{$this->_options['identity']['orgname']}\");\n"; + $data .= "defaultPref(\"mail.account.account1.identities\", \"id1\");\n"; + $data .= "defaultPref(\"mail.account.account1.server\", \"server1\");\n"; + $data .= "defaultPref(\"mail.account.account2.server\", \"server2\");\n"; + + $data .= "defaultPref(\"mail.accountmanager.defaultaccount\", \"account1\");\n"; + $data .= "defaultPref(\"mail.accountmanager.localfoldersserver\", \"server2\");\n"; + + if( isset( $this->_options['server']['imap']['enabled'] ) && $this->_options['server']['imap']['enabled'] ) + { + $host = preg_replace( "/%d/", $this->getMailbox()->getDomain()->getDomain(), $this->_options['server']['imap']['host'] ); + $data .= "defaultPref(\"mail.imap.min_chunk_size_threshold\", 712704);\n"; + $data .= "defaultPref(\"mail.last_msg_movecopy_was_move\", false);\n"; + $data .= "defaultPref(\"mail.openMessageBehavior.version\", 1);\n"; + $data .= "defaultPref(\"mail.preferences.advanced.selectedTabIndex\", 3);\n"; + $data .= "defaultPref(\"mail.preferences.security.selectedTabIndex\", 4);\n"; + $data .= "defaultPref(\"mail.rights.version\", 1);\n"; + + $data .= "//IMAP Settings\n"; + $data .= "defaultPref(\"mail.server.server1.userName\", \"{$this->getMailbox()->getUsername()}\");\n"; + $data .= "defaultPref(\"mail.server.server1.port\", {$this->_options['server']['imap']['port']});\n"; + $data .= "defaultPref(\"mail.server.server1.socketType\", 3);\n"; + $data .= "defaultPref(\"mail.server.server1.hostname\", \"{$host}\");\n"; + $data .= "defaultPref(\"mail.server.server1.directory-rel\", \"[ProfD]ImapMail/{$host}\");\n"; + $data .= "defaultPref(\"mail.server.server1.name\", \"{$this->getMailbox()->getUsername()}\");\n"; + $data .= "defaultPref(\"mail.server.server1.spamActionTargetAccount\", \"imap://{$urlUsername}@{$host}\");\n"; + $data .= "defaultPref(\"mail.server.server1.spamActionTargetFolder\", \"mailbox://nobody@Local%20Folders/Junk\");\n"; + $data .= "defaultPref(\"mail.server.server1.type\", \"imap\");\n"; + $data .= "defaultPref(\"mail.server.server1.timeout\", 29);\n"; + + $data .= "defaultPref(\"mail.server.server1.ageLimit\", 1);\n"; + $data .= "defaultPref(\"mail.server.server1.cacheCapa.acl\", false);\n"; + $data .= "defaultPref(\"mail.server.server1.cacheCapa.quota\", false);\n"; + $data .= "defaultPref(\"mail.server.server1.capability\", 101213733);\n"; + $data .= "defaultPref(\"mail.server.server1.login_at_startup\", true);\n"; + $data .= "defaultPref(\"mail.server.server1.storeContractID\", \"@mozilla.org/msgstore/berkeleystore;1\");\n"; + + $data .= "defaultPref(\"mail.identity.id1.archive_folder\", \"imap://{$urlUsername}@{$host}/Archives\");\n"; + $data .= "defaultPref(\"mail.identity.id1.draft_folder\", \"imap://{$urlUsername}@{$host}/Drafts\");\n"; + $data .= "defaultPref(\"mail.identity.id1.drafts_folder_picker_mode\", \"0\");\n"; + $data .= "defaultPref(\"mail.identity.id1.fcc_folder\", \"imap://{$urlUsername}@{$host}/Sent\");\n"; + $data .= "defaultPref(\"mail.identity.id1.fcc_folder_picker_mode\", \"0\");\n"; + $data .= "defaultPref(\"mail.identity.id1.stationery_folder\", \"imap://{$urlUsername}@{$host}/Templates\");\n"; + $data .= "defaultPref(\"mail.identity.id1.tmpl_folder_picker_mode\", \"0\");\n"; + + } + + $data .= "//Local mail folders\n"; + $data .= "defaultPref(\"mail.server.server2.directory-rel\", \"[ProfD]Mail/Local Folders\");\n"; + $data .= "defaultPref(\"mail.server.server2.hostname\", \"Local Folders\");\n"; + $data .= "defaultPref(\"mail.server.server2.name\", \"Local Folders\");\n"; + $data .= "defaultPref(\"mail.server.server2.spamActionTargetAccount\", \"mailbox://nobody@Local%20Folders\");\n"; + $data .= "defaultPref(\"mail.server.server2.storeContractID\", \"@mozilla.org/msgstore/berkeleystore;1\");\n"; + $data .= "defaultPref(\"mail.server.server2.type\", \"none\");\n"; + $data .= "defaultPref(\"mail.server.server2.userName\", \"nobody\");\n"; + + if( isset( $this->_options['server']['smtp']['enabled'] ) && $this->_options['server']['smtp']['enabled'] ) + { + $data .= "//SMTP Settings\n"; + $data .= "defaultPref(\"mail.smtpserver.smtp1.authMethod\", 3);\n"; + $data .= "defaultPref(\"mail.smtpserver.smtp1.description\", \"SMTP Mail\");\n"; + $host = preg_replace( "/%d/", $this->getMailbox()->getDomain()->getDomain(), $this->_options['server']['smtp']['host'] ); + $data .= "defaultPref(\"mail.smtpserver.smtp1.hostname\", \"{$host}\");\n"; + $data .= "defaultPref(\"mail.smtpserver.smtp1.port\", {$this->_options['server']['smtp']['port']});\n"; + $data .= "defaultPref(\"mail.smtpserver.smtp1.try_ssl\", 3);\n"; + $user = preg_replace( "/%m/", $this->getMailbox()->getUsername(), $this->_options['server']['smtp']['user'] ); + $data .= "defaultPref(\"mail.smtpserver.smtp1.username\", \"{$user}\");\n"; + } + + $data .= "defaultPref(\"mail.smtpservers\", \"smtp1\");\n"; + $srvCnt = "2"; + $accCnt = "2"; + + + // FIXME Temporary for time constraints. Really needs a plugin. + $data .= "\n\n//Sieve Out of Office\n"; + $host = preg_replace( "/%d/", $this->getMailbox()->getDomain()->getDomain(), $this->_options['server']['imap']['host'] ); + $oooAcc = urlencode( $this->getMailbox()->getUsername() ) . "@" . $host; + $data .= "defaultPref(\"extensions.sieve.account.{$oooAcc}.TLS\", true);\n"; + $data .= "defaultPref(\"extensions.sieve.account.{$oooAcc}.activeHost\", 0);\n"; + $data .= "defaultPref(\"extensions.sieve.account.{$oooAcc}.activeLogin\", 1);\n"; + $data .= "defaultPref(\"extensions.sieve.account.{$oooAcc}.compile\", true);\n"; + $data .= "defaultPref(\"extensions.sieve.account.{$oooAcc}.compile.delay\", 500);\n"; + $data .= "defaultPref(\"extensions.sieve.account.{$oooAcc}.debug.flags\", 0);\n"; + $data .= "defaultPref(\"extensions.sieve.account.{$oooAcc}.enabled\", true);\n"; + $data .= "defaultPref(\"extensions.sieve.account.{$oooAcc}.keepalive\", true);\n"; + $data .= "defaultPref(\"extensions.sieve.account.{$oooAcc}.keepalive.interval\", \"1800000\");\n"; + $data .= "defaultPref(\"extensions.sieve.account.{$oooAcc}.port\", 4190);\n\n\n"; + + + $file = sprintf( "%s/settings_%s.js", $this->_options['temporary_directory'], $this->getMailbox()->getId() ); + + file_put_contents( $file, $data ); + + $this->notify( 'export_settings', 'thunderbird', 'preSetSettings', $this, [ 'file' => $file, 'options' => $this->_options, 'server_count' => &$srvCnt, 'account_count' => &$accCnt ] ); + + $accs = []; + for( $acc = 1; $acc <= $accCnt; $acc++ ) + $accs[] = "account{$acc}"; + + $accs = implode( ',' , $accs ); + $data = "defaultPref(\"mail.accountmanager.accounts\", \"{$accs}\");\n"; + + file_put_contents( $file, $data, FILE_APPEND ); + + $content = file_get_contents( $file ); + unlink( $file ); + header('Content-type: text/javascript'); + die( $content ); + + } + +} diff --git a/application/controllers/IndexController.php b/application/controllers/IndexController.php index 10de3e7..25e6fa0 100644 --- a/application/controllers/IndexController.php +++ b/application/controllers/IndexController.php @@ -7,7 +7,7 @@ * project which provides an easily manageable web based virtual * mailbox administration system. * - * Copyright (c) 2011 Open Source Solutions Limited + * Copyright (c) 2011 - 2014 Open Source Solutions Limited * * ViMbAdmin is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,7 +26,7 @@ * 147 Stepaside Park, Stepaside, Dublin 18, Ireland. * Barry O'Donovan * - * @copyright Copyright (c) 2011 Open Source Solutions Limited + * @copyright Copyright (c) 2011 - 2014 Open Source Solutions Limited * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License, version 3 (GPLv3) * @author Open Source Solutions Limited * @author Barry O'Donovan diff --git a/application/controllers/LogController.php b/application/controllers/LogController.php index ce352a9..70cdc5b 100644 --- a/application/controllers/LogController.php +++ b/application/controllers/LogController.php @@ -7,7 +7,7 @@ * project which provides an easily manageable web based virtual * mailbox administration system. * - * Copyright (c) 2011 Open Source Solutions Limited + * Copyright (c) 2011 - 2014 Open Source Solutions Limited * * ViMbAdmin is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,7 +26,7 @@ * 147 Stepaside Park, Stepaside, Dublin 18, Ireland. * Barry O'Donovan * - * @copyright Copyright (c) 2011 Open Source Solutions Limited + * @copyright Copyright (c) 2011 - 2014 Open Source Solutions Limited * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License, version 3 (GPLv3) * @author Open Source Solutions Limited * @author Barry O'Donovan @@ -52,43 +52,18 @@ class LogController extends ViMbAdmin_Controller_Action */ public function preDispatch() { - if( $adminId = $this->_getParam( 'admin', false ) ) - { - if( $this->getAdmin()->id != $adminId ) - $this->authorise( true ); // super only - - if( !( $this->_targetAdmin = $this->loadAdmin( $adminId ) ) ) - { - // id parameter specified but invalid or non-existent - $this->addMessage( _( 'Invalid or non-existent admin.' ), ViMbAdmin_Message::ERROR ); - $this->_redirect( 'domain/list' ); - } - - $this->view->targetAdmin = $this->_targetAdmin; - } - else if( !$this->getAdmin()->isSuper() ) + if( !$this->getTargetAdmin() && !$this->getAdmin()->isSuper() ) $this->_targetAdmin = $this->getAdmin(); - if( $this->_getParam( 'unset', false ) ) - unset( $this->_session->domain ); + if( $this->getParam( 'unset', false ) ) + unset( $this->getSessionNamespace()->domain ); else { - if( isset( $this->_session->domain) && $this->_session->domain ) - $this->_domain = $this->_session->domain; - } - - if( $domainId = $this->_getParam( 'domain', false ) ) - { - if( !( $this->_domain = $this->loadDomain( $domainId ) ) ) - { - // id parameter specified but invalid or non-existent - $this->addMessage( _( 'Invalid or non-existent domain.' ), ViMbAdmin_Message::ERROR ); - $this->_redirect( 'domain/list' ); - } - - $this->authorise( false, $this->_domain ); + if( isset( $this->getSessionNamespace()->domain ) && $this->getSessionNamespace()->domain ) + $this->_domain = $this->getSessionNamespace()->domain; + else if( $this->getDomain() ) + $this->getSessionNamespace()->domain = $this->getDomain(); } - } @@ -97,7 +72,7 @@ public function preDispatch() */ public function indexAction() { - $this->_forward( 'list' ); + $this->forward( 'list' ); } @@ -107,18 +82,7 @@ public function indexAction() */ public function listAction() { - $query = Doctrine_Query::create() - ->from( 'Log' ); - - if( $this->_targetAdmin ) - $query->andWhere( 'username = ?', $this->_targetAdmin['username'] ); - - if( $this->_domain ) - $query->andWhere( 'domain = ?', $this->_domain['domain'] ); - - $this->view->logEntries = $query - ->orderBy( 'id asc' ) - ->execute(); + $this->view->logs = $this->getD2EM()->getRepository( "\\Entities\\Log" )->loadForLogList( $this->getTargetAdmin(), $this->getDomain() ); } } diff --git a/application/controllers/MailboxController.php b/application/controllers/MailboxController.php index 7c2455c..e9b95ae 100644 --- a/application/controllers/MailboxController.php +++ b/application/controllers/MailboxController.php @@ -7,7 +7,7 @@ * project which provides an easily manageable web based virtual * mailbox administration system. * - * Copyright (c) 2011 Open Source Solutions Limited + * Copyright (c) 2011 - 2014 Open Source Solutions Limited * * ViMbAdmin is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,7 +26,7 @@ * 147 Stepaside Park, Stepaside, Dublin 18, Ireland. * Barry O'Donovan * - * @copyright Copyright (c) 2011 Open Source Solutions Limited + * @copyright Copyright (c) 2011 - 2014 Open Source Solutions Limited * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License, version 3 (GPLv3) * @author Open Source Solutions Limited * @author Barry O'Donovan @@ -37,11 +37,17 @@ * The mailbox controller. * * @package ViMbAdmin - * @subpackage Controllers + * @subpackage Controllers` */ -class MailboxController extends ViMbAdmin_Controller_Action +class MailboxController extends ViMbAdmin_Controller_PluginAction { + /** + * Local store for the form + * @var ViMbAdmin_Form_Mailbox_AddEdit + */ + private $mailboxForm = null; + /** * Most actions in this object will require a domain object to edit / act on. * @@ -53,19 +59,22 @@ class MailboxController extends ViMbAdmin_Controller_Action */ public function preDispatch() { - if( !$this->_mailbox && !$this->_domain ) + if( $this->getRequest()->getActionName() != 'cli-get-sizes' + && $this->getRequest()->getActionName() != 'cli-delete-pending' + && !$this->getMailbox() && !$this->getDomain() ) $this->authorise(); - // if an ajax request, remove the view help - if( substr( $this->getRequest()->getParam( 'action' ), 0, 4 ) == 'ajax' ) - $this->_helper->viewRenderer->setNoRender( true ); - - if( $this->_getParam( 'unset', false ) ) - unset( $this->_session->domain ); - else + if( $this->getRequest()->getActionName() == "list-search" ||$this->getRequest()->getActionName() == "list" || $this->getRequest()->getActionName() == "index" ) { - if( isset( $this->_session->domain) && $this->_session->domain ) - $this->_domain = $this->_session->domain; + if( $this->getParam( 'unset', false ) ) + unset( $this->getSessionNamespace()->domain ); + else + { + if( isset( $this->getSessionNamespace()->domain ) && $this->getSessionNamespace()->domain ) + $this->_domain = $this->getSessionNamespace()->domain; + else if( $this->getDomain() ) + $this->getSessionNamespace()->domain = $this->getDomain(); + } } } @@ -75,521 +84,648 @@ public function preDispatch() */ public function indexAction() { - $this->_forward( 'list' ); + $this->forward( 'list' ); } /** * Lists all mailboxes available to the admin (superadmin sees all) or to the specified domain. + * + * $this->view->mailbox_actions allow to append mailbox list action buttons. %id% will be replaced by + * mailbox id form the list. below is example array which creates edit mailbox button, and another button + * with drop down options for purge or edit mailbox. Only one drop down button can be defined per button group, + * and it always be appended at the end. + * $actions = [ + * [ //Simple link button + * 'tagName' => 'a', //Mandatory parameter for element type. + * 'href' => OSS_Utils::genUrl( "mailbox", "edit" ) . "/mid/%id%", //Url for action + * 'title' => "Edit", + * 'class' => "btn btn-mini have-tooltip", //Class for css options. + * 'id' => "test-%id%", //If setting id id must have %id% which will be replaced by original mailbox id to avoid same ids. + * 'child' => [ //Mandatory element if is not array it will be shown as text. + * 'tagName' => "i", //Mandatory option if child is array to define element type + * 'class' => "icon-pencil" //Icon class + * ], + * ], + * [ //Drop down button + * 'tagName' => 'span', //Mandatory parameter for element type + * 'title' => "Settings", + * 'class' => "btn btn-mini have-tooltip dropdown-toggle", //Class dropdown-toggle is mandatory for drop down button + * 'data-toggle' => "dropdown", //data-toggle attribute is mandatory for drop down button + * 'id' => "cog-%id%", + * 'style' => "max-height: 15px;", + * 'child' => [ + * 'tagName' => "i", + * 'class' => "icon-cog" + * ], + * 'menu' => [ //menu array is mandatory then defining drop down button + * [ + * 'id' => "menu-edit-%id%", //Not mandatory attribute but if is set %id% should be use to avoid same ids. + * 'text' => " Edit", //Mandatory for display action text + * 'url' => OSS_Utils::genUrl( "mailbox", "edit" ) . "/mid/%id%" //Mandatory to redirect the action. + * ], + * [ 'text' => " Purge", 'url' => OSS_Utils::genUrl( "mailbox", "purge" ) . "/mid/%id%" ], + * ] + * ] + * ]; + * */ public function listAction() { - $query = Doctrine_Query::create() - ->from( 'Mailbox m' ); - - if( !$this->_domain ) + if( isset( $this->_options['defaults']['server_side']['pagination']['enable'] ) && $this->_options['defaults']['server_side']['pagination']['enable'] ) + $this->view->mailboxes = []; + else + $this->view->mailboxes = $this->getD2EM()->getRepository( "\\Entities\\Mailbox" )->loadForMailboxList( $this->getAdmin(), $this->getDomain() ); + + if( isset( $this->_options['defaults']['list_size']['disabled'] ) && !$this->_options['defaults']['list_size']['disabled'] ) { - if( !$this->getAdmin()->isSuper() ) - { - $query - ->leftJoin( 'm.Domain d' ) - ->leftJoin( 'd.DomainAdmin da' ) - ->andWhere( 'da.username = ?', $this->getAdmin()->username ); - } + if( isset( $this->_options['defaults']['list_size']['multiplier'] ) && isset( OSS_Filter_FileSize::$SIZE_MULTIPLIERS[ $this->_options['defaults']['list_size']['multiplier'] ] ) ) + $size_multiplier = $this->_options['defaults']['list_size']['multiplier']; + else + $size_multiplier = OSS_Filter_FileSize::SIZE_KILOBYTES; - $this->view->domain = 0; + $this->view->size_multiplier = $size_multiplier; + $this->view->multiplier = OSS_Filter_FileSize::$SIZE_MULTIPLIERS[ $size_multiplier ]; } + $this->notify( 'mailbox', 'list', 'listPostProcess', $this ); + } + + public function listSearchAction() + { + Zend_Controller_Action_HelperBroker::removeHelper( 'viewRenderer' ); + if( !isset( $this->_options['defaults']['server_side']['pagination']['enable'] ) || !$this->_options['defaults']['server_side']['pagination']['enable'] ) + echo "ko"; else { - $this->view->domain = $this->_session->domain = $this->_domain; - $query->andWhere( 'm.domain = ?', $this->_domain['domain'] ); + $strl_len = isset( $this->_options['defaults']['server_side']['pagination']['min_search_str'] ) ? $this->_options['defaults']['server_side']['pagination']['min_search_str'] : 3; + $search = $this->_getParam( "search", false ); + if( $search && strlen( $search ) >= $strl_len ) + { + $mboxes = $this->getD2EM()->getRepository( "\\Entities\\Mailbox" )->filterForMailboxList( $search, $this->getAdmin(), $this->getDomain() ); + $max_cnt = isset( $this->_options['defaults']['server_side']['pagination']['max_result_cnt'] ) ? $this->_options['defaults']['server_side']['pagination']['max_result_cnt'] : false; + if( $mboxes && ( !$max_cnt || $max_cnt >= count( $mboxes ) ) ) + echo json_encode( $mboxes ); + else + echo "ko"; + } + else + echo "ko"; } - - $this->view->mailboxes = $query->execute(); } - /** - * Toggles the active property of the current mailbox. Prints 'ok' on success or 'ko' otherwise to stdout. + * Instantiate / get the mailbox add-edit form + * @return ViMbAdmin_Form_Mailbox_AddEdit */ - public function ajaxToggleActiveAction() + public function getMailboxForm() { - if( !$this->_mailbox ) - return print 'ko'; + if( $this->mailboxForm == null ) + { + $form = new ViMbAdmin_Form_Mailbox_AddEdit(); - $this->_mailbox['active'] = !$this->_mailbox['active']; - $this->_mailbox->save(); + if( isset( $this->_options['defaults']['quota']['multiplier'] ) ) + $form->setFilterFileSizeMultiplier( $this->_options['defaults']['quota']['multiplier'] ); - LogTable::log( 'MAILBOX_TOGGLE_ACTIVE', - "Set {$this->_mailbox['username']} set " . ( $this->_mailbox['active'] ? '' : 'de' ) . "active", - $this->getAdmin(), $this->_mailbox['domain'] - ); - - return print 'ok'; - } + if( isset( $this->_options['defaults']['mailbox']['min_password_length'] ) ) + $form->setMinPasswordLength( $this->_options['defaults']['mailbox']['min_password_length'] ); + // populate the domain dropdown with the possible domains for this user + $form->getElement( "domain" )->setMultiOptions( + [ "" => "" ] + $this->getD2EM()->getRepository( "\\Entities\\Domain" )->loadForAdminAsArray( $this->getAdmin(), true ) + ); - /** - * Purges a mailbox from the system, with all the related entries in other tables. - */ - public function purgeAction() - { - $this->view->modal = $modal = $this->_getParam( 'modal', false ); + // if we have a default / preferred domain, set it as selected in the form + if( $this->getDomain() ) + $form->getElement( 'domain' )->setValue( $this->getDomain()->getId() ); - if( !$this->_mailbox ) - return $this->_forward( 'list' ); - $this->view->mailboxModel = $this->_mailbox; + if( $this->isEdit() ) + { + $form->removeElement( 'password' ); + $form->removeElement( 'local_part' ); + $form->removeElement( 'domain' ); + } + else + $form->getElement( "quota" )->setValue( 0 ); - $this->view->aliases = Doctrine_Query::create() - ->from( 'Alias a' ) - ->where( 'a.goto = ?', $this->_mailbox['username'] ) - ->andWhere( 'a.address != a.goto' ); + $this->view->form = $this->mailboxForm = $form; - if( !$this->getAdmin()->isSuper() ) - { - $this->view->aliases - ->leftJoin( 'a.Domain d' ) - ->leftJoin( 'd.DomainAdmin da' ) - ->andWhere( 'da.username = ?', $this->getAdmin()->username ); + // call plugins + $this->notify( 'mailbox', 'add', 'formPostProcess', $this ); } - $this->view->aliases = $this->view->aliases->execute(); + return $this->mailboxForm; + } - $this->view->inAliases = Doctrine_Query::create() - ->from( 'Alias a' ) - ->where( 'a.address != a.goto' ) - ->andWhere( 'a.goto != ?', $this->_mailbox['username'] ) - ->andWhere( 'a.goto like ?', '%' . $this->_mailbox['username'] . '%' ); + /** + * Add a mailbox. + */ + public function addAction() + { + if( !$this->getMailbox() ) + { + $this->isEdit = $this->view->isEdit = false; + $form = $this->getMailboxForm(); - if( !$this->getAdmin()->isSuper() ) + $this->_mailbox = new \Entities\Mailbox(); + $this->getD2EM()->persist( $this->getMailbox() ); + } + else { - $this->view->inAliases - ->leftJoin( 'a.Domain d' ) - ->leftJoin( 'd.DomainAdmin da' ) - ->andWhere( 'da.username = ?', $this->getAdmin()->username ); + $this->isEdit = $this->view->isEdit = true; + $this->view->mailbox = $this->getMailbox(); + + $form = $this->getMailboxForm(); + $form->assignEntityToForm( $this->getMailbox(), $this, $this->isEdit() ); } - $this->view->inAliases = $this->view->inAliases->execute(); + $this->view->quota_multiplier = $form->getFilterFileSizeMultiplier(); - if( isset( $_POST['purge'] ) && ( $_POST['purge'] == 'purge' ) ) + if( $this->getDomain() ) { - // this won't delete the alias entry where address == goto - foreach( $this->view->aliases as $oneAlias ) - $oneAlias->delete(); + $this->view->domain = $this->getDomain(); + if( $form->getElement( 'domain' ) ) + $form->getElement( 'domain' )->setValue( $this->getDomain()->getId() ); + } - // this delete fixes issue #3 : https://code.google.com/p/vimbadmin/issues/detail?id=3 + $this->notify( 'mailbox', 'add', 'addPrepare', $this ); - Doctrine_Query::create() - ->delete() - ->from( 'Alias' ) - ->where( 'address = ?', $this->_mailbox['username'] ) - ->execute(); + if( $this->getRequest()->isPost() ) + { + $this->notify( 'mailbox', 'add', 'addPrevalidate', $this ); - foreach( $this->view->inAliases as $key => $oneAlias ) + if( $form->isValid( $_POST ) ) { - $gotoArray = explode( ',', $oneAlias->goto ); + $this->notify( 'mailbox', 'add', 'addPostvalidate', $this ); - foreach( $gotoArray as $key => $item ) + if( !$this->isEdit() ) { - $gotoArray[ $key ] = $item = trim( $item ); + // do we have available mailboxes? + if( !$this->getAdmin()->isSuper() && $this->getDomain->getMaxMailoboxes() != 0 && $this->getDomain()->getMailboxCount() >= $this->getDomain()->getMaxMailboxes() ) + { + $this->addMessage( _( 'You have used all of your allocated mailboxes.' ), OSS_Message::ERROR ); + return; + } - if( ( $item == $this->_mailbox['username'] ) || ( $item == '' ) ) - unset( $gotoArray[ $key ] ); - } + if( !$this->getDomain() || $this->getDomain()->getId() != $form->getElement( 'domain' )->getValue() ) + $this->_domain = $this->loadDomain( $form->getElement( 'domain' )->getValue() ); + + // is the mailbox address valid? + $username = sprintf( "%s@%s", $form->getValue( 'local_part' ), $this->_domain->getDomain() ); + if( !Zend_Validate::is( $username, 'EmailAddress', array( 1, null ) ) ) + { + $form->getElement( 'local_part' )->addError( 'Invalid email address.' ); + return; + } + + // does a mailbox of the same name exist? + if( !$this->getD2EM()->getRepository( "\\Entities\\Mailbox" )->isUnique( $username ) ) + { + $this->addMessage( + _( 'Mailbox already exists for' ) . " {$username}", + OSS_Message::ERROR + ); + return; + } + + $this->getMailbox()->setUsername( $username ); + + $form->assignFormToEntity( $this->getMailbox(), $this, $this->isEdit() ); + + $this->getMailbox()->setDomain( $this->getDomain() ); + $this->getMailbox()->setHomedir( $this->_options['defaults']['mailbox']['homedir'] ); + $this->getMailbox()->setUid( $this->_options['defaults']['mailbox']['uid'] ); + $this->getMailbox()->setGid( $this->_options['defaults']['mailbox']['gid'] ); + $this->getMailbox()->formatHomedir( $this->_options['defaults']['mailbox']['homedir'] ); + $this->getMailbox()->formatMaildir( $this->_options['defaults']['mailbox']['maildir'] ); + $this->getMailbox()->setActive( 1 ); + $this->getMailbox()->setDeletePending( false ); + $this->getMailbox()->setCreated( new \DateTime () ); + + $password = $this->getMailbox()->getPassword(); + $this->getMailbox()->setPassword( + OSS_Auth_Password::hash( + $password, + [ + 'pwhash' => $this->_options['defaults']['mailbox']['password_scheme'], + 'pwsalt' => isset( $this->_options['defaults']['mailbox']['password_salt'] ) + ? $this->_options['defaults']['mailbox']['password_salt'] : null, + 'pwdovecot' => isset( $this->_options['defaults']['mailbox']['dovecot_pw_binary'] ) + ? $this->_options['defaults']['mailbox']['dovecot_pw_binary'] : null, + 'username' => $username + ] + ) + ); + + if( $this->_options['mailboxAliases'] == 1 ) + { + $alias = new \Entities\Alias(); + $alias->setAddress( $this->getMailbox()->getUsername() ); + $alias->setGoto( $this->getMailbox()->getUsername() ); + $alias->setDomain( $this->getDomain() ); + $alias->setActive( 1 ); + $alias->setCreated( new \DateTime () ); + $this->getD2EM()->persist( $alias ); + } + + $this->getDomain()->setMailboxCount( $this->getDomain()->getMailboxCount() + 1 ); - if( sizeof( $gotoArray ) == 0 ) - { - $oneAlias->delete(); } else { - $oneAlias->goto = implode( ',', $gotoArray ); - $oneAlias->save(); + $form->removeElement( "local_part" ); + $form->assignFormToEntity( $this->getMailbox(), $this, $this->isEdit() ); + $this->getMailbox()->setModified( new \DateTime() ); } - } - $domain = $this->_mailbox['domain']; - $this->_mailbox->delete(); + //check quota + if( $this->getDomain()->getMaxQuota() != 0 ) + { + if( $this->getMailbox()->getQuota() <= 0 || $this->getMailbox()->getQuota() > $this->getDomain()->getMaxQuota() ) + { + $this->getMailbox()->setQuota( $this->getDomain()->getQuota() ); + $this->addMessage( + _( "Mailbox quota set to ") . $this->getDomain()->getQuota(), + OSS_Message::ALERT + ); + } + } - LogTable::log( 'MAILBOX_PURGE', - "Purged mailbox and aliases for {$this->_mailbox['username']}", - $this->getAdmin(), $domain - ); + $this->log( + $this->isEdit() ? \Entities\Log::ACTION_MAILBOX_EDIT : \Entities\Log::ACTION_MAILBOX_ADD, + "{$this->getAdmin()->getFormattedName()} " . ( $this->isEdit() ? ' edited' : ' added' ) . " mailbox {$this->getMailbox()->getUsername()}" + ); - $this->addMessage( _( 'You have successfully purged the mailbox.' ), ViMbAdmin_Message::SUCCESS ); + $this->notify( 'mailbox', 'add', 'addPreflush', $this ); + $this->getD2EM()->flush(); + $this->notify( 'mailbox', 'add', 'addPostflush', $this, [ 'options' => $this->_options ] ); - if( !$modal ) - { - $this->_redirect( 'mailbox/list' ); - } - else - { - $this->_helper->viewRenderer->setNoRender( true ); - print "ok"; - } + if( $form->getValue( 'welcome_email' ) ) + { + if( !$this->_sendSettingsEmail( + ( $form->getValue( 'cc_welcome_email' ) ? $form->getValue( 'cc_welcome_email' ) : false ), + $password, true ) + ) + $this->addMessage( _( 'Could not sent welcome email' ), OSS_Message::ALERT ); + } + + if( $this->getParam( "did", false ) ) + $this->getSessionNamespace()->domain = $this->getDomain(); + $this->notify( 'mailbox', 'add', 'addFinish', $this ); + $this->addMessage( _( "You have successfully added/edited the mailbox record." ), OSS_Message::SUCCESS ); + $this->redirect( 'mailbox/list' ); + } } - } + } /** - * Lists the aliases of a mailbox, except the default alias (where address == goto). + * Edit a mailbox. */ - public function aliasesAction() + public function editAction() { - if( !$this->_mailbox ) - return $this->_forward( 'list' ); - - $includeMailboxAliases = $this->_getParam( 'ima', 0 ); - $this->view->includeMailboxAliases = $includeMailboxAliases; - $this->view->mailboxModel = $this->_mailbox; - - $this->view->aliases = Doctrine_Query::create() - ->select( '*' ) - ->from( 'Alias a' ); + $this->forward( 'add' ); + } - if( !$includeMailboxAliases ) - $this->view->aliases->where( 'a.address != a.goto' ); + /** + * Toggles the active property of the current mailbox. Prints 'ok' on success or 'ko' otherwise to stdout. + */ + public function ajaxToggleActiveAction() + { + if( !$this->getMailbox() ) + print 'ko'; - $this->view->aliases - ->andWhere( - '( a.address = ? ) or ( a.goto like ? )', - array( $this->_mailbox['username'], "%{$this->_mailbox['username']}%" ) - ); + $this->getMailbox()->setActive( !$this->getMailbox()->getActive() ); + $this->getMailbox()->setModified( new \DateTime() ); - if( !$this->getAdmin()->isSuper() ) - { - $this->view->aliases - ->leftJoin( 'a.Domain d' ) - ->leftJoin( 'd.DomainAdmin da' ) - ->andWhere( 'da.username = ?', $this->getAdmin()->username ); - } + $this->log( + $this->getMailbox()->getActive() ? \Entities\Log::ACTION_MAILBOX_ACTIVATE : \Entities\Log::ACTION_MAILBOX_DEACTIVATE, + "{$this->getAdmin()->getFormattedName()} " . ( $this->getMailbox()->getActive() ? 'activated' : 'deactivated' ) . " mailbox {$this->getMailbox()->getUsername()}" + ); - $this->view->aliases = $this->view->aliases->fetchArray(); + $this->notify( 'mailbox', 'toggleActive', 'postflush', $this, [ 'active' => $this->getMailbox()->getActive() ] ); + $this->getD2EM()->flush(); + $this->notify( 'mailbox', 'toggleActive', 'postflush', $this, [ 'active' => $this->getMailbox()->getActive() ] ); + print 'ok'; } /** - * Deletes a mailbox alias. Prints 'ok' on success or 'ko' otherwise to stdout. + * Purges a mailbox from the system, with all the related entries in other tables. */ - public function ajaxDeleteAliasAction() + public function purgeAction() { - if( !$this->_mailbox || !$this->_alias ) - return print 'ko'; + if( !$this->getMailbox() ) + return $this->forward( 'list' ); - if( $this->_mailbox['username'] == $this->_alias['goto'] ) + $this->view->mailbox = $this->getMailbox(); + $this->view->aliases = $aliases = $this->getD2EM()->getRepository( "\\Entities\\Alias" )->loadForMailbox( $this->getMailbox(), $this->getAdmin() ); + $this->view->inAliases = $inAliases = $this->getD2EM()->getRepository( "\\Entities\\Alias" )->loadWithMailbox( $this->getMailbox(), $this->getAdmin() ); + + if( isset( $_POST['purge'] ) && ( $_POST['purge'] == 'purge' ) ) { - $this->_alias->delete(); + + $this->notify( 'mailbox', 'purge', 'preRemove', $this ); - LogTable::log( 'ALIAS_DELETE', - "Deleted alias {$this->_alias['address']} -> {$this->_mailbox['username']}", - $this->getAdmin(), $this->_mailbox['domain'] + $this->getD2EM()->getRepository( "\\Entities\\Mailbox" )->purgeMailbox( $this->getMailbox(), $this->getAdmin(), !$this->getParam( 'delete_files', false ) ); + $this->log( + \Entities\Log::ACTION_MAILBOX_PURGE, + "{$this->getAdmin()->getFormattedName()} purged mailbox {$this->getMailbox()->getUsername()}" ); - } - else - { - $gotoArray = explode( ',', $this->_alias->goto ); + + $this->notify( 'mailbox', 'purge', 'preFlush', $this ); - foreach( $gotoArray as $key => $item ) + if( $this->getParam( 'delete_files', false ) ) { - $gotoArray[ $key ] = $item = trim( $item ); - - if( ( $item == $this->_mailbox['username'] ) || ( $item == '' ) ) - unset( $gotoArray[ $key ] ); + $this->getMailbox()->setDeletePending( true ); + $this->getMailbox()->setActive( false ); } + else + $this->getD2EM()->remove( $this->getMailbox() ); - $this->_alias['goto'] = implode( ',', $gotoArray ); - $this->_alias->save(); + $this->getD2EM()->flush(); + $this->notify( 'mailbox', 'purge', 'postFlush', $this ); + + $this->addMessage( _( 'You have successfully purged the mailbox.' ), OSS_Message::SUCCESS ); + $this->_redirect( 'mailbox/list' ); - LogTable::log( 'ALIAS_DELETE', - "Removed destination {$this->_mailbox['username']} from alias {$this->_alias['address']}", - $this->getAdmin(), $this->_mailbox['domain'] - ); } + } - $this->addMessage( _( 'You have successfully removed' ) . " {$this->_mailbox['username']} " . _( 'from the alias.') , ViMbAdmin_Message::SUCCESS ); - return print 'ok'; + /** + * Lists the aliases of a mailbox, except the default alias (where address == goto). + */ + public function aliasesAction() + { + if( !$this->getMailbox() ) + return $this->forward( 'list' ); + + //include maiblox aliases + $this->view->ima = $ima = $this->getParam( 'ima', 0 ); + $this->view->mailbox = $this->getMailbox(); + + $aliases = $this->getD2EM()->getRepository( "\\Entities\\Alias" )->loadForMailbox( $this->getMailbox(), $this->getAdmin(), $ima ); + $inAliases = $this->getD2EM()->getRepository( "\\Entities\\Alias" )->loadWithMailbox( $this->getMailbox(), $this->getAdmin() ); + + $this->view->aliases = array_merge( $aliases, $inAliases ); } /** - * Edit a mailbox. + * Deletes a mailbox alias. Prints 'ok' on success or 'ko' otherwise to stdout. */ - public function editAction() + public function deleteAliasAction() { - $this->view->modal = $modal = $this->_getParam( 'modal', false ); - - $this->view->operation = 'Edit'; - if( !$this->_mailbox ) + if( $this->getMailbox()->getUsername() == $this->getAlias()->getGoto() ) { - $this->_mailbox = new Mailbox(); - $this->view->operation = 'Add'; - } + $this->getD2EM()->remove( $this->getAlias() ); - $this->view->mailboxModel = $this->_mailbox; + $this->log( + \Entities\Log::ACTION_ALIAS_DELETE, + "{$this->getAdmin()->getFormattedName()} removed alias {$this->getAlias()->getAddress()}" + ); + $this->getDomain()->setAliasCount( $this->getDomain()->getAliasCount() -1 ); + $this->addMessage( "You have successfully removed the alias." , OSS_Message::SUCCESS ); + } + else + { + $gotos = explode( ',', $this->getAlias()->getGoto() ); - $domainList = DomainTable::getDomains( $this->getAdmin() ); + if( count( $gotos ) > 0 ) + { + foreach( $gotos as $key => $item ) + { + $gotos[ $key ] = $item = trim( $item ); - if( isset( $this->_options['allow_access_restriction'] ) && $this->_options['allow_access_restriction'] ) - $this->view->editForm = $editForm = new ViMbAdmin_Form_Mailbox_Edit( null, $domainList, $this->_options['defaults']['mailbox']['min_password_length'], $this->_options['allow_access_restriction'], $this->_options['access_restriction_type'] ); - else - $this->view->editForm = $editForm = new ViMbAdmin_Form_Mailbox_Edit( null, $domainList, $this->_options['defaults']['mailbox']['min_password_length'] ); + if( ( $item == $this->getMailbox()->getUsername() ) || ( $item == '' ) ) + unset( $gotos[ $key ] ); + } + $this->log( + \Entities\Log::ACTION_ALIAS_DELETE, + "{$this->getAdmin()->getFormattedName()} removed destination {$this->getMailbox()->getUsername()} from alias {$this->getAlias()->getAddress()}" + ); + $this->getAlias()->setGoto( implode( ',', $gotos ) ); + $this->addMessage( "You have successfully removed {$this->getMailbox()->getUsername()}from the alias {$this->getAlias()->getAddress()}." , OSS_Message::SUCCESS ); + } + else + { + $this->getD2EM()->remove( $this->getAlias() ); + $this->log( + \Entities\Log::ACTION_ALIAS_DELETE, + "{$this->getAdmin()->getFormattedName()} removed alias {$this->getAlias()->getAddress()}" + ); + $this->getDomain()->setAliasCount( $this->getDomain()->getAliasCount() -1 ); + $this->addMessage( "You have successfully removed the alias." , OSS_Message::SUCCESS ); + } + } - $editForm->setDefaults( $this->_mailbox->toArray() ); + $this->getD2EM()->flush(); + $this->redirect( "mailbox/aliases/mid/" . $this->getMailbox()->getId() ); + } - if( $this->_mailbox['id'] ) + public function emailSettingsAction() + { + $form = $this->view->form = new ViMbAdmin_Form_Mailbox_EmailSettings(); + $mailbox = $this->getMailbox( $this->getParam( "mid", false ), false ); + + if( !$mailbox ) { - $editForm->removeElement( 'password' ); - $editForm->getElement( 'local_part' )->setAttrib( 'disabled', 'disabled' )->setRequired( false ); - $editForm->getElement( 'domain' )->setAttrib( 'disabled', 'disabled' )->setRequired( false ); + $this->addMessage( _( 'Unable to load mailbox.' ), OSS_Message::ERROR ); + echo 'error'; + die(); } - - if( $this->getRequest()->isPost() && !$modal ) + $this->view->mailbox = $mailbox; + + $emails = [ 'username' => $mailbox->getUsername() ]; + if( $mailbox->getAltEmail() ) + $emails[ 'alt_email'] = $mailbox->getAltEmail(); + + $emails['other'] = "Other"; + $form->getElement( 'type' )->setMultiOptions( $emails ); + + if( $this->getRequest()->isPost() && $this->getParam( 'send', false )) { - if( $editForm->isValid( $_POST ) ) + $form->isValid( $_POST ); + if( $form->getValue( 'type' ) == 'other' ) + $form->getElement( 'email' )->setRequired( true ); + + $error = false; + if( $form->isValid( $_POST ) ) { - if( isset( $this->_options['allow_access_restriction'] ) && $this->_options['allow_access_restriction'] ) + if( $form->getValue( 'type' ) == 'other' ) { - if( $editForm->getValue( 'access_restr' ) && !isset( $_POST['type'] ) ) + $emails = explode( ",", $form->getValue( 'email' ) ); + $email = []; + foreach( $emails as $em ) { - $editForm->getElement( 'access_restr' )->addError( "You must select type if you allowing access restrictions." ); - if( $this->_mailbox['id'] ) - $editForm->getElement( 'local_part' )->setValue( $this->_mailbox['local_part'] ); - $this->view->restrictions = array(); - - if( $this->_domain ) + if( !Zend_Validate::is( $em, 'EmailAddress', array( 1, null ) ) ) { - $editForm->getElement( 'domain' )->setValue( $this->_domain['id'] ); - $this->view->domain = $this->_domain; + $form->getElement( 'email' )->addError( "Not valid email address(es)" ); + $error = true; + break; } - - if( !$this->_getParam( 'helper', true ) ) - $this->view->modal = true; - - return; + else + $email[] = trim( $em ); } } - - do + else if( $form->getValue( 'type' ) == 'username' ) + $email = $mailbox->getUsername(); + else if( $form->getValue( 'type' ) == 'alt_email' ) + $email = $mailbox->getAltEmail(); + else { - // do we have a domain - if( !$this->_domain ) - { - $this->_domain = Doctrine::getTable( 'Domain' )->find( $editForm->getElement( 'domain' )->getValue() ); - - if( !$this->_domain || !$this->authorise( false, $this->_domain, false ) ) - { - $this->addMessage( _( "Invalid, unauthorised or non-existent domain." ), ViMbAdmin_Message::ERROR ); - $this->_redirect( 'domain/list' ); - } - } - - if( $this->_mailbox['id'] ) - { - $this->_domain = $this->_mailbox->Domain; - - $editForm->removeElement( 'local_part' ); - $editForm->removeElement( 'domain' ); - $editForm->removeElement( 'password' ); - - $this->_mailbox->fromArray( $editForm->getValues() ); - $op = 'edit'; - } + $this->getLogger()->err( "Unknown email type." ); + echo "Unknown email type."; + die(); + } + + if( !$error ) + { + if( $this->_sendSettingsEmail( false, '', false, $email ) ) + $this->addMessage( _( 'Settings email successfully sent' ), OSS_Message::SUCCESS ); else - { - // do we have available mailboxes? - if( !$this->getAdmin()->isSuper() && $this->_domain['mailboxes'] != 0 && $this->_domain->countMailboxes() >= $this->_domain['mailboxes'] ) - { - $this->_helper->viewRenderer->setNoRender( true ); - $this->addMessage( _( 'You have used all of your allocated mailboxes.' ), ViMbAdmin_Message::ERROR ); - break; - } - - $this->_mailbox->fromArray( $editForm->getValues() ); - - $this->_mailbox['domain'] = $this->_domain['domain']; - $this->_mailbox['username'] = "{$this->_mailbox['local_part']}@{$this->_mailbox['domain']}"; - - $this->_mailbox['homedir'] = $this->_options['defaults']['mailbox']['homedir']; - $this->_mailbox['uid'] = $this->_options['defaults']['mailbox']['uid']; - $this->_mailbox['gid'] = $this->_options['defaults']['mailbox']['gid']; - - $this->_mailbox->formatMaildir( $this->_options['defaults']['mailbox']['maildir'] ); - - $plainPassword = $this->_mailbox['password']; - $this->_mailbox->hashPassword( - $this->_options['defaults']['mailbox']['password_scheme'], - $this->_mailbox['password'], - $this->_options['defaults']['mailbox']['password_hash'] - ); - - // is the mailbox address valid? - if( !Zend_Validate::is( "{$this->_mailbox['local_part']}@{$this->_mailbox['domain']}", 'EmailAddress', array( 1, null ) ) ) - { - $editForm->getElement( 'local_part' )->addError( _( 'Invalid email address.' ) ); - break; - } - - - // does a mailbox of the same name exist? - $dup = Doctrine_Query::create() - ->from( 'Mailbox m' ) - ->where( 'm.local_part = ?', $this->_mailbox['local_part'] ) - ->andWhere( 'm.domain = ?', $this->_mailbox['domain'] ) - ->execute( null, Doctrine_Core::HYDRATE_ARRAY ); - - if( count( $dup ) ) - { - $this->addMessage( - _( 'Mailbox already exists for' ) . " {$this->_mailbox['local_part']}@{$this->_mailbox['domain']}", - ViMbAdmin_Message::ERROR - ); - break; - } - - if( $this->_options['mailboxAliases'] == 1 ) - { - $aliasModel = new Alias(); - $aliasModel->address = $this->_mailbox['username']; - $aliasModel->goto = $this->_mailbox['username']; - $aliasModel->domain = $this->_domain['domain']; - $aliasModel->active = 1; - $aliasModel->save(); - } - - $op = 'add'; - } - - // check quota - if( $this->_domain['quota'] != 0 ) - { - if( $this->_mailbox['quota'] <= 0 || ( $this->_domain['maxquota'] != 0 && $this->_mailbox['quota'] > $this->_domain['maxquota'] ) ) - { - if ( $this->_mailbox['quota'] <= 0 ) - { - $this->_mailbox['quota'] = $this->_domain['quota']; - } - else - { - $this->_mailbox['quota'] = $this->_domain['maxquota']; - } - - $this->addMessage( - _("Mailbox quota set to ") . $this->_mailbox['quota'], - ViMbAdmin_Message::ALERT - ); - } - } - + $this->addMessage( _( 'Could not send settings email' ), OSS_Message::ERROR ); + + print "ok"; + die(); + } + } + } + } - if( isset( $this->_options['allow_access_restriction'] ) && $this->_options['allow_access_restriction'] ) + public function cliGetSizesAction() + { + if( !isset( $this->_options['defaults']['list_size']['disabled'] ) || $this->_options['defaults']['list_size']['disabled'] ) + { + $this->getLogger()->info( "MailboxController::cliGetSizesAction: List size option is disabled in application.ini." ); + echo "List size option is disabled in application.ini.\n"; + return; + } + + foreach( $this->getD2EM()->getRepository( "\\Entities\\Domain" )->findAll() as $domain ) + { + $cnt = 0; + + if( $this->getParam( 'verbose' ) ) + echo "Processing {$domain->getDomain()}...\n"; + + foreach( $domain->getMailboxes() as $mailbox ) + { + if( $this->getParam( 'debug' ) ) echo " - {$mailbox->getUsername()}"; + + $msize = OSS_DiskUtils::du( $mailbox->getCleanedMaildir() ); + if( $msize !== false ) + { + if( $this->getParam( 'debug' ) ) echo " [Mail Size: {$msize}]"; + $mailbox->setMaildirSize( $msize ); + $hsize = OSS_DiskUtils::du( $mailbox->getHomedir() ); + if( $hsize !== false ) { - if( $editForm->getValue( 'access_restr' ) ) - $this->_mailbox['access_restriction'] = implode(",", $_POST['type']); - else - $this->_mailbox['access_restriction'] = "ALL"; + $mailbox->setHomedirSize( $hsize - $msize ); + if( $this->getParam( 'debug' ) ) echo " [Home Size: {$hsize}]"; } else - $this->_mailbox['access_restriction'] = "ALL"; + if( $this->getParam( 'debug' ) ) echo " [Unknown Home Size]"; + } + else + { + $mailbox->setMaildirSize( null ); + $mailbox->setHomedirSize( null ); + if( $this->getParam( 'debug' ) ) echo " [Unknown Mail Size]"; + } - $this->_mailbox->save(); + $mailbox->setSizeAt( new \DateTime() ); + + if( $this->getParam( 'debug' ) ) echo "\n"; + + $cnt++; + if( $cnt % 200 == 0) + $this->getD2EM()->flush(); + + } // mailboxes + + $this->getD2EM()->flush(); + + } // domains + } - if( $editForm->getValue( 'welcome_email' ) ) - { - if( !$this->_sendSettingsEmail( - ( $editForm->getValue( 'cc_welcome_email' ) ? $editForm->getValue( 'cc_welcome_email' ) : false ), - $plainPassword, true ) - ) - $this->addMessage( _( 'Could not sent welcome email' ), ViMbAdmin_Message::ALERT ); - } + public function cliDeletePendingAction() + { + $mailboxes = $this->getD2EM()->getRepository( "\\Entities\\Mailbox" )->pendingDelete(); - LogTable::log( 'MAILBOX_' . ( $op == 'add' ? 'ADD' : 'EDIT' ), - print_r( $this->_mailbox->toArray(), true ), - $this->getAdmin(), $this->_mailbox['domain'] - ); + if( !count( $mailboxes ) ) + { + if( $this->getParam( 'verbose' ) ) echo "No mailboxes pending deleteion\n"; + return; + } - $this->addMessage( _( "You have successfully added/edited the mailbox record." ), ViMbAdmin_Message::SUCCESS ); + if( $this->getParam( 'verbose' ) ) echo "Deleting " . count( $mailboxes ) . " mailboxes:\n"; - if( $this->_getParam( 'helper', true ) ) - { - if( $this->_domain ) - $this->_redirect( 'mailbox/list/did/' . $this->_domain['id'] ); - else - $this->_redirect( 'mailbox/list' ); - } - else - { - $this->_helper->viewRenderer->setNoRender( true ); - print "ok"; - return; - } + foreach( $mailboxes as $mailbox ) + { + if( $this->getParam( 'verbose' ) ) echo " - " . $mailbox->getUsername() . "... "; + + $homedir = $mailbox->getHomedir(); + $maildir = $mailbox->getCleanedMaildir(); - }while( false ); // break-able clause - } - else + if( !isset( $this->_options['binary']['path']['rm_rf'] ) ) { - $this->view->restrictions = $_POST["type"]; - if( !$this->_getParam( 'helper', true ) ) - $this->view->modal = true; + echo "ERROR: Deleting mailboxes - you must set 'binary.path.rm_rf' in application.ini\n"; + continue; } - } - - if( $this->_domain ) - { - $editForm->getElement( 'domain' )->setValue( $this->_domain['id'] ); - $this->view->domain = $this->_domain; - } - if( isset( $this->_options['allow_access_restriction'] ) && $this->_options['allow_access_restriction'] ) - if( $this->_mailbox && $this->_mailbox['access_restriction'] != "ALL" && $this->_mailbox['access_restriction'] != "BOTH" ) + foreach( [ $maildir, $homedir ] as $dir ) { - $editForm->getElement( 'access_restr' )->setAttrib( "checked", "checked" ); - - if( strpos( $this->_mailbox['access_restriction'], "," ) ) - $this->view->restrictions = explode( ",", $this->_mailbox['access_restriction'] ); - else - $this->view->restrictions = array( $this->_mailbox['access_restriction'] ); + $command = sprintf( "%s %s", $this->_options['binary']['path']['rm_rf'], $dir ); + if( file_exists( $dir ) ) + { + exec( $command, $output, $result ); + if( $result !== 0 ) + echo "ERROR: Could not delete $dir when deleting mailbox " . $mailbox->getUsername() . "\n"; + } } + + $this->getD2EM()->remove( $mailbox ); + $this->getD2EM()->flush(); + if( $this->getParam( 'verbose' ) ) echo "DONE\n"; + } } - - public function emailSettingsAction() - { - if( $this->_mailbox ) - { - if( $this->_sendSettingsEmail() ) - $this->addMessage( _( 'Settings email successfully sent' ), ViMbAdmin_Message::SUCCESS ); - else - $this->addMessage( _( 'Could not send settings email' ), ViMbAdmin_Message::ERROR ); - } - - $this->_redirect( 'mailbox/list' ); - } - - - private function _sendSettingsEmail( $cc = false, $password = '', $isWelcome = false ) + /** + * Sends email with settings + * + * Send Email with settings for $this->_mailbox. + * If cc is set When additional email is set, then it sends additional emails to cc. + * If password is set, then password is shown in email. + * if isWelcome is set to true, adding welcome subject and welcome text to email. + * + * @param bool $cc Additional email. + * @param string $password Password to send for mailbox owner + * @param bool $isWelcome Defines email is welcome email or not. + * @return bool + */ + private function _sendSettingsEmail( $cc = false, $password = '', $isWelcome = false, $email = false ) { - $mailer = new Zend_Mail( 'UTF-8' ); - + $mailer = $this->getMailer(); + if( $isWelcome ) - $mailer->setSubject( _( "Welcome to your new mailbox on" ) . " {$this->_mailbox['domain']}" ); + $mailer->setSubject( sprintf( _( "Welcome to your new mailbox on %s" ), $this->getMailbox()->getDomain()->getDomain() ) ); else - $mailer->setSubject( _( "Settings for your mailbox on" ) . " {$this->_mailbox['domain']}" ); - - $mailer->setFrom( - $this->_options['server']['email']['address'], - $this->_options['server']['email']['name'] - ); + $mailer->setSubject( sprintf( _( "Settings for your mailbox on %s" ), $this->getMailbox()->getDomain()->getDomain() ) ); - $mailer->addTo( $this->_mailbox['username'], $this->_mailbox['name'] ); - - if( $cc ) - $mailer->addCc( $cc ); + $mailer->setFrom( $this->_options['server']['email']['address'], $this->_options['server']['email']['name'] ); + + if( !$email ) + $mailer->addTo( $this->getMailbox()->getUsername(), $this->getMailbox()->getName() ); + else + $mailer->addTo( $email ); + + if( $cc ) $mailer->addCc( $cc ); - $this->view->mailbox = $this->_mailbox; + $this->view->mailbox = $this->getMailbox(); $this->view->welcome = $isWelcome; $this->view->password = $password; @@ -597,21 +733,20 @@ private function _sendSettingsEmail( $cc = false, $password = '', $isWelcome = f foreach( $settings as $tech => $params ) foreach( $params as $k => $v ) - $settings[$tech][$k] = Mailbox::substitute( $this->_mailbox['username'], $v ); + $settings[$tech][$k] = \Entities\Mailbox::substitute( $this->getMailbox()->getUsername(), $v ); $this->view->settings = $settings; + $this->notify( 'mailbox', 'sendSettingsEmail', 'preSetBody', $this ); $mailer->setBodyText( $this->view->render( 'mailbox/email/settings.phtml' ) ); - try - { + try { $mailer->send(); - return true; + } catch( Exception $e ) { + return false; } - catch( Exception $e ) - {} - return false; + return true; } /** @@ -619,89 +754,72 @@ private function _sendSettingsEmail( $cc = false, $password = '', $isWelcome = f */ public function passwordAction() { - $this->view->modal = $modal = $this->_getParam( 'modal', false ); - - if( !$this->_mailbox ) + if( !$this->getMailbox() ) { - $this->_helper->viewRenderer->setNoRender( true ); - $this->addMessage( _( 'No mailbox id passed.' ), ViMbAdmin_Message::ERROR ); - return print $this->view->render( 'close_colorbox_reload_parent.phtml' ); + $this->addMessage( _( 'No mailbox id passed.' ), OSS_Message::ERROR ); + $this->redirect( 'list' ); } $this->view->mailbox = $this->_mailbox; - $form = new ViMbAdmin_Form_Admin_Password( $this->_options['defaults']['mailbox']['min_password_length'] ); + $this->view->form = $form = new ViMbAdmin_Form_Admin_Password(); + if( isset( $this->_options['defaults']['mailbox']['min_password_length'] ) ) + $form->setMinPasswordLength( $this->_options['defaults']['mailbox']['min_password_length'] ); - if( $this->getRequest()->isPost() && !$modal ) + if( $this->getRequest()->isPost() && $form->isValid( $_POST ) ) { - if( $form->isValid( $_POST ) ) - { - $plainPassword = $form->getValue( 'password' ); - $this->_mailbox->hashPassword( - $this->_options['defaults']['mailbox']['password_scheme'], - $plainPassword, - $this->_options['defaults']['mailbox']['password_hash'] - ); + $this->notify( 'mailbox', 'password', 'postValidation', $this ); + + $this->getMailbox()->setPassword( + OSS_Auth_Password::hash( + $form->getValue( 'password' ), + [ + 'pwhash' => $this->_options['defaults']['mailbox']['password_scheme'], + 'pwsalt' => isset( $this->_options['defaults']['mailbox']['password_salt'] ) + ? $this->_options['defaults']['mailbox']['password_salt'] : null, + 'pwdovecot' => isset( $this->_options['defaults']['mailbox']['dovecot_pw_binary'] ) + ? $this->_options['defaults']['mailbox']['dovecot_pw_binary'] : null, + 'username' => $this->getMailbox()->getUsername() + ] + ) + ); - $this->_mailbox->save(); + $this->log( + \Entities\Log::ACTION_MAILBOX_PW_CHANGE, + "{$this->getAdmin()->getFormattedName()} changed password for mailbox {$this->getMailbox()->getUsername()}" + ); - if( $form->getValue( 'email' ) ) - { - $mailer = new Zend_Mail( 'UTF-8' ); - $mailer->setSubject( _( 'New Password for ' . $this->_mailbox['username'] ) ); - $mailer->setFrom( $this->_options['server']['email']['address'], $this->_options['server']['email']['name'] ); - $mailer->addTo( $this->_mailbox['username'], $this->_mailbox['name'] ); - $this->view->newPassword = $form->getValue( 'password' ); - $mailer->setBodyText( $this->view->render( 'mailbox/email/change_password.phtml' ) ); + $this->notify( 'mailbox', 'password', 'preFlush', $this ); + $this->getD2EM()->flush(); + $this->notify( 'mailbox', 'password', 'postFlush', $this, [ 'options' => $this->_options ] ); - try - { - $mailer->send(); - } - catch( Zend_Mail_Exception $vException ) - { - $this->getLogger()->debug( $vException->getTraceAsString() ); - $this->addMessage( _( 'Could not send email.' ), ViMbAdmin_Message::ALERT ); - if( $this->_getParam( 'helper', true ) ) - { - $this->_redirect( 'mailbox/list' ); - } - else - { - $this->_helper->viewRenderer->setNoRender( true ); - print "ok"; - } - } - } - - LogTable::log( 'MAILBOX_PW_CHANGE', - "Changed password for {$this->_mailbox['username']}", - $this->getAdmin(), $this->_mailbox['domain'] - ); + if( $form->getValue( 'email' ) ) + { + $mailer = $this->getMailer(); + $mailer->setSubject( _( 'New Password for ' . $this->getMailbox()->getUsername() ) ); + $mailer->setFrom( $this->_options['server']['email']['address'], $this->_options['server']['email']['name'] ); + $mailer->addTo( $this->getMailbox()->getUsername(), $this->getMailbox()->getName() ); + $this->view->admin = $this->getAdmin(); + $this->view->newPassword = $form->getValue( 'password' ); + $mailer->setBodyText( $this->view->render( 'mailbox/email/change_password.phtml' ) ); - $this->addMessage( _( "Password has been sucessfully changed." ), ViMbAdmin_Message::SUCCESS ); - if( $this->_getParam( 'helper', true ) ) - { - $this->_redirect( 'mailbox/list' ); - } - else + try { - $this->_helper->viewRenderer->setNoRender( true ); - print "ok"; + $mailer->send(); } - } - else - { - if( !$this->_getParam( 'helper', true ) ) + catch( Zend_Mail_Exception $vException ) { - $this->view->modal = true; + $this->getLogger()->debug( $vException->getTraceAsString() ); + $this->addMessage( _( 'Could not send email.' ), OSS_Message::ALERT ); + $this->_redirect( 'mailbox/list' ); } } - } - $this->view->form = $form; + $this->addMessage( _( "Password has been sucessfully changed." ), OSS_Message::SUCCESS ); + $this->_redirect( 'mailbox/list' ); + } } } diff --git a/application/controllers/TestController.php b/application/controllers/TestController.php index b157a19..760809b 100644 --- a/application/controllers/TestController.php +++ b/application/controllers/TestController.php @@ -47,6 +47,8 @@ class TestController extends ViMbAdmin_Controller_Action */ public function indexAction() { + //var_dump( $this->getResource( 'Doctrine2' )->getConnection()->fetchAssoc( 'select * from Admin where id = 10' ) ); + //die(); } } diff --git a/application/models/Admin.php b/application/models/Admin.php deleted file mode 100644 index 8df16bb..0000000 --- a/application/models/Admin.php +++ /dev/null @@ -1,87 +0,0 @@ -. - * - * Open Source Solutions Limited T/A Open Solutions - * 147 Stepaside Park, Stepaside, Dublin 18, Ireland. - * Barry O'Donovan - * - * @copyright Copyright (c) 2011 Open Source Solutions Limited - * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License, version 3 (GPLv3) - * @author Open Source Solutions Limited - * @author Barry O'Donovan - * @author Roland Huszti - */ - -/** - * @package ViMbAdmin - * @subpackage Models - */ -class Admin extends BaseAdmin -{ - - /** - * Is this a super administrator? - * - * @param void - * @return boolean TRUE if the user is a super administrator, FALSE otherwise - */ - public function isSuper() - { - return (boolean) $this->super; - } - - - /** - * Sets the admin password and optionally saves it to the database. - * - * @param string $password the password - * @param string $salt default '' a random security salt to prevent dictionary lookups of the hashed value - * @param boolean $save default false set to true if you want to update the database - * @return object Admin returns a reference to this object for method chaining. - */ - public function setPassword( $password, $salt = '', $save = false ) - { - $this->password = AdminTable::hashPassword( $password, $salt ); - - if ( $save ) $this->save(); - - return $this; - } - - /** - * Cheks the admin password and returns true if it is correct and false if it is bad. - * - * @param string $password the password - * @param string $salt default '' a random security salt to prevent dictionary lookups of the hashed value - * @return boolean. - */ - public function checkPassword( $password, $salt = '' ) - { - if( $this->password == AdminTable::hashPassword( $password, $salt ) ) - return true; - else - return false; - } - -} diff --git a/application/models/AdminTable.php b/application/models/AdminTable.php deleted file mode 100644 index 3d89d86..0000000 --- a/application/models/AdminTable.php +++ /dev/null @@ -1,95 +0,0 @@ -. - * - * Open Source Solutions Limited T/A Open Solutions - * 147 Stepaside Park, Stepaside, Dublin 18, Ireland. - * Barry O'Donovan - * - * @copyright Copyright (c) 2011 Open Source Solutions Limited - * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License, version 3 (GPLv3) - * @author Open Source Solutions Limited - * @author Barry O'Donovan - * @author Roland Huszti - */ - -/** - * @package ViMbAdmin - * @subpackage Models - */ -class AdminTable extends Doctrine_Table -{ - - /** - * Returns an instance of this class. - * - * @return object AdminTable - */ - public static function getInstance() - { - return Doctrine_Core::getTable( 'Admin' ); - } - - - /** - * Hashes and salts a password. - * - * @param string $password the password to hash - * @param string $salt default '' the salt to use - * @return string the hashed and salted password - */ - public static function hashPassword( $password, $salt = '' ) - { - return sha1( $password . $salt ); - } - - - /** - * Returns with the number of admins. - * - * @param void - * @return int - */ - public static function getCount() - { - $retVal = Doctrine_Query::create() - ->select( 'count(*) as howmany' ) - ->from( 'Admin' ) - ->fetchArray(); - - return (int) $retVal[0]['howmany']; - } - - - /** - * Returns with boolean true if the Admin table is empty, otherwise with false. - * - * @param void - * @return boolean - */ - public static function isEmpty() - { - return ( self::getCount() == 0 ); - } - -} diff --git a/application/models/Alias.php b/application/models/Alias.php deleted file mode 100644 index f9c5174..0000000 --- a/application/models/Alias.php +++ /dev/null @@ -1,43 +0,0 @@ -. - * - * Open Source Solutions Limited T/A Open Solutions - * 147 Stepaside Park, Stepaside, Dublin 18, Ireland. - * Barry O'Donovan - * - * @copyright Copyright (c) 2011 Open Source Solutions Limited - * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License, version 3 (GPLv3) - * @author Open Source Solutions Limited - * @author Barry O'Donovan - * @author Roland Huszti - */ - -/** - * @package ViMbAdmin - * @subpackage Models - */ -class Alias extends BaseAlias -{ - -} diff --git a/application/models/Config.php b/application/models/Config.php deleted file mode 100644 index 2c50877..0000000 --- a/application/models/Config.php +++ /dev/null @@ -1,43 +0,0 @@ -. - * - * Open Source Solutions Limited T/A Open Solutions - * 147 Stepaside Park, Stepaside, Dublin 18, Ireland. - * Barry O'Donovan - * - * @copyright Copyright (c) 2011 Open Source Solutions Limited - * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License, version 3 (GPLv3) - * @author Open Source Solutions Limited - * @author Barry O'Donovan - * @author Roland Huszti - */ - -/** - * @package ViMbAdmin - * @subpackage Models - */ -class Config extends BaseConfig -{ - -} diff --git a/application/models/ConfigTable.php b/application/models/ConfigTable.php deleted file mode 100644 index 772e3fa..0000000 --- a/application/models/ConfigTable.php +++ /dev/null @@ -1,106 +0,0 @@ -. - * - * Open Source Solutions Limited T/A Open Solutions - * 147 Stepaside Park, Stepaside, Dublin 18, Ireland. - * Barry O'Donovan - * - * @copyright Copyright (c) 2011 Open Source Solutions Limited - * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License, version 3 (GPLv3) - * @author Open Source Solutions Limited - * @author Barry O'Donovan - * @author Roland Huszti - */ - -/** - * @package ViMbAdmin - * @subpackage Models - */ -class ConfigTable extends Doctrine_Table -{ - - /** - * Returns an instance of this class. - * - * @param void - * @return object ConfigTable - */ - public static function getInstance() - { - return Doctrine_Core::getTable( 'Config' ); - } - - - /** - * Get a value for a key / value pair from the config table - * - * @param string $name The key of the value to load - * @return string|boolean The value or false if it does not exist - */ - public static function getValue( $name ) - { - $a = Doctrine_Query::create() - ->from( 'Config c' ) - ->select( 'c.value' ) - ->where( 'c.name = ?', $name ) - ->execute( null, Doctrine_Core::HYDRATE_SINGLE_SCALAR ); - - if( count( $a ) ) - return $a; - - return false; - } - - - /** - * Creates or updates a key-value pair in the config table. - * - * @param string $name the key - * @param string $value the value - * @return void - */ - public static function setValue( $name, $value ) - { - $model = new Config(); - $model->name = $name; - $model->value = $value; - $model->replace(); - } - - - /** - * Deletes a given key from the config table. - * - * @param string $name The key to delete - * @return void - */ - public static function clearValue( string $name ) - { - Doctrine_Query::create() - ->delete( 'Config c' ) - ->where( 'c.name = ?', $name ) - ->execute(); - } - -} diff --git a/application/models/Domain.php b/application/models/Domain.php deleted file mode 100644 index e458d39..0000000 --- a/application/models/Domain.php +++ /dev/null @@ -1,100 +0,0 @@ -. - * - * Open Source Solutions Limited T/A Open Solutions - * 147 Stepaside Park, Stepaside, Dublin 18, Ireland. - * Barry O'Donovan - * - * @copyright Copyright (c) 2011 Open Source Solutions Limited - * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License, version 3 (GPLv3) - * @author Open Source Solutions Limited - * @author Barry O'Donovan - * @author Roland Huszti - */ - -/** - * @package ViMbAdmin - * @subpackage Models - */ -class Domain extends BaseDomain -{ - - /** - * Count the number of aliases this domain has - * - * @param boolean $excludeMailboxAliases Defaults to true. Excludes aliases where address == goto from mailboxes. - * @return int The number of mailboxes - */ - public function countAliases( $excludeMailboxAliases = true ) - { - $q = Doctrine_Query::create() - ->select( 'count(domain)' ) - ->from( 'Alias' ) - ->where( 'domain = ?', $this['domain'] ); - - if( $excludeMailboxAliases ) - $q->andWhere( 'address != goto' ); - - return $q->execute( null, Doctrine_Core::HYDRATE_SINGLE_SCALAR ); - } - - - /** - * Count the number of mailboxes this domain has - * - * @param void - * @return int The number of mailboxes - */ - public function countMailboxes() - { - return Doctrine_Query::create() - ->select( 'count(domain)' ) - ->from( 'Mailbox' ) - ->where( 'domain = ?', $this['domain'] ) - ->execute( null, Doctrine_Core::HYDRATE_SINGLE_SCALAR ); - } - - - /** - * Adds an admin to the domain, and returns with new DomainAdmin object. - * - * @param int $adminId - * @return object DomainAdmin - */ - public function addAdmin( $admin ) - { - if( ( $admin instanceof Admin ) && $admin->id ) - $adminUsername = $admin->username; - else - $adminUsername = Doctrine::getTable( 'Admin' )->find( $admin )->rawGet( 'username' ); - - $model = new DomainAdmin; - $model->username = $adminUsername; - $model->domain = $this->domain; - $model->save(); - - return $model; - } - -} diff --git a/application/models/DomainAdmin.php b/application/models/DomainAdmin.php deleted file mode 100644 index db152da..0000000 --- a/application/models/DomainAdmin.php +++ /dev/null @@ -1,43 +0,0 @@ -. - * - * Open Source Solutions Limited T/A Open Solutions - * 147 Stepaside Park, Stepaside, Dublin 18, Ireland. - * Barry O'Donovan - * - * @copyright Copyright (c) 2011 Open Source Solutions Limited - * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License, version 3 (GPLv3) - * @author Open Source Solutions Limited - * @author Barry O'Donovan - * @author Roland Huszti - */ - -/** - * @package ViMbAdmin - * @subpackage Models - */ -class DomainAdmin extends BaseDomainAdmin -{ - -} diff --git a/application/models/DomainAdminTable.php b/application/models/DomainAdminTable.php deleted file mode 100644 index 3119d3c..0000000 --- a/application/models/DomainAdminTable.php +++ /dev/null @@ -1,84 +0,0 @@ -. - * - * Open Source Solutions Limited T/A Open Solutions - * 147 Stepaside Park, Stepaside, Dublin 18, Ireland. - * Barry O'Donovan - * - * @copyright Copyright (c) 2011 Open Source Solutions Limited - * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License, version 3 (GPLv3) - * @author Open Source Solutions Limited - * @author Barry O'Donovan - * @author Roland Huszti - */ - -/** - * @package ViMbAdmin - * @subpackage Models - */ -class DomainAdminTable extends Doctrine_Table -{ - - /** - * Returns an instance of this class. - * - * @return object DomainAdminTable - */ - public static function getInstance() - { - return Doctrine_Core::getTable( 'DomainAdmin' ); - } - - - /** - * Get a list of domain IDs that an admin user is allowed to edit - * - * @param Admin|int The admin object or id to get the domains for. - * @return array An array of domain names - */ - public static function getAllowedDomains( $admin = null ) - { - if( ctype_digit( $admin ) && $admin ) - $admin = Doctrine_Core::getTable( 'Admin' )->find( $admin ); - - if( $admin instanceof Admin && $admin['id'] ) - $adminUsername = $admin['username']; - else - return array(); - - $domainAdmins = Doctrine_Query::create() - ->select( 'domain' ) - ->from( 'DomainAdmin' ) - ->where( 'username = ?', $adminUsername ) - ->fetchArray(); - - $domains = array(); - - foreach( $domainAdmins as $item ) - $domains[] = $item['domain']; - - return $domains; - } - -} diff --git a/application/models/DomainTable.php b/application/models/DomainTable.php deleted file mode 100644 index 159e820..0000000 --- a/application/models/DomainTable.php +++ /dev/null @@ -1,104 +0,0 @@ -. - * - * Open Source Solutions Limited T/A Open Solutions - * 147 Stepaside Park, Stepaside, Dublin 18, Ireland. - * Barry O'Donovan - * - * @copyright Copyright (c) 2011 Open Source Solutions Limited - * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License, version 3 (GPLv3) - * @author Open Source Solutions Limited - * @author Barry O'Donovan - * @author Roland Huszti - */ - -/** - * @package ViMbAdmin - * @subpackage Models - */ -class DomainTable extends Doctrine_Table -{ - - /** - * Returns an instance of this class. - * - * @param void - * @return object DomainTable - */ - public static function getInstance() - { - return Doctrine_Core::getTable( 'Domain' ); - } - - - /** - * Returns with the domain, or with NULL if no record found. - * - * @param int $id - * @return null|string - */ - public static function getDomain( $id ) - { - $model = Doctrine::getTable( 'Domain' )->find( $id ); - - return ( $model ? $model->domain : null ); - } - - - /** - * Returns with a list of domains available to the admin, as array( id -> domain, ... ) - * - * @param object Admin - * @return array - */ - public static function getDomains( $admin ) - { - if( $admin->isSuper() ) - { - $tempDomainList = Doctrine_Query::create() - ->from( 'Domain' ) - ->orderBy( 'domain ASC' ) - ->fetchArray(); - } - else - { - $tempDomainList = Doctrine_Query::create() - ->select( 'd.*' ) - ->from( 'Domain d' ) - ->leftJoin( 'DomainAdmin da' ) - ->where( 'da.domain = d.domain' ) - ->andWhere( 'da.username = ?', $admin['username'] ) - ->orderBy( 'd.domain ASC' ) - ->fetchArray(); - } - - $domainList = array(); - - foreach( $tempDomainList as $oneDomain ) - $domainList[ $oneDomain['id'] ] = $oneDomain['domain']; - - return $domainList; - } - -} diff --git a/application/models/Log.php b/application/models/Log.php deleted file mode 100644 index 67c4b70..0000000 --- a/application/models/Log.php +++ /dev/null @@ -1,42 +0,0 @@ -. - * - * Open Source Solutions Limited T/A Open Solutions - * 147 Stepaside Park, Stepaside, Dublin 18, Ireland. - * Barry O'Donovan - * - * @copyright Copyright (c) 2011 Open Source Solutions Limited - * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License, version 3 (GPLv3) - * @author Open Source Solutions Limited - * @author Barry O'Donovan - * @author Roland Huszti - */ - -/** - * @package ViMbAdmin - * @subpackage Models - */ -class Log extends BaseLog -{ -} diff --git a/application/models/LogTable.php b/application/models/LogTable.php deleted file mode 100644 index e4029fa..0000000 --- a/application/models/LogTable.php +++ /dev/null @@ -1,75 +0,0 @@ -. - * - * Open Source Solutions Limited T/A Open Solutions - * 147 Stepaside Park, Stepaside, Dublin 18, Ireland. - * Barry O'Donovan - * - * @copyright Copyright (c) 2011 Open Source Solutions Limited - * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License, version 3 (GPLv3) - * @author Open Source Solutions Limited - * @author Barry O'Donovan - * @author Roland Huszti - */ - -/** - * @package ViMbAdmin - * @subpackage Models - */ -class LogTable extends Doctrine_Table -{ - - /** - * Returns an instance of this class. - * - * @return object LogTable - */ - public static function getInstance() - { - return Doctrine_Core::getTable( 'Log' ); - } - - - /** - * Add a new log entry - */ - public static function log( $action, $data = '', $username = null, $domain = null ) - { - $log = new Log(); - $log['action'] = $action; - $log['data'] = $data; - - if( $domain instanceof Domain ) - $log['domain'] = $domain['domain']; - else if( is_string( $domain ) && strlen( $domain ) ) - $log['domain'] = $domain; - - if( $username instanceof Admin ) - $log['username'] = $username['username']; - else if( is_string( $username ) && strlen( $username ) ) - $log['username'] = $username; - - $log->save(); - } -} diff --git a/application/models/Mailbox.php b/application/models/Mailbox.php deleted file mode 100644 index 2c16ce3..0000000 --- a/application/models/Mailbox.php +++ /dev/null @@ -1,177 +0,0 @@ -. - * - * Open Source Solutions Limited T/A Open Solutions - * 147 Stepaside Park, Stepaside, Dublin 18, Ireland. - * Barry O'Donovan - * - * @copyright Copyright (c) 2011 Open Source Solutions Limited - * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License, version 3 (GPLv3) - * @author Open Source Solutions Limited - * @author Barry O'Donovan - * @author Roland Huszti - */ - -/** - * @package ViMbAdmin - * @subpackage Models - */ -class Mailbox extends BaseMailbox -{ - /** - * Set the maildir - * - * Replaces the following characters in the $maildir parameter: - * - * %u - the local part of the username (email address) - * %d - the domain part of the username (email address) - * %m - the username (email address) - * - * @param string $maildir The maildir format - * @return string The newly created maildir (also set in the object) - */ - public function formatMaildir( $maildir = '' ) - { - $this['maildir'] = self::substitute( $this['username'], $maildir ); - return $this['maildir']; - } - - /** - * Replaces the following characters in the $str parameter: - * - * %u - the local part of the username (email address) - * %d - the domain part of the username (email address) - * %m - the username (email address) - * - * @param string $email An email address used to extract the domain name - * @param string $str The format string - * @return string The newly created maildir (also set in the object) - */ - public static function substitute( $email, $str ) - { - list( $un, $dn ) = explode( '@', $email ); - - $str = str_replace ( '%u', $un, $str ); - $str = str_replace ( '%d', $dn, $str ); - $str = str_replace ( '%m', $email, $str ); - - return $str; - } - - /** - * Set the password using appropriate hash - * - * @param string $scheme The hashing scheme - * @param string $password The password to hash - * @param string $salt The salt to use. Default: none - * @return string The newly hashed password (also set on object) - */ - public function hashPassword( $scheme, $password, $salt = '' ) - { - if( substr( $scheme, 0, 8 ) == 'dovecot:' ) - { - $this['password'] = ViMbAdmin_Dovecot::password( substr( $scheme, 8 ), $password, $this['username'] ); - } - else if ( substr( $scheme, 0, 6) == 'crypt:' ) - { - $indicator = ''; - $salt_len = 2; - switch ($scheme) - { - case 'crypt:md5': - $salt_len = 8; - $indicator = '$1$'; - break; - case 'crypt:blowfish': - $salt_len = 22; - $indicator = '$2a$'; - break; - case 'crypt:sha256': - $salt_len = 16; - $indicator = '$5$'; - break; - case 'crypt:sha512': - $salt_len = 16; - $indicator = '$6$'; - break; - } - $seedchars = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; - for ($i = 0; $i < $salt_len ; $i++) { - $salt .= $seedchars[rand(0, 63)]; - } - $this['password'] = crypt( $password, $indicator . $salt ); - } - else - { - switch( $scheme ) - { - case 'md5': - $this['password'] = md5( $password ); - break; - - case 'md5.salted': - $this['password'] = md5( $password . $salt ); - break; - - // MD5 based salted password hash nowadays commonly used in /etc/shadow. - case 'md5.crypt': - if( strlen( $salt ) >= 8 ) - $s = '$1$' . substr( $salt, 0, 8 ) . '$'; - else - throw new ViMbAdmin_Exception( sprintf( _( 'This hashing function requires a hash of at least %d character(s) to be defined in application.ini (defaults.mailbox.password_hash)' ), 8 ) ); - - $this['password'] = crypt( $password, $s ); - break; - - case 'sha1': - $this['password'] = sha1( $password ); - break; - - case 'sha1.salted': - $this['password'] = sha1( $password . $salt ); - break; - - case 'plain': - $this['password'] = $password; - break; - - // Standard DES hash compatible with MySQL ENCRYPT() - case 'crypt': - if( strlen( $salt ) >= 2 ) - $s = substr( $salt, 0, 2 ); - else - throw new ViMbAdmin_Exception( sprintf( _( 'This hashing function requires a hash of at least %d character(s) to be defined in application.ini (defaults.mailbox.password_hash)' ), 2 ) ); - - $this['password'] = crypt( $password, $s ); - break; - - default: - die( 'Invalid password hash scheme in models/Mailbox.php hashPassword()' ); - } - } - - return $this['password']; - } - -} diff --git a/application/models/MigrationVersion.php b/application/models/MigrationVersion.php deleted file mode 100644 index 39b2fa6..0000000 --- a/application/models/MigrationVersion.php +++ /dev/null @@ -1,16 +0,0 @@ - - * @version SVN: $Id: Builder.php 7691 2011-02-04 15:43:29Z jwage $ - */ -class MigrationVersion extends BaseMigrationVersion -{ - -} \ No newline at end of file diff --git a/application/models/MigrationVersionTable.php b/application/models/MigrationVersionTable.php deleted file mode 100644 index a21eb31..0000000 --- a/application/models/MigrationVersionTable.php +++ /dev/null @@ -1,19 +0,0 @@ -. - * - * Open Source Solutions Limited T/A Open Solutions - * 147 Stepaside Park, Stepaside, Dublin 18, Ireland. - * Barry O'Donovan - * - * @copyright Copyright (c) 2011 Open Source Solutions Limited - * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License, version 3 (GPLv3) - * @author Open Source Solutions Limited - * @author Barry O'Donovan - * @author Roland Huszti - */ - -/** - * @package ViMbAdmin - * @subpackage Models - */ -class Token extends BaseToken -{ - -} diff --git a/application/models/TokenTable.php b/application/models/TokenTable.php deleted file mode 100644 index ca37b84..0000000 --- a/application/models/TokenTable.php +++ /dev/null @@ -1,113 +0,0 @@ -. - * - * Open Source Solutions Limited T/A Open Solutions - * 147 Stepaside Park, Stepaside, Dublin 18, Ireland. - * Barry O'Donovan - * - * @copyright Copyright (c) 2011 Open Source Solutions Limited - * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License, version 3 (GPLv3) - * @author Open Source Solutions Limited - * @author Barry O'Donovan - * @author Roland Huszti - */ - -/** - * @package ViMbAdmin - * @subpackage Models - */ -class TokenTable extends Doctrine_Table -{ - - /** - * Returns an instance of this class. - * - * @return object TokenTable - */ - public static function getInstance() - { - return Doctrine_Core::getTable( 'Token' ); - } - - - /** - * Creates a random string of a given length from [a-zA-Z0-9], but some letters are excluded - * from the character set: 1, 0, O, I, l - * - * @param int $length default 6 the length of the password to be generated - * @return string the random string - */ - public static function createRandomString( $length = 6 ) - { - $charSet = "abcdefghijkmnopqrstuvwxyz23456789ABCDEFGHJKLMNPQRSTUVWXYZ23456789"; - return substr( str_shuffle( "{$charSet}{$charSet}" ), 0, $length ); - } - - - /** - * Adds a new token to the admin, and returns with the id of the newly created Doctrine model. - * - * @param object $admin an Admin model object - * @param string $tokenType - * @param string $token default null if null then one will be generated - * @param string $rid default null if null then one will be generated - * @return object the new Token model object - */ - public static function addToken( $admin, $tokenType, $token = null, $rid = null ) - { - $model = new Token(); - - $model->username = $admin['username']; - $model->type = $tokenType; - $model->token = ( $token === null ? self::createRandomString() : $token ); - $model->rid = ( $rid === null ? self::createRandomString( 32 ) : $rid ); - - $model->save(); - - return $model; - } - - - /** - * Deletes tokens from the table, and returns with the number of deleted rows. If the $tokenType is null, - * then it will delete all the tokens of the admin, otherwise only the tokes of the specified type. - * - * @param object $admin an Admin object - * @param string $tokenType default null - * @return int - */ - public static function deleteTokens( $admin, $tokenType = null ) - { - $query = Doctrine_Query::create() - ->delete() - ->from( 'Token' ) - ->where('username = ?', $admin['username'] ); - - if( $tokenType !== null ) - $query->addWhere( 'type = ?', $tokenType ); - - return $query->execute(); - } - -} diff --git a/application/models/generated/BaseAdmin.php b/application/models/generated/BaseAdmin.php deleted file mode 100644 index 78bd4d1..0000000 --- a/application/models/generated/BaseAdmin.php +++ /dev/null @@ -1,85 +0,0 @@ - - * @version SVN: $Id: Builder.php 7691 2011-02-04 15:43:29Z jwage $ - */ -abstract class BaseAdmin extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->setTableName('admin'); - $this->hasColumn('id', 'integer', null, array( - 'primary' => true, - 'type' => 'integer', - 'autoincrement' => true, - )); - $this->hasColumn('username', 'string', 255, array( - 'unique' => true, - 'type' => 'string', - 'notnull' => true, - 'length' => '255', - )); - $this->hasColumn('password', 'string', 255, array( - 'type' => 'string', - 'notnull' => true, - 'length' => '255', - )); - $this->hasColumn('super', 'boolean', null, array( - 'default' => 0, - 'type' => 'boolean', - )); - $this->hasColumn('active', 'boolean', null, array( - 'default' => 1, - 'type' => 'boolean', - )); - - $this->option('collate', 'utf8_general_ci'); - $this->option('charset', 'utf8'); - } - - public function setUp() - { - parent::setUp(); - $this->hasMany('DomainAdmin', array( - 'local' => 'username', - 'foreign' => 'username')); - - $this->hasMany('Log', array( - 'local' => 'username', - 'foreign' => 'username')); - - $this->hasMany('Token', array( - 'local' => 'username', - 'foreign' => 'username')); - - $timestampable0 = new Doctrine_Template_Timestampable(array( - 'created' => - array( - 'name' => 'created', - 'type' => 'timestamp', - ), - 'updated' => - array( - 'name' => 'modified', - 'type' => 'timestamp', - ), - )); - $this->actAs($timestampable0); - } -} \ No newline at end of file diff --git a/application/models/generated/BaseAlias.php b/application/models/generated/BaseAlias.php deleted file mode 100644 index de890b2..0000000 --- a/application/models/generated/BaseAlias.php +++ /dev/null @@ -1,76 +0,0 @@ - - * @version SVN: $Id: Builder.php 7691 2011-02-04 15:43:29Z jwage $ - */ -abstract class BaseAlias extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->setTableName('alias'); - $this->hasColumn('id', 'integer', null, array( - 'primary' => true, - 'type' => 'integer', - 'autoincrement' => true, - )); - $this->hasColumn('address', 'string', 255, array( - 'unique' => true, - 'type' => 'string', - 'length' => '255', - )); - $this->hasColumn('goto', 'string', 65536, array( - 'type' => 'string', - 'notnull' => true, - 'length' => '65536', - )); - $this->hasColumn('domain', 'string', 255, array( - 'type' => 'string', - 'notnull' => true, - 'length' => '255', - )); - $this->hasColumn('active', 'boolean', null, array( - 'default' => 1, - 'type' => 'boolean', - 'notnull' => true, - )); - - $this->option('collate', 'utf8_general_ci'); - $this->option('charset', 'utf8'); - } - - public function setUp() - { - parent::setUp(); - $this->hasOne('Domain', array( - 'local' => 'domain', - 'foreign' => 'domain')); - - $timestampable0 = new Doctrine_Template_Timestampable(array( - 'created' => - array( - 'name' => 'created', - 'type' => 'timestamp', - ), - 'updated' => - array( - 'name' => 'modified', - 'type' => 'timestamp', - ), - )); - $this->actAs($timestampable0); - } -} \ No newline at end of file diff --git a/application/models/generated/BaseConfig.php b/application/models/generated/BaseConfig.php deleted file mode 100644 index a2fb1fc..0000000 --- a/application/models/generated/BaseConfig.php +++ /dev/null @@ -1,48 +0,0 @@ - - * @version SVN: $Id: Builder.php 7691 2011-02-04 15:43:29Z jwage $ - */ -abstract class BaseConfig extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->setTableName('config'); - $this->hasColumn('id', 'integer', null, array( - 'primary' => true, - 'type' => 'integer', - 'autoincrement' => true, - )); - $this->hasColumn('name', 'string', 255, array( - 'unique' => true, - 'type' => 'string', - 'notnull' => true, - 'length' => '255', - )); - $this->hasColumn('value', 'string', 255, array( - 'type' => 'string', - 'length' => '255', - )); - - $this->option('collate', 'utf8_general_ci'); - $this->option('charset', 'utf8'); - } - - public function setUp() - { - parent::setUp(); - $timestampable0 = new Doctrine_Template_Timestampable(); - $this->actAs($timestampable0); - } -} \ No newline at end of file diff --git a/application/models/generated/BaseDomain.php b/application/models/generated/BaseDomain.php deleted file mode 100644 index d8893fa..0000000 --- a/application/models/generated/BaseDomain.php +++ /dev/null @@ -1,124 +0,0 @@ - - * @version SVN: $Id: Builder.php 7691 2011-02-04 15:43:29Z jwage $ - */ -abstract class BaseDomain extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->setTableName('domain'); - $this->hasColumn('id', 'integer', 255, array( - 'primary' => true, - 'type' => 'integer', - 'autoincrement' => true, - 'length' => '255', - )); - $this->hasColumn('domain', 'string', 255, array( - 'unique' => true, - 'type' => 'string', - 'notnull' => true, - 'length' => '255', - )); - $this->hasColumn('description', 'string', 255, array( - 'type' => 'string', - 'length' => '255', - )); - $this->hasColumn('aliases', 'integer', null, array( - 'default' => 0, - 'type' => 'integer', - 'notnull' => true, - )); - $this->hasColumn('mailboxes', 'integer', null, array( - 'default' => 0, - 'type' => 'integer', - 'notnull' => true, - )); - $this->hasColumn('maxquota', 'integer', 20, array( - 'default' => 0, - 'type' => 'integer', - 'notnull' => true, - 'length' => '20', - )); - $this->hasColumn('quota', 'integer', 20, array( - 'default' => 0, - 'type' => 'integer', - 'notnull' => true, - 'length' => '20', - )); - $this->hasColumn('transport', 'string', 255, array( - 'default' => 'virtual', - 'type' => 'string', - 'notnull' => true, - 'length' => '255', - )); - $this->hasColumn('backupmx', 'boolean', null, array( - 'default' => 0, - 'type' => 'boolean', - 'notnull' => true, - )); - $this->hasColumn('active', 'boolean', null, array( - 'default' => 1, - 'type' => 'boolean', - )); - - $this->option('collate', 'utf8_general_ci'); - $this->option('charset', 'utf8'); - } - - public function setUp() - { - parent::setUp(); - $this->hasMany('DomainAdmin', array( - 'local' => 'domain', - 'foreign' => 'domain')); - - $this->hasMany('Mailbox', array( - 'local' => 'domain', - 'foreign' => 'domain')); - - $this->hasMany('Alias', array( - 'local' => 'domain', - 'foreign' => 'domain')); - - $this->hasMany('Log', array( - 'local' => 'domain', - 'foreign' => 'domain')); - - $timestampable0 = new Doctrine_Template_Timestampable(array( - 'created' => - array( - 'name' => 'created', - 'type' => 'timestamp', - ), - 'updated' => - array( - 'name' => 'modified', - 'type' => 'timestamp', - ), - )); - $this->actAs($timestampable0); - } -} \ No newline at end of file diff --git a/application/models/generated/BaseDomainAdmin.php b/application/models/generated/BaseDomainAdmin.php deleted file mode 100644 index 16fe119..0000000 --- a/application/models/generated/BaseDomainAdmin.php +++ /dev/null @@ -1,68 +0,0 @@ - - * @version SVN: $Id: Builder.php 7691 2011-02-04 15:43:29Z jwage $ - */ -abstract class BaseDomainAdmin extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->setTableName('domain_admin'); - $this->hasColumn('id', 'integer', null, array( - 'primary' => true, - 'type' => 'integer', - 'autoincrement' => true, - )); - $this->hasColumn('username', 'string', 255, array( - 'type' => 'string', - 'notnull' => true, - 'length' => '255', - )); - $this->hasColumn('domain', 'string', 255, array( - 'type' => 'string', - 'notnull' => true, - 'length' => '255', - )); - - $this->option('collate', 'utf8_general_ci'); - $this->option('charset', 'utf8'); - } - - public function setUp() - { - parent::setUp(); - $this->hasOne('Admin', array( - 'local' => 'username', - 'foreign' => 'username')); - - $this->hasOne('Domain', array( - 'local' => 'domain', - 'foreign' => 'domain')); - - $timestampable0 = new Doctrine_Template_Timestampable(array( - 'created' => - array( - 'name' => 'created', - 'type' => 'timestamp', - ), - 'updated' => - array( - 'disabled' => true, - ), - )); - $this->actAs($timestampable0); - } -} \ No newline at end of file diff --git a/application/models/generated/BaseLog.php b/application/models/generated/BaseLog.php deleted file mode 100644 index 8e95b82..0000000 --- a/application/models/generated/BaseLog.php +++ /dev/null @@ -1,78 +0,0 @@ - - * @version SVN: $Id: Builder.php 7691 2011-02-04 15:43:29Z jwage $ - */ -abstract class BaseLog extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->setTableName('log'); - $this->hasColumn('id', 'integer', null, array( - 'primary' => true, - 'type' => 'integer', - 'autoincrement' => true, - )); - $this->hasColumn('username', 'string', 255, array( - 'type' => 'string', - 'length' => '255', - )); - $this->hasColumn('domain', 'string', 255, array( - 'type' => 'string', - 'length' => '255', - )); - $this->hasColumn('action', 'string', 255, array( - 'type' => 'string', - 'notnull' => true, - 'length' => '255', - )); - $this->hasColumn('data', 'string', 65536, array( - 'type' => 'string', - 'notnull' => true, - 'length' => '65536', - )); - - $this->option('collate', 'utf8_general_ci'); - $this->option('charset', 'utf8'); - } - - public function setUp() - { - parent::setUp(); - $this->hasOne('Admin', array( - 'local' => 'username', - 'foreign' => 'username')); - - $this->hasOne('Domain', array( - 'local' => 'domain', - 'foreign' => 'domain')); - - $timestampable0 = new Doctrine_Template_Timestampable(array( - 'created' => - array( - 'name' => 'timestamp', - 'type' => 'timestamp', - ), - 'updated' => - array( - 'disabled' => true, - ), - )); - $this->actAs($timestampable0); - } -} \ No newline at end of file diff --git a/application/models/generated/BaseMailbox.php b/application/models/generated/BaseMailbox.php deleted file mode 100644 index 6881bea..0000000 --- a/application/models/generated/BaseMailbox.php +++ /dev/null @@ -1,125 +0,0 @@ - - * @version SVN: $Id: Builder.php 7691 2011-02-04 15:43:29Z jwage $ - */ -abstract class BaseMailbox extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->setTableName('mailbox'); - $this->hasColumn('id', 'integer', null, array( - 'primary' => true, - 'type' => 'integer', - 'autoincrement' => true, - )); - $this->hasColumn('username', 'string', 255, array( - 'unique' => true, - 'type' => 'string', - 'notnull' => true, - 'length' => '255', - )); - $this->hasColumn('password', 'string', 255, array( - 'type' => 'string', - 'notnull' => true, - 'length' => '255', - )); - $this->hasColumn('name', 'string', 255, array( - 'type' => 'string', - 'length' => '255', - )); - $this->hasColumn('maildir', 'string', 255, array( - 'type' => 'string', - 'length' => '255', - )); - $this->hasColumn('quota', 'integer', 20, array( - 'default' => 0, - 'type' => 'integer', - 'notnull' => true, - 'length' => '20', - )); - $this->hasColumn('local_part', 'string', 255, array( - 'type' => 'string', - 'notnull' => true, - 'length' => '255', - )); - $this->hasColumn('domain', 'string', 255, array( - 'type' => 'string', - 'notnull' => true, - 'length' => '255', - )); - $this->hasColumn('access_restriction', 'enum', null, array( - 'type' => 'enum', - 'values' => - array( - 0 => 'BOTH', - 1 => 'IMAP', - 2 => 'POP3', - ), - 'default' => 'BOTH', - 'notnull' => true, - )); - $this->hasColumn('active', 'boolean', null, array( - 'default' => 1, - 'type' => 'boolean', - 'notnull' => true, - )); - $this->hasColumn('homedir', 'string', 255, array( - 'type' => 'string', - 'length' => '255', - )); - $this->hasColumn('uid', 'integer', null, array( - 'type' => 'integer', - )); - $this->hasColumn('gid', 'integer', null, array( - 'type' => 'integer', - )); - - $this->option('collate', 'utf8_general_ci'); - $this->option('charset', 'utf8'); - } - - public function setUp() - { - parent::setUp(); - $this->hasOne('Domain', array( - 'local' => 'domain', - 'foreign' => 'domain')); - - $timestampable0 = new Doctrine_Template_Timestampable(array( - 'created' => - array( - 'name' => 'created', - 'type' => 'timestamp', - ), - 'updated' => - array( - 'name' => 'modified', - 'type' => 'timestamp', - ), - )); - $this->actAs($timestampable0); - } -} \ No newline at end of file diff --git a/application/models/generated/BaseMigrationVersion.php b/application/models/generated/BaseMigrationVersion.php deleted file mode 100644 index 9724847..0000000 --- a/application/models/generated/BaseMigrationVersion.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @version SVN: $Id: Builder.php 7691 2011-02-04 15:43:29Z jwage $ - */ -abstract class BaseMigrationVersion extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->setTableName('migration_version'); - $this->hasColumn('id', 'integer', 8, array( - 'type' => 'integer', - 'autoincrement' => true, - 'primary' => true, - 'length' => '8', - )); - $this->hasColumn('version', 'integer', 4, array( - 'type' => 'integer', - 'fixed' => 0, - 'unsigned' => false, - 'primary' => false, - 'notnull' => false, - 'autoincrement' => false, - 'length' => '4', - )); - - $this->option('collate', 'utf8_general_ci'); - $this->option('charset', 'utf8'); - } - - public function setUp() - { - parent::setUp(); - - } -} \ No newline at end of file diff --git a/application/models/generated/BaseToken.php b/application/models/generated/BaseToken.php deleted file mode 100644 index ee9c9c1..0000000 --- a/application/models/generated/BaseToken.php +++ /dev/null @@ -1,75 +0,0 @@ - - * @version SVN: $Id: Builder.php 7691 2011-02-04 15:43:29Z jwage $ - */ -abstract class BaseToken extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->setTableName('token'); - $this->hasColumn('id', 'integer', null, array( - 'primary' => true, - 'type' => 'integer', - 'autoincrement' => true, - )); - $this->hasColumn('username', 'string', 255, array( - 'type' => 'string', - 'notnull' => true, - 'length' => '255', - )); - $this->hasColumn('type', 'enum', null, array( - 'type' => 'enum', - 'values' => - array( - 0 => 'PASSWORD_RESET', - 1 => 'DUMMY', - ), - )); - $this->hasColumn('token', 'string', 64, array( - 'type' => 'string', - 'notnull' => false, - 'default' => '', - 'length' => '64', - )); - $this->hasColumn('rid', 'string', 64, array( - 'type' => 'string', - 'notnull' => false, - 'default' => '', - 'length' => '64', - )); - - $this->option('collate', 'utf8_general_ci'); - $this->option('charset', 'utf8'); - } - - public function setUp() - { - parent::setUp(); - $this->hasOne('Admin', array( - 'local' => 'username', - 'foreign' => 'username')); - - $timestampable0 = new Doctrine_Template_Timestampable(array( - 'updated' => - array( - 'disabled' => true, - ), - )); - $this->actAs($timestampable0); - } -} \ No newline at end of file diff --git a/application/modules/.git_hello b/application/modules/.git_hello new file mode 100644 index 0000000..56bd474 --- /dev/null +++ b/application/modules/.git_hello @@ -0,0 +1 @@ +Keep this so Git keeps the directory! diff --git a/application/plugins/AccessPermissions.php b/application/plugins/AccessPermissions.php new file mode 100644 index 0000000..9d08a43 --- /dev/null +++ b/application/plugins/AccessPermissions.php @@ -0,0 +1,93 @@ +. + * + * Open Source Solutions Limited T/A Open Solutions + * 147 Stepaside Park, Stepaside, Dublin 18, Ireland. + * Barry O'Donovan + * + * @copyright Copyright (c) 2011 - 2014 Open Source Solutions Limited + * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License, version 3 (GPLv3) + * @author Open Source Solutions Limited + * @author Barry O'Donovan + */ + +/** + * The AccessPermissions plugin + * + * AccessPermissions were part of the main ViMbAdmin code but I have shunted them to a + * plugin to demonstrate and prove the arcitecture. It's a slight cheat as AccessPermissions + * rely on a specific column in the Mailbox database table which plugins should typically + * avoid. + * + * See https://github.com/opensolutions/ViMbAdmin3/wiki/Plugin-Access-Permissions + * + * @package ViMbAdmin + * @subpackage Plugins + */ +class ViMbAdminPlugin_AccessPermissions extends ViMbAdmin_Plugin implements OSS_Plugin_Observer +{ + + public function __construct( OSS_Controller_Action $controller ) + { + parent::__construct( $controller, get_class() ); + + // no setup tasks are required + // + // typically you might load an config file for example, but as this is a system + // plugin, we can use the main application.ini for that. + } + + public function mailbox_add_formPostProcess( $controller, $params ) + { + $form = $controller->getMailboxForm(); + $mailbox = $controller->getMailbox(); + + $subform = new ViMbAdmin_Form_Mailbox_AccessPermissions(); + + if( $controller->isEdit() ) + $subform->setAccessPermissions( $controller->getOptions()['vimbadmin_plugins']['AccessPermissions']['type'], $mailbox ); + else + $subform->setAccessPermissions( $controller->getOptions()['vimbadmin_plugins']['AccessPermissions']['type'] ); + + $form->addSubForm( $subform, 'pluginsf_AccessPermissions' ); + } + + + public function mailbox_add_addPostvalidate( $controller, $params ) + { + $subform = $controller->getMailboxForm()->getSubform( 'pluginsf_AccessPermissions' ); + + if( $subform->getElement( 'plugin_accessPermissions' )->isChecked() ) + { + $controller->getMailbox()->setAccessRestriction( $subform->getSelectedAccessPermissions() ); + } + else + $controller->getMailbox()->setAccessRestriction( 'ALL' ); + } + + + + +} + diff --git a/application/plugins/AdditionalInfo.php b/application/plugins/AdditionalInfo.php new file mode 100644 index 0000000..3ece830 --- /dev/null +++ b/application/plugins/AdditionalInfo.php @@ -0,0 +1,164 @@ +. + * + * Open Source Solutions Limited T/A Open Solutions + * 147 Stepaside Park, Stepaside, Dublin 18, Ireland. + * Barry O'Donovan + * + * @copyright Copyright (c) 2011 - 2014 Open Source Solutions Limited + * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License, version 3 (GPLv3) + * @author Open Source Solutions Limited + * @author Barry O'Donovan + */ + +/** + * The AdditionalInfo plugin + * + * @package ViMbAdmin + * @subpackage Plugins + */ +class ViMbAdminPlugin_AdditionalInfo extends ViMbAdmin_Plugin implements OSS_Plugin_Observer +{ + + public function __construct( OSS_Controller_Action $controller ) + { + parent::__construct( $controller, get_class() ); + + // no setup tasks are required + // + // typically you might load an config file for example, but as this is a system + // plugin, we can use the main application.ini for that. + } + + /** + * Prepares and adds additional information subform + * + * @param object $controller an OSS_Controller_Action instance + * @param array $params Additional parameters + * @return void + */ + public function mailbox_add_formPostProcess( $controller, $params ) + { + $form = $controller->getMailboxForm(); + $mailbox = $controller->getMailbox(); + $subform = new ViMbAdmin_Form_Mailbox_AdditionalInfo(); + + if( $controller->isEdit() ) + $subform->createElements( $controller->getOptions()['vimbadmin_plugins']['AdditionalInfo']['elements'], $mailbox ); + else + $subform->createElements( $controller->getOptions()['vimbadmin_plugins']['AdditionalInfo']['elements'] ); + + $form->addSubForm( $subform, 'pluginsf_AdditionalInfo' ); + + } + + /** + * Sets additional information as mailbox preferences. + * + * @param object $controller an OSS_Controller_Action instance + * @param array $params Additional parameters + * @return void + */ + public function mailbox_add_addPreflush( $controller, $params ) + { + $form = $controller->getMailboxForm(); + $mailbox = $controller->getMailbox(); + $subform = $form->getSubForm( 'pluginsf_AdditionalInfo' ); + + foreach( $subform->getValues() as $name => $value ) + { + $name = substr( $name, 22 ); + $mailbox->setPreference( 'xpiInfo.' . $name, $value ); + } + $controller->getD2Cache()->delete( 'ViMbAdmin_Plugin_AdditionalInfo_autocomplete_*' ); + } + + /** + * Clears cache for additional Info autocomplete values. + * + * @param object $controller an OSS_Controller_Action instance + * @param array $params Additional parameters + * @return void + */ + public function mailbox_purge_postFlush( $controller, $params ) + { + $controller->getD2Cache()->delete( 'ViMbAdmin_Plugin_AdditionalInfo_autocomplete_*' ); + } + + /** + * Prepares and adds additional information subform + * + * @param object $controller an OSS_Controller_Action instance + * @param array $params Additional parameters + * @return void + */ + public function alias_add_formPostProcess( $controller, $params ) + { + $form = $controller->getAliasForm(); + $alias = $controller->getAlias(); + $subform = new ViMbAdmin_Form_Alias_AdditionalInfo(); + + if( $controller->isEdit() ) + $subform->createElements( $controller->getOptions()['vimbadmin_plugins']['AdditionalInfo']['alias']['elements'], $alias ); + else + $subform->createElements( $controller->getOptions()['vimbadmin_plugins']['AdditionalInfo']['alias']['elements'] ); + + $form->addSubForm( $subform, 'pluginsf_AdditionalInfo' ); + } + + + /** + * Sets additional information as mailbox preferences. + * + * @param object $controller an OSS_Controller_Action instance + * @param array $params Additional parameters + * @return void + */ + public function alias_add_addPreflush( $controller, $params ) + { + $form = $controller->getAliasForm(); + $alias = $controller->getAlias(); + $subform = $form->getSubForm( 'pluginsf_AdditionalInfo' ); + + foreach( $subform->getValues() as $name => $value ) + { + $name = substr( $name, 22 ); + $alias->setPreference( 'xpiInfo.' . $name, $value ); + } + $controller->getD2Cache()->delete( 'ViMbAdmin_Plugin_AdditionalInfo_autocomplete_*' ); + } + + /** + * Clears cache for addintional Info autocomplete values. + * + * @param object $controller an OSS_Controller_Action instance + * @param array $params Additional parameters + * @return void + */ + public function alias_purge_postFlush( $controller, $params ) + { + $controller->getD2Cache()->delete( 'ViMbAdmin_Plugin_AdditionalInfo_autocomplete_*' ); + } +} + diff --git a/application/plugins/DirectoryEntry.php b/application/plugins/DirectoryEntry.php new file mode 100644 index 0000000..2d05778 --- /dev/null +++ b/application/plugins/DirectoryEntry.php @@ -0,0 +1,162 @@ +. + * + * Open Source Solutions Limited T/A Open Solutions + * 147 Stepaside Park, Stepaside, Dublin 18, Ireland. + * Barry O'Donovan + * + * @copyright Copyright (c) 2011 - 2014 Open Source Solutions Limited + * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License, version 3 (GPLv3) + * @author Open Source Solutions Limited + * @author Barry O'Donovan + * @author Roland Huszti + */ + +/** + * The AdditionalInfo plugin + * + * @package ViMbAdmin + * @subpackage Plugins + */ +class ViMbAdminPlugin_DirectoryEntry extends ViMbAdmin_Plugin implements OSS_Plugin_Observer +{ + + public function __construct( OSS_Controller_Action $controller ) + { + parent::__construct( $controller, get_class() ); + + // no setup tasks are required + // + // typically you might load an config file for example, but as this is a system + // plugin, we can use the main application.ini for that. + } + + /** + * Prepares and adds directory entry subform + * + * @param object $controller an OSS_Controller_Action instance + * @param array $params Additional parameters + * @return void + */ + public function mailbox_add_formPostProcess( $controller, $params ) + { + $form = $controller->getMailboxForm(); + $mailbox = $controller->getMailbox(); + $subform = new ViMbAdmin_Form_Mailbox_DirectoryEntry(); + + $disabled = isset( $controller->getOptions()['vimbadmin_plugins']['DirectoryEntry']['disabled_elements'] ) ? + $controller->getOptions()['vimbadmin_plugins']['DirectoryEntry']['disabled_elements'] : + []; + if( isset( $controller->getOptions()['identity']['orgname'] ) ) + $subform->getElement( "plugin_directoryEntry_O" )->setValue( $controller->getOptions()['identity']['orgname'] ); + + if( $controller->isEdit() ) + $subform->prepare( $disabled, $mailbox->getDirectoryEntry() ); + else + $subform->prepare( $disabled ); + + $form->addSubForm( $subform, 'pluginsf_DirectoryEntry' ); + + } + + /** + * Creates/updates directory entry. + * + * @param object $controller an OSS_Controller_Action instance + * @param array $params Additional parameters + * @return void + */ + public function mailbox_add_addPreflush( $controller, $params ) + { + $form = $controller->getMailboxForm(); + $mailbox = $controller->getMailbox(); + $subform = $form->getSubform( 'pluginsf_DirectoryEntry' ); + + if( !$mailbox->getDirectoryEntry() ) + { + $dentry = new \Entities\DirectoryEntry(); + $controller->getD2EM()->persist( $dentry ); + $dentry->setMailbox( $mailbox ); + $dentry->setVimbCreated( new \DateTime() ); + } + else + $dentry = $mailbox->getDirectoryEntry(); + + $dentry->setMail( $mailbox->getUsername() ); + $subform->formToEntity( $dentry ); + $dentry->setVimbUpdate( new \DateTime() ); + } + + /** + * Clears cache for additional Info autocomplete values. + * + * @param object $controller an OSS_Controller_Action instance + * @param array $params Additional parameters + * @return void + */ + public function mailbox_purge_postFlush( $controller, $params ) + { + //$controller->getD2Cache()->delete( 'ViMbAdmin_Plugin_AdditionalInfo_autocomplete_*' ); + } + + + /** + * Deletes the drectory entry + * + * @param object $controller an OSS_Controller_Action instance + * @return void + * @access public + */ + public function mailbox_purge_preFlush( $controller, $params ) + { + $mailbox = $controller->getMailbox(); + + if( $de = $mailbox->getDirectoryEntry() ) + { + $controller->getD2EM()->remove( $de ); + $controller->getD2EM()->flush(); + } + } + + /** + * Deletes the drectory entry when archiving + * + * @param object $controller an OSS_Controller_Action instance + * @return void + * @access public + */ + public function archive_add_preSerialize( $controller, $params ) + { + if( $de = $controller->getMailbox()->getDirectoryEntry() ) + { + + $controller->getD2EM()->remove( $de ); + $controller->getMailbox()->setDirectoryEntry( null ); + $controller->getD2EM()->flush(); + } + } + + +} + diff --git a/application/views/_skins/myskin/footer.phtml b/application/views/_skins/myskin/footer.phtml new file mode 100644 index 0000000..330c69e --- /dev/null +++ b/application/views/_skins/myskin/footer.phtml @@ -0,0 +1,59 @@ + +{* ************************************************************************** + + =============================== + THINKING OF EDITING THE FOOTER? + =============================== + +Open Solutions and our staff have put a lot of time and effort into both +developing this web application and making it fit for public release under +the GPL license. + +As such, we would appreciate and request you leave our copyright message and +link to our site intact in the footer so that we may in some small way +benefit from this application. + +*************************************************************************** *} + +{if !isset($inColorBox) || !$inColorBox} + +

+ + +{/if} + + + + + + diff --git a/application/views/admin/add-domain.phtml b/application/views/admin/add-domain.phtml deleted file mode 100644 index 9a46438..0000000 --- a/application/views/admin/add-domain.phtml +++ /dev/null @@ -1,77 +0,0 @@ -{if !isset( $modal) || !$modal} - {include file="header.phtml"} -
- - {ViMbAdmin_Messages} -{else} - - - {include file="footer.phtml"} -{else} -
- - -{/if} diff --git a/application/views/admin/add.phtml b/application/views/admin/add.phtml index d41d482..62d7149 100644 --- a/application/views/admin/add.phtml +++ b/application/views/admin/add.phtml @@ -1,78 +1,13 @@ -{if !isset( $modal) || !$modal} - {include file="header.phtml"} -
- - {ViMbAdmin_Messages} -{else} - +{tmplinclude file="footer.phtml"} diff --git a/application/views/admin/assign-domain.phtml b/application/views/admin/assign-domain.phtml new file mode 100644 index 0000000..477dc59 --- /dev/null +++ b/application/views/admin/assign-domain.phtml @@ -0,0 +1,14 @@ +{tmplinclude file="header.phtml"} +
+ + {OSS_Message} + + {$form} + {addJSValidator form=$form} + +
+{tmplinclude file="footer.phtml"} diff --git a/application/views/admin/domains.phtml b/application/views/admin/domains.phtml index 274e251..db0a7bc 100644 --- a/application/views/admin/domains.phtml +++ b/application/views/admin/domains.phtml @@ -1,30 +1,25 @@ -{include file="header.phtml"} +{tmplinclude file="header.phtml"}
- {ViMbAdmin_Messages} + {OSS_Message} @@ -35,21 +30,16 @@ -{foreach $domainAdmins as $domainAdmin} - - + {foreach $targetAdmin->getDomains() as $domain} + + -{/foreach} + {/foreach}
{$domainAdmin.Domain.domain}
{$domain->getDomain()}{if !$domain->getActive()} (inactive){/if} - - - - + + +

@@ -61,15 +51,14 @@

Are you sure?

-{include file='admin/js/domains.js'} - + -{include file="footer.phtml"} +{tmplinclude file="footer.phtml"} diff --git a/application/views/admin/email/change_password.phtml b/application/views/admin/email/change_password.phtml index 252d698..8669559 100644 --- a/application/views/admin/email/change_password.phtml +++ b/application/views/admin/email/change_password.phtml @@ -1,6 +1,6 @@ To whom it may concern, -{$identity.admin.username} has changed your password for ViMbAdmin. +{$user->getUsername()} has changed your password for ViMbAdmin. Your new password is: {$newPassword} diff --git a/application/views/admin/email/new_admin.phtml b/application/views/admin/email/new_admin.phtml index 7de930a..be18a5c 100644 --- a/application/views/admin/email/new_admin.phtml +++ b/application/views/admin/email/new_admin.phtml @@ -1,7 +1,6 @@ To whom it may concern, -Your new administrator account on your ViMbAdmin installation -has been created. +Your new administrator account on your ViMbAdmin installation has been created. Your login details are: @@ -12,5 +11,10 @@ You can log into ViMbAdmin by browsing to: {genUrl} + +Plesase ensure you keep up with new release announcements and security issues by subscribing to: + + https://groups.google.com/forum/#!forum/vimbadmin-announce + Kind regards, {$options.server.email.name} diff --git a/application/views/admin/email/setup.phtml b/application/views/admin/email/setup.phtml index 7c2f359..fffeed7 100644 --- a/application/views/admin/email/setup.phtml +++ b/application/views/admin/email/setup.phtml @@ -12,5 +12,11 @@ You can log into ViMbAdmin by browsing to: {genUrl} + +Plesase ensure you keep up with new release announcements and security issues by subscribing to: + + https://groups.google.com/forum/#!forum/vimbadmin-announce + + Kind regards, {$options.server.email.name} diff --git a/application/views/admin/form/edit.phtml b/application/views/admin/form/add-edit.phtml similarity index 91% rename from application/views/admin/form/edit.phtml rename to application/views/admin/form/add-edit.phtml index 501415e..aa90c3d 100644 --- a/application/views/admin/form/edit.phtml +++ b/application/views/admin/form/add-edit.phtml @@ -48,13 +48,13 @@ {if isset( $element->active )} - {include file='form/element-input.phtml' ielement=$element->active} + {include file='form/element-checkbox.phtml' ielement=$element->active} {/if} {if isset( $element->super )} - {include file='form/element-input.phtml' ielement=$element->super} + {include file='form/element-checkbox.phtml' ielement=$element->super} {/if} {if isset( $element->welcome_email )} - {include file='form/element-input.phtml' ielement=$element->welcome_email} + {include file='form/element-checkbox.phtml' ielement=$element->welcome_email} {/if} {if !isset($modal) || !$modal} diff --git a/application/views/admin/form/add-domain.phtml b/application/views/admin/form/assign-domain.phtml similarity index 76% rename from application/views/admin/form/add-domain.phtml rename to application/views/admin/form/assign-domain.phtml index 52c7bc0..16c451b 100644 --- a/application/views/admin/form/add-domain.phtml +++ b/application/views/admin/form/assign-domain.phtml @@ -6,17 +6,14 @@ id="{$element->getId()}" name="{if $element->getName() != ''}{$element->getName()}{else}{$element->getId()}{/if}" {if $element->getAttrib('target')}target="{$element->getAttrib('target')}"{/if} - class="form-horizontal" - style="position: fixed; z-index: 1;"> + class="form-horizontal"> - {include file='form/element-input.phtml' ielement=$element->domain} + {$element->domain} - {if !isset($modal) || !$modal}
- Cancel + Cancel
- {/if} + {/if} +

+ {if $element->password->getMessages()} + {foreach from=$element->password->getMessages() item=messages} + {foreach from=$messages item=msg} + {$msg}
+ {/foreach} + {/foreach} + {/if} +

+ + {if isset($element->email)} {include file='form/element-checkbox.phtml' ielement=$element->email} {/if} {if !isset( $modal) || !$modal} -
- +
+ + Cancel
{/if} diff --git a/application/views/admin/js/domains.js b/application/views/admin/js/domains.js index 9dd96c7..043002f 100644 --- a/application/views/admin/js/domains.js +++ b/application/views/admin/js/domains.js @@ -1,85 +1,51 @@ - +var removeDialog; +var oDataTable; + + +$(document).ready( function() +{ + oDataTable = $( '#list_table' ).dataTable({ + 'fnDrawCallback': function() { + if( vm_prefs['iLength'] != $( "select[name|='list_table_length']" ).val() ) + vm_prefs['iLength'] = $( "select[name|='list_table_length']" ).val(); + + $.jsonCookie( 'vm_prefs', vm_prefs, vm_cookie_options ); + }, + 'iDisplayLength': ( typeof vm_prefs != 'undefined' && 'iLength' in vm_prefs ) + ? parseInt( vm_prefs['iLength'] ) + : {if isset( $options.defaults.table.entries )}{$options.defaults.table.entries}{else}10{/if}, + "sDom": "<'row'<'span6'l><'span6'f>r>t<'row'<'span6'i><'span6'p>>", + "sPaginationType": "bootstrap", + 'aoColumns': [ + null, + { 'bSortable': false, "bSearchable": false } + ] + }); + + $( "a[id|='remove-domain']" ).bind( 'click', removeDomain ); + +}); // document onready + +function removeDomain( event ){ + + event.preventDefault(); + + if( $( event.target ).is( "i" ) ) + element = $( event.target ).parent(); + else + element = $( event.target ); + + $( "#purge_domain_name" ).html( element.attr( "ref" ) ); + + delDialog = $( '#purge_dialog' ).modal({ + backdrop: true, + keyboard: true, + show: true + }); + + $( '#purge_dialog_delete' ).attr( 'href', element.attr( "href" ) ); + + $( '#purge_dialog_cancel' ).click( function(){ + delDialog.modal('hide'); + }); +}; \ No newline at end of file diff --git a/application/views/admin/js/list.js b/application/views/admin/js/list.js index 07eba6f..0856b9b 100644 --- a/application/views/admin/js/list.js +++ b/application/views/admin/js/list.js @@ -1,93 +1,63 @@ - +var purgeDialog; +var oDataTable; + + +$(document).ready( function() +{ + oDataTable = $( '#list_table' ).dataTable({ + 'fnDrawCallback': function() { + if( vm_prefs['iLength'] != $( "select[name|='list_table_length']" ).val() ) + vm_prefs['iLength'] = $( "select[name|='list_table_length']" ).val(); + + $.jsonCookie( 'vm_prefs', vm_prefs, vm_cookie_options ); + }, + 'iDisplayLength': ( typeof vm_prefs != 'undefined' && 'iLength' in vm_prefs ) + ? parseInt( vm_prefs['iLength'] ) + : {if isset( $options.defaults.table.entries )}{$options.defaults.table.entries}{else}10{/if}, + "sDom": "<'row'<'span6'l><'span6'f>r>t<'row'<'span6'i><'span6'p>>", + "sPaginationType": "bootstrap", + 'aoColumns': [ + null, + null, + null, + { 'bSortable': false, "bSearchable": false } + ] + }); + + $( "a[id|='purge-admin']" ).bind( 'click', purgeAdmin ); +}); // document onready + + +function toggleActive( elid, id ){ + ossToggle( $( '#' + elid ), "{genUrl controller='admin' action='ajax-toggle-active'}", { "aid": id } ); +}; + +function toggleSuper( elid, id ){ + if( ossToggle( $( '#' + elid ), "{genUrl controller='admin' action='ajax-toggle-super'}", { "aid": id } ) ) + $( '#admin_domains_' + id ).hide(); + else + $( '#admin_domains_' + id ).show(); +}; + +function purgeAdmin( event ){ + event.preventDefault(); + + if( $( event.target ).is( "i" ) ) + element = $( event.target ).parent(); + else + element = $( event.target ); + + $( "#purge_admin_name" ).html( element.attr( 'ref' ) ); + + $( '#purge_dialog_delete' ).attr( 'href', element.attr( 'href' ) ); + + delDialog = $( '#purge_dialog' ).modal({ + backdrop: true, + keyboard: true, + show: true + }); + + $( '#purge_dialog_cancel' ).click( function(){ + delDialog.modal('hide'); + }); +}; \ No newline at end of file diff --git a/application/views/admin/list.phtml b/application/views/admin/list.phtml index 9e3b8e4..83533f6 100644 --- a/application/views/admin/list.phtml +++ b/application/views/admin/list.phtml @@ -1,8 +1,4 @@ -{include file="header.phtml"} - -{assign var='changePwdParams' value="open: true, iframe: true, transition: 'elastic', width: '700px', height: '270px'"} -{assign var='addAdminParams' value="open: true, iframe: true, transition: 'elastic', width: '500px', height: '400px'"} -{assign var='domainListParams' value="open: true, iframe: true, transition: 'elastic', width: '700px', height: '600px'"} +{tmplinclude file="header.phtml"}
@@ -11,22 +7,17 @@
- + -

Administrators

-{ViMbAdmin_Messages} +{OSS_Message} @@ -38,57 +29,44 @@ - {foreach $admins as $oneAdmin} - - + {foreach $admins as $admin} + + {/foreach} @@ -109,12 +87,12 @@

-{include file='admin/js/list.js'} +
-{include file="footer.phtml"} +{tmplinclude file="footer.phtml"} diff --git a/application/views/admin/password.phtml b/application/views/admin/password.phtml index d941859..44a9c79 100644 --- a/application/views/admin/password.phtml +++ b/application/views/admin/password.phtml @@ -1,91 +1,14 @@ -{if !isset( $modal) || !$modal} - {include file="header.phtml"} -
- - {ViMbAdmin_Messages} -{else} - +{tmplinclude file="footer.phtml"} diff --git a/application/views/alias/add.phtml b/application/views/alias/add.phtml new file mode 100644 index 0000000..cb947a9 --- /dev/null +++ b/application/views/alias/add.phtml @@ -0,0 +1,18 @@ +{tmplinclude file="header.phtml"} +
+ + {OSS_Message} + + + {$form} + + {addJSValidator form=$form} + + + +
+{tmplinclude file="footer.phtml"} diff --git a/application/views/alias/edit.phtml b/application/views/alias/edit.phtml deleted file mode 100644 index 32ab7f2..0000000 --- a/application/views/alias/edit.phtml +++ /dev/null @@ -1,87 +0,0 @@ -{if !isset( $modal) || !$modal} - {include file="header.phtml"} -
- - {ViMbAdmin_Messages} -{else} - - - {include file="footer.phtml"} -{else} -
- - -{/if} diff --git a/application/views/alias/form/add-edit.phtml b/application/views/alias/form/add-edit.phtml new file mode 100644 index 0000000..7788402 --- /dev/null +++ b/application/views/alias/form/add-edit.phtml @@ -0,0 +1,136 @@ +
+ +
getAttrib('target')}target="{$element->getAttrib('target')}"{/if} + class="form-horizontal"> + +
+ + + +
+ +
+ + {if isset( $element->local_part ) && isset( $element->domain )} +
+ +
+
+ {$element->local_part} + {if !isset( $domain ) || !$domain} + @ + {$element->domain} + {else} +
{$element->domain}
+ @{$domain->getDomain()} + {/if} +
+ + {if $element->local_part->getMessages()} + + {/if} +

+ {if $element->local_part->getMessages()} +
+ {foreach from=$element->local_part->getMessages() item=messages} + {foreach from=$messages item=msg} +
{$msg} + {/foreach} + {/foreach} + {/if} +

+ + {if $element->domain->getMessages()} + + {/if} +

+ {if $element->domain->getMessages()} +
+ {foreach from=$element->domain->getMessages() item=messages} + {foreach from=$messages item=msg} +
{$msg} + {/foreach} + {/foreach} + {/if} +

+
+
+ {/if} + +
+ +
+
+ + + + +
+ {if $element->goto->getMessages()} + + {/if} +

+ {if $element->goto->getMessages()} + {foreach from=$element->goto->getMessages() item=messages} + {foreach from=$messages item=msg} + {if $msg|strstr:";"} + {assign var="end" value=$msg|strpos:";"} + {$msg|substr:0:$end} + {else} + {$msg} + {/if} +
+ {/foreach} + {/foreach} + {/if} +

+
+
+
+ + {* any plugin elements? *} + {foreach $element->getSubForms() as $name => $sf} + {if substr( $name, 0, 9 ) eq 'pluginsf_'} + {$sf} + {/if} + {/foreach} + +
+ +
+ +
+ Cancel + + + + +
diff --git a/application/views/alias/form/additional-info.phtml b/application/views/alias/form/additional-info.phtml new file mode 100644 index 0000000..2e06699 --- /dev/null +++ b/application/views/alias/form/additional-info.phtml @@ -0,0 +1,53 @@ +
+ + {if isset($options.AdditionalInfo.alias.formPreBlurb) } +

{$options.AdditionalInfo.alias.formPreBlurb}

+ {/if} + {if count( $element ) <= 3 } + {foreach $element as $el} + {$el} + {/foreach} + {else} + {assign var="mid" value=count( $element )/2} + {assign var="second" value=false} +
+
+ {foreach $element as $el} + {if $el@index >= $mid && !$second} + {assign var="second" value=true} +
+
+ {/if} + {$el} + {/foreach} +
+
+ {/if} + {if isset($options.AdditionalInfo.alias.formPostBlurb) } +

{$options.AdditionalInfo.alias.formPostBlurb}

+ {/if} + +
diff --git a/application/views/alias/form/edit.phtml b/application/views/alias/form/edit.phtml deleted file mode 100644 index 9e67edc..0000000 --- a/application/views/alias/form/edit.phtml +++ /dev/null @@ -1,120 +0,0 @@ -
- -
getAttrib('target')}target="{$element->getAttrib('target')}"{/if} - class="form-horizontal"> - -
- -
-
- {$element->local_part} - {if !isset( $domain ) || !$domain } - @ - {else} - @{$domain->domain} -
{$element->domain}
- {/if} -
- {if !isset( $domain ) || !$domain} - {$element->domain} - {/if} -
- {if $element->local_part->getMessages()} - - {/if} -

- {if $element->local_part->getMessages()} - {foreach from=$element->local_part->getMessages() item=messages} - {foreach from=$messages item=msg} - {$msg}
- {/foreach} - {/foreach} - {/if} -

- - {if $element->domain->getMessages()} - - {/if} -

- {if $element->domain->getMessages()} - {foreach from=$element->domain->getMessages() item=messages} - {foreach from=$messages item=msg} - {$msg}
- {/foreach} - {/foreach} - {/if} -

-
- {include file='form/element-checkbox.phtml' ielement=$element->active} - -
- -
-
- - - - -
- {if $element->goto->getMessages()} - - {/if} -

- {if $element->goto->getMessages()} - {foreach from=$element->goto->getMessages() item=messages} - {foreach from=$messages item=msg} - {$msg}
- {/foreach} - {/foreach} - {/if} -

-
-
- - {if !isset($modal) || !$modal} -
- Cancel - - - {/if} - - - - -
diff --git a/application/views/alias/js/add.js b/application/views/alias/js/add.js new file mode 100644 index 0000000..3b22d6d --- /dev/null +++ b/application/views/alias/js/add.js @@ -0,0 +1,88 @@ +var gotoList = new Array(); +var gotoId = 1; // constantly increment it to make sure it is always unique on the page + +$(document).ready( function() +{ + $("#address-popover").popover( { trigger: 'hover' } ); + + $( '#goto_empty' ).keypress( function(e) { + if( e.which == 13 ) + { + e.preventDefault(); + if( $( '#goto_empty' ).val().indexOf( "@" ) != -1 ) + addGoto(); + } + }); + + $( '#goto_empty' ).typeahead( { + source: {$emails} + }) + + tempArr = {if $alias->getGoto()}'{$alias->getGoto()}'.split( ',' ){else}{}{/if}; + + for( var i in tempArr ) + { + gotoItem = jQuery.trim( tempArr[i] ); + + if( gotoItem != '' ) + insertGoto( gotoItem ); + } + + {if isset($defaultGoto)}$( '#goto_empty' ).val( '{$defaultGoto}' );{/if} +}); // document onready + + +function insertGoto( address ) +{ + str = '
' + "\n" + + '' + "\n" + + '' + "\n" + + '' + "\n" + + '' + "\n" + + '
'; + + gotoList[gotoId] = address; + gotoId++; + + jQuery( str ).appendTo( '#div-controls-goto' ).hide().show( 'fast' ); +} + + +function removeGoto( id ) +{ + $( '#goto-div-' + id ).hide( 'fast', function() { $(this).remove() } ); + delete gotoList[id]; +} + + +function addGoto() +{ + address = jQuery.trim( $( '#goto_empty' ).val() ); + + if( address != '' ) + { + if( isValidEmail( address ) ) + { + if( gotoList.indexOf( address ) == -1 ) + { + insertGoto( address ); + $( '#goto_empty' ).val( '' ); + $( '#help-goto' ).html( '' ); + $( '#div-form-goto' ).removeClass( "error" ); + return true; + } + else + { + $( '#help-goto' ).html( 'Already in goto list.' ); + return false; + } + } + else + { + $( '#help-goto' ).html( 'Invalid email address.' ); + return false; + } + } + + return false; +} diff --git a/application/views/alias/js/edit.js b/application/views/alias/js/edit.js deleted file mode 100644 index f436d2b..0000000 --- a/application/views/alias/js/edit.js +++ /dev/null @@ -1,89 +0,0 @@ - diff --git a/application/views/alias/js/list.js b/application/views/alias/js/list.js index c3c521f..7f99a18 100644 --- a/application/views/alias/js/list.js +++ b/application/views/alias/js/list.js @@ -1,97 +1,225 @@ - +} + +function formatActive( id, active ) +{ + var active_class = active ? 'success': 'danger'; + var active_msg = active ? 'Yes': 'No'; + return '
\ + ' + active_msg + ''; +} + +function formatGoto( id, goto ) +{ + var str = '
50 ) + { + str += 'class="have-tooltip-long" title="' + goto.replace( /[,]/g, ", ") + '"'; + goto = goto.substr( 0, 50 ) + '...'; + } + str += '>' + goto + '
'; + return str; +} + +function formatControlls( id ) +{ + var tmpstr = ""; + var item_id = ""; + var href = ""; + + + var str = '
\ + \ + \ + '; + {if isset( $alias_actions ) } + {foreach $alias_actions as $action} + {if isset( $action.menu ) } + {assign var="action_list_menu" value=$action} + {else} + str += '<{$action.tagName} '; + {foreach $action as $attrib => $value} + {if !in_array( $attrib, [ "tagName", "child"] )} + tmpstr = "{$value}"; + str += '{$attrib}="' + tmpstr.replace( "%id%",id ) + '" '; + {/if} + {/foreach} + str += '>'; + {if !is_array( $action.child ) } + str += '{$action.child}'; + {else} + str += '<{$action.child.tagName} {foreach $action.child as $attrib => $value}{if $attrib != "tagName"}{$attrib}="{$value}" {/if}{/foreach} {if $action.child.tagName != "img"}>{else}/>{/if}'; + {/if} + str += ''; + {/if} + {/foreach} + {/if} + + str += '\ + \ + '; + + {if isset( $action_list_menu)} + {assign var="action" value=$action_list_menu} + str += '<{$action.tagName} '; + {foreach $action as $attrib => $value} + {if !in_array( $attrib, [ "tagName", "child", "menu" ] )} + tmpstr = "{$value}"; + str += '{$attrib}="' + tmpstr.replace( "%id%",id ) + '" '; + {/if} + {/foreach} + str += '>'; + {if !is_array( $action.child ) } + str += '{$action.child}'; + {else} + str += '<{$action.child.tagName} {foreach $action.child as $attrib => $value}{if $attrib != "tagName"}{$attrib}="{$value}" {/if}{/foreach} {if $action.child.tagName != "img"}>{else}/>{/if}'; + {/if} + str += '\ + \ +
- {foreach $aliases as $oneAlias} - - - + {foreach $aliases as $alias} + + + - {/foreach} @@ -101,7 +115,7 @@

-{include file='alias/js/list.js'} + -{include file="footer.phtml"} +{tmplinclude file="footer.phtml"} diff --git a/application/views/archive/add.phtml b/application/views/archive/add.phtml new file mode 100644 index 0000000..b733c35 --- /dev/null +++ b/application/views/archive/add.phtml @@ -0,0 +1,86 @@ +{tmplinclude file="header.phtml"} +
+ + {OSS_Message} + + + You are about to archive and delete mailbox {$mailbox->getUsername()} + +
+
+ + +
{$oneAdmin.username}
{$admin->getUsername()} -
- {if $identity.admin.id != $oneAdmin.id} - {$oneAdmin.active|yesno} +
+ {if $identity.user->getId() != $admin->getId()} + {$admin->getActive()|yesno} {else} - {$oneAdmin.active|yesno} + {$admin->getActive()|yesno} {/if}
-
- {if $identity.admin.id != $oneAdmin.id} - {$oneAdmin.super|yesno} +
+ {if $identity.user->getId() != $admin->getId()} + {$admin->getSuper()|yesno} {else} - {$oneAdmin.super|yesno} + {$admin->getSuper()|yesno} {/if}
- + - + - {if $identity.admin.id neq $oneAdmin.id} - - - - {/if} - {if not $oneAdmin.super} - + {if $identity.user->getId() != $admin->getId() } + + + + {/if} +
-
{$oneAlias.address}{$oneAlias.domain}
{$alias.address}{$alias.domain} -
- {$oneAlias.active|yesno} +
+ {$alias.active|yesno}
- {$oneAlias.goto|shorten:50} - {if strlen( $oneAlias.goto ) > 50 } - - {/if} + +
50 } class="have-tooltip-long" title="{$alias.goto|regex_replace:"/[,]/":", "}"{/if}> + {$alias.goto|shorten:50} +
- + - + {if isset( $alias_actions ) } + {assign var=oid value=$alias.id} + {foreach $alias_actions as $action} + {if isset( $action.menu ) } + {assign var="action_list_menu" value=$action} + {else} + <{$action.tagName} {foreach $action as $attrib => $value}{if !in_array( $attrib, [ "tagName", "child"] )}{$attrib}="{$value|replace:'%id%':$oid}" {/if}{/foreach}> + {if !is_array( $action.child ) } + {$action.child} + {else} + <{$action.child.tagName} {foreach $action.child as $attrib => $value}{if $attrib != "tagName"}{$attrib}="{$value}" {/if}{/foreach} {if $action.child.tagName != "img"}>{else}/>{/if} + {/if} + + {/if} + {/foreach} + {/if} + - + + {if isset( $action_list_menu)} + {assign var="action" value=$action_list_menu} + <{$action.tagName} {foreach $action as $attrib => $value}{if !in_array( $attrib, [ "tagName", "child", "menu" ] )}{$attrib}="{$value|replace:'%id%':$oid}" {/if}{/foreach}> + {if !is_array( $action.child ) } + {$action.child} + {else} + <{$action.child.tagName} {foreach $action.child as $attrib => $value}{if $attrib != "tagName"}{$attrib}="{$value}" {/if}{/foreach} {if $action.child.tagName != "img"}>{else}/>{/if} + {/if} + + + + {/if}
-
+ + + + + + {if count( $aliases ) > 0 } + + + + + {foreach $aliases as $alias} + + + + + {/foreach} + {else} + + + + {/if} +
Aliases
AddressGoto
{$alias->getAddress()}{$alias->getGoto()}
There are no aliases.
+ +
+ + + + + + + + {if count( $inAliases ) > 0 } + + + + + {foreach $inAliases as $alias} + + + + + {/foreach} + {else} + + + + {/if} +
In aliases
AddressGoto
{$alias->getAddress()} +
getGoto() ) > 50 } class="have-tooltip-long" title="{$alias->getGoto()|regex_replace:"/[,]/":", "}"{/if}> + {$alias->getGoto()|shorten:50} +
+
This mailbox is not used in any alias.
+ +
+ + The mailbox and all aliases where this mailbox is the sole recipient will be deleted. This mailbox + will be removed from any alias where it is one of two or more destinations. + +
+
+ +
+
+ Cancel + +
+
+ + + +{tmplinclude file="footer.phtml"} diff --git a/application/views/archive/email/archive-ready.txt b/application/views/archive/email/archive-ready.txt new file mode 100644 index 0000000..40a441b --- /dev/null +++ b/application/views/archive/email/archive-ready.txt @@ -0,0 +1,9 @@ +Dear Administrator, + +Archive for {$mailbox} was created successfully. Now you can restore it in: + +{$options.identity.siteurl}/archive + + +Kind regards, +{$options.server.email.name} <{$options.server.email.address}> \ No newline at end of file diff --git a/application/views/archive/email/archive-restored.txt b/application/views/archive/email/archive-restored.txt new file mode 100644 index 0000000..414194b --- /dev/null +++ b/application/views/archive/email/archive-restored.txt @@ -0,0 +1,9 @@ +Dear Administrator, + +Mailbox {$mailbox} was restored successfully from archive. Now you can find it in: + +{$options.identity.siteurl}/mailbox + + +Kind regards, +{$options.server.email.name} <{$options.server.email.address}> \ No newline at end of file diff --git a/application/views/archive/js/list.js b/application/views/archive/js/list.js new file mode 100644 index 0000000..2992d10 --- /dev/null +++ b/application/views/archive/js/list.js @@ -0,0 +1,73 @@ +var oDataTable; +var deleteDialog; + + +$(document).ready( function() +{ + oDataTable = $( '#list_table' ).dataTable({ + 'fnDrawCallback': function() { + if( vm_prefs['iLength'] != $( "select[name|='list_table_length']" ).val() ) + vm_prefs['iLength'] = $( "select[name|='list_table_length']" ).val(); + + $.jsonCookie( 'vm_prefs', vm_prefs, vm_cookie_options ); + }, + 'iDisplayLength': ( typeof vm_prefs != 'undefined' && 'iLength' in vm_prefs ) + ? parseInt( vm_prefs['iLength'] ) + : {if isset( $options.defaults.table.entries )}{$options.defaults.table.entries}{else}10{/if}, + "sDom": "<'row'<'span6'l><'span6'f>r>t<'row'<'span6'i><'span6'p>>", + "sPaginationType": "bootstrap", + 'aoColumns': [ + null, + null, + null, + { 'bSortable': false, "bSearchable": false } + ] + }); + + $( "a[id|='delete-archive']" ).bind( 'click', deleteArchive ); + $( "a[id|='cancel-archive']" ).bind( 'click', cancelArchive ); + +}); // document onready + + +function deleteArchive( event ){ + event.preventDefault(); + + delDialog = $( '#delete_dialog' ).modal({ + backdrop: true, + keyboard: true, + show: true + }); + + if( $( event.target ).is( "i" ) ) + element = $( event.target ).parent(); + else + element = $( event.target ); + + $( '#delete_dialog_delete' ).attr( 'href', element.attr( 'href' ) ); + + $( '#delete_dialog_cancel' ).click( function(){ + delDialog.modal('hide'); + }); +}; + +function cancelArchive( event ){ + event.preventDefault(); + + cancelDialog = $( '#cancel_dialog' ).modal({ + backdrop: true, + keyboard: true, + show: true + }); + + if( $( event.target ).is( "i" ) ) + element = $( event.target ).parent(); + else + element = $( event.target ); + + $( '#cancel_dialog_confirm' ).attr( 'href', element.attr( 'href' ) ); + + $( '#cancel_dialog_cancel' ).click( function(){ + cancelDialog.modal('hide'); + }); +}; \ No newline at end of file diff --git a/application/views/archive/list.phtml b/application/views/archive/list.phtml new file mode 100644 index 0000000..aac8d03 --- /dev/null +++ b/application/views/archive/list.phtml @@ -0,0 +1,96 @@ +{tmplinclude file="header.phtml"} + +{if isset( $session->domain ) && $session->domain } + {assign var=domain value=$session->domain} +{/if} + +
+ + + +{OSS_Message} + + + + + + + + + + + +{foreach $archives as $archive} + + + + + + +{/foreach} + +
UsernameStatusDomain
{$archive.username}{$statuses[$archive.status]}{$archive.domain} +
+ {if in_array( $archive.status, $allowCancel )} + + + + {/if} + {if in_array( $archive.status == "ARCHIVED", $allowRestore )} + + + + {/if} + {if in_array( $archive.status, $allowDelete )} + + + + {/if} +
+
+ +
+
+ + + + + + + + +
+ +{tmplinclude file="footer.phtml"} diff --git a/application/views/auth/change-password.phtml b/application/views/auth/change-password.phtml index ce1b8a3..e36172e 100644 --- a/application/views/auth/change-password.phtml +++ b/application/views/auth/change-password.phtml @@ -1,4 +1,4 @@ -{include file="header.phtml"} +{tmplinclude file="header.phtml"}
@@ -6,7 +6,7 @@

Change Password

- {ViMbAdmin_Messages} + {OSS_Message}
@@ -22,4 +22,4 @@
-{include file="footer.phtml"} +{tmplinclude file="footer.phtml"} diff --git a/application/views/auth/email/html/lost-password.phtml b/application/views/auth/email/html/lost-password.phtml new file mode 100644 index 0000000..eccd2f7 --- /dev/null +++ b/application/views/auth/email/html/lost-password.phtml @@ -0,0 +1,31 @@ + + +

+To whom it may concern, +

+ +

+You received this email because someone recently requested a +password reset in ViMbAdmin. +

+ +

+If this was not you, please ignore this email. +

+ +

+If you wish to change your password, please click on this link: +

+ +

+{genUrl controller='auth' action='password-reset'} +

+ +

+Thanks and kind regards, +

+

+{$options.server.email.name} +

+ + diff --git a/application/views/auth/email/html/reset-password.phtml b/application/views/auth/email/html/reset-password.phtml new file mode 100644 index 0000000..e9b7b56 --- /dev/null +++ b/application/views/auth/email/html/reset-password.phtml @@ -0,0 +1,23 @@ + + +

+To whom it may concern, +

+ +

+Your password for {$options.identity.sitename} (under the username {$user->getUsername()}) +has been reset by the user initiated password reset procedure. +

+ +

+If you did not make this request, please contact us immediately. +

+ +

+Thanks and kind regards, +

+

+{$options.server.email.name} +

+ + diff --git a/application/views/auth/email/password_reset.phtml b/application/views/auth/email/password_reset.phtml deleted file mode 100644 index 4b5356e..0000000 --- a/application/views/auth/email/password_reset.phtml +++ /dev/null @@ -1,16 +0,0 @@ - -To whom it may concern, - -You received this email because someone recently requested a -password reset in ViMbAdmin. - -If this was not you, please ignore this email. - -If you wish to change your password, please click on this link: - -{genUrl controller='auth' action='password-reset' rid=$tokenModel.rid} - - -Thanks and kind regards, - -{$options.server.email.name} diff --git a/application/views/auth/form/login.phtml b/application/views/auth/form/login.phtml index 3dd79e3..f38bd01 100644 --- a/application/views/auth/form/login.phtml +++ b/application/views/auth/form/login.phtml @@ -7,15 +7,15 @@ {if $element->getAttrib('target')}target="{$element->getAttrib('target')}"{/if} class="form-horizontal"> - {include file='form/element-input.phtml' ielement=$element->username} - {include file='form/element-input.phtml' ielement=$element->password} + {$element->username} + {$element->password} -
+
     - Lost Password -
+ Lost Password + diff --git a/application/views/auth/form/lost-password.phtml b/application/views/auth/form/lost-password.phtml new file mode 100644 index 0000000..fec3665 --- /dev/null +++ b/application/views/auth/form/lost-password.phtml @@ -0,0 +1,34 @@ +
getAttrib('target')}target="{$element->getAttrib('target')}"{/if} +> +
+ + {$element->username} + + {if isset( $useCaptcha ) && $useCaptcha} + {$element->captchaid} + {$element->requestnewimage} + +
+ +
+ CAPTCHA image +
+
+ + {$element->captchatext} + {/if} + +
+ {$element->login} + {$element->getDisplayGroup( "zfBootstrapFormActions" )->getElement( "return_to_login" )} +
+ + +
+ +
diff --git a/application/views/auth/js/captcha.js b/application/views/auth/js/captcha.js new file mode 100644 index 0000000..4bd1a46 --- /dev/null +++ b/application/views/auth/js/captcha.js @@ -0,0 +1,17 @@ + diff --git a/application/views/auth/login.phtml b/application/views/auth/login.phtml index 75fecce..c517402 100644 --- a/application/views/auth/login.phtml +++ b/application/views/auth/login.phtml @@ -1,4 +1,4 @@ -{include file="header.phtml"} +{tmplinclude file="header.phtml"}
@@ -6,14 +6,14 @@

Login to ViMbAdmin

-{ViMbAdmin_Messages} +{OSS_Message} {if isset( $loggedOut ) and $loggedOut}
× - You have been logged out. + There is no admin to assign to this domain.
{/if} @@ -28,7 +28,7 @@ Welcome to ViMbAdmin, a web application for managing your virtual mailboxes, domains and aliases.

- {$loginForm} + {$form}
@@ -37,7 +37,7 @@ Are you a user (mailbox owner) looking to change your
password? If so, please click on this button: - Mailbox Password Change + Mailbox Password Change

@@ -48,4 +48,4 @@ -{include file="footer.phtml"} +{tmplinclude file="footer.phtml"} diff --git a/application/views/auth/lost-password.phtml b/application/views/auth/lost-password.phtml new file mode 100644 index 0000000..dc6fda9 --- /dev/null +++ b/application/views/auth/lost-password.phtml @@ -0,0 +1,41 @@ +{tmplinclude file="header.phtml"} + +
+ + + + + {OSS_Message} + + +
+ +
+ + + + {$form} + + {addJSValidator form=$form} + +
+ +

+ Are you a user (mailbox owner) looking to change your
+ password? If so, please click on this button: + + Mailbox Password Change +

+ +
+ + +
+
+{if isset( $useCaptcha ) && $useCaptcha} + {include file='auth/js/captcha.js'} +{/if} +
+{tmplinclude file="footer.phtml"} diff --git a/application/views/auth/password-reset.phtml b/application/views/auth/reset-password.phtml similarity index 66% rename from application/views/auth/password-reset.phtml rename to application/views/auth/reset-password.phtml index 263a16a..de9d0a5 100644 --- a/application/views/auth/password-reset.phtml +++ b/application/views/auth/reset-password.phtml @@ -1,13 +1,13 @@ -{include file="header.phtml"} +{tmplinclude file="header.phtml"}
- {ViMbAdmin_Messages} + {OSS_Message}
@@ -16,9 +16,9 @@ - {$resetForm} + {$form} - {addJSValidator form=$resetForm} + {addJSValidator form=$form}
@@ -26,7 +26,7 @@ Are you a user (mailbox owner) looking to change your
password? If so, please click on this button: - Mailbox Password Change + Mailbox Password Change

@@ -36,4 +36,4 @@
-{include file="footer.phtml"} +{tmplinclude file="footer.phtml"} diff --git a/application/views/auth/setup.phtml b/application/views/auth/setup.phtml index 09b0890..e166abd 100644 --- a/application/views/auth/setup.phtml +++ b/application/views/auth/setup.phtml @@ -1,4 +1,4 @@ -{include file="header.phtml"} +{tmplinclude file="header.phtml"}
@@ -6,7 +6,7 @@

Welcome to Your New ViMbAdmin Installation!

- {ViMbAdmin_Messages} + {OSS_Message}

This set-up procedure will guide you the final steps to put your system live. @@ -14,19 +14,19 @@ {if not $saltSet}

-

Step 1: Security Salt

+

Step 1: Security Salts

- A security salt is used to ensure your administrator passwords are - secure. You must first set a random security salt in the securitysalt - parameter in the following file: application/config/application.ini. + Security salts are used to ensure your passwords are + secure, you are authorised to complete the install procedure and for cookie security. + To proceed, please set the following randomly generated salts + at the top of the [user] section of the following file: + application/config/application.ini.

-

- We suggest you use the following randomly generated string: -

- -
{$randomSalt}
+
securitysalt                       = "{$randomSalt|htmlentities}"
+resources.auth.oss.rememberme.salt = "{$rememberSalt|htmlentities}"
+defaults.mailbox.password_salt     = "{$passwordSalt|htmlentities}"

Please also ensure you have set all the appropriate values @@ -75,7 +75,8 @@

We are only interested in counting the install base to know if further development and support of this open source project is - worthwhile.. + worthwhile. In fact, ViMbAdmin V3 was only released as a result of these + statistics.

@@ -91,4 +92,4 @@

-{include file="footer.phtml"} +{tmplinclude file="footer.phtml"} diff --git a/application/views/domain/add.phtml b/application/views/domain/add.phtml new file mode 100644 index 0000000..fdbc034 --- /dev/null +++ b/application/views/domain/add.phtml @@ -0,0 +1,15 @@ +{tmplinclude file="header.phtml"} +
+ + + + {OSS_Message} + +{$form} +{addJSValidator form=$form} + +
+ +{tmplinclude file="footer.phtml"} diff --git a/application/views/domain/admins.phtml b/application/views/domain/admins.phtml index 45e2653..ec118e6 100644 --- a/application/views/domain/admins.phtml +++ b/application/views/domain/admins.phtml @@ -1,4 +1,4 @@ -{include file="header.phtml"} +{tmplinclude file="header.phtml"}
@@ -6,22 +6,18 @@
- + - +
- +
-

Domain Admins for {$domainModel.domain}

+

Domain Administrators for {$domain->getDomain()}

-{ViMbAdmin_Messages} +{OSS_Message} @@ -31,28 +27,23 @@ -{foreach $domainModel.DomainAdmin as $oneAdmin} - - - - -{/foreach} + {foreach $domain->getAdmins() as $admin} + {if !$admin->isSuper()} + + + + + {/if} + {/foreach}
{$oneAdmin.Admin.username}{if not $oneAdmin.Admin.active} (inactive){/if} - - - - -
{$admin->getUsername()}{if !$admin->getActive()} (inactive){/if} + + + +
- -
-
- -{include file='domain/js/admins.js'} +
+
+ - - - - - - - -{include file="footer.phtml"} + +{tmplinclude file="footer.phtml"} diff --git a/application/views/domain/assign-admin.phtml b/application/views/domain/assign-admin.phtml new file mode 100644 index 0000000..8fb8b9a --- /dev/null +++ b/application/views/domain/assign-admin.phtml @@ -0,0 +1,14 @@ +{tmplinclude file="header.phtml"} +
+ + {OSS_Message} + + {$form} + {addJSValidator form=$form} + +
+{tmplinclude file="footer.phtml"} diff --git a/application/views/domain/edit.phtml b/application/views/domain/edit.phtml deleted file mode 100644 index 0fd53b6..0000000 --- a/application/views/domain/edit.phtml +++ /dev/null @@ -1,73 +0,0 @@ -{if !isset( $modal) || !$modal} - {include file="header.phtml"} -
- - {ViMbAdmin_Messages} -{else} - - - {include file="footer.phtml"} -{else} -
- - -{/if} diff --git a/application/views/domain/form/add-edit.phtml b/application/views/domain/form/add-edit.phtml new file mode 100644 index 0000000..ba29954 --- /dev/null +++ b/application/views/domain/form/add-edit.phtml @@ -0,0 +1,98 @@ + +
getAttrib('target')}target="{$element->getAttrib('target')}"{/if} + class="form-horizontal"> + + +
+
+ {$element->domain} + {$element->description} + {$element->backupmx} + {$element->active} +
+
+
+
+ {$element->max_aliases} + {$element->max_mailboxes} + {* $element->max_quota *} + {* $element->quota *} +
+ +
+ max_quota->isRequired()}class="required"{/if} title="{$element->max_quota->getAttrib('title')}" + value="{$element->max_quota->getValue()}" id="{$element->max_quota->getId()}" name="{$element->max_quota->getName()}" /> + + ? + + {if $element->max_quota->hasErrors()} + + {foreach $element->max_quota->getMessages() as $messages} + {foreach $messages as $msg} + {$msg}
+ {/foreach} + {/foreach} +
+ {/if} +
+
+
+ +
+ quota->isRequired()}class="required"{/if} title="{$element->quota->getAttrib('title')}" + value="{$element->quota->getValue()}" id="{$element->quota->getId()}" name="{$element->quota->getName()}" /> + + ? + + {if $element->quota->hasErrors()} + + {foreach $element->quota->getMessages() as $messages} + {foreach $messages as $msg} + {$msg}
+ {/foreach} + {/foreach} +
+ {/if} +
+
+ + {$element->transport} +
+
+
+ +
+ Advanced + Cancel + +
+
+ + diff --git a/application/views/domain/form/assign-admin.phtml b/application/views/domain/form/assign-admin.phtml new file mode 100644 index 0000000..97f7f92 --- /dev/null +++ b/application/views/domain/form/assign-admin.phtml @@ -0,0 +1,27 @@ +
+ +
getAttrib('target')}target="{$element->getAttrib('target')}"{/if} + class="form-horizontal"> + + {$element->admin} + +
+ Cancel + +
+ +
+ +
diff --git a/application/views/domain/form/edit.phtml b/application/views/domain/form/edit.phtml deleted file mode 100644 index f20765b..0000000 --- a/application/views/domain/form/edit.phtml +++ /dev/null @@ -1,48 +0,0 @@ - -
getAttrib('target')}target="{$element->getAttrib('target')}"{/if} - class="form-horizontal"> - - -
-
- {include file='form/element-input.phtml' ielement=$element->domain} - {include file='form/element-textarea.phtml' ielement=$element->description} - {include file='form/element-checkbox.phtml' ielement=$element->backupmx} - {include file='form/element-checkbox.phtml' ielement=$element->active} -
-
-
- -
-
- - {if !isset($modal) || !$modal} -
- Advanced - - -
- {/if} -
- - diff --git a/application/views/domain/js/admins.js b/application/views/domain/js/admins.js index d388e73..bbce33f 100644 --- a/application/views/domain/js/admins.js +++ b/application/views/domain/js/admins.js @@ -1,146 +1,50 @@ - +var removeDialog; +var addDialog; +var oDataTable; + + +$(document).ready( function() +{ + oDataTable = $( '#list_table' ).dataTable({ + 'fnDrawCallback': function() { + if( vm_prefs['iLength'] != $( "select[name|='list_table_length']" ).val() ) + vm_prefs['iLength'] = $( "select[name|='list_table_length']" ).val(); + + $.jsonCookie( 'vm_prefs', vm_prefs, vm_cookie_options ); + }, + 'iDisplayLength': vm_prefs['iLength']? vm_prefs['iLength']: {$options.defaults.table.entries}, + "sDom": "<'row'<'span6'l><'span6'f>r>t<'row'<'span6'i><'span6'p>>", + "sPaginationType": "bootstrap", + 'aoColumns': [ + null, + { 'bSortable': false, "bSearchable": false } + ] + }); + + $( "a[id|='remove-admin']" ).bind( 'click', removeAdmin ); + +}); // document onready + +function removeAdmin( event ) { + + event.preventDefault(); + + if( $( event.target ).is( "i" ) ) + element = $( event.target ).parent(); + else + element = $( event.target ); + + $( "#purge_admin_name" ).html( element.attr( "ref" ) ); + + delDialog = $( '#purge_dialog' ).modal({ + backdrop: true, + keyboard: true, + show: true + }); + + $( '#purge_dialog_delete' ).attr( "href", element.attr( "href" ) ); + + $( '#purge_dialog_cancel' ).click( function(){ + delDialog.modal('hide'); + }); + }; \ No newline at end of file diff --git a/application/views/domain/js/list.js b/application/views/domain/js/list.js index f8f4497..5e16924 100644 --- a/application/views/domain/js/list.js +++ b/application/views/domain/js/list.js @@ -1,96 +1,253 @@ - diff --git a/application/views/domain/list.phtml b/application/views/domain/list.phtml index 37ecd69..ff58265 100644 --- a/application/views/domain/list.phtml +++ b/application/views/domain/list.phtml @@ -1,24 +1,17 @@ -{include file="header.phtml"} - -{assign var='addDomainParams' value="open: true, iframe: true, transition: 'elastic', width: '800px', height: '480px'"} +{tmplinclude file="header.phtml"}
- {ViMbAdmin_Messages} + {OSS_Message} @@ -34,6 +27,9 @@ + {if isset($options.defaults.list_size.disabled) && !$options.defaults.list_size.disabled} + + {/if} @@ -42,61 +38,91 @@ - {foreach $domains as $oneDomain} - - + {foreach $domains as $domain} + + + {if isset($options.defaults.list_size.disabled) && !$options.defaults.list_size.disabled} + + {/if} - - - + + + {/foreach}
Domain Mailboxes AliasesSize ({$size_multiplier})Active Transport Backup MX
{$oneDomain.domain}
{$domain.name} -    - {$oneDomain->countMailboxes()}{if $oneDomain.mailboxes}/{$oneDomain.mailboxes}{/if} +    + {$domain.mailboxes}{if $domain.maxmailboxes}/{$domain.maxmailboxes}{/if} -    - {$oneDomain->countAliases( true )}{if $oneDomain.aliases}/{$oneDomain.aliases}{/if} +    + {$domain.aliases}{if $domain.maxaliases}/{$domain.maxaliases}{/if} + {if $domain.mailboxes_size} + {($domain.mailboxes_size/$multiplier)|string_format:"%.3f"} + {else} + 0 + {/if} + -
- {$oneDomain.active|yesno} +
+ {$domain.active|yesno}
{$oneDomain.transport}{$oneDomain.backupmx|yesno}{$oneDomain.created}{$domain.transport}{$domain.backupmx|yesno}{$domain.created->format( 'Y-m-d' )}
- + - {if $identity.admin.super} - + {if isset( $domain_actions ) } + {assign var=oid value=$mbox.id} + {foreach $domain_actions as $action} + {if isset( $action.menu ) } + {assign var="action_list_menu" value=$action} + {else} + <{$action.tagName} {foreach $action as $attrib => $value}{if !in_array( $attrib, [ "tagName", "child"] )}{$attrib}="{$value|replace:'%id%':$oid}" {/if}{/foreach}> + {if !is_array( $action.child ) } + {$action.child} + {else} + <{$action.child.tagName} {foreach $action.child as $attrib => $value}{if $attrib != "tagName"}{$attrib}="{$value}" {/if}{/foreach} {if $action.child.tagName != "img"}>{else}/>{/if} + {/if} + + {/if} + {/foreach} + {/if} + {if $user->isSuper()} + {/if} - + - {if $identity.admin.super} - + {if $user->isSuper()} + {/if} + {if isset( $action_list_menu)} + {assign var="action" value=$action_list_menu} + <{$action.tagName} {foreach $action as $attrib => $value}{if !in_array( $attrib, [ "tagName", "child", "menu" ] )}{$attrib}="{$value|replace:'%id%':$oid}" {/if}{/foreach}> + {if !is_array( $action.child ) } + {$action.child} + {else} + <{$action.child.tagName} {foreach $action.child as $attrib => $value}{if $attrib != "tagName"}{$attrib}="{$value}" {/if}{/foreach} {if $action.child.tagName != "img"}>{else}/>{/if} + {/if} + + + + {/if}
-
- -{include file='domain/js/list.js'} +
-{include file="footer.phtml"} +{tmplinclude file="footer.phtml"} diff --git a/application/views/error/error-404.phtml b/application/views/error/error-404.phtml index 7b9f632..973379b 100644 --- a/application/views/error/error-404.phtml +++ b/application/views/error/error-404.phtml @@ -1,4 +1,4 @@ -{include file="header.phtml"} +{tmplinclude file="header.phtml"}
@@ -7,7 +7,7 @@
-{ViMbAdmin_Messages} +{OSS_Message}

@@ -28,4 +28,4 @@

-{include file="footer.phtml"} +{tmplinclude file="footer.phtml"} diff --git a/application/views/error/error-debug.phtml b/application/views/error/error-debug.phtml deleted file mode 100755 index 55b7392..0000000 --- a/application/views/error/error-debug.phtml +++ /dev/null @@ -1,34 +0,0 @@ -{include file="header.phtml"} - -
- - - - -{ViMbAdmin_Messages} - -{include file="message.tpl"} - -
-
File
-
{$errorException->getFile()}
- -
Line
-
{$errorException->getLine()}
- -
Message
-
{$errorException->getMessage()}
- -
Code
-
{$errorException->getCode()}
-
- -

Trace

- -
-    {$errorException->getTraceAsString()}
-    
-
-{include file="footer.phtml"} diff --git a/application/views/error/error.phtml b/application/views/error/error.phtml index 698c08b..251bc0e 100755 --- a/application/views/error/error.phtml +++ b/application/views/error/error.phtml @@ -1,4 +1,4 @@ -{include file="header.phtml"} +{tmplinclude file="header.phtml"}
@@ -8,7 +8,7 @@
-{ViMbAdmin_Messages} +{OSS_Message}

@@ -16,35 +16,53 @@
-

An Error has Occurred

+

Uh oh! Unexpected Error!

-

We apologise but an unexpected server error has occured.

+

We're very sorry but something we didn't expect has just happened.

+

We've alerted the web monkeys and, after a severe flogging, they will get it fixed as soon as possible.

+

Please feel free to email the {mailto address=$options.identity.email encode='javascript' text=$options.identity.name}

-{if $exception} - -
-
File
-
{$exception->getFile()}
- -
Line
-
{$exception->getLine()}
- -
Message
-
{$exception->getMessage()}
- -
Code
-
{$exception->getCode()}
-
- -

Trace

- -
{$exception->getTraceAsString()}
+{if isset( $options.phpSettings.display_errors ) and $options.phpSettings.display_errors} +
+

+ Development Platform Detected! Display errors enabled via application.ini. Disable in production! +

+
+ + {if isset( $exceptions )} + + {foreach $exceptions as $exception} + +

{get_class( $exception )}

+ +
+
File
+
{$exception->getFile()}
+ +
Line
+
{$exception->getLine()}
+ +
Message
+
{$exception->getMessage()}
+ +
Code
+
{$exception->getCode()}
+
+ +

Trace

+ +
{$exception->getTraceAsString()}
+ + {/foreach} + + {/if} {/if} + -{include file="footer.phtml"} +{tmplinclude file="footer.phtml"} diff --git a/application/views/error/insufficient-permissions.phtml b/application/views/error/insufficient-permissions.phtml index 44b485a..a913732 100755 --- a/application/views/error/insufficient-permissions.phtml +++ b/application/views/error/insufficient-permissions.phtml @@ -1,14 +1,25 @@ -{include file="header.phtml"} +{tmplinclude file="header.phtml"}
-{ViMbAdmin_Messages} +{OSS_Message} + +

+ You don't have the required permissions to access the requested page or object. +

+ +

+ This request has been logged. +

+ +

+ If you believe this is an error, please contact your administrator. +

-

You don't have the required permissions to access the page.

-{include file="footer.phtml"} +{tmplinclude file="footer.phtml"} diff --git a/application/views/footer.phtml b/application/views/footer.phtml index 8a937f2..32b4ad0 100644 --- a/application/views/footer.phtml +++ b/application/views/footer.phtml @@ -13,10 +13,6 @@ As such, we would appreciate and request you leave our copyright message and link to our site intact in the footer so that we may in some small way benefit from this application. -Please also consider supporting our worthwhile charity: - - http://www.barnardos.ie/ - *************************************************************************** *} {if !isset($inColorBox) || !$inColorBox} @@ -28,11 +24,10 @@ Please also consider supporting our worthwhile charity: This Program is provided AS IS, without warranty.

- ViMbAdmin V{ViMbAdmin_Version::VERSION}. + ViMbAdmin V{ViMbAdmin_Version::VERSION}. Licensed under the GNU General Public License V3 . - Support our Charity.

@@ -43,18 +38,22 @@ Please also consider supporting our worthwhile charity:  |  Get the source at - GitHub + GitHub -  |  - Learn more about +  |  + Learn more about Open Solutions -  |  - Track your time with +  |  + + Announcements + + and - TallyStick + Discussion + Mailing Lists

diff --git a/application/views/form/element-checkbox.phtml b/application/views/form/element-checkbox.phtml index 45551de..7836c2b 100644 --- a/application/views/form/element-checkbox.phtml +++ b/application/views/form/element-checkbox.phtml @@ -1,32 +1,25 @@ - -
- -
- - {if $ielement->getMessages()} - - {/if} - - {if $ielement->getMessages()} - {foreach from=$ielement->getMessages() item=messages} - {foreach from=$messages item=msg} - {$msg}
- {/foreach} - {/foreach} - {/if} -
-
-
+
+ +
+ + {if $ielement->getMessages()} + + {/if} + + {if $ielement->getMessages()} + {foreach from=$ielement->getMessages() item=messages} + {foreach from=$messages item=msg} + {$msg}
+ {/foreach} + {/foreach} + {/if} +
+
+
diff --git a/application/views/form/element-checkboxlist.phtml b/application/views/form/element-checkboxlist.phtml index 2f16652..40f09f0 100644 --- a/application/views/form/element-checkboxlist.phtml +++ b/application/views/form/element-checkboxlist.phtml @@ -1,16 +1,14 @@ - +
-
+
{foreach from=$ielements item=ielement} -
- +
+
{/foreach}
diff --git a/application/views/form_element_errors.phtml b/application/views/form_element_errors.phtml old mode 100755 new mode 100644 diff --git a/application/views/header-css.phtml b/application/views/header-css.phtml index f286cd8..5a4d6ac 100644 --- a/application/views/header-css.phtml +++ b/application/views/header-css.phtml @@ -1,5 +1,5 @@ {if isset( $config.use_minified_css ) and $config.use_minified_css} - + {else} diff --git a/application/views/header-js.phtml b/application/views/header-js.phtml index 0d9c794..7e63cb0 100644 --- a/application/views/header-js.phtml +++ b/application/views/header-js.phtml @@ -1,5 +1,5 @@ {if isset( $config.use_minified_js ) and $config.use_minified_js} - + {else} @@ -12,6 +12,7 @@ + diff --git a/application/views/header.phtml b/application/views/header.phtml index fb553d4..a081b87 100644 --- a/application/views/header.phtml +++ b/application/views/header.phtml @@ -18,8 +18,8 @@ - {include file='header-js.phtml'} - {include file='header-css.phtml'} + {tmplinclude file='header-js.phtml'} + {tmplinclude file='header-css.phtml'} {if isset($inColorBox) && $inColorBox} {if !$options.mini_css} @@ -34,13 +34,13 @@ - {include file="colorbox.css.phtml"} + {tmplinclude file="colorbox.css.phtml"} {if !isset($inColorBox) || !$inColorBox} -