Get a list of mailboxes on the mail server.

@param  string $mailboxSearch Pattern from http://php.net/manual/en/function.imap-list.php
@param  bool $withConnection Will strip off connection string from mailboxes by default
@return array List of mailboxes
436021
public function mailboxes($mailboxSearch = '*', $withConnection = false)
    {
        $connectionString = $this->connectionString();
        $stream = imap_open($connectionString, $this->user, $this->password);
        $mailboxes = imap_list($stream, $connectionString, $mailboxSearch);

        if ($withConnection) {
            return $mailboxes;
        }

        return array_map(function ($mailbox) use ($connectionString) {
            return str_replace($connectionString, '', $mailbox);
        }, $mailboxes);
    }
1097462
public function getMailboxes()
    {
        if (!$this->socket) {
            $this->connect();
        }

        $response = $this->call('LIST', $this->escape('', '*'));

        $mailboxes = array();
        foreach ($response as $line) {
            if (strpos($line, 'Noselect') !== false || strpos($line, 'LIST') == false) {
                continue;
            }

            $line = explode('"', $line);

            if (strpos(trim($line[0]), '*') !== 0) {
                continue;
            }

            $mailbox = trim($line[count($line) - 2]);

            if ($mailbox == "/" || $mailbox == "") {
                $mailbox = $line[count($line) - 1];
            }

            //Fix mailbox name encoded with utf7
            $mailbox = ImapUtf7::decode(trim($mailbox));
            //Decoding utf8 string result
            $mailbox = utf8_decode($mailbox);

            $mailboxes[] = $mailbox;
        }

        return $mailboxes;
    }
750551
public function deleteAllHistoryEntries($withFiles = true)
    {
        $params = [
            'name'      => 'delete',
            'del_files' => $withFiles,
            'value'     => 'all'
        ];
        $url = $this->buildUrl('history', $params);

        $request = $this->guzzle->request('GET', $url);

        return json_decode($request->getBody(), true)['status'];
    }
571798
public function populateTree($depth = null, $with = null)
    {
        /** @var ActiveRecord[]|static[] $nodes */
        $query = $this->getDescendants($depth);
        if ($with) {
            $query->with($with);
        }
        $nodes = $query->all();

        $relates = [];
        foreach ($nodes as $node) {
            $path = $node->getParentPath(true);
            $key = array_pop($path);
            if (!isset($relates[$key])) {
                $relates[$key] = [];
            }
            $relates[$key][] = $node;
        }

        $ownerDepth = $this->owner->getAttribute($this->depthAttribute);
        $nodes[] = $this->owner;
        foreach ($nodes as $node) {
            $key = $node->getAttribute($this->itemAttribute);
            if (isset($relates[$key])) {
                $node->populateRelation('children', $relates[$key]);
            } elseif ($depth === null || $ownerDepth + $depth > $node->getAttribute($this->depthAttribute)) {
                $node->populateRelation('children', []);
            }
        }

        return $this->owner;
    }
902461
public function getVotesList ($tag = null, bool $with = true) : array
    {
        return $this->_Votes->getVotesList(VoteUtil::tagsConvert($tag), $with);
    }
980341
public function findPendingSynchronisationList(MailingList $mailingList)
    {
        return $this->createQueryBuilder('s')
            ->innerjoin('s.mailingList', 'm')
            ->where('s.mailingList = :mailingList')
            ->andWhere('s.status = :pending OR s.status = :failed')
            ->setParameters([
                'mailingList' => $mailingList,
                'pending' => Subscription::STATUS_PENDING,
                'failed' => Subscription::STATUS_FAILED,
            ])
            ->getQuery()
            ->getResult();
    }
166082
public function getHost(bool $withPort = true) : string
  {
      // Check for proxy first
      if ($host = $this->server('HTTP_X_FORWARDED_HOST')) {
          $host = last(explode(',', $host));
      } elseif (!$host = $this->server('HTTP_HOST')) {
          if (!$host = $this->server('HTTP_SERVER_NAME')) {
              $host = $this->server('HTTP_SERVER_ADDR');
          }
      }

      // trim and remove port number from host
      // host is lowercase as per RFC 952/2181
      $host = strtolower(preg_replace('/:\d+$/', '', trim($host)));

      if (!$withPort) {
          return $host;
      }

      // Port number
      $scheme = $this->getHttpScheme();
      $port = $this->getPort();
      
      $appendPort = ':' . $port;

      // Don't append port number if a normal port.
      if (($scheme == 'http' && $port == '80') || ($scheme == 'https' && $port == '443')) {
          $appendPort = '';
      }

      return $host . $appendPort;
  }
326559
public static function getRequiredFields(bool $withSchema = false) : array
    {
        return $withSchema ? self::$_requiredFields : array_keys(self::$_requiredFields);
    }
1345906
public function getAll(bool $withEmpties = true): array {
		$properties = get_object_vars($this);
		
		// our $errors property shouldn't be accessed except with the
		// specialized getErrors() method below.  so, we'll unset that
		// one here.
		
		unset($properties["errors"]);
		
		// if we do not want the empty properties, we can use the default
		// behavior of array_filter, which removes any values that appear
		// to be false-y, to get rid of them.
		
		if (!$withEmpties) {
			$properties = array_filter($properties);
		}
		
		return $properties;
	}
980248
public function getTableFields($table, $withPrefix = false)
    {
        $fullTable = $withPrefix ? $table : $this->getTable($table);
        if (isset($this->tableFields[$fullTable])) {
            return $this->tableFields[$fullTable];
        } else {
            $fields = array();
            switch ($this->driver) {
                case 'mysql':
                    $tableInfo = $this->fetchAll("SHOW COLUMNS FROM $fullTable");
                    $fields = $this->filter($tableInfo, 'Field');
                    break;

                case 'sqlite':
                    $tableInfo = $this->fetchAll("PRAGMA table_info($fullTable)");
                    $fields = $this->filter($tableInfo, 'name');
                    break;

                case 'pgsql':
                    $tableInfo = $this->fetchAll(
                        "SELECT column_name FROM INFORMATION_SCHEMA.COLUMNS
                        WHERE table_catalog = ? AND table_name = ?
                        ORDER BY dtd_identifier ASC",
                        array($this->dbname, $fullTable)
                    );
                    $fields = $this->filter($tableInfo, 'column_name');
            }
            if (empty($fields)) {
                // For SQLite and PostgreSQL
                throw new \PDOException(sprintf('Table or view "%s" not found', $fullTable));
            }
            return $this->tableFields[$table] = $fields;
        }
    }
1156835
public static function get_all_eventlist($withoutcomponent = false) {
        if ($withoutcomponent) {
            $return = array_merge(self::get_core_eventlist(), self::get_non_core_eventlist($withoutcomponent));
            array_multisort($return, SORT_NATURAL);
        } else {
            $return = array_merge(array('core' => self::get_core_eventlist()),
                    self::get_non_core_eventlist($withoutcomponent = false));
        }
        return $return;
    }
539276
public function get(string $id, bool $with_config = true): ?array
  {
    if ( bbn\str::is_uid($id) ){
      $cols = implode(', ', array_map(function($a){
        return $a;
      }, $this->fields));
      $table = $this->db->tsn($this->class_cfg['table'], true);
      $uid = $this->db->csn($this->fields['id'], true);
      $id_user = $this->db->csn($this->fields['id_user'], true);
      $id_group = $this->db->csn($this->fields['id_group'], true);
      $public = $this->db->csn($this->fields['public'], true);
      $sql = <<< MYSQL
SELECT $cols
FROM $table
WHERE $uid = UNHEX(?)
AND ($id_user = UNHEX(?)
OR $id_group = UNHEX(?)
OR $public = 1)
MYSQL;
      if ( $row = $this->db->get_row($sql, $id, $this->id_user, $this->id_group) ){
        $cfg = $row['cfg'];
        unset($row['cfg']);
        if ( ($cfg = json_decode($cfg, true)) && $with_config ){
          $row = bbn\x::merge_arrays($cfg, $row);
        }
        return $row;
      }
    }
    return null;
  }
339176
final public static function count(array $criteria = [], bool $withTrash = false)
    {
        $criteria = self::criteriaWithSoftDelete($criteria, $withTrash);
        return static::getRepository()
            ->count($criteria);
    }
321474
public function getBy(array $where = [], array $with = [])
    {
        $query = $this->make($with);

        $query = $this->applyWhere($query, $where);

        return $query->get();
    }
226246
public function getByEmail($emailaddress)
    {
        $emailaddress = (string) $emailaddress;
        return $this->rest->get($this->action, [
            'emailaddress' => $emailaddress
        ]);
    }
165553
public function getFieldValues($with_nulls = true)
    {
        $request_values = $this->getRequest()->all();

        $values = [];
        foreach ($this->getAllAttributes() as $attribute) {
            $value = Arr::get($request_values, $attribute);
            if ($with_nulls || $value !== null) {
                Arr::set($values, $attribute, $value);
            }
        }

        // If this form is a child form, cherry pick a part
        if ($prefix = $this->getName()) {
            $prefix = $this->formHelper->transformToDotSyntax($prefix);
            $values = Arr::get($values, $prefix);
        }

        // Allow form-specific value alters
        $this->formHelper->alterFieldValues($this, $values);

        return $values;
    }
1276287
public function toDTO($filterByKey = null)
    {
        if (! $this->getAttribute("recipient") || ! $this->getAttribute("mosaicId"))
            return [];

        return [
            "type" => $this->type,
            "recipient" => $this->recipient()->address()->toClean(),
            "mosaicId" => $this->mosaicId()->toDTO(),
            "fee" => $this->fee,
        ];
    }