/** * Returns available virtual emails. * * @param string $filter If passed a domain then return all virtual emails * for the domain, otherwise if passed a user name * return all virtual emails for that user. * * @return array The available virtual emails. */ public function getVirtuals($filter) { $email_field = $this->_getTableField('virtuals', 'virtual_email'); $destination_field = $this->_getTableField('virtuals', 'virtual_destination'); /* Check if filtering only for domain. */ if (strpos($filter, '@') === false) { $where = $email_field . ' LIKE ?'; $values = array('%@' . $filter); } else { $where = $destination_field . ' = ?'; $values = array($filter); } $sql = 'SELECT ' . $this->_getTableFields('virtuals') . ' FROM ' . $this->_params['tables']['virtuals'] . ' WHERE ' . $where . ' ORDER BY ' . $destination_field . ', ' . $email_field; return $this->_db->selectAll($sql, $values); }