示例#1
0
 function Delete($ID)
 {
     global $DB, $APPLICATION;
     $aMsg = array();
     $ID = intval($ID);
     $rsWebNodes = CClusterWebnode::GetList(array(), array("=GROUP_ID" => $ID));
     if ($rsWebNodes->Fetch()) {
         $aMsg[] = array("text" => GetMessage("CLU_GROUP_HAS_WEBNODE"));
     }
     $rsDBNodes = CClusterDBNode::GetList(array(), array("=GROUP_ID" => $group_id));
     if ($rsWebNodes->Fetch()) {
         $aMsg[] = array("text" => GetMessage("CLU_GROUP_HAS_DBNODE"));
     }
     /*TODO: memcache check*/
     if (empty($aMsg)) {
         $res = $DB->Query("DELETE FROM b_cluster_group WHERE ID = " . $ID, false, '', array('fixed_connection' => true));
     } else {
         $e = new CAdminException($aMsg);
         $APPLICATION->ThrowException($e);
         return false;
     }
     return $res;
 }
    foreach ($arID as $ID) {
        if (strlen($ID) <= 0) {
            continue;
        }
        $ID = IntVal($ID);
        switch ($_REQUEST['action']) {
            case "delete":
                CClusterWebnode::Delete($ID);
                break;
        }
    }
}
$arHeaders = array(array("id" => "ID", "content" => GetMessage("CLU_WEBNODE_LIST_ID"), "align" => "right", "default" => true), array("id" => "FLAG", "content" => GetMessage("CLU_WEBNODE_LIST_FLAG"), "align" => "center", "default" => true), array("id" => "STATUS", "content" => GetMessage("CLU_WEBNODE_LIST_STATUS"), "align" => "center", "default" => true), array("id" => "NAME", "content" => GetMessage("CLU_WEBNODE_LIST_NAME"), "align" => "left", "default" => true), array("id" => "HOST", "content" => GetMessage("CLU_WEBNODE_LIST_HOST"), "align" => "left", "default" => true), array("id" => "STATUS_URL", "content" => GetMessage("CLU_WEBNODE_LIST_STATUS_URL"), "align" => "left", "default" => false), array("id" => "DESCRIPTION", "content" => GetMessage("CLU_WEBNODE_LIST_DESCRIPTION"), "align" => "left", "default" => false));
$lAdmin->AddHeaders($arHeaders);
$cData = new CClusterWebnode();
$rsData = $cData->GetList(array("ID" => "ASC"), array("=GROUP_ID" => $group_id));
$rsData = new CAdminResult($rsData, $sTableID);
while ($arRes = $rsData->Fetch()) {
    $row =& $lAdmin->AddRow($arRes["ID"], $arRes);
    $uptime = false;
    $RestartTime = "";
    $CurrentTime = "";
    $arStatus = CClusterWEBNode::GetStatus($arRes["HOST"], $arRes["PORT"], $arRes["STATUS_URL"]);
    if (is_array($arStatus)) {
        $html = '<table width="100%">';
        foreach ($arStatus as $key => $value) {
            if ($key == 'Restart Time') {
                $RestartTime = CClusterWEBNode::ParseDateTime($value);
            } elseif ($key == 'Current Time') {
                $CurrentTime = CClusterWEBNode::ParseDateTime($value);
            } else {
        $res = $ob->Delete($ID);
        if ($res) {
            LocalRedirect("/bitrix/admin/cluster_dbnode_list.php?lang=" . LANG . '&group_id=' . $group_id);
        } else {
            $bVarsFromForm = true;
        }
    }
}
ClearVars("str_");
$str_NAME = "";
$str_DESCRIPTION = "";
$str_HOST = "";
$str_PORT = "80";
$str_STATUS_URL = "/server-status";
if ($ID > 0) {
    $rs = CClusterWebnode::GetList(array(), array("=ID" => $ID, "=GROUP_ID" => $group_id), array());
    if (!$rs->ExtractFields("str_")) {
        $ID = 0;
    }
}
if ($bVarsFromForm) {
    $DB->InitTableVarsForEdit("b_cluster_webnode", "", "str_");
}
$APPLICATION->SetTitle($ID > 0 ? GetMessage("CLU_WEBNODE_EDIT_EDIT_TITLE") : GetMessage("CLU_WEBNODE_EDIT_ADD_TITLE"));
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_after.php";
$aMenu = array(array("TEXT" => GetMessage("CLU_WEBNODE_EDIT_MENU_LIST"), "TITLE" => GetMessage("CLU_WEBNODE_EDIT_MENU_LIST_TITLE"), "LINK" => "cluster_webnode_list.php?lang=" . LANG . '&group_id=' . $group_id, "ICON" => "btn_list"));
$context = new CAdminContextMenu($aMenu);
$context->Show();
if ($message) {
    echo $message->Show();
}