Exemplo n.º 1
0
 function InstallDB($arParams = array())
 {
     global $DB, $DBType, $APPLICATION;
     $this->errors = false;
     // Database tables creation
     if (!$DB->Query("SELECT 'x' FROM b_mail_mailbox WHERE 1=0", true)) {
         $this->errors = $DB->RunSQLBatch($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/mail/install/db/" . strtolower($DB->type) . "/install.sql");
     }
     if ($this->errors !== false) {
         $APPLICATION->ThrowException(implode("<br>", $this->errors));
         return false;
     } else {
         RegisterModule("mail");
         if (CModule::IncludeModule("mail")) {
             $result = Bitrix\Mail\MailServicesTable::getList(array('filter' => array('ACTIVE' => 'Y')));
             if ($result->fetch() === false) {
                 $mailServices = array('gmail' => array('SERVER' => 'imap.gmail.com', 'PORT' => 993, 'ENCRYPTION' => 'Y', 'LINK' => 'https://mail.google.com/'), 'icloud' => array('SERVER' => 'imap.mail.me.com', 'PORT' => 993, 'ENCRYPTION' => 'Y', 'LINK' => 'https://www.icloud.com/#mail'), 'outlook.com' => array('SERVER' => 'imap-mail.outlook.com', 'PORT' => 993, 'ENCRYPTION' => 'Y', 'LINK' => 'https://www.outlook.com/owa'), 'office365' => array('SERVER' => 'outlook.office365.com', 'PORT' => 993, 'ENCRYPTION' => 'Y', 'LINK' => 'http://mail.office365.com/'), 'yahoo' => array('SERVER' => 'imap.mail.yahoo.com', 'PORT' => 993, 'ENCRYPTION' => 'Y', 'LINK' => 'http://mail.yahoo.com/'), 'aol' => array('SERVER' => 'imap.aol.com', 'PORT' => 993, 'ENCRYPTION' => 'Y', 'LINK' => 'http://mail.aol.com/'), 'yandex' => array('SERVER' => 'imap.yandex.ru', 'PORT' => 993, 'ENCRYPTION' => 'Y', 'LINK' => 'https://mail.yandex.ru/'), 'mail.ru' => array('SERVER' => 'imap.mail.ru', 'PORT' => 993, 'ENCRYPTION' => 'Y', 'LINK' => 'http://e.mail.ru/'), 'ukr.net' => array('SERVER' => 'imap.ukr.net', 'PORT' => 993, 'ENCRYPTION' => 'Y', 'LINK' => 'http://freemail.ukr.net/'), 'exchange' => array(), 'other' => array());
                 $mailServicesByLang = array('ru' => array(100 => 'gmail', 200 => 'outlook.com', 300 => 'icloud', 400 => 'office365', 500 => 'exchange', 600 => 'yahoo', 700 => 'aol', 800 => 'yandex', 900 => 'mail.ru', 1000 => 'ukr.net', 1100 => 'other'), 'ua' => array(100 => 'gmail', 200 => 'outlook.com', 300 => 'icloud', 400 => 'office365', 500 => 'exchange', 600 => 'yahoo', 700 => 'aol', 800 => 'yandex', 900 => 'mail.ru', 1000 => 'ukr.net', 1100 => 'other'), 'en' => array(100 => 'gmail', 200 => 'outlook.com', 300 => 'icloud', 400 => 'office365', 500 => 'exchange', 600 => 'yahoo', 700 => 'aol', 800 => 'other'), 'de' => array(100 => 'gmail', 200 => 'outlook.com', 300 => 'icloud', 400 => 'office365', 500 => 'exchange', 600 => 'yahoo', 700 => 'aol', 800 => 'other'));
                 $result = \Bitrix\Main\SiteTable::getList();
                 while (($site = $result->fetch()) !== false) {
                     if (CModule::IncludeModule('extranet') && CExtranet::IsExtranetSite($site['LID'])) {
                         continue;
                     }
                     $mailServicesList = isset($mailServicesByLang[$site['LANGUAGE_ID']]) ? $mailServicesByLang[$site['LANGUAGE_ID']] : $mailServicesByLang['en'];
                     foreach ($mailServicesList as $serviceSort => $serviceName) {
                         $serviceSettings = $mailServices[$serviceName];
                         $serviceSettings['SITE_ID'] = $site['LID'];
                         $serviceSettings['ACTIVE'] = 'Y';
                         $serviceSettings['SERVICE_TYPE'] = 'imap';
                         $serviceSettings['NAME'] = $serviceName;
                         $serviceSettings['SORT'] = $serviceSort;
                         Bitrix\Mail\MailServicesTable::add($serviceSettings);
                     }
                 }
             }
         }
         RegisterModuleDependences('rest', 'OnRestServiceBuildDescription', 'mail', 'CMailRestService', 'OnRestServiceBuildDescription');
         RegisterModuleDependences('main', 'OnAfterUserUpdate', 'mail', 'CMail', 'onUserUpdate');
         RegisterModuleDependences('main', 'OnAfterUserDelete', 'mail', 'CMail', 'onUserDelete');
         CAgent::AddAgent("CMailbox::CleanUp();", "mail", "N", 60 * 60 * 24);
         return true;
     }
 }
Exemplo n.º 2
0
}
global $USER, $APPLICATION;
$APPLICATION->SetTitle(GetMessage('NTR_MAIL_PAGE_TITLE'));
if (!CModule::IncludeModule('mail')) {
    ShowError(GetMessage('MAIL_MODULE_NOT_INSTALLED'));
    return;
}
if (!is_object($USER) || !$USER->IsAuthorized()) {
    $APPLICATION->AuthForm('');
    return;
}
$arParams['OPTIONS'] = array('link', 'server', 'port', 'encryption', 'login', 'password');
$result = Bitrix\Mail\MailServicesTable::getList(array('filter' => array('ACTIVE' => 'Y', '=SITE_ID' => SITE_ID), 'order' => array('SORT' => 'ASC', 'NAME' => 'ASC')));
$arParams['SERVICES'] = array();
while (($service = $result->fetch()) !== false) {
    $arParams['SERVICES'][$service['ID']] = array('name' => $service['NAME'], 'link' => $service['LINK'], 'icon' => Bitrix\Mail\MailServicesTable::getIconSrc($service['NAME'], $service['ICON']), 'server' => $service['SERVER'], 'port' => $service['PORT'], 'encryption' => $service['ENCRYPTION']);
}
if (empty($arParams['SERVICES'])) {
    ShowError(GetMessage('MAIL_SERVICES_NOT_FOUND'));
    return;
}
function CheckOption($option, $value, &$error)
{
    if (!in_array($option, array('encryption')) && empty($value)) {
        $error = GetMessage('INTR_MAIL_INP_' . strtoupper($option) . '_EMPTY');
    }
    if (empty($error)) {
        switch ($option) {
            case 'server':
                $regExp = '`(?:(?:http|https|ssl|tls|imap)://)?((?:[a-z0-9](?:-*[a-z0-9])*\\.?)+)`';
                if (preg_match($regExp, strtolower($value), $matches) && strlen($matches[1]) > 0) {
Exemplo n.º 3
0
 public static function mailserviceDelete($arParams)
 {
     global $USER;
     IncludeModuleLangFile(__FILE__);
     if (!$USER->CanDoOperation('bitrix24_config')) {
         throw new Exception(GetMessage('ACCESS_DENIED'));
     }
     if (empty($arParams['ID'])) {
         throw new Exception(GetMessage('MAIL_MAILSERVICE_EMPTY_ID'));
     }
     $result = Bitrix\Mail\MailServicesTable::getList(array('filter' => array('=ID' => $arParams['ID'], '=SITE_ID' => SITE_ID)));
     if (!$result->fetch()) {
         throw new Exception(GetMessage('MAIL_MAILSERVICE_EMPTY'));
     }
     $result = Bitrix\Mail\MailServicesTable::delete($arParams['ID']);
     if (!$result->isSuccess()) {
         throw new Exception(join('; ', $result->getErrorMessages()));
     }
     return true;
 }
Exemplo n.º 4
0
	function CheckFields($arFields, $ID=false)
	{
		global $APPLICATION;
		$arMsg = array();

		if (is_set($arFields, 'NAME') && strlen($arFields['NAME']) < 1)
		{
			CMailError::SetError('B_MAIL_ERR_NAME', GetMessage('MAIL_CL_ERR_NAME').' "'.GetMessage('MAIL_CL_NAME').'"');
			$arMsg[] = array('id' => 'NAME', 'text' => GetMessage('MAIL_CL_ERR_NAME').' "'.GetMessage('MAIL_CL_NAME').'"');
		}

		if (in_array(strtolower($arFields['SERVER_TYPE']), array('pop3', 'imap', 'controller', 'domain', 'crdomain')) && is_set($arFields, 'LOGIN') && strlen($arFields['LOGIN']) < 1)
		{
			CMailError::SetError('B_MAIL_ERR_LOGIN', GetMessage('MAIL_CL_ERR_NAME').' "'.GetMessage('MAIL_CL_LOGIN').'"');
			$arMsg[] = array('id' => 'LOGIN', 'text' => GetMessage('MAIL_CL_ERR_NAME').' "'.GetMessage('MAIL_CL_LOGIN').'"');
		}

		if (in_array(strtolower($arFields['SERVER_TYPE']), array('pop3', 'imap')) && is_set($arFields, 'PASSWORD') && strlen($arFields['PASSWORD']) < 1)
		{
			CMailError::SetError('B_MAIL_ERR_PASSWORD', GetMessage('MAIL_CL_ERR_NAME').' "'.GetMessage('MAIL_CL_PASSWORD').'"');
			$arMsg[] = array('id' => 'PASSWORD', 'text' => GetMessage('MAIL_CL_ERR_NAME').' "'.GetMessage('MAIL_CL_PASSWORD').'"');
		}

		if (strtolower($arFields['SERVER_TYPE']) == 'imap' && is_set($arFields, 'LINK') && strlen($arFields['LINK']) < 1)
		{
			CMailError::SetError('B_MAIL_ERR_LINK', GetMessage('MAIL_CL_ERR_NAME').' "'.GetMessage('MAIL_CL_LINK').'"');
			$arMsg[] = array('id' => 'LINK', 'text' => GetMessage('MAIL_CL_ERR_NAME').' "'.GetMessage('MAIL_CL_LINK').'"');
		}

		if (in_array(strtolower($arFields['SERVER_TYPE']), array('imap', 'controller', 'domain', 'crdomain')) && is_set($arFields, 'USER_ID') && strlen($arFields['USER_ID']) < 1)
		{
			CMailError::SetError('B_MAIL_ERR_USER_ID', GetMessage('MAIL_CL_ERR_NAME').' "'.GetMessage('MAIL_CL_USER_ID').'"');
			$arMsg[] = array('id' => 'USER_ID', 'text' => GetMessage('MAIL_CL_ERR_NAME').' "'.GetMessage('MAIL_CL_USER_ID').'"');
		}

		if (in_array(strtolower($arFields['SERVER_TYPE']), array('pop3', 'smtp', 'imap')) && is_set($arFields, 'SERVER') && strlen($arFields['SERVER']) < 1)
		{
			CMailError::SetError('B_MAIL_ERR_SERVER_NAME', GetMessage('MAIL_CL_ERR_NAME').' "'.GetMessage('MAIL_CL_SERVER').'"');
			$arMsg[] = array('id' => 'SERVER', 'text' => GetMessage('MAIL_CL_ERR_NAME').' "'.GetMessage('MAIL_CL_SERVER').'"');
		}
		elseif (strtolower($arFields['SERVER_TYPE']) == 'smtp')
		{
			$dbres = CMailBox::GetList(array(), array('ACTIVE' => 'Y', 'SERVER_TYPE' => 'smtp', 'SERVER' => $arFields['SERVER'], 'PORT' => $arFields['PORT']));
			while($arres = $dbres->Fetch())
			{
				if ($ID === false || $arres['ID'] != $ID)
				{
					CMailError::SetError('B_MAIL_ERR_SERVER_NAME',  GetMessage('B_MAIL_ERR_SN').' "'.GetMessage('MAIL_CL_SERVER').'"');
					$arMsg[] = array('id' => 'SERVER', 'text' => GetMessage('B_MAIL_ERR_SN').' "'.GetMessage('MAIL_CL_SERVER').'"');
					break;
				}
			}
		}

		if (is_set($arFields, 'LID'))
		{
			$r = CLang::GetByID($arFields['LID']);
			if (!$r->Fetch())
			{
				CMailError::SetError('B_MAIL_ERR_BAD_LANG', GetMessage('MAIL_CL_ERR_BAD_LANG'));
				$arMsg[] = array('id' => 'LID', 'text' => GetMessage('MAIL_CL_ERR_BAD_LANG'));
			}
		}
		elseif ($ID === false)
		{
			CMailError::SetError('B_MAIL_ERR_BAD_LANG_NA', GetMessage('MAIL_CL_ERR_BAD_LANG_NX'));
			$arMsg[] = array('id' => 'LID', 'text' => GetMessage('MAIL_CL_ERR_BAD_LANG_NX'));
		}

		if ($arFields['USER_ID'])
		{
			if (is_set($arFields, 'SERVICE_ID'))
			{
				$result = Bitrix\Mail\MailServicesTable::getList(array(
					'filter' => array('=SITE_ID' => $arFields['LID'], '=ID' => $arFields['SERVICE_ID'])
				));
				if (!$result->fetch())
				{
					CMailError::SetError('B_MAIL_ERR_BAD_SERVICE_ID', GetMessage('MAIL_CL_ERR_BAD_SERVICE_ID'));
					$arMsg[] = array('id' => 'SERVICE_ID', 'text' => GetMessage('MAIL_CL_ERR_BAD_SERVICE_ID'));
				}
			}
			else if ($ID === false)
			{
				CMailError::SetError('B_MAIL_ERR_BAD_SERVICE_ID_NA', GetMessage('MAIL_CL_ERR_BAD_SERVICE_ID_NX'));
				$arMsg[] = array('id' => 'SERVICE_ID', 'text' => GetMessage('MAIL_CL_ERR_BAD_SERVICE_ID_NX'));
			}
		}

		if (!empty($arMsg))
		{
			$e = new CAdminException($arMsg);
			$APPLICATION->ThrowException($e);
			return false;
		}

		return true;
	}
Exemplo n.º 5
0
    $aMenu[] = array("ICON" => "btn_new", "TEXT" => GetMessage("MAIL_MBOX_EDT_NEW"), "LINK" => "mail_mailbox_edit.php?lang=" . LANG);
    if ($MOD_RIGHT == "W") {
        $aMenu[] = array("TEXT" => GetMessage("MAIL_MBOX_EDT_DEL"), "ICON" => "btn_delete", "LINK" => "javascript:if(confirm('" . GetMessage("MAIL_MBOX_EDT_DEL_CONFIRM") . "'))window.location='mail_mailbox_admin.php?action=delete&ID=" . $ID . "&lang=" . LANG . "&" . bitrix_sessid_get() . "';");
    }
}
//echo ShowSubMenu($aMenu);
$context = new CAdminContextMenu($aMenu);
$context->Show();
$aTabs = array(array("DIV" => "edit1", "TAB" => GetMessage("MAIL_MBOX_EDT_TAB"), "ICON" => "mail_mailbox_edit", "TITLE" => $sDocTitle));
if (in_array($str_SERVER_TYPE, array('pop3', 'smtp'))) {
    $aTabs[] = array("DIV" => "edit2", "TAB" => GetMessage("MAIL_MBOX_EDT_TAB2"), "ICON" => "mail_mailbox_edit", "TITLE" => $sDocTitle);
}
$tabControl = new CAdminTabControl("tabControl", $aTabs);
if (in_array($str_SERVER_TYPE, array('imap', 'domain', 'crdomain', 'controller'))) {
    $mailServices = array();
    $result = Bitrix\Mail\MailServicesTable::getList(array('filter' => array('ACTIVE' => 'Y'), 'order' => array('SORT' => 'ASC', 'NAME' => 'ASC')));
    while (($service = $result->fetch()) !== false) {
        if (!isset($mailServices[$service['SITE_ID']])) {
            $mailServices[$service['SITE_ID']] = array();
        }
        $mailServices[$service['SITE_ID']][$service['ID']] = $service;
    }
}
?>

<?php 
if ($message) {
    echo $message->Show();
}
?>
<form method="POST" action="<?php 
                }
                $DB->Commit();
                break;
            case "activate":
            case "deactivate":
                $arFields = array('ACTIVE' => $_REQUEST['action'] == 'activate' ? 'Y' : 'N');
                if (!Bitrix\Mail\MailServicesTable::update($ID, $arFields)) {
                    if ($e = $APPLICATION->GetException()) {
                        $lAdmin->AddGroupError(GetMessage('SAVE_ERROR') . $ID . ": " . $e->GetString(), $ID);
                    }
                }
                break;
        }
    }
}
$rsData = Bitrix\Mail\MailServicesTable::getList(array('filter' => array_filter($arFilter), 'order' => array(strtoupper($by) => $order)));
$rsData = new CAdminResult($rsData, $sTableID);
$rsData->NavStart();
$lAdmin->NavText($rsData->GetNavPrint(GetMessage("MAIL_MSERVICE_ADM_TITLE")));
$arHeaders = array();
$arHeaders[] = array('id' => 'NAME', 'content' => GetMessage('MAIL_MSERVICE_ADM_NAME'), 'default' => true, 'sort' => 'name');
$arHeaders[] = array('id' => 'ACTIVE', 'content' => GetMessage('MAIL_MSERVICE_ADM_ACTIVE'), 'default' => true, 'sort' => 'active');
$arHeaders[] = array('id' => 'SERVER', 'content' => GetMessage('MAIL_MSERVICE_ADM_SERVER'), 'default' => true, 'sort' => 'server');
$arHeaders[] = array('id' => 'SERVICE_TYPE', 'content' => GetMessage('MAIL_MSERVICE_ADM_TYPE'), 'default' => true, 'sort' => 'service_type');
$arHeaders[] = array('id' => 'ID', 'content' => 'ID', 'default' => true, 'sort' => 'id');
$lAdmin->AddHeaders($arHeaders);
while ($arRes = $rsData->NavNext(true, "f_")) {
    $row =& $lAdmin->AddRow($f_ID, $arRes);
    $row->AddCheckField("ACTIVE");
    $row->AddInputField("NAME", array("size" => "35"));
    $row->AddInputField("SERVER", array("size" => "35"));
Exemplo n.º 7
0
if ($str_ACTIVE == "Y") {
    ?>
 checked="checked"<?php 
}
?>
></td>
	</tr>
	<tr>
		<td valign="top"><?php 
echo GetMessage('MAIL_MSERVICE_EDT_ICON');
?>
</td>
		<td>
			<input type="file" name="ICON">
			<?php 
if ($icon = Bitrix\Mail\MailServicesTable::getIconSrc($str_NAME, $str_ICON)) {
    ?>
			<br><br><img src="<?php 
    echo $icon;
    ?>
" alt="<?php 
    echo $str_NAME;
    ?>
"><br>
			<?php 
    if ($str_ICON) {
        ?>
			<input type="checkbox" name="remove_icon" value="Y" id="remove_icon" >
			<label for="remove_icon"><?php 
        echo GetMessage("MAIL_MSERVICE_EDT_ICON_REMOVE");
        ?>