Returns a list of emails given a uid or set of uids

@param *number|array $uid  A list of uid/s
@param bool          $body Whether to also include the body

@return array
162192
public function getUniqueEmails($uid, $body = false)
    {
        Argument::i()
            ->test(1, 'int', 'string', 'array')
            ->test(2, 'bool');

        //if not connected
        if (!$this->socket) {
            //then connect
            $this->connect();
        }

        //if the total in this mailbox is 0
        //it means they probably didn't select a mailbox
        //or the mailbox selected is empty
        if ($this->total == 0) {
            //we might as well return an empty array
            return array();
        }

        //if uid is an array
        if (is_array($uid)) {
            $uid = implode(',', $uid);
        }

        //lets call it
        $items = array('UID', 'FLAGS', 'BODY[HEADER]');

        if ($body) {
            $items = array('UID', 'FLAGS', 'BODY[]');
        }

        $first = is_numeric($uid) ? true : false;

        return $this->getEmailResponse('UID FETCH', array($uid, $this->getList($items)), $first);
    }
1201059
public function getHeader( $uid = '' )
	{
		$html = '';

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

		return $html;
	}
748107
public function getRecords($uid, $type=null)
	{
		$entries = self::all()
			->whereEquals('uid', $uid);

		if ($type)
		{
			$entries->whereEquals('type', $type);
		}

		return $entries
			->order('priority', 'asc')
			->rows();
	}
480069
public function getBody( $uid = '' )
	{
		$view = $this->getView();
		$step = $view->get( 'standardStepActive' );
		$onepage = $view->config( 'client/html/checkout/standard/onepage', [] );

		if( $step != 'summary' && !( in_array( 'summary', $onepage ) && in_array( $step, $onepage ) ) ) {
			return '';
		}

		$html = '';
		foreach( $this->getSubClients() as $subclient ) {
			$html .= $subclient->setView( $view )->getBody( $uid );
		}
		$view->summaryBody = $html;

		/** client/html/checkout/standard/summary/standard/template-body
		 * Relative path to the HTML body template of the checkout standard summary client.
		 *
		 * The template file contains the HTML code and processing instructions
		 * to generate the result shown in the body of 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.
		 *
		 * @param string Relative path to the template creating code for the HTML page body
		 * @since 2014.03
		 * @category Developer
		 * @see client/html/checkout/standard/summary/standard/template-header
		 */
		$tplconf = 'client/html/checkout/standard/summary/standard/template-body';
		$default = 'checkout/standard/summary-body-standard';

		return $view->render( $view->config( $tplconf, $default ) );
	}
599846
public function getAllThreadIdsForUser($uid) {
    $query = 'SELECT DISTINCT(thread.id), MAX(thread.updated) ' .
      'FROM {private_message_threads} AS thread ' .
      'JOIN {private_message_thread__members} AS member ' .
      'ON member.entity_id = thread.id AND member.members_target_id = :uid ' .
      'JOIN {private_message_thread__private_messages} AS thread_messages ' .
      'ON thread_messages.entity_id = thread.id ' .
      'JOIN {private_messages} AS messages ' .
      'ON messages.id = thread_messages.private_messages_target_id ' .
      'JOIN {private_message_thread__last_delete_time} AS thread_delete_time ' .
      'ON thread_delete_time.entity_id = thread.id ' .
      'JOIN {pm_thread_delete_time} as owner_delete_time ' .
      'ON owner_delete_time.id = thread_delete_time.last_delete_time_target_id AND owner_delete_time.owner = :uid ' .
      'WHERE owner_delete_time.delete_time <= messages.created ';
    $vars = [':uid' => $uid];

    $query .= 'GROUP BY thread.id ORDER BY MAX(thread.updated) DESC, thread.id';

    $thread_ids = $this->database->query(
      $query,
      $vars
    )->fetchCol();

    return is_array($thread_ids) ? $thread_ids : [];
  }
874758
protected function sortByUids($uids, $contents)
    {
        $uids = (array) $uids;

        $orderedUids = [];
        foreach ($uids as $key => $uid) {
            $orderedUids[$uid] = $key;
        }

        $formattedResult = [];
        foreach ($contents as $content) {
            if (isset($orderedUids[$content->getUid()])) {
                $formattedResult[$orderedUids[$content->getUid()]] = $content;
            }
        }

        ksort($formattedResult);

        return $formattedResult;
    }
360650
public static function getGroupMemberRoles($uid, $gid)
	{
		$db = \App::get('db');
		$sql = "SELECT r.id, r.name, r.permissions FROM `#__xgroups_roles` as r, `#__xgroups_member_roles` as m WHERE r.id=m.roleid AND m.uidNumber=" . $db->quote($uid) . " AND r.gidNumber=" . $db->quote($gid);
		$db->setQuery($sql);

		return $db->loadAssocList();
	}
795705
public function getStructure($mailbox, $id, $is_uid = false)
    {
        $result = $this->fetch($mailbox, $id, $is_uid, array('BODYSTRUCTURE'));

        if (is_array($result)) {
            $result = array_shift($result);
            return $result->bodystructure;
        }

        return false;
    }
528901
public function getGroups( $uid ) {
        static $groups = [];
        if ( isset($groups[$uid]) )
            return $groups[$uid];
        $user_groups = Db::table( $this->prefix.$this->_config['auth_group_access'] )
            ->alias('a')
            ->join( $this->prefix.$this->_config['auth_group']." g", "g.id=a.group_id" )
            ->where( "a.uid='$uid' and g.status='1'" )
            ->field( 'uid,group_id,title,rules' )->select();
        $groups[$uid] = $user_groups ? $user_groups : [];
        return $groups[$uid];
    }
634764
public function getBody( $uid = '' )
	{
		$view = $this->getView();

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

		/** client/html/email/subscription/text/standard/template-body
		 * Relative path to the text body template of the subscription email text client.
		 *
		 * The template file contains the text and processing instructions
		 * to generate the result shown in the body of the e-mail. 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 email subscription text 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 e-mail body
		 * @since 2018.04
		 * @category Developer
		 * @see client/html/email/subscription/text/standard/template-header
		 */
		$tplconf = 'client/html/email/subscription/text/standard/template-body';

		$text = $view->render( $view->config( $tplconf, 'email/subscription/text-body-standard' ) );
		$view->mail()->setBody( $text );
		return $text;
	}
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);
            }
        }
    }
893000
protected function getContentObject($uid)
    {
        $contentTable = 'tt_content';
        $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($contentTable);
        $queryBuilder
            ->select('*')
            ->from($contentTable)
            ->where($queryBuilder->expr()->eq('uid', $uid));
        $queryBuilder->getRestrictions()->removeAll();
        $data = $queryBuilder->execute()->fetch();

        $this->inlineHelper->addFilesToData($data, 'tt_content');
        $this->inlineHelper->addIrreToData($data);

        return $data;
    }
191148
public function getRoleUser($uid) {

        if (empty($this->roleUser)){

            $role_user_data = $this->config['auth_cache'] ? Session::get($this->getRoleUserKey()) : [];

            if (empty($role_user_data) || !is_array($role_user_data)){

                $where = [];
                $where['user_id'] = $uid;
                $role_user_list = Db::name($this->config['role_user'])
                    ->field('role_id')
                    ->where($where)
                    ->select();

                $role_user_data = array_column($role_user_list,'role_id');

                //dump($role_user_data);

                if (empty($role_user_data)) return false;

                if ($this->config['auth_cache'])
                    Session::set($this->getRoleUserKey(),$role_user_data);
            }

            $this->roleUser = $role_user_data;

        }

        return $this->roleUser;
    }
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' ) ); ;
	}
855693
public function list(int $departmentId, bool $fetchChild = false, bool $needDetail = false): array
    {
        $uri = 'user/' . ($needDetail ? 'list' : 'simplelist');

        return $this->httpClient->get($uri, ['department_id' => $departmentId, 'fetch_child' => (int)$fetchChild]);
    }
1333556
public function getAllGroupsForUser($uid) {
    $groups = &drupal_static(__FUNCTION__);

    // Get the memberships for the user if they aren't known yet.
    if (!isset($groups[$uid])) {
      $group_content_types = GroupContentType::loadByEntityTypeId('user');
      $group_content_types = array_keys($group_content_types);

      $query = $this->database->select('group_content_field_data', 'gcfd');
      $query->addField('gcfd', 'gid');
      $query->condition('gcfd.entity_id', $uid);
      $query->condition('gcfd.type', $group_content_types, 'IN');
      $query->execute()->fetchAll();

      $group_ids = $query->execute()->fetchAllAssoc('gid');
      $groups[$uid] = array_keys($group_ids);
    }

    return $groups[$uid];
  }
901098
public function searchByUid($uid) {
		$results = $this->ldap->search($this->basedn,
			$this->search_username . '=' . $uid);
		return $results;
	}