Ticket #14: glotpress-profile.patch

File glotpress-profile.patch, 2.9 KB (added by joostdevalk, 20 months ago)
  • gp-templates/profile.php

     
     1<?php  
     2gp_title( __('Profile &lt; GlotPress') ); 
     3gp_breadcrumb(array( __('Profile') )); 
     4gp_tmpl_header(); 
     5 
     6$per_page = 15; 
     7 
     8if ( isset( $_COOKIE['gp_items_per_page'] ) ) 
     9        $per_page = (int) $_COOKIE['gp_items_per_page']; 
     10         
     11?> 
     12<h2>Profile</h2> 
     13<form method="post"> 
     14        <label for="per_page"><?php _e( "Number of items per page:" ); ?></label> 
     15        <input type="number" id="per_page" name="per_page" value="<?php echo $per_page ?>"/><br> 
     16        <input type="submit" value="<?php _e("Change Settings"); ?>"> 
     17</form> 
     18 No newline at end of file 
  • gp-templates/header.php

     
    2222                        if (GP::$user->logged_in()): 
    2323                                $user = GP::$user->current(); 
    2424                                 
    25                                 printf( __('Hi, %s.'), $user->user_login ); 
     25                                printf( __('Hi, %s.'), '<a href="'.gp_url( '/profile' ).'">'.$user->user_login.'</a>' ); 
    2626                                ?> 
    2727                                <a href="<?php echo gp_url('/logout')?>"><?php _e('Log out'); ?></a> 
    2828                        <?php else: ?> 
  • gp-includes/routes/profile.php

     
     1<?php 
     2class GP_Route_Profile extends GP_Route_Main { 
     3        function profile_get() { 
     4                gp_tmpl_load( 'profile', array() ); 
     5        } 
     6 
     7        function profile_post() { 
     8                 
     9                if ( isset( $_POST['per_page'] ) ) { 
     10                        $per_page = (int) $_POST['per_page']; 
     11                        setcookie( 'gp_items_per_page', $per_page, time()+60*60*24*365*11 ); 
     12                } 
     13                 
     14                $this->redirect( gp_url( '/profile' ) ); 
     15        } 
     16 
     17} 
  • gp-includes/thing.php

     
    3636                        } 
    3737                        $this->set_static( 'static-vars-are-set', true ); 
    3838                } 
     39 
     40                if ( isset( $_COOKIE['gp_items_per_page'] ) ) 
     41                        $this->per_page =  (int) $_COOKIE['gp_items_per_page']; 
    3942        } 
    4043         
    4144        function get_static( $name, $default = null ) { 
  • gp-includes/router.php

     
    4444                        'get:/login' => array('GP_Route_Login', 'login_get'), 
    4545                        'post:/login' => array('GP_Route_Login', 'login_post'), 
    4646                        'get:/logout' => array('GP_Route_Login', 'logout'), 
     47                         
     48                        'get:/profile' => array('GP_Route_Profile', 'profile_get'), 
     49                        'post:/profile' => array('GP_Route_Profile', 'profile_post'), 
    4750 
    4851                        "get:/$project/import-originals" => array('GP_Route_Project', 'import_originals_get'), 
    4952                        "post:/$project/import-originals" => array('GP_Route_Project', 'import_originals_post'),