本文整理汇总了PHP中CAgent::addAgent方法的典型用法代码示例。如果您正苦于以下问题:PHP CAgent::addAgent方法的具体用法?PHP CAgent::addAgent怎么用?PHP CAgent::addAgent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CAgent
的用法示例。
在下文中一共展示了CAgent::addAgent方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: InstallDB
function InstallDB($install_wizard = true)
{
global $DB, $DBType, $APPLICATION;
$errors = null;
if (!$DB->Query("SELECT 'x' FROM b_disk_storage", true)) {
$errors = $DB->RunSQLBatch($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/disk/install/db/" . $DBType . "/install.sql");
}
$this->InstallTasks();
if (!empty($errors)) {
$APPLICATION->ThrowException(implode("", $errors));
return false;
}
$isWebdavInstalled = isModuleInstalled('webdav');
$this->RegisterModuleDependences(!$isWebdavInstalled);
RegisterModule("disk");
$this->InstallUserFields();
/** @noinspection PhpDynamicAsStaticMethodCallInspection */
CAgent::addAgent('\\Bitrix\\Disk\\ExternalLink::removeExpiredWithTypeAuto();', 'disk', 'N');
/** @noinspection PhpDynamicAsStaticMethodCallInspection */
CAgent::addAgent('\\Bitrix\\Disk\\Bitrix24Disk\\UploadFileManager::removeIrrelevant();', 'disk', 'N');
if (!$isWebdavInstalled) {
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/disk/lib/configuration.php";
\Bitrix\Main\Config\Option::set('disk', 'successfully_converted', 'Y');
\Bitrix\Main\Config\Option::set('disk', 'disk_revision_api', \Bitrix\Disk\Configuration::REVISION_API);
} else {
\CAdminNotify::add(array("MESSAGE" => Loc::getMessage("DISK_NOTIFY_MIGRATE_WEBDAV", array("#LINK#" => "/bitrix/admin/disk_from_webdav_convertor.php?lang=" . \Bitrix\Main\Application::getInstance()->getContext()->getLanguage())), "TAG" => "disk_migrate_from_webdav", "MODULE_ID" => "disk", "ENABLE_CLOSE" => "N"));
}
return true;
}
示例2: checkMailDomain
public static function checkMailDomain($service_id, $user_id, $cnt = 1)
{
$service_id = intval($service_id);
$user_id = intval($user_id);
$cnt = intval($cnt);
if (!CModule::includeModule('mail')) {
return '';
}
$arAdmin = CUser::getList($by, $order, array('ID' => $user_id, 'GROUPS_ID' => 1, 'ACTIVE' => 'Y'), array('FIELDS' => array('ID', 'TIME_ZONE_OFFSET')))->fetch();
if (empty($arAdmin)) {
return '';
}
$service = \Bitrix\Mail\MailServicesTable::getList(array('filter' => array('=ID' => $service_id)))->fetch();
if (empty($service) || $service['ACTIVE'] != 'Y' || !in_array($service['SERVICE_TYPE'], array('domain', 'crdomain'))) {
return '';
}
if ($service['SERVICE_TYPE'] == 'domain') {
$result = CMailDomain2::getDomainStatus($service['TOKEN'], $service['SERVER']);
$stage = empty($result['stage']) ? null : $result['stage'];
} else {
$crResponse = CControllerClient::executeEvent('OnMailControllerCheckMemberDomain', array('DOMAIN' => $service['SERVER']));
$stage = empty($crResponse['result']['stage']) ? null : $crResponse['result']['stage'];
}
if (!in_array($stage, array('none', 'owner-check', 'mx-check', 'added'))) {
return false;
} else {
if (in_array($stage, array('none', 'added'))) {
if ($stage == 'added') {
if (CModule::includeModule('im')) {
includeModuleLangFile(__FILE__);
$siteUrl = sprintf('http%s://%s%s', CMain::isHTTPS() ? 's' : '', $_SERVER['SERVER_NAME'], in_array($_SERVER['SERVER_PORT'], array(80, 443)) ? '' : ':' . $_SERVER['SERVER_PORT']);
CIMNotify::add(array('TO_USER_ID' => $user_id, 'FROM_USER_ID' => 0, 'NOTIFY_TYPE' => IM_NOTIFY_SYSTEM, 'NOTIFY_MODULE' => 'intranet', 'NOTIFY_MESSAGE' => str_replace(array('#DOMAIN#', '#SERVER#'), array(htmlspecialcharsbx($service['SERVER']), $siteUrl), getMessage('INTR_MAIL_DOMAINREADY_NOTICE'))));
}
$timeout = new DateTime(intval($arAdmin['TIME_ZONE_OFFSET']) . ' seconds +7 days');
if ($timeout->format('N') > 5) {
$timeout->modify('next monday');
}
CAgent::addAgent('CIntranetUtils::notifyMailDomain("nomailbox", ' . $service_id . ', ' . $user_id . ');', 'intranet', 'N', $timeout->getTimestamp() - intval($arAdmin['TIME_ZONE_OFFSET']) - time());
}
return '';
} else {
if ($cnt > 100) {
return '';
}
global $pPERIOD;
$pPERIOD = $pPERIOD * $cnt;
if ($pPERIOD > 3600 * 4) {
$pPERIOD = 3600 * 4;
}
return 'CIntranetUtils::checkMailDomain(' . $service_id . ', ' . $user_id . ', ' . ++$cnt . ');';
}
}
}
示例3: clean
public function clean($baseDir, $initDir = false, $filename = false)
{
if (strlen($filename)) {
$documentRoot = \Bitrix\Main\Application::getDocumentRoot();
$fn = IO\Path::combine($documentRoot, $baseDir, $initDir, $filename);
$file = new IO\File($fn);
//This checks for Zend Server CE in order to supress warnings
if (function_exists('accelerator_reset')) {
try {
$file->markWritable();
if ($file->delete()) {
\Bitrix\Main\Application::resetAccelerator();
return true;
}
} catch (\Exception $ex) {
}
} else {
if ($file->isExists()) {
$file->markWritable();
if ($file->delete()) {
\Bitrix\Main\Application::resetAccelerator();
return true;
}
}
}
return false;
} else {
static $bAgentAdded = false;
$bDelayedDelete = false;
$source = IO\Path::combine($baseDir, $initDir);
$sourceDir = new IO\Directory(IO\Path::convertRelativeToAbsolute($source));
if ($sourceDir->isExists()) {
$target = $source . ".~";
for ($i = 0; $i < 9; $i++) {
$suffix = rand(0, 999999);
$targetDir = new IO\Directory(IO\Path::convertRelativeToAbsolute($target . $suffix));
if (!$targetDir->isExists()) {
$con = \Bitrix\Main\Application::getDbConnection();
$res = $con->queryExecute("INSERT INTO b_cache_tag (SITE_ID, CACHE_SALT, RELATIVE_PATH, TAG)\n\t\t\t\t\t\t\tVALUES ('*', '*', '" . $con->getSqlHelper()->forSql($target . $suffix) . "', '*')");
if ($res) {
if ($sourceDir->rename($targetDir->getPath())) {
$bDelayedDelete = true;
}
}
break;
}
}
}
if ($bDelayedDelete) {
if (!$bAgentAdded) {
$bAgentAdded = true;
/* TODO: јгенты */
$rsAgents = \CAgent::getList(array("ID" => "DESC"), array("NAME" => "CacheEngineFiles::delayedDelete(%"));
if (!$rsAgents->fetch()) {
$res = \CAgent::addAgent("CacheEngineFiles::delayedDelete();", "main", "Y", 1);
}
}
} else {
$sourceDir->delete();
}
\Bitrix\Main\Application::resetAccelerator();
}
}
示例4: executeDomainPage
private function executeDomainPage()
{
global $USER, $APPLICATION;
$APPLICATION->setTitle(GetMessage('INTR_MAIL_DOMAIN_PAGE_TITLE'));
if (!$USER->isAdmin() && !$USER->canDoOperation('bitrix24_config')) {
$APPLICATION->AuthForm(GetMessage('ACCESS_DENIED'));
return;
}
$errors = array();
$status = false;
$serviceId = null;
$settings = array();
$services = CIntranetMailSetupHelper::getMailServices();
if ($domainService = CIntranetMailSetupHelper::getDomainService()) {
$serviceId = $domainService['id'];
$settings = array('type' => $domainService['type'], 'domain' => $domainService['server'], 'flags' => $domainService['flags'], 'token' => $domainService['token'], 'public' => $domainService['encryption'] == 'N' ? 'Y' : 'N');
}
if ($serviceId) {
$status = self::checkDomainStatus($settings, $error);
// не нужно при посте
if ($error) {
$errors[] = $error;
}
}
if ($_SERVER['REQUEST_METHOD'] == 'POST' && !empty($_POST['act'])) {
$errors = array();
if (!check_bitrix_sessid()) {
$errors[] = GetMessage('INTR_MAIL_CSRF');
}
if (!empty($errors)) {
} else {
if ($_POST['act'] == 'save') {
if (empty($_REQUEST['type']) || !in_array($_REQUEST['type'], array('delegate', 'connect'))) {
$errors[] = GetMessage('INTR_MAIL_FORM_ERROR');
}
if (empty($errors)) {
if (!$serviceId && empty($_REQUEST['domain'])) {
$errors[] = GetMessage('INTR_MAIL_INP_DOMAIN_EMPTY');
}
if ($_REQUEST['type'] == 'connect' && empty($_REQUEST['token'])) {
$errors[] = GetMessage('INTR_MAIL_INP_TOKEN_EMPTY');
}
if (!$serviceId) {
$settings['type'] = $_REQUEST['type'] == 'connect' ? 'domain' : 'crdomain';
$settings['domain'] = $_REQUEST['domain'];
}
if ($settings['type'] == 'domain') {
$settings['token'] = $_REQUEST['token'];
}
$settings['public'] = isset($_REQUEST['public']) && $_REQUEST['public'] == 'Y' ? 'Y' : 'N';
if (empty($errors)) {
$status = self::checkDomainStatus($settings, $error);
if ($error) {
$errors[] = $error;
}
if (empty($errors)) {
if ($serviceId) {
$result = \Bitrix\Mail\MailServicesTable::update($serviceId, array('TOKEN' => $settings['token'], 'ENCRYPTION' => $settings['public'] == 'Y' ? 'N' : 'Y'));
} else {
$result = \Bitrix\Mail\MailServicesTable::add(array('SITE_ID' => SITE_ID, 'ACTIVE' => 'Y', 'SERVICE_TYPE' => $settings['type'], 'NAME' => $settings['domain'], 'SERVER' => $settings['domain'], 'ENCRYPTION' => $settings['public'] == 'Y' ? 'N' : 'Y', 'SORT' => $serviceId ? $services[$serviceId]['sort'] + 1 : 100, 'TOKEN' => $settings['token']));
if ($result->isSuccess()) {
$serviceId = $result->getId();
if ($settings['type'] == 'domain') {
if ($status['stage'] == 'added') {
CAgent::addAgent('CIntranetUtils::notifyMailDomain("nomailbox", ' . $serviceId . ', ' . $USER->getId() . ');', 'intranet', 'N', 3600 * 24 * 7);
} else {
CAgent::addAgent('CIntranetUtils::checkMailDomain(' . $serviceId . ', ' . $USER->getId() . ');', 'intranet', 'N', 600);
CAgent::addAgent('CIntranetUtils::notifyMailDomain("nocomplete", ' . $serviceId . ', ' . $USER->getId() . ');', 'intranet', 'N', 3600 * 24 * 3);
}
CMailDomain2::setDomainLogo($settings['token'], $settings['domain'], $_SERVER['DOCUMENT_ROOT'] . $this->getPath() . '/images/' . GetMessage('INTR_MAIL_DOMAIN_ICON'), $replace = false, $error);
CMailDomain2::selLocale($settings['token'], $settings['domain'], LANGUAGE_ID, $error);
}
}
}
if ($result->isSuccess()) {
if ($status['stage'] == 'added') {
LocalRedirect($APPLICATION->GetCurPage() . '?page=manage');
}
} else {
$errors[] = GetMessage('INTR_MAIL_SAVE_ERROR');
}
}
}
}
} else {
if ($serviceId && $_POST['act'] == 'remove') {
$result = \Bitrix\Mail\MailServicesTable::delete($serviceId);
if ($result->isSuccess()) {
LocalRedirect($APPLICATION->GetCurPage() . '?page=home');
} else {
LocalRedirect($APPLICATION->GetCurPage() . '?page=domain');
}
}
}
}
}
$this->arParams['SERVICES'] = $services;
$this->arResult['SERVICE'] = $serviceId;
$this->arResult['SETTINGS'] = $settings;
$this->arResult['ERRORS'] = $errors;
//.........这里部分代码省略.........
示例5: executeDomainCreate
private static function executeDomainCreate(&$error)
{
global $USER;
$error = false;
if (!check_bitrix_sessid()) {
$error = GetMessage('INTR_MAIL_CSRF');
}
if ($error === false) {
if (CIntranetMailSetupHelper::getDomainService()) {
$error = GetMessage('INTR_MAIL_AJAX_ERROR');
}
}
if ($error === false) {
$crResponse = CControllerClient::ExecuteEvent('OnMailControllerAddMemberDomain', array('DOMAIN' => $_REQUEST['domain']));
if (!isset($crResponse['result'])) {
$error = empty($crResponse['error']) ? GetMessage('INTR_MAIL_CONTROLLER_INVALID') : CMail::getErrorMessage($crResponse['error']);
} else {
$result = $crResponse['result'];
if (!is_array($result)) {
$error = GetMessage('INTR_MAIL_CONTROLLER_INVALID');
}
if (!isset($result['stage']) || !in_array($result['stage'], array('owner-check', 'mx-check', 'added'))) {
$error = GetMessage('INTR_MAIL_CONTROLLER_INVALID');
} else {
if ($result['stage'] == 'owner-check' && (!isset($result['secrets']['name']) || !isset($result['secrets']['content']))) {
$error = GetMessage('INTR_MAIL_CONTROLLER_INVALID');
}
}
if ($error === false) {
$domainStage = $result['stage'];
if ($result['stage'] == 'owner-check') {
$domainSecrets = array('name' => $result['secrets']['name'], 'content' => $result['secrets']['content']);
}
}
}
if ($error === false) {
$result = \Bitrix\Mail\MailServicesTable::add(array('SITE_ID' => SITE_ID, 'ACTIVE' => 'Y', 'SERVICE_TYPE' => 'crdomain', 'NAME' => $_REQUEST['domain'], 'SERVER' => $_REQUEST['domain'], 'ENCRYPTION' => $_REQUEST['public'] == 'Y' ? 'N' : 'Y'));
if ($result->isSuccess()) {
CAgent::addAgent('CIntranetUtils::checkMailDomain(' . $result->getId() . ', ' . $USER->getId() . ');', 'intranet', 'N', 600);
CAgent::addAgent('CIntranetUtils::notifyMailDomain("nocomplete", ' . $result->getId() . ', ' . $USER->getId() . ');', 'intranet', 'N', 3600 * 24 * 3);
}
if (!$result->isSuccess()) {
$error = GetMessage('INTR_MAIL_SAVE_ERROR');
}
}
}
return array('stage' => isset($domainStage) ? $domainStage : '', 'secrets' => isset($domainSecrets) ? $domainSecrets : '');
}