Revision [6274]
This is an old revision of JeroenJansen made by JeroenJansen on 2005-02-23 20:20:52.
Im working on my graduation thesis which is about wiki usage in higher education.
Please leave a message after the beep (which you'll hear eventually if you listen long enough).
Draft. Recently edited social awareness functionality
Patch description
If you open a WikiPage in edit mode (invoke the edit page handler),
a display of social awareness information might come in handy (eg. for collaboration purposes).
This patch displays an overview of users who recently opened the WikiPage in edit mode, on a per-page basis.
If you want this functionality you need to do the following:
1. Create new table to log necessary information.
CREATE TABLE yourprefix_log (
id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
handler VARCHAR(30) NOT NULL DEFAULT '',
tag VARCHAR(75) NOT NULL DEFAULT '0',
username VARCHAR(255) NOT NULL DEFAULT '',
accessed_at datetime NOT NULL,
PRIMARY KEY (id)
) TYPE=MyISAM;
id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
handler VARCHAR(30) NOT NULL DEFAULT '',
tag VARCHAR(75) NOT NULL DEFAULT '0',
username VARCHAR(255) NOT NULL DEFAULT '',
accessed_at datetime NOT NULL,
PRIMARY KEY (id)
) TYPE=MyISAM;
2. Patch edit page handler, handler/page/edit.php
//PATCH BEGIN
// indicates the number of minutes logs will be shown, eg. 5 = display users who accessed page in last 5 minutes and purge the rest
$minutes_interval = 30;
// first purge old showlogs
$deletebool = $this->Query("DELETE FROM ".$this->config["table_prefix"]."log WHERE handler=\"edit\" AND tag=\"" . $this->GetPageTag() . "\" AND accessed_at < (NOW() - INTERVAL " . $minutes_interval . " MINUTE)");
// if latest page version insert record in viewlog
$insertbool = $this->Query("INSERT INTO ".$this->config["table_prefix"]."log VALUES(\"\", \"edit\", \"" . $this->GetPageTag(). "\", \"" . $this->GetUserName() . "\", NOW()" . ")");
if($insertbool && $deletebool) $ispurged = true;
$lastusers = $this->LoadAll("SELECT * FROM ".$this->config["table_prefix"]."log WHERE handler=\"edit\" AND tag=\"" . $this->GetPageTag() . "\" AND accessed_at >= (NOW() - INTERVAL " . $minutes_interval . " MINUTE) GROUP BY username ORDER by username DESC");
foreach ($lastusers as $lastuser){
if($lastuser["username"] != $this->GetUserName()) {
if($x > 0) $userstoprint .= "::";
$userstoprint .= $this-Format($lastuser["username"]);
$x++;
}
}
if($userstoprint) $lastusersmessage = "In de laatste " . $minutes_interval . " minuten hebben de volgende gebruikers deze pagina in editmodus geopend: <p>" .$userstoprint . "</p>\n";
$output .= $lastusersmessage;
//PATCH END
// indicates the number of minutes logs will be shown, eg. 5 = display users who accessed page in last 5 minutes and purge the rest
$minutes_interval = 30;
// first purge old showlogs
$deletebool = $this->Query("DELETE FROM ".$this->config["table_prefix"]."log WHERE handler=\"edit\" AND tag=\"" . $this->GetPageTag() . "\" AND accessed_at < (NOW() - INTERVAL " . $minutes_interval . " MINUTE)");
// if latest page version insert record in viewlog
$insertbool = $this->Query("INSERT INTO ".$this->config["table_prefix"]."log VALUES(\"\", \"edit\", \"" . $this->GetPageTag(). "\", \"" . $this->GetUserName() . "\", NOW()" . ")");
if($insertbool && $deletebool) $ispurged = true;
$lastusers = $this->LoadAll("SELECT * FROM ".$this->config["table_prefix"]."log WHERE handler=\"edit\" AND tag=\"" . $this->GetPageTag() . "\" AND accessed_at >= (NOW() - INTERVAL " . $minutes_interval . " MINUTE) GROUP BY username ORDER by username DESC");
foreach ($lastusers as $lastuser){
if($lastuser["username"] != $this->GetUserName()) {
if($x > 0) $userstoprint .= "::";
$userstoprint .= $this-Format($lastuser["username"]);
$x++;
}
}
if($userstoprint) $lastusersmessage = "In de laatste " . $minutes_interval . " minuten hebben de volgende gebruikers deze pagina in editmodus geopend: <p>" .$userstoprint . "</p>\n";
$output .= $lastusersmessage;
//PATCH END
CategoryUsers