Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#145 histlib.php->get_last_changes fix

open
nobody
None
5
2012-12-08
2004-09-22
No

Hi,

The get_last_changes function has been unable to
display items from the action log which related to pages
which had been removed. I am submitting a new version
of this function which can do this:

// This function get the last changes from pages from
the last $days days
// if days is 0 this gets all the registers
// function parameters modified by ramiro_v on
11/03/2002
function get_last_changes($days, $offset = 0,
$limit = -1, $sort_mode = 'lastModif_desc', $findwhat
= '') {

    $where = "";
    $bindvars = array\(\);
    $conjunc = "";
    if \($findwhat\) \{
        $findstr='%' .

$findwhat . '%';
$where.= "where
ta.`pageName` like ? or ta.`user` like ? or
ta.`comment` like ?";
$bindvars = array
($findstr,$findstr,$findstr);
$conjunc = "and ";
}

    if \($days\) \{
        $toTime = mktime\(23, 59,

59, date("m"), date("d"), date("Y"));
$fromTime = $toTime - (24
* 60 * 60 * $days);
if ($conjunc){
$where.=
$conjunc . "ta.`lastModif`>=? and ta.`lastModif`<=? ";
} else {
$where.= "where
ta.`lastModif`>=? and ta.`lastModif`<=? ";
}
$bindvars[] = $fromTime;
$bindvars[] = $toTime;
}

    $query = "select ta.\`action\`,

ta.`lastModif`, ta.`user`, ta.`ip`,
ta.`pageName`,ta.`comment`, th.`version` as version,
tp.`version` as versionlast from `tiki_actionlog` ta
left join `tiki_history` th on
ta.`pageName`=th.`pageName` and
ta.`lastModif`=th.`lastModif`
left join `tiki_pages` tp on
ta.`pageName`=tp.`pageName` and
ta.`lastModif`=tp.`lastModif` " . $where . " order by
ta.".$this->convert_sortmode($sort_mode);
$query_cant = "select count(*) from
`tiki_actionlog` ta
left join `tiki_history` th on
ta.`pageName`=th.`pageName` and
ta.`lastModif`=th.`lastModif`
left join `tiki_pages` tp on
ta.`pageName`=tp.`pageName` and
ta.`lastModif`=tp.`lastModif` " . $where;

    $result = $this-&gt;query

($query,$bindvars,$limit,$offset);
$cant = $this->getOne
($query_cant,$bindvars);
$ret = array();
$retval = array();
while ($res = $result->fetchRow()) {
$ret[] = $res;
}
$retval["data"] = $ret;
$retval["cant"] = $cant;
return $retval;
}

--Stephen

Discussion

  • The modified function as a file.

     
    Attachments