summaryrefslogtreecommitdiff
path: root/manager/library
diff options
context:
space:
mode:
authorMarkus Warg <mw@it-sls.de>2010-08-18 14:57:13 +0200
committerMarkus Warg <mw@it-sls.de>2010-08-18 14:57:13 +0200
commit79b16d2a04b61587759b36b0ab773c2ebaf352a9 (patch)
tree65d4c8d402e0a134029b4eca2deb83500d06c25d /manager/library
parent5d25f6837871beae4067ce9a58e5fe664b3715e4 (diff)
downloadcacert-mgr-79b16d2a04b61587759b36b0ab773c2ebaf352a9.tar.gz
cacert-mgr-79b16d2a04b61587759b36b0ab773c2ebaf352a9.tar.xz
cacert-mgr-79b16d2a04b61587759b36b0ab773c2ebaf352a9.zip
display all emails to an user (check more addresses)
add method to get all email addresses that are associated to an account, use list of addresses to allow access to emails (mail ping issue #834 #845) modified: manager/application/configs/application.ini modified: manager/application/controllers/MailController.php new file: manager/library/CAcert/User/Emails.php
Diffstat (limited to 'manager/library')
-rw-r--r--manager/library/CAcert/User/Emails.php57
1 files changed, 57 insertions, 0 deletions
diff --git a/manager/library/CAcert/User/Emails.php b/manager/library/CAcert/User/Emails.php
new file mode 100644
index 0000000..d345ce8
--- /dev/null
+++ b/manager/library/CAcert/User/Emails.php
@@ -0,0 +1,57 @@
+<?php
+
+class CAcert_User_Emails {
+ public function __construct() {
+ Log::Log()->debug(__METHOD__);
+ }
+
+ /**
+ * get list of email addresses by login, needed to be able to filter emails
+ * @param string $addr
+ * @return array
+ */
+ public function getEmailAddressesByLogin($addr) {
+ $db = Zend_Registry::get('auth2_dbc');
+
+ /**
+ * find out user id by email address
+ */
+ $sql = 'select users.id from users where email=?';
+
+ $id = $db->fetchOne($sql, array($addr));
+
+ /**
+ * get secondary email addresses
+ */
+ $sql = 'select email.email from email where memid=?';
+
+ $res = $db->query($sql, array($id));
+
+ $emails = array();
+
+ $num = $res->rowCount();
+ for ($i = 0; $i < $num; $i++) {
+ $row = $res->fetch(PDO::FETCH_ASSOC);
+ $emails[] = $row['email'];
+ }
+
+ /**
+ * get additional addresses by domains
+ */
+ $sql = 'select domains.domain from domains where memid=?';
+
+ $res = $db->query($sql, array($id));
+ $num = $res->rowCount();
+ $variants = array('root','hostmaster','postmaster','admin','webmaster');
+ for ($i = 0; $i < $num; $i++) {
+ $row = $res->fetch(PDO::FETCH_ASSOC);
+
+ foreach ($variants as $variant) {
+ $emails[] = $variants . '@' . $row['domain'];
+ }
+ }
+
+ Log::Log()->debug(__METHOD__ . ' mail addresses ' . var_export($emails, true));
+ return $emails;
+ }
+} \ No newline at end of file