/**
  * inspect get user by property
  * 
  * @param Tinebase_Model_User  $_user  the user object
  */
 public function inspectGetUserByProperty(Tinebase_Model_User $_user)
 {
     if (!$_user instanceof Tinebase_Model_FullUser) {
         return;
     }
     // convert data to Tinebase_Model_EmailUser
     $emailUser = $this->_rawDataToRecord(array());
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . print_r($emailUser->toArray(), TRUE));
     }
     $emailUser->emailUsername = $this->_getEmailUserName($_user);
     if ($this instanceof Tinebase_EmailUser_Smtp_Interface) {
         $_user->smtpUser = $emailUser;
         $_user->emailUser = Tinebase_EmailUser::merge($_user->emailUser, clone $_user->smtpUser);
     } else {
         $_user->imapUser = $emailUser;
         $_user->emailUser = Tinebase_EmailUser::merge(clone $_user->imapUser, $_user->emailUser);
     }
 }
 /**
  * inspect get user by property
  * 
  * @param  Tinebase_Model_User  $_user  the user object
  */
 public function inspectGetUserByProperty(Tinebase_Model_User $_user)
 {
     if (!$_user instanceof Tinebase_Model_FullUser) {
         return;
     }
     $userId = $_user->getId();
     $select = $this->_getSelect();
     if ($this->_hasTine20Userid === true) {
         $select->where($this->_db->quoteIdentifier($this->_propertyMapping['emailUserId']) . ' = ?', $userId);
     } else {
         $select->where($this->_db->quoteIdentifier($this->_propertyMapping['emailUserId']) . ' = ?', $this->_convertToInt($userId));
     }
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . $select->__toString());
     }
     // Perferom query - retrieve user from database
     $stmt = $this->_db->query($select);
     $queryResult = $stmt->fetch();
     $stmt->closeCursor();
     if (!$queryResult) {
         if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
             Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . 'Dbmail config for user ' . $userId . ' not found!');
         }
         return;
     }
     #if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' ' . print_r($queryResult, TRUE));
     // convert data to Tinebase_Model_EmailUser
     $emailUser = $this->_rawDataToRecord($queryResult);
     #if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' ' . print_r($emailUser->toArray(), TRUE));
     // modify/correct user name
     // set emailUsername to Tine accout login name and append domain for login purposes if set
     $emailUser->emailUsername = $this->_appendDomain($_user->accountLoginName);
     $_user->imapUser = $emailUser;
     $_user->emailUser = Tinebase_EmailUser::merge(clone $_user->imapUser, isset($_user->emailUser) ? $_user->emailUser : null);
 }
示例#3
0
 /**
  * inspect get user by property
  * 
  * @param Tinebase_Model_User  $_user  the user object
  */
 public function inspectGetUserByProperty(Tinebase_Model_User $_user)
 {
     if (!$_user instanceof Tinebase_Model_FullUser) {
         return;
     }
     $imap = $this->_getImapConnection();
     $mailboxString = $this->_getUserMailbox($_user->accountLoginName);
     $quota = $imap->getQuotaRoot($mailboxString);
     $emailUser = new Tinebase_Model_EmailUser(array('emailUsername' => $this->_appendDomain($_user->accountLoginName), 'emailUserId' => $this->_appendDomain($_user->accountLoginName), 'emailMailQuota' => isset($quota['STORAGE']) ? round($quota['STORAGE']['limit'] / 1024) : null, 'emailMailSize' => isset($quota['STORAGE']) ? round($quota['STORAGE']['usage'] / 1024) : null));
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . print_r($emailUser->toArray(), TRUE));
     }
     $_user->imapUser = $emailUser;
     $_user->emailUser = Tinebase_EmailUser::merge(clone $_user->imapUser, isset($_user->emailUser) ? $_user->emailUser : null);
 }
 /**
  * inspect get user by property
  * 
  * @param Tinebase_Model_User  $_user  the user object
  */
 public function inspectGetUserByProperty(Tinebase_Model_User $_user)
 {
     if (!$_user instanceof Tinebase_Model_FullUser) {
         return;
     }
     $userId = $_user->getId();
     $select = $this->_getSelect()->where($this->_db->quoteIdentifier($this->_userTable . '.' . $this->_propertyMapping['emailUserId']) . ' = ?', $userId);
     // Perform query - retrieve user from database
     $stmt = $this->_db->query($select);
     $queryResult = $stmt->fetch();
     $stmt->closeCursor();
     if (!$queryResult) {
         if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
             Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' ' . $this->_subconfigKey . ' config for user ' . $userId . ' not found!');
         }
     }
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . print_r($queryResult, TRUE));
     }
     // convert data to Tinebase_Model_EmailUser
     $emailUser = $this->_rawDataToRecord((array) $queryResult);
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . print_r($emailUser->toArray(), TRUE));
     }
     // modify/correct user name
     // set emailUsername to Tine 2.0 account login name and append domain for login purposes if set
     if (empty($emailUser->emailUsername)) {
         $emailUser->emailUsername = $this->_getEmailUserName($_user);
     }
     if ($this instanceof Tinebase_EmailUser_Smtp_Interface) {
         $_user->smtpUser = $emailUser;
         $_user->emailUser = Tinebase_EmailUser::merge($_user->emailUser, clone $_user->smtpUser);
     } else {
         $_user->imapUser = $emailUser;
         $_user->emailUser = Tinebase_EmailUser::merge(clone $_user->imapUser, $_user->emailUser);
     }
 }
 /**
  * (non-PHPdoc)
  * @see Tinebase_User_Plugin_LdapAbstract::inspectGetUserByProperty()
  */
 public function inspectGetUserByProperty(Tinebase_Model_User $_user, array &$_ldapEntry)
 {
     if (!$_user instanceof Tinebase_Model_FullUser) {
         return;
     }
     $user = $this->_ldap2User($_user, $_ldapEntry);
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . print_r($user->toArray(), TRUE));
     }
     if ($this instanceof Tinebase_EmailUser_Ldap) {
         // TODO this should be moved to Tinebase_EmailUser_Ldap
         // modify/correct user name
         // set emailUsername to Tine 2.0 account login name and append domain for login purposes if set
         if (is_object($user) && empty($user->emailUsername)) {
             $user->emailUsername = $this->_getEmailUserName($_user);
         }
         if ($this instanceof Tinebase_EmailUser_Smtp_Interface) {
             $_user->smtpUser = $user;
             $_user->emailUser = Tinebase_EmailUser::merge($_user->emailUser, clone $_user->smtpUser);
         } else {
             $_user->imapUser = $user;
             $_user->emailUser = Tinebase_EmailUser::merge(clone $_user->imapUser, $_user->emailUser);
         }
     }
 }
示例#6
0
 /**
  * Returns a user object with raw data from ldap
  *
  * @param array $_userData
  * @param string $_accountClass
  * @return Tinebase_Record_Abstract
  * 
  * @todo add generic function for this in Tinebase_User_Ldap or Tinebase_Ldap?
  */
 protected function _ldap2User(Tinebase_Model_User $_user, array &$_ldapEntry)
 {
     #if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' ' . print_r($_ldapEntry, true));
     if ($this->_backendType == Tinebase_Config::SMTP) {
         $accountArray = array('emailForwardOnly' => false, 'emailAliases' => array(), 'emailForwards' => array());
     } else {
         $accountArray = array();
     }
     foreach ($_ldapEntry as $key => $value) {
         if (is_int($key)) {
             continue;
         }
         $keyMapping = array_search($key, $this->_propertyMapping);
         if ($keyMapping !== FALSE) {
             switch ($keyMapping) {
                 case 'emailMailQuota':
                     // convert to megabytes
                     $accountArray[$keyMapping] = convertToMegabytes($value[0]);
                     break;
                 case 'emailAliases':
                 case 'emailForwards':
                     $accountArray[$keyMapping] = $value;
                     break;
                 case 'emailForwardOnly':
                     $accountArray[$keyMapping] = $value[0] == 'forwardonly' ? true : false;
                     break;
                 default:
                     $accountArray[$keyMapping] = $value[0];
                     break;
             }
         }
     }
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . print_r($accountArray, true));
     }
     if ($this->_backendType == Tinebase_Config::SMTP) {
         $_user->smtpUser = new Tinebase_Model_EmailUser($accountArray);
         $_user->emailUser = Tinebase_EmailUser::merge(isset($_user->emailUser) ? $_user->emailUser : null, $_user->smtpUser);
     } else {
         $_user->imapUser = new Tinebase_Model_EmailUser($accountArray);
         $_user->emailUser = Tinebase_EmailUser::merge(clone $_user->imapUser, isset($_user->emailUser) ? $_user->emailUser : null);
     }
 }