function GetSubsForFavorites($section = 0, $mode = "plain", $catid = 0) { global $db, $_structure_level, $perm; $catid += 0; if (!$catid) { // Если не задан сайт, возьмем первый доступный $array_id = $perm->GetAllowSite(MASK_ADMIN | MASK_MODERATE, false); $where = is_array($array_id) ? " WHERE `Catalogue_ID` IN(" . join(',', $array_id) . ") " : " "; $sql = "SELECT Catalogue_ID FROM Catalogue " . $where . " ORDER BY Priority LIMIT 1"; $catid = $db->get_var($sql); } // Определение доступных сайтов $allow_id = $perm->GetAllowSub($catid, MASK_ADMIN, true, true, false); $qry_where = is_array($allow_id) ? " AND Subdivision_ID IN(" . join(',', (array) $allow_id) . ") " : " "; $ret = array(); $select = "SELECT * FROM Subdivision as a\n WHERE a.Catalogue_ID=" . $catid . "\n AND a.Parent_Sub_ID=" . $section . $qry_where . "\n ORDER BY a.Priority"; if ($Result = $db->get_results($select, ARRAY_A)) { foreach ($Result as $row) { $row["level"] = (int) $_structure_level; $ret[$row["Subdivision_ID"]] = $row; $_structure_level++; $children = GetSubsForFavorites($row["Subdivision_ID"], 'plain', $catid); $_structure_level--; foreach ($children as $idx => $row2) { $ret[$idx] = $row2; } } if ($mode == "get_children") { foreach ($ret as $idx => $row) { while ($row["Parent_Sub_ID"] != $section) { $ret[$row["Parent_Sub_ID"]]["Children"][] = $row["Subdivision_ID"]; $row = $ret[$row["Parent_Sub_ID"]]; } } } } return $ret; }
EndHtml(); exit; } } switch ($phase) { case 1: # покажем список рубрик BeginHtml($Title2, $Title2, "http://" . $DOC_DOMAIN . "/management/favorites/"); $UI_CONFIG = new ui_config_favorite('list'); ShowFavorites(); //echo "<a href=# onclick=\"window.open('".$ADMIN_PATH."subdivision/favorites.php?phase=4','LIST','top=50, left=100,directories=no,height=600,location=no,menubar=no,resizable=no,scrollbars=yes,status=yes,toolbar=no,width=400');return false;\"><b>".CONTROL_CONTENT_SUBDIVISION_FUNCS_ADDSECTION."</b></a>"; break; case 4: case 2: // покажем список разделов всего сайта для добавления в избранное $structure = GetSubsForFavorites(0, "get_children", $catid); print "<html>\n\t\t <title>" . SECTION_CONTROL_CONTENT_FAVORITES . "</title>\n\t\t <head>\n\t\t <link type='text/css' rel='Stylesheet' href='" . $ADMIN_TEMPLATE . "css/admin.css'>\n\t\t " . nc_css() . "\n\t\t <script>\n\n\t\t function add_to_favorites(sub_id, phase)\n {\n"; print "opener.frames['mainViewIframe'].location.href='" . $ADMIN_PATH . "subdivision/favorites.php?phase='+phase+'&subid='+sub_id;"; print "\n}\n\n\t\t </script>\n\t\t </head>\n\t\t <body style='overflow-y: visible;'>"; echo "<div id='menu_left' style='padding: 15px;'>\n <div class='menu_left_block' style='overflow: visible;'>"; ShowCataloguesForFavorites($catid, $phase); ShowSubsForFavorites($structure, 0, $catid, $phase); echo "</div></div>"; echo "</body></html>"; break; case 3: //Добавление в избранное if ($perm->isSubdivisionAdmin($subid)) { AddFavorites($subid); } header("Location: http://" . $HTTP_HOST . "" . $ADMIN_PATH . "");