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
    /*
        @filename:      describeusers.php
        @author:        George Petsagourakis
        @email:         petsagouris@hotmail.com
        @date:          18 Dec 2004
        @license:       GPL
        @todo:          Suggestions welcome ...
            @description:   it displays all the users and lists the WikiPages they own.
                            also displays the percentages of comments and pages they own in the wiki.
                        owned pages count and own comments count is also diaplayed.
        @usage:         insert {{describeusers}} any where in a wakka page.
                        Example : {{describeusers cellpadding="5" cellspacing="3" border="1" columns="2"}}
                        You may use the above syntax to customise the layout of the output.
                        Any of the attributes may be mentioned or not ;)
    */

    $row = 1;
    $cellpadding = 1;
    $cellspacing = 1;
    $border = 0;
    $columns = 3;

    if (is_array($vars)){
        foreach ($vars as $att => $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 <br />".round( ( (($arr['commentscount'])*100)/$total_wikicomments ), 2)."% of all comments in this wiki";

            $row_three = '<table width="100%" border="0" cellpadding="1">';
            $row_three .= '<tr><td>Page</td><td align=\"left\">| Last Edit</td></tr>';
            if (!count($arr['pages'])) {
                $row_three .= "<tr><td>none</td><td align=\"left\">| <em>never</em></td></tr>";
            }
            else {
                foreach($arr['pages'] as $p => $l){
                    //print "$p - $l\n";
                    $row_three .= "<tr><td align=\"left\">".$this->Format($p)."</td><td align=\"left\">| <em>$l</em></td></tr>";
                }
            }
            $row_three .= "</table>";

            $out = "<table border=\"0\" cellpadding=\"3\">";
            $out .= "<tr><td>$row_one</td></tr>";
            $out .= "<tr><td>$row_two</td></tr>";
            $out .= "<tr><td>$row_three</td></tr>";
            $out .= "</table>";
            // print $out;
            $the_big_one[] = $out;
        }
        $fin = "<hr />";
        //var_dump($the_big_one);
        foreach($the_big_one as $i => $cell){
            if ($row == 1) $fin .= "<table width=\"100%\" border=\"$border\" cellspacing=\"$cellspacing\" cellpadding=\"$cellpadding\">\n   <tr>\n";
            $fin .= "<td width=\"".(100/$columns)."%\"valign=\"top\" align=\"center\">$cell</td>\n";
            $row++;
            if ($row > $columns) {
                $row = 1;
                $fin .= "   </tr>\n</table>\n<hr />";
            }
        }
        echo $this->ReturnSafeHTML($fin);
    }
?>



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
$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
// 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 <br />".$percent_comments."% of all comments in this wiki";


CategoryUserContributions
Comments
Comment by DarTar
2004-12-20 10:12:06
George, I'll give it a look. We should really try to unify our efforts to improve user management. My UserPagesAction was actually a quick hack of MyPages to implement it as a module for http://wikka.jsnx.com/UserAdmin, where I think all the general user info should be centralized.
Comment by GeorgePetsagourakis
2004-12-20 13:31:03
I totaly agree ..
what would you propose that I do with this ? :)
should i develop further? ( pls guide me how )
should I help in some other part ?
I am willing to assist in any coding ;)
Comment by JavaWoman
2004-12-20 15:33:42
George,
I like the idea of presenting (probably only to an Admin) a lot of information about users. However, looking at the code, I'm rather horrified seeing it generates a triply-nested table (and not a data table, as it should be, but a layout table) - the result is totally inaccessible. Also with a lot of users, this could lead to a HUMUNGOUS page: a paging function would be in order.

Of course if you want to continue developing it, fine. But I'd suggest treating it as a "presentation of an idea" (a good idea) which would need a rather different implementation.

Hope you're not insulted by that - that's definitely not my intention! I *would* like to see the idea implemented. Just not like this. :)
Comment by GeorgePetsagourakis
2004-12-20 16:31:38
jw: Insults are not part of the web,.. on the contrary it encourages me to keep this moving ..

can someone give me a pointer on how to take away those "triply-nested tables" maybe div's are the way forward ? :)
Comment by JavaWoman
2004-12-20 17:42:19
George,
No, not divs, on the contrary, a *data* table ('cause that's what it is, really)! For some hints, have a look at GmBowenCalendar (which also had a triply nested table) and what I came up with (in JwCalendar): a more structured variant with an accessible, single data table. On the latter page is also a link to a good article about doing data tables in (X)HtML.

See if that is "pointer" enough. If not, ask!
Comment by StewartPlatt
2005-05-01 12:17:11
Perhaps this is only a problem on my particular server, however I get SQL errors when saving a page using this action 'as is'. Using 1.1.6.0 though, maybe this is the problem ;)
Comment by NilsLindenberg
2005-05-02 10:43:42
I'm sure it would be helpfull if you would say **what** error you get :)
Comment by StewartPlatt
2005-05-02 14:41:18
Sorry, I thought better of it and wanted to look into it myself first, my host has various security measures and diferences to most so I'm not sure if it's an error other people will be experiencing. Will see if I can fix it and report back soon!
Comment by NilsLindenberg
2005-05-03 15:07:59
No need to be sorry. I just wanted to inform you :)
Comment by KairoMiami
2007-11-21 06:57:56
Hi George. You did a marvelous job on me with explaining how to install "external plugins". i'm so new to wikkawiki, (still have to look at the hints how the script is actually called as i want to call it wikikiki, but nevertheless...) here's my question, can you throw a decent look at:

http://www.genfusion.net/ww/wikka.php?wakka=describeusers

the script doensn't work. it's: i grabbed and uploaded the scrpt to the actions folder, i even chmodded to 777 (the file) and still get an empty page, unexplained and nonethless not very helpful. i do have a user, but it's not listed... ??? :-)

thanks, and happy week, Tobias Kalle Aellig

PS. Go to http://www.genfusion.info too ... :-) We need nice and good-looking helpers... :-)

///----
(now a test for myself {{http://www.genfusion.info http://www.genfusion.info}} )
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki