Example #1
0
                        $connectids_old = $info->connectids;
                        //remove these non-exist connections
                        foreach ($connectids_old as $connectid) {
                            if (!in_array($connectid, $connectids)) {
                                $info2 = \query\main::category_infos($connectid);
                                $connect = str_replace("|" . $_GET['id'] . "|", "|", $info2->connect);
                                actions::edit_category($connectid, array('connect' => $connect));
                            }
                        }
                        //add new connections
                        foreach ($connectids as $connectid) {
                            if (!in_array($connectid, $connectids_old)) {
                                $info2 = \query\main::category_infos($connectid);
                                if (!in_array(intval($_GET['id']), $info2->connectids)) {
                                    $connect = $info2->connect . $_GET['id'] . "|";
                                    actions::edit_category($connectid, array('connect' => $connect));
                                }
                            }
                        }
                        $info = \query\main::category_infos($_GET['id']);
                        echo '<div class="a-success">' . $LANG['msg_saved'] . '&nbsp;<input type="button" value="Back" onclick="history.go(-2);"></div>';
                    } else {
                        echo '<div class="a-error">' . $LANG['msg_error'] . '</div>';
                    }
                }
            }
            $_SESSION['categories_csrf'] = $csrf;
            $categories_while = \query\main::while_categories(array('max' => 0, 'show' => $info->is_subcat ? 'cats' : 'subcats'));
            echo '<script>
var lastnum = ' . count($info->connectids) . ';
    function addSubcategory(){