Changeset 3301 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-svn-access.php
- Timestamp:
- 06/06/2016 12:12:09 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-svn-access.php
r3295 r3301 15 15 class SVN_Access extends Base { 16 16 17 protected $svn_access = array();18 19 17 protected $svn_access_table; 20 18 21 function __construct() {19 public function __construct() { 22 20 $this->svn_access_table = PLUGINS_TABLE_PREFIX . 'svn_access'; 23 21 … … 32 30 * Generates and prints the SVN access file for plugins.svn. 33 31 * 34 * Rather than returning a value, the file is echo'd directly to STDOUT, so it can be piped 32 * Rather than returning a value, the file is echo'd directly to STDOUT, so it can be piped 35 33 * directly into a file. It exit()'s immediately. 36 * 34 * 37 35 * @param \WP_REST_Request $request The Rest API Request. 38 36 * … … 40 38 */ 41 39 public function generate_svn_access( $request ) { 42 $ this->load_svn_access();40 $svn_access = $this->load_svn_access(); 43 41 44 if ( empty( $ this->svn_access ) ) {42 if ( empty( $svn_access ) ) { 45 43 return false; 46 44 } 47 45 48 foreach ( $ this->svn_access as $slug => $users ) {46 foreach ( $svn_access as $slug => $users ) { 49 47 $slug = ltrim( $slug, '/' ); 50 48 echo "\n[/$slug]\n"; … … 54 52 } 55 53 } 56 54 57 55 exit(); 58 56 } 59 57 58 59 /** 60 * Loads the SVN access data from the svn access table. 61 * 62 * @access private 63 * 64 * @return array SVN access data, keyed by repo, then username. 65 */ 60 66 private function load_svn_access() { 61 67 global $wpdb; 62 68 63 $svn_access = (array) $wpdb->get_results( "SELECT * FROM {$this->svn_access_table}");69 $svn_access = array(); 64 70 65 foreach ( $svn_access as $svn_access ) { 66 if ( ! isset( $this->svn_access[ $svn_access->path ] ) ) { 67 $this->svn_access[ $svn_access->path ] = array(); 71 $access_data = (array) $wpdb->get_results( "SELECT * FROM {$this->svn_access_table}" ); 72 73 foreach ( $access_data as $datum ) { 74 if ( ! isset( $svn_access[ $datum->path ] ) ) { 75 $svn_access[ $datum->path ] = array(); 68 76 } 69 77 70 $ this->svn_access[ $svn_access->path ][ $svn_access->user ] = $svn_access->access;78 $svn_access[ $datum->path ][ $datum->user ] = $datum->access; 71 79 } 80 81 return $svn_access; 72 82 } 73 74 75 83 }
Note: See TracChangeset
for help on using the changeset viewer.