===Advanced Sumary View of UserPages=== This action displays all the users and their pages. Also reveals the percentage they own from the total ""WikiPages"" and ""WikiComments"". The layout can be customised using attributes when calling the function. ==Typical Use== Use like : ""{{describeusers}}"" If you want to customise the appearance you may use a syntax similar to this : ""{{describeusers cellpadding="5" cellspacing="3" border="1" columns="2"}}"" @@Don't Forget To Read The Notes Within The Code@@ ==How to use== You will need **/wikka/actions/describeusers.php** with the following contents. %%(php) $v){ if ($att == 'columns') $columns=$v; if ($att == 'cellpadding') $cellpadding=$v; if ($att == 'cellspacing') $cellspacing=$v; if ($att == 'border') $border=$v; } // Getting the comments count ... $total_wikicomments = 0; $res = $this->LoadAll("SELECT Count(*) FROM ".$this->config['table_prefix']."comments GROUP BY page_tag"); foreach($res as $i => $arr) { foreach($arr as $t => $c){ $total_wikicomments += $c; } } // Getting the pages count ... $total_wikipages = 0; $res = $this->LoadAll("SELECT Count(*) from ".$this->config['table_prefix']."pages WHERE latest ='Y' GROUP BY tag"); foreach($res as $i => $arr) { foreach($arr as $t => $c){ $total_wikipages += $c; } } //print $total_wikipages." -- \n"; // Lets get all the usernames in an array... $all_usernames = array(); $res = $this->LoadAll("SELECT name from ".$this->config['table_prefix']."users"); foreach($res as $i => $arr) { foreach ($arr as $t => $name){ $res_pagenames = $this->LoadAll("SELECT tag,datediff(time, now()) as last_edit FROM ".$this->config['table_prefix']."pages WHERE owner='$name' and latest ='Y' GROUP BY tag"); $temp = array(); foreach($res_pagenames as $i => $page) { $le = abs($page['last_edit']+0) ; if ($le > 1) { $le = "$le days ago"; } else if ($le == 1) { $le = "yesterday"; } else {$le = "today";} $temp['pages'][$page['tag']] = "$le"; } $temp['commentscount'] = count($this->LoadAll("SELECT Count(*) FROM ".$this->config['table_prefix']."comments WHERE user='$name' GROUP BY id")); } $all_usernames[$name] = $temp; } $the_big_one = array(); foreach($all_usernames as $name => $arr){ $name = $this->Format($name); $row_one = "$name | Pages: ".count($arr['pages'])." | Comments: ".$arr['commentscount']; $row_two = "Owns ".round( ( ((count($arr['pages']))*100)/$total_wikipages ), 2)."% of all the pages and
".round( ( (($arr['commentscount'])*100)/$total_wikicomments ), 2)."% of all comments in this wiki"; $row_three = ''; $row_three .= ''; if (!count($arr['pages'])) { $row_three .= ""; } else { foreach($arr['pages'] as $p => $l){ //print "$p - $l\n"; $row_three .= ""; } } $row_three .= "
Page| Last Edit
none| never
".$this->Format($p)."| $l
"; $out = ""; $out .= ""; $out .= ""; $out .= ""; $out .= "
$row_one
$row_two
$row_three
"; // print $out; $the_big_one[] = $out; } $fin = "
"; //var_dump($the_big_one); foreach($the_big_one as $i => $cell){ if ($row == 1) $fin .= "\n \n"; $fin .= "\n"; $row++; if ($row > $columns) { $row = 1; $fin .= " \n
$cell
\n
"; } } echo $this->ReturnSafeHTML($fin); } ?>%% ~& Thanks so much for all of this work!! I've found a couple of errors/problems which I have suggested fixes for below. - CharlotteFischer For those of us for whom upgrading to mySQL 4.1 is more bother than correcting a few lines of code: make this correction to line 52 %%(php) $res_pagenames = $this->LoadAll("SELECT tag,TO_DAYS(now())-TO_DAYS(time) AS last_edit FROM ".$this->config['table_prefix']."pages WHERE owner='$name' and latest ='Y' GROUP BY tag"); %% And for those of us with users who have made no comments or created no pages: replace line 74 with this %%(php) // CORRECTION OF DIVISION-BY-ZERO ERROR if($total_wikipages>0) $percent_pages = round( ( ((count($arr['pages']))*100)/$total_wikipages ), 2); else $percent_pages = 0; if($total_wikicomments>0) $percent_comments = round( ( (($arr['commentscount'])*100)/$total_wikicomments ), 2); else $percent_comments = 0; $row_two = "Owns ".$percent_pages."% of all the pages and
".$percent_comments."% of all comments in this wiki"; %% ---- CategoryUserContributions