From 9f108dd1a969473375341d92a7b1252fa2cedc9a Mon Sep 17 00:00:00 2001 From: mszulecki Date: Thu, 14 Jun 2007 17:09:01 +0000 Subject: Initial import. git-svn-id: http://svn.sukimashita.com/repos/mailadmin/trunk@2 4281df72-ff29-0410-8fee-2d9ac0c5f5a7 --- apps/admin/config/app.yml | 50 + apps/admin/config/cache.yml | 4 + apps/admin/config/config.php | 8 + apps/admin/config/factories.yml | 35 + apps/admin/config/filters.yml | 10 + apps/admin/config/i18n.yml | 7 + apps/admin/config/logging.yml | 22 + apps/admin/config/routing.yml | 23 + apps/admin/config/security.yml | 3 + apps/admin/config/settings.yml | 117 ++ apps/admin/config/view.yml | 15 + apps/admin/lib/imap/FakeIMAPClient.php | 9 + apps/admin/lib/imap/IMAPClient.php | 498 ++++++++ apps/admin/lib/imap/IMAPManager.php | 48 + apps/admin/lib/imap/IMAPServerInformation.php | 63 + apps/admin/lib/myChangeNicknameValidator.php | 43 + apps/admin/lib/myDenyStringValidator.php | 38 + apps/admin/lib/myLoginValidator.php | 45 + apps/admin/lib/myUser.class.php | 83 ++ .../modules/address/actions/actions.class.php | 165 +++ apps/admin/modules/address/config/generator.yml | 48 + apps/admin/modules/address/templates/_alias.php | 9 + .../modules/address/templates/_destination.php | 23 + .../admin/modules/address/templates/_domain_id.php | 1 + .../admin/modules/address/templates/_localpart.php | 1 + .../modules/address/templates/_mailbox_id.php | 1 + apps/admin/modules/address/validate/create.yml | 10 + apps/admin/modules/address/validate/edit.yml | 10 + .../modules/content/actions/actions.class.php | 18 + .../admin/modules/domain/actions/actions.class.php | 47 + apps/admin/modules/domain/config/generator.yml | 53 + apps/admin/modules/domain/config/security.yml | 11 + .../domain/templates/_default_mailbox_quota.php | 1 + .../modules/domain/templates/_edit_header.php | 13 + .../domain/templates/_max_mailbox_count.php | 1 + apps/admin/modules/domain/templates/_quota.php | 1 + apps/admin/modules/domain/validate/create.yml | 46 + apps/admin/modules/domain/validate/edit.yml | 46 + apps/admin/modules/log/actions/actions.class.php | 46 + apps/admin/modules/log/config/generator.yml | 30 + apps/admin/modules/log/config/security.yml | 2 + apps/admin/modules/log/templates/_priority.php | 1 + apps/admin/modules/log/templates/_user_id.php | 1 + apps/admin/modules/log/templates/clearSuccess.php | 12 + .../modules/mailbox/actions/actions.class.php | 56 + apps/admin/modules/mailbox/config/generator.yml | 56 + .../admin/modules/mailbox/templates/_domain_id.php | 1 + .../modules/mailbox/templates/_last_login.php | 1 + .../mailbox/templates/_max_address_count.php | 1 + .../admin/modules/mailbox/templates/_max_quota.php | 1 + .../modules/mailbox/templates/_new_password.php | 1 + apps/admin/modules/mailbox/templates/_password.php | 1 + apps/admin/modules/mailbox/validate/create.yml | 50 + apps/admin/modules/mailbox/validate/edit.yml | 48 + .../admin/modules/server/actions/actions.class.php | 29 + .../admin/modules/server/templates/imapSuccess.php | 57 + apps/admin/modules/user/actions/actions.class.php | 115 ++ apps/admin/modules/user/config/generator.yml | 55 + apps/admin/modules/user/config/security.yml | 13 + .../modules/user/templates/_domain_permissions.php | 27 + apps/admin/modules/user/templates/_last_login.php | 1 + apps/admin/modules/user/templates/_password.php | 3 + apps/admin/modules/user/templates/_password1.php | 3 + apps/admin/modules/user/templates/_password2.php | 3 + apps/admin/modules/user/templates/_role_id.php | 1 + apps/admin/modules/user/templates/loginSuccess.php | 12 + .../modules/user/templates/settingsSuccess.php | 22 + apps/admin/modules/user/validate/create.yml | 37 + apps/admin/modules/user/validate/edit.yml | 40 + apps/admin/modules/user/validate/login.yml | 24 + apps/admin/modules/user/validate/settings.yml | 43 + apps/admin/templates/_branding.php | 4 + apps/admin/templates/_navigation.php | 53 + apps/admin/templates/_notes.php | 9 + apps/admin/templates/layout.php | 35 + config/config.php | 5 + config/databases.yml | 5 + config/generated-schema-transformed.xml | 2 + config/propel.ini | 44 + config/properties.ini | 2 + config/rsync_exclude.txt | 4 + config/schema-transformed.xml | 2 + config/schema.yml | 68 ++ data/fixtures/10-common_data.yml | 21 + .../mailadmin/template/actions/actions.class.php | 435 +++++++ .../mailadmin/template/templates/_edit_actions.php | 13 + .../mailadmin/template/templates/_edit_footer.php | 0 .../mailadmin/template/templates/_edit_form.php | 93 ++ .../mailadmin/template/templates/_edit_header.php | 0 .../template/templates/_edit_messages.php | 5 + .../mailadmin/template/templates/_filters.php | 36 + .../mailadmin/template/templates/_list.php | 18 + .../mailadmin/template/templates/_list_actions.php | 10 + .../mailadmin/template/templates/_list_footer.php | 0 .../mailadmin/template/templates/_list_header.php | 0 .../template/templates/_list_messages.php | 13 + .../template/templates/_list_td_actions.php | 5 + .../template/templates/_list_td_stacked.php | 16 + .../template/templates/_list_td_tabular.php | 30 + .../template/templates/_list_th_stacked.php | 1 + .../template/templates/_list_th_tabular.php | 28 + .../mailadmin/template/templates/_pager.php | 13 + .../mailadmin/template/templates/editSuccess.php | 20 + .../mailadmin/template/templates/listSuccess.php | 38 + data/sql/lib.model.schema.sql | 181 +++ data/sql/sqldb.map | 2 + lib/helper/FilesHelper.php | 27 + lib/helper/SortHeaderHelper.php | 21 + lib/model/Address.php | 124 ++ lib/model/AddressPeer.php | 30 + lib/model/Domain.php | 49 + lib/model/DomainPeer.php | 37 + lib/model/DomainPermission.php | 12 + lib/model/DomainPermissionPeer.php | 22 + lib/model/LogEntry.php | 38 + lib/model/LogEntryPeer.php | 23 + lib/model/Mailbox.php | 187 +++ lib/model/MailboxPeer.php | 30 + lib/model/Role.php | 20 + lib/model/RolePeer.php | 12 + lib/model/User.php | 36 + lib/model/UserPeer.php | 12 + lib/model/map/AddressMapBuilder.php | 52 + lib/model/map/DomainMapBuilder.php | 50 + lib/model/map/DomainPermissionMapBuilder.php | 42 + lib/model/map/LogEntryMapBuilder.php | 48 + lib/model/map/MailboxMapBuilder.php | 52 + lib/model/map/RoleMapBuilder.php | 42 + lib/model/map/UserMapBuilder.php | 58 + lib/model/om/BaseAddress.php | 643 ++++++++++ lib/model/om/BaseAddressPeer.php | 834 +++++++++++++ lib/model/om/BaseDomain.php | 926 ++++++++++++++ lib/model/om/BaseDomainPeer.php | 591 +++++++++ lib/model/om/BaseDomainPermission.php | 461 +++++++ lib/model/om/BaseDomainPermissionPeer.php | 809 +++++++++++++ lib/model/om/BaseLogEntry.php | 548 +++++++++ lib/model/om/BaseLogEntryPeer.php | 549 +++++++++ lib/model/om/BaseMailbox.php | 751 ++++++++++++ lib/model/om/BaseMailboxPeer.php | 579 +++++++++ lib/model/om/BaseRole.php | 493 ++++++++ lib/model/om/BaseRolePeer.php | 373 ++++++ lib/model/om/BaseUser.php | 1261 ++++++++++++++++++++ lib/model/om/BaseUserPeer.php | 758 ++++++++++++ symfony | 14 + test/bootstrap/functional.php | 29 + test/bootstrap/unit.php | 17 + test/functional/admin/addressActionsTest.php | 15 + test/functional/admin/administratorActionsTest.php | 15 + test/functional/admin/contentActionsTest.php | 15 + test/functional/admin/domainActionsTest.php | 15 + test/functional/admin/domaintestActionsTest.php | 15 + test/functional/admin/logActionsTest.php | 15 + test/functional/admin/mailboxActionsTest.php | 15 + test/functional/admin/serverActionsTest.php | 15 + test/functional/admin/userActionsTest.php | 15 + web/.htaccess | 25 + web/admin_dev.php | 10 + web/css/main.css | 405 +++++++ web/images/add.gif | Bin 0 -> 94 bytes web/images/address-new.gif | Bin 0 -> 688 bytes web/images/address.gif | Bin 0 -> 1187 bytes web/images/background-branding.png | Bin 0 -> 326 bytes web/images/background-navigation.png | Bin 0 -> 243 bytes web/images/background-notes-start.png | Bin 0 -> 270 bytes web/images/bottom.gif | Bin 0 -> 690 bytes web/images/down.gif | Bin 0 -> 633 bytes web/images/edit.gif | Bin 0 -> 434 bytes web/images/error.gif | Bin 0 -> 403 bytes web/images/favicon.ico | Bin 0 -> 1406 bytes web/images/first.gif | Bin 0 -> 706 bytes web/images/information.gif | Bin 0 -> 666 bytes web/images/last.gif | Bin 0 -> 699 bytes web/images/list.gif | Bin 0 -> 333 bytes web/images/load.gif | Bin 0 -> 825 bytes web/images/logo.png | Bin 0 -> 1506 bytes web/images/mail-new.gif | Bin 0 -> 443 bytes web/images/mail.gif | Bin 0 -> 1186 bytes web/images/network-server.gif | Bin 0 -> 195 bytes web/images/next.gif | Bin 0 -> 623 bytes web/images/ok.gif | Bin 0 -> 382 bytes web/images/previous.gif | Bin 0 -> 616 bytes web/images/remove.gif | Bin 0 -> 76 bytes web/images/search.gif | Bin 0 -> 587 bytes web/images/shred.gif | Bin 0 -> 380 bytes web/images/sort-asc.gif | Bin 0 -> 328 bytes web/images/sort-desc.gif | Bin 0 -> 323 bytes web/images/top.gif | Bin 0 -> 701 bytes web/images/trash.gif | Bin 0 -> 1199 bytes web/images/up.gif | Bin 0 -> 631 bytes web/images/warning.gif | Bin 0 -> 636 bytes web/index.php | 10 + web/robots.txt | 2 + 192 files changed, 14877 insertions(+) create mode 100644 apps/admin/config/app.yml create mode 100644 apps/admin/config/cache.yml create mode 100644 apps/admin/config/config.php create mode 100644 apps/admin/config/factories.yml create mode 100644 apps/admin/config/filters.yml create mode 100644 apps/admin/config/i18n.yml create mode 100644 apps/admin/config/logging.yml create mode 100644 apps/admin/config/routing.yml create mode 100644 apps/admin/config/security.yml create mode 100644 apps/admin/config/settings.yml create mode 100644 apps/admin/config/view.yml create mode 100644 apps/admin/lib/imap/FakeIMAPClient.php create mode 100644 apps/admin/lib/imap/IMAPClient.php create mode 100644 apps/admin/lib/imap/IMAPManager.php create mode 100644 apps/admin/lib/imap/IMAPServerInformation.php create mode 100644 apps/admin/lib/myChangeNicknameValidator.php create mode 100644 apps/admin/lib/myDenyStringValidator.php create mode 100644 apps/admin/lib/myLoginValidator.php create mode 100644 apps/admin/lib/myUser.class.php create mode 100644 apps/admin/modules/address/actions/actions.class.php create mode 100644 apps/admin/modules/address/config/generator.yml create mode 100644 apps/admin/modules/address/templates/_alias.php create mode 100644 apps/admin/modules/address/templates/_destination.php create mode 100644 apps/admin/modules/address/templates/_domain_id.php create mode 100644 apps/admin/modules/address/templates/_localpart.php create mode 100644 apps/admin/modules/address/templates/_mailbox_id.php create mode 100644 apps/admin/modules/address/validate/create.yml create mode 100644 apps/admin/modules/address/validate/edit.yml create mode 100644 apps/admin/modules/content/actions/actions.class.php create mode 100644 apps/admin/modules/domain/actions/actions.class.php create mode 100644 apps/admin/modules/domain/config/generator.yml create mode 100644 apps/admin/modules/domain/config/security.yml create mode 100644 apps/admin/modules/domain/templates/_default_mailbox_quota.php create mode 100644 apps/admin/modules/domain/templates/_edit_header.php create mode 100644 apps/admin/modules/domain/templates/_max_mailbox_count.php create mode 100644 apps/admin/modules/domain/templates/_quota.php create mode 100644 apps/admin/modules/domain/validate/create.yml create mode 100644 apps/admin/modules/domain/validate/edit.yml create mode 100644 apps/admin/modules/log/actions/actions.class.php create mode 100644 apps/admin/modules/log/config/generator.yml create mode 100644 apps/admin/modules/log/config/security.yml create mode 100644 apps/admin/modules/log/templates/_priority.php create mode 100644 apps/admin/modules/log/templates/_user_id.php create mode 100644 apps/admin/modules/log/templates/clearSuccess.php create mode 100644 apps/admin/modules/mailbox/actions/actions.class.php create mode 100644 apps/admin/modules/mailbox/config/generator.yml create mode 100644 apps/admin/modules/mailbox/templates/_domain_id.php create mode 100644 apps/admin/modules/mailbox/templates/_last_login.php create mode 100644 apps/admin/modules/mailbox/templates/_max_address_count.php create mode 100644 apps/admin/modules/mailbox/templates/_max_quota.php create mode 100644 apps/admin/modules/mailbox/templates/_new_password.php create mode 100644 apps/admin/modules/mailbox/templates/_password.php create mode 100644 apps/admin/modules/mailbox/validate/create.yml create mode 100644 apps/admin/modules/mailbox/validate/edit.yml create mode 100644 apps/admin/modules/server/actions/actions.class.php create mode 100644 apps/admin/modules/server/templates/imapSuccess.php create mode 100644 apps/admin/modules/user/actions/actions.class.php create mode 100644 apps/admin/modules/user/config/generator.yml create mode 100644 apps/admin/modules/user/config/security.yml create mode 100644 apps/admin/modules/user/templates/_domain_permissions.php create mode 100644 apps/admin/modules/user/templates/_last_login.php create mode 100644 apps/admin/modules/user/templates/_password.php create mode 100644 apps/admin/modules/user/templates/_password1.php create mode 100644 apps/admin/modules/user/templates/_password2.php create mode 100644 apps/admin/modules/user/templates/_role_id.php create mode 100644 apps/admin/modules/user/templates/loginSuccess.php create mode 100644 apps/admin/modules/user/templates/settingsSuccess.php create mode 100644 apps/admin/modules/user/validate/create.yml create mode 100644 apps/admin/modules/user/validate/edit.yml create mode 100644 apps/admin/modules/user/validate/login.yml create mode 100644 apps/admin/modules/user/validate/settings.yml create mode 100644 apps/admin/templates/_branding.php create mode 100644 apps/admin/templates/_navigation.php create mode 100644 apps/admin/templates/_notes.php create mode 100644 apps/admin/templates/layout.php create mode 100644 config/config.php create mode 100644 config/databases.yml create mode 100644 config/generated-schema-transformed.xml create mode 100644 config/propel.ini create mode 100644 config/properties.ini create mode 100644 config/rsync_exclude.txt create mode 100644 config/schema-transformed.xml create mode 100644 config/schema.yml create mode 100644 data/fixtures/10-common_data.yml create mode 100644 data/generator/sfPropelAdmin/mailadmin/template/actions/actions.class.php create mode 100644 data/generator/sfPropelAdmin/mailadmin/template/templates/_edit_actions.php create mode 100644 data/generator/sfPropelAdmin/mailadmin/template/templates/_edit_footer.php create mode 100644 data/generator/sfPropelAdmin/mailadmin/template/templates/_edit_form.php create mode 100644 data/generator/sfPropelAdmin/mailadmin/template/templates/_edit_header.php create mode 100644 data/generator/sfPropelAdmin/mailadmin/template/templates/_edit_messages.php create mode 100644 data/generator/sfPropelAdmin/mailadmin/template/templates/_filters.php create mode 100644 data/generator/sfPropelAdmin/mailadmin/template/templates/_list.php create mode 100644 data/generator/sfPropelAdmin/mailadmin/template/templates/_list_actions.php create mode 100644 data/generator/sfPropelAdmin/mailadmin/template/templates/_list_footer.php create mode 100644 data/generator/sfPropelAdmin/mailadmin/template/templates/_list_header.php create mode 100644 data/generator/sfPropelAdmin/mailadmin/template/templates/_list_messages.php create mode 100644 data/generator/sfPropelAdmin/mailadmin/template/templates/_list_td_actions.php create mode 100644 data/generator/sfPropelAdmin/mailadmin/template/templates/_list_td_stacked.php create mode 100644 data/generator/sfPropelAdmin/mailadmin/template/templates/_list_td_tabular.php create mode 100644 data/generator/sfPropelAdmin/mailadmin/template/templates/_list_th_stacked.php create mode 100644 data/generator/sfPropelAdmin/mailadmin/template/templates/_list_th_tabular.php create mode 100644 data/generator/sfPropelAdmin/mailadmin/template/templates/_pager.php create mode 100644 data/generator/sfPropelAdmin/mailadmin/template/templates/editSuccess.php create mode 100644 data/generator/sfPropelAdmin/mailadmin/template/templates/listSuccess.php create mode 100644 data/sql/lib.model.schema.sql create mode 100644 data/sql/sqldb.map create mode 100644 lib/helper/FilesHelper.php create mode 100644 lib/helper/SortHeaderHelper.php create mode 100644 lib/model/Address.php create mode 100644 lib/model/AddressPeer.php create mode 100644 lib/model/Domain.php create mode 100644 lib/model/DomainPeer.php create mode 100644 lib/model/DomainPermission.php create mode 100644 lib/model/DomainPermissionPeer.php create mode 100644 lib/model/LogEntry.php create mode 100644 lib/model/LogEntryPeer.php create mode 100644 lib/model/Mailbox.php create mode 100644 lib/model/MailboxPeer.php create mode 100644 lib/model/Role.php create mode 100644 lib/model/RolePeer.php create mode 100644 lib/model/User.php create mode 100644 lib/model/UserPeer.php create mode 100644 lib/model/map/AddressMapBuilder.php create mode 100644 lib/model/map/DomainMapBuilder.php create mode 100644 lib/model/map/DomainPermissionMapBuilder.php create mode 100644 lib/model/map/LogEntryMapBuilder.php create mode 100644 lib/model/map/MailboxMapBuilder.php create mode 100644 lib/model/map/RoleMapBuilder.php create mode 100644 lib/model/map/UserMapBuilder.php create mode 100644 lib/model/om/BaseAddress.php create mode 100644 lib/model/om/BaseAddressPeer.php create mode 100644 lib/model/om/BaseDomain.php create mode 100644 lib/model/om/BaseDomainPeer.php create mode 100644 lib/model/om/BaseDomainPermission.php create mode 100644 lib/model/om/BaseDomainPermissionPeer.php create mode 100644 lib/model/om/BaseLogEntry.php create mode 100644 lib/model/om/BaseLogEntryPeer.php create mode 100644 lib/model/om/BaseMailbox.php create mode 100644 lib/model/om/BaseMailboxPeer.php create mode 100644 lib/model/om/BaseRole.php create mode 100644 lib/model/om/BaseRolePeer.php create mode 100644 lib/model/om/BaseUser.php create mode 100644 lib/model/om/BaseUserPeer.php create mode 100755 symfony create mode 100644 test/bootstrap/functional.php create mode 100644 test/bootstrap/unit.php create mode 100644 test/functional/admin/addressActionsTest.php create mode 100644 test/functional/admin/administratorActionsTest.php create mode 100644 test/functional/admin/contentActionsTest.php create mode 100644 test/functional/admin/domainActionsTest.php create mode 100644 test/functional/admin/domaintestActionsTest.php create mode 100644 test/functional/admin/logActionsTest.php create mode 100644 test/functional/admin/mailboxActionsTest.php create mode 100644 test/functional/admin/serverActionsTest.php create mode 100644 test/functional/admin/userActionsTest.php create mode 100644 web/.htaccess create mode 100644 web/admin_dev.php create mode 100644 web/css/main.css create mode 100644 web/images/add.gif create mode 100644 web/images/address-new.gif create mode 100644 web/images/address.gif create mode 100644 web/images/background-branding.png create mode 100644 web/images/background-navigation.png create mode 100644 web/images/background-notes-start.png create mode 100644 web/images/bottom.gif create mode 100644 web/images/down.gif create mode 100644 web/images/edit.gif create mode 100644 web/images/error.gif create mode 100644 web/images/favicon.ico create mode 100644 web/images/first.gif create mode 100644 web/images/information.gif create mode 100644 web/images/last.gif create mode 100644 web/images/list.gif create mode 100644 web/images/load.gif create mode 100644 web/images/logo.png create mode 100644 web/images/mail-new.gif create mode 100644 web/images/mail.gif create mode 100644 web/images/network-server.gif create mode 100644 web/images/next.gif create mode 100644 web/images/ok.gif create mode 100644 web/images/previous.gif create mode 100644 web/images/remove.gif create mode 100644 web/images/search.gif create mode 100644 web/images/shred.gif create mode 100644 web/images/sort-asc.gif create mode 100644 web/images/sort-desc.gif create mode 100644 web/images/top.gif create mode 100644 web/images/trash.gif create mode 100644 web/images/up.gif create mode 100644 web/images/warning.gif create mode 100644 web/index.php create mode 100644 web/robots.txt diff --git a/apps/admin/config/app.yml b/apps/admin/config/app.yml new file mode 100644 index 0000000..1380235 --- /dev/null +++ b/apps/admin/config/app.yml @@ -0,0 +1,50 @@ +# default values +prod: + server: + default: + imap: + # Client Backend to use for IMAP server communication + # FakeIMAPClient: Returns pseudo data for testing purposes + # IMAPClient: Operates on a standards compliant IMAP server + client: IMAPClient + host: localhost + port: 143 + admin: cyrus + pass: secret + +all: + info: + version: 1.0.0 + pager: + max_per_page_options: [10,25,50,100] + max_per_page: 25 + domain: + quota: 150000 + max_mailbox_count: 300 + default_mailbox_quota: 20000 + mailbox: + deny_names: [cyrus, postmaster] + max_address_count: 300 + address: + dest_collapse_count: 1 + user: + domain_perm_collapse_count: 3 + server: + default: + pam: + # Method to encrypt Mailbox passwords (should match your pam setting) + # 0: plain = Passwords stored in plaintext + # 1: crypt = Use shadow-compatible crypt(3) function + # 2: md5 = Use md5 function + # 3: sha1 = Use sha1 function + crypt: 1 + imap: + # Client Backend to use for IMAP server communication + # FakeIMAPClient: Returns pseudo data for testing purposes + # IMAPClient: Operates on a standards compliant IMAP server + client: IMAPClient + host: mirell.de + port: 143 + admin: cyrus + pass: secret + diff --git a/apps/admin/config/cache.yml b/apps/admin/config/cache.yml new file mode 100644 index 0000000..9a80ccb --- /dev/null +++ b/apps/admin/config/cache.yml @@ -0,0 +1,4 @@ +default: + enabled: off + with_layout: false + lifetime: 86400 diff --git a/apps/admin/config/config.php b/apps/admin/config/config.php new file mode 100644 index 0000000..4038d49 --- /dev/null +++ b/apps/admin/config/config.php @@ -0,0 +1,8 @@ + diff --git a/apps/admin/lib/imap/IMAPClient.php b/apps/admin/lib/imap/IMAPClient.php new file mode 100644 index 0000000..2271cc9 --- /dev/null +++ b/apps/admin/lib/imap/IMAPClient.php @@ -0,0 +1,498 @@ +socket) + $this->closeConnection(); + } + + // FIXME: Extract server name and version; should probably be moved to own library (?) + /* + Couple of banners: + * OK mail.mirapoint.com Mirapoint IMAP4 3.7.4-GA server ready + * OK [CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA IDLE ACL ACL2=UNION STARTTLS] Courier-IMAP ready. Copyright 1998-2004 Double Precision, Inc. See COPYING for distribution information. + * OK mail8.hotbox.ru Cyrus IMAP4 v2.2.3 server ready + * OK dovecot ready. + * OK Microsoft Exchange IMAP4rev1 server version 5.5.2654.50 (wlvexc00.diginsite.com) ready + * OK Microsoft Exchange Server 2003 IMAP4rev1 server version 6.5.6944.0 (stbowa02.stb.sun.ac.za) ready. + * OK [x.x.x.x] IMAP4rev1 Mercury/32 v4.01a server ready. + * OK Messaging Multiplexor (iPlanet Messaging Server 5.2 HotFix 1.26 (built Mar 31 2004)) + * OK [CAPABILITY IMAP4REV1 LOGIN-REFERRALS STARTTLS AUTH=LOGIN] leto IMAP4rev1 2001.315rh at Mon, 31 May 2004 11:06:55 +0200 (CEST) + * OK mail1 Cyrus IMAP4 v2.0.16 server ready + * OK Microsoft Exchange IMAP4rev1 server version Exchange 2000.4208.3 (EX2000.com) ready. + * OK mcis.com Microsoft IMAP4Rev1 Server ready at Thu, 16 Mar 2000 19:03:15 -0800 Version: 5.5.1877.377.37 + */ + + // list of (name, version) regex pairs, first match has to be the value + protected static $servers = array( + array("/(Cyrus\sIMAP)4/", "/Cyrus\sIMAP4\sv((\d+)\.(\d+).(\d+))/"), + array("/(Courier.IMAP)/", null), + ); + + public function getServerName() + { + foreach(self::$servers as $server) + { + if(preg_match($server[0], $this->greeting, $matches)) + { + return $matches[1]; + } + } + + return false; + } + + public function getServerVersion() + { + foreach(self::$servers as $server) + { + if(preg_match($server[0], $this->greeting, $matches)) + { + if($server[1] == null) + return "Unknown"; + + if(preg_match($server[1], $this->greeting, $matches)) + { + return $matches[1]; + } + } + } + + return false; + } + + protected $greeting = null; + public function getGreeting() + { + return $this->greeting; + } + + protected $uri = null; + public function getURI() + { + return $this->uri; + } + + public function openConnection($uri, $timeout = 10) + { + $this->resetClient(); + $this->socket = $this->socket = fsockopen($this->uri = $uri, null, $errno, $errstr); + if(!$this->socket) + throw new Exception('Could not open Socket for IMAP connection: "'.$errstr.'"', $errno); + $this->state = self::STATE_GREETING; + $this->greeting = fgets($this->socket, 1024); + + if (sfConfig::get('sf_logging_enabled')) + { + sfContext::getInstance()->getLogger()->info("{IMAPClient} Greeting: ".trim($this->greeting)); + } + + $this->state = self::STATE_UNAUTH; + + return true; + } + + public function closeConnection() + { + if($this->socket) + { + if(!$this->logout()) + throw new Exception("Logout error."); + fclose($this->socket); + } + $this->resetClient(); + return true; + } + + protected function resetClient() + { + $this->state = self::STATE_GREETING; + $this->capabilities = null; + $this->hierarchydelimiter = null; + } + + protected function sendCommand($tag, $cmd, $args = "") + { + // check if we got a connection + if(!$this->socket) + throw new Exception('Unable to execute "'.$cmd.'" command: Not connected to a server.'); + + if(is_array($args)) + { + $args = " \"" . implode("\" \"", $args) . "\""; + } + + if (sfConfig::get('sf_logging_enabled')) + { + sfContext::getInstance()->getLogger()->info("{IMAPClient} Command: ".$tag." ".$cmd.$args); + } + + //LogEntryPeer::log("{IMAPClient} Command: ".$tag." ".$cmd.$args, LogEntry::PRIO_DEBUG); + + // send command + fputs($this->socket, $tag." ".$cmd.$args."\n"); + + // read response + $response = array(); + do + { + $line = fgets($this->socket, 1024); + $response[] = $line; + + if (sfConfig::get('sf_logging_enabled')) + { + sfContext::getInstance()->getLogger()->info("{IMAPClient} Line: \"".trim($line)."\""); + } + //LogEntryPeer::log("{IMAPClient} Line: \"".trim($line)."\"", LogEntry::PRIO_DEBUG); + } + while(self::getTag($line) != $tag && !feof($this->socket)); + + return $response; + } + + // PARSER API + protected static $tagcounter = 0; + protected static function generateTag() + { + $pattern = "0123456789". + "abcdefghij". + "klmnopqrst". + "uvwxyz"; + + if(self::$tagcounter==0) + self::$tagcounter = rand(0,999999); + + $s = ""; + $r = self::$tagcounter++; + do + { + $m = $r % 36; + $s = $pattern{$m} . $s; + } + while(($r = ($r-$m) / 36) > 0); + return sprintf("%04s", $s); + } + + protected static function getTag($line) + { + return self::getResponseData($line, 0); + } + + protected static function getResponseData($line, $index = 0) + { + $tokens = explode(" ", $line); + return $tokens[$index]; + } + + protected static function getResultStatus($tag, $response) + { + if(is_array($response)) + { + foreach($response as $line) + { + if(self::getTag($line) == $tag) + { + return self::getResponseData($line, 1); + } + } + } + + return null; + } + + protected function runCommandAndGetResult($command, $arguments = "") + { + $tag = self::generateTag(); + $response = $this->sendCommand($tag, $command, $arguments); + return self::getResultStatus($tag, $response); + } + + // IMAP API + + // RFC 3501 - IMAP4rev1 + // RFC 1730 - IMAP4 + public function login($user, $password) + { + $result = $this->runCommandAndGetResult("login", array($user, $password)); + if($result == self::RESULT_OK) + $this->state = self::STATE_AUTH; + + return ($result == self::RESULT_OK); + } + + public function logout() + { + $result = $this->runCommandAndGetResult("logout"); + if($result == self::RESULT_OK) + $this->state = self::STATE_UNAUTH; + + return ($result == self::RESULT_OK); + } + + public function noop() + { + $result = $this->runCommandAndGetResult("noop"); + return ($result == self::RESULT_OK); + } + + protected $hierarchydelimiter = null; + + public function getHierarchyDelimiter() + { + if($this->hierarchydelimiter != null) + return $this->hierarchydelimiter; + + if($info = $this->getlist('', '')) + { + $this->hierarchydelimiter = $info[0]['delimiter']; + return $this->hierarchydelimiter; + } + + return $info; + } + + // API break as "list" is PHP keyword... + public function getlist($reference = '', $mailboxname = '*') + { + $tag = self::generateTag(); + $response = $this->sendCommand($tag, "list", array($reference, $mailboxname)); + $result = self::getResultStatus($tag, $response); + + if($result == self::RESULT_OK) + { + // unserialize response + $list = array(); + + foreach($response as $line) + { + if(preg_match('/\*\sLIST\s\((.*)\)\s\"(.*?)\"\s\"(.*?)\"/', $line, $matches)) + { + $list[] = array('attributes' => $matches[1], + 'delimiter' => $matches[2], + 'name' => $matches[3] + ); + } + } + + return $list; + } + + return false; + } + + protected $capabilities = null; + + public function hasCapability($id) + { + if($this->capabilities == null) + $this->capability(); + + foreach($this->capabilities as $capability) + { + if($id == $capability) + return true; + } + return false; + } + + public function capability() + { + // cache this call + if($this->capabilities) + return $this->capabilities; + + $tag = self::generateTag(); + $response = $this->sendCommand($tag, "capability"); + $result = self::getResultStatus($tag, $response); + + if($result == self::RESULT_OK) + { + foreach($response as $line) + { + if(preg_match('/\*\sCAPABILITY\s(.*?)$/i', $line, $matches)) + { + $this->capabilities = explode(" ", $matches[1]); + return $this->capabilities; + } + } + } + + return false; + } + + public function create($name) + { + $result = $this->runCommandAndGetResult("create", array($name)); + return ($result == self::RESULT_OK); + } + + public function delete($name) + { + $result = $this->runCommandAndGetResult("delete", array($name)); + return ($result == self::RESULT_OK); + } + + public function rename($name, $newname) + { + $result = $this->runCommandAndGetResult("rename", array($name, $newname)); + return ($result == self::RESULT_OK); + } + + // RFC 2087 - QUOTA (Extension) + const QUOTA_TYPE_STORAGE = "STORAGE"; + const QUOTA_TYPE_MESSAGE = "MESSAGE"; + + public function getquota($quotaroot) + { + $tag = self::generateTag(); + $response = $this->sendCommand($tag, "getquota", array($quotaroot)); + $result = self::getResultStatus($tag, $response); + + if($result == self::RESULT_OK) + { + foreach($response as $line) + { + if(preg_match('/\*\sQUOTA\s'.$quotaroot.'\s\((\w)*\s(\d+)\s(\d+)\)/i', $line, $matches)) + { + return array( + 'resource' => $matches[1], + 'current' => $matches[2], + 'max' => $matches[3], + ); + } + } + } + + // OK -> not set, NO -> not set + if($result != self::RESULT_BAD) + { + return array( + 'resource' => null, + 'current' => null, + 'max' => null + ); + } + + return false; + } + + public function setquota($quotaroot, $quota = null, $resource = self::QUOTA_TYPE_STORAGE) + { + $tag = self::generateTag(); + $args = ' "'.$quotaroot.'" ('; + if($quota == 0 || $quota == null) + $args .= ')'; + else + $args .= $resource.' '.intval($quota).')'; + $response = $this->sendCommand($tag, "setquota", $args); + $result = self::getResultStatus($tag, $response); + + return ($result == self::RESULT_OK); + } + + // RFC 4314 - ACL (Extension) + const ACL_NONE = ''; + const ACL_LOOKUP = 'l'; + const ACL_READ = 'r'; + const ACL_SEEN = 's'; + const ACL_WRITE = 'w'; + const ACL_INSERT = 'i'; + const ACL_POST = 'p'; + + const ACL_CREATE = 'c'; // obsolete/depreciated + const ACL_DELETE = 'd'; // obsolete/depreciated + + const ACL_ADMIN = 'a'; + + const ACL_CREATEMB = 'k'; + const ACL_DELETEMB = 'x'; + const ACL_EXPUNGE = 'e'; + const ACL_DELETEMSGS = 't'; + + public function getAvailableACL() + { + $result = self::ACL_LOOKUP. + self::ACL_READ. + self::ACL_SEEN. + self::ACL_WRITE. + self::ACL_INSERT. + self::ACL_POST. + self::ACL_CREATE. + self::ACL_DELETE. + self::ACL_ADMIN; + + // add additional rights set in the capabilities + if($this->capabilities == null) + $this->capability(); + + foreach($this->capabilities as $capability) + { + if(preg_match('/RIGHTS=([kxte]*)/i', $capability, $matches)) + { + $result .= $matches[1]; + break; + } + } + + return $result; + } + + public function getacl($mailboxname) + { + $tag = self::generateTag(); + $response = $this->sendCommand($tag, "getacl", array($mailboxname)); + $result = self::getResultStatus($tag, $response); + + if($result == self::RESULT_OK) + { + foreach($response as $line) + { + // grab acl list + if(preg_match('/\*\sACL\s[^\s]*\s(.*)/', $line, $matches)) + { + // grab all acls + if(preg_match_all('/([^\s]*)\s(['.$this->getAvailableACL().']*)/', $matches[1], $matches)) + { + return array_combine($matches[1], $matches[2]); + } + } + } + } + + return false; + } + + public function setacl($mailboxname, $identifier, $aclmodification) + { + $result = $this->runCommandAndGetResult("setacl", array($mailboxname, $identifier, $aclmodification)); + return ($result == self::RESULT_OK); + } + + public function deleteacl($mailboxname, $identifier) + { + $result = $this->runCommandAndGetResult("deleteacl", array($mailboxname, $identifier)); + return ($result == self::RESULT_OK); + } +} + +?> diff --git a/apps/admin/lib/imap/IMAPManager.php b/apps/admin/lib/imap/IMAPManager.php new file mode 100644 index 0000000..0cac78a --- /dev/null +++ b/apps/admin/lib/imap/IMAPManager.php @@ -0,0 +1,48 @@ +openConnection( + $imap_settings['host'].":". + $imap_settings['port'] + ); + + $success = self::$adminclient->login( + $imap_settings['admin'], + $imap_settings['pass'] + ); + + if(!$success) + throw new Exception("Failed to authenticate on IMAP server."); + + } catch (Exception $e) { + LogEntryPeer::log($e->getMessage(), LogEntry::PRIO_ALERT); + } + + return self::$adminclient; + } + + public static function getAdminUsername() + { + $server_settings = sfConfig::get('app_server_default'); + $imap_settings = $server_settings['imap']; + return $imap_settings['admin']; + } +} + +?> diff --git a/apps/admin/lib/imap/IMAPServerInformation.php b/apps/admin/lib/imap/IMAPServerInformation.php new file mode 100644 index 0000000..e185bae --- /dev/null +++ b/apps/admin/lib/imap/IMAPServerInformation.php @@ -0,0 +1,63 @@ +imap = IMAPManager::getAdminConnection(); + } + + public function getGreeting() + { + return substr($this->imap->getGreeting(), 5); + } + + public function getServerName() + { + return $this->imap->getServerName(); + } + + public function getServerVersion() + { + return $this->imap->getServerVersion(); + } + + public function hasCapability($name) + { + return $this->imap->hasCapability($name); + } + + public function getCapabilties() + { + if(!($c = $this->imap->capability())) + $c = array(); + return $c; + } + + public function getHierarchyDelimiter() + { + return $this->imap->getHierarchyDelimiter(); + } + + public function getAvailableACL() + { + if(!$this->imap->hasCapability('ACL')) + return false; + + return $this->imap->getAvailableACL(); + } + + public function getHost() + { + return substr($this->imap->getURI(), 0, strpos($this->imap->getURI(), ":")); + } + + public function getPort() + { + return substr($this->imap->getURI(), strpos($this->imap->getURI(), ":")+1); + } +} + +?> diff --git a/apps/admin/lib/myChangeNicknameValidator.php b/apps/admin/lib/myChangeNicknameValidator.php new file mode 100644 index 0000000..e8dfdb1 --- /dev/null +++ b/apps/admin/lib/myChangeNicknameValidator.php @@ -0,0 +1,43 @@ +setParameter('change_error', 'Invalid input'); + + $this->getParameterHolder()->add($parameters); + + return true; + } + + public function execute(&$value, &$error) + { + $current_nickname = $this->getContext()->getUser()->getNickname(); + + $new_nickname = $value; + + // changed the nickname? + if($new_nickname == $current_nickname) + return true; + + $c = new Criteria(); + $c->add(UserPeer::NICKNAME, $new_nickname); + $user = UserPeer::doSelectOne($c); + + // nickname exists? + if($user) + { + $error = $this->getParameter('change_error'); + return false; + } + + return true; + } +} + +?> diff --git a/apps/admin/lib/myDenyStringValidator.php b/apps/admin/lib/myDenyStringValidator.php new file mode 100644 index 0000000..d817ea9 --- /dev/null +++ b/apps/admin/lib/myDenyStringValidator.php @@ -0,0 +1,38 @@ +setParameter('values_error', 'Invalid input'); + + $this->getParameterHolder()->add($parameters); + + return true; + } + + public function execute(&$value, &$error) + { + $values = $this->getParameter('values'); + + if(!is_array($values)) + return true; + + foreach($values as $check) + { + if($check==$value) + { + $error = $this->getParameter('values_error'); + return false; + } + } + + return true; + } +} + +?> diff --git a/apps/admin/lib/myLoginValidator.php b/apps/admin/lib/myLoginValidator.php new file mode 100644 index 0000000..03890aa --- /dev/null +++ b/apps/admin/lib/myLoginValidator.php @@ -0,0 +1,45 @@ +setParameter('login_error', 'Invalid input'); + + $this->getParameterHolder()->add($parameters); + + return true; + } + + public function execute(&$value, &$error) + { + $password_param = $this->getParameter('password'); + $password = $this->getContext()->getRequest()->getParameter($password_param); + + $login = $value; + + $c = new Criteria(); + $c->add(UserPeer::NICKNAME, $login); + $user = UserPeer::doSelectOne($c); + + // nickname exists? + if ($user) + { + // password is OK? + if (sha1($user->getSalt().$password) == $user->getSha1Password()) + { + $this->getContext()->getUser()->signIn($user); + return true; + } + } + + $error = $this->getParameter('login_error'); + return false; + } +} + +?> diff --git a/apps/admin/lib/myUser.class.php b/apps/admin/lib/myUser.class.php new file mode 100644 index 0000000..2f67e51 --- /dev/null +++ b/apps/admin/lib/myUser.class.php @@ -0,0 +1,83 @@ +setAuthenticated(true); + + // TODO: set credentials + $this->addCredential($user->getRole()->getCredentials()); + + // set session attributes + $this->updateUserAttributes($user); + + $this->setResultsPerPage(sfConfig::get("app_pagination_results_per_page")); + + LogEntryPeer::log("User logged in.", LogEntry::PRIO_INFO); + + $user->setLastlogin(time()); + $user->save(); + } + + public function updateUserAttributes($user) + { + $this->setAttribute("nickname", $user->getNickname(), "user"); + $this->setAttribute("role", $user->getRole()->getName(), "user"); + $this->setAttribute("role_id", $user->getRole()->getId(), "user"); + $this->setAttribute("user_id", $user->getId(), "user"); + $this->setAttribute("lastlogin", $user->getLastLogin(), "user"); + } + + public function signOut($user) + { + LogEntryPeer::log("User logged out.", LogEntry::PRIO_INFO); + + $this->setAuthenticated(false); + $this->clearCredentials(); + $this->getAttributeHolder()->removeNamespace("user"); + $this->getAttributeHolder()->removeNamespace("pager"); + } + + public function getResultsPerPage() + { + return $this->getAttribute("max_per_page", sfConfig::get("app_pager_max_per_page"), "pager"); + } + + + public function setResultsPerPage($count) + { + $this->setAttribute("max_per_page", $count, "pager"); + } + + public function getDomainPermissions($c = null) + { + $user = UserPeer::retrieveByPK($this->getId()); + return $user->getDomainPermissions($c); + } + + public function getId() + { + return $this->getAttribute("user_id", '', "user"); + } + + public function getLastLogin() + { + return $this->getAttribute("lastlogin", '', "user"); + } + + public function getRoleId() + { + return $this->getAttribute("role_id", '', "user"); + } + + public function getRoleName() + { + return $this->getAttribute("role", '', "user"); + } + + public function getNickname() + { + return $this->getAttribute("nickname", '', "user"); + } +} diff --git a/apps/admin/modules/address/actions/actions.class.php b/apps/admin/modules/address/actions/actions.class.php new file mode 100644 index 0000000..d042fbf --- /dev/null +++ b/apps/admin/modules/address/actions/actions.class.php @@ -0,0 +1,165 @@ +hasRequestParameter("max_per_page")) + $this->getUser()->setResultsPerPage($this->getRequestParameter("max_per_page")); + + return parent::executeList(); + } + + public function executeCreate() + { + $this->setTemplate("edit"); + $result = $this->executeEdit(); + + if($this->getRequest()->getMethod() == sfRequest::GET) + { + if(!$this->hasRequestParameter("id")) + { + $this->updateAddressFromRequest(); + } + $this->address->setActive(true); + $this->address->setSaveInMailbox(true); + } + + return $result; + } + + public function handleErrorCreate() + { + $this->setTemplate("edit"); + return $this->handleErrorEdit(); + } + + public function validateCreate() + { + return $this->validateEdit(); + } + + public function validateEdit() + { + $i18n = sfI18N::getInstance(); + + if($this->getRequest()->getMethod() == sfRequest::GET) + return true; + + $newaddress = $this->getRequestParameter('address'); + if($newaddress["domain_id"]=='') + { + $this->getRequest()->setError('address{alias}', 'A domain must be selected'); + return false; + } + + $address = new Address(); + + if($this->getRequest()->hasParameter('id')) + $address = AddressPeer::retrieveByPk($this->getRequestParameter('id')); + + // if we got different values than the current record already has + if($this->getActionName()=="create" || + $address->getLocalpart() != $newaddress["localpart"] || + $address->getDomainId() != $newaddress["domain_id"] + ) + { + // check if localpart@domain is already used + $c = new Criteria(); + $c->add(AddressPeer::LOCALPART, $newaddress["localpart"]); + $c->add(AddressPeer::DOMAIN_ID, $newaddress["domain_id"]); + $checkaddress = AddressPeer::doSelectOne($c); + if($checkaddress) + { + $this->getRequest()->setError('address{alias}', $i18n->__('The address "%1%" already exists', array("%1%"=>$checkaddress))); + return false; + } + } + + // check if either save to mailbox option or destination is set to satisfy message routing + if(!isset($newaddress["save_in_mailbox"]) && $newaddress["destination"]=='') + { + $this->getRequest()->setError('address{save_in_mailbox}', 'If messages are not saved in the mailbox, the forward destination has to be set'); + $this->getRequest()->setError('address{destination}', 'Destination can not be empty if the message is not saved in the mailbox'); + return false; + + } + + // verify destination list + $ev = new sfEmailValidator(); + $destinations = Address::getDestinationAsArray($newaddress["destination"]); + foreach($destinations as $dest) + { + if($dest=='') + continue; + + // check email + if(strpos($dest, "@") !== false) + { + $error = ''; + $ev->initialize($this->getContext(), array( + 'email_error' => $i18n->__('Invalid E-Mail address "%1%"', array("%1%" => $dest)) + )); + + if(!$ev->execute($dest, $error)) + { + $this->getRequest()->setError('address{destination}', $error); + return false; + } + } + else // check if mailbox name is valid + { + // superadmin has all freedom + if($this->getUser()->hasCredential("superadmin")) + continue; + + $c = new Criteria(); + $c->add(MailboxPeer::NAME, $dest); + $mailbox = MailboxPeer::doSelectOne($c); + if(!$mailbox) + { + // no such target + $this->getRequest()->setError('address{destination}', $i18n->__('Mailbox "%1%" does not exist', array("%1%" => $dest))); + return false; + } + + // check permissions + $c = new Criteria(); + $c->add(DomainPermissionPeer::DOMAIN_ID, $mailbox->getDomainId()); + $permissions = $this->getUser()->getDomainPermissions($c); + if(!$permissions) + { + $this->getRequest()->setError('address{destination}', $i18n->__('No permissions to use Mailbox "%1%" as destination', array("%1%" => $dest))); + return false; + } + } + } + + return true; + } + + protected function updateAddressFromRequest() + { + $address = $this->getRequestParameter('address'); + + if (isset($address['localpart'])) + { + $this->address->setLocalpart($address['localpart']); + } + if (isset($address['domain_id'])) + { + $this->address->setDomainId($address['domain_id']); + } + + return parent::updateAddressFromRequest(); + } +} diff --git a/apps/admin/modules/address/config/generator.yml b/apps/admin/modules/address/config/generator.yml new file mode 100644 index 0000000..2bd2e44 --- /dev/null +++ b/apps/admin/modules/address/config/generator.yml @@ -0,0 +1,48 @@ +generator: + class: sfPropelAdminGenerator + param: + model_class: Address + theme: mailadmin + + fields: + destination: { name: Destination } + mailbox_id: { name: Mailbox } + active: { name: Active } + + list: + peer_method: doSelectJoinAll + title: List of Addresses + display: [=_localpart, _domain_id, _destination, active, _mailbox_id] + filters: [alias, domain_id, active, mailbox_id, destination] + max_per_page: '$this->getUser()->getResultsPerPage("pager")' + sort: [mailbox_id, asc] + fields: + localpart: { name: Address, params: align=right } + domain_id: { params: align=left } + alias: { params: align=left } + destination: { params: align=left } + active: { params: align=center width=1% } + mailbox_id: { params: align=right } + object_actions: + edit: { name: Edit Address, action: edit, icon: edit.gif } + delete: { name: Delete Address, action: delete, icon: trash.gif, params: confirm=Are you sure? } + actions: {} + + create: + title: Create New Address + + edit: + title: 'Editing Address %%alias%%' + display: + 'Address': [_alias, active, mailbox_id] + 'Destination': [save_in_mailbox, destination] + fields: + mailbox_id: { name: For Mailbox, help: 'The primary mailbox for this address' } + alias: { name: Address, help: 'Leave blank if this is a catch all address' } + save_in_mailbox: { name: Save to Mailbox, type: checkbox_tag, help: 'Incoming messages are saved, then forwarded' } + destination: { name: Forward to these Destinations, params: size=51x8, help: 'E-Mail addresses and/or mailbox names, one per line or comma-seperated' } + active: { name: Active, help: Inactive addresses are not routed } + actions: + _save_and_list: { name: Save } + _save_and_add: { name: 'Save, then create new one' } + _list: { name: Cancel } diff --git a/apps/admin/modules/address/templates/_alias.php b/apps/admin/modules/address/templates/_alias.php new file mode 100644 index 0000000..e6550c1 --- /dev/null +++ b/apps/admin/modules/address/templates/_alias.php @@ -0,0 +1,9 @@ + 25, + 'control_name' => 'address[localpart]', + 'style' => 'text-align:right', +)); echo $value ? $value : ' ' ?> @ 'Domain', + 'control_name' => 'address[domain_id]', + 'include_blank' => true, +)); echo $value ? $value : ' ' ?> diff --git a/apps/admin/modules/address/templates/_destination.php b/apps/admin/modules/address/templates/_destination.php new file mode 100644 index 0000000..f01676c --- /dev/null +++ b/apps/admin/modules/address/templates/_destination.php @@ -0,0 +1,23 @@ + +getDestination()); + if($address->getSaveInMailbox()) + $list = array_merge(array($address->getMailbox()->getName()), $list); +?> +
+ sfConfig::get('app_address_dest_collapse_count')): ?> + + count($list))), visual_effect( +'toggle_slide', 'addresslist_'.$address->getId())) ?> + + +
diff --git a/apps/admin/modules/address/templates/_domain_id.php b/apps/admin/modules/address/templates/_domain_id.php new file mode 100644 index 0000000..bb51b3d --- /dev/null +++ b/apps/admin/modules/address/templates/_domain_id.php @@ -0,0 +1 @@ +@getDomain() ?> diff --git a/apps/admin/modules/address/templates/_localpart.php b/apps/admin/modules/address/templates/_localpart.php new file mode 100644 index 0000000..e01fe5d --- /dev/null +++ b/apps/admin/modules/address/templates/_localpart.php @@ -0,0 +1 @@ +isCatchAll() ? "*": $address->getLocalpart() ) ?> diff --git a/apps/admin/modules/address/templates/_mailbox_id.php b/apps/admin/modules/address/templates/_mailbox_id.php new file mode 100644 index 0000000..0ab885b --- /dev/null +++ b/apps/admin/modules/address/templates/_mailbox_id.php @@ -0,0 +1 @@ +getMailbox() ?> diff --git a/apps/admin/modules/address/validate/create.yml b/apps/admin/modules/address/validate/create.yml new file mode 100644 index 0000000..a55efed --- /dev/null +++ b/apps/admin/modules/address/validate/create.yml @@ -0,0 +1,10 @@ +fillin: + enabled: true + +fields: + address{domain_id}: + required: + msg: A domain has to be selected + address{mailbox_id}: + required: + msg: A primary mailbox has to be selected diff --git a/apps/admin/modules/address/validate/edit.yml b/apps/admin/modules/address/validate/edit.yml new file mode 100644 index 0000000..a55efed --- /dev/null +++ b/apps/admin/modules/address/validate/edit.yml @@ -0,0 +1,10 @@ +fillin: + enabled: true + +fields: + address{domain_id}: + required: + msg: A domain has to be selected + address{mailbox_id}: + required: + msg: A primary mailbox has to be selected diff --git a/apps/admin/modules/content/actions/actions.class.php b/apps/admin/modules/content/actions/actions.class.php new file mode 100644 index 0000000..bbc9d08 --- /dev/null +++ b/apps/admin/modules/content/actions/actions.class.php @@ -0,0 +1,18 @@ +redirect($this->getRequest()->getReferer(), '@homepage'); + } +} diff --git a/apps/admin/modules/domain/actions/actions.class.php b/apps/admin/modules/domain/actions/actions.class.php new file mode 100644 index 0000000..badbf03 --- /dev/null +++ b/apps/admin/modules/domain/actions/actions.class.php @@ -0,0 +1,47 @@ +hasRequestParameter("max_per_page")) + $this->getUser()->setResultsPerPage($this->getRequestParameter("max_per_page")); + + return parent::executeList(); + } + + public function executeCreate() + { + // populate preset values + $this->getRequest()->setParameter('domain[creator_id]', $this->getUser()->getId()); + + $this->setTemplate("edit"); + return $this->executeEdit(); + } + + public function handleErrorCreate() + { + $this->setTemplate("edit"); + return $this->handleErrorEdit(); + } + + public function executeCreateMailbox() + { + $domain = DomainPeer::retrieveByPk($this->getRequestParameter('id')); + $this->redirect("mailbox/create?mailbox[domain_id]=".$domain->getId()."&mailbox[name]=".sprintf("%s%d", $domain->getMailboxPrefix(), $domain->getMailboxCount()+1)."&mailbox[max_quota]=".$domain->getDefaultMailboxQuota() ); + } + + public function executeViewMailboxes() + { + $this->redirect("mailbox/list?filter=filter&filters[domain_id]=".$this->getRequestParameter('id')); + } +} diff --git a/apps/admin/modules/domain/config/generator.yml b/apps/admin/modules/domain/config/generator.yml new file mode 100644 index 0000000..df971b3 --- /dev/null +++ b/apps/admin/modules/domain/config/generator.yml @@ -0,0 +1,53 @@ +generator: + class: sfPropelAdminGenerator + param: + model_class: Domain + theme: mailadmin + + fields: + name: { name: Domain } + mailbox_prefix: { name: Mailbox Prefix } + max_mailbox_count: { name: Max Mailbox Count } + quota: { name: Quota } + creator: { name: Created by } + + list: + title: List of Domains + display: [=name, user, mailbox_prefix, _max_mailbox_count, _quota, _default_mailbox_quota] + filters: [name, mailbox_prefix, max_mailbox_count, quota, default_mailbox_quota] + max_per_page: '$this->getUser()->getResultsPerPage("pager")' + sort: [name, asc] + fields: + name: { params: align=left } + mailbox_prefix: { params: align=left } + user: { name: Created By, credentials: [[superadmin]] } + max_mailbox_count: { params: align=right } + mailbox_count: { params: align=right } + quota: { params: align=right } + default_mailbox_quota: { name: Default Mailbox Quota, params: align=right } + object_actions: + viewmailboxes: { name: View Mailboxes, action: viewMailboxes, icon: mail.gif } + createmailbox: { name: Create New Mailbox, action: createMailbox, icon: mail-new.gif } + edit: { name: Edit Domain, action: edit, icon: edit.gif, credentials: [[superadmin, domainmaster]] } + delete: { name: Delete Domain, action: delete, icon: trash.gif, credentials: [[superadmin, domainmaster]], params: confirm=Are you sure? } + actions: {} + + create: + title: Create New Domain + + edit: + title: 'Editing Domain %%name%%' + display: + 'General Settings': [name, mailbox_prefix] + 'Limits': [max_mailbox_count, quota, default_mailbox_quota] + fields: + name: { name: Domain Name, params: size=50 } + mailbox_prefix: { name: Prefix for new Mailboxes, params: size=50 onfocus='updatePrefixFromDomainName(this);' } + max_mailbox_count: { name: Maximum Number of Mailboxes, help: '0 = No Limit', params: size=50 } + quota: { name: Default Quota in kb, help: '0 = No Limit', params: size=50 } + default_mailbox_quota: { name: Quota for Domain in kb, help: '0 = No Limit', params: size=50 } + actions: + _save_and_list: { name: Save } + _save_and_add: { name: 'Save, then create new one' } + _list: { name: Cancel } + diff --git a/apps/admin/modules/domain/config/security.yml b/apps/admin/modules/domain/config/security.yml new file mode 100644 index 0000000..2431ebf --- /dev/null +++ b/apps/admin/modules/domain/config/security.yml @@ -0,0 +1,11 @@ +create: + is_secure: on + credentials: [[superadmin, domainmaster]] + +edit: + is_secure: on + credentials: [[superadmin, domainmaster]] + +all: + is_secure: on + diff --git a/apps/admin/modules/domain/templates/_default_mailbox_quota.php b/apps/admin/modules/domain/templates/_default_mailbox_quota.php new file mode 100644 index 0000000..272ad83 --- /dev/null +++ b/apps/admin/modules/domain/templates/_default_mailbox_quota.php @@ -0,0 +1 @@ +getDefaultMailboxQuota()==0 ? "Unlimited" : format_bytes($domain->getDefaultMailboxQuota()*1000)) ?> diff --git a/apps/admin/modules/domain/templates/_edit_header.php b/apps/admin/modules/domain/templates/_edit_header.php new file mode 100644 index 0000000..fed004a --- /dev/null +++ b/apps/admin/modules/domain/templates/_edit_header.php @@ -0,0 +1,13 @@ + + + diff --git a/apps/admin/modules/domain/templates/_max_mailbox_count.php b/apps/admin/modules/domain/templates/_max_mailbox_count.php new file mode 100644 index 0000000..8b7a70b --- /dev/null +++ b/apps/admin/modules/domain/templates/_max_mailbox_count.php @@ -0,0 +1 @@ +getMailboxCount() ?> / getMaxMailboxCount()==0 ? "Unlimited": $domain->getMaxMailboxCount()) ?> diff --git a/apps/admin/modules/domain/templates/_quota.php b/apps/admin/modules/domain/templates/_quota.php new file mode 100644 index 0000000..0b36b22 --- /dev/null +++ b/apps/admin/modules/domain/templates/_quota.php @@ -0,0 +1 @@ +getUsedQuota()*1000) ?> / getQuota()==0 ? "Unlimited" : format_bytes($domain->getQuota()*1000)) ?> diff --git a/apps/admin/modules/domain/validate/create.yml b/apps/admin/modules/domain/validate/create.yml new file mode 100644 index 0000000..c8183c2 --- /dev/null +++ b/apps/admin/modules/domain/validate/create.yml @@ -0,0 +1,46 @@ +fillin: + enabled: true + +validators: + myStringValidator: + class: sfStringValidator + param: + min: 2 + min_error: This field is too short (2 characters minimum) + max: 100 + max_error: This field is too long (100 characters maximum) + +fields: + domain{name}: + required: + msg: The Domain Name is required + myStringValidator: + sfRegexValidator: + match:..........Yes + match_error: 'The name must be in the form: example.org' + pattern: /[^.]+\.[^.]+$/si + sfPropelUniqueValidator: + class: Domain + column: name + unique_error: This domain already exists + domain{mailbox_prefix}: + required: + msg: The Mailbox Prefix is required + myStringValidator: + sfRegexValidator: + match: Yes + match_error: The prefix must only consist out of alphanumeric characters + pattern: /[A-z0-9]/si + sfPropelUniqueValidator: + class: Domain + column: mailbox_prefix + unique_error: This prefix already exists + domain{max_mailbox_count}: + required: + msg: The Mailbox Count is required + domain{quota}: + required: + msg: The Domain Quota is required + domain{default_mailbox_quota}: + required: + msg: The Mailbox Quota is required diff --git a/apps/admin/modules/domain/validate/edit.yml b/apps/admin/modules/domain/validate/edit.yml new file mode 100644 index 0000000..c8183c2 --- /dev/null +++ b/apps/admin/modules/domain/validate/edit.yml @@ -0,0 +1,46 @@ +fillin: + enabled: true + +validators: + myStringValidator: + class: sfStringValidator + param: + min: 2 + min_error: This field is too short (2 characters minimum) + max: 100 + max_error: This field is too long (100 characters maximum) + +fields: + domain{name}: + required: + msg: The Domain Name is required + myStringValidator: + sfRegexValidator: + match:..........Yes + match_error: 'The name must be in the form: example.org' + pattern: /[^.]+\.[^.]+$/si + sfPropelUniqueValidator: + class: Domain + column: name + unique_error: This domain already exists + domain{mailbox_prefix}: + required: + msg: The Mailbox Prefix is required + myStringValidator: + sfRegexValidator: + match: Yes + match_error: The prefix must only consist out of alphanumeric characters + pattern: /[A-z0-9]/si + sfPropelUniqueValidator: + class: Domain + column: mailbox_prefix + unique_error: This prefix already exists + domain{max_mailbox_count}: + required: + msg: The Mailbox Count is required + domain{quota}: + required: + msg: The Domain Quota is required + domain{default_mailbox_quota}: + required: + msg: The Mailbox Quota is required diff --git a/apps/admin/modules/log/actions/actions.class.php b/apps/admin/modules/log/actions/actions.class.php new file mode 100644 index 0000000..9eed7c7 --- /dev/null +++ b/apps/admin/modules/log/actions/actions.class.php @@ -0,0 +1,46 @@ +hasRequestParameter("max_per_page")) + $this->getUser()->setResultsPerPage($this->getRequestParameter("max_per_page")); + + return parent::executeList(); + } + + public function executeClear() + { + if($this->getRequest()->getMethod() == sfRequest::POST) + { + if($this->getRequestParameter("commit")=="Yes") + { + LogEntryPeer::doDeleteAll(); + return $this->redirect("log", "list"); + } + + } + + return sfView::SUCCESS; + } + + public function executeCreate() + { + return $this->forward404(); + } + + public function executeEdit() + { + return $this->forward404(); + } +} diff --git a/apps/admin/modules/log/config/generator.yml b/apps/admin/modules/log/config/generator.yml new file mode 100644 index 0000000..553b1c2 --- /dev/null +++ b/apps/admin/modules/log/config/generator.yml @@ -0,0 +1,30 @@ +generator: + class: sfPropelAdminGenerator + param: + model_class: LogEntry + theme: mailadmin + + fields: + created_at: { name: Time } + user_id: { name: User } + host: { name: Host } + priority: { name: Type } + + list: + peer_method: doSelectJoinUser + title: Logs + display: [created_at, _priority, message, _user_id, host] + filters: [created_at, priority, message, user_id, host] + max_per_page: '$this->getUser()->getResultsPerPage("pager")' + sort: [created_at, desc] + fields: + created_at: { params: align=left center } + user_id: { params: align=left } + message: { params: align=left } + host: { params: align=left } + priority: { params: align=left } + object_actions: + delete: { name: Delete, action: delete, icon: trash.gif, params: confirm=Are you sure? } + actions: {} + + edit: {} diff --git a/apps/admin/modules/log/config/security.yml b/apps/admin/modules/log/config/security.yml new file mode 100644 index 0000000..60868c9 --- /dev/null +++ b/apps/admin/modules/log/config/security.yml @@ -0,0 +1,2 @@ +all: + credentials: [superadmin] diff --git a/apps/admin/modules/log/templates/_priority.php b/apps/admin/modules/log/templates/_priority.php new file mode 100644 index 0000000..2427ac7 --- /dev/null +++ b/apps/admin/modules/log/templates/_priority.php @@ -0,0 +1 @@ +getPriority()<3?"information.gif":($log_entry->getPriority()<4?"warning.gif":"error.gif")),"alt=[!] border=0") ?>getLevel() ?> diff --git a/apps/admin/modules/log/templates/_user_id.php b/apps/admin/modules/log/templates/_user_id.php new file mode 100644 index 0000000..737a1c7 --- /dev/null +++ b/apps/admin/modules/log/templates/_user_id.php @@ -0,0 +1 @@ +getUser() ? $log_entry->getUser(): "Anonymous") ?> diff --git a/apps/admin/modules/log/templates/clearSuccess.php b/apps/admin/modules/log/templates/clearSuccess.php new file mode 100644 index 0000000..83508eb --- /dev/null +++ b/apps/admin/modules/log/templates/clearSuccess.php @@ -0,0 +1,12 @@ +
+ +   +

Clear Log

+ +
+ +

Do you really want to remove all log entries?

+ +
+ +
diff --git a/apps/admin/modules/mailbox/actions/actions.class.php b/apps/admin/modules/mailbox/actions/actions.class.php new file mode 100644 index 0000000..566c69f --- /dev/null +++ b/apps/admin/modules/mailbox/actions/actions.class.php @@ -0,0 +1,56 @@ +hasRequestParameter("max_per_page")) + $this->getUser()->setResultsPerPage($this->getRequestParameter("max_per_page")); + + return parent::executeList(); + } + + public function executeCreate() + { + $this->setTemplate("edit"); + $result = $this->executeEdit(); + + if($this->getRequest()->getMethod() == sfRequest::GET) + { + if(!$this->hasRequestParameter("id")) + { + $this->updateMailboxFromRequest(); + } + + // reset is needed as updateMailboxFromRequest() deactivates + $this->mailbox->setActive(true); + } + return $result; + } + + public function handleErrorCreate() + { + $this->setTemplate("edit"); + return $this->handleErrorEdit(); + } + + public function executeCreateAddress() + { + $mailbox = MailboxPeer::retrieveByPk($this->getRequestParameter('id')); + $this->redirect("address/create?address[mailbox_id]=".$this->getRequestParameter('id')."&address[domain_id]=".$mailbox->getDomainId()); + } + + public function executeViewAddresses() + { + $this->redirect("address/list?filter=filter&filters[mailbox_id]=".$this->getRequestParameter('id')); + } +} diff --git a/apps/admin/modules/mailbox/config/generator.yml b/apps/admin/modules/mailbox/config/generator.yml new file mode 100644 index 0000000..9c119ea --- /dev/null +++ b/apps/admin/modules/mailbox/config/generator.yml @@ -0,0 +1,56 @@ +generator: + class: sfPropelAdminGenerator + param: + model_class: Mailbox + theme: mailadmin + + fields: + domain: { name: Domain } + domain_id: { name: Domain } + name { name: Username } + max_quota: { name: Quota } + max_address_count: { name: Maximum Addresses } + last_login: { name: Last Login } + + list: + peer_method: doSelectJoinDomain + title: List of Mailboxes + display: [=name, _domain_id, _max_quota, _max_address_count, active, _last_login] + filters: [name, domain_id, max_quota, max_address_count, active, last_login] + max_per_page: '$this->getUser()->getResultsPerPage("pager")' + sort: [domain_id, asc] + fields: + name: { params: align=right } + domain_id: { params: align=left } + max_quota: { params: align=right } + max_address_count: { params: align=right } + active: { params: align=center width=1% } + last_login: { params: align=right } + object_actions: + viewaddresses: { name: View Addresses, action: viewAddresses, icon: address.gif } + createaddress: { name: Create New Address, action: createAddress, icon: address-new.gif } + edit: { name: Edit Mailbox, action: edit, icon: edit.gif } + delete: { name: Delete Mailbox, action: delete, icon: trash.gif, params: confirm=This will also remove all addresses for this mailbox. Are you sure? } + actions: {} + + create: + title: Create New Mailbox + + edit: + title: Editing Mailbox %%name%% + display: + 'General Settings': [name, _password, _new_password, domain_id, active] + 'Limits': [max_quota, max_address_count] + fields: + name: { name: Username, params: size=50 } + password: { name: Password, params: size=50, only_for: create } + new_password: { name: New Password, help: 'Enter a password to change it, leave the field blank to keep the current one', params: size=50, only_for: edit } + domain_id: { name: For Domain } + active: { name: Enable Login, help: 'Inactive mailboxes receive mail, however users are unable to login' } + max_quota: { name: Maximum Storage Space in kb, help: '0 = No Limit', params: size=50 } + max_address_count: { name: Maximum Number of Addresses, help: '0 = No Limit', params: size=50 } + actions: + _save_and_list: { name: Save } + _save_and_add: { name: 'Save, then create new one' } + _list: { name: Cancel } + diff --git a/apps/admin/modules/mailbox/templates/_domain_id.php b/apps/admin/modules/mailbox/templates/_domain_id.php new file mode 100644 index 0000000..4e93b4b --- /dev/null +++ b/apps/admin/modules/mailbox/templates/_domain_id.php @@ -0,0 +1 @@ +getDomain()->getName() ?> diff --git a/apps/admin/modules/mailbox/templates/_last_login.php b/apps/admin/modules/mailbox/templates/_last_login.php new file mode 100644 index 0000000..6e0583a --- /dev/null +++ b/apps/admin/modules/mailbox/templates/_last_login.php @@ -0,0 +1 @@ +getLastLogin()==""? "Never":$mailbox->getLastLogin()) ?> diff --git a/apps/admin/modules/mailbox/templates/_max_address_count.php b/apps/admin/modules/mailbox/templates/_max_address_count.php new file mode 100644 index 0000000..66cc68f --- /dev/null +++ b/apps/admin/modules/mailbox/templates/_max_address_count.php @@ -0,0 +1 @@ +getAddressCount() ?> / getMaxAddressCount()==0 ? "Unlimited": $mailbox->getMaxAddressCount()) ?> diff --git a/apps/admin/modules/mailbox/templates/_max_quota.php b/apps/admin/modules/mailbox/templates/_max_quota.php new file mode 100644 index 0000000..3bf8c47 --- /dev/null +++ b/apps/admin/modules/mailbox/templates/_max_quota.php @@ -0,0 +1 @@ +getQuota(); $qmax = ($q["max"] != null ? $q["max"]: $mailbox->getMaxQuota()); ?> / diff --git a/apps/admin/modules/mailbox/templates/_new_password.php b/apps/admin/modules/mailbox/templates/_new_password.php new file mode 100644 index 0000000..1c28ee6 --- /dev/null +++ b/apps/admin/modules/mailbox/templates/_new_password.php @@ -0,0 +1 @@ + diff --git a/apps/admin/modules/mailbox/templates/_password.php b/apps/admin/modules/mailbox/templates/_password.php new file mode 100644 index 0000000..412f824 --- /dev/null +++ b/apps/admin/modules/mailbox/templates/_password.php @@ -0,0 +1 @@ + diff --git a/apps/admin/modules/mailbox/validate/create.yml b/apps/admin/modules/mailbox/validate/create.yml new file mode 100644 index 0000000..3668321 --- /dev/null +++ b/apps/admin/modules/mailbox/validate/create.yml @@ -0,0 +1,50 @@ +fillin: + enabled: true + param: + exclude_types: [password] + +validators: + myStringValidator: + class: sfStringValidator + param: + min: 2 + min_error: This field is too short (2 characters minimum) + max: 100 + max_error: This field is too long (100 characters maximum) + myPasswordValidator: + class: sfStringValidator + param: + min: 5 + min_error: The password is too short (5 characters minimum) + max: 100 + max_error: The password is too long (100 characters maximum) + +fields: + mailbox{name}: + required: + msg: The Username is required + myStringValidator: + sfRegexValidator: + match:..........Yes + match_error: 'The characters ".,;/" are not allowed' + pattern: '/[^.,;\/]$/i' + myDenyStringValidator: + values: [] + values_error: This Username is not allowed + sfPropelUniqueValidator: + class: Mailbox + column: name + unique_error: This Username already exists + mailbox{password}: + required: + msg: The Password is required + myPasswordValidator: + mailbox{domain_id}: + required: + msg: A Domain has to be specified + mailbox{max_quota}: + required: + msg: The Mailbox Quota is required + mailbox{max_address_count}: + required: + msg: The Maximum Address Count is required diff --git a/apps/admin/modules/mailbox/validate/edit.yml b/apps/admin/modules/mailbox/validate/edit.yml new file mode 100644 index 0000000..1629a9d --- /dev/null +++ b/apps/admin/modules/mailbox/validate/edit.yml @@ -0,0 +1,48 @@ +fillin: + enabled: true + param: + exclude_types: [password] + +validators: + myStringValidator: + class: sfStringValidator + param: + min: 2 + min_error: This field is too short (2 characters minimum) + max: 100 + max_error: This field is too long (100 characters maximum) + myPasswordValidator: + class: sfStringValidator + param: + min: 5 + min_error: The password is too short (5 characters minimum) + max: 100 + max_error: The password is too long (100 characters maximum) + +fields: + mailbox{name}: + required: + msg: The Username is required + myStringValidator: + sfRegexValidator: + match:..........Yes + match_error: 'The characters ".,;/" are not allowed' + pattern: '/[^.,;\/]$/i' + myDenyStringValidator: + values: [] + values_error: This Username is not allowed + sfPropelUniqueValidator: + class: Mailbox + column: name + unique_error: This Username already exists + mailbox{new_password}: + myPasswordValidator: + mailbox{domain_id}: + required: + msg: A Domain has to be specified + mailbox{max_quota}: + required: + msg: The Mailbox Quota is required + mailbox{max_address_count}: + required: + msg: The Maximum Address Count is required diff --git a/apps/admin/modules/server/actions/actions.class.php b/apps/admin/modules/server/actions/actions.class.php new file mode 100644 index 0000000..a83d9b9 --- /dev/null +++ b/apps/admin/modules/server/actions/actions.class.php @@ -0,0 +1,29 @@ +forward('server', 'imap'); + } + + public function executeImap() + { + $serverinfo = new IMAPServerInformation(); + $this->serverinfo = $serverinfo; + + return sfView::SUCCESS; + } +} diff --git a/apps/admin/modules/server/templates/imapSuccess.php b/apps/admin/modules/server/templates/imapSuccess.php new file mode 100644 index 0000000..57569ad --- /dev/null +++ b/apps/admin/modules/server/templates/imapSuccess.php @@ -0,0 +1,57 @@ +
+ +

IMAP Server Information

+ +
+ + + + + + + + + + + + + + + + + + + + + getServerName()) !== false): ?> + + + + + + + + + + + + + + + + + + hasCapability('ACL')): ?> + + + + + + + + +
Connection:
Host:getHost() ?>
Port:getPort() ?>
General:
Greeting:getGreeting() ?>
Server:getServerName() ?>
Version:getServerVersion() ?>
Hierarchy Delimiter:getHierarchyDelimiter() ?>
Capabilities:", $serverinfo->getCapabilties()) ?>
Extension: Access Control List (ACL)
Available ACL:getAvailableACL() ?>
+ +
+ +
diff --git a/apps/admin/modules/user/actions/actions.class.php b/apps/admin/modules/user/actions/actions.class.php new file mode 100644 index 0000000..1af2445 --- /dev/null +++ b/apps/admin/modules/user/actions/actions.class.php @@ -0,0 +1,115 @@ +hasRequestParameter("max_per_page")) + $this->getUser()->setResultsPerPage($this->getRequestParameter("max_per_page")); + + return parent::executeList(); + } + + public function executeCreate() + { + // populate preset values + $user = $this->getRequestParameter('user'); + $user["parent_user_id"] = $this->getUser()->getId(); + $this->getRequest()->setParameter('user', $user); + + $this->setTemplate("edit"); + return $this->executeEdit(); + } + + public function handleErrorCreate() + { + // populate preset values + $user = $this->getRequestParameter('user'); + $user["parent_user_id"] = $this->getUser()->getId(); + $this->getRequest()->setParameter('user', $user); + + $this->setTemplate("edit"); + return $this->handleErrorEdit(); + } + + public function executeLogin() + { + if($this->getRequest()->getMethod() != sfRequest::POST) + { + $this->getRequest()->setAttribute('referer', $this->getRequest()->getReferer()); + + return sfView::SUCCESS; + } + else + { + return $this->redirect($this->getRequestParameter('referer', '@homepage')); + } + } + + public function handleErrorLogin() + { + return sfView::SUCCESS; + } + + public function executeSettings() + { + $user = UserPeer::retrieveByPK($this->getUser()->getId()); + $this->user = $user; + + if($this->getRequest()->getMethod() != sfRequest::POST) + { + $this->getRequest()->setAttribute('referer', $this->getRequest()->getReferer()); + } + else + { + if($this->getRequest()->getParameter("commit") == "Cancel") + return $this->redirect($this->getRequestParameter('referer', '@homepage')); + + // update record + $user->setNickname($this->getRequestParameter("nickname")); + $user->setFirstName($this->getRequestParameter("first_name")); + $user->setLastName($this->getRequestParameter("last_name")); + $user->setEmail($this->getRequestParameter("email")); + + // set new password + $password = $this->getRequestParameter("password2"); + if($password != "") + $user->setPassword($password); + + $user->save(); + + // update session + $this->getUser()->updateUserAttributes($user); + + return $this->redirect($this->getRequestParameter('referer', '@homepage')); + } + + return sfView::SUCCESS; + } + + public function handleErrorSettings() + { + $user = UserPeer::retrieveByPK($this->getUser()->getId()); + $this->user = $user; + + if($this->getRequest()->getParameter("commit") == "Cancel") + return $this->redirect($this->getRequestParameter('referer', '@homepage')); + + return sfView::SUCCESS; + } + + public function executeLogout() + { + $this->getUser()->signOut($user); + $this->redirect("@homepage"); + } +} diff --git a/apps/admin/modules/user/config/generator.yml b/apps/admin/modules/user/config/generator.yml new file mode 100644 index 0000000..4764f5b --- /dev/null +++ b/apps/admin/modules/user/config/generator.yml @@ -0,0 +1,55 @@ +generator: + class: sfPropelAdminGenerator + param: + model_class: User + theme: mailadmin + + fields: + nickname: { name: Nickname } + full_name: { name: Name } + email: { name: E-Mail } + last_login: { name: Last Login } + + list: + peer_method: doSelectJoinRole + title: List of Administrators + display: [=nickname, _role_id, _domain_permissions, full_name, email, _last_login] + filters: [nickname, role_id, email, parent_user_id, last_login, created_at] + max_per_page: '$this->getUser()->getResultsPerPage("pager")' + sort: [nickname, asc] + fields: + domain_permissions: { name: Associated Domains, params: align=left } + nickname: { params: align=left } + role_id: { params: align=left } + full_name: { params: align=left } + email: { params: align=left } + last_login: { params: align=right } + object_actions: + edit: { name: Edit, action: edit, icon: edit.gif } + delete: { name: Delete, action: delete, icon: trash.gif, params: confirm=Are you sure? } + actions: {} + + create: + title: Create New Administrator + + edit: + title: 'Editing Administrator %%nickname%%' + display: + 'General Settings': [nickname, first_name, last_name, email, parent_user_id] + 'Password Settings': [_password, _password2] + 'Permissions': [role_id, domain_permission] + fields: + domain_permission: { name: Assign Domains, type: admin_double_list, params: through_class=DomainPermission, help: Assign which domains the user is allowed to see (Ignored for superadmins) } + parent_user_id: { name: Parent User, only_for: edit } + nickname: { name: Nickname, params: size=50 } + first_name: { name: First Name, params: size=50 } + last_name: { name: Last Name, params: size=50 } + email: { name: E-Mail, params: size=50, help: Used for password requests or notifications } + role_id: { name: Role } + password: { name: Desired Password } + password2: { name: Re-Type New Password, only_for: edit, help: Leave blank if you do not want to change the password } + actions: + _save_and_list: { name: Save } + _save_and_add: { name: 'Save, then create new one' } + _list: { name: Cancel } + diff --git a/apps/admin/modules/user/config/security.yml b/apps/admin/modules/user/config/security.yml new file mode 100644 index 0000000..dbe3ebb --- /dev/null +++ b/apps/admin/modules/user/config/security.yml @@ -0,0 +1,13 @@ +settings: + is_secure: on + credentials: [] + +login: + is_secure: off + +logout: + is_secure: off + +all: + is_secure: on + credentials: [superadmin] diff --git a/apps/admin/modules/user/templates/_domain_permissions.php b/apps/admin/modules/user/templates/_domain_permissions.php new file mode 100644 index 0000000..0d3e19d --- /dev/null +++ b/apps/admin/modules/user/templates/_domain_permissions.php @@ -0,0 +1,27 @@ + +getRoleId() == Role::SUPERADMIN): ?> + + +getDomainPermissionsJoinDomain() ?> + + + +
+ sfConfig::get('app_user_domain_perm_collapse_count')): ?> + count($list))), visual_effect( +'toggle_slide', 'domain_permissionlist_'.$user->getId())) ?> + + +
+ + diff --git a/apps/admin/modules/user/templates/_last_login.php b/apps/admin/modules/user/templates/_last_login.php new file mode 100644 index 0000000..f15439a --- /dev/null +++ b/apps/admin/modules/user/templates/_last_login.php @@ -0,0 +1 @@ +getLastLogin() ? $user->getLastLogin(): "Never") ?> diff --git a/apps/admin/modules/user/templates/_password.php b/apps/admin/modules/user/templates/_password.php new file mode 100644 index 0000000..e32e4ab --- /dev/null +++ b/apps/admin/modules/user/templates/_password.php @@ -0,0 +1,3 @@ + 50, +)); echo $value ? $value : ' ' ?> diff --git a/apps/admin/modules/user/templates/_password1.php b/apps/admin/modules/user/templates/_password1.php new file mode 100644 index 0000000..e32e4ab --- /dev/null +++ b/apps/admin/modules/user/templates/_password1.php @@ -0,0 +1,3 @@ + 50, +)); echo $value ? $value : ' ' ?> diff --git a/apps/admin/modules/user/templates/_password2.php b/apps/admin/modules/user/templates/_password2.php new file mode 100644 index 0000000..eab912d --- /dev/null +++ b/apps/admin/modules/user/templates/_password2.php @@ -0,0 +1,3 @@ + 50, +)); echo $value ? $value : ' ' ?> diff --git a/apps/admin/modules/user/templates/_role_id.php b/apps/admin/modules/user/templates/_role_id.php new file mode 100644 index 0000000..bfaf818 --- /dev/null +++ b/apps/admin/modules/user/templates/_role_id.php @@ -0,0 +1 @@ +getRole() ?> diff --git a/apps/admin/modules/user/templates/loginSuccess.php b/apps/admin/modules/user/templates/loginSuccess.php new file mode 100644 index 0000000..f41a809 --- /dev/null +++ b/apps/admin/modules/user/templates/loginSuccess.php @@ -0,0 +1,12 @@ +
+ +   +

:

+
+ get("nickname"), "size=50") ?>
+
+ getAttribute('referer')) ?> +
+ + +
diff --git a/apps/admin/modules/user/templates/settingsSuccess.php b/apps/admin/modules/user/templates/settingsSuccess.php new file mode 100644 index 0000000..f1c49d7 --- /dev/null +++ b/apps/admin/modules/user/templates/settingsSuccess.php @@ -0,0 +1,22 @@ +
+ + +

Update Settings:

+ +
+ +

General Settings:

+ +
+
+
+
Used to retrieve your password or to send critical notifications


+ +

Change Password:

+
+
+ getAttribute('referer')) ?> + +
+ +
diff --git a/apps/admin/modules/user/validate/create.yml b/apps/admin/modules/user/validate/create.yml new file mode 100644 index 0000000..7686c7b --- /dev/null +++ b/apps/admin/modules/user/validate/create.yml @@ -0,0 +1,37 @@ +fillin: + enabled: true + param: + exclude_types: [password] + +validators: + myStringValidator: + class: sfStringValidator + param: + min: 2 + min_error: This field is too short (2 characters minimum) + max: 100 + max_error: This field is too long (100 characters maximum) + +fields: + user{nickname}: + required: + msg: The Username is required + sfStringValidator: + min: 5 + min_error: Username must be 5 or more characters + sfPropelUniqueValidator: + class: User + column: nickname + unique_error: This Username does already exist + user{email}: + myStringValidator: + sfEmailValidator: + email_error: This E-Mail Address is invalid + user{password}: + required: + msg: You must define a password + myStringValidator: + user{role_id}: + required: + msg: You must set a role for this user + diff --git a/apps/admin/modules/user/validate/edit.yml b/apps/admin/modules/user/validate/edit.yml new file mode 100644 index 0000000..6480b37 --- /dev/null +++ b/apps/admin/modules/user/validate/edit.yml @@ -0,0 +1,40 @@ +fillin: + enabled: true + param: + exclude_types: [password] + +validators: + myStringValidator: + class: sfStringValidator + param: + min: 2 + min_error: This field is too short (2 characters minimum) + max: 100 + max_error: This field is too long (100 characters maximum) + +fields: + user{nickname}: + required: + msg: The Username is required + sfStringValidator: + min: 5 + min_error: Username must be 5 or more characters + sfPropelUniqueValidator: + class: User + column: nickname + unique_error: This Username does already exist + user{email}: + myStringValidator: + sfEmailValidator: + email_error: This E-Mail Address is invalid + user{role_id}: + required: + msg: You must set a role for this user + user{password}: + group: password_group + user{password2}: + group: password_group + sfCompareValidator: + check: "user[password]" + compare_error: The two passwords do not match + diff --git a/apps/admin/modules/user/validate/login.yml b/apps/admin/modules/user/validate/login.yml new file mode 100644 index 0000000..d6ea563 --- /dev/null +++ b/apps/admin/modules/user/validate/login.yml @@ -0,0 +1,24 @@ +methods: + post: [nickname, password] + +names: + nickname: + required: true + required_msg: Your Username is required + validators: [nicknameValidator, userValidator] + + password: + required: true + required_msg: Your password is required + +nicknameValidator: + class: sfStringValidator + param: + min: 5 + min_error: Username must be 5 or more characters + +userValidator: + class: myLoginValidator + param: + password: password + login_error: This Username does not exist or you entered a wrong password diff --git a/apps/admin/modules/user/validate/settings.yml b/apps/admin/modules/user/validate/settings.yml new file mode 100644 index 0000000..0706d53 --- /dev/null +++ b/apps/admin/modules/user/validate/settings.yml @@ -0,0 +1,43 @@ +fillin: + enabled: true + param: + exclude_types: [password] + +validators: + myStringValidator: + class: sfStringValidator + param: + min: 2 + min_error: This field is too short (2 characters minimum) + max: 100 + max_error: This field is too long (100 characters maximum) + +fields: + nickname: + required: + msg: Your Username is required + sfStringValidator: + min: 5 + min_error: Username must be 5 or more characters + myChangeNicknameValidator: + change_error: This Username does already exist + + first_name: + myStringValidator: + last_name: + myStringValidator: + + email: + required: + msg: Your must provide an E-Mail Address + myStringValidator: + sfEmailValidator: + email_error: This E-Mail Address is invalid + + password1: + group: password_group + password2: + group: password_group + sfCompareValidator: + check: password1 + compare_error: The two passwords do not match diff --git a/apps/admin/templates/_branding.php b/apps/admin/templates/_branding.php new file mode 100644 index 0000000..c035a54 --- /dev/null +++ b/apps/admin/templates/_branding.php @@ -0,0 +1,4 @@ + +
+ +
diff --git a/apps/admin/templates/_navigation.php b/apps/admin/templates/_navigation.php new file mode 100644 index 0000000..b991247 --- /dev/null +++ b/apps/admin/templates/_navigation.php @@ -0,0 +1,53 @@ + + + + + + + + + + + + hasCredential('superadmin')): ?> + + + + + + + + + + diff --git a/apps/admin/templates/_notes.php b/apps/admin/templates/_notes.php new file mode 100644 index 0000000..e994a50 --- /dev/null +++ b/apps/admin/templates/_notes.php @@ -0,0 +1,9 @@ + +
+ + © - +
diff --git a/apps/admin/templates/layout.php b/apps/admin/templates/layout.php new file mode 100644 index 0000000..d10d047 --- /dev/null +++ b/apps/admin/templates/layout.php @@ -0,0 +1,35 @@ + + + + + + + + + +
+ + +
+ isAuthenticated()): ?> + + + + +
+ isAuthenticated()): ?> + $sf_context->getModuleName(), "action" => $sf_context->getActionName())) ?> + + getRaw('sf_content') ?> + +
+ + diff --git a/config/config.php b/config/config.php new file mode 100644 index 0000000..381af2c --- /dev/null +++ b/config/config.php @@ -0,0 +1,5 @@ + +
diff --git a/config/propel.ini b/config/propel.ini new file mode 100644 index 0000000..92b813f --- /dev/null +++ b/config/propel.ini @@ -0,0 +1,44 @@ +propel.targetPackage = lib.model +propel.packageObjectModel = true +propel.project = mailadmin +propel.database = mysql +propel.database.createUrl = mysql://user:password@localhost/ +propel.database.url = mysql://ruser:password@localhost/mailadmin + +propel.addGenericAccessors = true +propel.addGenericMutators = true +propel.addTimeStamp = false + +propel.schema.validate = false + +; directories +propel.home = . +propel.output.dir = /home/mszulecki/projects/mailadmin +propel.schema.dir = ${propel.output.dir}/config +propel.conf.dir = ${propel.output.dir}/config +propel.phpconf.dir = ${propel.output.dir}/config +propel.sql.dir = ${propel.output.dir}/data/sql +propel.runtime.conf.file = runtime-conf.xml +propel.php.dir = ${propel.output.dir} +propel.default.schema.basename = schema +propel.datadump.mapper.from = *schema.xml +propel.datadump.mapper.to = *data.xml + +; builder settings +propel.builder.peer.class = addon.propel.builder.SfPeerBuilder +propel.builder.object.class = addon.propel.builder.SfObjectBuilder + +propel.builder.objectstub.class = addon.propel.builder.SfExtensionObjectBuilder +propel.builder.peerstub.class = addon.propel.builder.SfExtensionPeerBuilder +propel.builder.objectmultiextend.class = addon.propel.builder.SfMultiExtendObjectBuilder +propel.builder.mapbuilder.class = addon.propel.builder.SfMapBuilderBuilder +propel.builder.interface.class = propel.engine.builder.om.php5.PHP5InterfaceBuilder +propel.builder.node.class = propel.engine.builder.om.php5.PHP5NodeBuilder +propel.builder.nodepeer.class = propel.engine.builder.om.php5.PHP5NodePeerBuilder +propel.builder.nodestub.class = propel.engine.builder.om.php5.PHP5ExtensionNodeBuilder +propel.builder.nodepeerstub.class = propel.engine.builder.om.php5.PHP5ExtensionNodePeerBuilder + +propel.builder.addIncludes = false +propel.builder.addComments = false + +propel.builder.addBehaviors = false diff --git a/config/properties.ini b/config/properties.ini new file mode 100644 index 0000000..be28321 --- /dev/null +++ b/config/properties.ini @@ -0,0 +1,2 @@ +[symfony] + name=mailadmin diff --git a/config/rsync_exclude.txt b/config/rsync_exclude.txt new file mode 100644 index 0000000..4b76ea8 --- /dev/null +++ b/config/rsync_exclude.txt @@ -0,0 +1,4 @@ +.svn +/web/uploads/* +/cache/* +/log/* diff --git a/config/schema-transformed.xml b/config/schema-transformed.xml new file mode 100644 index 0000000..ea51a55 --- /dev/null +++ b/config/schema-transformed.xml @@ -0,0 +1,2 @@ + +
diff --git a/config/schema.yml b/config/schema.yml new file mode 100644 index 0000000..58f0f72 --- /dev/null +++ b/config/schema.yml @@ -0,0 +1,68 @@ +propel: + role: + _attributes: { phpName: Role } + id: + name: varchar(255) + credentials: varchar(255) + + user: + _attributes: { phpName: User } + id: + parent_user_id: { type: integer, default: -1, foreignTable: user, foreignReference: id, onDelete: setnull } + nickname: varchar(50) + first_name: varchar(100) + last_name: varchar(100) + email: varchar(255) + sha1_password: varchar(40) + salt: varchar(32) + role_id: + last_login: timestamp + created_at: + + domain_permission: + _attributes: { phpName: DomainPermission } + user_id: { type: integer, foreignTable: user, foreignReference: id, onDelete: cascade } + domain_id: { type: integer, foreignTable: domain, foreignReference: id, onDelete: cascade } + + domain: + _attributes: { phpName: Domain } + id: + name: varchar(255) + creator_id: { type: integer, foreignTable: user, foreignReference: id, onDelete: setnull } + mailbox_prefix: varchar(255) + max_mailbox_count: integer + quota: integer + default_mailbox_quota: integer + _uniques: + i2: [name] + + mailbox: + _attributes: { phpName: Mailbox } + id: + domain_id: { type: integer, foreignTable: domain, foreignReference: id, onDelete: setnull } + name: varchar(30) + password: varchar(40) + max_quota: integer + max_address_count: integer + last_login: timestamp + active: { type: boolean, default: true } + + address: + _attributes: { phpName: Address } + id: + mailbox_id: { type: integer, foreignTable: mailbox, foreignReference: id, onDelete: cascade } + localpart: varchar(255) + domain_id: + alias: varchar(255) + destination: longvarchar + active: { type: boolean, default: true } + save_in_mailbox: { type: boolean, default: true } + + log: + _attributes: { phpName: LogEntry } + id: + user_id: { type: integer, default: null, foreignTable: user, foreignReference: id, onDelete: setnull } + created_at: + message: longvarchar + host: varchar(255) + priority: integer diff --git a/data/fixtures/10-common_data.yml b/data/fixtures/10-common_data.yml new file mode 100644 index 0000000..f435ccc --- /dev/null +++ b/data/fixtures/10-common_data.yml @@ -0,0 +1,21 @@ +Role: + superadmin: + name: Superadmin + credentials: 'superadmin' + domainmaster: + name: Domain Master + credentials: 'domainmaster' + mailboxmaster: + name: Mailbox Master + credentials: 'mailboxmaster' + +User: + admin: + nickname: admin + first_name: + last_name: + email: + password: admin + role_id: superadmin + created_at: + diff --git a/data/generator/sfPropelAdmin/mailadmin/template/actions/actions.class.php b/data/generator/sfPropelAdmin/mailadmin/template/actions/actions.class.php new file mode 100644 index 0000000..70f94f0 --- /dev/null +++ b/data/generator/sfPropelAdmin/mailadmin/template/actions/actions.class.php @@ -0,0 +1,435 @@ +[?php + +/** + * getGeneratedModuleName() ?> actions. + * + * @package ##PROJECT_NAME## + * @subpackage getGeneratedModuleName() ?> + + * @author Fabien Potencier + * @version SVN: $Id: actions.class.php 3501 2007-02-18 10:28:17Z fabien $ + */ +class getGeneratedModuleName() ?>Actions extends sfActions +{ + public function executeIndex() + { + return $this->forward('getModuleName() ?>', 'list'); + } + + public function executeList() + { + $this->processSort(); + + $this->processFilters(); + +getParameterValue('list.filters')): ?> + $this->filters = $this->getUser()->getAttributeHolder()->getAll('sf_admin/getSingularName() ?>/filters'); + + + // pager + $this->pager = new sfPropelPager('getClassName() ?>', getParameterValue('list.max_per_page', 20) ?>); + $c = new Criteria(); + $this->addSortCriteria($c); + $this->addFiltersCriteria($c); + $this->pager->setCriteria($c); + $this->pager->setPage($this->getRequestParameter('page', 1)); +getParameterValue('list.peer_method')): ?> + $this->pager->setPeerMethod('getParameterValue('list.peer_method') ?>'); + +getParameterValue('list.peer_count_method')): ?> + $this->pager->setPeerCountMethod('getParameterValue('list.peer_count_method') ?>'); + + $this->pager->init(); + } + + public function executeCreate() + { + return $this->forward('getModuleName() ?>', 'edit'); + } + + public function executeSave() + { + return $this->forward('getModuleName() ?>', 'edit'); + } + + public function executeEdit() + { + $this->getSingularName() ?> = $this->getgetClassName() ?>OrCreate(); + + if ($this->getRequest()->getMethod() == sfRequest::POST) + { + $this->updategetClassName() ?>FromRequest(); + + $this->savegetClassName() ?>($this->getSingularName() ?>); + + $this->setFlash('notice', 'Your modifications have been saved'); + + if ($this->getRequestParameter('save_and_add')) + { + return $this->redirect('getModuleName() ?>/create'); + } + else if ($this->getRequestParameter('save_and_list')) + { + return $this->redirect('getModuleName() ?>/list'); + } + else + { + return $this->redirect('getModuleName() ?>/edit?getPrimaryKeyUrlParams('this->') ?>); + } + } + else + { + $this->labels = $this->getLabels(); + } + } + + public function executeDelete() + { + $this->getSingularName() ?> = getClassName() ?>Peer::retrieveByPk(getRetrieveByPkParamsForAction(40) ?>); + $this->forward404Unless($this->getSingularName() ?>); + + try + { + $this->deletegetClassName() ?>($this->getSingularName() ?>); + } + catch (PropelException $e) + { + $this->getRequest()->setError('delete', 'Could not delete the selected getSingularName()) ?>. Make sure it does not have any associated items.'); + return $this->forward('getModuleName() ?>', 'list'); + } + +getColumnCategories('edit.display') as $category): ?> +getColumns('edit.display', $category) as $name => $column): ?> +getParameterValue('edit.fields.'.$column->getName().'.type') ?> + +replaceConstants($this->getParameterValue('edit.fields.'.$column->getName().'.upload_dir')) ?> + $currentFile = sfConfig::get('sf_upload_dir')."//".$this->getSingularName() ?>->getgetPhpName() ?>(); + if (is_file($currentFile)) + { + unlink($currentFile); + } + + + + + return $this->redirect('getModuleName() ?>/list'); + } + + public function handleErrorEdit() + { + $this->preExecute(); + $this->getSingularName() ?> = $this->getgetClassName() ?>OrCreate(); + $this->updategetClassName() ?>FromRequest(); + + $this->labels = $this->getLabels(); + + return sfView::SUCCESS; + } + + protected function savegetClassName() ?>($getSingularName() ?>) + { + $getSingularName() ?>->save(); + +getColumnCategories('edit.display') as $category): ?> +getColumns('edit.display', $category) as $name => $column): $type = $column->getCreoleType(); ?> +getName() ?> +isPrimaryKey()) continue ?> +getParameterValue('edit.fields.'.$column->getName().'.credentials') ?> +getParameterValue('edit.fields.'.$column->getName().'.type') ?> +getParameterValue('edit.fields.'.$column->getName().'.params'); +$user_params = is_array($user_params) ? $user_params : sfToolkit::stringToArray($user_params); +$through_class = isset($user_params['through_class']) ? $user_params['through_class'] : ''; + +?> + +getClassName(); +$related_class = sfPropelManyToMany::getRelatedClass($class, $through_class); +$related_table = constant($related_class.'Peer::TABLE_NAME'); +$middle_table = constant($through_class.'Peer::TABLE_NAME'); +$this_table = constant($class.'Peer::TABLE_NAME'); + +$related_column = sfPropelManyToMany::getRelatedColumn($class, $through_class); +$column = sfPropelManyToMany::getColumn($class, $through_class); + +?> + + + if ($this->getUser()->hasCredential()) + { + + // Update many-to-many for "" + $c = new Criteria(); + $c->add(Peer::getColumnName()) ?>, $getSingularName() ?>->getPrimaryKey()); + Peer::doDelete($c); + + $ids = $this->getRequestParameter('associated_'); + if (is_array($ids)) + { + foreach ($ids as $id) + { + $ = new (); + $->setgetPhpName() ?>($getSingularName() ?>->getPrimaryKey()); + $->setgetPhpName() ?>($id); + $->save(); + } + } + + + } + + + + + + } + + protected function deletegetClassName() ?>($getSingularName() ?>) + { + $getSingularName() ?>->delete(); + } + + protected function updategetClassName() ?>FromRequest() + { + $getSingularName() ?> = $this->getRequestParameter('getSingularName() ?>'); + +getColumnCategories('edit.display') as $category): ?> +getColumns('edit.display', $category) as $name => $column): $type = $column->getCreoleType(); ?> +getName() ?> +isPrimaryKey()) continue ?> +getParameterValue('edit.fields.'.$column->getName().'.credentials') ?> +getParameterValue('edit.fields.'.$column->getName().'.type') ?> + + if ($this->getUser()->hasCredential()) + { + + +replaceConstants($this->getParameterValue('edit.fields.'.$column->getName().'.upload_dir')) ?> + $currentFile = sfConfig::get('sf_upload_dir')."//".$this->getSingularName() ?>->getgetPhpName() ?>(); + if (!$this->getRequest()->hasErrors() && isset($getSingularName() ?>['_remove'])) + { + $this->getSingularName() ?>->setgetPhpName() ?>(''); + if (is_file($currentFile)) + { + unlink($currentFile); + } + } + + if (!$this->getRequest()->hasErrors() && $this->getRequest()->getFileSize('getSingularName() ?>[]')) + { + + if (isset($getSingularName() ?>[''])) + { + + +getParameterValue('edit.fields.'.$column->getName().'.filename')): ?> + $fileName = "replaceConstants($this->getParameterValue('edit.fields.'.$column->getName().'.filename'))) ?>"; + + $fileName = md5($this->getRequest()->getFileName('getSingularName() ?>[]').time().rand(0, 99999)); + + $ext = $this->getRequest()->getFileExtension('getSingularName() ?>[]'); + if (is_file($currentFile)) + { + unlink($currentFile); + } + $this->getRequest()->moveFile('getSingularName() ?>[]', sfConfig::get('sf_upload_dir')."//".$fileName.$ext); + $this->getSingularName() ?>->setgetPhpName() ?>($fileName.$ext); + + if ($getSingularName() ?>['']) + { + try + { + $dateFormat = new sfDateFormat($this->getUser()->getCulture()); + + + if (!is_array($getSingularName() ?>[''])) + { + $value = $dateFormat->format($getSingularName() ?>[''], '', $dateFormat->getInputPattern('')); + } + else + { + $value_array = $getSingularName() ?>['']; + $value = $value_array['year'].'-'.$value_array['month'].'-'.$value_array['day'].(isset($value_array['hour']) ? ' '.$value_array['hour'].':'.$value_array['minute'].(isset($value_array['second']) ? ':'.$value_array['second'] : '') : ''); + } + $this->getSingularName() ?>->setgetPhpName() ?>($value); + } + catch (sfException $e) + { + // not a date + } + } + else + { + $this->getSingularName() ?>->setgetPhpName() ?>(null); + } + + $this->getSingularName() ?>->setgetPhpName() ?>(isset($getSingularName() ?>['']) ? $getSingularName() ?>[''] : 0); +isForeignKey()): ?> + $this->getSingularName() ?>->setgetPhpName() ?>($getSingularName() ?>[''] ? $getSingularName() ?>[''] : null); + + $this->getSingularName() ?>->setgetPhpName() ?>($getSingularName() ?>['']); + + + } + + + } + + + + } + + protected function getgetClassName() ?>OrCreate(getMethodParamsForGetOrCreate() ?>) + { + if (getTestPksForGetOrCreate() ?>) + { + $getSingularName() ?> = new getClassName() ?>(); + } + else + { + $getSingularName() ?> = getClassName() ?>Peer::retrieveByPk(getRetrieveByPkParamsForGetOrCreate() ?>); + + $this->forward404Unless($getSingularName() ?>); + } + + return $getSingularName() ?>; + } + + protected function processFilters() + { +getParameterValue('list.filters')): ?> + if ($this->getRequest()->hasParameter('filter')) + { + $filters = $this->getRequestParameter('filters'); +getColumns('list.filters') as $column): $type = $column->getCreoleType() ?> + + if (isset($filters['getName() ?>']['from']) && $filters['getName() ?>']['from'] !== '') + { + $filters['getName() ?>']['from'] = sfI18N::getTimestampForCulture($filters['getName() ?>']['from'], $this->getUser()->getCulture()); + } + if (isset($filters['getName() ?>']['to']) && $filters['getName() ?>']['to'] !== '') + { + $filters['getName() ?>']['to'] = sfI18N::getTimestampForCulture($filters['getName() ?>']['to'], $this->getUser()->getCulture()); + } + + + + $this->getUser()->getAttributeHolder()->removeNamespace('sf_admin/getSingularName() ?>/filters'); + $this->getUser()->getAttributeHolder()->add($filters, 'sf_admin/getSingularName() ?>/filters'); + } + + } + + protected function processSort() + { + if ($this->getRequestParameter('sort')) + { + $this->getUser()->setAttribute('sort', $this->getRequestParameter('sort'), 'sf_admin/getSingularName() ?>/sort'); + $this->getUser()->setAttribute('type', $this->getRequestParameter('type', 'asc'), 'sf_admin/getSingularName() ?>/sort'); + } + + if (!$this->getUser()->getAttribute('sort', null, 'sf_admin/getSingularName() ?>/sort')) + { +getParameterValue('list.sort')): ?> + + $this->getUser()->setAttribute('sort', '', 'sf_admin/getSingularName() ?>/sort'); + $this->getUser()->setAttribute('type', '', 'sf_admin/getSingularName() ?>/sort'); + + $this->getUser()->setAttribute('sort', '', 'sf_admin/getSingularName() ?>/sort'); + $this->getUser()->setAttribute('type', 'asc', 'sf_admin/getSingularName() ?>/sort'); + + + } + } + + protected function addFiltersCriteria($c) + { +getParameterValue('list.filters')): ?> +getColumns('list.filters') as $column): $type = $column->getCreoleType() ?> +isPartial() || $column->isComponent()) && $this->getParameterValue('list.fields.'.$column->getName().'.filter_criteria_disabled')) continue ?> + if (isset($this->filters['getName() ?>_is_empty'])) + { + $criterion = $c->getNewCriterion(getPeerClassName() ?>::getName()) ?>, ''); + $criterion->addOr($c->getNewCriterion(getPeerClassName() ?>::getName()) ?>, null, Criteria::ISNULL)); + $c->add($criterion); + } + + else if (isset($this->filters['getName() ?>'])) + { + if (isset($this->filters['getName() ?>']['from']) && $this->filters['getName() ?>']['from'] !== '') + { + + $criterion = $c->getNewCriterion(getPeerClassName() ?>::getName()) ?>, date('Y-m-d', $this->filters['getName() ?>']['from']), Criteria::GREATER_EQUAL); + + $criterion = $c->getNewCriterion(getPeerClassName() ?>::getName()) ?>, $this->filters['getName() ?>']['from'], Criteria::GREATER_EQUAL); + + } + if (isset($this->filters['getName() ?>']['to']) && $this->filters['getName() ?>']['to'] !== '') + { + if (isset($criterion)) + { + + $criterion->addAnd($c->getNewCriterion(getPeerClassName() ?>::getName()) ?>, date('Y-m-d', $this->filters['getName() ?>']['to']), Criteria::LESS_EQUAL)); + + $criterion->addAnd($c->getNewCriterion(getPeerClassName() ?>::getName()) ?>, $this->filters['getName() ?>']['to'], Criteria::LESS_EQUAL)); + + } + else + { + + $criterion = $c->getNewCriterion(getPeerClassName() ?>::getName()) ?>, date('Y-m-d', $this->filters['getName() ?>']['to']), Criteria::LESS_EQUAL); + + $criterion = $c->getNewCriterion(getPeerClassName() ?>::getName()) ?>, $this->filters['getName() ?>']['to'], Criteria::LESS_EQUAL); + + } + } + + if (isset($criterion)) + { + $c->add($criterion); + } + } + + else if (isset($this->filters['getName() ?>']) && $this->filters['getName() ?>'] !== '') + { + + $c->add(getPeerClassName() ?>::getName()) ?>, strtr($this->filters['getName() ?>'], '*', '%'), Criteria::LIKE); + + $c->add(getPeerClassName() ?>::getName()) ?>, $this->filters['getName() ?>']); + + } + + + + } + + protected function addSortCriteria($c) + { + if ($sort_column = $this->getUser()->getAttribute('sort', null, 'sf_admin/getSingularName() ?>/sort')) + { + $sort_column = getClassName() ?>Peer::translateFieldName($sort_column, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_COLNAME); + if ($this->getUser()->getAttribute('type', null, 'sf_admin/getSingularName() ?>/sort') == 'asc') + { + $c->addAscendingOrderByColumn($sort_column); + } + else + { + $c->addDescendingOrderByColumn($sort_column); + } + } + } + + protected function getLabels() + { + return array( +getColumnCategories('edit.display') as $category): ?> +getColumns('edit.display', $category) as $name => $column): ?> + 'getSingularName() ?>{getName() ?>}' => 'getParameterValue('edit.fields.'.$column->getName().'.name')); echo $label_name ?>:', + + + ); + } +} diff --git a/data/generator/sfPropelAdmin/mailadmin/template/templates/_edit_actions.php b/data/generator/sfPropelAdmin/mailadmin/template/templates/_edit_actions.php new file mode 100644 index 0000000..1d0d720 --- /dev/null +++ b/data/generator/sfPropelAdmin/mailadmin/template/templates/_edit_actions.php @@ -0,0 +1,13 @@ + diff --git a/data/generator/sfPropelAdmin/mailadmin/template/templates/_edit_footer.php b/data/generator/sfPropelAdmin/mailadmin/template/templates/_edit_footer.php new file mode 100644 index 0000000..e69de29 diff --git a/data/generator/sfPropelAdmin/mailadmin/template/templates/_edit_form.php b/data/generator/sfPropelAdmin/mailadmin/template/templates/_edit_form.php new file mode 100644 index 0000000..47c385e --- /dev/null +++ b/data/generator/sfPropelAdmin/mailadmin/template/templates/_edit_form.php @@ -0,0 +1,93 @@ +[?php echo form_tag('getModuleName() ?>/'.$sf_context->getActionName(), array( + 'id' => 'sf_admin_edit_form', + 'name' => 'sf_admin_edit_form', + 'multipart' => true, +getColumnCategories('edit.display') as $category): ?> +getColumns('edit.display', $category) as $name => $column): ?> +getParameterValue('edit.fields.'.$column->getName().'.type')): ?> + 'onsubmit' => 'double_list_submit(); return true;' + + + + +)) ?] + +getPrimaryKey() as $pk): ?> +[?php echo object_input_hidden_tag($getSingularName() ?>, 'getgetPhpName() ?>') ?] + + + +getColumnCategories('edit.display') as $category): ?> + +
+

[?php echo __('') ?]

+ + + +getParameterValue('edit.hide', array()) ?> +getColumns('edit.display', $category) as $name => $column): ?> +getName(), $hides)) continue ?> +isPrimaryKey()) continue ?> +getParameterValue('edit.fields.'.$column->getName().'.credentials') ?> + + [?php if ($sf_user->hasCredential()): ?] + +getParameterValue('edit.fields.'.$column->getName().'.only_for'); if($only_for): ?> +[?php if($sf_context->getActionName()==''): ?] + +
+ [?php echo label_for('getParameterValue("edit.fields.".$column->getName().".label_for", $this->getSingularName()."[".$column->getName()."]") ?>', __($labels['getSingularName() ?>{getName() ?>}']), 'isNotNull()): ?>class="required" ') ?] +
+ [?php if ($sf_request->hasError('getSingularName() ?>{getName() ?>}')): ?] + [?php echo form_error('getSingularName() ?>{getName() ?>}', array('class' => 'form-error-msg')) ?] + [?php endif; ?] + [?php $value = getColumnEditTag($column); ?>; echo $value ? $value : ' ' ?] + getHelp($column, 'edit') ?> +
+
+ + +[?php endif; ?] + + + + [?php endif; ?] + + + +
+ + +[?php include_partial('edit_actions', array('getSingularName() ?>' => $getSingularName() ?>)) ?] + + + + diff --git a/data/generator/sfPropelAdmin/mailadmin/template/templates/_edit_header.php b/data/generator/sfPropelAdmin/mailadmin/template/templates/_edit_header.php new file mode 100644 index 0000000..e69de29 diff --git a/data/generator/sfPropelAdmin/mailadmin/template/templates/_edit_messages.php b/data/generator/sfPropelAdmin/mailadmin/template/templates/_edit_messages.php new file mode 100644 index 0000000..2306f05 --- /dev/null +++ b/data/generator/sfPropelAdmin/mailadmin/template/templates/_edit_messages.php @@ -0,0 +1,5 @@ +[?php if ($sf_flash->has('notice')): ?] +
+

[?php echo __($sf_flash->get('notice')) ?]

+
+[?php endif; ?] diff --git a/data/generator/sfPropelAdmin/mailadmin/template/templates/_filters.php b/data/generator/sfPropelAdmin/mailadmin/template/templates/_filters.php new file mode 100644 index 0000000..76be382 --- /dev/null +++ b/data/generator/sfPropelAdmin/mailadmin/template/templates/_filters.php @@ -0,0 +1,36 @@ +[?php use_helper('Object') ?] + +getParameterValue('list.filters')): ?> + + diff --git a/data/generator/sfPropelAdmin/mailadmin/template/templates/_list.php b/data/generator/sfPropelAdmin/mailadmin/template/templates/_list.php new file mode 100644 index 0000000..cc85625 --- /dev/null +++ b/data/generator/sfPropelAdmin/mailadmin/template/templates/_list.php @@ -0,0 +1,18 @@ + + +getParameterValue('list.object_actions')): ?> +[?php $c = 0; ?] +getParameterValue('list.object_actions') as $actionName => $params): ?> + addCredentialCondition('[?php $c++; ?]', $params) ?> + + + +[?php include_partial('list_th_getParameterValue('list.layout', 'tabular') ?>') ?] + +[?php $i = 1; foreach ($pager->getResults() as $getSingularName() ?>): $odd = fmod(++$i, 2) ?] + +[?php include_partial('list_td_actions', array('getSingularName() ?>' => $getSingularName() ?>)) ?] +[?php include_partial('list_td_getParameterValue('list.layout', 'tabular') ?>', array('getSingularName() ?>' => $getSingularName() ?>)) ?] + +[?php endforeach; ?] +
[?php echo __('Actions') ?]
diff --git a/data/generator/sfPropelAdmin/mailadmin/template/templates/_list_actions.php b/data/generator/sfPropelAdmin/mailadmin/template/templates/_list_actions.php new file mode 100644 index 0000000..a13263c --- /dev/null +++ b/data/generator/sfPropelAdmin/mailadmin/template/templates/_list_actions.php @@ -0,0 +1,10 @@ + diff --git a/data/generator/sfPropelAdmin/mailadmin/template/templates/_list_footer.php b/data/generator/sfPropelAdmin/mailadmin/template/templates/_list_footer.php new file mode 100644 index 0000000..e69de29 diff --git a/data/generator/sfPropelAdmin/mailadmin/template/templates/_list_header.php b/data/generator/sfPropelAdmin/mailadmin/template/templates/_list_header.php new file mode 100644 index 0000000..e69de29 diff --git a/data/generator/sfPropelAdmin/mailadmin/template/templates/_list_messages.php b/data/generator/sfPropelAdmin/mailadmin/template/templates/_list_messages.php new file mode 100644 index 0000000..c2eb7c7 --- /dev/null +++ b/data/generator/sfPropelAdmin/mailadmin/template/templates/_list_messages.php @@ -0,0 +1,13 @@ +[?php if ($sf_request->getError('delete')): ?] +
+

Could not delete the selected getSingularName()) ?>

+ +
+[?php endif; ?] +[?php if ($sf_flash->has('notice')): ?] +
+

[?php echo image_tag("information.gif","alt=[?]")?] [?php echo __($sf_flash->get('notice')) ?]

+
+[?php endif; ?] diff --git a/data/generator/sfPropelAdmin/mailadmin/template/templates/_list_td_actions.php b/data/generator/sfPropelAdmin/mailadmin/template/templates/_list_td_actions.php new file mode 100644 index 0000000..fcaca78 --- /dev/null +++ b/data/generator/sfPropelAdmin/mailadmin/template/templates/_list_td_actions.php @@ -0,0 +1,5 @@ +getParameterValue('list.object_actions')): ?> +getParameterValue('list.object_actions') as $actionName => $params): ?> + addCredentialCondition("", $params) ?> + + diff --git a/data/generator/sfPropelAdmin/mailadmin/template/templates/_list_td_stacked.php b/data/generator/sfPropelAdmin/mailadmin/template/templates/_list_td_stacked.php new file mode 100644 index 0000000..0d9e274 --- /dev/null +++ b/data/generator/sfPropelAdmin/mailadmin/template/templates/_list_td_stacked.php @@ -0,0 +1,16 @@ + +getParameterValue('list.params')): ?> + getI18NString('list.params') ?> + +getParameterValue('list.hide', array()) ?> +getColumns('list.display') as $column): ?> +getName(), $hides)) continue ?> + isLink()): ?> + [?php echo link_to(getColumnListTag($column) ?> ? getColumnListTag($column) ?> : __('-'), 'getModuleName() ?>/edit?getPrimaryKeyUrlParams() ?>) ?] + + [?php echo getColumnListTag($column) ?> ?] + + - + + + \ No newline at end of file diff --git a/data/generator/sfPropelAdmin/mailadmin/template/templates/_list_td_tabular.php b/data/generator/sfPropelAdmin/mailadmin/template/templates/_list_td_tabular.php new file mode 100644 index 0000000..e4e50bb --- /dev/null +++ b/data/generator/sfPropelAdmin/mailadmin/template/templates/_list_td_tabular.php @@ -0,0 +1,30 @@ +getParameterValue('list.hide', array()) ?> +getColumns('list.display') as $column): ?> +getName(), $hs)) continue ?> +getParameterValue('list.fields.'.$column->getName().'.credentials') ?> + + [?php if ($sf_user->hasCredential()): ?] + + getParameterValue('list.fields.'.$column->getName().'.params'); + $user_params = is_array($user_params) ? sfToolkit::stringToArray($user_params) : $user_params; + ?> + isLink()): ?> + + getParameterValue('list.object_actions.edit.credentials'); ?> + + [?php if ($sf_user->hasCredential()): ?] + + [?php echo tag('td', , true) ?][?php echo link_to(getColumnListTag($column) ?> ? getColumnListTag($column) ?> : __('-'), 'getModuleName() ?>/edit?getPrimaryKeyUrlParams() ?>) ?] + + [?php else: ?] + [?php echo tag('td', , true) ?][?php echo getColumnListTag($column) ?> ?] + [?php endif; ?] + + + [?php echo tag('td', , true) ?][?php echo getColumnListTag($column) ?> ?] + + + [?php endif; ?] + + diff --git a/data/generator/sfPropelAdmin/mailadmin/template/templates/_list_th_stacked.php b/data/generator/sfPropelAdmin/mailadmin/template/templates/_list_th_stacked.php new file mode 100644 index 0000000..305bdcf --- /dev/null +++ b/data/generator/sfPropelAdmin/mailadmin/template/templates/_list_th_stacked.php @@ -0,0 +1 @@ +[?php include_partial('list_th_tabular') ?] diff --git a/data/generator/sfPropelAdmin/mailadmin/template/templates/_list_th_tabular.php b/data/generator/sfPropelAdmin/mailadmin/template/templates/_list_th_tabular.php new file mode 100644 index 0000000..4a48eca --- /dev/null +++ b/data/generator/sfPropelAdmin/mailadmin/template/templates/_list_th_tabular.php @@ -0,0 +1,28 @@ +getParameterValue('list.hide', array()) ?> +getColumns('list.display') as $column): ?> +getName(), $hides)) continue ?> +getParameterValue('list.fields.'.$column->getName().'.credentials') ?> + + [?php if ($sf_user->hasCredential()): ?] + + getParameterValue('list.fields.'.$column->getName().'.params'); + $user_params = is_array($user_params) ? $user_params : sfToolkit::stringToArray($user_params); + $user_params['id'] = "sf_admin_list_th_".$column->getName(); + ?> + [?php echo tag('th', , true) ?] + isReal()): ?> + [?php if ($sf_user->getAttribute('sort', null, 'sf_admin/getSingularName() ?>/sort') == 'getName() ?>'): ?] + [?php echo link_to(__('getParameterValue('list.fields.'.$column->getName().'.name')) ?>'), 'getModuleName() ?>/list?sort=getName() ?>&type='.($sf_user->getAttribute('type', 'asc', 'sf_admin/getSingularName() ?>/sort') == 'asc' ? 'desc' : 'asc')) ?][?php $sorttype = $sf_user->getAttribute('type', 'asc','sf_admin/getSingularName() ?>/sort'); if($sorttype=='images') $sorttype = 'desc'; ?][?php echo image_tag('sort-'.$sorttype.'.gif', array('alt' => __($sorttype), 'border' => 0)) ?] + [?php else: ?] + [?php echo link_to(__('getParameterValue('list.fields.'.$column->getName().'.name')) ?>'), 'getModuleName() ?>/list?sort=getName() ?>&type=asc') ?] + [?php endif; ?] + + [?php echo __('getParameterValue('list.fields.'.$column->getName().'.name')) ?>') ?] + + getHelpAsIcon($column, 'list') ?> + + + [?php endif; ?] + + diff --git a/data/generator/sfPropelAdmin/mailadmin/template/templates/_pager.php b/data/generator/sfPropelAdmin/mailadmin/template/templates/_pager.php new file mode 100644 index 0000000..818d925 --- /dev/null +++ b/data/generator/sfPropelAdmin/mailadmin/template/templates/_pager.php @@ -0,0 +1,13 @@ +[?php if($pager->getNbResults() > 25 || $pager->haveToPaginate()): ?] +
+ +
+[?php endif; ?] diff --git a/data/generator/sfPropelAdmin/mailadmin/template/templates/editSuccess.php b/data/generator/sfPropelAdmin/mailadmin/template/templates/editSuccess.php new file mode 100644 index 0000000..2727a2c --- /dev/null +++ b/data/generator/sfPropelAdmin/mailadmin/template/templates/editSuccess.php @@ -0,0 +1,20 @@ +[?php use_helper('Object', 'Validation', 'ObjectAdmin', 'I18N', 'Date') ?] + +
+ +

[?php echo ($sf_context->getActionName()=='create' ? getI18NString('create.title', 'create '.$this->getModuleName(), false) ?>: getI18NString('edit.title', 'edit '.$this->getModuleName(), false) ?>) ?]

+ +
+[?php include_partial('getModuleName() ?>/edit_header', array('getSingularName() ?>' => $getSingularName() ?>)) ?] +
+ +
+[?php include_partial('getModuleName() ?>/edit_messages', array('getSingularName() ?>' => $getSingularName() ?>, 'labels' => $labels)) ?] +[?php include_partial('getModuleName() ?>/edit_form', array('getSingularName() ?>' => $getSingularName() ?>, 'labels' => $labels)) ?] +
+ + + +
diff --git a/data/generator/sfPropelAdmin/mailadmin/template/templates/listSuccess.php b/data/generator/sfPropelAdmin/mailadmin/template/templates/listSuccess.php new file mode 100644 index 0000000..c92aaf4 --- /dev/null +++ b/data/generator/sfPropelAdmin/mailadmin/template/templates/listSuccess.php @@ -0,0 +1,38 @@ +[?php use_helper('I18N', 'Date', 'Tag', 'Javascript') ?] + +
+ +

getI18NString('list.title', $this->getModuleName().' list') ?>

+ +
+[?php include_partial('getModuleName() ?>/list_header', array('pager' => $pager)) ?] +[?php include_partial('getModuleName() ?>/list_messages', array('pager' => $pager)) ?] +
+ +
+[?php echo __('Results') ?]: [?php echo $pager->getNbResults() ?]Entries per Page: [?php echo select_tag("resultsperpage", options_for_select(getParameterValue('list.max_per_page_options', array(10,25,50,100)); var_export(@array_combine($opt,$opt)); ?>, $pager->getMaxPerPage()), array("onchange" => "document.location.href = '".url_for('getModuleName() ?>/list')."?max_per_page='+this.value")) ?]getParameterValue('list.filters')): ?>[?php echo link_to_function(__('Toggle Filter Settings'), visual_effect('toggle_blind', 'sf_admin_filters' )) ?] + + +getParameterValue('list.filters')): ?> +
+[?php include_partial('filters', array('filters' => $filters)) ?] +
+ + +[?php include_partial('pager', array('pager' => $pager, 'location' => 'top')) ?] +
+[?php if (!$pager->getNbResults()): ?] +[?php echo __('no result') ?] +[?php else: ?] +[?php include_partial('getModuleName() ?>/list', array('pager' => $pager)) ?] +[?php endif; ?] +
+[?php include_partial('pager', array('pager' => $pager, 'location' => 'bottom')) ?] +[?php include_partial('list_actions') ?] +
+ + + +
diff --git a/data/sql/lib.model.schema.sql b/data/sql/lib.model.schema.sql new file mode 100644 index 0000000..ffbe542 --- /dev/null +++ b/data/sql/lib.model.schema.sql @@ -0,0 +1,181 @@ + +# This is a fix for InnoDB in MySQL >= 4.1.x +# It "suspends judgement" for fkey relationships until are tables are set. +SET FOREIGN_KEY_CHECKS = 0; + +#----------------------------------------------------------------------------- +#-- role +#----------------------------------------------------------------------------- + +DROP TABLE IF EXISTS `role`; + + +CREATE TABLE `role` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `name` VARCHAR(255), + `credentials` VARCHAR(255), + PRIMARY KEY (`id`) +)Type=MyISAM; + +#----------------------------------------------------------------------------- +#-- user +#----------------------------------------------------------------------------- + +DROP TABLE IF EXISTS `user`; + + +CREATE TABLE `user` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `parent_user_id` INTEGER default -1, + `nickname` VARCHAR(50), + `first_name` VARCHAR(100), + `last_name` VARCHAR(100), + `email` VARCHAR(255), + `sha1_password` VARCHAR(40), + `salt` VARCHAR(32), + `role_id` INTEGER, + `last_login` DATETIME, + `created_at` DATETIME, + PRIMARY KEY (`id`), + INDEX `user_FI_1` (`parent_user_id`), + CONSTRAINT `user_FK_1` + FOREIGN KEY (`parent_user_id`) + REFERENCES `user` (`id`) + ON DELETE SET NULL, + INDEX `user_FI_2` (`role_id`), + CONSTRAINT `user_FK_2` + FOREIGN KEY (`role_id`) + REFERENCES `role` (`id`) +)Type=MyISAM; + +#----------------------------------------------------------------------------- +#-- domain_permission +#----------------------------------------------------------------------------- + +DROP TABLE IF EXISTS `domain_permission`; + + +CREATE TABLE `domain_permission` +( + `user_id` INTEGER, + `domain_id` INTEGER, + `id` INTEGER NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`id`), + INDEX `domain_permission_FI_1` (`user_id`), + CONSTRAINT `domain_permission_FK_1` + FOREIGN KEY (`user_id`) + REFERENCES `user` (`id`) + ON DELETE CASCADE, + INDEX `domain_permission_FI_2` (`domain_id`), + CONSTRAINT `domain_permission_FK_2` + FOREIGN KEY (`domain_id`) + REFERENCES `domain` (`id`) + ON DELETE CASCADE +)Type=MyISAM; + +#----------------------------------------------------------------------------- +#-- domain +#----------------------------------------------------------------------------- + +DROP TABLE IF EXISTS `domain`; + + +CREATE TABLE `domain` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `name` VARCHAR(255), + `creator_id` INTEGER, + `mailbox_prefix` VARCHAR(255), + `max_mailbox_count` INTEGER, + `quota` INTEGER, + `default_mailbox_quota` INTEGER, + PRIMARY KEY (`id`), + UNIQUE KEY `i2` (`name`), + INDEX `domain_FI_1` (`creator_id`), + CONSTRAINT `domain_FK_1` + FOREIGN KEY (`creator_id`) + REFERENCES `user` (`id`) + ON DELETE SET NULL +)Type=MyISAM; + +#----------------------------------------------------------------------------- +#-- mailbox +#----------------------------------------------------------------------------- + +DROP TABLE IF EXISTS `mailbox`; + + +CREATE TABLE `mailbox` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `domain_id` INTEGER, + `name` VARCHAR(30), + `password` VARCHAR(40), + `max_quota` INTEGER, + `max_address_count` INTEGER, + `last_login` DATETIME, + `active` INTEGER default 1, + PRIMARY KEY (`id`), + INDEX `mailbox_FI_1` (`domain_id`), + CONSTRAINT `mailbox_FK_1` + FOREIGN KEY (`domain_id`) + REFERENCES `domain` (`id`) + ON DELETE SET NULL +)Type=MyISAM; + +#----------------------------------------------------------------------------- +#-- address +#----------------------------------------------------------------------------- + +DROP TABLE IF EXISTS `address`; + + +CREATE TABLE `address` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `mailbox_id` INTEGER, + `localpart` VARCHAR(255), + `domain_id` INTEGER, + `alias` VARCHAR(255), + `destination` TEXT, + `active` INTEGER default 1, + `save_in_mailbox` INTEGER default 1, + PRIMARY KEY (`id`), + INDEX `address_FI_1` (`mailbox_id`), + CONSTRAINT `address_FK_1` + FOREIGN KEY (`mailbox_id`) + REFERENCES `mailbox` (`id`) + ON DELETE CASCADE, + INDEX `address_FI_2` (`domain_id`), + CONSTRAINT `address_FK_2` + FOREIGN KEY (`domain_id`) + REFERENCES `domain` (`id`) +)Type=MyISAM; + +#----------------------------------------------------------------------------- +#-- log +#----------------------------------------------------------------------------- + +DROP TABLE IF EXISTS `log`; + + +CREATE TABLE `log` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `user_id` INTEGER default null, + `created_at` DATETIME, + `message` TEXT, + `host` VARCHAR(255), + `priority` INTEGER, + PRIMARY KEY (`id`), + INDEX `log_FI_1` (`user_id`), + CONSTRAINT `log_FK_1` + FOREIGN KEY (`user_id`) + REFERENCES `user` (`id`) + ON DELETE SET NULL +)Type=MyISAM; + +# This restores the fkey checks, after having unset them earlier +SET FOREIGN_KEY_CHECKS = 1; diff --git a/data/sql/sqldb.map b/data/sql/sqldb.map new file mode 100644 index 0000000..83d47c5 --- /dev/null +++ b/data/sql/sqldb.map @@ -0,0 +1,2 @@ +# Sqlfile -> Database map +lib.model.schema.sql=propel diff --git a/lib/helper/FilesHelper.php b/lib/helper/FilesHelper.php new file mode 100644 index 0000000..ff290d6 --- /dev/null +++ b/lib/helper/FilesHelper.php @@ -0,0 +1,27 @@ +=$factor;$i++) + $val /= $factor; + $p = strpos($val, "."); + if($p !== false && $p > $digits) $val = round($val); + elseif($p !== false) $val = round($val, $digits-$p); + return round($val, $digits) . " " . $symbols[$i] . $bB; +} + +?> diff --git a/lib/helper/SortHeaderHelper.php b/lib/helper/SortHeaderHelper.php new file mode 100644 index 0000000..ef16eb1 --- /dev/null +++ b/lib/helper/SortHeaderHelper.php @@ -0,0 +1,21 @@ + diff --git a/lib/model/Address.php b/lib/model/Address.php new file mode 100644 index 0000000..b6b9cf8 --- /dev/null +++ b/lib/model/Address.php @@ -0,0 +1,124 @@ +splitEmail($this->getAlias()); + if(is_array($alias)) + { + if($alias[0]!=$v) + { + parent::setAlias($v."@".$alias[1]); + } + } + + return parent::setLocalpart($v); + } + + public function setDomainId($v) + { + // sync alias + $alias = $this->splitEmail($this->getAlias()); + if(is_array($alias)) + { + $domain = DomainPeer::retrieveByPk($v); + if($domain) + { + if($alias[(count($alias)>1?1:0)] != $domain) + { + parent::setAlias((count($alias)>1?$alias[0]:"")."@".$domain->getName()); + } + } + } + + return parent::setDomainId($v); + } + + public function setAlias($v) + { + $alias = $this->splitEmail($v); + + // sync localpart + parent::setLocalpart($alias[0]); + + // sync domain_id + $c = new Criteria(); + $c->add(DomainPeer::NAME, $alias[1]); + $domain = DomainPeer::doSelectOne($c); + + if($domain) + parent::setDomainId($domain->getId()); + else + parent::setDomainId(null); + + return parent::setAlias($v); + } + + public function setDestination($dest) + { + // make sure we are a comma seperated string + $destarray = self::getDestinationAsArray($dest); + + // if a mailbox is set, make sure it is first in the list + if($this->getSaveInMailbox()) + { + $mailbox = $this->getMailbox(); + if($mailbox) + { + if(array_search($mailbox->getName(), $destarray) == false) + { + $destarray = array_merge(array($this->getMailbox()->getName()), $destarray); + } + } + + } + + parent::setDestination(implode(",", $destarray)); + } + + public function getDestination($delimiter = '\n') + { + // if a mailbox is set, strip it out of the list + $destarray = self::getDestinationAsArray(parent::getDestination()); + $destarray2 = array(); + if($this->getSaveInMailbox()) + { + foreach($destarray as $dest) + { + if($dest != $this->getMailbox()->getName()) + $destarray2[] = $dest; + } + } + else $destarray2 = $destarray; + return implode("\n", $destarray2); + } + + public static function getDestinationAsArray($d) + { + return preg_split("/[\s\n,;]+/", $d, -1, PREG_SPLIT_NO_EMPTY); + } + + public function isCatchAll() + { + return ($this->getLocalpart()==""); + } + + public function __toString() + { + return $this->getAlias(); + } +} diff --git a/lib/model/AddressPeer.php b/lib/model/AddressPeer.php new file mode 100644 index 0000000..62ba476 --- /dev/null +++ b/lib/model/AddressPeer.php @@ -0,0 +1,30 @@ +setMaxMailboxCount(sfConfig::get('app_domain_max_mailbox_count')); + $this->setQuota(sfConfig::get('app_domain_quota')); + $this->setDefaultMailboxQuota(sfConfig::get('app_domain_default_mailbox_quota')); + } + + public function getMailboxCount() + { + return $this->countMailboxs(); + } + + public function getUsedQuota() + { + $used = 0; + + $c = new Criteria(); + $c->add(MailboxPeer::DOMAIN_ID, $this->getId()); + $c->addSelectColumn('SUM('.MailboxPeer::MAX_QUOTA.')'); + $rs = MailboxPeer::doSelectRS($c); + if($rs->next()) + return $rs->getInt(1); + + /* + foreach($this->getMailboxs() as $mbox) + { + $used += $mbox->getQuota(); + } + */ + return $used; + } + + public function __toString() + { + return $this->getName(); + } +} diff --git a/lib/model/DomainPeer.php b/lib/model/DomainPeer.php new file mode 100644 index 0000000..f52c6ca --- /dev/null +++ b/lib/model/DomainPeer.php @@ -0,0 +1,37 @@ +add(self::NAME, $name); + return self::doSelect($c); + } +} diff --git a/lib/model/DomainPermission.php b/lib/model/DomainPermission.php new file mode 100644 index 0000000..3a4c40b --- /dev/null +++ b/lib/model/DomainPermission.php @@ -0,0 +1,12 @@ +getUser()->hasCredential("superadmin")) + return; + + // set domain permissions + $criteria->addJoin(DomainPermissionPeer::DOMAIN_ID, $domain_id); + $criteria->add(DomainPermissionPeer::USER_ID, sfContext::getInstance()->getUser()->getId()); + } +} diff --git a/lib/model/LogEntry.php b/lib/model/LogEntry.php new file mode 100644 index 0000000..5b7fbb5 --- /dev/null +++ b/lib/model/LogEntry.php @@ -0,0 +1,38 @@ +getPriority()) + { + case 0: return "Debug"; + case 1: return "Info"; + case 2: return "Notice"; + case 3: return "Warning"; + case 4: return "Error"; + case 5: return "Critical"; + case 6: return "Alert"; + case 7: return "Emergency"; + default: + return "Unknown"; + } + } +} diff --git a/lib/model/LogEntryPeer.php b/lib/model/LogEntryPeer.php new file mode 100644 index 0000000..53501da --- /dev/null +++ b/lib/model/LogEntryPeer.php @@ -0,0 +1,23 @@ +setMessage($message); + $e->setPriority($priority); + $e->setHost(gethostbyaddr($_SERVER["REMOTE_ADDR"])); + $user = sfContext::getInstance()->getUser(); + if($user) + $e->setUserId($user->getId()); + $e->save(); + } +} diff --git a/lib/model/Mailbox.php b/lib/model/Mailbox.php new file mode 100644 index 0000000..c29e1db --- /dev/null +++ b/lib/model/Mailbox.php @@ -0,0 +1,187 @@ +setMaxQuota(sfConfig::get('app_domain_default_mailbox_quota')); + $this->setMaxAddressCount(sfConfig::get('app_mailbox_max_address_count')); + } + + public function getImapName() + { + return "user.".$this->getName(); + } + + public function getExistsOnImapServer() + { + $this->requireIMAPAdminConnection(); + $exists = $this->imap->getlist($this->getImapName(), '%'); + if(is_array($exists) && (count($exists)!=0)) + { + return true; + } + return false; + } + + protected function requireIMAPAdminConnection() + { + if(!$this->imap) + $this->imap = IMAPManager::getAdminConnection(); + } + + protected $quota = null; + protected function updateIMAPQuota() + { + $this->requireIMAPAdminConnection(); + $quota = $this->imap->getquota("user.".$this->getName()); + if($quota) + $this->quota = $quota; + } + + public function getQuota() + { + if($this->quota == null) + $this->updateIMAPQuota(); + + return $this->quota; + } + + public function save($con = null) + { + // create or update resources on IMAP server + if($this->isNew()) + { + $this->requireIMAPAdminConnection(); + + // mailbox + $this->imap->create($this->getImapName()); + + // acl + $this->imap->setacl($this->getImapName(), IMAPManager::getAdminUsername(), $this->imap->getAvailableACL()); + + // quota + $this->imap->setquota($this->getImapName(), $this->getMaxQuota()); + + // default folders + + } + else // update + { + // mailbox name changed? + if($this->isColumnModified(MailboxPeer::NAME)) + { + $this->requireIMAPAdminConnection(); + + $oldmailbox = MailboxPeer::retrieveByPk($this->getId()); + if($oldmailbox->getName() != $this->getName()) + { + // requires "allowusermoves: 1" in /etc/imapd.conf + // mailbox + $this->imap->rename($oldmailbox->getImapName(), $this->getImapName()); + } + } + + // quota changed? + if($this->isColumnModified(MailboxPeer::MAX_QUOTA)) + { + $this->requireIMAPAdminConnection(); + + $this->imap->setquota($this->getImapName(), $this->getMaxQuota()); + } + } + + return parent::save($con); + } + + public function delete($con = null) + { + // remove resources on IMAP server + if(!$this->isNew()) + { + $this->requireIMAPAdminConnection(); + + // grant all rights to admin to be able to delete mailbox + $this->imap->setacl($this->getImapName(), IMAPManager::getAdminUsername(), $this->imap->getAvailableACL()); + + // mailbox + $this->imap->delete($this->getImapName()); + } + + return parent::delete($con); + } + + // TODO: extract password logic into own library + public function isPasswordEqual($password) + { + // check crypt type + $server_settings = sfConfig::get('app_server_default'); + $crypt_type = $server_settings['pam']['crypt']; + + switch($crypt_type) + { + case 0: // plain + return ($password == $this->getPassword()); + case 1: // crypt + return (crypt($password, substr($this->getPassword(), 0, 2)) == $this->getPassword()); + case 2: // md5 + return (md5($password) == $this->getPassword()); + case 3: // sha1 + return (sha1($password) == $this->getPassword()); + break; + } + + return false; + } + + public function setPassword($password) + { + if($password=='') + return false; + // check crypt type + $server_settings = sfConfig::get('app_server_default'); + $crypt_type = $server_settings['pam']['crypt']; + + switch($crypt_type) + { + case 0: // plain + break; + case 1: // crypt + $password = crypt($password, substr($password, 0, 8)); + break; + case 2: // md5 + $password = md5($password); + break; + case 3: // sha1 + $password = sha1($password); + break; + } + + return parent::setPassword($password); + } + + public function setNewPassword($password) + { + return $this->setPassword($password); + } + + public function getAddressCount() + { + return $this->countAddresss(); + } + + public function __toString() + { + return $this->getName(); + } +} diff --git a/lib/model/MailboxPeer.php b/lib/model/MailboxPeer.php new file mode 100644 index 0000000..46170c3 --- /dev/null +++ b/lib/model/MailboxPeer.php @@ -0,0 +1,30 @@ +getName(); + } +} diff --git a/lib/model/RolePeer.php b/lib/model/RolePeer.php new file mode 100644 index 0000000..db848d5 --- /dev/null +++ b/lib/model/RolePeer.php @@ -0,0 +1,12 @@ +getNickname().$this->getFirstName()); + $this->setSalt($salt); + $this->setSha1Password(sha1($salt.$password)); + } + + public function setPassword2($password) + { + if($password!='') + $this->setPassword($password); + } + + public function getFullName() + { + return $this->getFirstName()." ".$this->getLastName(); + } + + public function __toString() + { + return $this->getNickname(); + } +} diff --git a/lib/model/UserPeer.php b/lib/model/UserPeer.php new file mode 100644 index 0000000..72c3ef1 --- /dev/null +++ b/lib/model/UserPeer.php @@ -0,0 +1,12 @@ +dbMap !== null); + } + + + public function getDatabaseMap() + { + return $this->dbMap; + } + + + public function doBuild() + { + $this->dbMap = Propel::getDatabaseMap('propel'); + + $tMap = $this->dbMap->addTable('address'); + $tMap->setPhpName('Address'); + + $tMap->setUseIdGenerator(true); + + $tMap->addPrimaryKey('ID', 'Id', 'int', CreoleTypes::INTEGER, true, null); + + $tMap->addForeignKey('MAILBOX_ID', 'MailboxId', 'int', CreoleTypes::INTEGER, 'mailbox', 'ID', false, null); + + $tMap->addColumn('LOCALPART', 'Localpart', 'string', CreoleTypes::VARCHAR, false, 255); + + $tMap->addForeignKey('DOMAIN_ID', 'DomainId', 'int', CreoleTypes::INTEGER, 'domain', 'ID', false, null); + + $tMap->addColumn('ALIAS', 'Alias', 'string', CreoleTypes::VARCHAR, false, 255); + + $tMap->addColumn('DESTINATION', 'Destination', 'string', CreoleTypes::LONGVARCHAR, false, null); + + $tMap->addColumn('ACTIVE', 'Active', 'boolean', CreoleTypes::BOOLEAN, false, null); + + $tMap->addColumn('SAVE_IN_MAILBOX', 'SaveInMailbox', 'boolean', CreoleTypes::BOOLEAN, false, null); + + } +} \ No newline at end of file diff --git a/lib/model/map/DomainMapBuilder.php b/lib/model/map/DomainMapBuilder.php new file mode 100644 index 0000000..36e0d83 --- /dev/null +++ b/lib/model/map/DomainMapBuilder.php @@ -0,0 +1,50 @@ +dbMap !== null); + } + + + public function getDatabaseMap() + { + return $this->dbMap; + } + + + public function doBuild() + { + $this->dbMap = Propel::getDatabaseMap('propel'); + + $tMap = $this->dbMap->addTable('domain'); + $tMap->setPhpName('Domain'); + + $tMap->setUseIdGenerator(true); + + $tMap->addPrimaryKey('ID', 'Id', 'int', CreoleTypes::INTEGER, true, null); + + $tMap->addColumn('NAME', 'Name', 'string', CreoleTypes::VARCHAR, false, 255); + + $tMap->addForeignKey('CREATOR_ID', 'CreatorId', 'int', CreoleTypes::INTEGER, 'user', 'ID', false, null); + + $tMap->addColumn('MAILBOX_PREFIX', 'MailboxPrefix', 'string', CreoleTypes::VARCHAR, false, 255); + + $tMap->addColumn('MAX_MAILBOX_COUNT', 'MaxMailboxCount', 'int', CreoleTypes::INTEGER, false, null); + + $tMap->addColumn('QUOTA', 'Quota', 'int', CreoleTypes::INTEGER, false, null); + + $tMap->addColumn('DEFAULT_MAILBOX_QUOTA', 'DefaultMailboxQuota', 'int', CreoleTypes::INTEGER, false, null); + + } +} \ No newline at end of file diff --git a/lib/model/map/DomainPermissionMapBuilder.php b/lib/model/map/DomainPermissionMapBuilder.php new file mode 100644 index 0000000..380be1c --- /dev/null +++ b/lib/model/map/DomainPermissionMapBuilder.php @@ -0,0 +1,42 @@ +dbMap !== null); + } + + + public function getDatabaseMap() + { + return $this->dbMap; + } + + + public function doBuild() + { + $this->dbMap = Propel::getDatabaseMap('propel'); + + $tMap = $this->dbMap->addTable('domain_permission'); + $tMap->setPhpName('DomainPermission'); + + $tMap->setUseIdGenerator(true); + + $tMap->addForeignKey('USER_ID', 'UserId', 'int', CreoleTypes::INTEGER, 'user', 'ID', false, null); + + $tMap->addForeignKey('DOMAIN_ID', 'DomainId', 'int', CreoleTypes::INTEGER, 'domain', 'ID', false, null); + + $tMap->addPrimaryKey('ID', 'Id', 'int', CreoleTypes::INTEGER, true, null); + + } +} \ No newline at end of file diff --git a/lib/model/map/LogEntryMapBuilder.php b/lib/model/map/LogEntryMapBuilder.php new file mode 100644 index 0000000..737ea21 --- /dev/null +++ b/lib/model/map/LogEntryMapBuilder.php @@ -0,0 +1,48 @@ +dbMap !== null); + } + + + public function getDatabaseMap() + { + return $this->dbMap; + } + + + public function doBuild() + { + $this->dbMap = Propel::getDatabaseMap('propel'); + + $tMap = $this->dbMap->addTable('log'); + $tMap->setPhpName('LogEntry'); + + $tMap->setUseIdGenerator(true); + + $tMap->addPrimaryKey('ID', 'Id', 'int', CreoleTypes::INTEGER, true, null); + + $tMap->addForeignKey('USER_ID', 'UserId', 'int', CreoleTypes::INTEGER, 'user', 'ID', false, null); + + $tMap->addColumn('CREATED_AT', 'CreatedAt', 'int', CreoleTypes::TIMESTAMP, false, null); + + $tMap->addColumn('MESSAGE', 'Message', 'string', CreoleTypes::LONGVARCHAR, false, null); + + $tMap->addColumn('HOST', 'Host', 'string', CreoleTypes::VARCHAR, false, 255); + + $tMap->addColumn('PRIORITY', 'Priority', 'int', CreoleTypes::INTEGER, false, null); + + } +} \ No newline at end of file diff --git a/lib/model/map/MailboxMapBuilder.php b/lib/model/map/MailboxMapBuilder.php new file mode 100644 index 0000000..54bbe40 --- /dev/null +++ b/lib/model/map/MailboxMapBuilder.php @@ -0,0 +1,52 @@ +dbMap !== null); + } + + + public function getDatabaseMap() + { + return $this->dbMap; + } + + + public function doBuild() + { + $this->dbMap = Propel::getDatabaseMap('propel'); + + $tMap = $this->dbMap->addTable('mailbox'); + $tMap->setPhpName('Mailbox'); + + $tMap->setUseIdGenerator(true); + + $tMap->addPrimaryKey('ID', 'Id', 'int', CreoleTypes::INTEGER, true, null); + + $tMap->addForeignKey('DOMAIN_ID', 'DomainId', 'int', CreoleTypes::INTEGER, 'domain', 'ID', false, null); + + $tMap->addColumn('NAME', 'Name', 'string', CreoleTypes::VARCHAR, false, 30); + + $tMap->addColumn('PASSWORD', 'Password', 'string', CreoleTypes::VARCHAR, false, 40); + + $tMap->addColumn('MAX_QUOTA', 'MaxQuota', 'int', CreoleTypes::INTEGER, false, null); + + $tMap->addColumn('MAX_ADDRESS_COUNT', 'MaxAddressCount', 'int', CreoleTypes::INTEGER, false, null); + + $tMap->addColumn('LAST_LOGIN', 'LastLogin', 'int', CreoleTypes::TIMESTAMP, false, null); + + $tMap->addColumn('ACTIVE', 'Active', 'boolean', CreoleTypes::BOOLEAN, false, null); + + } +} \ No newline at end of file diff --git a/lib/model/map/RoleMapBuilder.php b/lib/model/map/RoleMapBuilder.php new file mode 100644 index 0000000..44aeb93 --- /dev/null +++ b/lib/model/map/RoleMapBuilder.php @@ -0,0 +1,42 @@ +dbMap !== null); + } + + + public function getDatabaseMap() + { + return $this->dbMap; + } + + + public function doBuild() + { + $this->dbMap = Propel::getDatabaseMap('propel'); + + $tMap = $this->dbMap->addTable('role'); + $tMap->setPhpName('Role'); + + $tMap->setUseIdGenerator(true); + + $tMap->addPrimaryKey('ID', 'Id', 'int', CreoleTypes::INTEGER, true, null); + + $tMap->addColumn('NAME', 'Name', 'string', CreoleTypes::VARCHAR, false, 255); + + $tMap->addColumn('CREDENTIALS', 'Credentials', 'string', CreoleTypes::VARCHAR, false, 255); + + } +} \ No newline at end of file diff --git a/lib/model/map/UserMapBuilder.php b/lib/model/map/UserMapBuilder.php new file mode 100644 index 0000000..3ee3252 --- /dev/null +++ b/lib/model/map/UserMapBuilder.php @@ -0,0 +1,58 @@ +dbMap !== null); + } + + + public function getDatabaseMap() + { + return $this->dbMap; + } + + + public function doBuild() + { + $this->dbMap = Propel::getDatabaseMap('propel'); + + $tMap = $this->dbMap->addTable('user'); + $tMap->setPhpName('User'); + + $tMap->setUseIdGenerator(true); + + $tMap->addPrimaryKey('ID', 'Id', 'int', CreoleTypes::INTEGER, true, null); + + $tMap->addForeignKey('PARENT_USER_ID', 'ParentUserId', 'int', CreoleTypes::INTEGER, 'user', 'ID', false, null); + + $tMap->addColumn('NICKNAME', 'Nickname', 'string', CreoleTypes::VARCHAR, false, 50); + + $tMap->addColumn('FIRST_NAME', 'FirstName', 'string', CreoleTypes::VARCHAR, false, 100); + + $tMap->addColumn('LAST_NAME', 'LastName', 'string', CreoleTypes::VARCHAR, false, 100); + + $tMap->addColumn('EMAIL', 'Email', 'string', CreoleTypes::VARCHAR, false, 255); + + $tMap->addColumn('SHA1_PASSWORD', 'Sha1Password', 'string', CreoleTypes::VARCHAR, false, 40); + + $tMap->addColumn('SALT', 'Salt', 'string', CreoleTypes::VARCHAR, false, 32); + + $tMap->addForeignKey('ROLE_ID', 'RoleId', 'int', CreoleTypes::INTEGER, 'role', 'ID', false, null); + + $tMap->addColumn('LAST_LOGIN', 'LastLogin', 'int', CreoleTypes::TIMESTAMP, false, null); + + $tMap->addColumn('CREATED_AT', 'CreatedAt', 'int', CreoleTypes::TIMESTAMP, false, null); + + } +} \ No newline at end of file diff --git a/lib/model/om/BaseAddress.php b/lib/model/om/BaseAddress.php new file mode 100644 index 0000000..8e9c258 --- /dev/null +++ b/lib/model/om/BaseAddress.php @@ -0,0 +1,643 @@ +id; + } + + + public function getMailboxId() + { + + return $this->mailbox_id; + } + + + public function getLocalpart() + { + + return $this->localpart; + } + + + public function getDomainId() + { + + return $this->domain_id; + } + + + public function getAlias() + { + + return $this->alias; + } + + + public function getDestination() + { + + return $this->destination; + } + + + public function getActive() + { + + return $this->active; + } + + + public function getSaveInMailbox() + { + + return $this->save_in_mailbox; + } + + + public function setId($v) + { + + if ($v !== null && !is_int($v) && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = AddressPeer::ID; + } + + } + + public function setMailboxId($v) + { + + if ($v !== null && !is_int($v) && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->mailbox_id !== $v) { + $this->mailbox_id = $v; + $this->modifiedColumns[] = AddressPeer::MAILBOX_ID; + } + + if ($this->aMailbox !== null && $this->aMailbox->getId() !== $v) { + $this->aMailbox = null; + } + + } + + public function setLocalpart($v) + { + + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->localpart !== $v) { + $this->localpart = $v; + $this->modifiedColumns[] = AddressPeer::LOCALPART; + } + + } + + public function setDomainId($v) + { + + if ($v !== null && !is_int($v) && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->domain_id !== $v) { + $this->domain_id = $v; + $this->modifiedColumns[] = AddressPeer::DOMAIN_ID; + } + + if ($this->aDomain !== null && $this->aDomain->getId() !== $v) { + $this->aDomain = null; + } + + } + + public function setAlias($v) + { + + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->alias !== $v) { + $this->alias = $v; + $this->modifiedColumns[] = AddressPeer::ALIAS; + } + + } + + public function setDestination($v) + { + + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->destination !== $v) { + $this->destination = $v; + $this->modifiedColumns[] = AddressPeer::DESTINATION; + } + + } + + public function setActive($v) + { + + if ($this->active !== $v || $v === true) { + $this->active = $v; + $this->modifiedColumns[] = AddressPeer::ACTIVE; + } + + } + + public function setSaveInMailbox($v) + { + + if ($this->save_in_mailbox !== $v || $v === true) { + $this->save_in_mailbox = $v; + $this->modifiedColumns[] = AddressPeer::SAVE_IN_MAILBOX; + } + + } + + public function hydrate(ResultSet $rs, $startcol = 1) + { + try { + + $this->id = $rs->getInt($startcol + 0); + + $this->mailbox_id = $rs->getInt($startcol + 1); + + $this->localpart = $rs->getString($startcol + 2); + + $this->domain_id = $rs->getInt($startcol + 3); + + $this->alias = $rs->getString($startcol + 4); + + $this->destination = $rs->getString($startcol + 5); + + $this->active = $rs->getBoolean($startcol + 6); + + $this->save_in_mailbox = $rs->getBoolean($startcol + 7); + + $this->resetModified(); + + $this->setNew(false); + + return $startcol + 8; + } catch (Exception $e) { + throw new PropelException("Error populating Address object", $e); + } + } + + + public function delete($con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getConnection(AddressPeer::DATABASE_NAME); + } + + try { + $con->begin(); + AddressPeer::doDelete($this, $con); + $this->setDeleted(true); + $con->commit(); + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + + public function save($con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getConnection(AddressPeer::DATABASE_NAME); + } + + try { + $con->begin(); + $affectedRows = $this->doSave($con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + + protected function doSave($con) + { + $affectedRows = 0; if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + + + if ($this->aMailbox !== null) { + if ($this->aMailbox->isModified()) { + $affectedRows += $this->aMailbox->save($con); + } + $this->setMailbox($this->aMailbox); + } + + if ($this->aDomain !== null) { + if ($this->aDomain->isModified()) { + $affectedRows += $this->aDomain->save($con); + } + $this->setDomain($this->aDomain); + } + + + if ($this->isModified()) { + if ($this->isNew()) { + $pk = AddressPeer::doInsert($this, $con); + $affectedRows += 1; + $this->setId($pk); + $this->setNew(false); + } else { + $affectedRows += AddressPeer::doUpdate($this, $con); + } + $this->resetModified(); } + + $this->alreadyInSave = false; + } + return $affectedRows; + } + + protected $validationFailures = array(); + + + public function getValidationFailures() + { + return $this->validationFailures; + } + + + public function validate($columns = null) + { + $res = $this->doValidate($columns); + if ($res === true) { + $this->validationFailures = array(); + return true; + } else { + $this->validationFailures = $res; + return false; + } + } + + + protected function doValidate($columns = null) + { + if (!$this->alreadyInValidation) { + $this->alreadyInValidation = true; + $retval = null; + + $failureMap = array(); + + + + if ($this->aMailbox !== null) { + if (!$this->aMailbox->validate($columns)) { + $failureMap = array_merge($failureMap, $this->aMailbox->getValidationFailures()); + } + } + + if ($this->aDomain !== null) { + if (!$this->aDomain->validate($columns)) { + $failureMap = array_merge($failureMap, $this->aDomain->getValidationFailures()); + } + } + + + if (($retval = AddressPeer::doValidate($this, $columns)) !== true) { + $failureMap = array_merge($failureMap, $retval); + } + + + + $this->alreadyInValidation = false; + } + + return (!empty($failureMap) ? $failureMap : true); + } + + + public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + { + $pos = AddressPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + return $this->getByPosition($pos); + } + + + public function getByPosition($pos) + { + switch($pos) { + case 0: + return $this->getId(); + break; + case 1: + return $this->getMailboxId(); + break; + case 2: + return $this->getLocalpart(); + break; + case 3: + return $this->getDomainId(); + break; + case 4: + return $this->getAlias(); + break; + case 5: + return $this->getDestination(); + break; + case 6: + return $this->getActive(); + break; + case 7: + return $this->getSaveInMailbox(); + break; + default: + return null; + break; + } } + + + public function toArray($keyType = BasePeer::TYPE_PHPNAME) + { + $keys = AddressPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getMailboxId(), + $keys[2] => $this->getLocalpart(), + $keys[3] => $this->getDomainId(), + $keys[4] => $this->getAlias(), + $keys[5] => $this->getDestination(), + $keys[6] => $this->getActive(), + $keys[7] => $this->getSaveInMailbox(), + ); + return $result; + } + + + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $pos = AddressPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + return $this->setByPosition($pos, $value); + } + + + public function setByPosition($pos, $value) + { + switch($pos) { + case 0: + $this->setId($value); + break; + case 1: + $this->setMailboxId($value); + break; + case 2: + $this->setLocalpart($value); + break; + case 3: + $this->setDomainId($value); + break; + case 4: + $this->setAlias($value); + break; + case 5: + $this->setDestination($value); + break; + case 6: + $this->setActive($value); + break; + case 7: + $this->setSaveInMailbox($value); + break; + } } + + + public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) + { + $keys = AddressPeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setMailboxId($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setLocalpart($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setDomainId($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setAlias($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setDestination($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setActive($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setSaveInMailbox($arr[$keys[7]]); + } + + + public function buildCriteria() + { + $criteria = new Criteria(AddressPeer::DATABASE_NAME); + + if ($this->isColumnModified(AddressPeer::ID)) $criteria->add(AddressPeer::ID, $this->id); + if ($this->isColumnModified(AddressPeer::MAILBOX_ID)) $criteria->add(AddressPeer::MAILBOX_ID, $this->mailbox_id); + if ($this->isColumnModified(AddressPeer::LOCALPART)) $criteria->add(AddressPeer::LOCALPART, $this->localpart); + if ($this->isColumnModified(AddressPeer::DOMAIN_ID)) $criteria->add(AddressPeer::DOMAIN_ID, $this->domain_id); + if ($this->isColumnModified(AddressPeer::ALIAS)) $criteria->add(AddressPeer::ALIAS, $this->alias); + if ($this->isColumnModified(AddressPeer::DESTINATION)) $criteria->add(AddressPeer::DESTINATION, $this->destination); + if ($this->isColumnModified(AddressPeer::ACTIVE)) $criteria->add(AddressPeer::ACTIVE, $this->active); + if ($this->isColumnModified(AddressPeer::SAVE_IN_MAILBOX)) $criteria->add(AddressPeer::SAVE_IN_MAILBOX, $this->save_in_mailbox); + + return $criteria; + } + + + public function buildPkeyCriteria() + { + $criteria = new Criteria(AddressPeer::DATABASE_NAME); + + $criteria->add(AddressPeer::ID, $this->id); + + return $criteria; + } + + + public function getPrimaryKey() + { + return $this->getId(); + } + + + public function setPrimaryKey($key) + { + $this->setId($key); + } + + + public function copyInto($copyObj, $deepCopy = false) + { + + $copyObj->setMailboxId($this->mailbox_id); + + $copyObj->setLocalpart($this->localpart); + + $copyObj->setDomainId($this->domain_id); + + $copyObj->setAlias($this->alias); + + $copyObj->setDestination($this->destination); + + $copyObj->setActive($this->active); + + $copyObj->setSaveInMailbox($this->save_in_mailbox); + + + $copyObj->setNew(true); + + $copyObj->setId(NULL); + } + + + public function copy($deepCopy = false) + { + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + return $copyObj; + } + + + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new AddressPeer(); + } + return self::$peer; + } + + + public function setMailbox($v) + { + + + if ($v === null) { + $this->setMailboxId(NULL); + } else { + $this->setMailboxId($v->getId()); + } + + + $this->aMailbox = $v; + } + + + + public function getMailbox($con = null) + { + include_once 'lib/model/om/BaseMailboxPeer.php'; + + if ($this->aMailbox === null && ($this->mailbox_id !== null)) { + + $this->aMailbox = MailboxPeer::retrieveByPK($this->mailbox_id, $con); + + + } + return $this->aMailbox; + } + + + public function setDomain($v) + { + + + if ($v === null) { + $this->setDomainId(NULL); + } else { + $this->setDomainId($v->getId()); + } + + + $this->aDomain = $v; + } + + + + public function getDomain($con = null) + { + include_once 'lib/model/om/BaseDomainPeer.php'; + + if ($this->aDomain === null && ($this->domain_id !== null)) { + + $this->aDomain = DomainPeer::retrieveByPK($this->domain_id, $con); + + + } + return $this->aDomain; + } + +} \ No newline at end of file diff --git a/lib/model/om/BaseAddressPeer.php b/lib/model/om/BaseAddressPeer.php new file mode 100644 index 0000000..acc23cb --- /dev/null +++ b/lib/model/om/BaseAddressPeer.php @@ -0,0 +1,834 @@ + array ('Id', 'MailboxId', 'Localpart', 'DomainId', 'Alias', 'Destination', 'Active', 'SaveInMailbox', ), + BasePeer::TYPE_COLNAME => array (AddressPeer::ID, AddressPeer::MAILBOX_ID, AddressPeer::LOCALPART, AddressPeer::DOMAIN_ID, AddressPeer::ALIAS, AddressPeer::DESTINATION, AddressPeer::ACTIVE, AddressPeer::SAVE_IN_MAILBOX, ), + BasePeer::TYPE_FIELDNAME => array ('id', 'mailbox_id', 'localpart', 'domain_id', 'alias', 'destination', 'active', 'save_in_mailbox', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, ) + ); + + + private static $fieldKeys = array ( + BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'MailboxId' => 1, 'Localpart' => 2, 'DomainId' => 3, 'Alias' => 4, 'Destination' => 5, 'Active' => 6, 'SaveInMailbox' => 7, ), + BasePeer::TYPE_COLNAME => array (AddressPeer::ID => 0, AddressPeer::MAILBOX_ID => 1, AddressPeer::LOCALPART => 2, AddressPeer::DOMAIN_ID => 3, AddressPeer::ALIAS => 4, AddressPeer::DESTINATION => 5, AddressPeer::ACTIVE => 6, AddressPeer::SAVE_IN_MAILBOX => 7, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'mailbox_id' => 1, 'localpart' => 2, 'domain_id' => 3, 'alias' => 4, 'destination' => 5, 'active' => 6, 'save_in_mailbox' => 7, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, ) + ); + + + public static function getMapBuilder() + { + include_once 'lib/model/map/AddressMapBuilder.php'; + return BasePeer::getMapBuilder('lib.model.map.AddressMapBuilder'); + } + + public static function getPhpNameMap() + { + if (self::$phpNameMap === null) { + $map = AddressPeer::getTableMap(); + $columns = $map->getColumns(); + $nameMap = array(); + foreach ($columns as $column) { + $nameMap[$column->getPhpName()] = $column->getColumnName(); + } + self::$phpNameMap = $nameMap; + } + return self::$phpNameMap; + } + + static public function translateFieldName($name, $fromType, $toType) + { + $toNames = self::getFieldNames($toType); + $key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null; + if ($key === null) { + throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true)); + } + return $toNames[$key]; + } + + + + static public function getFieldNames($type = BasePeer::TYPE_PHPNAME) + { + if (!array_key_exists($type, self::$fieldNames)) { + throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.'); + } + return self::$fieldNames[$type]; + } + + + public static function alias($alias, $column) + { + return str_replace(AddressPeer::TABLE_NAME.'.', $alias.'.', $column); + } + + + public static function addSelectColumns(Criteria $criteria) + { + + $criteria->addSelectColumn(AddressPeer::ID); + + $criteria->addSelectColumn(AddressPeer::MAILBOX_ID); + + $criteria->addSelectColumn(AddressPeer::LOCALPART); + + $criteria->addSelectColumn(AddressPeer::DOMAIN_ID); + + $criteria->addSelectColumn(AddressPeer::ALIAS); + + $criteria->addSelectColumn(AddressPeer::DESTINATION); + + $criteria->addSelectColumn(AddressPeer::ACTIVE); + + $criteria->addSelectColumn(AddressPeer::SAVE_IN_MAILBOX); + + } + + const COUNT = 'COUNT(address.ID)'; + const COUNT_DISTINCT = 'COUNT(DISTINCT address.ID)'; + + + public static function doCount(Criteria $criteria, $distinct = false, $con = null) + { + $criteria = clone $criteria; + + $criteria->clearSelectColumns()->clearOrderByColumns(); + if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->addSelectColumn(AddressPeer::COUNT_DISTINCT); + } else { + $criteria->addSelectColumn(AddressPeer::COUNT); + } + + foreach($criteria->getGroupByColumns() as $column) + { + $criteria->addSelectColumn($column); + } + + $rs = AddressPeer::doSelectRS($criteria, $con); + if ($rs->next()) { + return $rs->getInt(1); + } else { + return 0; + } + } + + public static function doSelectOne(Criteria $criteria, $con = null) + { + $critcopy = clone $criteria; + $critcopy->setLimit(1); + $objects = AddressPeer::doSelect($critcopy, $con); + if ($objects) { + return $objects[0]; + } + return null; + } + + public static function doSelect(Criteria $criteria, $con = null) + { + return AddressPeer::populateObjects(AddressPeer::doSelectRS($criteria, $con)); + } + + public static function doSelectRS(Criteria $criteria, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + if (!$criteria->getSelectColumns()) { + $criteria = clone $criteria; + AddressPeer::addSelectColumns($criteria); + } + + $criteria->setDbName(self::DATABASE_NAME); + + return BasePeer::doSelect($criteria, $con); + } + + public static function populateObjects(ResultSet $rs) + { + $results = array(); + + $cls = AddressPeer::getOMClass(); + $cls = Propel::import($cls); + while($rs->next()) { + + $obj = new $cls(); + $obj->hydrate($rs); + $results[] = $obj; + + } + return $results; + } + + + public static function doCountJoinMailbox(Criteria $criteria, $distinct = false, $con = null) + { + $criteria = clone $criteria; + + $criteria->clearSelectColumns()->clearOrderByColumns(); + if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->addSelectColumn(AddressPeer::COUNT_DISTINCT); + } else { + $criteria->addSelectColumn(AddressPeer::COUNT); + } + + foreach($criteria->getGroupByColumns() as $column) + { + $criteria->addSelectColumn($column); + } + + $criteria->addJoin(AddressPeer::MAILBOX_ID, MailboxPeer::ID); + + $rs = AddressPeer::doSelectRS($criteria, $con); + if ($rs->next()) { + return $rs->getInt(1); + } else { + return 0; + } + } + + + + public static function doCountJoinDomain(Criteria $criteria, $distinct = false, $con = null) + { + $criteria = clone $criteria; + + $criteria->clearSelectColumns()->clearOrderByColumns(); + if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->addSelectColumn(AddressPeer::COUNT_DISTINCT); + } else { + $criteria->addSelectColumn(AddressPeer::COUNT); + } + + foreach($criteria->getGroupByColumns() as $column) + { + $criteria->addSelectColumn($column); + } + + $criteria->addJoin(AddressPeer::DOMAIN_ID, DomainPeer::ID); + + $rs = AddressPeer::doSelectRS($criteria, $con); + if ($rs->next()) { + return $rs->getInt(1); + } else { + return 0; + } + } + + + + public static function doSelectJoinMailbox(Criteria $c, $con = null) + { + $c = clone $c; + + if ($c->getDbName() == Propel::getDefaultDB()) { + $c->setDbName(self::DATABASE_NAME); + } + + AddressPeer::addSelectColumns($c); + $startcol = (AddressPeer::NUM_COLUMNS - AddressPeer::NUM_LAZY_LOAD_COLUMNS) + 1; + MailboxPeer::addSelectColumns($c); + + $c->addJoin(AddressPeer::MAILBOX_ID, MailboxPeer::ID); + $rs = BasePeer::doSelect($c, $con); + $results = array(); + + while($rs->next()) { + + $omClass = AddressPeer::getOMClass(); + + $cls = Propel::import($omClass); + $obj1 = new $cls(); + $obj1->hydrate($rs); + + $omClass = MailboxPeer::getOMClass(); + + $cls = Propel::import($omClass); + $obj2 = new $cls(); + $obj2->hydrate($rs, $startcol); + + $newObject = true; + foreach($results as $temp_obj1) { + $temp_obj2 = $temp_obj1->getMailbox(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { + $newObject = false; + $temp_obj2->addAddress($obj1); break; + } + } + if ($newObject) { + $obj2->initAddresss(); + $obj2->addAddress($obj1); } + $results[] = $obj1; + } + return $results; + } + + + + public static function doSelectJoinDomain(Criteria $c, $con = null) + { + $c = clone $c; + + if ($c->getDbName() == Propel::getDefaultDB()) { + $c->setDbName(self::DATABASE_NAME); + } + + AddressPeer::addSelectColumns($c); + $startcol = (AddressPeer::NUM_COLUMNS - AddressPeer::NUM_LAZY_LOAD_COLUMNS) + 1; + DomainPeer::addSelectColumns($c); + + $c->addJoin(AddressPeer::DOMAIN_ID, DomainPeer::ID); + $rs = BasePeer::doSelect($c, $con); + $results = array(); + + while($rs->next()) { + + $omClass = AddressPeer::getOMClass(); + + $cls = Propel::import($omClass); + $obj1 = new $cls(); + $obj1->hydrate($rs); + + $omClass = DomainPeer::getOMClass(); + + $cls = Propel::import($omClass); + $obj2 = new $cls(); + $obj2->hydrate($rs, $startcol); + + $newObject = true; + foreach($results as $temp_obj1) { + $temp_obj2 = $temp_obj1->getDomain(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { + $newObject = false; + $temp_obj2->addAddress($obj1); break; + } + } + if ($newObject) { + $obj2->initAddresss(); + $obj2->addAddress($obj1); } + $results[] = $obj1; + } + return $results; + } + + + + public static function doCountJoinAll(Criteria $criteria, $distinct = false, $con = null) + { + $criteria = clone $criteria; + + $criteria->clearSelectColumns()->clearOrderByColumns(); + if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->addSelectColumn(AddressPeer::COUNT_DISTINCT); + } else { + $criteria->addSelectColumn(AddressPeer::COUNT); + } + + foreach($criteria->getGroupByColumns() as $column) + { + $criteria->addSelectColumn($column); + } + + $criteria->addJoin(AddressPeer::MAILBOX_ID, MailboxPeer::ID); + + $criteria->addJoin(AddressPeer::DOMAIN_ID, DomainPeer::ID); + + $rs = AddressPeer::doSelectRS($criteria, $con); + if ($rs->next()) { + return $rs->getInt(1); + } else { + return 0; + } + } + + + + public static function doSelectJoinAll(Criteria $c, $con = null) + { + $c = clone $c; + + if ($c->getDbName() == Propel::getDefaultDB()) { + $c->setDbName(self::DATABASE_NAME); + } + + AddressPeer::addSelectColumns($c); + $startcol2 = (AddressPeer::NUM_COLUMNS - AddressPeer::NUM_LAZY_LOAD_COLUMNS) + 1; + + MailboxPeer::addSelectColumns($c); + $startcol3 = $startcol2 + MailboxPeer::NUM_COLUMNS; + + DomainPeer::addSelectColumns($c); + $startcol4 = $startcol3 + DomainPeer::NUM_COLUMNS; + + $c->addJoin(AddressPeer::MAILBOX_ID, MailboxPeer::ID); + + $c->addJoin(AddressPeer::DOMAIN_ID, DomainPeer::ID); + + $rs = BasePeer::doSelect($c, $con); + $results = array(); + + while($rs->next()) { + + $omClass = AddressPeer::getOMClass(); + + + $cls = Propel::import($omClass); + $obj1 = new $cls(); + $obj1->hydrate($rs); + + + + $omClass = MailboxPeer::getOMClass(); + + + $cls = Propel::import($omClass); + $obj2 = new $cls(); + $obj2->hydrate($rs, $startcol2); + + $newObject = true; + for ($j=0, $resCount=count($results); $j < $resCount; $j++) { + $temp_obj1 = $results[$j]; + $temp_obj2 = $temp_obj1->getMailbox(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { + $newObject = false; + $temp_obj2->addAddress($obj1); break; + } + } + + if ($newObject) { + $obj2->initAddresss(); + $obj2->addAddress($obj1); + } + + + + $omClass = DomainPeer::getOMClass(); + + + $cls = Propel::import($omClass); + $obj3 = new $cls(); + $obj3->hydrate($rs, $startcol3); + + $newObject = true; + for ($j=0, $resCount=count($results); $j < $resCount; $j++) { + $temp_obj1 = $results[$j]; + $temp_obj3 = $temp_obj1->getDomain(); if ($temp_obj3->getPrimaryKey() === $obj3->getPrimaryKey()) { + $newObject = false; + $temp_obj3->addAddress($obj1); break; + } + } + + if ($newObject) { + $obj3->initAddresss(); + $obj3->addAddress($obj1); + } + + $results[] = $obj1; + } + return $results; + } + + + + public static function doCountJoinAllExceptMailbox(Criteria $criteria, $distinct = false, $con = null) + { + $criteria = clone $criteria; + + $criteria->clearSelectColumns()->clearOrderByColumns(); + if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->addSelectColumn(AddressPeer::COUNT_DISTINCT); + } else { + $criteria->addSelectColumn(AddressPeer::COUNT); + } + + foreach($criteria->getGroupByColumns() as $column) + { + $criteria->addSelectColumn($column); + } + + $criteria->addJoin(AddressPeer::DOMAIN_ID, DomainPeer::ID); + + $rs = AddressPeer::doSelectRS($criteria, $con); + if ($rs->next()) { + return $rs->getInt(1); + } else { + return 0; + } + } + + + + public static function doCountJoinAllExceptDomain(Criteria $criteria, $distinct = false, $con = null) + { + $criteria = clone $criteria; + + $criteria->clearSelectColumns()->clearOrderByColumns(); + if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->addSelectColumn(AddressPeer::COUNT_DISTINCT); + } else { + $criteria->addSelectColumn(AddressPeer::COUNT); + } + + foreach($criteria->getGroupByColumns() as $column) + { + $criteria->addSelectColumn($column); + } + + $criteria->addJoin(AddressPeer::MAILBOX_ID, MailboxPeer::ID); + + $rs = AddressPeer::doSelectRS($criteria, $con); + if ($rs->next()) { + return $rs->getInt(1); + } else { + return 0; + } + } + + + + public static function doSelectJoinAllExceptMailbox(Criteria $c, $con = null) + { + $c = clone $c; + + if ($c->getDbName() == Propel::getDefaultDB()) { + $c->setDbName(self::DATABASE_NAME); + } + + AddressPeer::addSelectColumns($c); + $startcol2 = (AddressPeer::NUM_COLUMNS - AddressPeer::NUM_LAZY_LOAD_COLUMNS) + 1; + + DomainPeer::addSelectColumns($c); + $startcol3 = $startcol2 + DomainPeer::NUM_COLUMNS; + + $c->addJoin(AddressPeer::DOMAIN_ID, DomainPeer::ID); + + + $rs = BasePeer::doSelect($c, $con); + $results = array(); + + while($rs->next()) { + + $omClass = AddressPeer::getOMClass(); + + $cls = Propel::import($omClass); + $obj1 = new $cls(); + $obj1->hydrate($rs); + + $omClass = DomainPeer::getOMClass(); + + + $cls = Propel::import($omClass); + $obj2 = new $cls(); + $obj2->hydrate($rs, $startcol2); + + $newObject = true; + for ($j=0, $resCount=count($results); $j < $resCount; $j++) { + $temp_obj1 = $results[$j]; + $temp_obj2 = $temp_obj1->getDomain(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { + $newObject = false; + $temp_obj2->addAddress($obj1); + break; + } + } + + if ($newObject) { + $obj2->initAddresss(); + $obj2->addAddress($obj1); + } + + $results[] = $obj1; + } + return $results; + } + + + + public static function doSelectJoinAllExceptDomain(Criteria $c, $con = null) + { + $c = clone $c; + + if ($c->getDbName() == Propel::getDefaultDB()) { + $c->setDbName(self::DATABASE_NAME); + } + + AddressPeer::addSelectColumns($c); + $startcol2 = (AddressPeer::NUM_COLUMNS - AddressPeer::NUM_LAZY_LOAD_COLUMNS) + 1; + + MailboxPeer::addSelectColumns($c); + $startcol3 = $startcol2 + MailboxPeer::NUM_COLUMNS; + + $c->addJoin(AddressPeer::MAILBOX_ID, MailboxPeer::ID); + + + $rs = BasePeer::doSelect($c, $con); + $results = array(); + + while($rs->next()) { + + $omClass = AddressPeer::getOMClass(); + + $cls = Propel::import($omClass); + $obj1 = new $cls(); + $obj1->hydrate($rs); + + $omClass = MailboxPeer::getOMClass(); + + + $cls = Propel::import($omClass); + $obj2 = new $cls(); + $obj2->hydrate($rs, $startcol2); + + $newObject = true; + for ($j=0, $resCount=count($results); $j < $resCount; $j++) { + $temp_obj1 = $results[$j]; + $temp_obj2 = $temp_obj1->getMailbox(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { + $newObject = false; + $temp_obj2->addAddress($obj1); + break; + } + } + + if ($newObject) { + $obj2->initAddresss(); + $obj2->addAddress($obj1); + } + + $results[] = $obj1; + } + return $results; + } + + + public static function getTableMap() + { + return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME); + } + + + public static function getOMClass() + { + return AddressPeer::CLASS_DEFAULT; + } + + + public static function doInsert($values, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; } else { + $criteria = $values->buildCriteria(); } + + $criteria->remove(AddressPeer::ID); + + $criteria->setDbName(self::DATABASE_NAME); + + try { + $con->begin(); + $pk = BasePeer::doInsert($criteria, $con); + $con->commit(); + } catch(PropelException $e) { + $con->rollback(); + throw $e; + } + + return $pk; + } + + + public static function doUpdate($values, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + $selectCriteria = new Criteria(self::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; + $comparison = $criteria->getComparison(AddressPeer::ID); + $selectCriteria->add(AddressPeer::ID, $criteria->remove(AddressPeer::ID), $comparison); + + } else { $criteria = $values->buildCriteria(); $selectCriteria = $values->buildPkeyCriteria(); } + + $criteria->setDbName(self::DATABASE_NAME); + + return BasePeer::doUpdate($selectCriteria, $criteria, $con); + } + + + public static function doDeleteAll($con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + $affectedRows = 0; try { + $con->begin(); + $affectedRows += BasePeer::doDeleteAll(AddressPeer::TABLE_NAME, $con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + + public static function doDelete($values, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(AddressPeer::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; } elseif ($values instanceof Address) { + + $criteria = $values->buildPkeyCriteria(); + } else { + $criteria = new Criteria(self::DATABASE_NAME); + $criteria->add(AddressPeer::ID, (array) $values, Criteria::IN); + } + + $criteria->setDbName(self::DATABASE_NAME); + + $affectedRows = 0; + try { + $con->begin(); + + $affectedRows += BasePeer::doDelete($criteria, $con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + + public static function doValidate(Address $obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(AddressPeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(AddressPeer::TABLE_NAME); + + if (! is_array($cols)) { + $cols = array($cols); + } + + foreach($cols as $colName) { + if ($tableMap->containsColumn($colName)) { + $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); + $columns[$colName] = $obj->$get(); + } + } + } else { + + } + + $res = BasePeer::doValidate(AddressPeer::DATABASE_NAME, AddressPeer::TABLE_NAME, $columns); + if ($res !== true) { + $request = sfContext::getInstance()->getRequest(); + foreach ($res as $failed) { + $col = AddressPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME); + $request->setError($col, $failed->getMessage()); + } + } + + return $res; + } + + + public static function retrieveByPK($pk, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + $criteria = new Criteria(AddressPeer::DATABASE_NAME); + + $criteria->add(AddressPeer::ID, $pk); + + + $v = AddressPeer::doSelect($criteria, $con); + + return !empty($v) > 0 ? $v[0] : null; + } + + + public static function retrieveByPKs($pks, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(); + $criteria->add(AddressPeer::ID, $pks, Criteria::IN); + $objs = AddressPeer::doSelect($criteria, $con); + } + return $objs; + } + +} +if (Propel::isInit()) { + try { + BaseAddressPeer::getMapBuilder(); + } catch (Exception $e) { + Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR); + } +} else { + require_once 'lib/model/map/AddressMapBuilder.php'; + Propel::registerMapBuilder('lib.model.map.AddressMapBuilder'); +} diff --git a/lib/model/om/BaseDomain.php b/lib/model/om/BaseDomain.php new file mode 100644 index 0000000..0c8317c --- /dev/null +++ b/lib/model/om/BaseDomain.php @@ -0,0 +1,926 @@ +id; + } + + + public function getName() + { + + return $this->name; + } + + + public function getCreatorId() + { + + return $this->creator_id; + } + + + public function getMailboxPrefix() + { + + return $this->mailbox_prefix; + } + + + public function getMaxMailboxCount() + { + + return $this->max_mailbox_count; + } + + + public function getQuota() + { + + return $this->quota; + } + + + public function getDefaultMailboxQuota() + { + + return $this->default_mailbox_quota; + } + + + public function setId($v) + { + + if ($v !== null && !is_int($v) && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = DomainPeer::ID; + } + + } + + public function setName($v) + { + + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->name !== $v) { + $this->name = $v; + $this->modifiedColumns[] = DomainPeer::NAME; + } + + } + + public function setCreatorId($v) + { + + if ($v !== null && !is_int($v) && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->creator_id !== $v) { + $this->creator_id = $v; + $this->modifiedColumns[] = DomainPeer::CREATOR_ID; + } + + if ($this->aUser !== null && $this->aUser->getId() !== $v) { + $this->aUser = null; + } + + } + + public function setMailboxPrefix($v) + { + + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->mailbox_prefix !== $v) { + $this->mailbox_prefix = $v; + $this->modifiedColumns[] = DomainPeer::MAILBOX_PREFIX; + } + + } + + public function setMaxMailboxCount($v) + { + + if ($v !== null && !is_int($v) && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->max_mailbox_count !== $v) { + $this->max_mailbox_count = $v; + $this->modifiedColumns[] = DomainPeer::MAX_MAILBOX_COUNT; + } + + } + + public function setQuota($v) + { + + if ($v !== null && !is_int($v) && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->quota !== $v) { + $this->quota = $v; + $this->modifiedColumns[] = DomainPeer::QUOTA; + } + + } + + public function setDefaultMailboxQuota($v) + { + + if ($v !== null && !is_int($v) && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->default_mailbox_quota !== $v) { + $this->default_mailbox_quota = $v; + $this->modifiedColumns[] = DomainPeer::DEFAULT_MAILBOX_QUOTA; + } + + } + + public function hydrate(ResultSet $rs, $startcol = 1) + { + try { + + $this->id = $rs->getInt($startcol + 0); + + $this->name = $rs->getString($startcol + 1); + + $this->creator_id = $rs->getInt($startcol + 2); + + $this->mailbox_prefix = $rs->getString($startcol + 3); + + $this->max_mailbox_count = $rs->getInt($startcol + 4); + + $this->quota = $rs->getInt($startcol + 5); + + $this->default_mailbox_quota = $rs->getInt($startcol + 6); + + $this->resetModified(); + + $this->setNew(false); + + return $startcol + 7; + } catch (Exception $e) { + throw new PropelException("Error populating Domain object", $e); + } + } + + + public function delete($con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getConnection(DomainPeer::DATABASE_NAME); + } + + try { + $con->begin(); + DomainPeer::doDelete($this, $con); + $this->setDeleted(true); + $con->commit(); + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + + public function save($con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getConnection(DomainPeer::DATABASE_NAME); + } + + try { + $con->begin(); + $affectedRows = $this->doSave($con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + + protected function doSave($con) + { + $affectedRows = 0; if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + + + if ($this->aUser !== null) { + if ($this->aUser->isModified()) { + $affectedRows += $this->aUser->save($con); + } + $this->setUser($this->aUser); + } + + + if ($this->isModified()) { + if ($this->isNew()) { + $pk = DomainPeer::doInsert($this, $con); + $affectedRows += 1; + $this->setId($pk); + $this->setNew(false); + } else { + $affectedRows += DomainPeer::doUpdate($this, $con); + } + $this->resetModified(); } + + if ($this->collDomainPermissions !== null) { + foreach($this->collDomainPermissions as $referrerFK) { + if (!$referrerFK->isDeleted()) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->collMailboxs !== null) { + foreach($this->collMailboxs as $referrerFK) { + if (!$referrerFK->isDeleted()) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->collAddresss !== null) { + foreach($this->collAddresss as $referrerFK) { + if (!$referrerFK->isDeleted()) { + $affectedRows += $referrerFK->save($con); + } + } + } + + $this->alreadyInSave = false; + } + return $affectedRows; + } + + protected $validationFailures = array(); + + + public function getValidationFailures() + { + return $this->validationFailures; + } + + + public function validate($columns = null) + { + $res = $this->doValidate($columns); + if ($res === true) { + $this->validationFailures = array(); + return true; + } else { + $this->validationFailures = $res; + return false; + } + } + + + protected function doValidate($columns = null) + { + if (!$this->alreadyInValidation) { + $this->alreadyInValidation = true; + $retval = null; + + $failureMap = array(); + + + + if ($this->aUser !== null) { + if (!$this->aUser->validate($columns)) { + $failureMap = array_merge($failureMap, $this->aUser->getValidationFailures()); + } + } + + + if (($retval = DomainPeer::doValidate($this, $columns)) !== true) { + $failureMap = array_merge($failureMap, $retval); + } + + + if ($this->collDomainPermissions !== null) { + foreach($this->collDomainPermissions as $referrerFK) { + if (!$referrerFK->validate($columns)) { + $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); + } + } + } + + if ($this->collMailboxs !== null) { + foreach($this->collMailboxs as $referrerFK) { + if (!$referrerFK->validate($columns)) { + $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); + } + } + } + + if ($this->collAddresss !== null) { + foreach($this->collAddresss as $referrerFK) { + if (!$referrerFK->validate($columns)) { + $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); + } + } + } + + + $this->alreadyInValidation = false; + } + + return (!empty($failureMap) ? $failureMap : true); + } + + + public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + { + $pos = DomainPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + return $this->getByPosition($pos); + } + + + public function getByPosition($pos) + { + switch($pos) { + case 0: + return $this->getId(); + break; + case 1: + return $this->getName(); + break; + case 2: + return $this->getCreatorId(); + break; + case 3: + return $this->getMailboxPrefix(); + break; + case 4: + return $this->getMaxMailboxCount(); + break; + case 5: + return $this->getQuota(); + break; + case 6: + return $this->getDefaultMailboxQuota(); + break; + default: + return null; + break; + } } + + + public function toArray($keyType = BasePeer::TYPE_PHPNAME) + { + $keys = DomainPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getName(), + $keys[2] => $this->getCreatorId(), + $keys[3] => $this->getMailboxPrefix(), + $keys[4] => $this->getMaxMailboxCount(), + $keys[5] => $this->getQuota(), + $keys[6] => $this->getDefaultMailboxQuota(), + ); + return $result; + } + + + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $pos = DomainPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + return $this->setByPosition($pos, $value); + } + + + public function setByPosition($pos, $value) + { + switch($pos) { + case 0: + $this->setId($value); + break; + case 1: + $this->setName($value); + break; + case 2: + $this->setCreatorId($value); + break; + case 3: + $this->setMailboxPrefix($value); + break; + case 4: + $this->setMaxMailboxCount($value); + break; + case 5: + $this->setQuota($value); + break; + case 6: + $this->setDefaultMailboxQuota($value); + break; + } } + + + public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) + { + $keys = DomainPeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setName($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setCreatorId($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setMailboxPrefix($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setMaxMailboxCount($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setQuota($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setDefaultMailboxQuota($arr[$keys[6]]); + } + + + public function buildCriteria() + { + $criteria = new Criteria(DomainPeer::DATABASE_NAME); + + if ($this->isColumnModified(DomainPeer::ID)) $criteria->add(DomainPeer::ID, $this->id); + if ($this->isColumnModified(DomainPeer::NAME)) $criteria->add(DomainPeer::NAME, $this->name); + if ($this->isColumnModified(DomainPeer::CREATOR_ID)) $criteria->add(DomainPeer::CREATOR_ID, $this->creator_id); + if ($this->isColumnModified(DomainPeer::MAILBOX_PREFIX)) $criteria->add(DomainPeer::MAILBOX_PREFIX, $this->mailbox_prefix); + if ($this->isColumnModified(DomainPeer::MAX_MAILBOX_COUNT)) $criteria->add(DomainPeer::MAX_MAILBOX_COUNT, $this->max_mailbox_count); + if ($this->isColumnModified(DomainPeer::QUOTA)) $criteria->add(DomainPeer::QUOTA, $this->quota); + if ($this->isColumnModified(DomainPeer::DEFAULT_MAILBOX_QUOTA)) $criteria->add(DomainPeer::DEFAULT_MAILBOX_QUOTA, $this->default_mailbox_quota); + + return $criteria; + } + + + public function buildPkeyCriteria() + { + $criteria = new Criteria(DomainPeer::DATABASE_NAME); + + $criteria->add(DomainPeer::ID, $this->id); + + return $criteria; + } + + + public function getPrimaryKey() + { + return $this->getId(); + } + + + public function setPrimaryKey($key) + { + $this->setId($key); + } + + + public function copyInto($copyObj, $deepCopy = false) + { + + $copyObj->setName($this->name); + + $copyObj->setCreatorId($this->creator_id); + + $copyObj->setMailboxPrefix($this->mailbox_prefix); + + $copyObj->setMaxMailboxCount($this->max_mailbox_count); + + $copyObj->setQuota($this->quota); + + $copyObj->setDefaultMailboxQuota($this->default_mailbox_quota); + + + if ($deepCopy) { + $copyObj->setNew(false); + + foreach($this->getDomainPermissions() as $relObj) { + $copyObj->addDomainPermission($relObj->copy($deepCopy)); + } + + foreach($this->getMailboxs() as $relObj) { + $copyObj->addMailbox($relObj->copy($deepCopy)); + } + + foreach($this->getAddresss() as $relObj) { + $copyObj->addAddress($relObj->copy($deepCopy)); + } + + } + + $copyObj->setNew(true); + + $copyObj->setId(NULL); + } + + + public function copy($deepCopy = false) + { + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + return $copyObj; + } + + + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new DomainPeer(); + } + return self::$peer; + } + + + public function setUser($v) + { + + + if ($v === null) { + $this->setCreatorId(NULL); + } else { + $this->setCreatorId($v->getId()); + } + + + $this->aUser = $v; + } + + + + public function getUser($con = null) + { + include_once 'lib/model/om/BaseUserPeer.php'; + + if ($this->aUser === null && ($this->creator_id !== null)) { + + $this->aUser = UserPeer::retrieveByPK($this->creator_id, $con); + + + } + return $this->aUser; + } + + + public function initDomainPermissions() + { + if ($this->collDomainPermissions === null) { + $this->collDomainPermissions = array(); + } + } + + + public function getDomainPermissions($criteria = null, $con = null) + { + include_once 'lib/model/om/BaseDomainPermissionPeer.php'; + if ($criteria === null) { + $criteria = new Criteria(); + } + elseif ($criteria instanceof Criteria) + { + $criteria = clone $criteria; + } + + if ($this->collDomainPermissions === null) { + if ($this->isNew()) { + $this->collDomainPermissions = array(); + } else { + + $criteria->add(DomainPermissionPeer::DOMAIN_ID, $this->getId()); + + DomainPermissionPeer::addSelectColumns($criteria); + $this->collDomainPermissions = DomainPermissionPeer::doSelect($criteria, $con); + } + } else { + if (!$this->isNew()) { + + + $criteria->add(DomainPermissionPeer::DOMAIN_ID, $this->getId()); + + DomainPermissionPeer::addSelectColumns($criteria); + if (!isset($this->lastDomainPermissionCriteria) || !$this->lastDomainPermissionCriteria->equals($criteria)) { + $this->collDomainPermissions = DomainPermissionPeer::doSelect($criteria, $con); + } + } + } + $this->lastDomainPermissionCriteria = $criteria; + return $this->collDomainPermissions; + } + + + public function countDomainPermissions($criteria = null, $distinct = false, $con = null) + { + include_once 'lib/model/om/BaseDomainPermissionPeer.php'; + if ($criteria === null) { + $criteria = new Criteria(); + } + elseif ($criteria instanceof Criteria) + { + $criteria = clone $criteria; + } + + $criteria->add(DomainPermissionPeer::DOMAIN_ID, $this->getId()); + + return DomainPermissionPeer::doCount($criteria, $distinct, $con); + } + + + public function addDomainPermission(DomainPermission $l) + { + $this->collDomainPermissions[] = $l; + $l->setDomain($this); + } + + + + public function getDomainPermissionsJoinUser($criteria = null, $con = null) + { + include_once 'lib/model/om/BaseDomainPermissionPeer.php'; + if ($criteria === null) { + $criteria = new Criteria(); + } + elseif ($criteria instanceof Criteria) + { + $criteria = clone $criteria; + } + + if ($this->collDomainPermissions === null) { + if ($this->isNew()) { + $this->collDomainPermissions = array(); + } else { + + $criteria->add(DomainPermissionPeer::DOMAIN_ID, $this->getId()); + + $this->collDomainPermissions = DomainPermissionPeer::doSelectJoinUser($criteria, $con); + } + } else { + + $criteria->add(DomainPermissionPeer::DOMAIN_ID, $this->getId()); + + if (!isset($this->lastDomainPermissionCriteria) || !$this->lastDomainPermissionCriteria->equals($criteria)) { + $this->collDomainPermissions = DomainPermissionPeer::doSelectJoinUser($criteria, $con); + } + } + $this->lastDomainPermissionCriteria = $criteria; + + return $this->collDomainPermissions; + } + + + public function initMailboxs() + { + if ($this->collMailboxs === null) { + $this->collMailboxs = array(); + } + } + + + public function getMailboxs($criteria = null, $con = null) + { + include_once 'lib/model/om/BaseMailboxPeer.php'; + if ($criteria === null) { + $criteria = new Criteria(); + } + elseif ($criteria instanceof Criteria) + { + $criteria = clone $criteria; + } + + if ($this->collMailboxs === null) { + if ($this->isNew()) { + $this->collMailboxs = array(); + } else { + + $criteria->add(MailboxPeer::DOMAIN_ID, $this->getId()); + + MailboxPeer::addSelectColumns($criteria); + $this->collMailboxs = MailboxPeer::doSelect($criteria, $con); + } + } else { + if (!$this->isNew()) { + + + $criteria->add(MailboxPeer::DOMAIN_ID, $this->getId()); + + MailboxPeer::addSelectColumns($criteria); + if (!isset($this->lastMailboxCriteria) || !$this->lastMailboxCriteria->equals($criteria)) { + $this->collMailboxs = MailboxPeer::doSelect($criteria, $con); + } + } + } + $this->lastMailboxCriteria = $criteria; + return $this->collMailboxs; + } + + + public function countMailboxs($criteria = null, $distinct = false, $con = null) + { + include_once 'lib/model/om/BaseMailboxPeer.php'; + if ($criteria === null) { + $criteria = new Criteria(); + } + elseif ($criteria instanceof Criteria) + { + $criteria = clone $criteria; + } + + $criteria->add(MailboxPeer::DOMAIN_ID, $this->getId()); + + return MailboxPeer::doCount($criteria, $distinct, $con); + } + + + public function addMailbox(Mailbox $l) + { + $this->collMailboxs[] = $l; + $l->setDomain($this); + } + + + public function initAddresss() + { + if ($this->collAddresss === null) { + $this->collAddresss = array(); + } + } + + + public function getAddresss($criteria = null, $con = null) + { + include_once 'lib/model/om/BaseAddressPeer.php'; + if ($criteria === null) { + $criteria = new Criteria(); + } + elseif ($criteria instanceof Criteria) + { + $criteria = clone $criteria; + } + + if ($this->collAddresss === null) { + if ($this->isNew()) { + $this->collAddresss = array(); + } else { + + $criteria->add(AddressPeer::DOMAIN_ID, $this->getId()); + + AddressPeer::addSelectColumns($criteria); + $this->collAddresss = AddressPeer::doSelect($criteria, $con); + } + } else { + if (!$this->isNew()) { + + + $criteria->add(AddressPeer::DOMAIN_ID, $this->getId()); + + AddressPeer::addSelectColumns($criteria); + if (!isset($this->lastAddressCriteria) || !$this->lastAddressCriteria->equals($criteria)) { + $this->collAddresss = AddressPeer::doSelect($criteria, $con); + } + } + } + $this->lastAddressCriteria = $criteria; + return $this->collAddresss; + } + + + public function countAddresss($criteria = null, $distinct = false, $con = null) + { + include_once 'lib/model/om/BaseAddressPeer.php'; + if ($criteria === null) { + $criteria = new Criteria(); + } + elseif ($criteria instanceof Criteria) + { + $criteria = clone $criteria; + } + + $criteria->add(AddressPeer::DOMAIN_ID, $this->getId()); + + return AddressPeer::doCount($criteria, $distinct, $con); + } + + + public function addAddress(Address $l) + { + $this->collAddresss[] = $l; + $l->setDomain($this); + } + + + + public function getAddresssJoinMailbox($criteria = null, $con = null) + { + include_once 'lib/model/om/BaseAddressPeer.php'; + if ($criteria === null) { + $criteria = new Criteria(); + } + elseif ($criteria instanceof Criteria) + { + $criteria = clone $criteria; + } + + if ($this->collAddresss === null) { + if ($this->isNew()) { + $this->collAddresss = array(); + } else { + + $criteria->add(AddressPeer::DOMAIN_ID, $this->getId()); + + $this->collAddresss = AddressPeer::doSelectJoinMailbox($criteria, $con); + } + } else { + + $criteria->add(AddressPeer::DOMAIN_ID, $this->getId()); + + if (!isset($this->lastAddressCriteria) || !$this->lastAddressCriteria->equals($criteria)) { + $this->collAddresss = AddressPeer::doSelectJoinMailbox($criteria, $con); + } + } + $this->lastAddressCriteria = $criteria; + + return $this->collAddresss; + } + +} \ No newline at end of file diff --git a/lib/model/om/BaseDomainPeer.php b/lib/model/om/BaseDomainPeer.php new file mode 100644 index 0000000..93ee281 --- /dev/null +++ b/lib/model/om/BaseDomainPeer.php @@ -0,0 +1,591 @@ + array ('Id', 'Name', 'CreatorId', 'MailboxPrefix', 'MaxMailboxCount', 'Quota', 'DefaultMailboxQuota', ), + BasePeer::TYPE_COLNAME => array (DomainPeer::ID, DomainPeer::NAME, DomainPeer::CREATOR_ID, DomainPeer::MAILBOX_PREFIX, DomainPeer::MAX_MAILBOX_COUNT, DomainPeer::QUOTA, DomainPeer::DEFAULT_MAILBOX_QUOTA, ), + BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'creator_id', 'mailbox_prefix', 'max_mailbox_count', 'quota', 'default_mailbox_quota', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, ) + ); + + + private static $fieldKeys = array ( + BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Name' => 1, 'CreatorId' => 2, 'MailboxPrefix' => 3, 'MaxMailboxCount' => 4, 'Quota' => 5, 'DefaultMailboxQuota' => 6, ), + BasePeer::TYPE_COLNAME => array (DomainPeer::ID => 0, DomainPeer::NAME => 1, DomainPeer::CREATOR_ID => 2, DomainPeer::MAILBOX_PREFIX => 3, DomainPeer::MAX_MAILBOX_COUNT => 4, DomainPeer::QUOTA => 5, DomainPeer::DEFAULT_MAILBOX_QUOTA => 6, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'creator_id' => 2, 'mailbox_prefix' => 3, 'max_mailbox_count' => 4, 'quota' => 5, 'default_mailbox_quota' => 6, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, ) + ); + + + public static function getMapBuilder() + { + include_once 'lib/model/map/DomainMapBuilder.php'; + return BasePeer::getMapBuilder('lib.model.map.DomainMapBuilder'); + } + + public static function getPhpNameMap() + { + if (self::$phpNameMap === null) { + $map = DomainPeer::getTableMap(); + $columns = $map->getColumns(); + $nameMap = array(); + foreach ($columns as $column) { + $nameMap[$column->getPhpName()] = $column->getColumnName(); + } + self::$phpNameMap = $nameMap; + } + return self::$phpNameMap; + } + + static public function translateFieldName($name, $fromType, $toType) + { + $toNames = self::getFieldNames($toType); + $key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null; + if ($key === null) { + throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true)); + } + return $toNames[$key]; + } + + + + static public function getFieldNames($type = BasePeer::TYPE_PHPNAME) + { + if (!array_key_exists($type, self::$fieldNames)) { + throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.'); + } + return self::$fieldNames[$type]; + } + + + public static function alias($alias, $column) + { + return str_replace(DomainPeer::TABLE_NAME.'.', $alias.'.', $column); + } + + + public static function addSelectColumns(Criteria $criteria) + { + + $criteria->addSelectColumn(DomainPeer::ID); + + $criteria->addSelectColumn(DomainPeer::NAME); + + $criteria->addSelectColumn(DomainPeer::CREATOR_ID); + + $criteria->addSelectColumn(DomainPeer::MAILBOX_PREFIX); + + $criteria->addSelectColumn(DomainPeer::MAX_MAILBOX_COUNT); + + $criteria->addSelectColumn(DomainPeer::QUOTA); + + $criteria->addSelectColumn(DomainPeer::DEFAULT_MAILBOX_QUOTA); + + } + + const COUNT = 'COUNT(domain.ID)'; + const COUNT_DISTINCT = 'COUNT(DISTINCT domain.ID)'; + + + public static function doCount(Criteria $criteria, $distinct = false, $con = null) + { + $criteria = clone $criteria; + + $criteria->clearSelectColumns()->clearOrderByColumns(); + if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->addSelectColumn(DomainPeer::COUNT_DISTINCT); + } else { + $criteria->addSelectColumn(DomainPeer::COUNT); + } + + foreach($criteria->getGroupByColumns() as $column) + { + $criteria->addSelectColumn($column); + } + + $rs = DomainPeer::doSelectRS($criteria, $con); + if ($rs->next()) { + return $rs->getInt(1); + } else { + return 0; + } + } + + public static function doSelectOne(Criteria $criteria, $con = null) + { + $critcopy = clone $criteria; + $critcopy->setLimit(1); + $objects = DomainPeer::doSelect($critcopy, $con); + if ($objects) { + return $objects[0]; + } + return null; + } + + public static function doSelect(Criteria $criteria, $con = null) + { + return DomainPeer::populateObjects(DomainPeer::doSelectRS($criteria, $con)); + } + + public static function doSelectRS(Criteria $criteria, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + if (!$criteria->getSelectColumns()) { + $criteria = clone $criteria; + DomainPeer::addSelectColumns($criteria); + } + + $criteria->setDbName(self::DATABASE_NAME); + + return BasePeer::doSelect($criteria, $con); + } + + public static function populateObjects(ResultSet $rs) + { + $results = array(); + + $cls = DomainPeer::getOMClass(); + $cls = Propel::import($cls); + while($rs->next()) { + + $obj = new $cls(); + $obj->hydrate($rs); + $results[] = $obj; + + } + return $results; + } + + + public static function doCountJoinUser(Criteria $criteria, $distinct = false, $con = null) + { + $criteria = clone $criteria; + + $criteria->clearSelectColumns()->clearOrderByColumns(); + if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->addSelectColumn(DomainPeer::COUNT_DISTINCT); + } else { + $criteria->addSelectColumn(DomainPeer::COUNT); + } + + foreach($criteria->getGroupByColumns() as $column) + { + $criteria->addSelectColumn($column); + } + + $criteria->addJoin(DomainPeer::CREATOR_ID, UserPeer::ID); + + $rs = DomainPeer::doSelectRS($criteria, $con); + if ($rs->next()) { + return $rs->getInt(1); + } else { + return 0; + } + } + + + + public static function doSelectJoinUser(Criteria $c, $con = null) + { + $c = clone $c; + + if ($c->getDbName() == Propel::getDefaultDB()) { + $c->setDbName(self::DATABASE_NAME); + } + + DomainPeer::addSelectColumns($c); + $startcol = (DomainPeer::NUM_COLUMNS - DomainPeer::NUM_LAZY_LOAD_COLUMNS) + 1; + UserPeer::addSelectColumns($c); + + $c->addJoin(DomainPeer::CREATOR_ID, UserPeer::ID); + $rs = BasePeer::doSelect($c, $con); + $results = array(); + + while($rs->next()) { + + $omClass = DomainPeer::getOMClass(); + + $cls = Propel::import($omClass); + $obj1 = new $cls(); + $obj1->hydrate($rs); + + $omClass = UserPeer::getOMClass(); + + $cls = Propel::import($omClass); + $obj2 = new $cls(); + $obj2->hydrate($rs, $startcol); + + $newObject = true; + foreach($results as $temp_obj1) { + $temp_obj2 = $temp_obj1->getUser(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { + $newObject = false; + $temp_obj2->addDomain($obj1); break; + } + } + if ($newObject) { + $obj2->initDomains(); + $obj2->addDomain($obj1); } + $results[] = $obj1; + } + return $results; + } + + + + public static function doCountJoinAll(Criteria $criteria, $distinct = false, $con = null) + { + $criteria = clone $criteria; + + $criteria->clearSelectColumns()->clearOrderByColumns(); + if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->addSelectColumn(DomainPeer::COUNT_DISTINCT); + } else { + $criteria->addSelectColumn(DomainPeer::COUNT); + } + + foreach($criteria->getGroupByColumns() as $column) + { + $criteria->addSelectColumn($column); + } + + $criteria->addJoin(DomainPeer::CREATOR_ID, UserPeer::ID); + + $rs = DomainPeer::doSelectRS($criteria, $con); + if ($rs->next()) { + return $rs->getInt(1); + } else { + return 0; + } + } + + + + public static function doSelectJoinAll(Criteria $c, $con = null) + { + $c = clone $c; + + if ($c->getDbName() == Propel::getDefaultDB()) { + $c->setDbName(self::DATABASE_NAME); + } + + DomainPeer::addSelectColumns($c); + $startcol2 = (DomainPeer::NUM_COLUMNS - DomainPeer::NUM_LAZY_LOAD_COLUMNS) + 1; + + UserPeer::addSelectColumns($c); + $startcol3 = $startcol2 + UserPeer::NUM_COLUMNS; + + $c->addJoin(DomainPeer::CREATOR_ID, UserPeer::ID); + + $rs = BasePeer::doSelect($c, $con); + $results = array(); + + while($rs->next()) { + + $omClass = DomainPeer::getOMClass(); + + + $cls = Propel::import($omClass); + $obj1 = new $cls(); + $obj1->hydrate($rs); + + + + $omClass = UserPeer::getOMClass(); + + + $cls = Propel::import($omClass); + $obj2 = new $cls(); + $obj2->hydrate($rs, $startcol2); + + $newObject = true; + for ($j=0, $resCount=count($results); $j < $resCount; $j++) { + $temp_obj1 = $results[$j]; + $temp_obj2 = $temp_obj1->getUser(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { + $newObject = false; + $temp_obj2->addDomain($obj1); break; + } + } + + if ($newObject) { + $obj2->initDomains(); + $obj2->addDomain($obj1); + } + + $results[] = $obj1; + } + return $results; + } + + + public static function getTableMap() + { + return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME); + } + + + public static function getOMClass() + { + return DomainPeer::CLASS_DEFAULT; + } + + + public static function doInsert($values, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; } else { + $criteria = $values->buildCriteria(); } + + $criteria->remove(DomainPeer::ID); + + $criteria->setDbName(self::DATABASE_NAME); + + try { + $con->begin(); + $pk = BasePeer::doInsert($criteria, $con); + $con->commit(); + } catch(PropelException $e) { + $con->rollback(); + throw $e; + } + + return $pk; + } + + + public static function doUpdate($values, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + $selectCriteria = new Criteria(self::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; + $comparison = $criteria->getComparison(DomainPeer::ID); + $selectCriteria->add(DomainPeer::ID, $criteria->remove(DomainPeer::ID), $comparison); + + } else { $criteria = $values->buildCriteria(); $selectCriteria = $values->buildPkeyCriteria(); } + + $criteria->setDbName(self::DATABASE_NAME); + + return BasePeer::doUpdate($selectCriteria, $criteria, $con); + } + + + public static function doDeleteAll($con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + $affectedRows = 0; try { + $con->begin(); + $affectedRows += DomainPeer::doOnDeleteCascade(new Criteria(), $con); + DomainPeer::doOnDeleteSetNull(new Criteria(), $con); + $affectedRows += BasePeer::doDeleteAll(DomainPeer::TABLE_NAME, $con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + + public static function doDelete($values, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(DomainPeer::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; } elseif ($values instanceof Domain) { + + $criteria = $values->buildPkeyCriteria(); + } else { + $criteria = new Criteria(self::DATABASE_NAME); + $criteria->add(DomainPeer::ID, (array) $values, Criteria::IN); + } + + $criteria->setDbName(self::DATABASE_NAME); + + $affectedRows = 0; + try { + $con->begin(); + $affectedRows += DomainPeer::doOnDeleteCascade($criteria, $con);DomainPeer::doOnDeleteSetNull($criteria, $con); + $affectedRows += BasePeer::doDelete($criteria, $con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + + protected static function doOnDeleteCascade(Criteria $criteria, Connection $con) + { + $affectedRows = 0; + + $objects = DomainPeer::doSelect($criteria, $con); + foreach($objects as $obj) { + + + include_once 'lib/model/DomainPermission.php'; + + $c = new Criteria(); + + $c->add(DomainPermissionPeer::DOMAIN_ID, $obj->getId()); + $affectedRows += DomainPermissionPeer::doDelete($c, $con); + } + return $affectedRows; + } + + + protected static function doOnDeleteSetNull(Criteria $criteria, Connection $con) + { + + $objects = DomainPeer::doSelect($criteria, $con); + foreach($objects as $obj) { + + $selectCriteria = new Criteria(DomainPeer::DATABASE_NAME); + $updateValues = new Criteria(DomainPeer::DATABASE_NAME); + $selectCriteria->add(MailboxPeer::DOMAIN_ID, $obj->getId()); + $updateValues->add(MailboxPeer::DOMAIN_ID, null); + + BasePeer::doUpdate($selectCriteria, $updateValues, $con); + } + } + + + public static function doValidate(Domain $obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(DomainPeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(DomainPeer::TABLE_NAME); + + if (! is_array($cols)) { + $cols = array($cols); + } + + foreach($cols as $colName) { + if ($tableMap->containsColumn($colName)) { + $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); + $columns[$colName] = $obj->$get(); + } + } + } else { + + } + + $res = BasePeer::doValidate(DomainPeer::DATABASE_NAME, DomainPeer::TABLE_NAME, $columns); + if ($res !== true) { + $request = sfContext::getInstance()->getRequest(); + foreach ($res as $failed) { + $col = DomainPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME); + $request->setError($col, $failed->getMessage()); + } + } + + return $res; + } + + + public static function retrieveByPK($pk, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + $criteria = new Criteria(DomainPeer::DATABASE_NAME); + + $criteria->add(DomainPeer::ID, $pk); + + + $v = DomainPeer::doSelect($criteria, $con); + + return !empty($v) > 0 ? $v[0] : null; + } + + + public static function retrieveByPKs($pks, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(); + $criteria->add(DomainPeer::ID, $pks, Criteria::IN); + $objs = DomainPeer::doSelect($criteria, $con); + } + return $objs; + } + +} +if (Propel::isInit()) { + try { + BaseDomainPeer::getMapBuilder(); + } catch (Exception $e) { + Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR); + } +} else { + require_once 'lib/model/map/DomainMapBuilder.php'; + Propel::registerMapBuilder('lib.model.map.DomainMapBuilder'); +} diff --git a/lib/model/om/BaseDomainPermission.php b/lib/model/om/BaseDomainPermission.php new file mode 100644 index 0000000..48a6e89 --- /dev/null +++ b/lib/model/om/BaseDomainPermission.php @@ -0,0 +1,461 @@ +user_id; + } + + + public function getDomainId() + { + + return $this->domain_id; + } + + + public function getId() + { + + return $this->id; + } + + + public function setUserId($v) + { + + if ($v !== null && !is_int($v) && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->user_id !== $v) { + $this->user_id = $v; + $this->modifiedColumns[] = DomainPermissionPeer::USER_ID; + } + + if ($this->aUser !== null && $this->aUser->getId() !== $v) { + $this->aUser = null; + } + + } + + public function setDomainId($v) + { + + if ($v !== null && !is_int($v) && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->domain_id !== $v) { + $this->domain_id = $v; + $this->modifiedColumns[] = DomainPermissionPeer::DOMAIN_ID; + } + + if ($this->aDomain !== null && $this->aDomain->getId() !== $v) { + $this->aDomain = null; + } + + } + + public function setId($v) + { + + if ($v !== null && !is_int($v) && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = DomainPermissionPeer::ID; + } + + } + + public function hydrate(ResultSet $rs, $startcol = 1) + { + try { + + $this->user_id = $rs->getInt($startcol + 0); + + $this->domain_id = $rs->getInt($startcol + 1); + + $this->id = $rs->getInt($startcol + 2); + + $this->resetModified(); + + $this->setNew(false); + + return $startcol + 3; + } catch (Exception $e) { + throw new PropelException("Error populating DomainPermission object", $e); + } + } + + + public function delete($con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getConnection(DomainPermissionPeer::DATABASE_NAME); + } + + try { + $con->begin(); + DomainPermissionPeer::doDelete($this, $con); + $this->setDeleted(true); + $con->commit(); + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + + public function save($con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getConnection(DomainPermissionPeer::DATABASE_NAME); + } + + try { + $con->begin(); + $affectedRows = $this->doSave($con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + + protected function doSave($con) + { + $affectedRows = 0; if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + + + if ($this->aUser !== null) { + if ($this->aUser->isModified()) { + $affectedRows += $this->aUser->save($con); + } + $this->setUser($this->aUser); + } + + if ($this->aDomain !== null) { + if ($this->aDomain->isModified()) { + $affectedRows += $this->aDomain->save($con); + } + $this->setDomain($this->aDomain); + } + + + if ($this->isModified()) { + if ($this->isNew()) { + $pk = DomainPermissionPeer::doInsert($this, $con); + $affectedRows += 1; + $this->setId($pk); + $this->setNew(false); + } else { + $affectedRows += DomainPermissionPeer::doUpdate($this, $con); + } + $this->resetModified(); } + + $this->alreadyInSave = false; + } + return $affectedRows; + } + + protected $validationFailures = array(); + + + public function getValidationFailures() + { + return $this->validationFailures; + } + + + public function validate($columns = null) + { + $res = $this->doValidate($columns); + if ($res === true) { + $this->validationFailures = array(); + return true; + } else { + $this->validationFailures = $res; + return false; + } + } + + + protected function doValidate($columns = null) + { + if (!$this->alreadyInValidation) { + $this->alreadyInValidation = true; + $retval = null; + + $failureMap = array(); + + + + if ($this->aUser !== null) { + if (!$this->aUser->validate($columns)) { + $failureMap = array_merge($failureMap, $this->aUser->getValidationFailures()); + } + } + + if ($this->aDomain !== null) { + if (!$this->aDomain->validate($columns)) { + $failureMap = array_merge($failureMap, $this->aDomain->getValidationFailures()); + } + } + + + if (($retval = DomainPermissionPeer::doValidate($this, $columns)) !== true) { + $failureMap = array_merge($failureMap, $retval); + } + + + + $this->alreadyInValidation = false; + } + + return (!empty($failureMap) ? $failureMap : true); + } + + + public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + { + $pos = DomainPermissionPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + return $this->getByPosition($pos); + } + + + public function getByPosition($pos) + { + switch($pos) { + case 0: + return $this->getUserId(); + break; + case 1: + return $this->getDomainId(); + break; + case 2: + return $this->getId(); + break; + default: + return null; + break; + } } + + + public function toArray($keyType = BasePeer::TYPE_PHPNAME) + { + $keys = DomainPermissionPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getUserId(), + $keys[1] => $this->getDomainId(), + $keys[2] => $this->getId(), + ); + return $result; + } + + + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $pos = DomainPermissionPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + return $this->setByPosition($pos, $value); + } + + + public function setByPosition($pos, $value) + { + switch($pos) { + case 0: + $this->setUserId($value); + break; + case 1: + $this->setDomainId($value); + break; + case 2: + $this->setId($value); + break; + } } + + + public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) + { + $keys = DomainPermissionPeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setUserId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setDomainId($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setId($arr[$keys[2]]); + } + + + public function buildCriteria() + { + $criteria = new Criteria(DomainPermissionPeer::DATABASE_NAME); + + if ($this->isColumnModified(DomainPermissionPeer::USER_ID)) $criteria->add(DomainPermissionPeer::USER_ID, $this->user_id); + if ($this->isColumnModified(DomainPermissionPeer::DOMAIN_ID)) $criteria->add(DomainPermissionPeer::DOMAIN_ID, $this->domain_id); + if ($this->isColumnModified(DomainPermissionPeer::ID)) $criteria->add(DomainPermissionPeer::ID, $this->id); + + return $criteria; + } + + + public function buildPkeyCriteria() + { + $criteria = new Criteria(DomainPermissionPeer::DATABASE_NAME); + + $criteria->add(DomainPermissionPeer::ID, $this->id); + + return $criteria; + } + + + public function getPrimaryKey() + { + return $this->getId(); + } + + + public function setPrimaryKey($key) + { + $this->setId($key); + } + + + public function copyInto($copyObj, $deepCopy = false) + { + + $copyObj->setUserId($this->user_id); + + $copyObj->setDomainId($this->domain_id); + + + $copyObj->setNew(true); + + $copyObj->setId(NULL); + } + + + public function copy($deepCopy = false) + { + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + return $copyObj; + } + + + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new DomainPermissionPeer(); + } + return self::$peer; + } + + + public function setUser($v) + { + + + if ($v === null) { + $this->setUserId(NULL); + } else { + $this->setUserId($v->getId()); + } + + + $this->aUser = $v; + } + + + + public function getUser($con = null) + { + include_once 'lib/model/om/BaseUserPeer.php'; + + if ($this->aUser === null && ($this->user_id !== null)) { + + $this->aUser = UserPeer::retrieveByPK($this->user_id, $con); + + + } + return $this->aUser; + } + + + public function setDomain($v) + { + + + if ($v === null) { + $this->setDomainId(NULL); + } else { + $this->setDomainId($v->getId()); + } + + + $this->aDomain = $v; + } + + + + public function getDomain($con = null) + { + include_once 'lib/model/om/BaseDomainPeer.php'; + + if ($this->aDomain === null && ($this->domain_id !== null)) { + + $this->aDomain = DomainPeer::retrieveByPK($this->domain_id, $con); + + + } + return $this->aDomain; + } + +} \ No newline at end of file diff --git a/lib/model/om/BaseDomainPermissionPeer.php b/lib/model/om/BaseDomainPermissionPeer.php new file mode 100644 index 0000000..747cea0 --- /dev/null +++ b/lib/model/om/BaseDomainPermissionPeer.php @@ -0,0 +1,809 @@ + array ('UserId', 'DomainId', 'Id', ), + BasePeer::TYPE_COLNAME => array (DomainPermissionPeer::USER_ID, DomainPermissionPeer::DOMAIN_ID, DomainPermissionPeer::ID, ), + BasePeer::TYPE_FIELDNAME => array ('user_id', 'domain_id', 'id', ), + BasePeer::TYPE_NUM => array (0, 1, 2, ) + ); + + + private static $fieldKeys = array ( + BasePeer::TYPE_PHPNAME => array ('UserId' => 0, 'DomainId' => 1, 'Id' => 2, ), + BasePeer::TYPE_COLNAME => array (DomainPermissionPeer::USER_ID => 0, DomainPermissionPeer::DOMAIN_ID => 1, DomainPermissionPeer::ID => 2, ), + BasePeer::TYPE_FIELDNAME => array ('user_id' => 0, 'domain_id' => 1, 'id' => 2, ), + BasePeer::TYPE_NUM => array (0, 1, 2, ) + ); + + + public static function getMapBuilder() + { + include_once 'lib/model/map/DomainPermissionMapBuilder.php'; + return BasePeer::getMapBuilder('lib.model.map.DomainPermissionMapBuilder'); + } + + public static function getPhpNameMap() + { + if (self::$phpNameMap === null) { + $map = DomainPermissionPeer::getTableMap(); + $columns = $map->getColumns(); + $nameMap = array(); + foreach ($columns as $column) { + $nameMap[$column->getPhpName()] = $column->getColumnName(); + } + self::$phpNameMap = $nameMap; + } + return self::$phpNameMap; + } + + static public function translateFieldName($name, $fromType, $toType) + { + $toNames = self::getFieldNames($toType); + $key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null; + if ($key === null) { + throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true)); + } + return $toNames[$key]; + } + + + + static public function getFieldNames($type = BasePeer::TYPE_PHPNAME) + { + if (!array_key_exists($type, self::$fieldNames)) { + throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.'); + } + return self::$fieldNames[$type]; + } + + + public static function alias($alias, $column) + { + return str_replace(DomainPermissionPeer::TABLE_NAME.'.', $alias.'.', $column); + } + + + public static function addSelectColumns(Criteria $criteria) + { + + $criteria->addSelectColumn(DomainPermissionPeer::USER_ID); + + $criteria->addSelectColumn(DomainPermissionPeer::DOMAIN_ID); + + $criteria->addSelectColumn(DomainPermissionPeer::ID); + + } + + const COUNT = 'COUNT(domain_permission.ID)'; + const COUNT_DISTINCT = 'COUNT(DISTINCT domain_permission.ID)'; + + + public static function doCount(Criteria $criteria, $distinct = false, $con = null) + { + $criteria = clone $criteria; + + $criteria->clearSelectColumns()->clearOrderByColumns(); + if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->addSelectColumn(DomainPermissionPeer::COUNT_DISTINCT); + } else { + $criteria->addSelectColumn(DomainPermissionPeer::COUNT); + } + + foreach($criteria->getGroupByColumns() as $column) + { + $criteria->addSelectColumn($column); + } + + $rs = DomainPermissionPeer::doSelectRS($criteria, $con); + if ($rs->next()) { + return $rs->getInt(1); + } else { + return 0; + } + } + + public static function doSelectOne(Criteria $criteria, $con = null) + { + $critcopy = clone $criteria; + $critcopy->setLimit(1); + $objects = DomainPermissionPeer::doSelect($critcopy, $con); + if ($objects) { + return $objects[0]; + } + return null; + } + + public static function doSelect(Criteria $criteria, $con = null) + { + return DomainPermissionPeer::populateObjects(DomainPermissionPeer::doSelectRS($criteria, $con)); + } + + public static function doSelectRS(Criteria $criteria, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + if (!$criteria->getSelectColumns()) { + $criteria = clone $criteria; + DomainPermissionPeer::addSelectColumns($criteria); + } + + $criteria->setDbName(self::DATABASE_NAME); + + return BasePeer::doSelect($criteria, $con); + } + + public static function populateObjects(ResultSet $rs) + { + $results = array(); + + $cls = DomainPermissionPeer::getOMClass(); + $cls = Propel::import($cls); + while($rs->next()) { + + $obj = new $cls(); + $obj->hydrate($rs); + $results[] = $obj; + + } + return $results; + } + + + public static function doCountJoinUser(Criteria $criteria, $distinct = false, $con = null) + { + $criteria = clone $criteria; + + $criteria->clearSelectColumns()->clearOrderByColumns(); + if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->addSelectColumn(DomainPermissionPeer::COUNT_DISTINCT); + } else { + $criteria->addSelectColumn(DomainPermissionPeer::COUNT); + } + + foreach($criteria->getGroupByColumns() as $column) + { + $criteria->addSelectColumn($column); + } + + $criteria->addJoin(DomainPermissionPeer::USER_ID, UserPeer::ID); + + $rs = DomainPermissionPeer::doSelectRS($criteria, $con); + if ($rs->next()) { + return $rs->getInt(1); + } else { + return 0; + } + } + + + + public static function doCountJoinDomain(Criteria $criteria, $distinct = false, $con = null) + { + $criteria = clone $criteria; + + $criteria->clearSelectColumns()->clearOrderByColumns(); + if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->addSelectColumn(DomainPermissionPeer::COUNT_DISTINCT); + } else { + $criteria->addSelectColumn(DomainPermissionPeer::COUNT); + } + + foreach($criteria->getGroupByColumns() as $column) + { + $criteria->addSelectColumn($column); + } + + $criteria->addJoin(DomainPermissionPeer::DOMAIN_ID, DomainPeer::ID); + + $rs = DomainPermissionPeer::doSelectRS($criteria, $con); + if ($rs->next()) { + return $rs->getInt(1); + } else { + return 0; + } + } + + + + public static function doSelectJoinUser(Criteria $c, $con = null) + { + $c = clone $c; + + if ($c->getDbName() == Propel::getDefaultDB()) { + $c->setDbName(self::DATABASE_NAME); + } + + DomainPermissionPeer::addSelectColumns($c); + $startcol = (DomainPermissionPeer::NUM_COLUMNS - DomainPermissionPeer::NUM_LAZY_LOAD_COLUMNS) + 1; + UserPeer::addSelectColumns($c); + + $c->addJoin(DomainPermissionPeer::USER_ID, UserPeer::ID); + $rs = BasePeer::doSelect($c, $con); + $results = array(); + + while($rs->next()) { + + $omClass = DomainPermissionPeer::getOMClass(); + + $cls = Propel::import($omClass); + $obj1 = new $cls(); + $obj1->hydrate($rs); + + $omClass = UserPeer::getOMClass(); + + $cls = Propel::import($omClass); + $obj2 = new $cls(); + $obj2->hydrate($rs, $startcol); + + $newObject = true; + foreach($results as $temp_obj1) { + $temp_obj2 = $temp_obj1->getUser(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { + $newObject = false; + $temp_obj2->addDomainPermission($obj1); break; + } + } + if ($newObject) { + $obj2->initDomainPermissions(); + $obj2->addDomainPermission($obj1); } + $results[] = $obj1; + } + return $results; + } + + + + public static function doSelectJoinDomain(Criteria $c, $con = null) + { + $c = clone $c; + + if ($c->getDbName() == Propel::getDefaultDB()) { + $c->setDbName(self::DATABASE_NAME); + } + + DomainPermissionPeer::addSelectColumns($c); + $startcol = (DomainPermissionPeer::NUM_COLUMNS - DomainPermissionPeer::NUM_LAZY_LOAD_COLUMNS) + 1; + DomainPeer::addSelectColumns($c); + + $c->addJoin(DomainPermissionPeer::DOMAIN_ID, DomainPeer::ID); + $rs = BasePeer::doSelect($c, $con); + $results = array(); + + while($rs->next()) { + + $omClass = DomainPermissionPeer::getOMClass(); + + $cls = Propel::import($omClass); + $obj1 = new $cls(); + $obj1->hydrate($rs); + + $omClass = DomainPeer::getOMClass(); + + $cls = Propel::import($omClass); + $obj2 = new $cls(); + $obj2->hydrate($rs, $startcol); + + $newObject = true; + foreach($results as $temp_obj1) { + $temp_obj2 = $temp_obj1->getDomain(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { + $newObject = false; + $temp_obj2->addDomainPermission($obj1); break; + } + } + if ($newObject) { + $obj2->initDomainPermissions(); + $obj2->addDomainPermission($obj1); } + $results[] = $obj1; + } + return $results; + } + + + + public static function doCountJoinAll(Criteria $criteria, $distinct = false, $con = null) + { + $criteria = clone $criteria; + + $criteria->clearSelectColumns()->clearOrderByColumns(); + if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->addSelectColumn(DomainPermissionPeer::COUNT_DISTINCT); + } else { + $criteria->addSelectColumn(DomainPermissionPeer::COUNT); + } + + foreach($criteria->getGroupByColumns() as $column) + { + $criteria->addSelectColumn($column); + } + + $criteria->addJoin(DomainPermissionPeer::USER_ID, UserPeer::ID); + + $criteria->addJoin(DomainPermissionPeer::DOMAIN_ID, DomainPeer::ID); + + $rs = DomainPermissionPeer::doSelectRS($criteria, $con); + if ($rs->next()) { + return $rs->getInt(1); + } else { + return 0; + } + } + + + + public static function doSelectJoinAll(Criteria $c, $con = null) + { + $c = clone $c; + + if ($c->getDbName() == Propel::getDefaultDB()) { + $c->setDbName(self::DATABASE_NAME); + } + + DomainPermissionPeer::addSelectColumns($c); + $startcol2 = (DomainPermissionPeer::NUM_COLUMNS - DomainPermissionPeer::NUM_LAZY_LOAD_COLUMNS) + 1; + + UserPeer::addSelectColumns($c); + $startcol3 = $startcol2 + UserPeer::NUM_COLUMNS; + + DomainPeer::addSelectColumns($c); + $startcol4 = $startcol3 + DomainPeer::NUM_COLUMNS; + + $c->addJoin(DomainPermissionPeer::USER_ID, UserPeer::ID); + + $c->addJoin(DomainPermissionPeer::DOMAIN_ID, DomainPeer::ID); + + $rs = BasePeer::doSelect($c, $con); + $results = array(); + + while($rs->next()) { + + $omClass = DomainPermissionPeer::getOMClass(); + + + $cls = Propel::import($omClass); + $obj1 = new $cls(); + $obj1->hydrate($rs); + + + + $omClass = UserPeer::getOMClass(); + + + $cls = Propel::import($omClass); + $obj2 = new $cls(); + $obj2->hydrate($rs, $startcol2); + + $newObject = true; + for ($j=0, $resCount=count($results); $j < $resCount; $j++) { + $temp_obj1 = $results[$j]; + $temp_obj2 = $temp_obj1->getUser(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { + $newObject = false; + $temp_obj2->addDomainPermission($obj1); break; + } + } + + if ($newObject) { + $obj2->initDomainPermissions(); + $obj2->addDomainPermission($obj1); + } + + + + $omClass = DomainPeer::getOMClass(); + + + $cls = Propel::import($omClass); + $obj3 = new $cls(); + $obj3->hydrate($rs, $startcol3); + + $newObject = true; + for ($j=0, $resCount=count($results); $j < $resCount; $j++) { + $temp_obj1 = $results[$j]; + $temp_obj3 = $temp_obj1->getDomain(); if ($temp_obj3->getPrimaryKey() === $obj3->getPrimaryKey()) { + $newObject = false; + $temp_obj3->addDomainPermission($obj1); break; + } + } + + if ($newObject) { + $obj3->initDomainPermissions(); + $obj3->addDomainPermission($obj1); + } + + $results[] = $obj1; + } + return $results; + } + + + + public static function doCountJoinAllExceptUser(Criteria $criteria, $distinct = false, $con = null) + { + $criteria = clone $criteria; + + $criteria->clearSelectColumns()->clearOrderByColumns(); + if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->addSelectColumn(DomainPermissionPeer::COUNT_DISTINCT); + } else { + $criteria->addSelectColumn(DomainPermissionPeer::COUNT); + } + + foreach($criteria->getGroupByColumns() as $column) + { + $criteria->addSelectColumn($column); + } + + $criteria->addJoin(DomainPermissionPeer::DOMAIN_ID, DomainPeer::ID); + + $rs = DomainPermissionPeer::doSelectRS($criteria, $con); + if ($rs->next()) { + return $rs->getInt(1); + } else { + return 0; + } + } + + + + public static function doCountJoinAllExceptDomain(Criteria $criteria, $distinct = false, $con = null) + { + $criteria = clone $criteria; + + $criteria->clearSelectColumns()->clearOrderByColumns(); + if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->addSelectColumn(DomainPermissionPeer::COUNT_DISTINCT); + } else { + $criteria->addSelectColumn(DomainPermissionPeer::COUNT); + } + + foreach($criteria->getGroupByColumns() as $column) + { + $criteria->addSelectColumn($column); + } + + $criteria->addJoin(DomainPermissionPeer::USER_ID, UserPeer::ID); + + $rs = DomainPermissionPeer::doSelectRS($criteria, $con); + if ($rs->next()) { + return $rs->getInt(1); + } else { + return 0; + } + } + + + + public static function doSelectJoinAllExceptUser(Criteria $c, $con = null) + { + $c = clone $c; + + if ($c->getDbName() == Propel::getDefaultDB()) { + $c->setDbName(self::DATABASE_NAME); + } + + DomainPermissionPeer::addSelectColumns($c); + $startcol2 = (DomainPermissionPeer::NUM_COLUMNS - DomainPermissionPeer::NUM_LAZY_LOAD_COLUMNS) + 1; + + DomainPeer::addSelectColumns($c); + $startcol3 = $startcol2 + DomainPeer::NUM_COLUMNS; + + $c->addJoin(DomainPermissionPeer::DOMAIN_ID, DomainPeer::ID); + + + $rs = BasePeer::doSelect($c, $con); + $results = array(); + + while($rs->next()) { + + $omClass = DomainPermissionPeer::getOMClass(); + + $cls = Propel::import($omClass); + $obj1 = new $cls(); + $obj1->hydrate($rs); + + $omClass = DomainPeer::getOMClass(); + + + $cls = Propel::import($omClass); + $obj2 = new $cls(); + $obj2->hydrate($rs, $startcol2); + + $newObject = true; + for ($j=0, $resCount=count($results); $j < $resCount; $j++) { + $temp_obj1 = $results[$j]; + $temp_obj2 = $temp_obj1->getDomain(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { + $newObject = false; + $temp_obj2->addDomainPermission($obj1); + break; + } + } + + if ($newObject) { + $obj2->initDomainPermissions(); + $obj2->addDomainPermission($obj1); + } + + $results[] = $obj1; + } + return $results; + } + + + + public static function doSelectJoinAllExceptDomain(Criteria $c, $con = null) + { + $c = clone $c; + + if ($c->getDbName() == Propel::getDefaultDB()) { + $c->setDbName(self::DATABASE_NAME); + } + + DomainPermissionPeer::addSelectColumns($c); + $startcol2 = (DomainPermissionPeer::NUM_COLUMNS - DomainPermissionPeer::NUM_LAZY_LOAD_COLUMNS) + 1; + + UserPeer::addSelectColumns($c); + $startcol3 = $startcol2 + UserPeer::NUM_COLUMNS; + + $c->addJoin(DomainPermissionPeer::USER_ID, UserPeer::ID); + + + $rs = BasePeer::doSelect($c, $con); + $results = array(); + + while($rs->next()) { + + $omClass = DomainPermissionPeer::getOMClass(); + + $cls = Propel::import($omClass); + $obj1 = new $cls(); + $obj1->hydrate($rs); + + $omClass = UserPeer::getOMClass(); + + + $cls = Propel::import($omClass); + $obj2 = new $cls(); + $obj2->hydrate($rs, $startcol2); + + $newObject = true; + for ($j=0, $resCount=count($results); $j < $resCount; $j++) { + $temp_obj1 = $results[$j]; + $temp_obj2 = $temp_obj1->getUser(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { + $newObject = false; + $temp_obj2->addDomainPermission($obj1); + break; + } + } + + if ($newObject) { + $obj2->initDomainPermissions(); + $obj2->addDomainPermission($obj1); + } + + $results[] = $obj1; + } + return $results; + } + + + public static function getTableMap() + { + return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME); + } + + + public static function getOMClass() + { + return DomainPermissionPeer::CLASS_DEFAULT; + } + + + public static function doInsert($values, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; } else { + $criteria = $values->buildCriteria(); } + + $criteria->remove(DomainPermissionPeer::ID); + + $criteria->setDbName(self::DATABASE_NAME); + + try { + $con->begin(); + $pk = BasePeer::doInsert($criteria, $con); + $con->commit(); + } catch(PropelException $e) { + $con->rollback(); + throw $e; + } + + return $pk; + } + + + public static function doUpdate($values, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + $selectCriteria = new Criteria(self::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; + $comparison = $criteria->getComparison(DomainPermissionPeer::ID); + $selectCriteria->add(DomainPermissionPeer::ID, $criteria->remove(DomainPermissionPeer::ID), $comparison); + + } else { $criteria = $values->buildCriteria(); $selectCriteria = $values->buildPkeyCriteria(); } + + $criteria->setDbName(self::DATABASE_NAME); + + return BasePeer::doUpdate($selectCriteria, $criteria, $con); + } + + + public static function doDeleteAll($con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + $affectedRows = 0; try { + $con->begin(); + $affectedRows += BasePeer::doDeleteAll(DomainPermissionPeer::TABLE_NAME, $con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + + public static function doDelete($values, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(DomainPermissionPeer::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; } elseif ($values instanceof DomainPermission) { + + $criteria = $values->buildPkeyCriteria(); + } else { + $criteria = new Criteria(self::DATABASE_NAME); + $criteria->add(DomainPermissionPeer::ID, (array) $values, Criteria::IN); + } + + $criteria->setDbName(self::DATABASE_NAME); + + $affectedRows = 0; + try { + $con->begin(); + + $affectedRows += BasePeer::doDelete($criteria, $con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + + public static function doValidate(DomainPermission $obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(DomainPermissionPeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(DomainPermissionPeer::TABLE_NAME); + + if (! is_array($cols)) { + $cols = array($cols); + } + + foreach($cols as $colName) { + if ($tableMap->containsColumn($colName)) { + $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); + $columns[$colName] = $obj->$get(); + } + } + } else { + + } + + $res = BasePeer::doValidate(DomainPermissionPeer::DATABASE_NAME, DomainPermissionPeer::TABLE_NAME, $columns); + if ($res !== true) { + $request = sfContext::getInstance()->getRequest(); + foreach ($res as $failed) { + $col = DomainPermissionPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME); + $request->setError($col, $failed->getMessage()); + } + } + + return $res; + } + + + public static function retrieveByPK($pk, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + $criteria = new Criteria(DomainPermissionPeer::DATABASE_NAME); + + $criteria->add(DomainPermissionPeer::ID, $pk); + + + $v = DomainPermissionPeer::doSelect($criteria, $con); + + return !empty($v) > 0 ? $v[0] : null; + } + + + public static function retrieveByPKs($pks, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(); + $criteria->add(DomainPermissionPeer::ID, $pks, Criteria::IN); + $objs = DomainPermissionPeer::doSelect($criteria, $con); + } + return $objs; + } + +} +if (Propel::isInit()) { + try { + BaseDomainPermissionPeer::getMapBuilder(); + } catch (Exception $e) { + Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR); + } +} else { + require_once 'lib/model/map/DomainPermissionMapBuilder.php'; + Propel::registerMapBuilder('lib.model.map.DomainPermissionMapBuilder'); +} diff --git a/lib/model/om/BaseLogEntry.php b/lib/model/om/BaseLogEntry.php new file mode 100644 index 0000000..5bf1f41 --- /dev/null +++ b/lib/model/om/BaseLogEntry.php @@ -0,0 +1,548 @@ +id; + } + + + public function getUserId() + { + + return $this->user_id; + } + + + public function getCreatedAt($format = 'Y-m-d H:i:s') + { + + if ($this->created_at === null || $this->created_at === '') { + return null; + } elseif (!is_int($this->created_at)) { + $ts = strtotime($this->created_at); + if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse value of [created_at] as date/time value: " . var_export($this->created_at, true)); + } + } else { + $ts = $this->created_at; + } + if ($format === null) { + return $ts; + } elseif (strpos($format, '%') !== false) { + return strftime($format, $ts); + } else { + return date($format, $ts); + } + } + + + public function getMessage() + { + + return $this->message; + } + + + public function getHost() + { + + return $this->host; + } + + + public function getPriority() + { + + return $this->priority; + } + + + public function setId($v) + { + + if ($v !== null && !is_int($v) && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = LogEntryPeer::ID; + } + + } + + public function setUserId($v) + { + + if ($v !== null && !is_int($v) && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->user_id !== $v || $v === 0) { + $this->user_id = $v; + $this->modifiedColumns[] = LogEntryPeer::USER_ID; + } + + if ($this->aUser !== null && $this->aUser->getId() !== $v) { + $this->aUser = null; + } + + } + + public function setCreatedAt($v) + { + + if ($v !== null && !is_int($v)) { + $ts = strtotime($v); + if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse date/time value for [created_at] from input: " . var_export($v, true)); + } + } else { + $ts = $v; + } + if ($this->created_at !== $ts) { + $this->created_at = $ts; + $this->modifiedColumns[] = LogEntryPeer::CREATED_AT; + } + + } + + public function setMessage($v) + { + + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->message !== $v) { + $this->message = $v; + $this->modifiedColumns[] = LogEntryPeer::MESSAGE; + } + + } + + public function setHost($v) + { + + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->host !== $v) { + $this->host = $v; + $this->modifiedColumns[] = LogEntryPeer::HOST; + } + + } + + public function setPriority($v) + { + + if ($v !== null && !is_int($v) && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->priority !== $v) { + $this->priority = $v; + $this->modifiedColumns[] = LogEntryPeer::PRIORITY; + } + + } + + public function hydrate(ResultSet $rs, $startcol = 1) + { + try { + + $this->id = $rs->getInt($startcol + 0); + + $this->user_id = $rs->getInt($startcol + 1); + + $this->created_at = $rs->getTimestamp($startcol + 2, null); + + $this->message = $rs->getString($startcol + 3); + + $this->host = $rs->getString($startcol + 4); + + $this->priority = $rs->getInt($startcol + 5); + + $this->resetModified(); + + $this->setNew(false); + + return $startcol + 6; + } catch (Exception $e) { + throw new PropelException("Error populating LogEntry object", $e); + } + } + + + public function delete($con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getConnection(LogEntryPeer::DATABASE_NAME); + } + + try { + $con->begin(); + LogEntryPeer::doDelete($this, $con); + $this->setDeleted(true); + $con->commit(); + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + + public function save($con = null) + { + if ($this->isNew() && !$this->isColumnModified(LogEntryPeer::CREATED_AT)) + { + $this->setCreatedAt(time()); + } + + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getConnection(LogEntryPeer::DATABASE_NAME); + } + + try { + $con->begin(); + $affectedRows = $this->doSave($con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + + protected function doSave($con) + { + $affectedRows = 0; if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + + + if ($this->aUser !== null) { + if ($this->aUser->isModified()) { + $affectedRows += $this->aUser->save($con); + } + $this->setUser($this->aUser); + } + + + if ($this->isModified()) { + if ($this->isNew()) { + $pk = LogEntryPeer::doInsert($this, $con); + $affectedRows += 1; + $this->setId($pk); + $this->setNew(false); + } else { + $affectedRows += LogEntryPeer::doUpdate($this, $con); + } + $this->resetModified(); } + + $this->alreadyInSave = false; + } + return $affectedRows; + } + + protected $validationFailures = array(); + + + public function getValidationFailures() + { + return $this->validationFailures; + } + + + public function validate($columns = null) + { + $res = $this->doValidate($columns); + if ($res === true) { + $this->validationFailures = array(); + return true; + } else { + $this->validationFailures = $res; + return false; + } + } + + + protected function doValidate($columns = null) + { + if (!$this->alreadyInValidation) { + $this->alreadyInValidation = true; + $retval = null; + + $failureMap = array(); + + + + if ($this->aUser !== null) { + if (!$this->aUser->validate($columns)) { + $failureMap = array_merge($failureMap, $this->aUser->getValidationFailures()); + } + } + + + if (($retval = LogEntryPeer::doValidate($this, $columns)) !== true) { + $failureMap = array_merge($failureMap, $retval); + } + + + + $this->alreadyInValidation = false; + } + + return (!empty($failureMap) ? $failureMap : true); + } + + + public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + { + $pos = LogEntryPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + return $this->getByPosition($pos); + } + + + public function getByPosition($pos) + { + switch($pos) { + case 0: + return $this->getId(); + break; + case 1: + return $this->getUserId(); + break; + case 2: + return $this->getCreatedAt(); + break; + case 3: + return $this->getMessage(); + break; + case 4: + return $this->getHost(); + break; + case 5: + return $this->getPriority(); + break; + default: + return null; + break; + } } + + + public function toArray($keyType = BasePeer::TYPE_PHPNAME) + { + $keys = LogEntryPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getUserId(), + $keys[2] => $this->getCreatedAt(), + $keys[3] => $this->getMessage(), + $keys[4] => $this->getHost(), + $keys[5] => $this->getPriority(), + ); + return $result; + } + + + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $pos = LogEntryPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + return $this->setByPosition($pos, $value); + } + + + public function setByPosition($pos, $value) + { + switch($pos) { + case 0: + $this->setId($value); + break; + case 1: + $this->setUserId($value); + break; + case 2: + $this->setCreatedAt($value); + break; + case 3: + $this->setMessage($value); + break; + case 4: + $this->setHost($value); + break; + case 5: + $this->setPriority($value); + break; + } } + + + public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) + { + $keys = LogEntryPeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setUserId($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setCreatedAt($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setMessage($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setHost($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setPriority($arr[$keys[5]]); + } + + + public function buildCriteria() + { + $criteria = new Criteria(LogEntryPeer::DATABASE_NAME); + + if ($this->isColumnModified(LogEntryPeer::ID)) $criteria->add(LogEntryPeer::ID, $this->id); + if ($this->isColumnModified(LogEntryPeer::USER_ID)) $criteria->add(LogEntryPeer::USER_ID, $this->user_id); + if ($this->isColumnModified(LogEntryPeer::CREATED_AT)) $criteria->add(LogEntryPeer::CREATED_AT, $this->created_at); + if ($this->isColumnModified(LogEntryPeer::MESSAGE)) $criteria->add(LogEntryPeer::MESSAGE, $this->message); + if ($this->isColumnModified(LogEntryPeer::HOST)) $criteria->add(LogEntryPeer::HOST, $this->host); + if ($this->isColumnModified(LogEntryPeer::PRIORITY)) $criteria->add(LogEntryPeer::PRIORITY, $this->priority); + + return $criteria; + } + + + public function buildPkeyCriteria() + { + $criteria = new Criteria(LogEntryPeer::DATABASE_NAME); + + $criteria->add(LogEntryPeer::ID, $this->id); + + return $criteria; + } + + + public function getPrimaryKey() + { + return $this->getId(); + } + + + public function setPrimaryKey($key) + { + $this->setId($key); + } + + + public function copyInto($copyObj, $deepCopy = false) + { + + $copyObj->setUserId($this->user_id); + + $copyObj->setCreatedAt($this->created_at); + + $copyObj->setMessage($this->message); + + $copyObj->setHost($this->host); + + $copyObj->setPriority($this->priority); + + + $copyObj->setNew(true); + + $copyObj->setId(NULL); + } + + + public function copy($deepCopy = false) + { + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + return $copyObj; + } + + + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new LogEntryPeer(); + } + return self::$peer; + } + + + public function setUser($v) + { + + + if ($v === null) { + $this->setUserId('null'); + } else { + $this->setUserId($v->getId()); + } + + + $this->aUser = $v; + } + + + + public function getUser($con = null) + { + include_once 'lib/model/om/BaseUserPeer.php'; + + if ($this->aUser === null && ($this->user_id !== null)) { + + $this->aUser = UserPeer::retrieveByPK($this->user_id, $con); + + + } + return $this->aUser; + } + +} \ No newline at end of file diff --git a/lib/model/om/BaseLogEntryPeer.php b/lib/model/om/BaseLogEntryPeer.php new file mode 100644 index 0000000..2b3d8ec --- /dev/null +++ b/lib/model/om/BaseLogEntryPeer.php @@ -0,0 +1,549 @@ + array ('Id', 'UserId', 'CreatedAt', 'Message', 'Host', 'Priority', ), + BasePeer::TYPE_COLNAME => array (LogEntryPeer::ID, LogEntryPeer::USER_ID, LogEntryPeer::CREATED_AT, LogEntryPeer::MESSAGE, LogEntryPeer::HOST, LogEntryPeer::PRIORITY, ), + BasePeer::TYPE_FIELDNAME => array ('id', 'user_id', 'created_at', 'message', 'host', 'priority', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, ) + ); + + + private static $fieldKeys = array ( + BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'UserId' => 1, 'CreatedAt' => 2, 'Message' => 3, 'Host' => 4, 'Priority' => 5, ), + BasePeer::TYPE_COLNAME => array (LogEntryPeer::ID => 0, LogEntryPeer::USER_ID => 1, LogEntryPeer::CREATED_AT => 2, LogEntryPeer::MESSAGE => 3, LogEntryPeer::HOST => 4, LogEntryPeer::PRIORITY => 5, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'user_id' => 1, 'created_at' => 2, 'message' => 3, 'host' => 4, 'priority' => 5, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, ) + ); + + + public static function getMapBuilder() + { + include_once 'lib/model/map/LogEntryMapBuilder.php'; + return BasePeer::getMapBuilder('lib.model.map.LogEntryMapBuilder'); + } + + public static function getPhpNameMap() + { + if (self::$phpNameMap === null) { + $map = LogEntryPeer::getTableMap(); + $columns = $map->getColumns(); + $nameMap = array(); + foreach ($columns as $column) { + $nameMap[$column->getPhpName()] = $column->getColumnName(); + } + self::$phpNameMap = $nameMap; + } + return self::$phpNameMap; + } + + static public function translateFieldName($name, $fromType, $toType) + { + $toNames = self::getFieldNames($toType); + $key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null; + if ($key === null) { + throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true)); + } + return $toNames[$key]; + } + + + + static public function getFieldNames($type = BasePeer::TYPE_PHPNAME) + { + if (!array_key_exists($type, self::$fieldNames)) { + throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.'); + } + return self::$fieldNames[$type]; + } + + + public static function alias($alias, $column) + { + return str_replace(LogEntryPeer::TABLE_NAME.'.', $alias.'.', $column); + } + + + public static function addSelectColumns(Criteria $criteria) + { + + $criteria->addSelectColumn(LogEntryPeer::ID); + + $criteria->addSelectColumn(LogEntryPeer::USER_ID); + + $criteria->addSelectColumn(LogEntryPeer::CREATED_AT); + + $criteria->addSelectColumn(LogEntryPeer::MESSAGE); + + $criteria->addSelectColumn(LogEntryPeer::HOST); + + $criteria->addSelectColumn(LogEntryPeer::PRIORITY); + + } + + const COUNT = 'COUNT(log.ID)'; + const COUNT_DISTINCT = 'COUNT(DISTINCT log.ID)'; + + + public static function doCount(Criteria $criteria, $distinct = false, $con = null) + { + $criteria = clone $criteria; + + $criteria->clearSelectColumns()->clearOrderByColumns(); + if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->addSelectColumn(LogEntryPeer::COUNT_DISTINCT); + } else { + $criteria->addSelectColumn(LogEntryPeer::COUNT); + } + + foreach($criteria->getGroupByColumns() as $column) + { + $criteria->addSelectColumn($column); + } + + $rs = LogEntryPeer::doSelectRS($criteria, $con); + if ($rs->next()) { + return $rs->getInt(1); + } else { + return 0; + } + } + + public static function doSelectOne(Criteria $criteria, $con = null) + { + $critcopy = clone $criteria; + $critcopy->setLimit(1); + $objects = LogEntryPeer::doSelect($critcopy, $con); + if ($objects) { + return $objects[0]; + } + return null; + } + + public static function doSelect(Criteria $criteria, $con = null) + { + return LogEntryPeer::populateObjects(LogEntryPeer::doSelectRS($criteria, $con)); + } + + public static function doSelectRS(Criteria $criteria, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + if (!$criteria->getSelectColumns()) { + $criteria = clone $criteria; + LogEntryPeer::addSelectColumns($criteria); + } + + $criteria->setDbName(self::DATABASE_NAME); + + return BasePeer::doSelect($criteria, $con); + } + + public static function populateObjects(ResultSet $rs) + { + $results = array(); + + $cls = LogEntryPeer::getOMClass(); + $cls = Propel::import($cls); + while($rs->next()) { + + $obj = new $cls(); + $obj->hydrate($rs); + $results[] = $obj; + + } + return $results; + } + + + public static function doCountJoinUser(Criteria $criteria, $distinct = false, $con = null) + { + $criteria = clone $criteria; + + $criteria->clearSelectColumns()->clearOrderByColumns(); + if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->addSelectColumn(LogEntryPeer::COUNT_DISTINCT); + } else { + $criteria->addSelectColumn(LogEntryPeer::COUNT); + } + + foreach($criteria->getGroupByColumns() as $column) + { + $criteria->addSelectColumn($column); + } + + $criteria->addJoin(LogEntryPeer::USER_ID, UserPeer::ID); + + $rs = LogEntryPeer::doSelectRS($criteria, $con); + if ($rs->next()) { + return $rs->getInt(1); + } else { + return 0; + } + } + + + + public static function doSelectJoinUser(Criteria $c, $con = null) + { + $c = clone $c; + + if ($c->getDbName() == Propel::getDefaultDB()) { + $c->setDbName(self::DATABASE_NAME); + } + + LogEntryPeer::addSelectColumns($c); + $startcol = (LogEntryPeer::NUM_COLUMNS - LogEntryPeer::NUM_LAZY_LOAD_COLUMNS) + 1; + UserPeer::addSelectColumns($c); + + $c->addJoin(LogEntryPeer::USER_ID, UserPeer::ID); + $rs = BasePeer::doSelect($c, $con); + $results = array(); + + while($rs->next()) { + + $omClass = LogEntryPeer::getOMClass(); + + $cls = Propel::import($omClass); + $obj1 = new $cls(); + $obj1->hydrate($rs); + + $omClass = UserPeer::getOMClass(); + + $cls = Propel::import($omClass); + $obj2 = new $cls(); + $obj2->hydrate($rs, $startcol); + + $newObject = true; + foreach($results as $temp_obj1) { + $temp_obj2 = $temp_obj1->getUser(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { + $newObject = false; + $temp_obj2->addLogEntry($obj1); break; + } + } + if ($newObject) { + $obj2->initLogEntrys(); + $obj2->addLogEntry($obj1); } + $results[] = $obj1; + } + return $results; + } + + + + public static function doCountJoinAll(Criteria $criteria, $distinct = false, $con = null) + { + $criteria = clone $criteria; + + $criteria->clearSelectColumns()->clearOrderByColumns(); + if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->addSelectColumn(LogEntryPeer::COUNT_DISTINCT); + } else { + $criteria->addSelectColumn(LogEntryPeer::COUNT); + } + + foreach($criteria->getGroupByColumns() as $column) + { + $criteria->addSelectColumn($column); + } + + $criteria->addJoin(LogEntryPeer::USER_ID, UserPeer::ID); + + $rs = LogEntryPeer::doSelectRS($criteria, $con); + if ($rs->next()) { + return $rs->getInt(1); + } else { + return 0; + } + } + + + + public static function doSelectJoinAll(Criteria $c, $con = null) + { + $c = clone $c; + + if ($c->getDbName() == Propel::getDefaultDB()) { + $c->setDbName(self::DATABASE_NAME); + } + + LogEntryPeer::addSelectColumns($c); + $startcol2 = (LogEntryPeer::NUM_COLUMNS - LogEntryPeer::NUM_LAZY_LOAD_COLUMNS) + 1; + + UserPeer::addSelectColumns($c); + $startcol3 = $startcol2 + UserPeer::NUM_COLUMNS; + + $c->addJoin(LogEntryPeer::USER_ID, UserPeer::ID); + + $rs = BasePeer::doSelect($c, $con); + $results = array(); + + while($rs->next()) { + + $omClass = LogEntryPeer::getOMClass(); + + + $cls = Propel::import($omClass); + $obj1 = new $cls(); + $obj1->hydrate($rs); + + + + $omClass = UserPeer::getOMClass(); + + + $cls = Propel::import($omClass); + $obj2 = new $cls(); + $obj2->hydrate($rs, $startcol2); + + $newObject = true; + for ($j=0, $resCount=count($results); $j < $resCount; $j++) { + $temp_obj1 = $results[$j]; + $temp_obj2 = $temp_obj1->getUser(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { + $newObject = false; + $temp_obj2->addLogEntry($obj1); break; + } + } + + if ($newObject) { + $obj2->initLogEntrys(); + $obj2->addLogEntry($obj1); + } + + $results[] = $obj1; + } + return $results; + } + + + public static function getTableMap() + { + return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME); + } + + + public static function getOMClass() + { + return LogEntryPeer::CLASS_DEFAULT; + } + + + public static function doInsert($values, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; } else { + $criteria = $values->buildCriteria(); } + + $criteria->remove(LogEntryPeer::ID); + + $criteria->setDbName(self::DATABASE_NAME); + + try { + $con->begin(); + $pk = BasePeer::doInsert($criteria, $con); + $con->commit(); + } catch(PropelException $e) { + $con->rollback(); + throw $e; + } + + return $pk; + } + + + public static function doUpdate($values, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + $selectCriteria = new Criteria(self::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; + $comparison = $criteria->getComparison(LogEntryPeer::ID); + $selectCriteria->add(LogEntryPeer::ID, $criteria->remove(LogEntryPeer::ID), $comparison); + + } else { $criteria = $values->buildCriteria(); $selectCriteria = $values->buildPkeyCriteria(); } + + $criteria->setDbName(self::DATABASE_NAME); + + return BasePeer::doUpdate($selectCriteria, $criteria, $con); + } + + + public static function doDeleteAll($con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + $affectedRows = 0; try { + $con->begin(); + $affectedRows += BasePeer::doDeleteAll(LogEntryPeer::TABLE_NAME, $con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + + public static function doDelete($values, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(LogEntryPeer::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; } elseif ($values instanceof LogEntry) { + + $criteria = $values->buildPkeyCriteria(); + } else { + $criteria = new Criteria(self::DATABASE_NAME); + $criteria->add(LogEntryPeer::ID, (array) $values, Criteria::IN); + } + + $criteria->setDbName(self::DATABASE_NAME); + + $affectedRows = 0; + try { + $con->begin(); + + $affectedRows += BasePeer::doDelete($criteria, $con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + + public static function doValidate(LogEntry $obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(LogEntryPeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(LogEntryPeer::TABLE_NAME); + + if (! is_array($cols)) { + $cols = array($cols); + } + + foreach($cols as $colName) { + if ($tableMap->containsColumn($colName)) { + $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); + $columns[$colName] = $obj->$get(); + } + } + } else { + + } + + $res = BasePeer::doValidate(LogEntryPeer::DATABASE_NAME, LogEntryPeer::TABLE_NAME, $columns); + if ($res !== true) { + $request = sfContext::getInstance()->getRequest(); + foreach ($res as $failed) { + $col = LogEntryPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME); + $request->setError($col, $failed->getMessage()); + } + } + + return $res; + } + + + public static function retrieveByPK($pk, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + $criteria = new Criteria(LogEntryPeer::DATABASE_NAME); + + $criteria->add(LogEntryPeer::ID, $pk); + + + $v = LogEntryPeer::doSelect($criteria, $con); + + return !empty($v) > 0 ? $v[0] : null; + } + + + public static function retrieveByPKs($pks, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(); + $criteria->add(LogEntryPeer::ID, $pks, Criteria::IN); + $objs = LogEntryPeer::doSelect($criteria, $con); + } + return $objs; + } + +} +if (Propel::isInit()) { + try { + BaseLogEntryPeer::getMapBuilder(); + } catch (Exception $e) { + Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR); + } +} else { + require_once 'lib/model/map/LogEntryMapBuilder.php'; + Propel::registerMapBuilder('lib.model.map.LogEntryMapBuilder'); +} diff --git a/lib/model/om/BaseMailbox.php b/lib/model/om/BaseMailbox.php new file mode 100644 index 0000000..cda4d2f --- /dev/null +++ b/lib/model/om/BaseMailbox.php @@ -0,0 +1,751 @@ +id; + } + + + public function getDomainId() + { + + return $this->domain_id; + } + + + public function getName() + { + + return $this->name; + } + + + public function getPassword() + { + + return $this->password; + } + + + public function getMaxQuota() + { + + return $this->max_quota; + } + + + public function getMaxAddressCount() + { + + return $this->max_address_count; + } + + + public function getLastLogin($format = 'Y-m-d H:i:s') + { + + if ($this->last_login === null || $this->last_login === '') { + return null; + } elseif (!is_int($this->last_login)) { + $ts = strtotime($this->last_login); + if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse value of [last_login] as date/time value: " . var_export($this->last_login, true)); + } + } else { + $ts = $this->last_login; + } + if ($format === null) { + return $ts; + } elseif (strpos($format, '%') !== false) { + return strftime($format, $ts); + } else { + return date($format, $ts); + } + } + + + public function getActive() + { + + return $this->active; + } + + + public function setId($v) + { + + if ($v !== null && !is_int($v) && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = MailboxPeer::ID; + } + + } + + public function setDomainId($v) + { + + if ($v !== null && !is_int($v) && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->domain_id !== $v) { + $this->domain_id = $v; + $this->modifiedColumns[] = MailboxPeer::DOMAIN_ID; + } + + if ($this->aDomain !== null && $this->aDomain->getId() !== $v) { + $this->aDomain = null; + } + + } + + public function setName($v) + { + + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->name !== $v) { + $this->name = $v; + $this->modifiedColumns[] = MailboxPeer::NAME; + } + + } + + public function setPassword($v) + { + + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->password !== $v) { + $this->password = $v; + $this->modifiedColumns[] = MailboxPeer::PASSWORD; + } + + } + + public function setMaxQuota($v) + { + + if ($v !== null && !is_int($v) && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->max_quota !== $v) { + $this->max_quota = $v; + $this->modifiedColumns[] = MailboxPeer::MAX_QUOTA; + } + + } + + public function setMaxAddressCount($v) + { + + if ($v !== null && !is_int($v) && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->max_address_count !== $v) { + $this->max_address_count = $v; + $this->modifiedColumns[] = MailboxPeer::MAX_ADDRESS_COUNT; + } + + } + + public function setLastLogin($v) + { + + if ($v !== null && !is_int($v)) { + $ts = strtotime($v); + if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse date/time value for [last_login] from input: " . var_export($v, true)); + } + } else { + $ts = $v; + } + if ($this->last_login !== $ts) { + $this->last_login = $ts; + $this->modifiedColumns[] = MailboxPeer::LAST_LOGIN; + } + + } + + public function setActive($v) + { + + if ($this->active !== $v || $v === true) { + $this->active = $v; + $this->modifiedColumns[] = MailboxPeer::ACTIVE; + } + + } + + public function hydrate(ResultSet $rs, $startcol = 1) + { + try { + + $this->id = $rs->getInt($startcol + 0); + + $this->domain_id = $rs->getInt($startcol + 1); + + $this->name = $rs->getString($startcol + 2); + + $this->password = $rs->getString($startcol + 3); + + $this->max_quota = $rs->getInt($startcol + 4); + + $this->max_address_count = $rs->getInt($startcol + 5); + + $this->last_login = $rs->getTimestamp($startcol + 6, null); + + $this->active = $rs->getBoolean($startcol + 7); + + $this->resetModified(); + + $this->setNew(false); + + return $startcol + 8; + } catch (Exception $e) { + throw new PropelException("Error populating Mailbox object", $e); + } + } + + + public function delete($con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getConnection(MailboxPeer::DATABASE_NAME); + } + + try { + $con->begin(); + MailboxPeer::doDelete($this, $con); + $this->setDeleted(true); + $con->commit(); + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + + public function save($con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getConnection(MailboxPeer::DATABASE_NAME); + } + + try { + $con->begin(); + $affectedRows = $this->doSave($con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + + protected function doSave($con) + { + $affectedRows = 0; if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + + + if ($this->aDomain !== null) { + if ($this->aDomain->isModified()) { + $affectedRows += $this->aDomain->save($con); + } + $this->setDomain($this->aDomain); + } + + + if ($this->isModified()) { + if ($this->isNew()) { + $pk = MailboxPeer::doInsert($this, $con); + $affectedRows += 1; + $this->setId($pk); + $this->setNew(false); + } else { + $affectedRows += MailboxPeer::doUpdate($this, $con); + } + $this->resetModified(); } + + if ($this->collAddresss !== null) { + foreach($this->collAddresss as $referrerFK) { + if (!$referrerFK->isDeleted()) { + $affectedRows += $referrerFK->save($con); + } + } + } + + $this->alreadyInSave = false; + } + return $affectedRows; + } + + protected $validationFailures = array(); + + + public function getValidationFailures() + { + return $this->validationFailures; + } + + + public function validate($columns = null) + { + $res = $this->doValidate($columns); + if ($res === true) { + $this->validationFailures = array(); + return true; + } else { + $this->validationFailures = $res; + return false; + } + } + + + protected function doValidate($columns = null) + { + if (!$this->alreadyInValidation) { + $this->alreadyInValidation = true; + $retval = null; + + $failureMap = array(); + + + + if ($this->aDomain !== null) { + if (!$this->aDomain->validate($columns)) { + $failureMap = array_merge($failureMap, $this->aDomain->getValidationFailures()); + } + } + + + if (($retval = MailboxPeer::doValidate($this, $columns)) !== true) { + $failureMap = array_merge($failureMap, $retval); + } + + + if ($this->collAddresss !== null) { + foreach($this->collAddresss as $referrerFK) { + if (!$referrerFK->validate($columns)) { + $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); + } + } + } + + + $this->alreadyInValidation = false; + } + + return (!empty($failureMap) ? $failureMap : true); + } + + + public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + { + $pos = MailboxPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + return $this->getByPosition($pos); + } + + + public function getByPosition($pos) + { + switch($pos) { + case 0: + return $this->getId(); + break; + case 1: + return $this->getDomainId(); + break; + case 2: + return $this->getName(); + break; + case 3: + return $this->getPassword(); + break; + case 4: + return $this->getMaxQuota(); + break; + case 5: + return $this->getMaxAddressCount(); + break; + case 6: + return $this->getLastLogin(); + break; + case 7: + return $this->getActive(); + break; + default: + return null; + break; + } } + + + public function toArray($keyType = BasePeer::TYPE_PHPNAME) + { + $keys = MailboxPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getDomainId(), + $keys[2] => $this->getName(), + $keys[3] => $this->getPassword(), + $keys[4] => $this->getMaxQuota(), + $keys[5] => $this->getMaxAddressCount(), + $keys[6] => $this->getLastLogin(), + $keys[7] => $this->getActive(), + ); + return $result; + } + + + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $pos = MailboxPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + return $this->setByPosition($pos, $value); + } + + + public function setByPosition($pos, $value) + { + switch($pos) { + case 0: + $this->setId($value); + break; + case 1: + $this->setDomainId($value); + break; + case 2: + $this->setName($value); + break; + case 3: + $this->setPassword($value); + break; + case 4: + $this->setMaxQuota($value); + break; + case 5: + $this->setMaxAddressCount($value); + break; + case 6: + $this->setLastLogin($value); + break; + case 7: + $this->setActive($value); + break; + } } + + + public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) + { + $keys = MailboxPeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setDomainId($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setName($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setPassword($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setMaxQuota($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setMaxAddressCount($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setLastLogin($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setActive($arr[$keys[7]]); + } + + + public function buildCriteria() + { + $criteria = new Criteria(MailboxPeer::DATABASE_NAME); + + if ($this->isColumnModified(MailboxPeer::ID)) $criteria->add(MailboxPeer::ID, $this->id); + if ($this->isColumnModified(MailboxPeer::DOMAIN_ID)) $criteria->add(MailboxPeer::DOMAIN_ID, $this->domain_id); + if ($this->isColumnModified(MailboxPeer::NAME)) $criteria->add(MailboxPeer::NAME, $this->name); + if ($this->isColumnModified(MailboxPeer::PASSWORD)) $criteria->add(MailboxPeer::PASSWORD, $this->password); + if ($this->isColumnModified(MailboxPeer::MAX_QUOTA)) $criteria->add(MailboxPeer::MAX_QUOTA, $this->max_quota); + if ($this->isColumnModified(MailboxPeer::MAX_ADDRESS_COUNT)) $criteria->add(MailboxPeer::MAX_ADDRESS_COUNT, $this->max_address_count); + if ($this->isColumnModified(MailboxPeer::LAST_LOGIN)) $criteria->add(MailboxPeer::LAST_LOGIN, $this->last_login); + if ($this->isColumnModified(MailboxPeer::ACTIVE)) $criteria->add(MailboxPeer::ACTIVE, $this->active); + + return $criteria; + } + + + public function buildPkeyCriteria() + { + $criteria = new Criteria(MailboxPeer::DATABASE_NAME); + + $criteria->add(MailboxPeer::ID, $this->id); + + return $criteria; + } + + + public function getPrimaryKey() + { + return $this->getId(); + } + + + public function setPrimaryKey($key) + { + $this->setId($key); + } + + + public function copyInto($copyObj, $deepCopy = false) + { + + $copyObj->setDomainId($this->domain_id); + + $copyObj->setName($this->name); + + $copyObj->setPassword($this->password); + + $copyObj->setMaxQuota($this->max_quota); + + $copyObj->setMaxAddressCount($this->max_address_count); + + $copyObj->setLastLogin($this->last_login); + + $copyObj->setActive($this->active); + + + if ($deepCopy) { + $copyObj->setNew(false); + + foreach($this->getAddresss() as $relObj) { + $copyObj->addAddress($relObj->copy($deepCopy)); + } + + } + + $copyObj->setNew(true); + + $copyObj->setId(NULL); + } + + + public function copy($deepCopy = false) + { + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + return $copyObj; + } + + + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new MailboxPeer(); + } + return self::$peer; + } + + + public function setDomain($v) + { + + + if ($v === null) { + $this->setDomainId(NULL); + } else { + $this->setDomainId($v->getId()); + } + + + $this->aDomain = $v; + } + + + + public function getDomain($con = null) + { + include_once 'lib/model/om/BaseDomainPeer.php'; + + if ($this->aDomain === null && ($this->domain_id !== null)) { + + $this->aDomain = DomainPeer::retrieveByPK($this->domain_id, $con); + + + } + return $this->aDomain; + } + + + public function initAddresss() + { + if ($this->collAddresss === null) { + $this->collAddresss = array(); + } + } + + + public function getAddresss($criteria = null, $con = null) + { + include_once 'lib/model/om/BaseAddressPeer.php'; + if ($criteria === null) { + $criteria = new Criteria(); + } + elseif ($criteria instanceof Criteria) + { + $criteria = clone $criteria; + } + + if ($this->collAddresss === null) { + if ($this->isNew()) { + $this->collAddresss = array(); + } else { + + $criteria->add(AddressPeer::MAILBOX_ID, $this->getId()); + + AddressPeer::addSelectColumns($criteria); + $this->collAddresss = AddressPeer::doSelect($criteria, $con); + } + } else { + if (!$this->isNew()) { + + + $criteria->add(AddressPeer::MAILBOX_ID, $this->getId()); + + AddressPeer::addSelectColumns($criteria); + if (!isset($this->lastAddressCriteria) || !$this->lastAddressCriteria->equals($criteria)) { + $this->collAddresss = AddressPeer::doSelect($criteria, $con); + } + } + } + $this->lastAddressCriteria = $criteria; + return $this->collAddresss; + } + + + public function countAddresss($criteria = null, $distinct = false, $con = null) + { + include_once 'lib/model/om/BaseAddressPeer.php'; + if ($criteria === null) { + $criteria = new Criteria(); + } + elseif ($criteria instanceof Criteria) + { + $criteria = clone $criteria; + } + + $criteria->add(AddressPeer::MAILBOX_ID, $this->getId()); + + return AddressPeer::doCount($criteria, $distinct, $con); + } + + + public function addAddress(Address $l) + { + $this->collAddresss[] = $l; + $l->setMailbox($this); + } + + + + public function getAddresssJoinDomain($criteria = null, $con = null) + { + include_once 'lib/model/om/BaseAddressPeer.php'; + if ($criteria === null) { + $criteria = new Criteria(); + } + elseif ($criteria instanceof Criteria) + { + $criteria = clone $criteria; + } + + if ($this->collAddresss === null) { + if ($this->isNew()) { + $this->collAddresss = array(); + } else { + + $criteria->add(AddressPeer::MAILBOX_ID, $this->getId()); + + $this->collAddresss = AddressPeer::doSelectJoinDomain($criteria, $con); + } + } else { + + $criteria->add(AddressPeer::MAILBOX_ID, $this->getId()); + + if (!isset($this->lastAddressCriteria) || !$this->lastAddressCriteria->equals($criteria)) { + $this->collAddresss = AddressPeer::doSelectJoinDomain($criteria, $con); + } + } + $this->lastAddressCriteria = $criteria; + + return $this->collAddresss; + } + +} \ No newline at end of file diff --git a/lib/model/om/BaseMailboxPeer.php b/lib/model/om/BaseMailboxPeer.php new file mode 100644 index 0000000..4a7fd36 --- /dev/null +++ b/lib/model/om/BaseMailboxPeer.php @@ -0,0 +1,579 @@ + array ('Id', 'DomainId', 'Name', 'Password', 'MaxQuota', 'MaxAddressCount', 'LastLogin', 'Active', ), + BasePeer::TYPE_COLNAME => array (MailboxPeer::ID, MailboxPeer::DOMAIN_ID, MailboxPeer::NAME, MailboxPeer::PASSWORD, MailboxPeer::MAX_QUOTA, MailboxPeer::MAX_ADDRESS_COUNT, MailboxPeer::LAST_LOGIN, MailboxPeer::ACTIVE, ), + BasePeer::TYPE_FIELDNAME => array ('id', 'domain_id', 'name', 'password', 'max_quota', 'max_address_count', 'last_login', 'active', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, ) + ); + + + private static $fieldKeys = array ( + BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'DomainId' => 1, 'Name' => 2, 'Password' => 3, 'MaxQuota' => 4, 'MaxAddressCount' => 5, 'LastLogin' => 6, 'Active' => 7, ), + BasePeer::TYPE_COLNAME => array (MailboxPeer::ID => 0, MailboxPeer::DOMAIN_ID => 1, MailboxPeer::NAME => 2, MailboxPeer::PASSWORD => 3, MailboxPeer::MAX_QUOTA => 4, MailboxPeer::MAX_ADDRESS_COUNT => 5, MailboxPeer::LAST_LOGIN => 6, MailboxPeer::ACTIVE => 7, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'domain_id' => 1, 'name' => 2, 'password' => 3, 'max_quota' => 4, 'max_address_count' => 5, 'last_login' => 6, 'active' => 7, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, ) + ); + + + public static function getMapBuilder() + { + include_once 'lib/model/map/MailboxMapBuilder.php'; + return BasePeer::getMapBuilder('lib.model.map.MailboxMapBuilder'); + } + + public static function getPhpNameMap() + { + if (self::$phpNameMap === null) { + $map = MailboxPeer::getTableMap(); + $columns = $map->getColumns(); + $nameMap = array(); + foreach ($columns as $column) { + $nameMap[$column->getPhpName()] = $column->getColumnName(); + } + self::$phpNameMap = $nameMap; + } + return self::$phpNameMap; + } + + static public function translateFieldName($name, $fromType, $toType) + { + $toNames = self::getFieldNames($toType); + $key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null; + if ($key === null) { + throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true)); + } + return $toNames[$key]; + } + + + + static public function getFieldNames($type = BasePeer::TYPE_PHPNAME) + { + if (!array_key_exists($type, self::$fieldNames)) { + throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.'); + } + return self::$fieldNames[$type]; + } + + + public static function alias($alias, $column) + { + return str_replace(MailboxPeer::TABLE_NAME.'.', $alias.'.', $column); + } + + + public static function addSelectColumns(Criteria $criteria) + { + + $criteria->addSelectColumn(MailboxPeer::ID); + + $criteria->addSelectColumn(MailboxPeer::DOMAIN_ID); + + $criteria->addSelectColumn(MailboxPeer::NAME); + + $criteria->addSelectColumn(MailboxPeer::PASSWORD); + + $criteria->addSelectColumn(MailboxPeer::MAX_QUOTA); + + $criteria->addSelectColumn(MailboxPeer::MAX_ADDRESS_COUNT); + + $criteria->addSelectColumn(MailboxPeer::LAST_LOGIN); + + $criteria->addSelectColumn(MailboxPeer::ACTIVE); + + } + + const COUNT = 'COUNT(mailbox.ID)'; + const COUNT_DISTINCT = 'COUNT(DISTINCT mailbox.ID)'; + + + public static function doCount(Criteria $criteria, $distinct = false, $con = null) + { + $criteria = clone $criteria; + + $criteria->clearSelectColumns()->clearOrderByColumns(); + if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->addSelectColumn(MailboxPeer::COUNT_DISTINCT); + } else { + $criteria->addSelectColumn(MailboxPeer::COUNT); + } + + foreach($criteria->getGroupByColumns() as $column) + { + $criteria->addSelectColumn($column); + } + + $rs = MailboxPeer::doSelectRS($criteria, $con); + if ($rs->next()) { + return $rs->getInt(1); + } else { + return 0; + } + } + + public static function doSelectOne(Criteria $criteria, $con = null) + { + $critcopy = clone $criteria; + $critcopy->setLimit(1); + $objects = MailboxPeer::doSelect($critcopy, $con); + if ($objects) { + return $objects[0]; + } + return null; + } + + public static function doSelect(Criteria $criteria, $con = null) + { + return MailboxPeer::populateObjects(MailboxPeer::doSelectRS($criteria, $con)); + } + + public static function doSelectRS(Criteria $criteria, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + if (!$criteria->getSelectColumns()) { + $criteria = clone $criteria; + MailboxPeer::addSelectColumns($criteria); + } + + $criteria->setDbName(self::DATABASE_NAME); + + return BasePeer::doSelect($criteria, $con); + } + + public static function populateObjects(ResultSet $rs) + { + $results = array(); + + $cls = MailboxPeer::getOMClass(); + $cls = Propel::import($cls); + while($rs->next()) { + + $obj = new $cls(); + $obj->hydrate($rs); + $results[] = $obj; + + } + return $results; + } + + + public static function doCountJoinDomain(Criteria $criteria, $distinct = false, $con = null) + { + $criteria = clone $criteria; + + $criteria->clearSelectColumns()->clearOrderByColumns(); + if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->addSelectColumn(MailboxPeer::COUNT_DISTINCT); + } else { + $criteria->addSelectColumn(MailboxPeer::COUNT); + } + + foreach($criteria->getGroupByColumns() as $column) + { + $criteria->addSelectColumn($column); + } + + $criteria->addJoin(MailboxPeer::DOMAIN_ID, DomainPeer::ID); + + $rs = MailboxPeer::doSelectRS($criteria, $con); + if ($rs->next()) { + return $rs->getInt(1); + } else { + return 0; + } + } + + + + public static function doSelectJoinDomain(Criteria $c, $con = null) + { + $c = clone $c; + + if ($c->getDbName() == Propel::getDefaultDB()) { + $c->setDbName(self::DATABASE_NAME); + } + + MailboxPeer::addSelectColumns($c); + $startcol = (MailboxPeer::NUM_COLUMNS - MailboxPeer::NUM_LAZY_LOAD_COLUMNS) + 1; + DomainPeer::addSelectColumns($c); + + $c->addJoin(MailboxPeer::DOMAIN_ID, DomainPeer::ID); + $rs = BasePeer::doSelect($c, $con); + $results = array(); + + while($rs->next()) { + + $omClass = MailboxPeer::getOMClass(); + + $cls = Propel::import($omClass); + $obj1 = new $cls(); + $obj1->hydrate($rs); + + $omClass = DomainPeer::getOMClass(); + + $cls = Propel::import($omClass); + $obj2 = new $cls(); + $obj2->hydrate($rs, $startcol); + + $newObject = true; + foreach($results as $temp_obj1) { + $temp_obj2 = $temp_obj1->getDomain(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { + $newObject = false; + $temp_obj2->addMailbox($obj1); break; + } + } + if ($newObject) { + $obj2->initMailboxs(); + $obj2->addMailbox($obj1); } + $results[] = $obj1; + } + return $results; + } + + + + public static function doCountJoinAll(Criteria $criteria, $distinct = false, $con = null) + { + $criteria = clone $criteria; + + $criteria->clearSelectColumns()->clearOrderByColumns(); + if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->addSelectColumn(MailboxPeer::COUNT_DISTINCT); + } else { + $criteria->addSelectColumn(MailboxPeer::COUNT); + } + + foreach($criteria->getGroupByColumns() as $column) + { + $criteria->addSelectColumn($column); + } + + $criteria->addJoin(MailboxPeer::DOMAIN_ID, DomainPeer::ID); + + $rs = MailboxPeer::doSelectRS($criteria, $con); + if ($rs->next()) { + return $rs->getInt(1); + } else { + return 0; + } + } + + + + public static function doSelectJoinAll(Criteria $c, $con = null) + { + $c = clone $c; + + if ($c->getDbName() == Propel::getDefaultDB()) { + $c->setDbName(self::DATABASE_NAME); + } + + MailboxPeer::addSelectColumns($c); + $startcol2 = (MailboxPeer::NUM_COLUMNS - MailboxPeer::NUM_LAZY_LOAD_COLUMNS) + 1; + + DomainPeer::addSelectColumns($c); + $startcol3 = $startcol2 + DomainPeer::NUM_COLUMNS; + + $c->addJoin(MailboxPeer::DOMAIN_ID, DomainPeer::ID); + + $rs = BasePeer::doSelect($c, $con); + $results = array(); + + while($rs->next()) { + + $omClass = MailboxPeer::getOMClass(); + + + $cls = Propel::import($omClass); + $obj1 = new $cls(); + $obj1->hydrate($rs); + + + + $omClass = DomainPeer::getOMClass(); + + + $cls = Propel::import($omClass); + $obj2 = new $cls(); + $obj2->hydrate($rs, $startcol2); + + $newObject = true; + for ($j=0, $resCount=count($results); $j < $resCount; $j++) { + $temp_obj1 = $results[$j]; + $temp_obj2 = $temp_obj1->getDomain(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { + $newObject = false; + $temp_obj2->addMailbox($obj1); break; + } + } + + if ($newObject) { + $obj2->initMailboxs(); + $obj2->addMailbox($obj1); + } + + $results[] = $obj1; + } + return $results; + } + + + public static function getTableMap() + { + return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME); + } + + + public static function getOMClass() + { + return MailboxPeer::CLASS_DEFAULT; + } + + + public static function doInsert($values, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; } else { + $criteria = $values->buildCriteria(); } + + $criteria->remove(MailboxPeer::ID); + + $criteria->setDbName(self::DATABASE_NAME); + + try { + $con->begin(); + $pk = BasePeer::doInsert($criteria, $con); + $con->commit(); + } catch(PropelException $e) { + $con->rollback(); + throw $e; + } + + return $pk; + } + + + public static function doUpdate($values, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + $selectCriteria = new Criteria(self::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; + $comparison = $criteria->getComparison(MailboxPeer::ID); + $selectCriteria->add(MailboxPeer::ID, $criteria->remove(MailboxPeer::ID), $comparison); + + } else { $criteria = $values->buildCriteria(); $selectCriteria = $values->buildPkeyCriteria(); } + + $criteria->setDbName(self::DATABASE_NAME); + + return BasePeer::doUpdate($selectCriteria, $criteria, $con); + } + + + public static function doDeleteAll($con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + $affectedRows = 0; try { + $con->begin(); + $affectedRows += MailboxPeer::doOnDeleteCascade(new Criteria(), $con); + $affectedRows += BasePeer::doDeleteAll(MailboxPeer::TABLE_NAME, $con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + + public static function doDelete($values, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(MailboxPeer::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; } elseif ($values instanceof Mailbox) { + + $criteria = $values->buildPkeyCriteria(); + } else { + $criteria = new Criteria(self::DATABASE_NAME); + $criteria->add(MailboxPeer::ID, (array) $values, Criteria::IN); + } + + $criteria->setDbName(self::DATABASE_NAME); + + $affectedRows = 0; + try { + $con->begin(); + $affectedRows += MailboxPeer::doOnDeleteCascade($criteria, $con); + $affectedRows += BasePeer::doDelete($criteria, $con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + + protected static function doOnDeleteCascade(Criteria $criteria, Connection $con) + { + $affectedRows = 0; + + $objects = MailboxPeer::doSelect($criteria, $con); + foreach($objects as $obj) { + + + include_once 'lib/model/Address.php'; + + $c = new Criteria(); + + $c->add(AddressPeer::MAILBOX_ID, $obj->getId()); + $affectedRows += AddressPeer::doDelete($c, $con); + } + return $affectedRows; + } + + + public static function doValidate(Mailbox $obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(MailboxPeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(MailboxPeer::TABLE_NAME); + + if (! is_array($cols)) { + $cols = array($cols); + } + + foreach($cols as $colName) { + if ($tableMap->containsColumn($colName)) { + $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); + $columns[$colName] = $obj->$get(); + } + } + } else { + + } + + $res = BasePeer::doValidate(MailboxPeer::DATABASE_NAME, MailboxPeer::TABLE_NAME, $columns); + if ($res !== true) { + $request = sfContext::getInstance()->getRequest(); + foreach ($res as $failed) { + $col = MailboxPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME); + $request->setError($col, $failed->getMessage()); + } + } + + return $res; + } + + + public static function retrieveByPK($pk, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + $criteria = new Criteria(MailboxPeer::DATABASE_NAME); + + $criteria->add(MailboxPeer::ID, $pk); + + + $v = MailboxPeer::doSelect($criteria, $con); + + return !empty($v) > 0 ? $v[0] : null; + } + + + public static function retrieveByPKs($pks, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(); + $criteria->add(MailboxPeer::ID, $pks, Criteria::IN); + $objs = MailboxPeer::doSelect($criteria, $con); + } + return $objs; + } + +} +if (Propel::isInit()) { + try { + BaseMailboxPeer::getMapBuilder(); + } catch (Exception $e) { + Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR); + } +} else { + require_once 'lib/model/map/MailboxMapBuilder.php'; + Propel::registerMapBuilder('lib.model.map.MailboxMapBuilder'); +} diff --git a/lib/model/om/BaseRole.php b/lib/model/om/BaseRole.php new file mode 100644 index 0000000..7936e1e --- /dev/null +++ b/lib/model/om/BaseRole.php @@ -0,0 +1,493 @@ +id; + } + + + public function getName() + { + + return $this->name; + } + + + public function getCredentials() + { + + return $this->credentials; + } + + + public function setId($v) + { + + if ($v !== null && !is_int($v) && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = RolePeer::ID; + } + + } + + public function setName($v) + { + + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->name !== $v) { + $this->name = $v; + $this->modifiedColumns[] = RolePeer::NAME; + } + + } + + public function setCredentials($v) + { + + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->credentials !== $v) { + $this->credentials = $v; + $this->modifiedColumns[] = RolePeer::CREDENTIALS; + } + + } + + public function hydrate(ResultSet $rs, $startcol = 1) + { + try { + + $this->id = $rs->getInt($startcol + 0); + + $this->name = $rs->getString($startcol + 1); + + $this->credentials = $rs->getString($startcol + 2); + + $this->resetModified(); + + $this->setNew(false); + + return $startcol + 3; + } catch (Exception $e) { + throw new PropelException("Error populating Role object", $e); + } + } + + + public function delete($con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getConnection(RolePeer::DATABASE_NAME); + } + + try { + $con->begin(); + RolePeer::doDelete($this, $con); + $this->setDeleted(true); + $con->commit(); + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + + public function save($con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getConnection(RolePeer::DATABASE_NAME); + } + + try { + $con->begin(); + $affectedRows = $this->doSave($con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + + protected function doSave($con) + { + $affectedRows = 0; if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + + if ($this->isModified()) { + if ($this->isNew()) { + $pk = RolePeer::doInsert($this, $con); + $affectedRows += 1; + $this->setId($pk); + $this->setNew(false); + } else { + $affectedRows += RolePeer::doUpdate($this, $con); + } + $this->resetModified(); } + + if ($this->collUsers !== null) { + foreach($this->collUsers as $referrerFK) { + if (!$referrerFK->isDeleted()) { + $affectedRows += $referrerFK->save($con); + } + } + } + + $this->alreadyInSave = false; + } + return $affectedRows; + } + + protected $validationFailures = array(); + + + public function getValidationFailures() + { + return $this->validationFailures; + } + + + public function validate($columns = null) + { + $res = $this->doValidate($columns); + if ($res === true) { + $this->validationFailures = array(); + return true; + } else { + $this->validationFailures = $res; + return false; + } + } + + + protected function doValidate($columns = null) + { + if (!$this->alreadyInValidation) { + $this->alreadyInValidation = true; + $retval = null; + + $failureMap = array(); + + + if (($retval = RolePeer::doValidate($this, $columns)) !== true) { + $failureMap = array_merge($failureMap, $retval); + } + + + if ($this->collUsers !== null) { + foreach($this->collUsers as $referrerFK) { + if (!$referrerFK->validate($columns)) { + $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); + } + } + } + + + $this->alreadyInValidation = false; + } + + return (!empty($failureMap) ? $failureMap : true); + } + + + public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + { + $pos = RolePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + return $this->getByPosition($pos); + } + + + public function getByPosition($pos) + { + switch($pos) { + case 0: + return $this->getId(); + break; + case 1: + return $this->getName(); + break; + case 2: + return $this->getCredentials(); + break; + default: + return null; + break; + } } + + + public function toArray($keyType = BasePeer::TYPE_PHPNAME) + { + $keys = RolePeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getName(), + $keys[2] => $this->getCredentials(), + ); + return $result; + } + + + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $pos = RolePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + return $this->setByPosition($pos, $value); + } + + + public function setByPosition($pos, $value) + { + switch($pos) { + case 0: + $this->setId($value); + break; + case 1: + $this->setName($value); + break; + case 2: + $this->setCredentials($value); + break; + } } + + + public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) + { + $keys = RolePeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setName($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setCredentials($arr[$keys[2]]); + } + + + public function buildCriteria() + { + $criteria = new Criteria(RolePeer::DATABASE_NAME); + + if ($this->isColumnModified(RolePeer::ID)) $criteria->add(RolePeer::ID, $this->id); + if ($this->isColumnModified(RolePeer::NAME)) $criteria->add(RolePeer::NAME, $this->name); + if ($this->isColumnModified(RolePeer::CREDENTIALS)) $criteria->add(RolePeer::CREDENTIALS, $this->credentials); + + return $criteria; + } + + + public function buildPkeyCriteria() + { + $criteria = new Criteria(RolePeer::DATABASE_NAME); + + $criteria->add(RolePeer::ID, $this->id); + + return $criteria; + } + + + public function getPrimaryKey() + { + return $this->getId(); + } + + + public function setPrimaryKey($key) + { + $this->setId($key); + } + + + public function copyInto($copyObj, $deepCopy = false) + { + + $copyObj->setName($this->name); + + $copyObj->setCredentials($this->credentials); + + + if ($deepCopy) { + $copyObj->setNew(false); + + foreach($this->getUsers() as $relObj) { + $copyObj->addUser($relObj->copy($deepCopy)); + } + + } + + $copyObj->setNew(true); + + $copyObj->setId(NULL); + } + + + public function copy($deepCopy = false) + { + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + return $copyObj; + } + + + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new RolePeer(); + } + return self::$peer; + } + + + public function initUsers() + { + if ($this->collUsers === null) { + $this->collUsers = array(); + } + } + + + public function getUsers($criteria = null, $con = null) + { + include_once 'lib/model/om/BaseUserPeer.php'; + if ($criteria === null) { + $criteria = new Criteria(); + } + elseif ($criteria instanceof Criteria) + { + $criteria = clone $criteria; + } + + if ($this->collUsers === null) { + if ($this->isNew()) { + $this->collUsers = array(); + } else { + + $criteria->add(UserPeer::ROLE_ID, $this->getId()); + + UserPeer::addSelectColumns($criteria); + $this->collUsers = UserPeer::doSelect($criteria, $con); + } + } else { + if (!$this->isNew()) { + + + $criteria->add(UserPeer::ROLE_ID, $this->getId()); + + UserPeer::addSelectColumns($criteria); + if (!isset($this->lastUserCriteria) || !$this->lastUserCriteria->equals($criteria)) { + $this->collUsers = UserPeer::doSelect($criteria, $con); + } + } + } + $this->lastUserCriteria = $criteria; + return $this->collUsers; + } + + + public function countUsers($criteria = null, $distinct = false, $con = null) + { + include_once 'lib/model/om/BaseUserPeer.php'; + if ($criteria === null) { + $criteria = new Criteria(); + } + elseif ($criteria instanceof Criteria) + { + $criteria = clone $criteria; + } + + $criteria->add(UserPeer::ROLE_ID, $this->getId()); + + return UserPeer::doCount($criteria, $distinct, $con); + } + + + public function addUser(User $l) + { + $this->collUsers[] = $l; + $l->setRole($this); + } + + + + public function getUsersJoinUserRelatedByParentUserId($criteria = null, $con = null) + { + include_once 'lib/model/om/BaseUserPeer.php'; + if ($criteria === null) { + $criteria = new Criteria(); + } + elseif ($criteria instanceof Criteria) + { + $criteria = clone $criteria; + } + + if ($this->collUsers === null) { + if ($this->isNew()) { + $this->collUsers = array(); + } else { + + $criteria->add(UserPeer::ROLE_ID, $this->getId()); + + $this->collUsers = UserPeer::doSelectJoinUserRelatedByParentUserId($criteria, $con); + } + } else { + + $criteria->add(UserPeer::ROLE_ID, $this->getId()); + + if (!isset($this->lastUserCriteria) || !$this->lastUserCriteria->equals($criteria)) { + $this->collUsers = UserPeer::doSelectJoinUserRelatedByParentUserId($criteria, $con); + } + } + $this->lastUserCriteria = $criteria; + + return $this->collUsers; + } + +} \ No newline at end of file diff --git a/lib/model/om/BaseRolePeer.php b/lib/model/om/BaseRolePeer.php new file mode 100644 index 0000000..85130fb --- /dev/null +++ b/lib/model/om/BaseRolePeer.php @@ -0,0 +1,373 @@ + array ('Id', 'Name', 'Credentials', ), + BasePeer::TYPE_COLNAME => array (RolePeer::ID, RolePeer::NAME, RolePeer::CREDENTIALS, ), + BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'credentials', ), + BasePeer::TYPE_NUM => array (0, 1, 2, ) + ); + + + private static $fieldKeys = array ( + BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Name' => 1, 'Credentials' => 2, ), + BasePeer::TYPE_COLNAME => array (RolePeer::ID => 0, RolePeer::NAME => 1, RolePeer::CREDENTIALS => 2, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'credentials' => 2, ), + BasePeer::TYPE_NUM => array (0, 1, 2, ) + ); + + + public static function getMapBuilder() + { + include_once 'lib/model/map/RoleMapBuilder.php'; + return BasePeer::getMapBuilder('lib.model.map.RoleMapBuilder'); + } + + public static function getPhpNameMap() + { + if (self::$phpNameMap === null) { + $map = RolePeer::getTableMap(); + $columns = $map->getColumns(); + $nameMap = array(); + foreach ($columns as $column) { + $nameMap[$column->getPhpName()] = $column->getColumnName(); + } + self::$phpNameMap = $nameMap; + } + return self::$phpNameMap; + } + + static public function translateFieldName($name, $fromType, $toType) + { + $toNames = self::getFieldNames($toType); + $key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null; + if ($key === null) { + throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true)); + } + return $toNames[$key]; + } + + + + static public function getFieldNames($type = BasePeer::TYPE_PHPNAME) + { + if (!array_key_exists($type, self::$fieldNames)) { + throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.'); + } + return self::$fieldNames[$type]; + } + + + public static function alias($alias, $column) + { + return str_replace(RolePeer::TABLE_NAME.'.', $alias.'.', $column); + } + + + public static function addSelectColumns(Criteria $criteria) + { + + $criteria->addSelectColumn(RolePeer::ID); + + $criteria->addSelectColumn(RolePeer::NAME); + + $criteria->addSelectColumn(RolePeer::CREDENTIALS); + + } + + const COUNT = 'COUNT(role.ID)'; + const COUNT_DISTINCT = 'COUNT(DISTINCT role.ID)'; + + + public static function doCount(Criteria $criteria, $distinct = false, $con = null) + { + $criteria = clone $criteria; + + $criteria->clearSelectColumns()->clearOrderByColumns(); + if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->addSelectColumn(RolePeer::COUNT_DISTINCT); + } else { + $criteria->addSelectColumn(RolePeer::COUNT); + } + + foreach($criteria->getGroupByColumns() as $column) + { + $criteria->addSelectColumn($column); + } + + $rs = RolePeer::doSelectRS($criteria, $con); + if ($rs->next()) { + return $rs->getInt(1); + } else { + return 0; + } + } + + public static function doSelectOne(Criteria $criteria, $con = null) + { + $critcopy = clone $criteria; + $critcopy->setLimit(1); + $objects = RolePeer::doSelect($critcopy, $con); + if ($objects) { + return $objects[0]; + } + return null; + } + + public static function doSelect(Criteria $criteria, $con = null) + { + return RolePeer::populateObjects(RolePeer::doSelectRS($criteria, $con)); + } + + public static function doSelectRS(Criteria $criteria, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + if (!$criteria->getSelectColumns()) { + $criteria = clone $criteria; + RolePeer::addSelectColumns($criteria); + } + + $criteria->setDbName(self::DATABASE_NAME); + + return BasePeer::doSelect($criteria, $con); + } + + public static function populateObjects(ResultSet $rs) + { + $results = array(); + + $cls = RolePeer::getOMClass(); + $cls = Propel::import($cls); + while($rs->next()) { + + $obj = new $cls(); + $obj->hydrate($rs); + $results[] = $obj; + + } + return $results; + } + + public static function getTableMap() + { + return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME); + } + + + public static function getOMClass() + { + return RolePeer::CLASS_DEFAULT; + } + + + public static function doInsert($values, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; } else { + $criteria = $values->buildCriteria(); } + + $criteria->remove(RolePeer::ID); + + $criteria->setDbName(self::DATABASE_NAME); + + try { + $con->begin(); + $pk = BasePeer::doInsert($criteria, $con); + $con->commit(); + } catch(PropelException $e) { + $con->rollback(); + throw $e; + } + + return $pk; + } + + + public static function doUpdate($values, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + $selectCriteria = new Criteria(self::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; + $comparison = $criteria->getComparison(RolePeer::ID); + $selectCriteria->add(RolePeer::ID, $criteria->remove(RolePeer::ID), $comparison); + + } else { $criteria = $values->buildCriteria(); $selectCriteria = $values->buildPkeyCriteria(); } + + $criteria->setDbName(self::DATABASE_NAME); + + return BasePeer::doUpdate($selectCriteria, $criteria, $con); + } + + + public static function doDeleteAll($con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + $affectedRows = 0; try { + $con->begin(); + $affectedRows += BasePeer::doDeleteAll(RolePeer::TABLE_NAME, $con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + + public static function doDelete($values, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(RolePeer::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; } elseif ($values instanceof Role) { + + $criteria = $values->buildPkeyCriteria(); + } else { + $criteria = new Criteria(self::DATABASE_NAME); + $criteria->add(RolePeer::ID, (array) $values, Criteria::IN); + } + + $criteria->setDbName(self::DATABASE_NAME); + + $affectedRows = 0; + try { + $con->begin(); + + $affectedRows += BasePeer::doDelete($criteria, $con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + + public static function doValidate(Role $obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(RolePeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(RolePeer::TABLE_NAME); + + if (! is_array($cols)) { + $cols = array($cols); + } + + foreach($cols as $colName) { + if ($tableMap->containsColumn($colName)) { + $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); + $columns[$colName] = $obj->$get(); + } + } + } else { + + } + + $res = BasePeer::doValidate(RolePeer::DATABASE_NAME, RolePeer::TABLE_NAME, $columns); + if ($res !== true) { + $request = sfContext::getInstance()->getRequest(); + foreach ($res as $failed) { + $col = RolePeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME); + $request->setError($col, $failed->getMessage()); + } + } + + return $res; + } + + + public static function retrieveByPK($pk, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + $criteria = new Criteria(RolePeer::DATABASE_NAME); + + $criteria->add(RolePeer::ID, $pk); + + + $v = RolePeer::doSelect($criteria, $con); + + return !empty($v) > 0 ? $v[0] : null; + } + + + public static function retrieveByPKs($pks, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(); + $criteria->add(RolePeer::ID, $pks, Criteria::IN); + $objs = RolePeer::doSelect($criteria, $con); + } + return $objs; + } + +} +if (Propel::isInit()) { + try { + BaseRolePeer::getMapBuilder(); + } catch (Exception $e) { + Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR); + } +} else { + require_once 'lib/model/map/RoleMapBuilder.php'; + Propel::registerMapBuilder('lib.model.map.RoleMapBuilder'); +} diff --git a/lib/model/om/BaseUser.php b/lib/model/om/BaseUser.php new file mode 100644 index 0000000..c9588be --- /dev/null +++ b/lib/model/om/BaseUser.php @@ -0,0 +1,1261 @@ +id; + } + + + public function getParentUserId() + { + + return $this->parent_user_id; + } + + + public function getNickname() + { + + return $this->nickname; + } + + + public function getFirstName() + { + + return $this->first_name; + } + + + public function getLastName() + { + + return $this->last_name; + } + + + public function getEmail() + { + + return $this->email; + } + + + public function getSha1Password() + { + + return $this->sha1_password; + } + + + public function getSalt() + { + + return $this->salt; + } + + + public function getRoleId() + { + + return $this->role_id; + } + + + public function getLastLogin($format = 'Y-m-d H:i:s') + { + + if ($this->last_login === null || $this->last_login === '') { + return null; + } elseif (!is_int($this->last_login)) { + $ts = strtotime($this->last_login); + if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse value of [last_login] as date/time value: " . var_export($this->last_login, true)); + } + } else { + $ts = $this->last_login; + } + if ($format === null) { + return $ts; + } elseif (strpos($format, '%') !== false) { + return strftime($format, $ts); + } else { + return date($format, $ts); + } + } + + + public function getCreatedAt($format = 'Y-m-d H:i:s') + { + + if ($this->created_at === null || $this->created_at === '') { + return null; + } elseif (!is_int($this->created_at)) { + $ts = strtotime($this->created_at); + if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse value of [created_at] as date/time value: " . var_export($this->created_at, true)); + } + } else { + $ts = $this->created_at; + } + if ($format === null) { + return $ts; + } elseif (strpos($format, '%') !== false) { + return strftime($format, $ts); + } else { + return date($format, $ts); + } + } + + + public function setId($v) + { + + if ($v !== null && !is_int($v) && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = UserPeer::ID; + } + + } + + public function setParentUserId($v) + { + + if ($v !== null && !is_int($v) && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->parent_user_id !== $v || $v === -1) { + $this->parent_user_id = $v; + $this->modifiedColumns[] = UserPeer::PARENT_USER_ID; + } + + if ($this->aUserRelatedByParentUserId !== null && $this->aUserRelatedByParentUserId->getId() !== $v) { + $this->aUserRelatedByParentUserId = null; + } + + } + + public function setNickname($v) + { + + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->nickname !== $v) { + $this->nickname = $v; + $this->modifiedColumns[] = UserPeer::NICKNAME; + } + + } + + public function setFirstName($v) + { + + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->first_name !== $v) { + $this->first_name = $v; + $this->modifiedColumns[] = UserPeer::FIRST_NAME; + } + + } + + public function setLastName($v) + { + + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->last_name !== $v) { + $this->last_name = $v; + $this->modifiedColumns[] = UserPeer::LAST_NAME; + } + + } + + public function setEmail($v) + { + + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->email !== $v) { + $this->email = $v; + $this->modifiedColumns[] = UserPeer::EMAIL; + } + + } + + public function setSha1Password($v) + { + + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->sha1_password !== $v) { + $this->sha1_password = $v; + $this->modifiedColumns[] = UserPeer::SHA1_PASSWORD; + } + + } + + public function setSalt($v) + { + + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->salt !== $v) { + $this->salt = $v; + $this->modifiedColumns[] = UserPeer::SALT; + } + + } + + public function setRoleId($v) + { + + if ($v !== null && !is_int($v) && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->role_id !== $v) { + $this->role_id = $v; + $this->modifiedColumns[] = UserPeer::ROLE_ID; + } + + if ($this->aRole !== null && $this->aRole->getId() !== $v) { + $this->aRole = null; + } + + } + + public function setLastLogin($v) + { + + if ($v !== null && !is_int($v)) { + $ts = strtotime($v); + if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse date/time value for [last_login] from input: " . var_export($v, true)); + } + } else { + $ts = $v; + } + if ($this->last_login !== $ts) { + $this->last_login = $ts; + $this->modifiedColumns[] = UserPeer::LAST_LOGIN; + } + + } + + public function setCreatedAt($v) + { + + if ($v !== null && !is_int($v)) { + $ts = strtotime($v); + if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse date/time value for [created_at] from input: " . var_export($v, true)); + } + } else { + $ts = $v; + } + if ($this->created_at !== $ts) { + $this->created_at = $ts; + $this->modifiedColumns[] = UserPeer::CREATED_AT; + } + + } + + public function hydrate(ResultSet $rs, $startcol = 1) + { + try { + + $this->id = $rs->getInt($startcol + 0); + + $this->parent_user_id = $rs->getInt($startcol + 1); + + $this->nickname = $rs->getString($startcol + 2); + + $this->first_name = $rs->getString($startcol + 3); + + $this->last_name = $rs->getString($startcol + 4); + + $this->email = $rs->getString($startcol + 5); + + $this->sha1_password = $rs->getString($startcol + 6); + + $this->salt = $rs->getString($startcol + 7); + + $this->role_id = $rs->getInt($startcol + 8); + + $this->last_login = $rs->getTimestamp($startcol + 9, null); + + $this->created_at = $rs->getTimestamp($startcol + 10, null); + + $this->resetModified(); + + $this->setNew(false); + + return $startcol + 11; + } catch (Exception $e) { + throw new PropelException("Error populating User object", $e); + } + } + + + public function delete($con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getConnection(UserPeer::DATABASE_NAME); + } + + try { + $con->begin(); + UserPeer::doDelete($this, $con); + $this->setDeleted(true); + $con->commit(); + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + + public function save($con = null) + { + if ($this->isNew() && !$this->isColumnModified(UserPeer::CREATED_AT)) + { + $this->setCreatedAt(time()); + } + + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getConnection(UserPeer::DATABASE_NAME); + } + + try { + $con->begin(); + $affectedRows = $this->doSave($con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + + protected function doSave($con) + { + $affectedRows = 0; if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + + + if ($this->aUserRelatedByParentUserId !== null) { + if ($this->aUserRelatedByParentUserId->isModified()) { + $affectedRows += $this->aUserRelatedByParentUserId->save($con); + } + $this->setUserRelatedByParentUserId($this->aUserRelatedByParentUserId); + } + + if ($this->aRole !== null) { + if ($this->aRole->isModified()) { + $affectedRows += $this->aRole->save($con); + } + $this->setRole($this->aRole); + } + + + if ($this->isModified()) { + if ($this->isNew()) { + $pk = UserPeer::doInsert($this, $con); + $affectedRows += 1; + $this->setId($pk); + $this->setNew(false); + } else { + $affectedRows += UserPeer::doUpdate($this, $con); + } + $this->resetModified(); } + + if ($this->collUsersRelatedByParentUserId !== null) { + foreach($this->collUsersRelatedByParentUserId as $referrerFK) { + if (!$referrerFK->isDeleted()) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->collDomainPermissions !== null) { + foreach($this->collDomainPermissions as $referrerFK) { + if (!$referrerFK->isDeleted()) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->collDomains !== null) { + foreach($this->collDomains as $referrerFK) { + if (!$referrerFK->isDeleted()) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->collLogEntrys !== null) { + foreach($this->collLogEntrys as $referrerFK) { + if (!$referrerFK->isDeleted()) { + $affectedRows += $referrerFK->save($con); + } + } + } + + $this->alreadyInSave = false; + } + return $affectedRows; + } + + protected $validationFailures = array(); + + + public function getValidationFailures() + { + return $this->validationFailures; + } + + + public function validate($columns = null) + { + $res = $this->doValidate($columns); + if ($res === true) { + $this->validationFailures = array(); + return true; + } else { + $this->validationFailures = $res; + return false; + } + } + + + protected function doValidate($columns = null) + { + if (!$this->alreadyInValidation) { + $this->alreadyInValidation = true; + $retval = null; + + $failureMap = array(); + + + + if ($this->aUserRelatedByParentUserId !== null) { + if (!$this->aUserRelatedByParentUserId->validate($columns)) { + $failureMap = array_merge($failureMap, $this->aUserRelatedByParentUserId->getValidationFailures()); + } + } + + if ($this->aRole !== null) { + if (!$this->aRole->validate($columns)) { + $failureMap = array_merge($failureMap, $this->aRole->getValidationFailures()); + } + } + + + if (($retval = UserPeer::doValidate($this, $columns)) !== true) { + $failureMap = array_merge($failureMap, $retval); + } + + + if ($this->collDomainPermissions !== null) { + foreach($this->collDomainPermissions as $referrerFK) { + if (!$referrerFK->validate($columns)) { + $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); + } + } + } + + if ($this->collDomains !== null) { + foreach($this->collDomains as $referrerFK) { + if (!$referrerFK->validate($columns)) { + $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); + } + } + } + + if ($this->collLogEntrys !== null) { + foreach($this->collLogEntrys as $referrerFK) { + if (!$referrerFK->validate($columns)) { + $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); + } + } + } + + + $this->alreadyInValidation = false; + } + + return (!empty($failureMap) ? $failureMap : true); + } + + + public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + { + $pos = UserPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + return $this->getByPosition($pos); + } + + + public function getByPosition($pos) + { + switch($pos) { + case 0: + return $this->getId(); + break; + case 1: + return $this->getParentUserId(); + break; + case 2: + return $this->getNickname(); + break; + case 3: + return $this->getFirstName(); + break; + case 4: + return $this->getLastName(); + break; + case 5: + return $this->getEmail(); + break; + case 6: + return $this->getSha1Password(); + break; + case 7: + return $this->getSalt(); + break; + case 8: + return $this->getRoleId(); + break; + case 9: + return $this->getLastLogin(); + break; + case 10: + return $this->getCreatedAt(); + break; + default: + return null; + break; + } } + + + public function toArray($keyType = BasePeer::TYPE_PHPNAME) + { + $keys = UserPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getParentUserId(), + $keys[2] => $this->getNickname(), + $keys[3] => $this->getFirstName(), + $keys[4] => $this->getLastName(), + $keys[5] => $this->getEmail(), + $keys[6] => $this->getSha1Password(), + $keys[7] => $this->getSalt(), + $keys[8] => $this->getRoleId(), + $keys[9] => $this->getLastLogin(), + $keys[10] => $this->getCreatedAt(), + ); + return $result; + } + + + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $pos = UserPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + return $this->setByPosition($pos, $value); + } + + + public function setByPosition($pos, $value) + { + switch($pos) { + case 0: + $this->setId($value); + break; + case 1: + $this->setParentUserId($value); + break; + case 2: + $this->setNickname($value); + break; + case 3: + $this->setFirstName($value); + break; + case 4: + $this->setLastName($value); + break; + case 5: + $this->setEmail($value); + break; + case 6: + $this->setSha1Password($value); + break; + case 7: + $this->setSalt($value); + break; + case 8: + $this->setRoleId($value); + break; + case 9: + $this->setLastLogin($value); + break; + case 10: + $this->setCreatedAt($value); + break; + } } + + + public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) + { + $keys = UserPeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setParentUserId($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setNickname($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setFirstName($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setLastName($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setEmail($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setSha1Password($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setSalt($arr[$keys[7]]); + if (array_key_exists($keys[8], $arr)) $this->setRoleId($arr[$keys[8]]); + if (array_key_exists($keys[9], $arr)) $this->setLastLogin($arr[$keys[9]]); + if (array_key_exists($keys[10], $arr)) $this->setCreatedAt($arr[$keys[10]]); + } + + + public function buildCriteria() + { + $criteria = new Criteria(UserPeer::DATABASE_NAME); + + if ($this->isColumnModified(UserPeer::ID)) $criteria->add(UserPeer::ID, $this->id); + if ($this->isColumnModified(UserPeer::PARENT_USER_ID)) $criteria->add(UserPeer::PARENT_USER_ID, $this->parent_user_id); + if ($this->isColumnModified(UserPeer::NICKNAME)) $criteria->add(UserPeer::NICKNAME, $this->nickname); + if ($this->isColumnModified(UserPeer::FIRST_NAME)) $criteria->add(UserPeer::FIRST_NAME, $this->first_name); + if ($this->isColumnModified(UserPeer::LAST_NAME)) $criteria->add(UserPeer::LAST_NAME, $this->last_name); + if ($this->isColumnModified(UserPeer::EMAIL)) $criteria->add(UserPeer::EMAIL, $this->email); + if ($this->isColumnModified(UserPeer::SHA1_PASSWORD)) $criteria->add(UserPeer::SHA1_PASSWORD, $this->sha1_password); + if ($this->isColumnModified(UserPeer::SALT)) $criteria->add(UserPeer::SALT, $this->salt); + if ($this->isColumnModified(UserPeer::ROLE_ID)) $criteria->add(UserPeer::ROLE_ID, $this->role_id); + if ($this->isColumnModified(UserPeer::LAST_LOGIN)) $criteria->add(UserPeer::LAST_LOGIN, $this->last_login); + if ($this->isColumnModified(UserPeer::CREATED_AT)) $criteria->add(UserPeer::CREATED_AT, $this->created_at); + + return $criteria; + } + + + public function buildPkeyCriteria() + { + $criteria = new Criteria(UserPeer::DATABASE_NAME); + + $criteria->add(UserPeer::ID, $this->id); + + return $criteria; + } + + + public function getPrimaryKey() + { + return $this->getId(); + } + + + public function setPrimaryKey($key) + { + $this->setId($key); + } + + + public function copyInto($copyObj, $deepCopy = false) + { + + $copyObj->setParentUserId($this->parent_user_id); + + $copyObj->setNickname($this->nickname); + + $copyObj->setFirstName($this->first_name); + + $copyObj->setLastName($this->last_name); + + $copyObj->setEmail($this->email); + + $copyObj->setSha1Password($this->sha1_password); + + $copyObj->setSalt($this->salt); + + $copyObj->setRoleId($this->role_id); + + $copyObj->setLastLogin($this->last_login); + + $copyObj->setCreatedAt($this->created_at); + + + if ($deepCopy) { + $copyObj->setNew(false); + + foreach($this->getUsersRelatedByParentUserId() as $relObj) { + if($this->getPrimaryKey() === $relObj->getPrimaryKey()) { + continue; + } + + $copyObj->addUserRelatedByParentUserId($relObj->copy($deepCopy)); + } + + foreach($this->getDomainPermissions() as $relObj) { + $copyObj->addDomainPermission($relObj->copy($deepCopy)); + } + + foreach($this->getDomains() as $relObj) { + $copyObj->addDomain($relObj->copy($deepCopy)); + } + + foreach($this->getLogEntrys() as $relObj) { + $copyObj->addLogEntry($relObj->copy($deepCopy)); + } + + } + + $copyObj->setNew(true); + + $copyObj->setId(NULL); + } + + + public function copy($deepCopy = false) + { + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + return $copyObj; + } + + + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new UserPeer(); + } + return self::$peer; + } + + + public function setUserRelatedByParentUserId($v) + { + + + if ($v === null) { + $this->setParentUserId('-1'); + } else { + $this->setParentUserId($v->getId()); + } + + + $this->aUserRelatedByParentUserId = $v; + } + + + + public function getUserRelatedByParentUserId($con = null) + { + include_once 'lib/model/om/BaseUserPeer.php'; + + if ($this->aUserRelatedByParentUserId === null && ($this->parent_user_id !== null)) { + + $this->aUserRelatedByParentUserId = UserPeer::retrieveByPK($this->parent_user_id, $con); + + + } + return $this->aUserRelatedByParentUserId; + } + + + public function setRole($v) + { + + + if ($v === null) { + $this->setRoleId(NULL); + } else { + $this->setRoleId($v->getId()); + } + + + $this->aRole = $v; + } + + + + public function getRole($con = null) + { + include_once 'lib/model/om/BaseRolePeer.php'; + + if ($this->aRole === null && ($this->role_id !== null)) { + + $this->aRole = RolePeer::retrieveByPK($this->role_id, $con); + + + } + return $this->aRole; + } + + + public function initUsersRelatedByParentUserId() + { + if ($this->collUsersRelatedByParentUserId === null) { + $this->collUsersRelatedByParentUserId = array(); + } + } + + + public function getUsersRelatedByParentUserId($criteria = null, $con = null) + { + include_once 'lib/model/om/BaseUserPeer.php'; + if ($criteria === null) { + $criteria = new Criteria(); + } + elseif ($criteria instanceof Criteria) + { + $criteria = clone $criteria; + } + + if ($this->collUsersRelatedByParentUserId === null) { + if ($this->isNew()) { + $this->collUsersRelatedByParentUserId = array(); + } else { + + $criteria->add(UserPeer::PARENT_USER_ID, $this->getId()); + + UserPeer::addSelectColumns($criteria); + $this->collUsersRelatedByParentUserId = UserPeer::doSelect($criteria, $con); + } + } else { + if (!$this->isNew()) { + + + $criteria->add(UserPeer::PARENT_USER_ID, $this->getId()); + + UserPeer::addSelectColumns($criteria); + if (!isset($this->lastUserRelatedByParentUserIdCriteria) || !$this->lastUserRelatedByParentUserIdCriteria->equals($criteria)) { + $this->collUsersRelatedByParentUserId = UserPeer::doSelect($criteria, $con); + } + } + } + $this->lastUserRelatedByParentUserIdCriteria = $criteria; + return $this->collUsersRelatedByParentUserId; + } + + + public function countUsersRelatedByParentUserId($criteria = null, $distinct = false, $con = null) + { + include_once 'lib/model/om/BaseUserPeer.php'; + if ($criteria === null) { + $criteria = new Criteria(); + } + elseif ($criteria instanceof Criteria) + { + $criteria = clone $criteria; + } + + $criteria->add(UserPeer::PARENT_USER_ID, $this->getId()); + + return UserPeer::doCount($criteria, $distinct, $con); + } + + + public function addUserRelatedByParentUserId(User $l) + { + $this->collUsersRelatedByParentUserId[] = $l; + $l->setUserRelatedByParentUserId($this); + } + + + + public function getUsersRelatedByParentUserIdJoinRole($criteria = null, $con = null) + { + include_once 'lib/model/om/BaseUserPeer.php'; + if ($criteria === null) { + $criteria = new Criteria(); + } + elseif ($criteria instanceof Criteria) + { + $criteria = clone $criteria; + } + + if ($this->collUsersRelatedByParentUserId === null) { + if ($this->isNew()) { + $this->collUsersRelatedByParentUserId = array(); + } else { + + $criteria->add(UserPeer::PARENT_USER_ID, $this->getId()); + + $this->collUsersRelatedByParentUserId = UserPeer::doSelectJoinRole($criteria, $con); + } + } else { + + $criteria->add(UserPeer::PARENT_USER_ID, $this->getId()); + + if (!isset($this->lastUserRelatedByParentUserIdCriteria) || !$this->lastUserRelatedByParentUserIdCriteria->equals($criteria)) { + $this->collUsersRelatedByParentUserId = UserPeer::doSelectJoinRole($criteria, $con); + } + } + $this->lastUserRelatedByParentUserIdCriteria = $criteria; + + return $this->collUsersRelatedByParentUserId; + } + + + public function initDomainPermissions() + { + if ($this->collDomainPermissions === null) { + $this->collDomainPermissions = array(); + } + } + + + public function getDomainPermissions($criteria = null, $con = null) + { + include_once 'lib/model/om/BaseDomainPermissionPeer.php'; + if ($criteria === null) { + $criteria = new Criteria(); + } + elseif ($criteria instanceof Criteria) + { + $criteria = clone $criteria; + } + + if ($this->collDomainPermissions === null) { + if ($this->isNew()) { + $this->collDomainPermissions = array(); + } else { + + $criteria->add(DomainPermissionPeer::USER_ID, $this->getId()); + + DomainPermissionPeer::addSelectColumns($criteria); + $this->collDomainPermissions = DomainPermissionPeer::doSelect($criteria, $con); + } + } else { + if (!$this->isNew()) { + + + $criteria->add(DomainPermissionPeer::USER_ID, $this->getId()); + + DomainPermissionPeer::addSelectColumns($criteria); + if (!isset($this->lastDomainPermissionCriteria) || !$this->lastDomainPermissionCriteria->equals($criteria)) { + $this->collDomainPermissions = DomainPermissionPeer::doSelect($criteria, $con); + } + } + } + $this->lastDomainPermissionCriteria = $criteria; + return $this->collDomainPermissions; + } + + + public function countDomainPermissions($criteria = null, $distinct = false, $con = null) + { + include_once 'lib/model/om/BaseDomainPermissionPeer.php'; + if ($criteria === null) { + $criteria = new Criteria(); + } + elseif ($criteria instanceof Criteria) + { + $criteria = clone $criteria; + } + + $criteria->add(DomainPermissionPeer::USER_ID, $this->getId()); + + return DomainPermissionPeer::doCount($criteria, $distinct, $con); + } + + + public function addDomainPermission(DomainPermission $l) + { + $this->collDomainPermissions[] = $l; + $l->setUser($this); + } + + + + public function getDomainPermissionsJoinDomain($criteria = null, $con = null) + { + include_once 'lib/model/om/BaseDomainPermissionPeer.php'; + if ($criteria === null) { + $criteria = new Criteria(); + } + elseif ($criteria instanceof Criteria) + { + $criteria = clone $criteria; + } + + if ($this->collDomainPermissions === null) { + if ($this->isNew()) { + $this->collDomainPermissions = array(); + } else { + + $criteria->add(DomainPermissionPeer::USER_ID, $this->getId()); + + $this->collDomainPermissions = DomainPermissionPeer::doSelectJoinDomain($criteria, $con); + } + } else { + + $criteria->add(DomainPermissionPeer::USER_ID, $this->getId()); + + if (!isset($this->lastDomainPermissionCriteria) || !$this->lastDomainPermissionCriteria->equals($criteria)) { + $this->collDomainPermissions = DomainPermissionPeer::doSelectJoinDomain($criteria, $con); + } + } + $this->lastDomainPermissionCriteria = $criteria; + + return $this->collDomainPermissions; + } + + + public function initDomains() + { + if ($this->collDomains === null) { + $this->collDomains = array(); + } + } + + + public function getDomains($criteria = null, $con = null) + { + include_once 'lib/model/om/BaseDomainPeer.php'; + if ($criteria === null) { + $criteria = new Criteria(); + } + elseif ($criteria instanceof Criteria) + { + $criteria = clone $criteria; + } + + if ($this->collDomains === null) { + if ($this->isNew()) { + $this->collDomains = array(); + } else { + + $criteria->add(DomainPeer::CREATOR_ID, $this->getId()); + + DomainPeer::addSelectColumns($criteria); + $this->collDomains = DomainPeer::doSelect($criteria, $con); + } + } else { + if (!$this->isNew()) { + + + $criteria->add(DomainPeer::CREATOR_ID, $this->getId()); + + DomainPeer::addSelectColumns($criteria); + if (!isset($this->lastDomainCriteria) || !$this->lastDomainCriteria->equals($criteria)) { + $this->collDomains = DomainPeer::doSelect($criteria, $con); + } + } + } + $this->lastDomainCriteria = $criteria; + return $this->collDomains; + } + + + public function countDomains($criteria = null, $distinct = false, $con = null) + { + include_once 'lib/model/om/BaseDomainPeer.php'; + if ($criteria === null) { + $criteria = new Criteria(); + } + elseif ($criteria instanceof Criteria) + { + $criteria = clone $criteria; + } + + $criteria->add(DomainPeer::CREATOR_ID, $this->getId()); + + return DomainPeer::doCount($criteria, $distinct, $con); + } + + + public function addDomain(Domain $l) + { + $this->collDomains[] = $l; + $l->setUser($this); + } + + + public function initLogEntrys() + { + if ($this->collLogEntrys === null) { + $this->collLogEntrys = array(); + } + } + + + public function getLogEntrys($criteria = null, $con = null) + { + include_once 'lib/model/om/BaseLogEntryPeer.php'; + if ($criteria === null) { + $criteria = new Criteria(); + } + elseif ($criteria instanceof Criteria) + { + $criteria = clone $criteria; + } + + if ($this->collLogEntrys === null) { + if ($this->isNew()) { + $this->collLogEntrys = array(); + } else { + + $criteria->add(LogEntryPeer::USER_ID, $this->getId()); + + LogEntryPeer::addSelectColumns($criteria); + $this->collLogEntrys = LogEntryPeer::doSelect($criteria, $con); + } + } else { + if (!$this->isNew()) { + + + $criteria->add(LogEntryPeer::USER_ID, $this->getId()); + + LogEntryPeer::addSelectColumns($criteria); + if (!isset($this->lastLogEntryCriteria) || !$this->lastLogEntryCriteria->equals($criteria)) { + $this->collLogEntrys = LogEntryPeer::doSelect($criteria, $con); + } + } + } + $this->lastLogEntryCriteria = $criteria; + return $this->collLogEntrys; + } + + + public function countLogEntrys($criteria = null, $distinct = false, $con = null) + { + include_once 'lib/model/om/BaseLogEntryPeer.php'; + if ($criteria === null) { + $criteria = new Criteria(); + } + elseif ($criteria instanceof Criteria) + { + $criteria = clone $criteria; + } + + $criteria->add(LogEntryPeer::USER_ID, $this->getId()); + + return LogEntryPeer::doCount($criteria, $distinct, $con); + } + + + public function addLogEntry(LogEntry $l) + { + $this->collLogEntrys[] = $l; + $l->setUser($this); + } + +} \ No newline at end of file diff --git a/lib/model/om/BaseUserPeer.php b/lib/model/om/BaseUserPeer.php new file mode 100644 index 0000000..605ff27 --- /dev/null +++ b/lib/model/om/BaseUserPeer.php @@ -0,0 +1,758 @@ + array ('Id', 'ParentUserId', 'Nickname', 'FirstName', 'LastName', 'Email', 'Sha1Password', 'Salt', 'RoleId', 'LastLogin', 'CreatedAt', ), + BasePeer::TYPE_COLNAME => array (UserPeer::ID, UserPeer::PARENT_USER_ID, UserPeer::NICKNAME, UserPeer::FIRST_NAME, UserPeer::LAST_NAME, UserPeer::EMAIL, UserPeer::SHA1_PASSWORD, UserPeer::SALT, UserPeer::ROLE_ID, UserPeer::LAST_LOGIN, UserPeer::CREATED_AT, ), + BasePeer::TYPE_FIELDNAME => array ('id', 'parent_user_id', 'nickname', 'first_name', 'last_name', 'email', 'sha1_password', 'salt', 'role_id', 'last_login', 'created_at', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ) + ); + + + private static $fieldKeys = array ( + BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'ParentUserId' => 1, 'Nickname' => 2, 'FirstName' => 3, 'LastName' => 4, 'Email' => 5, 'Sha1Password' => 6, 'Salt' => 7, 'RoleId' => 8, 'LastLogin' => 9, 'CreatedAt' => 10, ), + BasePeer::TYPE_COLNAME => array (UserPeer::ID => 0, UserPeer::PARENT_USER_ID => 1, UserPeer::NICKNAME => 2, UserPeer::FIRST_NAME => 3, UserPeer::LAST_NAME => 4, UserPeer::EMAIL => 5, UserPeer::SHA1_PASSWORD => 6, UserPeer::SALT => 7, UserPeer::ROLE_ID => 8, UserPeer::LAST_LOGIN => 9, UserPeer::CREATED_AT => 10, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'parent_user_id' => 1, 'nickname' => 2, 'first_name' => 3, 'last_name' => 4, 'email' => 5, 'sha1_password' => 6, 'salt' => 7, 'role_id' => 8, 'last_login' => 9, 'created_at' => 10, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ) + ); + + + public static function getMapBuilder() + { + include_once 'lib/model/map/UserMapBuilder.php'; + return BasePeer::getMapBuilder('lib.model.map.UserMapBuilder'); + } + + public static function getPhpNameMap() + { + if (self::$phpNameMap === null) { + $map = UserPeer::getTableMap(); + $columns = $map->getColumns(); + $nameMap = array(); + foreach ($columns as $column) { + $nameMap[$column->getPhpName()] = $column->getColumnName(); + } + self::$phpNameMap = $nameMap; + } + return self::$phpNameMap; + } + + static public function translateFieldName($name, $fromType, $toType) + { + $toNames = self::getFieldNames($toType); + $key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null; + if ($key === null) { + throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true)); + } + return $toNames[$key]; + } + + + + static public function getFieldNames($type = BasePeer::TYPE_PHPNAME) + { + if (!array_key_exists($type, self::$fieldNames)) { + throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.'); + } + return self::$fieldNames[$type]; + } + + + public static function alias($alias, $column) + { + return str_replace(UserPeer::TABLE_NAME.'.', $alias.'.', $column); + } + + + public static function addSelectColumns(Criteria $criteria) + { + + $criteria->addSelectColumn(UserPeer::ID); + + $criteria->addSelectColumn(UserPeer::PARENT_USER_ID); + + $criteria->addSelectColumn(UserPeer::NICKNAME); + + $criteria->addSelectColumn(UserPeer::FIRST_NAME); + + $criteria->addSelectColumn(UserPeer::LAST_NAME); + + $criteria->addSelectColumn(UserPeer::EMAIL); + + $criteria->addSelectColumn(UserPeer::SHA1_PASSWORD); + + $criteria->addSelectColumn(UserPeer::SALT); + + $criteria->addSelectColumn(UserPeer::ROLE_ID); + + $criteria->addSelectColumn(UserPeer::LAST_LOGIN); + + $criteria->addSelectColumn(UserPeer::CREATED_AT); + + } + + const COUNT = 'COUNT(user.ID)'; + const COUNT_DISTINCT = 'COUNT(DISTINCT user.ID)'; + + + public static function doCount(Criteria $criteria, $distinct = false, $con = null) + { + $criteria = clone $criteria; + + $criteria->clearSelectColumns()->clearOrderByColumns(); + if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->addSelectColumn(UserPeer::COUNT_DISTINCT); + } else { + $criteria->addSelectColumn(UserPeer::COUNT); + } + + foreach($criteria->getGroupByColumns() as $column) + { + $criteria->addSelectColumn($column); + } + + $rs = UserPeer::doSelectRS($criteria, $con); + if ($rs->next()) { + return $rs->getInt(1); + } else { + return 0; + } + } + + public static function doSelectOne(Criteria $criteria, $con = null) + { + $critcopy = clone $criteria; + $critcopy->setLimit(1); + $objects = UserPeer::doSelect($critcopy, $con); + if ($objects) { + return $objects[0]; + } + return null; + } + + public static function doSelect(Criteria $criteria, $con = null) + { + return UserPeer::populateObjects(UserPeer::doSelectRS($criteria, $con)); + } + + public static function doSelectRS(Criteria $criteria, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + if (!$criteria->getSelectColumns()) { + $criteria = clone $criteria; + UserPeer::addSelectColumns($criteria); + } + + $criteria->setDbName(self::DATABASE_NAME); + + return BasePeer::doSelect($criteria, $con); + } + + public static function populateObjects(ResultSet $rs) + { + $results = array(); + + $cls = UserPeer::getOMClass(); + $cls = Propel::import($cls); + while($rs->next()) { + + $obj = new $cls(); + $obj->hydrate($rs); + $results[] = $obj; + + } + return $results; + } + + + public static function doCountJoinRole(Criteria $criteria, $distinct = false, $con = null) + { + $criteria = clone $criteria; + + $criteria->clearSelectColumns()->clearOrderByColumns(); + if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->addSelectColumn(UserPeer::COUNT_DISTINCT); + } else { + $criteria->addSelectColumn(UserPeer::COUNT); + } + + foreach($criteria->getGroupByColumns() as $column) + { + $criteria->addSelectColumn($column); + } + + $criteria->addJoin(UserPeer::ROLE_ID, RolePeer::ID); + + $rs = UserPeer::doSelectRS($criteria, $con); + if ($rs->next()) { + return $rs->getInt(1); + } else { + return 0; + } + } + + + + public static function doSelectJoinRole(Criteria $c, $con = null) + { + $c = clone $c; + + if ($c->getDbName() == Propel::getDefaultDB()) { + $c->setDbName(self::DATABASE_NAME); + } + + UserPeer::addSelectColumns($c); + $startcol = (UserPeer::NUM_COLUMNS - UserPeer::NUM_LAZY_LOAD_COLUMNS) + 1; + RolePeer::addSelectColumns($c); + + $c->addJoin(UserPeer::ROLE_ID, RolePeer::ID); + $rs = BasePeer::doSelect($c, $con); + $results = array(); + + while($rs->next()) { + + $omClass = UserPeer::getOMClass(); + + $cls = Propel::import($omClass); + $obj1 = new $cls(); + $obj1->hydrate($rs); + + $omClass = RolePeer::getOMClass(); + + $cls = Propel::import($omClass); + $obj2 = new $cls(); + $obj2->hydrate($rs, $startcol); + + $newObject = true; + foreach($results as $temp_obj1) { + $temp_obj2 = $temp_obj1->getRole(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { + $newObject = false; + $temp_obj2->addUser($obj1); break; + } + } + if ($newObject) { + $obj2->initUsers(); + $obj2->addUser($obj1); } + $results[] = $obj1; + } + return $results; + } + + + + public static function doCountJoinAll(Criteria $criteria, $distinct = false, $con = null) + { + $criteria = clone $criteria; + + $criteria->clearSelectColumns()->clearOrderByColumns(); + if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->addSelectColumn(UserPeer::COUNT_DISTINCT); + } else { + $criteria->addSelectColumn(UserPeer::COUNT); + } + + foreach($criteria->getGroupByColumns() as $column) + { + $criteria->addSelectColumn($column); + } + + $criteria->addJoin(UserPeer::ROLE_ID, RolePeer::ID); + + $rs = UserPeer::doSelectRS($criteria, $con); + if ($rs->next()) { + return $rs->getInt(1); + } else { + return 0; + } + } + + + + public static function doSelectJoinAll(Criteria $c, $con = null) + { + $c = clone $c; + + if ($c->getDbName() == Propel::getDefaultDB()) { + $c->setDbName(self::DATABASE_NAME); + } + + UserPeer::addSelectColumns($c); + $startcol2 = (UserPeer::NUM_COLUMNS - UserPeer::NUM_LAZY_LOAD_COLUMNS) + 1; + + RolePeer::addSelectColumns($c); + $startcol3 = $startcol2 + RolePeer::NUM_COLUMNS; + + $c->addJoin(UserPeer::ROLE_ID, RolePeer::ID); + + $rs = BasePeer::doSelect($c, $con); + $results = array(); + + while($rs->next()) { + + $omClass = UserPeer::getOMClass(); + + + $cls = Propel::import($omClass); + $obj1 = new $cls(); + $obj1->hydrate($rs); + + + + $omClass = RolePeer::getOMClass(); + + + $cls = Propel::import($omClass); + $obj2 = new $cls(); + $obj2->hydrate($rs, $startcol2); + + $newObject = true; + for ($j=0, $resCount=count($results); $j < $resCount; $j++) { + $temp_obj1 = $results[$j]; + $temp_obj2 = $temp_obj1->getRole(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { + $newObject = false; + $temp_obj2->addUser($obj1); break; + } + } + + if ($newObject) { + $obj2->initUsers(); + $obj2->addUser($obj1); + } + + $results[] = $obj1; + } + return $results; + } + + + + public static function doCountJoinAllExceptUserRelatedByParentUserId(Criteria $criteria, $distinct = false, $con = null) + { + $criteria = clone $criteria; + + $criteria->clearSelectColumns()->clearOrderByColumns(); + if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->addSelectColumn(UserPeer::COUNT_DISTINCT); + } else { + $criteria->addSelectColumn(UserPeer::COUNT); + } + + foreach($criteria->getGroupByColumns() as $column) + { + $criteria->addSelectColumn($column); + } + + $criteria->addJoin(UserPeer::ROLE_ID, RolePeer::ID); + + $rs = UserPeer::doSelectRS($criteria, $con); + if ($rs->next()) { + return $rs->getInt(1); + } else { + return 0; + } + } + + + + public static function doCountJoinAllExceptRole(Criteria $criteria, $distinct = false, $con = null) + { + $criteria = clone $criteria; + + $criteria->clearSelectColumns()->clearOrderByColumns(); + if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->addSelectColumn(UserPeer::COUNT_DISTINCT); + } else { + $criteria->addSelectColumn(UserPeer::COUNT); + } + + foreach($criteria->getGroupByColumns() as $column) + { + $criteria->addSelectColumn($column); + } + + $rs = UserPeer::doSelectRS($criteria, $con); + if ($rs->next()) { + return $rs->getInt(1); + } else { + return 0; + } + } + + + + public static function doSelectJoinAllExceptUserRelatedByParentUserId(Criteria $c, $con = null) + { + $c = clone $c; + + if ($c->getDbName() == Propel::getDefaultDB()) { + $c->setDbName(self::DATABASE_NAME); + } + + UserPeer::addSelectColumns($c); + $startcol2 = (UserPeer::NUM_COLUMNS - UserPeer::NUM_LAZY_LOAD_COLUMNS) + 1; + + RolePeer::addSelectColumns($c); + $startcol3 = $startcol2 + RolePeer::NUM_COLUMNS; + + $c->addJoin(UserPeer::ROLE_ID, RolePeer::ID); + + + $rs = BasePeer::doSelect($c, $con); + $results = array(); + + while($rs->next()) { + + $omClass = UserPeer::getOMClass(); + + $cls = Propel::import($omClass); + $obj1 = new $cls(); + $obj1->hydrate($rs); + + $omClass = RolePeer::getOMClass(); + + + $cls = Propel::import($omClass); + $obj2 = new $cls(); + $obj2->hydrate($rs, $startcol2); + + $newObject = true; + for ($j=0, $resCount=count($results); $j < $resCount; $j++) { + $temp_obj1 = $results[$j]; + $temp_obj2 = $temp_obj1->getRole(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { + $newObject = false; + $temp_obj2->addUser($obj1); + break; + } + } + + if ($newObject) { + $obj2->initUsers(); + $obj2->addUser($obj1); + } + + $results[] = $obj1; + } + return $results; + } + + + + public static function doSelectJoinAllExceptRole(Criteria $c, $con = null) + { + $c = clone $c; + + if ($c->getDbName() == Propel::getDefaultDB()) { + $c->setDbName(self::DATABASE_NAME); + } + + UserPeer::addSelectColumns($c); + $startcol2 = (UserPeer::NUM_COLUMNS - UserPeer::NUM_LAZY_LOAD_COLUMNS) + 1; + + + $rs = BasePeer::doSelect($c, $con); + $results = array(); + + while($rs->next()) { + + $omClass = UserPeer::getOMClass(); + + $cls = Propel::import($omClass); + $obj1 = new $cls(); + $obj1->hydrate($rs); + + $results[] = $obj1; + } + return $results; + } + + + public static function getTableMap() + { + return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME); + } + + + public static function getOMClass() + { + return UserPeer::CLASS_DEFAULT; + } + + + public static function doInsert($values, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; } else { + $criteria = $values->buildCriteria(); } + + $criteria->remove(UserPeer::ID); + + $criteria->setDbName(self::DATABASE_NAME); + + try { + $con->begin(); + $pk = BasePeer::doInsert($criteria, $con); + $con->commit(); + } catch(PropelException $e) { + $con->rollback(); + throw $e; + } + + return $pk; + } + + + public static function doUpdate($values, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + $selectCriteria = new Criteria(self::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; + $comparison = $criteria->getComparison(UserPeer::ID); + $selectCriteria->add(UserPeer::ID, $criteria->remove(UserPeer::ID), $comparison); + + } else { $criteria = $values->buildCriteria(); $selectCriteria = $values->buildPkeyCriteria(); } + + $criteria->setDbName(self::DATABASE_NAME); + + return BasePeer::doUpdate($selectCriteria, $criteria, $con); + } + + + public static function doDeleteAll($con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + $affectedRows = 0; try { + $con->begin(); + $affectedRows += UserPeer::doOnDeleteCascade(new Criteria(), $con); + UserPeer::doOnDeleteSetNull(new Criteria(), $con); + $affectedRows += BasePeer::doDeleteAll(UserPeer::TABLE_NAME, $con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + + public static function doDelete($values, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(UserPeer::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; } elseif ($values instanceof User) { + + $criteria = $values->buildPkeyCriteria(); + } else { + $criteria = new Criteria(self::DATABASE_NAME); + $criteria->add(UserPeer::ID, (array) $values, Criteria::IN); + } + + $criteria->setDbName(self::DATABASE_NAME); + + $affectedRows = 0; + try { + $con->begin(); + $affectedRows += UserPeer::doOnDeleteCascade($criteria, $con);UserPeer::doOnDeleteSetNull($criteria, $con); + $affectedRows += BasePeer::doDelete($criteria, $con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + + protected static function doOnDeleteCascade(Criteria $criteria, Connection $con) + { + $affectedRows = 0; + + $objects = UserPeer::doSelect($criteria, $con); + foreach($objects as $obj) { + + + include_once 'lib/model/DomainPermission.php'; + + $c = new Criteria(); + + $c->add(DomainPermissionPeer::USER_ID, $obj->getId()); + $affectedRows += DomainPermissionPeer::doDelete($c, $con); + } + return $affectedRows; + } + + + protected static function doOnDeleteSetNull(Criteria $criteria, Connection $con) + { + + $objects = UserPeer::doSelect($criteria, $con); + foreach($objects as $obj) { + + $selectCriteria = new Criteria(UserPeer::DATABASE_NAME); + $updateValues = new Criteria(UserPeer::DATABASE_NAME); + $selectCriteria->add(DomainPeer::CREATOR_ID, $obj->getId()); + $updateValues->add(DomainPeer::CREATOR_ID, null); + + BasePeer::doUpdate($selectCriteria, $updateValues, $con); + $selectCriteria = new Criteria(UserPeer::DATABASE_NAME); + $updateValues = new Criteria(UserPeer::DATABASE_NAME); + $selectCriteria->add(LogEntryPeer::USER_ID, $obj->getId()); + $updateValues->add(LogEntryPeer::USER_ID, null); + + BasePeer::doUpdate($selectCriteria, $updateValues, $con); + } + } + + + public static function doValidate(User $obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(UserPeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(UserPeer::TABLE_NAME); + + if (! is_array($cols)) { + $cols = array($cols); + } + + foreach($cols as $colName) { + if ($tableMap->containsColumn($colName)) { + $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); + $columns[$colName] = $obj->$get(); + } + } + } else { + + } + + $res = BasePeer::doValidate(UserPeer::DATABASE_NAME, UserPeer::TABLE_NAME, $columns); + if ($res !== true) { + $request = sfContext::getInstance()->getRequest(); + foreach ($res as $failed) { + $col = UserPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME); + $request->setError($col, $failed->getMessage()); + } + } + + return $res; + } + + + public static function retrieveByPK($pk, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + $criteria = new Criteria(UserPeer::DATABASE_NAME); + + $criteria->add(UserPeer::ID, $pk); + + + $v = UserPeer::doSelect($criteria, $con); + + return !empty($v) > 0 ? $v[0] : null; + } + + + public static function retrieveByPKs($pks, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(); + $criteria->add(UserPeer::ID, $pks, Criteria::IN); + $objs = UserPeer::doSelect($criteria, $con); + } + return $objs; + } + +} +if (Propel::isInit()) { + try { + BaseUserPeer::getMapBuilder(); + } catch (Exception $e) { + Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR); + } +} else { + require_once 'lib/model/map/UserMapBuilder.php'; + Propel::registerMapBuilder('lib.model.map.UserMapBuilder'); +} diff --git a/symfony b/symfony new file mode 100755 index 0000000..b540da2 --- /dev/null +++ b/symfony @@ -0,0 +1,14 @@ +#!/usr/bin/env php + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +chdir(dirname(__FILE__)); +include('config/config.php'); +include($sf_symfony_data_dir.'/bin/symfony.php'); diff --git a/test/bootstrap/functional.php b/test/bootstrap/functional.php new file mode 100644 index 0000000..05ea38c --- /dev/null +++ b/test/bootstrap/functional.php @@ -0,0 +1,29 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +// guess current application +if (!isset($app)) +{ + $traces = debug_backtrace(); + $caller = $traces[0]; + $app = array_pop(explode(DIRECTORY_SEPARATOR, dirname($caller['file']))); +} + +// define symfony constant +define('SF_ROOT_DIR', realpath(dirname(__FILE__).'/../..')); +define('SF_APP', $app); +define('SF_ENVIRONMENT', 'test'); +define('SF_DEBUG', true); + +// initialize symfony +require_once(SF_ROOT_DIR.DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.SF_APP.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php'); + +// remove all cache +sfToolkit::clearDirectory(sfConfig::get('sf_cache_dir')); diff --git a/test/bootstrap/unit.php b/test/bootstrap/unit.php new file mode 100644 index 0000000..fccb9eb --- /dev/null +++ b/test/bootstrap/unit.php @@ -0,0 +1,17 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +$_test_dir = realpath(dirname(__FILE__).'/..'); +define('SF_ROOT_DIR', realpath($_test_dir.'/..')); + +// symfony directories +include(SF_ROOT_DIR.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php'); + +require_once($sf_symfony_lib_dir.'/vendor/lime/lime.php'); diff --git a/test/functional/admin/addressActionsTest.php b/test/functional/admin/addressActionsTest.php new file mode 100644 index 0000000..853c9c4 --- /dev/null +++ b/test/functional/admin/addressActionsTest.php @@ -0,0 +1,15 @@ +initialize(); + +$browser-> + get('/address/index')-> + isStatusCode(200)-> + isRequestParameter('module', 'address')-> + isRequestParameter('action', 'index')-> + checkResponseElement('body', '!/This is a temporary page/') +; diff --git a/test/functional/admin/administratorActionsTest.php b/test/functional/admin/administratorActionsTest.php new file mode 100644 index 0000000..3084fb3 --- /dev/null +++ b/test/functional/admin/administratorActionsTest.php @@ -0,0 +1,15 @@ +initialize(); + +$browser-> + get('/administrator/index')-> + isStatusCode(200)-> + isRequestParameter('module', 'administrator')-> + isRequestParameter('action', 'index')-> + checkResponseElement('body', '!/This is a temporary page/') +; diff --git a/test/functional/admin/contentActionsTest.php b/test/functional/admin/contentActionsTest.php new file mode 100644 index 0000000..94650a4 --- /dev/null +++ b/test/functional/admin/contentActionsTest.php @@ -0,0 +1,15 @@ +initialize(); + +$browser-> + get('/content/index')-> + isStatusCode(200)-> + isRequestParameter('module', 'content')-> + isRequestParameter('action', 'index')-> + checkResponseElement('body', '!/This is a temporary page/') +; diff --git a/test/functional/admin/domainActionsTest.php b/test/functional/admin/domainActionsTest.php new file mode 100644 index 0000000..955fed1 --- /dev/null +++ b/test/functional/admin/domainActionsTest.php @@ -0,0 +1,15 @@ +initialize(); + +$browser-> + get('/domain/index')-> + isStatusCode(200)-> + isRequestParameter('module', 'domain')-> + isRequestParameter('action', 'index')-> + checkResponseElement('body', '!/This is a temporary page/') +; diff --git a/test/functional/admin/domaintestActionsTest.php b/test/functional/admin/domaintestActionsTest.php new file mode 100644 index 0000000..dba9ffa --- /dev/null +++ b/test/functional/admin/domaintestActionsTest.php @@ -0,0 +1,15 @@ +initialize(); + +$browser-> + get('/domaintest/index')-> + isStatusCode(200)-> + isRequestParameter('module', 'domaintest')-> + isRequestParameter('action', 'index')-> + checkResponseElement('body', '!/This is a temporary page/') +; diff --git a/test/functional/admin/logActionsTest.php b/test/functional/admin/logActionsTest.php new file mode 100644 index 0000000..8e10f64 --- /dev/null +++ b/test/functional/admin/logActionsTest.php @@ -0,0 +1,15 @@ +initialize(); + +$browser-> + get('/log/index')-> + isStatusCode(200)-> + isRequestParameter('module', 'log')-> + isRequestParameter('action', 'index')-> + checkResponseElement('body', '!/This is a temporary page/') +; diff --git a/test/functional/admin/mailboxActionsTest.php b/test/functional/admin/mailboxActionsTest.php new file mode 100644 index 0000000..42bf697 --- /dev/null +++ b/test/functional/admin/mailboxActionsTest.php @@ -0,0 +1,15 @@ +initialize(); + +$browser-> + get('/mailbox/index')-> + isStatusCode(200)-> + isRequestParameter('module', 'mailbox')-> + isRequestParameter('action', 'index')-> + checkResponseElement('body', '!/This is a temporary page/') +; diff --git a/test/functional/admin/serverActionsTest.php b/test/functional/admin/serverActionsTest.php new file mode 100644 index 0000000..3ea4a37 --- /dev/null +++ b/test/functional/admin/serverActionsTest.php @@ -0,0 +1,15 @@ +initialize(); + +$browser-> + get('/server/index')-> + isStatusCode(200)-> + isRequestParameter('module', 'server')-> + isRequestParameter('action', 'index')-> + checkResponseElement('body', '!/This is a temporary page/') +; diff --git a/test/functional/admin/userActionsTest.php b/test/functional/admin/userActionsTest.php new file mode 100644 index 0000000..fca0dd1 --- /dev/null +++ b/test/functional/admin/userActionsTest.php @@ -0,0 +1,15 @@ +initialize(); + +$browser-> + get('/user/index')-> + isStatusCode(200)-> + isRequestParameter('module', 'user')-> + isRequestParameter('action', 'index')-> + checkResponseElement('body', '!/This is a temporary page/') +; diff --git a/web/.htaccess b/web/.htaccess new file mode 100644 index 0000000..2c0a59f --- /dev/null +++ b/web/.htaccess @@ -0,0 +1,25 @@ +Options +FollowSymLinks +ExecCGI + + + RewriteEngine On + + # uncomment the following line, if you are having trouble + # getting no_script_name to work + #RewriteBase / + + # we skip all files with .something + RewriteCond %{REQUEST_URI} \..+$ + RewriteCond %{REQUEST_URI} !\.html$ + RewriteRule .* - [L] + + # we check if the .html version is here (caching) + RewriteRule ^$ index.html [QSA] + RewriteRule ^([^.]+)$ $1.html [QSA] + RewriteCond %{REQUEST_FILENAME} !-f + + # no, so we redirect to our front web controller + RewriteRule ^(.*)$ index.php [QSA,L] + + +# big crash from our front web controller +ErrorDocument 500 "

Application error

symfony application failed to start properly" diff --git a/web/admin_dev.php b/web/admin_dev.php new file mode 100644 index 0000000..931e0a7 --- /dev/null +++ b/web/admin_dev.php @@ -0,0 +1,10 @@ +getController()->dispatch(); diff --git a/web/css/main.css b/web/css/main.css new file mode 100644 index 0000000..2a66410 --- /dev/null +++ b/web/css/main.css @@ -0,0 +1,405 @@ +/* -------------------------------------------------------------------------- */ +/* Common */ +/* -------------------------------------------------------------------------- */ + +html body { + background-color:#ece9d8; + height:100%; + margin:0; + font-size:x-small; + voice-family:"\"}\""; + voice-family:inherit; + font-size:small; +} + +/* !IE */ +html>/**/body { + font-size:small; +} + +.base { + font-family:Verdana, Helvetica, Sans-Serif; + line-height:1.4em; + font-size:96%; + background-color:transparent; + padding:0; + margin:0; +} + +/* -------------------------------------------------------------------------- */ +/* Structure */ +/* -------------------------------------------------------------------------- */ + +.base div.branding { + margin:0; + padding:20px; + height:40px; + background-image: url("../images/background-branding.png"); + background-repeat: repeat-x; +} + +.base div.branding div.logo { + float:left; + padding-top:4px; +} + +.base div.session { + margin:0; + padding:5px 20px 5px 20px; + background-color:#fff3dc; +} + +.base div.session ul { + padding:0; + margin:0; +} + +.base div.session li { + padding:0; + margin-right:20px; + display:inline; +} + +.base div.session a { + text-decoration:none; + border-bottom:1px dotted; + color:#006699; + font-weight:bold; +} + +.base div.navigation { + margin:0; + padding:10px 20px 9px 20px; + background-image: url("../images/background-navigation.png"); + background-position:top left; +} + +.base div.navigation ul { + padding:0; + margin:0; +} + +.base div.navigation li { + margin:0; + height:1%; /* IE <= 5.5 */ + padding-right:10px; + display:inline; +} + +.base div.navigation li a { + margin:0; + padding:2px 10px 9px 10px; + text-decoration:none; + font-size:16px; + font-weight:bold; + color:#fff; +} + +.base div.navigation li.active a { + margin:0; + background-color:#485659; +} + +.base div.subnavigation { + margin:0; + padding:6px 20px 5px 20px; + background-color:#485659; +} + +.base div.subnavigation ul { + padding:0; + margin:0; +} + +.base div.subnavigation li { + padding-right:10px; + margin:0; + height:1%; /* IE <= 5.5 */ + display:inline; +} + +.base div.subnavigation li a { + padding:3px 6px 6px 6px; + text-decoration:none; + color:#fff; +} + +.base div.subnavigation li.active a { + background-color:white; + color:black; +} + +.base div#context { + margin:0; + height:1%; /* IE <= 5.5 */ + padding:20px; + background-color:white; +} + +.base div#context div.tablenavigation { + text-align:right; +} + +.base div#context div.tablenavigation a { + text-decoration:none; + color:#006699; +} + +.base div#context div.tablenavigation ul { + margin:0; + padding:0; +} + +.base div#context div.tablenavigation li { + margin:0; + padding-left:20px; + display:inline; +} + +.base div#context hr { + height:1px; + border-top:1px dotted #999999; +} + +.base div#context table { + width:100%; + border-spacing:5px; +} + +.base div#context table tr.sf_admin_row_0 td { + background-color:#f5f4eb; +} + +.base div#context table th { + padding:5px; + background-color:#ece9d8; +} + +.base div#context table th a { + text-decoration: none; + color:#000; + font-weight:bold; + border-bottom:1px dotted; +} + +.base div#context table td { + padding:5px; + background-color:#ece9d8; +} + +.base div#context table td a { + text-decoration:none; + color:#006699; +} + +.base div#context table td ul.sf_admin_td_actions { + margin:0; + padding:0; +} + +.base div#context table td ul.sf_admin_td_actions li { + margin:0; + padding:0; + display:inline; +} + +.base div#context table th#sf_admin_list_th_sf_actions { + text-align:left; +} + +.base div#context div#sf_admin_content { + padding-top:10px; +} + +.base div#context ul.sf_admin_actions { + margin:0; + padding:0; +} + +.base div#context ul.sf_admin_actions li { + margin:0; + padding:0; + display:inline; +} + +.base div#context div.sf_admin_edit_help { + color:#888a85; +} + +.base div.notes { + margin:0; + padding:20px; + color:#999; + text-align:center; + background-image: url("../images/background-notes-start.png"); + background-repeat: repeat-x; + background-position:top; +} + +.base div.notes ul { + margin:0; + padding:0; +} + +.base div.notes li { + margin:0; + padding:0; + padding-right:20px; + display:inline; +} + +.base div.notes a { + color:#999; + text-decoration:none; + border-bottom:1px dotted; + font-weight:bold; +} + +/* -------------------------------------------------------------------------- */ +/* Standard Tags */ +/* -------------------------------------------------------------------------- */ + +.base img { + vertical-align:middle; + border:0; +} + +.base h1 { + font-weight:normal; + font-size:24px; + color:#006699; + padding-bottom:10px; +} + +.base h2 { + font-size:16px; + font-weight:bold; + color:#485659; +} + +.base form { + margin:0; + padding:0; +} + +.base form select { + color:#333; + font-size:small; + border:1px solid; +} + +.base form input { + border:1px solid #485659; + font-size:small; + padding:2px; + vertical-align:middle; +} + +.base form textarea { + border:1px solid #485659; + padding:2px; + font-size:small; +} + +.base form label { + display:block; + color:#006699; + font-weight:bold; + padding-top:5px; +} + +.base form fieldset { + border:0; + border-top:1px dotted #999999; + padding-left:0; + padding-right:0; + padding-bottom:20px; +} + +.base form div.formaction, .base form div.sf_admin_actions { + display:block; + margin-top:10px; + padding-bottom:20px; +} + +.base form div.formaction input { + margin-right:10px; +} + +/* -------------------------------------------------------------------------- */ +/* Additional Formatting */ +/* -------------------------------------------------------------------------- */ + +.base #indicator { + display:none; +} + +.base div.slidelist ul { + margin:0; + padding:0; + list-style-type:none; +} + +.base div.slidelist a { + border-bottom:1px dotted; +} + +.base ul.linklist { + margin:0; + padding:0; + list-style-type:none; +} + +.base ul.linklist li { + display:inline; + height:1%; /* IE == 5 */ + padding-left:5px; + padding-right:5px; +} + +.base ul.linklist li.label { + border:none; + padding-left:20px; +} + +.base ul.linklist li a { + text-decoration:none; + color:#006699; +} + +.base span.adminname { + font-style:italic; +} + +.base span.adminrole { + color:#ff9900; +} + +.base .form_error, .base .form-error-msg { + color:#ef2929; +} + +.base .form_help { + padding-left:10px; + color:#999; +} + +.base span.legal, .base span.legal a { +} + +.base span.toggle a { + text-decoration:none; + color:#006699; + border-bottom:1px dotted; +} + +.base span.pageinfo { +} + +.base span.pageindex { + font-weight:bold; +} + +.base span.summary { + padding-right:20px; +} diff --git a/web/images/add.gif b/web/images/add.gif new file mode 100644 index 0000000..f7ab24a Binary files /dev/null and b/web/images/add.gif differ diff --git a/web/images/address-new.gif b/web/images/address-new.gif new file mode 100644 index 0000000..98d6a9f Binary files /dev/null and b/web/images/address-new.gif differ diff --git a/web/images/address.gif b/web/images/address.gif new file mode 100644 index 0000000..15842df Binary files /dev/null and b/web/images/address.gif differ diff --git a/web/images/background-branding.png b/web/images/background-branding.png new file mode 100644 index 0000000..faeb260 Binary files /dev/null and b/web/images/background-branding.png differ diff --git a/web/images/background-navigation.png b/web/images/background-navigation.png new file mode 100644 index 0000000..0358ad3 Binary files /dev/null and b/web/images/background-navigation.png differ diff --git a/web/images/background-notes-start.png b/web/images/background-notes-start.png new file mode 100644 index 0000000..d0de8f3 Binary files /dev/null and b/web/images/background-notes-start.png differ diff --git a/web/images/bottom.gif b/web/images/bottom.gif new file mode 100644 index 0000000..a7a0730 Binary files /dev/null and b/web/images/bottom.gif differ diff --git a/web/images/down.gif b/web/images/down.gif new file mode 100644 index 0000000..7751dae Binary files /dev/null and b/web/images/down.gif differ diff --git a/web/images/edit.gif b/web/images/edit.gif new file mode 100644 index 0000000..8b21080 Binary files /dev/null and b/web/images/edit.gif differ diff --git a/web/images/error.gif b/web/images/error.gif new file mode 100644 index 0000000..79c53a1 Binary files /dev/null and b/web/images/error.gif differ diff --git a/web/images/favicon.ico b/web/images/favicon.ico new file mode 100644 index 0000000..410daf6 Binary files /dev/null and b/web/images/favicon.ico differ diff --git a/web/images/first.gif b/web/images/first.gif new file mode 100644 index 0000000..99a2a74 Binary files /dev/null and b/web/images/first.gif differ diff --git a/web/images/information.gif b/web/images/information.gif new file mode 100644 index 0000000..0e89c99 Binary files /dev/null and b/web/images/information.gif differ diff --git a/web/images/last.gif b/web/images/last.gif new file mode 100644 index 0000000..35219f8 Binary files /dev/null and b/web/images/last.gif differ diff --git a/web/images/list.gif b/web/images/list.gif new file mode 100644 index 0000000..667ef38 Binary files /dev/null and b/web/images/list.gif differ diff --git a/web/images/load.gif b/web/images/load.gif new file mode 100644 index 0000000..cce32f2 Binary files /dev/null and b/web/images/load.gif differ diff --git a/web/images/logo.png b/web/images/logo.png new file mode 100644 index 0000000..0f2131c Binary files /dev/null and b/web/images/logo.png differ diff --git a/web/images/mail-new.gif b/web/images/mail-new.gif new file mode 100644 index 0000000..b766324 Binary files /dev/null and b/web/images/mail-new.gif differ diff --git a/web/images/mail.gif b/web/images/mail.gif new file mode 100644 index 0000000..c14447b Binary files /dev/null and b/web/images/mail.gif differ diff --git a/web/images/network-server.gif b/web/images/network-server.gif new file mode 100644 index 0000000..9fc4dd2 Binary files /dev/null and b/web/images/network-server.gif differ diff --git a/web/images/next.gif b/web/images/next.gif new file mode 100644 index 0000000..0dabbfc Binary files /dev/null and b/web/images/next.gif differ diff --git a/web/images/ok.gif b/web/images/ok.gif new file mode 100644 index 0000000..c03f738 Binary files /dev/null and b/web/images/ok.gif differ diff --git a/web/images/previous.gif b/web/images/previous.gif new file mode 100644 index 0000000..57e200f Binary files /dev/null and b/web/images/previous.gif differ diff --git a/web/images/remove.gif b/web/images/remove.gif new file mode 100644 index 0000000..2905ce5 Binary files /dev/null and b/web/images/remove.gif differ diff --git a/web/images/search.gif b/web/images/search.gif new file mode 100644 index 0000000..790843c Binary files /dev/null and b/web/images/search.gif differ diff --git a/web/images/shred.gif b/web/images/shred.gif new file mode 100644 index 0000000..2c81d3b Binary files /dev/null and b/web/images/shred.gif differ diff --git a/web/images/sort-asc.gif b/web/images/sort-asc.gif new file mode 100644 index 0000000..29fee1d Binary files /dev/null and b/web/images/sort-asc.gif differ diff --git a/web/images/sort-desc.gif b/web/images/sort-desc.gif new file mode 100644 index 0000000..d049aa0 Binary files /dev/null and b/web/images/sort-desc.gif differ diff --git a/web/images/top.gif b/web/images/top.gif new file mode 100644 index 0000000..13502e4 Binary files /dev/null and b/web/images/top.gif differ diff --git a/web/images/trash.gif b/web/images/trash.gif new file mode 100644 index 0000000..73fa119 Binary files /dev/null and b/web/images/trash.gif differ diff --git a/web/images/up.gif b/web/images/up.gif new file mode 100644 index 0000000..1165d2e Binary files /dev/null and b/web/images/up.gif differ diff --git a/web/images/warning.gif b/web/images/warning.gif new file mode 100644 index 0000000..76d93ee Binary files /dev/null and b/web/images/warning.gif differ diff --git a/web/index.php b/web/index.php new file mode 100644 index 0000000..5e4fa7a --- /dev/null +++ b/web/index.php @@ -0,0 +1,10 @@ +getController()->dispatch(); diff --git a/web/robots.txt b/web/robots.txt new file mode 100644 index 0000000..0827227 --- /dev/null +++ b/web/robots.txt @@ -0,0 +1,2 @@ +#User-agent: * +#Disallow: -- cgit v1.1-32-gdbae