Esempio n. 1
0
 case 'lister_items_groupe':
     $arbo_html = $html = "";
     $folder_is_pf = $show_error = 0;
     $items_id_list = $rights = array();
     //Build query limits
     if (empty($_POST['start'])) {
         $start = 0;
         $html = '<ul class="liste_items">';
     } else {
         $start = $_POST['start'];
         $html = '<ul class="liste_items" style="">';
     }
     //Prepare tree
     require_once "NestedTree.class.php";
     $tree = new NestedTree($pre . 'nested_tree', 'id', 'parent_id', 'title');
     $arbo = $tree->getPath($_POST['id'], true);
     foreach ($arbo as $elem) {
         if ($elem->title == $_SESSION['user_id'] && $elem->nlevel == 1) {
             $elem->title = $_SESSION['login'];
             $folder_is_pf = 1;
         }
         if (empty($arbo_html)) {
             $arbo_html = htmlspecialchars(stripslashes($elem->title), ENT_QUOTES);
         } else {
             $arbo_html .= " » " . htmlspecialchars(stripslashes($elem->title), ENT_QUOTES);
         }
     }
     //check if this folder is a PF. If yes check if saltket is set
     if ((!isset($_SESSION['my_sk']) || empty($_SESSION['my_sk'])) && $folder_is_pf == 1) {
         $show_error = "is_pf_but_no_saltkey";
     }
Esempio n. 2
0
     $rows = mysql_query($sql);
     while ($reccord = mysql_fetch_array($rows)) {
         //Get all TAGS
         $tags = "";
         $items_res = mysql_query("SELECT tag FROM " . $_SESSION['tbl_prefix'] . "tags WHERE item_id=" . $reccord['id']) or die(mysql_error());
         $item_tags = mysql_fetch_array($items_res);
         if (!empty($item_tags)) {
             foreach ($item_tags as $item_tag) {
                 if (!empty($item_tag['tag'])) {
                     $tags .= $item_tag['tag'] . " ";
                 }
             }
         }
         //form id_tree to full foldername
         $folder = "";
         $arbo = $tree->getPath($reccord['id_tree'], true);
         foreach ($arbo as $elem) {
             $folder .= htmlspecialchars(stripslashes($elem->title), ENT_QUOTES) . " > ";
         }
         //store data
         mysql_query("INSERT INTO " . $_SESSION['tbl_prefix'] . "cache\r\n                        VALUES (\r\n                            '" . $reccord['id'] . "',\r\n                            '" . $reccord['label'] . "',\r\n                            '" . $reccord['description'] . "',\r\n                            '" . $tags . "',\r\n                            '" . $reccord['id_tree'] . "',\r\n                            '" . $reccord['perso'] . "',\r\n                            '" . $reccord['restricted_to'] . "',\r\n                            '" . $reccord['login'] . "',\r\n                            '" . $folder . "'\r\n                        )");
     }
     echo 'document.getElementById("tbl_7").innerHTML = "<img src=\\"images/tick.png\\">";';
 } else {
     echo 'document.getElementById("res_step4").innerHTML = "An error appears on table CACHE!";';
     echo 'document.getElementById("tbl_7").innerHTML = "<img src=\\"images/exclamation-red.png\\">";';
     echo 'document.getElementById("loader").style.display = "none";';
     mysql_close($db_tmp);
     break;
 }
 /*
Esempio n. 3
0
/**
 * UpdateCacheTable()
 *
 * Update the CACHE table
 */
function UpdateCacheTable($action, $id = "")
{
    global $db, $server, $user, $pass, $database, $pre;
    //include librairies
    require_once "NestedTree.class.php";
    //Build tree
    $tree = new NestedTree($pre . 'nested_tree', 'id', 'parent_id', 'title');
    //Rebuild full cache table
    if ($action == "reload") {
        //truncate table
        $db->query("TRUNCATE TABLE " . $pre . "cache");
        //reload date
        $sql = "SELECT *\r\n                FROM " . $pre . "items\r\n                WHERE inactif=0";
        $rows = $db->fetch_all_array($sql);
        foreach ($rows as $reccord) {
            //Get all TAGS
            $tags = "";
            $item_tags = $db->fetch_all_array("SELECT tag FROM " . $pre . "tags WHERE item_id=" . $reccord['id']);
            foreach ($item_tags as $item_tag) {
                if (!empty($item_tag['tag'])) {
                    $tags .= $item_tag['tag'] . " ";
                }
            }
            //form id_tree to full foldername
            $folder = "";
            $arbo = $tree->getPath($reccord['id_tree'], true);
            foreach ($arbo as $elem) {
                if ($elem->title == $_SESSION['user_id'] && $elem->nlevel == 1) {
                    $elem->title = $_SESSION['login'];
                }
                if (empty($folder)) {
                    $folder = stripslashes($elem->title);
                } else {
                    $folder .= " » " . stripslashes($elem->title);
                }
            }
            //store data
            $db->query_insert("cache", array('id' => $reccord['id'], 'label' => $reccord['label'], 'description' => $reccord['description'], 'tags' => $tags, 'id_tree' => $reccord['id_tree'], 'perso' => $reccord['perso'], 'restricted_to' => $reccord['restricted_to'], 'login' => $reccord['login'], 'folder' => $folder));
        }
        //UPDATE an item
    } else {
        if ($action == "update_value") {
            //get new value from db
            $sql = "SELECT label, description, id_tree, perso, restricted_to, login\r\n                FROM " . $pre . "items\r\n                WHERE id=" . $id;
            $row = $db->query($sql);
            $data = $db->fetch_array($row);
            //Get all TAGS
            $tags = "";
            $item_tags = $db->fetch_all_array("SELECT tag FROM " . $pre . "tags WHERE item_id=" . $id);
            foreach ($item_tags as $item_tag) {
                if (!empty($item_tag['tag'])) {
                    $tags .= $item_tag['tag'] . " ";
                }
            }
            //form id_tree to full foldername
            $folder = "";
            $arbo = $tree->getPath($data['id_tree'], true);
            foreach ($arbo as $elem) {
                if ($elem->title == $_SESSION['user_id'] && $elem->nlevel == 1) {
                    $elem->title = $_SESSION['login'];
                }
                if (empty($folder)) {
                    $folder = stripslashes($elem->title);
                } else {
                    $folder .= " » " . stripslashes($elem->title);
                }
            }
            //finaly update
            $db->query_update("cache", array('label' => $data['label'], 'description' => $data['description'], 'tags' => $tags, 'id_tree' => $data['id_tree'], 'perso' => $data['perso'], 'restricted_to' => $data['restricted_to'], 'login' => $data['login'], 'folder' => $folder), "id='" . $id . "'");
            //ADD an item
        } else {
            if ($action == "add_value") {
                //get new value from db
                $sql = "SELECT label, description, id_tree, perso, restricted_to, id, login\r\n                FROM " . $pre . "items\r\n                WHERE id=" . $id;
                $row = $db->query($sql);
                $data = $db->fetch_array($row);
                //Get all TAGS
                $tags = "";
                $item_tags = $db->fetch_all_array("SELECT tag FROM " . $pre . "tags WHERE item_id=" . $id);
                foreach ($item_tags as $item_tag) {
                    if (!empty($item_tag['tag'])) {
                        $tags .= $item_tag['tag'] . " ";
                    }
                }
                //form id_tree to full foldername
                $folder = "";
                $arbo = $tree->getPath($row['id_tree'], true);
                foreach ($arbo as $elem) {
                    if ($elem->title == $_SESSION['user_id'] && $elem->nlevel == 1) {
                        $elem->title = $_SESSION['login'];
                    }
                    if (empty($folder)) {
                        $folder = stripslashes($elem->title);
                    } else {
                        $folder .= " » " . stripslashes($elem->title);
                    }
                }
                //finaly update
                $db->query_insert("cache", array('id' => $data['id'], 'label' => $data['label'], 'description' => $data['description'], 'tags' => $tags, 'id_tree' => $data['id_tree'], 'perso' => $data['perso'], 'restricted_to' => $data['restricted_to'], 'login' => $data['login'], 'folder' => $folder));
                //DELETE an item
            } else {
                if ($action == "delete_value") {
                    mysql_query("DELETE FROM " . $pre . "cache WHERE id = " . $id);
                }
            }
        }
    }
}