Changeset 1021

Show
Ignore:
Timestamp:
03/30/2008 01:46:37 AM (15 months ago)
Author:
BrianKoontz
Message:

Port of {{adminusers}} action to 1.1.7. Refs #575, #608.

Location:
trunk
Files:
13 added
7 modified

Legend:

Unmodified
Added
Removed
  • trunk/actions/mychanges/mychanges.php

    r911 r1021  
    3535$time_output = ''; 
    3636 
    37 if ($this->existsUser()) 
     37$params = '';  
     38$username = '';  
     39if(isset($_REQUEST['user']))  
     40{  
     41        $username = $this->htmlspecialchars_ent($_REQUEST['user']);  
     42        $params .= "user=$username&";  
     43}  
     44  
     45$action = '';  
     46if(isset($_REQUEST['action']))  
     47{  
     48        $action = $this->htmlspecialchars_ent($_REQUEST['action']);  
     49        $params .= "action=$action&";  
     50}  
     51$params = substr($params, 0, -1);  
     52  
     53if (($this->IsAdmin() && !empty($username)) ||  
     54                ($this->existsUser() &&  $username = $this->GetUserName()))  
    3855{ 
    3956        $my_edits_count = 0; 
     
    4360        if ($alpha) 
    4461        { 
    45                 $output .= MYCHANGES_ALPHA_LIST.' (<a href="'.$this->href("", $tag).'">'.ORDER_DATE_LINK_DESC; 
     62        $output .= sprintf(MYCHANGES_ALPHA_LIST, $username).' (<a href="'.$this->Href("", $tag, $params).'">'.ORDER_DATE_LINK_DESC; 
    4663        } 
    4764        else 
    4865        { 
    49                 $output .= MYCHANGES_DATE_LIST.' (<a href="'.$this->href("", $tag, "alphabetically=1").'">'.ORDER_ALPHA_LINK_DESC; 
     66                if(!empty($params))  
     67                {  
     68                        $params .= "&alphabetically=1";  
     69                }  
     70                else  
     71                {  
     72                        $params = "alphabetically=1";  
     73                }  
     74 
     75                $output .= sprintf(MYCHANGES_DATE_LIST, $username).' (<a href="'.$this->href("", $tag, $params).'">'.ORDER_ALPHA_LINK_DESC;  
    5076        } 
    5177        $output .= '</a>)</div><div class="clear">&nbsp;</div>'."\n"; 
     
    5581                SELECT id, tag, time 
    5682                FROM ".$this->GetConfigValue('table_prefix')."pages 
    57                 WHERE user = '".mysql_real_escape_string($this->reg_username)."' 
     83                WHERE user = '".mysql_real_escape_string($username)."' 
    5884                AND latest = 'Y' 
    5985                ORDER BY ".$order; 
  • trunk/actions/mypages/mypages.php

    r820 r1021  
    2222 */ 
    2323 
    24 #if ($user = $this->GetUser()) 
    25 if ($this->existsUser()) 
     24$username = ''; 
     25if(isset($_REQUEST['user'])) 
    2626{ 
    27         echo '<div class="floatl">'.OWNED_PAGES_TXT.'</div><div class="clear">&nbsp;</div>'."\n"; 
     27        $username = $this->htmlspecialchars_ent($_REQUEST['user']);  
     28} 
     29if (($this->IsAdmin() && !empty($username)) ||  
     30                ($this->GetUser() && $username = $this->GetUserName()))  
     31{  
     32        printf("<div class="floatl">".OWNED_PAGES_TXT."</div><div class="clear">&nbsp;</div>\n", $username); 
    2833        $curChar = ''; 
    2934 
     
    3237        if ($pages = $this->LoadPagesByOwner($this->reg_username)) 
    3338        { 
     39                $my_pages_count = 0; 
    3440                foreach ($pages as $page) 
    3541                { 
    36                         //if ($this->GetUserName() == $page["owner"]) 
    37                         //{ 
     42                        if($username == $page['owner']) 
     43                        { 
     44                                ++$my_pages_count; 
    3845                                $firstChar = strtoupper($page["tag"][0]); 
    3946                                if (!preg_match("/[A-Z,a-z]/", $firstChar)) //TODO: (#104 #340, #34) Internationalization (allow other starting chars, make consistent with Formatter REs) 
     
    5158                                echo $this->Link($page['tag'])."<br />\n"; 
    5259 
    53                         //} 
     60                        } 
     61                } 
     62                if($my_pages_count == 0) 
     63                { 
     64                        print("<em class='error'>".MYPAGES_NONE_OWNED."</em>"); 
    5465                } 
    5566 
  • trunk/css/wikka.css

    r954 r1021  
    235235 
    236236tt { 
    237         color: #666; 
     237        color: #393; 
     238        background-color: #EFE; 
    238239} 
    239240 
     
    325326.code { 
    326327        color: black; 
    327         background: #FAFAFA; 
     328        background: #ffffee; 
    328329        border: 1px solid #CCC; 
    329330        font-size: 11px; 
     
    402403} 
    403404 
    404 input[readonly=readonly] { 
    405         color: #666; 
    406 } 
    407  
    408 input[readonly=readonly]:hover, input[readonly=readonly]:focus { 
    409         background-color: transparent; 
    410 } 
    411  
    412 /* editor textarea decorations */ 
    413 /* (decorations can't be in "textarea#body" declaration, else the "width:100%" won't work) */ 
    414 #textarea_container { 
    415         border: 1px solid #CCC; 
    416         padding: 2px; 
    417         margin-bottom: 2px; 
    418 } 
    419  
    420405textarea#body{ 
    421406        width: 100%; 
    422407        height: 500px; 
    423         /* padding and border must be 0 for the "width:100%" to work */ 
    424         padding: 0; 
    425         border: 0; 
     408        padding: 2px; 
    426409} 
    427410 
     
    446429 
    447430/* system information */ 
    448  
    449 .datetime { 
    450         color: #666; 
    451         font-size: 80%; 
    452         font-family: "Lucida Console", Monaco, monospace; 
    453 } 
    454431 
    455432.missingpage { 
     
    541518} 
    542519 
     520.recentchanges {font-size: 0.9em;} 
     521 
    543522.pagenote {color: #888;} 
    544523 
     
    553532} 
    554533 
     534/* ACTION-related styling */ 
     535 
     536/* File attachments */ 
     537 
     538div.files { 
     539        display: block; 
     540        padding: 5px; 
     541        width: 40%; 
     542} 
     543 
     544table.files { 
     545        width: 100%; 
     546        font-size: 90%; 
     547        border: 2px solid #CCC; 
     548        border-collapse: collapse; 
     549        border-spacing: 0; 
     550} 
     551 
     552table.files caption { 
     553        border: 1px solid #CCC; 
     554        color: #666; 
     555        margin:5px 0; 
     556        padding:2px; 
     557} 
     558 
     559table.files thead { 
     560        background-color: #DDD; 
     561} 
     562 
     563table.files th, table.files td { 
     564        border: 1px solid #CCC; 
     565        padding: 1px 3px; 
     566} 
     567 
     568table.files thead th { 
     569        background-color: #DDD; 
     570} 
     571 
     572table.files tfoot th { 
     573        background-color: #DDD; 
     574} 
     575 
     576table.files tbody th { 
     577        background-color: #EEE; 
     578} 
     579 
     580table.files tbody tr:hover { 
     581        background-color: #EEE; 
     582} 
     583 
    555584/* Tables */ 
    556  
    557585table.data { 
    558586        border: 2px solid #CCC; 
     
    598626} 
    599627 
    600 table.data tbody tr.alt:hover { 
    601         background-color: #E9E9F9; 
    602 } 
    603  
    604628table.data td { 
    605629        border: 1px solid #CCC; 
    606630        padding: .1em .25em; 
    607 } 
    608  
    609 table.data td.number { 
    610         text-align: right; 
    611 } 
    612  
    613 table.data td.datetime { 
    614         color: #666; 
    615         font-size: 80%; 
    616         font-family: "Lucida Console", Monaco, monospace; 
    617         text-align: right; 
    618         white-space: nowrap; 
    619 } 
    620  
    621 /* --- alternate row & column color --- */ 
    622  
    623 table.data tr.alt { 
    624         background-color: #EEE; 
    625 } 
    626  
    627 table.data th.c1 { 
    628         background-color: #CDD; 
    629 } 
    630  
    631 table.data th.c2 { 
    632         background-color: #DCC; 
    633 } 
    634  
    635 table.data th.c3 { 
    636         background-color: #DDC; 
    637 } 
    638  
    639 table.data th.c4 { 
    640         background-color: #CDC; 
    641 } 
    642  
    643 table.data th.c5 { 
    644         background-color: #CCD; 
    645 } 
    646  
    647 table.data th.c6 { 
    648         background-color: #DCD; 
    649 } 
    650  
    651 table.data td.c1 { 
    652         background-color: #EFF; 
    653 } 
    654  
    655 table.data td.c2 { 
    656         background-color: #FEE; 
    657 } 
    658  
    659 table.data td.c3 { 
    660         background-color: #FFE; 
    661 } 
    662  
    663 table.data td.c4 { 
    664         background-color: #EFE; 
    665 } 
    666  
    667 table.data td.c5 { 
    668         background-color: #EEF; 
    669 } 
    670  
    671 table.data td.c6 { 
    672         background-color: #FEF; 
    673 } 
    674  
    675 table.data tr.alt td.c1 { 
    676         background-color: #DEE; 
    677 } 
    678  
    679 table.data tr.alt td.c2 { 
    680         background-color: #EDD; 
    681 } 
    682  
    683 table.data tr.alt td.c3 { 
    684         background-color: #EED; 
    685 } 
    686  
    687 table.data tr.alt td.c4 { 
    688         background-color: #DED; 
    689 } 
    690  
    691 table.data tr.alt td.c5 { 
    692         background-color: #DDE; 
    693 } 
    694  
    695 table.data tr.alt td.c6 { 
    696         background-color: #EDE; 
    697 } 
    698  
    699 /* ACTION-related styling */ 
    700  
    701 /* Files action */ 
    702  
    703 div.files { 
    704         display: block; 
    705         padding: 5px; 
    706         width: 40%; 
    707 } 
    708  
    709 table.files { 
    710         width: 100%; 
    711         font-size: 90%; 
    712         border: 2px solid #CCC; 
    713         border-collapse: collapse; 
    714         border-spacing: 0; 
    715 } 
    716  
    717 table.files caption { 
    718         border: 1px solid #CCC; 
    719         color: #666; 
    720         margin:5px 0; 
    721         padding:2px; 
    722 } 
    723  
    724 table.files thead { 
    725         background-color: #DDD; 
    726 } 
    727  
    728 table.files th, table.files td { 
    729         border: 1px solid #CCC; 
    730         padding: 1px 3px; 
    731 } 
    732  
    733 table.files thead th { 
    734         background-color: #DDD; 
    735 } 
    736  
    737 table.files tfoot th { 
    738         background-color: #DDD; 
    739 } 
    740  
    741 table.files tbody th { 
    742         background-color: #EEE; 
    743 } 
    744  
    745 table.files tbody tr:hover { 
    746         background-color: #EEE; 
    747631} 
    748632 
     
    900784fieldset.feedback br { 
    901785        clear: left; 
    902 } 
    903  
    904 /* HighScores action */ 
    905  
    906 table.highscores { 
    907         white-space: nowrap; 
    908         padding 1px 3px 
    909786} 
    910787 
     
    1042919        margin-left: 1em; 
    1043920        margin-bottom: 1em; 
    1044 } 
    1045  
    1046 ul.recentchanges li { 
    1047         font-size: 0.9em; 
    1048921} 
    1049922 
  • trunk/lang/en/en.inc.php

    r962 r1021  
    325325// mychanges 
    326326define('NO_PAGES_EDITED', 'You have not edited any pages yet.'); 
    327 define('MYCHANGES_ALPHA_LIST', "This is a list of pages you've edited, along with the time of your last change."); 
    328 define('MYCHANGES_DATE_LIST', "This is a list of pages you've edited, ordered by the time of your last change."); 
     327define('MYCHANGES_ALPHA_LIST', "This is a list of pages edited by %s, along with the time of the last change."); 
     328define('MYCHANGES_DATE_LIST', "This is a list of pages edited by %s, ordered by the time of the last change."); 
    329329define('ORDER_DATE_LINK_DESC', 'order by date'); 
    330330define('ORDER_ALPHA_LINK_DESC', 'order alphabetically'); 
     
    336336 */ 
    337337// mypages 
    338 define('OWNED_PAGES_TXT', 'This is the list of pages you own.'); 
     338define('OWNED_PAGES_TXT', "This is the list of pages owned by %s."); 
    339339define('OWNED_NO_PAGES', 'You don\'t own any pages.'); 
     340define('OWNED_NONE_FOUND', 'No pages found.'); 
    340341define('OWNED_NOT_LOGGED_IN', "You're not logged in, thus the list of your pages couldn't be retrieved."); 
    341342/**#@-*/ 
  • trunk/libs/Wakka.class.php

    r961 r1021  
    39143914                        $this->deleteWikkaCookie('user_name'); 
    39153915                        $this->deleteWikkaCookie('pass'); 
     3916                        // Delete this session from sessions table 
     3917                        $this->Query("DELETE FROM ".$this->config['table_prefix']."sessions WHERE userid='".$this->GetUserName()."' AND sessionid='".session_id()."'"); 
     3918                        $_SESSION["user"] = ""; 
     3919                        // This seems a good as place as any to purge all session 
     3920                        // records older than PERSISTENT_COOKIE_EXPIRY, as this is 
     3921                        // not a time-critical function for the user.  The 
     3922                        // assumption here is that server-side sessions have long 
     3923                        // ago been cleaned up by PHP.  
     3924                        $cookie_expiration_secs = DEFAULT_COOKIE_EXPIRATION_HOURS * 3600; 
     3925                        $this->Query("DELETE FROM 
     3926                        ".$this->config['table_prefix']."sessions WHERE DATE_SUB(NOW(), INTERVAL ".$cookie_expiration_secs." SECOND) > session_start");  
    39163927                } 
    39173928                return $rc; 
     
    43474358         * @return      boolean TRUE if the user is an admin, FALSE otherwise 
    43484359         */ 
    4349         function IsAdmin() 
    4350         { 
     4360        function IsAdmin($user='') 
     4361        { 
     4362                if(TRUE===empty($user)) 
     4363                { 
     4364                        $user = $this->reg_username; 
     4365                } 
     4366                else if(is_array($user)) 
     4367                { 
     4368                        $user = $user['name']; 
     4369                } 
    43514370                $isadmin = FALSE; 
    43524371                // use preg_split to get an array with already-trimmed elements (no looping needed) 
     
    43544373 
    43554374                // only a logged-in user can be admin; check if name occurs in the array 
    4356                 if ($this->existsUser() && in_array($this->reg_username, $adminarray)) 
     4375                if ($this->existsUser() && in_array($user, $adminarray)) 
    43574376                { 
    43584377                        $isadmin = TRUE; 
  • trunk/setup/install.php

    r928 r1021  
    107107                         "signuptime datetime NOT NULL default '0000-00-00 00:00:00',". 
    108108                         "show_comments enum('Y','N') NOT NULL default 'N',". 
     109                     "status enum('invited','signed-up','pending','active','suspended','banned','deleted'),". 
    109110                         "default_comment_display int(10) unsigned NOT NULL default '1',". 
    110111                         "challenge char(8) NOT NULL default '00000000',". 
     
    344345        test(__('Dropping unnecessary index `from_tag`').'...', 
    345346        @mysql_query('alter table '.$config['table_prefix'].'links drop index `idx_from`', $dblink), __('Already done?  OK!'), 0); 
     347        test("Adding sessions tracking table...", 
     348        mysql_query("create table ".$config['table_prefix']."sessions (sessionid char(32) NOT NULL, userid varchar(75) NOT NULL, PRIMARY KEY (sessionid, userid), session_start datetime NOT NULL)"), "Already done? OK!", 0); 
     349        test("Adding AdminUsers page...",  
     350        mysql_query("insert into ".$config['table_prefix']."pages set tag = 'AdminUsers', body = '{{adminusers}}\n\n----\nCategoryAdmin', owner = '(Public)', note='".$upgrade_note."', user = 'WikkaInstaller', time = now(), latest = 'Y'", $dblink), "Already done? OK!", 0);  
     351        test("Adding AdminPages page...",  
     352        mysql_query("insert into ".$config['table_prefix']."pages set tag = 'AdminPages', body = '{{adminpages}}\n\n----\nCategoryAdmin', owner = '(Public)', note='".$upgrade_note."', user = 'WikkaInstaller', time = now(), latest = 'Y'", $dblink), "Already done? OK!", 0);  
    346353        break; 
    347354case "trunk": //latest development version from the SVN repository - do not remove 
  • trunk/wikka.php

    r1020 r1021  
    9090 * Do not change the version number or you will have problems upgrading. 
    9191 */ 
    92 if (!defined('WAKKA_VERSION'))                  define('WAKKA_VERSION', 'trunk'); 
     92if (!defined('WAKKA_VERSION'))                  define('WAKKA_VERSION', 'trunk-r1020'); 
    9393/** 
    9494 * Defines the basic name the session name will be derived from. 
     
    954954        die($mysql_version_error);              #FatalErrorAfterLangFileIncluded 
    955955} 
     956 
     957/** 
     958 * Save session ID 
     959 */ 
     960$user = $wakka->GetUser();  
     961// Only store sessions for real users!  
     962if(NULL != $user)  
     963{  
     964        $res = $wakka->LoadSingle("SELECT * FROM ".$wakka->config['table_prefix']."sessions WHERE sessionid='".session_id()."' AND userid='".$user['name']."'");   
     965        if(isset($res))  
     966        {  
     967                // Just update the session_start time  
     968                $wakka->Query("UPDATE ".$wakka->config['table_prefix']."sessions SET session_start=FROM_UNIXTIME(".$wakka->GetMicroTime().") WHERE sessionid='".session_id()."' AND userid='".$user['name']."'");  
     969        }  
     970        else  
     971        {  
     972                // Create new session record  
     973                $wakka->Query("INSERT INTO ".$wakka->config['table_prefix']."sessions (sessionid, userid, session_start) VALUES('".session_id()."', '".$user['name']."', FROM_UNIXTIME(".$wakka->GetMicroTime()."))");  
     974        }  
     975} 
     976 
    956977// ---------------------------- READY TO ROLL NOW ------------------------------ 
    957  
    958  
    959978// ---------------------------------- ROLL! ------------------------------------ 
    960979// --- Dependencies: