Example #1
0
 /**
  * Перехват события "изменние раздела" для обновления Last-Modified
  * @param <type> $catalogue_id
  * @param <type> $sub_id
  */
 public function update_subdivision($catalogue_id, $sub_id)
 {
     $res = array();
     if (is_array($sub_id)) {
         foreach ($sub_id as $v) {
             $res = array_merge($res, nc_get_sub_children($v));
         }
     } else {
         $res = nc_get_sub_children($sub_id);
     }
     $this->update_lastmodified($res);
 }
Example #2
0
/**
 * Получить идентификаторы всех подразделов раздела с идентификатором $sub
 * @param int $sub идентификатор родительского раздела
 * @return array массив с идентификаторами подразделов
 *
 */
function nc_get_sub_children($sub)
{
    global $db;
    $sub = intval($sub);
    $array[] = $sub;
    $sub_array = $db->get_col("SELECT `Subdivision_ID` FROM `Subdivision` WHERE Parent_Sub_ID = '" . $sub . "'");
    if (!empty($sub_array)) {
        foreach ($sub_array as $key => $val) {
            $array = array_merge($array, nc_get_sub_children($val));
        }
    }
    return $array;
}
Example #3
0
function AscIfDeleteSubdivision($phase, $action)
{
    global $db, $nc_core;
    global $ParentSubID, $CatalogueID;
    global $UI_CONFIG;
    $ask = false;
    $cat_counter = 0;
    print "<form method=post action=\"" . $action . "\"><ul>";
    foreach ($nc_core->input->fetch_get_post() as $key => $val) {
        if (substr($key, 0, 6) == "Delete" && $val) {
            $ask = true;
            $sub_id = substr($key, 6, strlen($key) - 6) + 0;
            $sub_array = nc_get_sub_children($sub_id);
            $SelectArray = $db->get_results("SELECT Subdivision_ID, Subdivision_Name FROM Subdivision WHERE Subdivision_ID IN (" . join(',', $sub_array) . ")", ARRAY_A);
            if (!empty($SelectArray)) {
                foreach ($SelectArray as $temp) {
                    print "<li>" . $temp['Subdivision_Name'] . "<br>";
                    print "<INPUT TYPE=HIDDEN NAME=Delete" . $temp['Subdivision_ID'] . " VALUE=" . $temp['Subdivision_ID'] . ">";
                    $cat_counter++;
                }
            }
        }
    }
    if (!$ask) {
        return false;
    }
    if ($cat_counter > 1) {
        $post_f1 = CONTROL_CONTENT_SUBDIVISION_FUNCS_LINEADD_WARNING_ONE_MANY;
        $post_f2 = CONTROL_CONTENT_SUBDIVISION_FUNCS_LINEADD_WARNING_TWO_MANY;
    } else {
        $post_f1 = CONTROL_CONTENT_SUBDIVISION_FUNCS_LINEADD_WARNING_ONE_ONE;
        $post_f2 = CONTROL_CONTENT_SUBDIVISION_FUNCS_LINEADD_WARNING_TWO_ONE;
    }
    ?>
    </ul>
        <?php 
    nc_print_status(sprintf(CONTROL_CONTENT_SUBDIVISION_FUNCS_LINEADD_WARNING, $post_f1, $post_f2), 'info');
    ?>
    <input type=hidden name=phase value=<?php 
    print $phase;
    ?>
>
    <input type=hidden name=ParentSubID value=<?php 
    echo $ParentSubID + 0;
    ?>
>
    <input type=hidden name=CatalogueID value=<?php 
    echo $CatalogueID + 0;
    ?>
>
    <?php 
    print $nc_core->token->get_input();
    print "</form>";
    $UI_CONFIG->actionButtons[] = array("caption" => CONTROL_CONTENT_SUBDIVISION_FUNCS_LINEADD_DELETE_CONFIRMATION, "action" => "mainView.submitIframeForm()", "red_border" => true);
    return true;
}