Create and return the UID for a mailbox/user/server combo.

@param string $mailbox  Mailbox name.

@return string  UID from base table.
321561
protected function _createUid($mailbox)
    {
        $doc = array(
            self::BASE_HOSTSPEC => $this->_params['hostspec'],
            self::BASE_MAILBOX => $mailbox,
            self::BASE_PORT => $this->_params['port'],
            self::BASE_USERNAME => $this->_params['username']
        );
        $this->_db->selectCollection(self::BASE)->insert($doc);

        return $this->_getUid($mailbox);
    }
296373
def create(cls, domain, login, options, alias):
        """"""
        cls.echo('Creating your mailbox.')
        result = cls.call('domain.mailbox.create', domain, login, options)

        if alias:
            cls.echo('Creating aliases.')
            result = cls.set_alias(domain, login, list(alias))

        return result
379954
public function deleteFolder($mailbox)
    {
        $result = $this->execute('DELETE', array($this->escape($mailbox)),
            self::COMMAND_NORESPONSE);

        return $result == self::ERROR_OK;
    }
1121671
public function userIdToFid($uid) {
        $value = Cache::redis()->hGet('user_id_#_fid', $uid);
        Cache::release();
        return $value;
    }
861750
public function fetchPartHeader($mailbox, $id, $is_uid = false, $part = null)
    {
        $part = empty($part) ? 'HEADER' : $part.'.MIME';

        return $this->handlePartBody($mailbox, $id, $is_uid, $part);
    }
1018119
public function getHeader( $uid = '' )
	{
		$view = $this->getObject()->addData( $this->getView() );

		$content = '';
		foreach( $this->getSubClients() as $subclient ) {
			$content .= $subclient->setView( $view )->getHeader( $uid );
		}
		$view->accountHeader = $content;


		$addr = $view->extAddressItem;

		$msg = $view->mail();
		$msg->addHeader( 'X-MailGenerator', 'Aimeos' );
		$msg->addTo( $addr->getEMail(), $addr->getFirstName() . ' ' . $addr->getLastName() );


		/** client/html/email/from-name
		 * @see client/html/email/account/from-email
		 */
		$fromName = $view->config( 'client/html/email/from-name' );

		/** client/html/email/account/from-name
		 * Name used when sending account creation e-mails
		 *
		 * The name of the person or e-mail account that is used for sending all
		 * shop related account e-mails to customers. This configuration option
		 * overwrite the name set in "client/html/email/from-name".
		 *
		 * @param string Name shown in the e-mail
		 * @since 2015.09
		 * @category User
		 * @see client/html/email/from-name
		 * @see client/html/email/from-email
		 * @see client/html/email/reply-email
		 * @see client/html/email/bcc-email
		 */
		$fromNameAccount = $view->config( 'client/html/email/account/from-name', $fromName );

		/** client/html/email/from-email
		 * @see client/html/email/account/from-email
		 */
		$fromEmail = $view->config( 'client/html/email/from-email' );

		/** client/html/email/account/from-email
		 * E-Mail address used when sending account creation e-mails
		 *
		 * The e-mail address of the person or account that is used for sending
		 * all shop related product notification e-mails to customers. This configuration option
		 * overwrites the e-mail address set via "client/html/email/from-email".
		 *
		 * @param string E-mail address
		 * @since 2015.09
		 * @category User
		 * @see client/html/email/account/from-name
		 * @see client/html/email/from-email
		 * @see client/html/email/reply-email
		 * @see client/html/email/bcc-email
		 */
		if( ( $fromEmailAccount = $view->config( 'client/html/email/account/from-email', $fromEmail ) ) != null ) {
			$msg->addFrom( $fromEmailAccount, $fromNameAccount );
		}


		/** client/html/email/reply-name
		 * @see client/html/email/account/reply-email
		 */
		$replyName = $view->config( 'client/html/email/reply-name', $fromName );

		/** client/html/email/account/reply-name
		 * Recipient name displayed when the customer replies to account creation e-mails
		 *
		 * The name of the person or e-mail account the customer should
		 * reply to in case of account related questions or problems. This
		 * configuration option overwrites the name set via
		 * "client/html/email/reply-name".
		 *
		 * @param string Name shown in the e-mail
		 * @since 2015.09
		 * @category User
		 * @see client/html/email/account/reply-email
		 * @see client/html/email/reply-name
		 * @see client/html/email/reply-email
		 * @see client/html/email/from-email
		 * @see client/html/email/bcc-email
		 */
		$replyNameAccount = $view->config( 'client/html/email/account/reply-name', $replyName );

		/** client/html/email/reply-email
		 * @see client/html/email/account/reply-email
		 */
		$replyEmail = $view->config( 'client/html/email/reply-email', $fromEmail );

		/** client/html/email/account/reply-email
		 * E-Mail address used by the customer when replying to account creation e-mails
		 *
		 * The e-mail address of the person or e-mail account the customer
		 * should reply to in case of account related questions or problems.
		 * This configuration option overwrites the e-mail address set via
		 * "client/html/email/reply-email".
		 *
		 * @param string E-mail address
		 * @since 2015.09
		 * @category User
		 * @see client/html/email/account/reply-name
		 * @see client/html/email/reply-email
		 * @see client/html/email/from-email
		 * @see client/html/email/bcc-email
		 */
		if( ( $replyEmailAccount = $view->config( 'client/html/email/account/reply-email', $replyEmail ) ) != null ) {
			$msg->addReplyTo( $replyEmailAccount, $replyNameAccount );
		}


		/** client/html/email/bcc-email
		 * @see client/html/email/account/bcc-email
		 */
		$bccEmail = $view->config( 'client/html/email/bcc-email' );

		/** client/html/email/account/bcc-email
		 * E-Mail address all account creation e-mails should be also sent to
		 *
		 * Using this option you can send a copy of all account related e-mails
		 * to a second e-mail account. This can be handy for testing and checking
		 * the e-mails sent to customers.
		 *
		 * It also allows shop owners with a very small volume of orders to be
		 * notified about account changes. Be aware that this isn't useful if the
		 * order volumne is high or has peeks!
		 *
		 * This configuration option overwrites the e-mail address set via
		 * "client/html/email/bcc-email".
		 *
		 * @param string|array E-mail address or list of e-mail addresses
		 * @since 2015.09
		 * @category User
		 * @category Developer
		 * @see client/html/email/bcc-email
		 * @see client/html/email/reply-email
		 * @see client/html/email/from-email
		 */
		if( ( $bccEmailAccount = $view->config( 'client/html/email/account/bcc-email', $bccEmail ) ) != null )
		{
			foreach( (array) $bccEmailAccount as $emailAddr ) {
				$msg->addBcc( $emailAddr );
			}
		}


		/** client/html/email/account/standard/template-header
		 * Relative path to the HTML header template of the account creation e-mail client.
		 *
		 * The template file contains the HTML code and processing instructions
		 * to generate the HTML code that is inserted into the HTML page header
		 * of the rendered page in the frontend. The configuration string is the
		 * path to the template file relative to the templates directory (usually
		 * in client/html/templates).
		 *
		 * You can overwrite the template file configuration in extensions and
		 * provide alternative templates. These alternative templates should be
		 * named like the default one but with the string "standard" replaced by
		 * an unique name. You may use the name of your project for this. If
		 * you've implemented an alternative client class as well, "standard"
		 * should be replaced by the name of the new class.
		 *
		 * The product notification e-mail HTML client allows to use a different template for
		 * each account status value. You can create a template for each account
		 * status and store it in the "email/account/<status number>/" directory
		 * below the "templates" directory (usually in client/html/templates). If no
		 * specific layout template is found, the common template in the
		 * "email/account/" directory is used.
		 *
		 * @param string Relative path to the template creating code for the HTML page head
		 * @since 2015.09
		 * @category Developer
		 * @see client/html/email/account/standard/template-body
		 */
		$tplconf = 'client/html/email/account/standard/template-header';

		return $view->render( $view->config( $tplconf, 'email/account/header-standard' ) ); ;
	}
1206939
protected function getBaseUser($uid)
    {
        $query = "SELECT email, password, isactive FROM {$this->config->table_users} WHERE id = :id";
        $query_prepared = $this->dbh->prepare($query);
        $query_prepared->execute(['id' => $uid]);

        $data = $query_prepared->fetch(\PDO::FETCH_ASSOC);

        if (!$data) {
            return false;
        }

        $data['uid'] = $uid;

        return $data;
    }
928932
protected function _getCid($mailbox)
    {
        return implode(self::CID_SEPARATOR, array(
            'horde_imap_client',
            $this->_params['username'],
            $mailbox,
            $this->_params['hostspec'],
            $this->_params['port']
        ));
    }
888523
protected function _getUidByMessageId($mailbox, $msgid)
    {
        if (!$msgid) {
            return null;
        }

        $query = new Horde_Imap_Client_Search_Query();
        $query->headerText('Message-ID', $msgid);
        $res = $this->search($mailbox, $query, array(
            'results' => array(Horde_Imap_Client::SEARCH_RESULTS_MAX)
        ));

        return $res['max'];
    }
468841
public function getGoogleBatchServiceGmailForUserId(string $userId)
    {
        $email = $this->directory->resolvePrimaryEmailFromUserId($userId);
        if (array_key_exists($email, $this->googleBatchServiceGmails)) {
            return $this->googleBatchServiceGmails[$email];
        }

        $googleServiceGmail = new \Google_Service_Gmail($this->serviceAccount->getGoogleBatchClientForEmail($email));
        $this->googleBatchServiceGmails[$email] = $googleServiceGmail;

        return $googleServiceGmail;
    }
398793
public function subscribeMailbox($name = '') {
        if (empty($name)) {
            return false;
        }

        $name = imap_utf7_encode($name);
        return imap_subscribe ( $this->conn, "{".$this->settings['server']."}INBOX.".$name );
    }
1363262
public function copy($mailbox, $options = 0) {
        $this->client->openFolder($this->folder_path);
        return imap_mail_copy($this->client->getConnection(), $this->msglist, $mailbox, $options);
    }
1216233
function change_flag($mailbox, $uids, $flag, $enabled = false)
    {
        if (empty($uids)) {
            return;
        }

        if (!($this->mode & self::MODE_MESSAGE)) {
            return;
        }

        $flag = strtoupper($flag);
        $idx  = (int) array_search($flag, $this->flags);
        $uids = (array) $uids;

        if (!$idx) {
            return;
        }

        // Internal cache update
        if (($message = $this->icache['__message'])
            && $message['mailbox'] === $mailbox
            && in_array($message['object']->uid, $uids)
        ) {
            $message['object']->flags[$flag] = $enabled;

            if (count($uids) == 1) {
                return;
            }
        }

        $binary_check = $this->db->db_provider == 'oracle' ? "BITAND(`flags`, %d)" : "(`flags` & %d)";

        $this->db->query(
            "UPDATE {$this->messages_table}"
            ." SET `expires` = ". ($this->ttl ? $this->db->now($this->ttl) : 'NULL')
            .", `flags` = `flags` ".($enabled ? "+ $idx" : "- $idx")
            ." WHERE `user_id` = ?"
                ." AND `mailbox` = ?"
                .(!empty($uids) ? " AND `uid` IN (".$this->db->array2list($uids, 'integer').")" : "")
                ." AND " . sprintf($binary_check, $idx) . ($enabled ? " = 0" : " = $idx"),
            $this->userid, $mailbox);
    }
1195517
public function getHeader( $uid = '' )
	{
		$view = $this->getObject()->addData( $this->getView() );

		$content = '';
		foreach( $this->getSubClients() as $subclient ) {
			$content .= $subclient->setView( $view )->getHeader( $uid );
		}
		$view->subscriptionHeader = $content;


		$addr = $view->extAddressItem;

		$msg = $view->mail();
		$msg->addHeader( 'X-MailGenerator', 'Aimeos' );
		$msg->addTo( $addr->getEMail(), $addr->getFirstName() . ' ' . $addr->getLastName() );


		/** client/html/email/from-name
		 * @see client/html/email/subscription/from-email
		 */
		$fromName = $view->config( 'client/html/email/from-name' );

		/** client/html/email/subscription/from-name
		 * Name used when sending subscription e-mails
		 *
		 * The name of the person or e-mail subscription that is used for sending all
		 * shop related subscription e-mails to customers. This configuration option
		 * overwrite the name set in "client/html/email/from-name".
		 *
		 * @param string Name shown in the e-mail
		 * @since 2018.04
		 * @category User
		 * @see client/html/email/from-name
		 * @see client/html/email/from-email
		 * @see client/html/email/reply-email
		 * @see client/html/email/bcc-email
		 */
		$fromNameSubscription = $view->config( 'client/html/email/subscription/from-name', $fromName );

		/** client/html/email/from-email
		 * @see client/html/email/subscription/from-email
		 */
		$fromEmail = $view->config( 'client/html/email/from-email' );

		/** client/html/email/subscription/from-email
		 * E-Mail address used when sending subscription e-mails
		 *
		 * The e-mail address of the person or subscription that is used for sending
		 * all shop related product notification e-mails to customers. This configuration option
		 * overwrites the e-mail address set via "client/html/email/from-email".
		 *
		 * @param string E-mail address
		 * @since 2018.04
		 * @category User
		 * @see client/html/email/subscription/from-name
		 * @see client/html/email/from-email
		 * @see client/html/email/reply-email
		 * @see client/html/email/bcc-email
		 */
		if( ( $fromEmailSubscription = $view->config( 'client/html/email/subscription/from-email', $fromEmail ) ) != null ) {
			$msg->addFrom( $fromEmailSubscription, $fromNameSubscription );
		}


		/** client/html/email/reply-name
		 * @see client/html/email/subscription/reply-email
		 */
		$replyName = $view->config( 'client/html/email/reply-name', $fromName );

		/** client/html/email/subscription/reply-name
		 * Recipient name displayed when the customer replies to subscription e-mails
		 *
		 * The name of the person or e-mail subscription the customer should
		 * reply to in case of subscription related questions or problems. This
		 * configuration option overwrites the name set via
		 * "client/html/email/reply-name".
		 *
		 * @param string Name shown in the e-mail
		 * @since 2018.04
		 * @category User
		 * @see client/html/email/subscription/reply-email
		 * @see client/html/email/reply-name
		 * @see client/html/email/reply-email
		 * @see client/html/email/from-email
		 * @see client/html/email/bcc-email
		 */
		$replyNameSubscription = $view->config( 'client/html/email/subscription/reply-name', $replyName );

		/** client/html/email/reply-email
		 * @see client/html/email/subscription/reply-email
		 */
		$replyEmail = $view->config( 'client/html/email/reply-email', $fromEmail );

		/** client/html/email/subscription/reply-email
		 * E-Mail address used by the customer when replying to subscription e-mails
		 *
		 * The e-mail address of the person or e-mail subscription the customer
		 * should reply to in case of subscription related questions or problems.
		 * This configuration option overwrites the e-mail address set via
		 * "client/html/email/reply-email".
		 *
		 * @param string E-mail address
		 * @since 2018.04
		 * @category User
		 * @see client/html/email/subscription/reply-name
		 * @see client/html/email/reply-email
		 * @see client/html/email/from-email
		 * @see client/html/email/bcc-email
		 */
		if( ( $replyEmailSubscription = $view->config( 'client/html/email/subscription/reply-email', $replyEmail ) ) != null ) {
			$msg->addReplyTo( $replyEmailSubscription, $replyNameSubscription );
		}


		/** client/html/email/bcc-email
		 * @see client/html/email/subscription/bcc-email
		 */
		$bccEmail = $view->config( 'client/html/email/bcc-email' );

		/** client/html/email/subscription/bcc-email
		 * E-Mail address all subscription e-mails should be also sent to
		 *
		 * Using this option you can send a copy of all subscription related e-mails
		 * to a second e-mail subscription. This can be handy for testing and checking
		 * the e-mails sent to customers.
		 *
		 * It also allows shop owners with a very small volume of orders to be
		 * notified about subscription changes. Be aware that this isn't useful if the
		 * order volumne is high or has peeks!
		 *
		 * This configuration option overwrites the e-mail address set via
		 * "client/html/email/bcc-email".
		 *
		 * @param string|array E-mail address or list of e-mail addresses
		 * @since 2018.04
		 * @category User
		 * @category Developer
		 * @see client/html/email/bcc-email
		 * @see client/html/email/reply-email
		 * @see client/html/email/from-email
		 */
		if( ( $bccEmailSubscription = $view->config( 'client/html/email/subscription/bcc-email', $bccEmail ) ) != null )
		{
			foreach( (array) $bccEmailSubscription as $emailAddr ) {
				$msg->addBcc( $emailAddr );
			}
		}


		/** client/html/email/subscription/standard/template-header
		 * Relative path to the HTML header template of the subscription e-mail client.
		 *
		 * The template file contains the HTML code and processing instructions
		 * to generate the HTML code that is inserted into the HTML page header
		 * of the rendered page in the frontend. The configuration string is the
		 * path to the template file relative to the templates directory (usually
		 * in client/html/templates).
		 *
		 * You can overwrite the template file configuration in extensions and
		 * provide alternative templates. These alternative templates should be
		 * named like the default one but with the string "standard" replaced by
		 * an unique name. You may use the name of your project for this. If
		 * you've implemented an alternative client class as well, "standard"
		 * should be replaced by the name of the new class.
		 *
		 * The product notification e-mail HTML client allows to use a different template for
		 * each subscription status value. You can create a template for each subscription
		 * status and store it in the "email/subscription/<status number>/" directory
		 * below the "templates" directory (usually in client/html/templates). If no
		 * specific layout template is found, the common template in the
		 * "email/subscription/" directory is used.
		 *
		 * @param string Relative path to the template creating code for the HTML page head
		 * @since 2018.04
		 * @category Developer
		 * @see client/html/email/subscription/standard/template-body
		 */
		$tplconf = 'client/html/email/subscription/standard/template-header';

		return $view->render( $view->config( $tplconf, 'email/subscription/header-standard' ) ); ;
	}
574770
public static function NewGuid()
    {
        if (function_exists('com_create_guid')) {
            return trim(com_create_guid(), "{}");
        } else {
            $charid = strtoupper(bin2hex(openssl_random_pseudo_bytes(16)));
            $hyphen = chr(45);
            $uuid = substr($charid, 0, 8) . $hyphen . substr($charid, 8, 4) . $hyphen . substr($charid, 12, 4) . $hyphen . substr($charid, 16, 4) . $hyphen . substr($charid, 20, 12);
            return $uuid;
        }
    }
1170187
public static function getBox($box)
    {
        return isset(self::$data[$box]) ? self::$data[$box] : null;
    }
224731
protected function _loadUids($mailbox, $uids, $uidvalid = null)
    {
        if (!isset($this->_data[$mailbox])) {
            $this->_data[$mailbox] = array();
        }

        $this->_loadSliceMap($mailbox, $uidvalid);

        if (!empty($uids)) {
            foreach (array_unique(array_intersect_key($this->_slicemap[$mailbox]['s'], array_flip($uids))) as $slice) {
                $this->_loadSlice($mailbox, $slice);
            }
        }
    }