Exemple #1
0
 case 'imap':
     $unseen = CMailUtil::CheckImapMailbox($acc['SERVER'], $acc['PORT'], $acc['USE_TLS'], $acc['LOGIN'], $acc['PASSWORD'], $error, 30);
     break;
 case 'controller':
     list($acc['login'], $acc['domain']) = explode('@', $acc['LOGIN'], 2);
     $crCheckMailbox = CControllerClient::ExecuteEvent('OnMailControllerCheckMailbox', array('DOMAIN' => $acc['domain'], 'NAME' => $acc['login']));
     if (isset($crCheckMailbox['result'])) {
         $unseen = intval($crCheckMailbox['result']);
     } else {
         $unseen = -1;
         $error = empty($crCheckMailbox['error']) ? GetMessage('INTR_MAIL_CONTROLLER_INVALID') : CMail::getErrorMessage($crCheckMailbox['error']);
     }
     break;
 case 'crdomain':
     list($acc['login'], $acc['domain']) = explode('@', $acc['LOGIN'], 2);
     $crCheckMailbox = CControllerClient::ExecuteEvent('OnMailControllerCheckMemberMailbox', array('DOMAIN' => $acc['domain'], 'NAME' => $acc['login']));
     if (isset($crCheckMailbox['result'])) {
         $unseen = intval($crCheckMailbox['result']);
     } else {
         $unseen = -1;
         $error = empty($crCheckMailbox['error']) ? GetMessage('INTR_MAIL_CONTROLLER_INVALID') : CMail::getErrorMessage($crCheckMailbox['error']);
     }
     break;
 case 'domain':
     $service = \Bitrix\Mail\MailServicesTable::getRowById($acc['SERVICE_ID']);
     list($acc['login'], $acc['domain']) = explode('@', $acc['LOGIN'], 2);
     $result = CMailDomain2::getUnreadMessagesCount($service['TOKEN'], $acc['domain'], $acc['login'], $error);
     if (is_null($result)) {
         $unseen = -1;
         $error = CMail::getErrorMessage($error);
     } else {
Exemple #2
0
 public static function notifyMailDomain($type, $sid, $user_id, $cnt = 0)
 {
     $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', 'EMAIL')))->fetch();
     if (empty($arAdmin)) {
         return '';
     }
     if ($cnt == 0) {
         return 'CIntranetUtils::notifyMailDomain("' . $type . '", "' . $sid . '", ' . $user_id . ', ' . ++$cnt . ');';
     }
     includeModuleLangFile(__FILE__);
     if (isModuleInstalled('bitrix24')) {
         $learnmoreLink = getMessage('INTR_MAIL_DOMAIN_LEARNMOREB24_LINK');
         $supportLink = getMessage('INTR_MAIL_DOMAIN_SUPPORTB24_LINK');
     } else {
         $learnmoreLink = getMessage('INTR_MAIL_DOMAIN_LEARNMORE_LINK');
         $supportLink = getMessage('INTR_MAIL_DOMAIN_SUPPORT_LINK');
     }
     if (in_array($type, array('nocomplete', 'nomailbox'))) {
         $sid = intval($sid);
         $service = \Bitrix\Mail\MailServicesTable::getList(array('filter' => array('=ID' => $sid)))->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'], $error);
             $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 ($type == 'nocomplete') {
             if (in_array($stage, array('owner-check', 'mx-check'))) {
                 CEvent::send('INTRANET_MAILDOMAIN_NOCOMPLETE', array($service['SITE_ID']), array('EMAIL_TO' => $arAdmin['EMAIL'], 'LEARNMORE_LINK' => $learnmoreLink, 'SUPPORT_LINK' => $supportLink));
                 if ($cnt == 1) {
                     global $pPERIOD;
                     $pPERIOD = 3600 * 24 * 4;
                     return 'CIntranetUtils::notifyMailDomain("nocomplete", ' . $sid . ', ' . $user_id . ', ' . ++$cnt . ');';
                 }
             }
         } else {
             if ($stage == 'added') {
                 $dbMailboxes = CMailbox::getList(array(), array('ACTIVE' => 'Y', '!USER_ID' => 0, 'SERVICE_ID' => $sid));
                 $adminMailbox = false;
                 $userMailboxes = false;
                 while ($arMailbox = $dbMailboxes->fetch()) {
                     if ($arMailbox['USER_ID'] == $user_id) {
                         $adminMailbox = true;
                     } else {
                         $userMailboxes = true;
                         break;
                     }
                 }
                 if (!$userMailboxes) {
                     $eventType = $adminMailbox ? 'INTRANET_MAILDOMAIN_NOMAILBOX2' : 'INTRANET_MAILDOMAIN_NOMAILBOX';
                     CEvent::send($eventType, array($service['SITE_ID']), array('EMAIL_TO' => $arAdmin['EMAIL'], 'LEARNMORE_LINK' => $learnmoreLink, 'SUPPORT_LINK' => $supportLink));
                     if ($cnt == 1) {
                         global $pPERIOD;
                         $pPERIOD = 3600 * 24 * 21;
                         return 'CIntranetUtils::notifyMailDomain("nomailbox", ' . $sid . ', ' . $user_id . ', ' . ++$cnt . ');';
                     }
                 }
             }
         }
     } else {
         if ($type == 'noreg') {
             $dbServices = \Bitrix\Mail\MailServicesTable::getList(array('filter' => array('ACTIVE' => 'Y', 'SERVICE_TYPE' => 'crdomain')));
             while ($service = $dbServices->fetch()) {
                 if ($service['FLAGS'] & CMail::F_DOMAIN_REG) {
                     return '';
                 }
             }
             $r = CEvent::send('INTRANET_MAILDOMAIN_NOREG', array($sid), array('EMAIL_TO' => $arAdmin['EMAIL'], 'LEARNMORE_LINK' => $learnmoreLink, 'SUPPORT_LINK' => $supportLink));
         }
     }
     return '';
 }
Exemple #3
0
	&& check_freetrix_sessid()
	&& COption::GetOptionString("main", "controller_member", "N") == "Y"
)
{
	$controller_url = COption::GetOptionString("main", "controller_url", "");
	if(strlen($controller_login)<=0 || strlen($controller_password)<=0)
	{
		LocalRedirect($controller_url."/freetrix/admin/controller_member_edit.php?lang=".LANGUAGE_ID.'&act=unregister&member_id='.urlencode(COption::GetOptionString("main", "controller_member_id", "")).'&back_url='.urlencode(($APPLICATION->IsHTTPS()?"https://":"http://").$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']));
	}
	else
	{
		if(!CControllerClient::RemoveFromController($controller_login, $controller_password))
		{
			if($_REQUEST['remove_anywhere'] == 'Y')
			{
				CControllerClient::Unlink();
			}
			else
			{
				$bControllerRemoveError = true;
				if ($e = $APPLICATION->GetException())
					$message = new CAdminMessage(GetMessage("MAIN_ERROR_SAVING"), $e);
			}
		}
	}
}
if($message)
	echo $message->Show();
?>
<h2><?php 
echo GetMessage("MAIN_SUB2");
<?php

include $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php";
//COption::SetOptionString("main", "controller_member", "N");
CControllerClient::JoinToController("http://controller.bsm:6448/", "admin", "password", false, false, false, true);
require_once $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/interface/init_admin.php";
?>
<html><head><title><?php 
$APPLICATION->ShowTitle();
?>
</title></head>
<body><table width="100%"><tr><td width="1%"></td><td width="98%" align="center">
<div style="width:600px;">
<?php 
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/classes/general/wizard.php";
$wizard = new CWizard("bitrix:controller_site");
$wizard->Install();
?>
</div>
</td><td width="1%"></td>
</table>
</body>
</html>
<?php 
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_after.php";
Exemple #5
0
function __AdmSettingsDrawRow($module_id, $Option)
{
    $arControllerOption = CControllerClient::GetInstalledOptions($module_id);
    if (!is_array($Option)) {
        ?>
		<tr class="heading">
			<td colspan="2"><?php 
        echo $Option;
        ?>
</td>
		</tr>
	<?php 
    } elseif (isset($Option["note"])) {
        ?>
		<tr>
			<td colspan="2" align="center">
				<?php 
        echo BeginNote('align="center"');
        ?>
				<?php 
        echo $Option["note"];
        ?>
				<?php 
        echo EndNote();
        ?>
			</td>
		</tr>
	<?php 
    } else {
        if ($Option[0] != "") {
            $val = COption::GetOptionString($module_id, $Option[0], $Option[2]);
        } else {
            $val = $Option[2];
        }
        $type = $Option[3];
        $disabled = array_key_exists(4, $Option) && $Option[4] == 'Y' ? ' disabled' : '';
        $sup_text = array_key_exists(5, $Option) ? $Option[5] : '';
        ?>
		<tr>
			<td<?php 
        if ($type[0] == "multiselectbox" || $type[0] == "textarea" || $type[0] == "statictext" || $type[0] == "statichtml") {
            echo ' class="adm-detail-valign-top"';
        }
        ?>
 width="50%"><?php 
        if ($type[0] == "checkbox") {
            echo "<label for='" . htmlspecialcharsbx($Option[0]) . "'>" . $Option[1] . "</label>";
        } else {
            echo $Option[1];
        }
        if (strlen($sup_text) > 0) {
            ?>
<span class="required"><sup><?php 
            echo $sup_text;
            ?>
</sup></span><?php 
        }
        ?>
<a name="opt_<?php 
        echo htmlspecialcharsbx($Option[0]);
        ?>
"></a></td>
			<td width="50%"><?php 
        if ($type[0] == "checkbox") {
            ?>
<input type="checkbox" <?php 
            if (isset($arControllerOption[$Option[0]])) {
                echo ' disabled title="' . GetMessage("MAIN_ADMIN_SET_CONTROLLER_ALT") . '"';
            }
            ?>
 id="<?php 
            echo htmlspecialcharsbx($Option[0]);
            ?>
" name="<?php 
            echo htmlspecialcharsbx($Option[0]);
            ?>
" value="Y"<?php 
            if ($val == "Y") {
                echo " checked";
            }
            echo $disabled;
            if ($type[2] != '') {
                echo " " . $type[2];
            }
            ?>
><?php 
        } elseif ($type[0] == "text" || $type[0] == "password") {
            ?>
<input type="<?php 
            echo $type[0];
            ?>
"<?php 
            if (isset($arControllerOption[$Option[0]])) {
                echo ' disabled title="' . GetMessage("MAIN_ADMIN_SET_CONTROLLER_ALT") . '"';
            }
            ?>
 size="<?php 
            echo $type[1];
            ?>
" maxlength="255" value="<?php 
            echo htmlspecialcharsbx($val);
            ?>
" name="<?php 
            echo htmlspecialcharsbx($Option[0]);
            ?>
"<?php 
            echo $disabled;
            echo $type[0] == "password" || $type["noautocomplete"] ? ' autocomplete="off"' : '';
            ?>
><?php 
        } elseif ($type[0] == "selectbox") {
            $arr = $type[1];
            if (!is_array($arr)) {
                $arr = array();
            }
            ?>
<select name="<?php 
            echo htmlspecialcharsbx($Option[0]);
            ?>
" <?php 
            if (isset($arControllerOption[$Option[0]])) {
                echo ' disabled title="' . GetMessage("MAIN_ADMIN_SET_CONTROLLER_ALT") . '"';
            }
            ?>
 <?php 
            echo $disabled;
            ?>
><?php 
            foreach ($arr as $key => $v) {
                ?>
<option value="<?php 
                echo $key;
                ?>
"<?php 
                if ($val == $key) {
                    echo " selected";
                }
                ?>
><?php 
                echo htmlspecialcharsbx($v);
                ?>
</option><?php 
            }
            ?>
</select><?php 
        } elseif ($type[0] == "multiselectbox") {
            $arr = $type[1];
            if (!is_array($arr)) {
                $arr = array();
            }
            $arr_val = explode(",", $val);
            ?>
<select size="5" <?php 
            if (isset($arControllerOption[$Option[0]])) {
                echo ' disabled title="' . GetMessage("MAIN_ADMIN_SET_CONTROLLER_ALT") . '"';
            }
            ?>
 multiple name="<?php 
            echo htmlspecialcharsbx($Option[0]);
            ?>
[]"<?php 
            echo $disabled;
            ?>
><?php 
            foreach ($arr as $key => $v) {
                ?>
<option value="<?php 
                echo $key;
                ?>
"<?php 
                if (in_array($key, $arr_val)) {
                    echo " selected";
                }
                ?>
><?php 
                echo htmlspecialcharsbx($v);
                ?>
</option><?php 
            }
            ?>
</select><?php 
        } elseif ($type[0] == "textarea") {
            ?>
<textarea <?php 
            if (isset($arControllerOption[$Option[0]])) {
                echo ' disabled title="' . GetMessage("MAIN_ADMIN_SET_CONTROLLER_ALT") . '"';
            }
            ?>
 rows="<?php 
            echo $type[1];
            ?>
" cols="<?php 
            echo $type[2];
            ?>
" name="<?php 
            echo htmlspecialcharsbx($Option[0]);
            ?>
"<?php 
            echo $disabled;
            ?>
><?php 
            echo htmlspecialcharsbx($val);
            ?>
</textarea><?php 
        } elseif ($type[0] == "statictext") {
            echo htmlspecialcharsbx($val);
        } elseif ($type[0] == "statichtml") {
            echo $val;
        }
        ?>
</td>
		</tr>
	<?php 
    }
}
 function GetInstalledOptions($module_id)
 {
     $arOptions = CControllerClient::GetBackup();
     $arOptions = $arOptions["options"][$module_id];
     if (!is_array($arOptions)) {
         return array();
     }
     return $arOptions;
 }
 $arControllerLog = array('NAME' => 'AUTH', 'CONTROLLER_MEMBER_ID' => $ar["ID"], 'STATUS' => 'Y');
 $dbUser = CUser::GetByLogin($oRequest->arParameters['login']);
 if (!($arUser = $dbUser->Fetch())) {
     $oResponse->status = "444 User is not found.";
     $oResponse->text = "User is not found.";
     $arControllerLog['STATUS'] = 'N';
 } else {
     if (strlen($arUser["PASSWORD"]) > 32) {
         $salt = substr($arUser["PASSWORD"], 0, strlen($arUser["PASSWORD"]) - 32);
         $db_password = substr($arUser["PASSWORD"], -32);
     } else {
         $salt = "";
         $db_password = $arUser["PASSWORD"];
     }
     if ($arUser['ACTIVE'] == 'Y' && md5($db_password . 'MySalt') == md5(md5($salt . $oRequest->arParameters['password']) . 'MySalt')) {
         $arSaveUser = CControllerClient::PrepareUserInfo($arUser);
         $arSaveUser["GROUP_ID"] = array();
         $arUserGroups = CUser::GetUserGroup($arUser['ID']);
         $MOD_RIGHT = $APPLICATION->GetGroupRight("controller", $arUserGroups);
         if ($MOD_RIGHT >= "V") {
             $arSaveUser['CONTROLLER_ADMIN'] = 'Y';
             $arSaveUser["GROUP_ID"][] = "administrators";
         } elseif (COption::GetOptionString("controller", "auth_loc_enabled", "N") != "Y") {
             $oResponse->status = "423 Remoute Authorization Disabled.";
             $oResponse->text = "Remote authorization disabled on controller.";
             break;
         }
         $arLocGroups = unserialize(COption::GetOptionString("controller", "auth_loc", serialize(array())));
         foreach ($arLocGroups as $arTGroup) {
             foreach ($arUserGroups as $group_id) {
                 if ($arTGroup["LOC"] == $group_id) {
 function DBUpdaterUpdateFromVersion($moduleID, $dbVersion)
 {
     if (StrLen($moduleID) <= 0) {
         return;
     }
     if (StrLen($dbVersion) <= 0) {
         return;
     }
     $errorMessage = "";
     if (file_exists($_SERVER["DOCUMENT_ROOT"] . US_SAVE_UPDATERS_DIR . "/" . $moduleID) && is_dir($_SERVER["DOCUMENT_ROOT"] . US_SAVE_UPDATERS_DIR . "/" . $moduleID)) {
         $arUpdaters = array();
         if ($handle = @opendir($_SERVER["DOCUMENT_ROOT"] . US_SAVE_UPDATERS_DIR . "/" . $moduleID)) {
             while (false !== ($dir = readdir($handle))) {
                 if ($dir == "." || $dir == "..") {
                     continue;
                 }
                 if (substr($dir, 0, 7) == "updater") {
                     if (is_file($_SERVER["DOCUMENT_ROOT"] . US_SAVE_UPDATERS_DIR . "/" . $moduleID . "/" . $dir)) {
                         $num = substr($dir, 7, strlen($dir) - 11);
                         if (substr($dir, strlen($dir) - 9) == "_post.php") {
                             $num = substr($dir, 7, strlen($dir) - 16);
                         }
                         $arUpdaters[] = array("/" . $dir, Trim($num));
                     } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . US_SAVE_UPDATERS_DIR . "/" . $moduleID . "/" . $dir . "/index.php")) {
                         $num = substr($dir, 7);
                         if (substr($dir, strlen($dir) - 5) == "_post") {
                             $num = substr($dir, 7, strlen($dir) - 12);
                         }
                         $arUpdaters[] = array("/" . $dir . "/index.php", Trim($num));
                     }
                 }
             }
             closedir($handle);
         }
         for ($i1 = 0; $i1 < count($arUpdaters) - 1; $i1++) {
             for ($j1 = $i1 + 1; $j1 < count($arUpdaters); $j1++) {
                 if (CUpdateClient::CompareVersions($arUpdaters[$i1][1], $arUpdaters[$j1][1]) > 0) {
                     $tmp1 = $arUpdaters[$i1];
                     $arUpdaters[$i1] = $arUpdaters[$j1];
                     $arUpdaters[$j1] = $tmp1;
                 }
             }
         }
         for ($i1 = 0; $i1 < count($arUpdaters); $i1++) {
             if (CUpdateClient::CompareVersions($arUpdaters[$i1][1], $dbVersion) <= 0) {
                 continue;
             }
             $errorMessageTmp = "";
             CUpdateClient::RunUpdaterScript($_SERVER["DOCUMENT_ROOT"] . US_SAVE_UPDATERS_DIR . "/" . $moduleID . $arUpdaters[$i1][0], $errorMessageTmp, "", $moduleID);
             if (strlen($errorMessageTmp) > 0) {
                 $errorMessage .= str_replace("#MODULE#", $moduleID, str_replace("#VER#", $arUpdaters[$i1][1], GetMessage("SUPP_UK_UPDN_ERR"))) . ": " . $errorMessageTmp . ".<br>";
             }
             DBUpdaterCollectDBVersionsNew("N", $moduleID, $arUpdaters[$i1][1]);
         }
     }
     if (StrLen($errorMessage) > 0) {
         CControllerClient::SendMessage("SITE_UPDATE_KERNEL_DB", "N", $errorMessage);
     }
 }
             }
         }
         if (!$bDomainUsersExist && !empty($arMailServices[$arService['ID']]['users'])) {
             $bConnectDomainsExist = true;
             $bDomainUsersExist = true;
         }
     }
 } else {
     if ($arService['SERVICE_TYPE'] == 'crdomain') {
         $crDomains = CControllerClient::ExecuteEvent('OnMailControllerGetMemberDomains', array());
         if (!empty($crDomains['result']) && is_array($crDomains['result'])) {
             $arMailServices[$arService['ID']]['domains'] = $crDomains['result'];
             $bCreateDomainsExist = true;
         }
         $arMailServices[$arService['ID']]['users'] = array();
         $crUsers = CControllerClient::ExecuteEvent('OnMailControllerGetMemberUsers', array('DOMAIN' => $arService['SERVER']));
         if (!empty($crUsers['result']) && is_array($crUsers['result'])) {
             foreach ($crUsers['result'] as $login) {
                 if (empty($arMailServices[$arService['ID']]['users'][$arService['SERVER']])) {
                     $arMailServices[$arService['ID']]['users'][$arService['SERVER']] = array();
                 }
                 $arMailServices[$arService['ID']]['users'][$arService['SERVER']][] = $login;
             }
             $rsMailbox = CMailbox::getList(array('TIMESTAMP_X' => 'ASC'), array('ACTIVE' => 'Y', '!USER_ID' => 0, 'SERVICE_ID' => $arMailServices[$arService['ID']]['id']));
             while ($arMailbox = $rsMailbox->Fetch()) {
                 list($login, $domain) = explode('@', $arMailbox['LOGIN'], 2);
                 if (!empty($arMailServices[$arService['ID']]['users'][$domain]) && ($key = array_search($login, $arMailServices[$arService['ID']]['users'][$domain])) !== false) {
                     array_splice($arMailServices[$arService['ID']]['users'][$domain], $key, 1);
                 }
             }
             if (is_array($arMailServices[$arService['ID']]['users'])) {
Exemple #10
0
 private static function checkDomainStatus($settings, &$error)
 {
     if ($settings['type'] == 'domain') {
         $result = CMailDomain2::getDomainStatus($settings['token'], $settings['domain'], $error);
         if (is_null($result)) {
             $error = CMail::getErrorMessage($error);
         } else {
             if (!isset($result['stage']) || !in_array($result['stage'], array('owner-check', 'mx-check', 'added'))) {
                 $error = CMail::getErrorMessage(CMail::ERR_API_DENIED);
             }
         }
     } else {
         if ($settings['type'] == 'crdomain') {
             $result = null;
             $crResponse = CControllerClient::ExecuteEvent('OnMailControllerCheckMemberDomain', array('DOMAIN' => $settings['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');
                 } else {
                     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');
                         }
                     }
                 }
             }
         }
     }
     return $result;
 }
Exemple #11
0
 private static function executeManageDeleteMailbox(&$error)
 {
     $error = false;
     $userId = $_REQUEST['USER_ID'];
     if (!check_bitrix_sessid()) {
         $error = GetMessage('INTR_MAIL_CSRF');
     }
     if ($error === false) {
         $mailbox = CIntranetMailSetupHelper::getUserMailbox($userId);
         if (empty($mailbox) || !in_array($mailbox['SERVER_TYPE'], array('controller', 'domain', 'crdomain'))) {
             $error = GetMessage('INTR_MAIL_AJAX_ERROR');
         }
     }
     if ($error === false) {
         CMailbox::delete($mailbox['ID']);
         list($login, $domain) = explode('@', $mailbox['LOGIN'], 2);
         if ($mailbox['SERVER_TYPE'] == 'domain') {
             $domainService = CIntranetMailSetupHelper::getDomainService($mailbox['SERVICE_ID']);
             CMailDomain2::deleteUser($domainService['token'], $domain, $login);
         } else {
             if ($mailbox['SERVER_TYPE'] == 'crdomain') {
                 $crResponse = CControllerClient::ExecuteEvent('OnMailControllerDeleteMemberUser', array('DOMAIN' => $domain, 'NAME' => $login));
                 if (!isset($crResponse['result'])) {
                     $error = empty($crResponse['error']) ? GetMessage('INTR_MAIL_CONTROLLER_INVALID') : CMail::getErrorMessage($crResponse['error']);
                 }
             } else {
                 if ($mailbox['SERVER_TYPE'] == 'controller') {
                     $crResponse = CControllerClient::ExecuteEvent('OnMailControllerDeleteUser', array('DOMAIN' => $domain, 'NAME' => $login));
                     if (!isset($crResponse['result'])) {
                         $error = empty($crResponse['error']) ? GetMessage('INTR_MAIL_CONTROLLER_INVALID') : CMail::getErrorMessage($crResponse['error']);
                     }
                 }
             }
         }
         CUserCounter::Clear($userId, 'mail_unseen', $mailbox['LID']);
         CUserOptions::DeleteOption('global', 'last_mail_check_' . $mailbox['LID']);
         CUserOptions::DeleteOption('global', 'last_mail_check_success_' . $mailbox['LID']);
     }
     if ($error === false) {
         $create = '<a href="#" onclick="mb.create(' . intval($userId) . '); return false; ">' . GetMessage('INTR_MAIL_MANAGE_CREATE') . '</a>';
     }
     return array('result' => $error === false ? 'ok' : 'error', 'create' => isset($create) ? CharsetConverter::ConvertCharset($create, SITE_CHARSET, 'UTF-8') : '', 'error' => CharsetConverter::ConvertCharset($error, SITE_CHARSET, 'UTF-8'));
 }
Exemple #12
0
 public static function createMailbox($exists, $userId, $serviceId, $domain, $login, $password, &$error)
 {
     $error = false;
     if (intval($userId)) {
         $dbUser = CUser::getList($by = 'ID', $order = 'ASC', array('ID_EQUAL_EXACT' => intval($userId)), array('FIELDS' => 'ID'));
         if (!$dbUser->fetch()) {
             $error = GetMessage('INTR_MAIL_FORM_ERROR');
         }
     }
     if ($error === false) {
         $services = self::getMailServices();
         if (empty($services[$serviceId]) || !in_array($services[$serviceId]['type'], array('controller', 'domain', 'crdomain'))) {
             $error = GetMessage('INTR_MAIL_FORM_ERROR');
         }
     }
     if ($error === false) {
         $service = $services[$serviceId];
         if ($service['type'] == 'controller') {
             $crDomains = CControllerClient::ExecuteEvent('OnMailControllerGetDomains', array());
             $arDomains = empty($crDomains['result']) ? array() : $crDomains['result'];
             if (!is_array($arDomains) || !in_array($domain, $arDomains)) {
                 $error = CMail::getErrorMessage(CMail::ERR_API_OP_DENIED);
             }
         } else {
             if ($service['type'] == 'crdomain') {
                 $crDomains = CControllerClient::ExecuteEvent('OnMailControllerGetMemberDomains', array());
                 $arDomains = empty($crDomains['result']) ? array() : $crDomains['result'];
                 if (!is_array($arDomains) || !in_array($domain, $arDomains)) {
                     $error = CMail::getErrorMessage(CMail::ERR_API_OP_DENIED);
                 }
             } else {
                 if ($service['type'] == 'domain') {
                     if ($service['server'] != $domain) {
                         $error = GetMessage('INTR_MAIL_FORM_ERROR');
                     }
                 }
             }
         }
     }
     if ($error === false && !$exists) {
         if (!preg_match('/^[a-z0-9_]+(\\.?[a-z0-9_-]*[a-z0-9_]+)*?$/i', $login)) {
             $error = CMail::getErrorMessage(CMail::ERR_API_BAD_NAME);
         }
         if ($error === false) {
             if ($service['type'] == 'controller') {
                 $crResponse = CControllerClient::ExecuteEvent('OnMailControllerAddUser', array('DOMAIN' => $domain, 'NAME' => $login, 'PASSWORD' => $password));
                 if (!isset($crResponse['result'])) {
                     $error = empty($crResponse['error']) ? GetMessage('INTR_MAIL_CONTROLLER_INVALID') : CMail::getErrorMessage($crResponse['error']);
                 }
             } else {
                 if ($service['type'] == 'crdomain') {
                     $crResponse = CControllerClient::ExecuteEvent('OnMailControllerAddMemberUser', array('DOMAIN' => $domain, 'NAME' => $login, 'PASSWORD' => $password));
                     if (!isset($crResponse['result'])) {
                         $error = empty($crResponse['error']) ? GetMessage('INTR_MAIL_CONTROLLER_INVALID') : CMail::getErrorMessage($crResponse['error']);
                     }
                 } else {
                     if ($service['type'] == 'domain') {
                         $result = CMailDomain2::addUser($service['token'], $domain, $login, $password, $error);
                         if (is_null($result)) {
                             $error = CMail::getErrorMessage($error);
                         }
                     }
                 }
             }
         }
     }
     if ($error === false && intval($userId)) {
         if ($exists) {
             if ($service['type'] == 'controller') {
                 $crCheckMailbox = CControllerClient::ExecuteEvent('OnMailControllerCheckMailbox', array('DOMAIN' => $domain, 'NAME' => $login));
                 if (!isset($crCheckMailbox['result'])) {
                     $error = empty($crCheckMailbox['error']) ? GetMessage('INTR_MAIL_CONTROLLER_INVALID') : CMail::getErrorMessage($crCheckMailbox['error']);
                 }
             }
             if ($error === false) {
                 $dbMailbox = CMailbox::getList(array('TIMESTAMP_X' => 'ASC'), array('ACTIVE' => 'Y', '!USER_ID' => intval($userId), '=LOGIN' => $login . '@' . $domain));
                 if (($mailbox = $dbMailbox->fetch()) && $mailbox['USER_ID']) {
                     $error = GetMessage('INTR_MAIL_MAILBOX_OCCUPIED');
                 }
             }
         }
         if ($error === false) {
             $mailbox = self::getUserMailbox($userId);
             if (!empty($mailbox)) {
                 $res = CMailbox::delete($mailbox['ID']);
             }
             $arFields = array('LID' => SITE_ID, 'ACTIVE' => 'Y', 'SERVICE_ID' => $serviceId, 'NAME' => $service['name'], 'LOGIN' => $login . '@' . $domain, 'SERVER_TYPE' => $service['type'], 'USER_ID' => intval($userId));
             $res = CMailbox::add($arFields);
             if (!$res) {
                 $error = GetMessage('INTR_MAIL_SAVE_ERROR');
             }
         }
     }
     if ($error === false) {
         return $login . '@' . $domain;
     }
 }
Exemple #13
0
function __AdmSettingsDrawRow($module_id, $Option)
{
	$arControllerOption = CControllerClient::GetInstalledOptions($module_id);
	if(!is_array($Option)):
	?>
		<tr class="heading">
			<td valign="top" colspan="2" align="center"><b><?php 
echo $Option;
?>
</b></td>
		</tr>
	<?
	elseif(isset($Option["note"])):
	?>
		<tr>
			<td valign="top" colspan="2" align="center">
				<?echo BeginNote('align="center"');?>
				<?php 
echo $Option["note"];
?>
				<?echo EndNote();?>
			</td>
		</tr>
	<?
	else:
		$val = COption::GetOptionString($module_id, $Option[0], $Option[2]);
		$type = $Option[3];
		$disabled = array_key_exists(4, $Option) && $Option[4] == 'Y' ? ' disabled' : '';
		$sup_text = array_key_exists(5, $Option) ? $Option[5] : '';
	?>
		<tr>
			<td valign="top" width="50%" class="field-name"><?
				if($type[0]=="checkbox")
					echo "<label for='".htmlspecialcharsbx($Option[0])."'>".$Option[1]."</label>";
				else
					echo $Option[1];
				if (strlen($sup_text) > 0)
				{
					?><span class="required"><sup><?php 
echo $sup_text;
?>
</sup></span><?
				}
					?></td>
			<td valign="middle" width="50%"><?
			if($type[0]=="checkbox"):
				?><input type="checkbox" <?if(isset($arControllerOption[$Option[0]]))echo ' disabled title="'.GetMessage("MAIN_ADMIN_SET_CONTROLLER_ALT").'"';?> id="<?echo htmlspecialcharsbx($Option[0])?>" name="<?echo htmlspecialcharsbx($Option[0])?>" value="Y"<?if($val=="Y")echo" checked";?><?php 
echo $disabled;
?>
<?if($type[2]<>'') echo " ".$type[2]?>><?
			elseif($type[0]=="text" || $type[0]=="password"):
				?><input type="<?echo $type[0]?>"<?if(isset($arControllerOption[$Option[0]]))echo ' disabled title="'.GetMessage("MAIN_ADMIN_SET_CONTROLLER_ALT").'"';?> size="<?echo $type[1]?>" maxlength="255" value="<?echo htmlspecialcharsbx($val)?>" name="<?echo htmlspecialcharsbx($Option[0])?>"<?php 
echo $disabled;
echo $type[0] == "password" ? ' autocomplete="off"' : '';
?>
><?
			elseif($type[0]=="selectbox"):
				$arr = $type[1];
				if(!is_array($arr))
					$arr = array();
				$arr_keys = array_keys($arr);
				?><select name="<?echo htmlspecialcharsbx($Option[0])?>" <?if(isset($arControllerOption[$Option[0]]))echo ' disabled title="'.GetMessage("MAIN_ADMIN_SET_CONTROLLER_ALT").'"';?> <?php 
echo $disabled;
?>
><?
					for($j=0; $j<count($arr_keys); $j++):
						?><option value="<?echo $arr_keys[$j]?>"<?if($val==$arr_keys[$j])echo" selected"?>><?echo htmlspecialcharsbx($arr[$arr_keys[$j]])?></option><?
					endfor;
					?></select><?
			elseif($type[0]=="multiselectbox"):
				$arr = $type[1];
				if(!is_array($arr))
					$arr = array();
				$arr_keys = array_keys($arr);
				$arr_val = explode(",",$val);
				?><select size="5" <?if(isset($arControllerOption[$Option[0]]))echo ' disabled title="'.GetMessage("MAIN_ADMIN_SET_CONTROLLER_ALT").'"';?> multiple name="<?echo htmlspecialcharsbx($Option[0])?>[]"<?php 
echo $disabled;
?>
><?
					for($j=0; $j<count($arr_keys); $j++):
						?><option value="<?echo $arr_keys[$j]?>"<?if(in_array($arr_keys[$j],$arr_val)) echo " selected"?>><?echo htmlspecialcharsbx($arr[$arr_keys[$j]])?></option><?
					endfor;
				?></select><?
			elseif($type[0]=="textarea"):
				?><textarea <?if(isset($arControllerOption[$Option[0]]))echo ' disabled title="'.GetMessage("MAIN_ADMIN_SET_CONTROLLER_ALT").'"';?> rows="<?echo $type[1]?>" cols="<?echo $type[2]?>" name="<?echo htmlspecialcharsbx($Option[0])?>"<?php 
echo $disabled;
?>
><?echo htmlspecialcharsbx($val)?></textarea><?
			elseif($type[0]=="statictext"):
				echo htmlspecialcharsbx($val);
			elseif($type[0]=="statichtml"):
				echo $val;
			endif;
			?></td>
		</tr>
	<?
	endif;
}