Ticket #14: glotpress-profile.2.patch
| File glotpress-profile.2.patch, 5.2 KB (added by joostdevalk, 20 months ago) |
|---|
-
gp-templates/profile.php
1 <?php 2 gp_title( __('Profile < GlotPress') ); 3 gp_breadcrumb( array( __('Profile') ) ); 4 gp_tmpl_header(); 5 6 $per_page = GP::$user->get_meta('per_page'); 7 if ( 0 == $per_page ) 8 $per_page = 15; 9 10 ?> 11 <h2><?php _e( "Profile" ); ?></h2> 12 <form method="post"> 13 <label for="per_page"><?php _e( "Number of items per page:" ); ?></label> 14 <input type="number" id="per_page" name="per_page" value="<?php echo $per_page ?>"/><br> 15 <input type="submit" value="<?php _e("Change Settings"); ?>"> 16 </form> 17 No newline at end of file -
gp-templates/header.php
22 22 if (GP::$user->logged_in()): 23 23 $user = GP::$user->current(); 24 24 25 printf( __('Hi, %s.'), $user->user_login);25 printf( __('Hi, %s.'), '<a href="'.gp_url( '/profile' ).'">'.$user->user_login.'</a>' ); 26 26 ?> 27 27 <a href="<?php echo gp_url('/logout')?>"><?php _e('Log out'); ?></a> 28 28 <?php else: ?> -
gp-includes/routes/profile.php
1 <?php 2 class GP_Route_Profile extends GP_Route_Main { 3 function profile_get() { 4 gp_tmpl_load( 'profile', array() ); 5 } 6 7 function profile_post() { 8 if ( isset( $_POST['per_page'] ) ) { 9 $per_page = (int) $_POST['per_page']; 10 GP::$user->set_meta( 'per_page', $per_page ); 11 } 12 13 $this->redirect( gp_url( '/profile' ) ); 14 } 15 } -
gp-includes/things/translation.php
155 155 } 156 156 157 157 $sql_sort = sprintf( $sort_by, $sort_how ); 158 $limit = $this->sql_limit_for_paging( $page ); 158 159 $per_page = GP::$user->get_meta('per_page'); 160 if ( 0 == $per_page ) 161 $per_page = $this->per_page; 162 163 $limit = $this->sql_limit_for_paging( $page, $per_page ); 164 159 165 $rows = $this->many_no_map( " 160 166 SELECT SQL_CALC_FOUND_ROWS t.*, o.*, t.id as id, o.id as original_id, t.status as translation_status, o.status as original_status, t.date_added as translation_added, o.date_added as original_added 161 167 FROM $gpdb->originals as o -
gp-includes/things/user.php
112 112 } 113 113 114 114 function get_meta( $key ) { 115 global $wp_users_object; 116 if ( !$user = $wp_users_object->get_user( $this->id ) ) { 117 return; 118 } 115 $user = $this->current(); 119 116 120 117 $key = gp_sanitize_meta_key( $key ); 121 118 if ( !isset( $user->$key ) ) { … … 125 122 } 126 123 127 124 function set_meta( $key, $value ) { 128 return gp_update_meta( $this->id, $key, $value, 'user' ); 125 $user = $this->current(); 126 return gp_update_meta( $user->id, $key, $value, 'user' ); 129 127 } 130 128 131 129 function delete_meta( $key ) { 132 return gp_delete_meta( $this->id, $key, '', 'user' ); 130 $user = $this->current(); 131 return gp_delete_meta( $user->id, $key, '', 'user' ); 133 132 } 134 133 135 134 -
gp-includes/thing.php
383 383 $per_page = is_null( $per_page )? $this->per_page : $per_page; 384 384 if ( 'no-limit' == $per_page || 'no-limit' == $page ) return ''; 385 385 $page = intval( $page )? intval( $page ) : 1; 386 return sprintf( "LIMIT %d OFFSET %d", $ this->per_page, ($page-1)*$this->per_page );386 return sprintf( "LIMIT %d OFFSET %d", $per_page, ($page-1)*$per_page ); 387 387 } 388 388 389 389 function found_rows() { -
gp-includes/router.php
44 44 'get:/login' => array('GP_Route_Login', 'login_get'), 45 45 'post:/login' => array('GP_Route_Login', 'login_post'), 46 46 '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'), 47 50 48 51 "get:/$project/import-originals" => array('GP_Route_Project', 'import_originals_get'), 49 52 "post:/$project/import-originals" => array('GP_Route_Project', 'import_originals_post'), -
gp-includes/meta.php
17 17 */ 18 18 function gp_update_meta( $object_id = 0, $meta_key, $meta_value, $type, $global = false ) { 19 19 global $gpdb; 20 if ( !is_numeric( $object_id ) || empty( $object_id ) && !$global ) { 20 21 if ( !is_numeric( $object_id ) || empty( $object_id ) ) { 21 22 return false; 22 23 } 23 24 $cache_object_id = $object_id = (int) $object_id;
