function admin_menu_list()
{
    global $site;
    $alamlipikud = array();
    $peaosad = array("id" => array(), "nimi" => array());
    $admin_menu = array();
    ############### otsime lubatud alamlipikud
    # 1. k�si k�ik admin-lehed
    $sql = $site->db->prepare("SELECT admin_osa.id\r\n\tFROM admin_osa\r\n\tWHERE admin_osa.parent_id!=1 ");
    $sql .= " ORDER BY sorteering DESC";
    $sth = new SQL($sql);
    while ($adminpage = $sth->fetch()) {
        # 3. vaata kas admin-leht on userile lubatud
        $perm = get_user_permission(array(type => 'ADMIN', adminpage_id => $adminpage['id'], site => $site));
        # kas useril on selle admin-lehe kohta Read �igus?
        if (!$perm['R']) {
            # if forbidden, go to next adminpage
            continue;
        }
        # 4. kui k�ik lubatud, siis pane l�pp-massiivi
        array_push($alamlipikud, $adminpage['id']);
    }
    #printr($alamlipikud);
    # see on n��d k�igi vaatamiseks lubatud adminlehtede massiiv:
    $alamlipikud_joined = join("','", $alamlipikud);
    ############## Alamlipiku id jargi otsime pealipikud
    $sql = $site->db->prepare("SELECT A.id AS peaid, A.nimetus AS peanimetus, A.eng_nimetus AS eng_peanimetus, A.sorteering FROM admin_osa\r\n\t\tLEFT JOIN admin_osa as A ON A.id = admin_osa.parent_id\r\n\t\tWHERE " . (!$site->in_admin ? "A.show_in_editor=1 AND " : "") . " admin_osa.id IN ('{$alamlipikud_joined}')\r\n\t\tGROUP BY A.id, A.nimetus, A.eng_nimetus, A.sorteering ORDER BY A.sorteering DESC");
    $sth = new SQL($sql);
    $pea_total = $sth->rows;
    $site->debug->msg($sth->debug->get_msgs());
    while ($lipik = $sth->fetch()) {
        $admin_menu[]['id'] = $lipik['peaid'];
        $admin_menu[sizeof($admin_menu) - 1]['name'] = $lipik['eng_peanimetus'];
        $admin_menu[sizeof($admin_menu) - 1]['translated_name'] = $site->sys_sona(array(sona => $lipik['eng_peanimetus'], tyyp => 'admin', lang_id => $_SESSION['keel_admin']['glossary_id']));
        $admin_menu[sizeof($admin_menu) - 1]['submenus'] = admin_menu_sublist($lipik['peaid'], $alamlipikud_joined);
    }
    /*
    We now need to find out if there are duplicate menus (because different modules might share the same menus and they are both in use, which means there are double menus in the array. Easiest example is the E-Commerce module that requires the existance of E-Payment module. Both of them use the same menus, but E-Payment can also be as a standalone module, not requireing E-Commerce.
    We try to find out if the duplicate menus are basically the same thing just linked to a different module. If so, we just remove one of them. But if they are different things (say the name is the same, but the file it links to is different) we just add them under one main menu.
    Peeter 26.08.2008
    */
    $list = array();
    // Count the times main menu names are listed in the array.
    foreach ($admin_menu as $am) {
        $list[$am['name']]++;
    }
    //remove all the unique (occurs 1 time) names.
    foreach ($list as $k => $v) {
        if ($v < 2) {
            unset($list[$k]);
        }
    }
    //if any menus are represented several times we need to check their submenus and merge them.
    if (sizeof($list) > 0) {
        //we sort through each of the main menus and get their submenus into one array.
        foreach ($list as $k => $v) {
            $sm = "";
            $first_occurance = "";
            //first occurance of the menu, duplicates are unset after submenu values are extracted. Reasoning behind this is that the main menu names are and will be in the future, unique.
            foreach ($admin_menu as $ka => $av) {
                if ($av['name'] == $k) {
                    if ($first_occurance == "") {
                        $first_occurance = $ka;
                    }
                    foreach ($av['submenus'] as $menu) {
                        $sm[] = $menu;
                    }
                    if ($first_occurance != $ka) {
                        unset($admin_menu[$ka]);
                    }
                }
            }
            //we remove duplicate submenus, in this case that have a matching "fail" value.
            $admin_menu[$first_occurance]['submenus'] = remove_duplicates($sm, array("fail", "eng_nimetus"));
        }
    }
    //Now that we have removed the duplicate main menus and sub-menus there is still a chance that there are duplicate submenus (For instance Extension menu may have several fields by the same name and path, so we basically run through the menu/submenu tree and remove duplicates.
    foreach ($admin_menu as $k => $v) {
        $admin_menu[$k]['submenus'] = remove_duplicates($admin_menu[$k]['submenus'], array("fail", "eng_nimetus"));
    }
    return $admin_menu;
}
Пример #2
0
            foreach ($lastposts as $id => $post) {
                $content .= $post->post_content;
            }
            unset($lastposts);
            // Use content_filter to parse all shortcodes, extracting ASINs
            $saved_tags = $this->tags;
            $this->tags = array();
            $this->content_filter($content, False, False);
            unset($content);
            $asins_list = remove_duplicates($this->tags, $cc, $settings['default_cc']);
            $this->tags = $saved_tags;
            // Need to reset 'Settings' back to our settings. TODO: use local not global?
            $this->Settings =& $settings['global'];
        } else {
            // Use the 'local' ASINs already found by the plugin
            $asins_list = remove_duplicates($this->tags, $cc, $settings['default_cc']);
        }
    }
}
/*
 * If we have some ASINS in the tags array then use them to create a wishlist.
 */
if (count($asins_list) != 0 && is_array($asins_list)) {
    if (strcasecmp($settings[$cc]['wishlist_type'], 'similar') == 0) {
        // Special case we want to get 'similar' products to the ones listed...
        // Construct a request to get the Cart Similarities for the items found
        $request = array('Operation' => 'CartCreate', 'MergeCart' => 'True', 'ResponseGroup' => 'CartSimilarities', 'IdType' => 'ASIN', 'MerchantId' => 'Amazon');
        $counter = 1;
        foreach ($asins_list as $asins) {
            $asin = isset($asins[$cc]) ? $asins[$cc] : (isset($asins[$settings['default_cc']]) ? $asins[$settings['default_cc']] : '');
            $request['Item.' . $counter . '.ASIN'] = $asin;
Пример #3
0
    $_remove_this_one = '';
    foreach ($_tags_array as $key => $value) {
        $word = trim($value);
        fw("word: [" . $word . "]");
        if ($wrd == $word) {
            fw("found: [" . $word . "]");
            $_remove_this_one = $key;
        }
    }
    if ($_remove_this_one != '') {
        unset($_tags_array[$_remove_this_one]);
        $_tags_array = array_values($_tags_array);
        var_dump($_tags_array);
    }
    // remove duplcates
    $_tags_array = remove_duplicates($_tags_array);
    $original_tags = implode(", ", $_tags_array);
    $original_tags = str_replace("  ", " ", $original_tags);
    /*
    	$original_tags = str_replace(",", ", ", $original_tags);
    	$original_tags = str_replace("  ", " ", $original_tags);
    	$original_tags = str_replace($wrd, "", $original_tags);
    */
    $sql = "update wp_product_list set additional_description = '" . $original_tags . "' where id=" . $id;
    $result = mysql_query($sql);
    if (!$result) {
        die('Invalid query: ' . mysql_error());
    }
    mysql_close($link);
}
return;
Пример #4
0
function get_column($col_name, $filters)
{
    $reader = get_sheet_reader('..');
    $col_list = [];
    $first = 1;
    foreach ($reader as $row) {
        if ($first) {
            $keys = $row;
            $first = 0;
        } else {
            if (passes_filters($keys, $row, $filters)) {
                $col_list = array_merge($col_list, get_from_row($col_name, $keys, $row));
            }
        }
    }
    sort($col_list);
    return remove_duplicates($col_list);
}