<?php # Copyright(C) 2004-2008 INL # Written by Eric Leblond <regit@inl.fr> # Vincent Deffontaines <gryzor@inl.fr> # Jean Gillaux <jean@inl.fr> # Damien Boucard <damien.boucard AT inl.fr> # # $Id: history.php 17927 2009-02-16 13:16:09Z haypo $ # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, version 3 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see <http://www.gnu.org/licenses/>. function updateHistoryWrapper($page,$element=0, $ress) { if ($element == 0) { # updateHistory($page); return(0); } $my_elt = $ress->get_elt($element); if (!isset($my_elt)) { # updateHistory($page); return(0); } if (isset($my_elt->name)) { updateHistory($page,$element,$my_elt->name); return(0); } $tab=$my_elt->get_obj(); if (isset($tab{'name'})) updateHistory($page,$element,$tab{'name'}); } function updateHistory($page,$element,$elementname) { $max_history_size = 20; $donothing=0; $history = getSession('history', true, Array()); $new = array($page,$element,$elementname); foreach ($history as $elt) { if (count(array_diff($elt,$new))==0) { $donothing++; } } # print_pre($history); if ($donothing==0) { array_push($history,$new); if (count($history) > $max_history_size) { array_shift($history); } $_SESSION{'history'} = serialize($history); } } function deletefromhistory($type,$nb) { $history = getSession('history', true, Array()); foreach ($history as $key=>$histtab) { if (($histtab[0] == $type) and ($histtab[1]==$nb)) { # $tmp_array = array($histtab[0], $histtab[1], $histtab[2]); # print_pre(array_diff($histtab, array($id, $tmp_array))); #$history = array_diff($histtab, array($type, $nb)); unset ($history[$key]); } } $_SESSION{'history'} = serialize($history); } ?>