Test Failed
Push — master ( 4cd501...1b9ce5 )
by Stiofan
07:38
created
geodirectory-admin/google-api-php-client/src/cache/Google_ApcCache.php 2 patches
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -26,66 +26,66 @@  discard block
 block discarded – undo
26 26
 class Google_APCCache extends Google_Cache {
27 27
 
28 28
   public function __construct() {
29
-    if (! function_exists('apc_add')) {
30
-      throw new Google_CacheException("Apc functions not available");
31
-    }
29
+	if (! function_exists('apc_add')) {
30
+	  throw new Google_CacheException("Apc functions not available");
31
+	}
32 32
   }
33 33
 
34 34
   private function isLocked($key) {
35
-    if ((@apc_fetch($key . '.lock')) === false) {
36
-      return false;
37
-    }
38
-    return true;
35
+	if ((@apc_fetch($key . '.lock')) === false) {
36
+	  return false;
37
+	}
38
+	return true;
39 39
   }
40 40
 
41 41
   private function createLock($key) {
42
-    // the interesting thing is that this could fail if the lock was created in the meantime..
43
-    // but we'll ignore that out of convenience
44
-    @apc_add($key . '.lock', '', 5);
42
+	// the interesting thing is that this could fail if the lock was created in the meantime..
43
+	// but we'll ignore that out of convenience
44
+	@apc_add($key . '.lock', '', 5);
45 45
   }
46 46
 
47 47
   private function removeLock($key) {
48
-    // suppress all warnings, if some other process removed it that's ok too
49
-    @apc_delete($key . '.lock');
48
+	// suppress all warnings, if some other process removed it that's ok too
49
+	@apc_delete($key . '.lock');
50 50
   }
51 51
 
52 52
   private function waitForLock($key) {
53
-    // 20 x 250 = 5 seconds
54
-    $tries = 20;
55
-    $cnt = 0;
56
-    do {
57
-      // 250 ms is a long time to sleep, but it does stop the server from burning all resources on polling locks..
58
-      usleep(250);
59
-      $cnt ++;
60
-    } while ($cnt <= $tries && $this->isLocked($key));
61
-    if ($this->isLocked($key)) {
62
-      // 5 seconds passed, assume the owning process died off and remove it
63
-      $this->removeLock($key);
64
-    }
53
+	// 20 x 250 = 5 seconds
54
+	$tries = 20;
55
+	$cnt = 0;
56
+	do {
57
+	  // 250 ms is a long time to sleep, but it does stop the server from burning all resources on polling locks..
58
+	  usleep(250);
59
+	  $cnt ++;
60
+	} while ($cnt <= $tries && $this->isLocked($key));
61
+	if ($this->isLocked($key)) {
62
+	  // 5 seconds passed, assume the owning process died off and remove it
63
+	  $this->removeLock($key);
64
+	}
65 65
   }
66 66
 
67 67
    /**
68
-   * @inheritDoc
69
-   */
68
+    * @inheritDoc
69
+    */
70 70
   public function get($key, $expiration = false) {
71 71
 
72
-    if (($ret = @apc_fetch($key)) === false) {
73
-      return false;
74
-    }
75
-    if (!$expiration || (time() - $ret['time'] > $expiration)) {
76
-      $this->delete($key);
77
-      return false;
78
-    }
79
-    return unserialize($ret['data']);
72
+	if (($ret = @apc_fetch($key)) === false) {
73
+	  return false;
74
+	}
75
+	if (!$expiration || (time() - $ret['time'] > $expiration)) {
76
+	  $this->delete($key);
77
+	  return false;
78
+	}
79
+	return unserialize($ret['data']);
80 80
   }
81 81
 
82 82
   /**
83 83
    * @inheritDoc
84 84
    */
85 85
   public function set($key, $value) {
86
-    if (@apc_store($key, array('time' => time(), 'data' => serialize($value))) == false) {
87
-      throw new Google_CacheException("Couldn't store data");
88
-    }
86
+	if (@apc_store($key, array('time' => time(), 'data' => serialize($value))) == false) {
87
+	  throw new Google_CacheException("Couldn't store data");
88
+	}
89 89
   }
90 90
 
91 91
   /**
@@ -93,6 +93,6 @@  discard block
 block discarded – undo
93 93
    * @param String $key
94 94
    */
95 95
   public function delete($key) {
96
-    @apc_delete($key);
96
+	@apc_delete($key);
97 97
   }
98 98
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -26,13 +26,13 @@  discard block
 block discarded – undo
26 26
 class Google_APCCache extends Google_Cache {
27 27
 
28 28
   public function __construct() {
29
-    if (! function_exists('apc_add')) {
29
+    if (!function_exists('apc_add')) {
30 30
       throw new Google_CacheException("Apc functions not available");
31 31
     }
32 32
   }
33 33
 
34 34
   private function isLocked($key) {
35
-    if ((@apc_fetch($key . '.lock')) === false) {
35
+    if ((@apc_fetch($key.'.lock')) === false) {
36 36
       return false;
37 37
     }
38 38
     return true;
@@ -41,12 +41,12 @@  discard block
 block discarded – undo
41 41
   private function createLock($key) {
42 42
     // the interesting thing is that this could fail if the lock was created in the meantime..
43 43
     // but we'll ignore that out of convenience
44
-    @apc_add($key . '.lock', '', 5);
44
+    @apc_add($key.'.lock', '', 5);
45 45
   }
46 46
 
47 47
   private function removeLock($key) {
48 48
     // suppress all warnings, if some other process removed it that's ok too
49
-    @apc_delete($key . '.lock');
49
+    @apc_delete($key.'.lock');
50 50
   }
51 51
 
52 52
   private function waitForLock($key) {
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
     do {
57 57
       // 250 ms is a long time to sleep, but it does stop the server from burning all resources on polling locks..
58 58
       usleep(250);
59
-      $cnt ++;
59
+      $cnt++;
60 60
     } while ($cnt <= $tries && $this->isLocked($key));
61 61
     if ($this->isLocked($key)) {
62 62
       // 5 seconds passed, assume the owning process died off and remove it
Please login to merge, or discard this patch.
geodirectory-admin/google-api-php-client/src/config.php 2 patches
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -17,65 +17,65 @@
 block discarded – undo
17 17
 
18 18
 global $apiConfig;
19 19
 $apiConfig = array(
20
-    // True if objects should be returned by the service classes.
21
-    // False if associative arrays should be returned (default behavior).
22
-    'use_objects' => false,
20
+	// True if objects should be returned by the service classes.
21
+	// False if associative arrays should be returned (default behavior).
22
+	'use_objects' => false,
23 23
   
24
-    // The application_name is included in the User-Agent HTTP header.
25
-    'application_name' => '',
24
+	// The application_name is included in the User-Agent HTTP header.
25
+	'application_name' => '',
26 26
 
27
-    // OAuth2 Settings, you can get these keys at https://code.google.com/apis/console
28
-    'oauth2_client_id' => '',
29
-    'oauth2_client_secret' => '',
30
-    'oauth2_redirect_uri' => '',
27
+	// OAuth2 Settings, you can get these keys at https://code.google.com/apis/console
28
+	'oauth2_client_id' => '',
29
+	'oauth2_client_secret' => '',
30
+	'oauth2_redirect_uri' => '',
31 31
 
32
-    // The developer key, you get this at https://code.google.com/apis/console
33
-    'developer_key' => '',
32
+	// The developer key, you get this at https://code.google.com/apis/console
33
+	'developer_key' => '',
34 34
   
35
-    // Site name to show in the Google's OAuth 1 authentication screen.
36
-    'site_name' => 'www.example.org',
35
+	// Site name to show in the Google's OAuth 1 authentication screen.
36
+	'site_name' => 'www.example.org',
37 37
 
38
-    // Which Authentication, Storage and HTTP IO classes to use.
39
-    'authClass'    => 'Google_OAuth2',
40
-    'ioClass'      => 'Google_CurlIO',
41
-    'cacheClass'   => 'Google_FileCache',
38
+	// Which Authentication, Storage and HTTP IO classes to use.
39
+	'authClass'    => 'Google_OAuth2',
40
+	'ioClass'      => 'Google_CurlIO',
41
+	'cacheClass'   => 'Google_FileCache',
42 42
 
43
-    // Don't change these unless you're working against a special development or testing environment.
44
-    'basePath' => 'https://www.googleapis.com',
43
+	// Don't change these unless you're working against a special development or testing environment.
44
+	'basePath' => 'https://www.googleapis.com',
45 45
 
46
-    // IO Class dependent configuration, you only have to configure the values
47
-    // for the class that was configured as the ioClass above
48
-    'ioFileCache_directory'  =>
49
-        (function_exists('sys_get_temp_dir') ?
50
-            sys_get_temp_dir() . '/Google_Client' :
51
-        '/tmp/Google_Client'),
46
+	// IO Class dependent configuration, you only have to configure the values
47
+	// for the class that was configured as the ioClass above
48
+	'ioFileCache_directory'  =>
49
+		(function_exists('sys_get_temp_dir') ?
50
+			sys_get_temp_dir() . '/Google_Client' :
51
+		'/tmp/Google_Client'),
52 52
 
53
-    // Definition of service specific values like scopes, oauth token URLs, etc
54
-    'services' => array(
55
-      'analytics' => array('scope' => 'https://www.googleapis.com/auth/analytics.readonly'),
56
-      'calendar' => array(
57
-          'scope' => array(
58
-              "https://www.googleapis.com/auth/calendar",
59
-              "https://www.googleapis.com/auth/calendar.readonly",
60
-          )
61
-      ),
62
-      'books' => array('scope' => 'https://www.googleapis.com/auth/books'),
63
-      'latitude' => array(
64
-          'scope' => array(
65
-              'https://www.googleapis.com/auth/latitude.all.best',
66
-              'https://www.googleapis.com/auth/latitude.all.city',
67
-          )
68
-      ),
69
-      'moderator' => array('scope' => 'https://www.googleapis.com/auth/moderator'),
70
-      'oauth2' => array(
71
-          'scope' => array(
72
-              'https://www.googleapis.com/auth/userinfo.profile',
73
-              'https://www.googleapis.com/auth/userinfo.email',
74
-          )
75
-      ),
76
-      'plus' => array('scope' => 'https://www.googleapis.com/auth/plus.login'),
77
-      'siteVerification' => array('scope' => 'https://www.googleapis.com/auth/siteverification'),
78
-      'tasks' => array('scope' => 'https://www.googleapis.com/auth/tasks'),
79
-      'urlshortener' => array('scope' => 'https://www.googleapis.com/auth/urlshortener')
80
-    )
53
+	// Definition of service specific values like scopes, oauth token URLs, etc
54
+	'services' => array(
55
+	  'analytics' => array('scope' => 'https://www.googleapis.com/auth/analytics.readonly'),
56
+	  'calendar' => array(
57
+		  'scope' => array(
58
+			  "https://www.googleapis.com/auth/calendar",
59
+			  "https://www.googleapis.com/auth/calendar.readonly",
60
+		  )
61
+	  ),
62
+	  'books' => array('scope' => 'https://www.googleapis.com/auth/books'),
63
+	  'latitude' => array(
64
+		  'scope' => array(
65
+			  'https://www.googleapis.com/auth/latitude.all.best',
66
+			  'https://www.googleapis.com/auth/latitude.all.city',
67
+		  )
68
+	  ),
69
+	  'moderator' => array('scope' => 'https://www.googleapis.com/auth/moderator'),
70
+	  'oauth2' => array(
71
+		  'scope' => array(
72
+			  'https://www.googleapis.com/auth/userinfo.profile',
73
+			  'https://www.googleapis.com/auth/userinfo.email',
74
+		  )
75
+	  ),
76
+	  'plus' => array('scope' => 'https://www.googleapis.com/auth/plus.login'),
77
+	  'siteVerification' => array('scope' => 'https://www.googleapis.com/auth/siteverification'),
78
+	  'tasks' => array('scope' => 'https://www.googleapis.com/auth/tasks'),
79
+	  'urlshortener' => array('scope' => 'https://www.googleapis.com/auth/urlshortener')
80
+	)
81 81
 );
Please login to merge, or discard this patch.
Spacing   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -47,8 +47,7 @@
 block discarded – undo
47 47
     // for the class that was configured as the ioClass above
48 48
     'ioFileCache_directory'  =>
49 49
         (function_exists('sys_get_temp_dir') ?
50
-            sys_get_temp_dir() . '/Google_Client' :
51
-        '/tmp/Google_Client'),
50
+            sys_get_temp_dir().'/Google_Client' : '/tmp/Google_Client'),
52 51
 
53 52
     // Definition of service specific values like scopes, oauth token URLs, etc
54 53
     'services' => array(
Please login to merge, or discard this patch.
geodirectory-admin/google-api-php-client/src/local_config.php 2 patches
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -17,65 +17,65 @@
 block discarded – undo
17 17
 
18 18
 global $apiConfig;
19 19
 $apiConfig = array(
20
-    // True if objects should be returned by the service classes.
21
-    // False if associative arrays should be returned (default behavior).
22
-    'use_objects' => false,
20
+	// True if objects should be returned by the service classes.
21
+	// False if associative arrays should be returned (default behavior).
22
+	'use_objects' => false,
23 23
   
24
-    // The application_name is included in the User-Agent HTTP header.
25
-    'application_name' => '',
24
+	// The application_name is included in the User-Agent HTTP header.
25
+	'application_name' => '',
26 26
 
27
-    // OAuth2 Settings, you can get these keys at https://code.google.com/apis/console
28
-    //'oauth2_client_id' => '',
29
-    //'oauth2_client_secret' => '',
30
-    //'oauth2_redirect_uri' => '',
27
+	// OAuth2 Settings, you can get these keys at https://code.google.com/apis/console
28
+	//'oauth2_client_id' => '',
29
+	//'oauth2_client_secret' => '',
30
+	//'oauth2_redirect_uri' => '',
31 31
 
32
-    // The developer key, you get this at https://code.google.com/apis/console
33
-    'developer_key' => '',
32
+	// The developer key, you get this at https://code.google.com/apis/console
33
+	'developer_key' => '',
34 34
   
35
-    // Site name to show in the Google's OAuth 1 authentication screen.
36
-    'site_name' => 'www.example.org',
35
+	// Site name to show in the Google's OAuth 1 authentication screen.
36
+	'site_name' => 'www.example.org',
37 37
 
38
-    // Which Authentication, Storage and HTTP IO classes to use.
39
-    'authClass'    => 'Google_OAuth2',
40
-    'ioClass'      => 'Google_CurlIO',
41
-    'cacheClass'   => 'Google_FileCache',
38
+	// Which Authentication, Storage and HTTP IO classes to use.
39
+	'authClass'    => 'Google_OAuth2',
40
+	'ioClass'      => 'Google_CurlIO',
41
+	'cacheClass'   => 'Google_FileCache',
42 42
 
43
-    // Don't change these unless you're working against a special development or testing environment.
44
-    'basePath' => 'https://www.googleapis.com',
43
+	// Don't change these unless you're working against a special development or testing environment.
44
+	'basePath' => 'https://www.googleapis.com',
45 45
 
46
-    // IO Class dependent configuration, you only have to configure the values
47
-    // for the class that was configured as the ioClass above
48
-    'ioFileCache_directory'  =>
49
-        (function_exists('get_temp_dir') ?
50
-            get_temp_dir()  . '/Google_Client' :
51
-        '/tmp/Google_Client'),
46
+	// IO Class dependent configuration, you only have to configure the values
47
+	// for the class that was configured as the ioClass above
48
+	'ioFileCache_directory'  =>
49
+		(function_exists('get_temp_dir') ?
50
+			get_temp_dir()  . '/Google_Client' :
51
+		'/tmp/Google_Client'),
52 52
 
53
-    // Definition of service specific values like scopes, oauth token URLs, etc
54
-    'services' => array(
55
-      'analytics' => array('scope' => 'https://www.googleapis.com/auth/analytics.readonly'),
56
-      'calendar' => array(
57
-          'scope' => array(
58
-              "https://www.googleapis.com/auth/calendar",
59
-              "https://www.googleapis.com/auth/calendar.readonly",
60
-          )
61
-      ),
62
-      'books' => array('scope' => 'https://www.googleapis.com/auth/books'),
63
-      'latitude' => array(
64
-          'scope' => array(
65
-              'https://www.googleapis.com/auth/latitude.all.best',
66
-              'https://www.googleapis.com/auth/latitude.all.city',
67
-          )
68
-      ),
69
-      'moderator' => array('scope' => 'https://www.googleapis.com/auth/moderator'),
70
-      'oauth2' => array(
71
-          'scope' => array(
72
-              'https://www.googleapis.com/auth/userinfo.profile',
73
-              'https://www.googleapis.com/auth/userinfo.email',
74
-          )
75
-      ),
76
-      'plus' => array('scope' => 'https://www.googleapis.com/auth/plus.me'),
77
-      'siteVerification' => array('scope' => 'https://www.googleapis.com/auth/siteverification'),
78
-      'tasks' => array('scope' => 'https://www.googleapis.com/auth/tasks'),
79
-      'urlshortener' => array('scope' => 'https://www.googleapis.com/auth/urlshortener')
80
-    )
53
+	// Definition of service specific values like scopes, oauth token URLs, etc
54
+	'services' => array(
55
+	  'analytics' => array('scope' => 'https://www.googleapis.com/auth/analytics.readonly'),
56
+	  'calendar' => array(
57
+		  'scope' => array(
58
+			  "https://www.googleapis.com/auth/calendar",
59
+			  "https://www.googleapis.com/auth/calendar.readonly",
60
+		  )
61
+	  ),
62
+	  'books' => array('scope' => 'https://www.googleapis.com/auth/books'),
63
+	  'latitude' => array(
64
+		  'scope' => array(
65
+			  'https://www.googleapis.com/auth/latitude.all.best',
66
+			  'https://www.googleapis.com/auth/latitude.all.city',
67
+		  )
68
+	  ),
69
+	  'moderator' => array('scope' => 'https://www.googleapis.com/auth/moderator'),
70
+	  'oauth2' => array(
71
+		  'scope' => array(
72
+			  'https://www.googleapis.com/auth/userinfo.profile',
73
+			  'https://www.googleapis.com/auth/userinfo.email',
74
+		  )
75
+	  ),
76
+	  'plus' => array('scope' => 'https://www.googleapis.com/auth/plus.me'),
77
+	  'siteVerification' => array('scope' => 'https://www.googleapis.com/auth/siteverification'),
78
+	  'tasks' => array('scope' => 'https://www.googleapis.com/auth/tasks'),
79
+	  'urlshortener' => array('scope' => 'https://www.googleapis.com/auth/urlshortener')
80
+	)
81 81
 );
82 82
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -47,8 +47,7 @@
 block discarded – undo
47 47
     // for the class that was configured as the ioClass above
48 48
     'ioFileCache_directory'  =>
49 49
         (function_exists('get_temp_dir') ?
50
-            get_temp_dir()  . '/Google_Client' :
51
-        '/tmp/Google_Client'),
50
+            get_temp_dir().'/Google_Client' : '/tmp/Google_Client'),
52 51
 
53 52
     // Definition of service specific values like scopes, oauth token URLs, etc
54 53
     'services' => array(
Please login to merge, or discard this patch.
geodirectory-admin/google-api-php-client/src/auth/Google_OAuth2.php 2 patches
Indentation   +281 added lines, -281 removed lines patch added patch discarded remove patch
@@ -53,31 +53,31 @@  discard block
 block discarded – undo
53 53
    * to the discretion of the caller (which is done by calling authenticate()).
54 54
    */
55 55
   public function __construct() {
56
-    global $apiConfig;
56
+	global $apiConfig;
57 57
 
58
-    if (! empty($apiConfig['developer_key'])) {
59
-      $this->developerKey = $apiConfig['developer_key'];
60
-    }
58
+	if (! empty($apiConfig['developer_key'])) {
59
+	  $this->developerKey = $apiConfig['developer_key'];
60
+	}
61 61
 
62
-    if (! empty($apiConfig['oauth2_client_id'])) {
63
-      $this->clientId = $apiConfig['oauth2_client_id'];
64
-    }
62
+	if (! empty($apiConfig['oauth2_client_id'])) {
63
+	  $this->clientId = $apiConfig['oauth2_client_id'];
64
+	}
65 65
 
66
-    if (! empty($apiConfig['oauth2_client_secret'])) {
67
-      $this->clientSecret = $apiConfig['oauth2_client_secret'];
68
-    }
66
+	if (! empty($apiConfig['oauth2_client_secret'])) {
67
+	  $this->clientSecret = $apiConfig['oauth2_client_secret'];
68
+	}
69 69
 
70
-    if (! empty($apiConfig['oauth2_redirect_uri'])) {
71
-      $this->redirectUri = $apiConfig['oauth2_redirect_uri'];
72
-    }
70
+	if (! empty($apiConfig['oauth2_redirect_uri'])) {
71
+	  $this->redirectUri = $apiConfig['oauth2_redirect_uri'];
72
+	}
73 73
 
74
-    if (! empty($apiConfig['oauth2_access_type'])) {
75
-      $this->accessType = $apiConfig['oauth2_access_type'];
76
-    }
74
+	if (! empty($apiConfig['oauth2_access_type'])) {
75
+	  $this->accessType = $apiConfig['oauth2_access_type'];
76
+	}
77 77
 
78
-    if (! empty($apiConfig['oauth2_approval_prompt'])) {
79
-      $this->approvalPrompt = $apiConfig['oauth2_approval_prompt'];
80
-    }
78
+	if (! empty($apiConfig['oauth2_approval_prompt'])) {
79
+	  $this->approvalPrompt = $apiConfig['oauth2_approval_prompt'];
80
+	}
81 81
 
82 82
   }
83 83
 
@@ -88,37 +88,37 @@  discard block
 block discarded – undo
88 88
    * @return string
89 89
    */
90 90
   public function authenticate($service, $code = null) {
91
-    if (!$code && isset($_GET['code'])) {
92
-      $code = $_GET['code'];
93
-    }
94
-
95
-    if ($code) {
96
-      // We got here from the redirect from a successful authorization grant, fetch the access token
97
-      $request = Google_Client::$io->makeRequest(new Google_HttpRequest(self::OAUTH2_TOKEN_URI, 'POST', array(), array(
98
-          'code' => $code,
99
-          'grant_type' => 'authorization_code',
100
-          'redirect_uri' => $this->redirectUri,
101
-          'client_id' => $this->clientId,
102
-          'client_secret' => $this->clientSecret
103
-      )));
104
-
105
-      if ($request->getResponseHttpCode() == 200) {
106
-        $this->setAccessToken($request->getResponseBody());
107
-        $this->token['created'] = time();
108
-        return $this->getAccessToken();
109
-      } else {
110
-        $response = $request->getResponseBody();
111
-        $decodedResponse = json_decode($response, true);
112
-        if ($decodedResponse != null && $decodedResponse['error']) {
113
-          $response = $decodedResponse['error'];
114
-        }
115
-        throw new Google_AuthException("Error fetching OAuth2 access token, message: '$response'", $request->getResponseHttpCode());
116
-      }
117
-    }
118
-
119
-    $authUrl = $this->createAuthUrl($service['scope']);
120
-    header('Location: ' . $authUrl);
121
-    return true;
91
+	if (!$code && isset($_GET['code'])) {
92
+	  $code = $_GET['code'];
93
+	}
94
+
95
+	if ($code) {
96
+	  // We got here from the redirect from a successful authorization grant, fetch the access token
97
+	  $request = Google_Client::$io->makeRequest(new Google_HttpRequest(self::OAUTH2_TOKEN_URI, 'POST', array(), array(
98
+		  'code' => $code,
99
+		  'grant_type' => 'authorization_code',
100
+		  'redirect_uri' => $this->redirectUri,
101
+		  'client_id' => $this->clientId,
102
+		  'client_secret' => $this->clientSecret
103
+	  )));
104
+
105
+	  if ($request->getResponseHttpCode() == 200) {
106
+		$this->setAccessToken($request->getResponseBody());
107
+		$this->token['created'] = time();
108
+		return $this->getAccessToken();
109
+	  } else {
110
+		$response = $request->getResponseBody();
111
+		$decodedResponse = json_decode($response, true);
112
+		if ($decodedResponse != null && $decodedResponse['error']) {
113
+		  $response = $decodedResponse['error'];
114
+		}
115
+		throw new Google_AuthException("Error fetching OAuth2 access token, message: '$response'", $request->getResponseHttpCode());
116
+	  }
117
+	}
118
+
119
+	$authUrl = $this->createAuthUrl($service['scope']);
120
+	header('Location: ' . $authUrl);
121
+	return true;
122 122
   }
123 123
 
124 124
   /**
@@ -129,27 +129,27 @@  discard block
 block discarded – undo
129 129
    * @return string
130 130
    */
131 131
   public function createAuthUrl($scope) {
132
-    $params = array(
133
-        'response_type=code',
134
-        'redirect_uri=' . urlencode($this->redirectUri),
135
-        'client_id=' . urlencode($this->clientId),
136
-        'scope=' . urlencode($scope),
137
-        'access_type=' . urlencode($this->accessType),
138
-        'approval_prompt=' . urlencode($this->approvalPrompt),
139
-    );
140
-
141
-    // if the list of scopes contains plus.login, add request_visible_actions
142
-    // to auth URL
143
-    if(strpos($scope, 'plus.login') && count($this->requestVisibleActions) > 0) {
144
-        $params[] = 'request_visible_actions=' .
145
-            urlencode($this->requestVisibleActions);
146
-    }
147
-
148
-    if (isset($this->state)) {
149
-      $params[] = 'state=' . urlencode($this->state);
150
-    }
151
-    $params = implode('&', $params);
152
-    return self::OAUTH2_AUTH_URL . "?$params";
132
+	$params = array(
133
+		'response_type=code',
134
+		'redirect_uri=' . urlencode($this->redirectUri),
135
+		'client_id=' . urlencode($this->clientId),
136
+		'scope=' . urlencode($scope),
137
+		'access_type=' . urlencode($this->accessType),
138
+		'approval_prompt=' . urlencode($this->approvalPrompt),
139
+	);
140
+
141
+	// if the list of scopes contains plus.login, add request_visible_actions
142
+	// to auth URL
143
+	if(strpos($scope, 'plus.login') && count($this->requestVisibleActions) > 0) {
144
+		$params[] = 'request_visible_actions=' .
145
+			urlencode($this->requestVisibleActions);
146
+	}
147
+
148
+	if (isset($this->state)) {
149
+	  $params[] = 'state=' . urlencode($this->state);
150
+	}
151
+	$params = implode('&', $params);
152
+	return self::OAUTH2_AUTH_URL . "?$params";
153 153
   }
154 154
 
155 155
   /**
@@ -157,38 +157,38 @@  discard block
 block discarded – undo
157 157
    * @throws Google_AuthException
158 158
    */
159 159
   public function setAccessToken($token) {
160
-    $token = json_decode($token, true);
161
-    if ($token == null) {
162
-      throw new Google_AuthException('Could not json decode the token');
163
-    }
164
-    if (! isset($token['access_token'])) {
165
-      throw new Google_AuthException("Invalid token format");
166
-    }
167
-    $this->token = $token;
160
+	$token = json_decode($token, true);
161
+	if ($token == null) {
162
+	  throw new Google_AuthException('Could not json decode the token');
163
+	}
164
+	if (! isset($token['access_token'])) {
165
+	  throw new Google_AuthException("Invalid token format");
166
+	}
167
+	$this->token = $token;
168 168
   }
169 169
 
170 170
   public function getAccessToken() {
171
-    return json_encode($this->token);
171
+	return json_encode($this->token);
172 172
   }
173 173
 
174 174
   public function setDeveloperKey($developerKey) {
175
-    $this->developerKey = $developerKey;
175
+	$this->developerKey = $developerKey;
176 176
   }
177 177
 
178 178
   public function setState($state) {
179
-    $this->state = $state;
179
+	$this->state = $state;
180 180
   }
181 181
 
182 182
   public function setAccessType($accessType) {
183
-    $this->accessType = $accessType;
183
+	$this->accessType = $accessType;
184 184
   }
185 185
 
186 186
   public function setApprovalPrompt($approvalPrompt) {
187
-    $this->approvalPrompt = $approvalPrompt;
187
+	$this->approvalPrompt = $approvalPrompt;
188 188
   }
189 189
 
190 190
   public function setAssertionCredentials(Google_AssertionCredentials $creds) {
191
-    $this->assertionCredentials = $creds;
191
+	$this->assertionCredentials = $creds;
192 192
   }
193 193
 
194 194
   /**
@@ -198,40 +198,40 @@  discard block
 block discarded – undo
198 198
    * @throws Google_AuthException
199 199
    */
200 200
   public function sign(Google_HttpRequest $request) {
201
-    // add the developer key to the request before signing it
202
-    if ($this->developerKey) {
203
-      $requestUrl = $request->getUrl();
204
-      $requestUrl .= (strpos($request->getUrl(), '?') === false) ? '?' : '&';
205
-      $requestUrl .=  'key=' . urlencode($this->developerKey);
206
-      $request->setUrl($requestUrl);
207
-    }
208
-
209
-    // Cannot sign the request without an OAuth access token.
210
-    if (null == $this->token && null == $this->assertionCredentials) {
211
-      return $request;
212
-    }
213
-
214
-    // Check if the token is set to expire in the next 30 seconds
215
-    // (or has already expired).
216
-    if ($this->isAccessTokenExpired()) {
217
-      if ($this->assertionCredentials) {
218
-        $this->refreshTokenWithAssertion();
219
-      } else {
220
-        if (! array_key_exists('refresh_token', $this->token)) {
221
-            throw new Google_AuthException("The OAuth 2.0 access token has expired, "
222
-                . "and a refresh token is not available. Refresh tokens are not "
223
-                . "returned for responses that were auto-approved.");
224
-        }
225
-        $this->refreshToken($this->token['refresh_token']);
226
-      }
227
-    }
228
-
229
-    // Add the OAuth2 header to the request
230
-    $request->setRequestHeaders(
231
-        array('Authorization' => 'Bearer ' . $this->token['access_token'])
232
-    );
233
-
234
-    return $request;
201
+	// add the developer key to the request before signing it
202
+	if ($this->developerKey) {
203
+	  $requestUrl = $request->getUrl();
204
+	  $requestUrl .= (strpos($request->getUrl(), '?') === false) ? '?' : '&';
205
+	  $requestUrl .=  'key=' . urlencode($this->developerKey);
206
+	  $request->setUrl($requestUrl);
207
+	}
208
+
209
+	// Cannot sign the request without an OAuth access token.
210
+	if (null == $this->token && null == $this->assertionCredentials) {
211
+	  return $request;
212
+	}
213
+
214
+	// Check if the token is set to expire in the next 30 seconds
215
+	// (or has already expired).
216
+	if ($this->isAccessTokenExpired()) {
217
+	  if ($this->assertionCredentials) {
218
+		$this->refreshTokenWithAssertion();
219
+	  } else {
220
+		if (! array_key_exists('refresh_token', $this->token)) {
221
+			throw new Google_AuthException("The OAuth 2.0 access token has expired, "
222
+				. "and a refresh token is not available. Refresh tokens are not "
223
+				. "returned for responses that were auto-approved.");
224
+		}
225
+		$this->refreshToken($this->token['refresh_token']);
226
+	  }
227
+	}
228
+
229
+	// Add the OAuth2 header to the request
230
+	$request->setRequestHeaders(
231
+		array('Authorization' => 'Bearer ' . $this->token['access_token'])
232
+	);
233
+
234
+	return $request;
235 235
   }
236 236
 
237 237
   /**
@@ -240,12 +240,12 @@  discard block
 block discarded – undo
240 240
    * @return void
241 241
    */
242 242
   public function refreshToken($refreshToken) {
243
-    $this->refreshTokenRequest(array(
244
-        'client_id' => $this->clientId,
245
-        'client_secret' => $this->clientSecret,
246
-        'refresh_token' => $refreshToken,
247
-        'grant_type' => 'refresh_token'
248
-    ));
243
+	$this->refreshTokenRequest(array(
244
+		'client_id' => $this->clientId,
245
+		'client_secret' => $this->clientSecret,
246
+		'refresh_token' => $refreshToken,
247
+		'grant_type' => 'refresh_token'
248
+	));
249 249
   }
250 250
 
251 251
   /**
@@ -254,61 +254,61 @@  discard block
 block discarded – undo
254 254
    * @return void
255 255
    */
256 256
   public function refreshTokenWithAssertion($assertionCredentials = null) {
257
-    if (!$assertionCredentials) {
258
-      $assertionCredentials = $this->assertionCredentials;
259
-    }
260
-
261
-    $this->refreshTokenRequest(array(
262
-        'grant_type' => 'assertion',
263
-        'assertion_type' => $assertionCredentials->assertionType,
264
-        'assertion' => $assertionCredentials->generateAssertion(),
265
-    ));
257
+	if (!$assertionCredentials) {
258
+	  $assertionCredentials = $this->assertionCredentials;
259
+	}
260
+
261
+	$this->refreshTokenRequest(array(
262
+		'grant_type' => 'assertion',
263
+		'assertion_type' => $assertionCredentials->assertionType,
264
+		'assertion' => $assertionCredentials->generateAssertion(),
265
+	));
266 266
   }
267 267
 
268 268
   private function refreshTokenRequest($params) {
269
-    $http = new Google_HttpRequest(self::OAUTH2_TOKEN_URI, 'POST', array(), $params);
270
-    $request = Google_Client::$io->makeRequest($http);
271
-
272
-    $code = $request->getResponseHttpCode();
273
-    $body = $request->getResponseBody();
274
-    if (200 == $code) {
275
-      $token = json_decode($body, true);
276
-      if ($token == null) {
277
-        throw new Google_AuthException("Could not json decode the access token");
278
-      }
279
-
280
-      if (! isset($token['access_token']) || ! isset($token['expires_in'])) {
281
-        throw new Google_AuthException("Invalid token format");
282
-      }
283
-
284
-      $this->token['access_token'] = $token['access_token'];
285
-      $this->token['expires_in'] = $token['expires_in'];
286
-      $this->token['created'] = time();
287
-    } else {
288
-      throw new Google_AuthException("Error refreshing the OAuth2 token, message: '$body'", $code);
289
-    }
269
+	$http = new Google_HttpRequest(self::OAUTH2_TOKEN_URI, 'POST', array(), $params);
270
+	$request = Google_Client::$io->makeRequest($http);
271
+
272
+	$code = $request->getResponseHttpCode();
273
+	$body = $request->getResponseBody();
274
+	if (200 == $code) {
275
+	  $token = json_decode($body, true);
276
+	  if ($token == null) {
277
+		throw new Google_AuthException("Could not json decode the access token");
278
+	  }
279
+
280
+	  if (! isset($token['access_token']) || ! isset($token['expires_in'])) {
281
+		throw new Google_AuthException("Invalid token format");
282
+	  }
283
+
284
+	  $this->token['access_token'] = $token['access_token'];
285
+	  $this->token['expires_in'] = $token['expires_in'];
286
+	  $this->token['created'] = time();
287
+	} else {
288
+	  throw new Google_AuthException("Error refreshing the OAuth2 token, message: '$body'", $code);
289
+	}
290 290
   }
291 291
 
292
-    /**
293
-     * Revoke an OAuth2 access token or refresh token. This method will revoke the current access
294
-     * token, if a token isn't provided.
295
-     * @throws Google_AuthException
296
-     * @param string|null $token The token (access token or a refresh token) that should be revoked.
297
-     * @return boolean Returns True if the revocation was successful, otherwise False.
298
-     */
292
+	/**
293
+	 * Revoke an OAuth2 access token or refresh token. This method will revoke the current access
294
+	 * token, if a token isn't provided.
295
+	 * @throws Google_AuthException
296
+	 * @param string|null $token The token (access token or a refresh token) that should be revoked.
297
+	 * @return boolean Returns True if the revocation was successful, otherwise False.
298
+	 */
299 299
   public function revokeToken($token = null) {
300
-    if (!$token) {
301
-      $token = $this->token['access_token'];
302
-    }
303
-    $request = new Google_HttpRequest(self::OAUTH2_REVOKE_URI, 'POST', array(), "token=$token");
304
-    $response = Google_Client::$io->makeRequest($request);
305
-    $code = $response->getResponseHttpCode();
306
-    if ($code == 200) {
307
-      $this->token = null;
308
-      return true;
309
-    }
310
-
311
-    return false;
300
+	if (!$token) {
301
+	  $token = $this->token['access_token'];
302
+	}
303
+	$request = new Google_HttpRequest(self::OAUTH2_REVOKE_URI, 'POST', array(), "token=$token");
304
+	$response = Google_Client::$io->makeRequest($request);
305
+	$code = $response->getResponseHttpCode();
306
+	if ($code == 200) {
307
+	  $this->token = null;
308
+	  return true;
309
+	}
310
+
311
+	return false;
312 312
   }
313 313
 
314 314
   /**
@@ -316,34 +316,34 @@  discard block
 block discarded – undo
316 316
    * @return bool Returns True if the access_token is expired.
317 317
    */
318 318
   public function isAccessTokenExpired() {
319
-    if (null == $this->token) {
320
-      return true;
321
-    }
319
+	if (null == $this->token) {
320
+	  return true;
321
+	}
322 322
 
323
-    // If the token is set to expire in the next 30 seconds.
324
-    $expired = ($this->token['created']
325
-        + ($this->token['expires_in'] - 30)) < time();
323
+	// If the token is set to expire in the next 30 seconds.
324
+	$expired = ($this->token['created']
325
+		+ ($this->token['expires_in'] - 30)) < time();
326 326
 
327
-    return $expired;
327
+	return $expired;
328 328
   }
329 329
 
330 330
   // Gets federated sign-on certificates to use for verifying identity tokens.
331 331
   // Returns certs as array structure, where keys are key ids, and values
332 332
   // are PEM encoded certificates.
333 333
   private function getFederatedSignOnCerts() {
334
-    // This relies on makeRequest caching certificate responses.
335
-    $request = Google_Client::$io->makeRequest(new Google_HttpRequest(
336
-        self::OAUTH2_FEDERATED_SIGNON_CERTS_URL));
337
-    if ($request->getResponseHttpCode() == 200) {
338
-      $certs = json_decode($request->getResponseBody(), true);
339
-      if ($certs) {
340
-        return $certs;
341
-      }
342
-    }
343
-    throw new Google_AuthException(
344
-        "Failed to retrieve verification certificates: '" .
345
-            $request->getResponseBody() . "'.",
346
-        $request->getResponseHttpCode());
334
+	// This relies on makeRequest caching certificate responses.
335
+	$request = Google_Client::$io->makeRequest(new Google_HttpRequest(
336
+		self::OAUTH2_FEDERATED_SIGNON_CERTS_URL));
337
+	if ($request->getResponseHttpCode() == 200) {
338
+	  $certs = json_decode($request->getResponseBody(), true);
339
+	  if ($certs) {
340
+		return $certs;
341
+	  }
342
+	}
343
+	throw new Google_AuthException(
344
+		"Failed to retrieve verification certificates: '" .
345
+			$request->getResponseBody() . "'.",
346
+		$request->getResponseHttpCode());
347 347
   }
348 348
 
349 349
   /**
@@ -357,97 +357,97 @@  discard block
 block discarded – undo
357 357
    * @return Google_LoginTicket
358 358
    */
359 359
   public function verifyIdToken($id_token = null, $audience = null) {
360
-    if (!$id_token) {
361
-      $id_token = $this->token['id_token'];
362
-    }
363
-
364
-    $certs = $this->getFederatedSignonCerts();
365
-    if (!$audience) {
366
-      $audience = $this->clientId;
367
-    }
368
-    return $this->verifySignedJwtWithCerts($id_token, $certs, $audience);
360
+	if (!$id_token) {
361
+	  $id_token = $this->token['id_token'];
362
+	}
363
+
364
+	$certs = $this->getFederatedSignonCerts();
365
+	if (!$audience) {
366
+	  $audience = $this->clientId;
367
+	}
368
+	return $this->verifySignedJwtWithCerts($id_token, $certs, $audience);
369 369
   }
370 370
 
371 371
   // Verifies the id token, returns the verified token contents.
372 372
   // Visible for testing.
373 373
   function verifySignedJwtWithCerts($jwt, $certs, $required_audience) {
374
-    $segments = explode(".", $jwt);
375
-    if (count($segments) != 3) {
376
-      throw new Google_AuthException("Wrong number of segments in token: $jwt");
377
-    }
378
-    $signed = $segments[0] . "." . $segments[1];
379
-    $signature = Google_Utils::urlSafeB64Decode($segments[2]);
380
-
381
-    // Parse envelope.
382
-    $envelope = json_decode(Google_Utils::urlSafeB64Decode($segments[0]), true);
383
-    if (!$envelope) {
384
-      throw new Google_AuthException("Can't parse token envelope: " . $segments[0]);
385
-    }
386
-
387
-    // Parse token
388
-    $json_body = Google_Utils::urlSafeB64Decode($segments[1]);
389
-    $payload = json_decode($json_body, true);
390
-    if (!$payload) {
391
-      throw new Google_AuthException("Can't parse token payload: " . $segments[1]);
392
-    }
393
-
394
-    // Check signature
395
-    $verified = false;
396
-    foreach ($certs as $keyName => $pem) {
397
-      $public_key = new Google_PemVerifier($pem);
398
-      if ($public_key->verify($signed, $signature)) {
399
-        $verified = true;
400
-        break;
401
-      }
402
-    }
403
-
404
-    if (!$verified) {
405
-      throw new Google_AuthException("Invalid token signature: $jwt");
406
-    }
407
-
408
-    // Check issued-at timestamp
409
-    $iat = 0;
410
-    if (array_key_exists("iat", $payload)) {
411
-      $iat = $payload["iat"];
412
-    }
413
-    if (!$iat) {
414
-      throw new Google_AuthException("No issue time in token: $json_body");
415
-    }
416
-    $earliest = $iat - self::CLOCK_SKEW_SECS;
417
-
418
-    // Check expiration timestamp
419
-    $now = time();
420
-    $exp = 0;
421
-    if (array_key_exists("exp", $payload)) {
422
-      $exp = $payload["exp"];
423
-    }
424
-    if (!$exp) {
425
-      throw new Google_AuthException("No expiration time in token: $json_body");
426
-    }
427
-    if ($exp >= $now + self::MAX_TOKEN_LIFETIME_SECS) {
428
-      throw new Google_AuthException(
429
-          "Expiration time too far in future: $json_body");
430
-    }
431
-
432
-    $latest = $exp + self::CLOCK_SKEW_SECS;
433
-    if ($now < $earliest) {
434
-      throw new Google_AuthException(
435
-          "Token used too early, $now < $earliest: $json_body");
436
-    }
437
-    if ($now > $latest) {
438
-      throw new Google_AuthException(
439
-          "Token used too late, $now > $latest: $json_body");
440
-    }
441
-
442
-    // TODO(beaton): check issuer field?
443
-
444
-    // Check audience
445
-    $aud = $payload["aud"];
446
-    if ($aud != $required_audience) {
447
-      throw new Google_AuthException("Wrong recipient, $aud != $required_audience: $json_body");
448
-    }
449
-
450
-    // All good.
451
-    return new Google_LoginTicket($envelope, $payload);
374
+	$segments = explode(".", $jwt);
375
+	if (count($segments) != 3) {
376
+	  throw new Google_AuthException("Wrong number of segments in token: $jwt");
377
+	}
378
+	$signed = $segments[0] . "." . $segments[1];
379
+	$signature = Google_Utils::urlSafeB64Decode($segments[2]);
380
+
381
+	// Parse envelope.
382
+	$envelope = json_decode(Google_Utils::urlSafeB64Decode($segments[0]), true);
383
+	if (!$envelope) {
384
+	  throw new Google_AuthException("Can't parse token envelope: " . $segments[0]);
385
+	}
386
+
387
+	// Parse token
388
+	$json_body = Google_Utils::urlSafeB64Decode($segments[1]);
389
+	$payload = json_decode($json_body, true);
390
+	if (!$payload) {
391
+	  throw new Google_AuthException("Can't parse token payload: " . $segments[1]);
392
+	}
393
+
394
+	// Check signature
395
+	$verified = false;
396
+	foreach ($certs as $keyName => $pem) {
397
+	  $public_key = new Google_PemVerifier($pem);
398
+	  if ($public_key->verify($signed, $signature)) {
399
+		$verified = true;
400
+		break;
401
+	  }
402
+	}
403
+
404
+	if (!$verified) {
405
+	  throw new Google_AuthException("Invalid token signature: $jwt");
406
+	}
407
+
408
+	// Check issued-at timestamp
409
+	$iat = 0;
410
+	if (array_key_exists("iat", $payload)) {
411
+	  $iat = $payload["iat"];
412
+	}
413
+	if (!$iat) {
414
+	  throw new Google_AuthException("No issue time in token: $json_body");
415
+	}
416
+	$earliest = $iat - self::CLOCK_SKEW_SECS;
417
+
418
+	// Check expiration timestamp
419
+	$now = time();
420
+	$exp = 0;
421
+	if (array_key_exists("exp", $payload)) {
422
+	  $exp = $payload["exp"];
423
+	}
424
+	if (!$exp) {
425
+	  throw new Google_AuthException("No expiration time in token: $json_body");
426
+	}
427
+	if ($exp >= $now + self::MAX_TOKEN_LIFETIME_SECS) {
428
+	  throw new Google_AuthException(
429
+		  "Expiration time too far in future: $json_body");
430
+	}
431
+
432
+	$latest = $exp + self::CLOCK_SKEW_SECS;
433
+	if ($now < $earliest) {
434
+	  throw new Google_AuthException(
435
+		  "Token used too early, $now < $earliest: $json_body");
436
+	}
437
+	if ($now > $latest) {
438
+	  throw new Google_AuthException(
439
+		  "Token used too late, $now > $latest: $json_body");
440
+	}
441
+
442
+	// TODO(beaton): check issuer field?
443
+
444
+	// Check audience
445
+	$aud = $payload["aud"];
446
+	if ($aud != $required_audience) {
447
+	  throw new Google_AuthException("Wrong recipient, $aud != $required_audience: $json_body");
448
+	}
449
+
450
+	// All good.
451
+	return new Google_LoginTicket($envelope, $payload);
452 452
   }
453 453
 }
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 
18 18
 require_once "Google_Verifier.php";
19 19
 require_once "Google_LoginTicket.php";
20
-require_once GA_API_Path. "service/Google_Utils.php";
20
+require_once GA_API_Path."service/Google_Utils.php";
21 21
 
22 22
 /**
23 23
  * Authentication class that deals with the OAuth 2 web-server authentication flow
@@ -55,27 +55,27 @@  discard block
 block discarded – undo
55 55
   public function __construct() {
56 56
     global $apiConfig;
57 57
 
58
-    if (! empty($apiConfig['developer_key'])) {
58
+    if (!empty($apiConfig['developer_key'])) {
59 59
       $this->developerKey = $apiConfig['developer_key'];
60 60
     }
61 61
 
62
-    if (! empty($apiConfig['oauth2_client_id'])) {
62
+    if (!empty($apiConfig['oauth2_client_id'])) {
63 63
       $this->clientId = $apiConfig['oauth2_client_id'];
64 64
     }
65 65
 
66
-    if (! empty($apiConfig['oauth2_client_secret'])) {
66
+    if (!empty($apiConfig['oauth2_client_secret'])) {
67 67
       $this->clientSecret = $apiConfig['oauth2_client_secret'];
68 68
     }
69 69
 
70
-    if (! empty($apiConfig['oauth2_redirect_uri'])) {
70
+    if (!empty($apiConfig['oauth2_redirect_uri'])) {
71 71
       $this->redirectUri = $apiConfig['oauth2_redirect_uri'];
72 72
     }
73 73
 
74
-    if (! empty($apiConfig['oauth2_access_type'])) {
74
+    if (!empty($apiConfig['oauth2_access_type'])) {
75 75
       $this->accessType = $apiConfig['oauth2_access_type'];
76 76
     }
77 77
 
78
-    if (! empty($apiConfig['oauth2_approval_prompt'])) {
78
+    if (!empty($apiConfig['oauth2_approval_prompt'])) {
79 79
       $this->approvalPrompt = $apiConfig['oauth2_approval_prompt'];
80 80
     }
81 81
 
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
     }
118 118
 
119 119
     $authUrl = $this->createAuthUrl($service['scope']);
120
-    header('Location: ' . $authUrl);
120
+    header('Location: '.$authUrl);
121 121
     return true;
122 122
   }
123 123
 
@@ -131,25 +131,25 @@  discard block
 block discarded – undo
131 131
   public function createAuthUrl($scope) {
132 132
     $params = array(
133 133
         'response_type=code',
134
-        'redirect_uri=' . urlencode($this->redirectUri),
135
-        'client_id=' . urlencode($this->clientId),
136
-        'scope=' . urlencode($scope),
137
-        'access_type=' . urlencode($this->accessType),
138
-        'approval_prompt=' . urlencode($this->approvalPrompt),
134
+        'redirect_uri='.urlencode($this->redirectUri),
135
+        'client_id='.urlencode($this->clientId),
136
+        'scope='.urlencode($scope),
137
+        'access_type='.urlencode($this->accessType),
138
+        'approval_prompt='.urlencode($this->approvalPrompt),
139 139
     );
140 140
 
141 141
     // if the list of scopes contains plus.login, add request_visible_actions
142 142
     // to auth URL
143
-    if(strpos($scope, 'plus.login') && count($this->requestVisibleActions) > 0) {
144
-        $params[] = 'request_visible_actions=' .
143
+    if (strpos($scope, 'plus.login') && count($this->requestVisibleActions) > 0) {
144
+        $params[] = 'request_visible_actions='.
145 145
             urlencode($this->requestVisibleActions);
146 146
     }
147 147
 
148 148
     if (isset($this->state)) {
149
-      $params[] = 'state=' . urlencode($this->state);
149
+      $params[] = 'state='.urlencode($this->state);
150 150
     }
151 151
     $params = implode('&', $params);
152
-    return self::OAUTH2_AUTH_URL . "?$params";
152
+    return self::OAUTH2_AUTH_URL."?$params";
153 153
   }
154 154
 
155 155
   /**
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
     if ($token == null) {
162 162
       throw new Google_AuthException('Could not json decode the token');
163 163
     }
164
-    if (! isset($token['access_token'])) {
164
+    if (!isset($token['access_token'])) {
165 165
       throw new Google_AuthException("Invalid token format");
166 166
     }
167 167
     $this->token = $token;
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
     if ($this->developerKey) {
203 203
       $requestUrl = $request->getUrl();
204 204
       $requestUrl .= (strpos($request->getUrl(), '?') === false) ? '?' : '&';
205
-      $requestUrl .=  'key=' . urlencode($this->developerKey);
205
+      $requestUrl .= 'key='.urlencode($this->developerKey);
206 206
       $request->setUrl($requestUrl);
207 207
     }
208 208
 
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
       if ($this->assertionCredentials) {
218 218
         $this->refreshTokenWithAssertion();
219 219
       } else {
220
-        if (! array_key_exists('refresh_token', $this->token)) {
220
+        if (!array_key_exists('refresh_token', $this->token)) {
221 221
             throw new Google_AuthException("The OAuth 2.0 access token has expired, "
222 222
                 . "and a refresh token is not available. Refresh tokens are not "
223 223
                 . "returned for responses that were auto-approved.");
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 
229 229
     // Add the OAuth2 header to the request
230 230
     $request->setRequestHeaders(
231
-        array('Authorization' => 'Bearer ' . $this->token['access_token'])
231
+        array('Authorization' => 'Bearer '.$this->token['access_token'])
232 232
     );
233 233
 
234 234
     return $request;
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
         throw new Google_AuthException("Could not json decode the access token");
278 278
       }
279 279
 
280
-      if (! isset($token['access_token']) || ! isset($token['expires_in'])) {
280
+      if (!isset($token['access_token']) || !isset($token['expires_in'])) {
281 281
         throw new Google_AuthException("Invalid token format");
282 282
       }
283 283
 
@@ -341,8 +341,8 @@  discard block
 block discarded – undo
341 341
       }
342 342
     }
343 343
     throw new Google_AuthException(
344
-        "Failed to retrieve verification certificates: '" .
345
-            $request->getResponseBody() . "'.",
344
+        "Failed to retrieve verification certificates: '".
345
+            $request->getResponseBody()."'.",
346 346
         $request->getResponseHttpCode());
347 347
   }
348 348
 
@@ -375,20 +375,20 @@  discard block
 block discarded – undo
375 375
     if (count($segments) != 3) {
376 376
       throw new Google_AuthException("Wrong number of segments in token: $jwt");
377 377
     }
378
-    $signed = $segments[0] . "." . $segments[1];
378
+    $signed = $segments[0].".".$segments[1];
379 379
     $signature = Google_Utils::urlSafeB64Decode($segments[2]);
380 380
 
381 381
     // Parse envelope.
382 382
     $envelope = json_decode(Google_Utils::urlSafeB64Decode($segments[0]), true);
383 383
     if (!$envelope) {
384
-      throw new Google_AuthException("Can't parse token envelope: " . $segments[0]);
384
+      throw new Google_AuthException("Can't parse token envelope: ".$segments[0]);
385 385
     }
386 386
 
387 387
     // Parse token
388 388
     $json_body = Google_Utils::urlSafeB64Decode($segments[1]);
389 389
     $payload = json_decode($json_body, true);
390 390
     if (!$payload) {
391
-      throw new Google_AuthException("Can't parse token payload: " . $segments[1]);
391
+      throw new Google_AuthException("Can't parse token payload: ".$segments[1]);
392 392
     }
393 393
 
394 394
     // Check signature
Please login to merge, or discard this patch.
geodirectory-admin/google-api-php-client/src/auth/Google_AuthNone.php 2 patches
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -24,10 +24,10 @@  discard block
 block discarded – undo
24 24
   public $key = null;
25 25
 
26 26
   public function __construct() {
27
-    global $apiConfig;
28
-    if (!empty($apiConfig['developer_key'])) {
29
-      $this->setDeveloperKey($apiConfig['developer_key']);
30
-    }
27
+	global $apiConfig;
28
+	if (!empty($apiConfig['developer_key'])) {
29
+	  $this->setDeveloperKey($apiConfig['developer_key']);
30
+	}
31 31
   }
32 32
 
33 33
   public function setDeveloperKey($key) {$this->key = $key;}
@@ -39,10 +39,10 @@  discard block
 block discarded – undo
39 39
   public function revokeToken() {/* noop*/}
40 40
 
41 41
   public function sign(Google_HttpRequest $request) {
42
-    if ($this->key) {
43
-      $request->setUrl($request->getUrl() . ((strpos($request->getUrl(), '?') === false) ? '?' : '&')
44
-          . 'key='.urlencode($this->key));
45
-    }
46
-    return $request;
42
+	if ($this->key) {
43
+	  $request->setUrl($request->getUrl() . ((strpos($request->getUrl(), '?') === false) ? '?' : '&')
44
+		  . 'key='.urlencode($this->key));
45
+	}
46
+	return $request;
47 47
   }
48 48
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -30,17 +30,17 @@
 block discarded – undo
30 30
     }
31 31
   }
32 32
 
33
-  public function setDeveloperKey($key) {$this->key = $key;}
33
+  public function setDeveloperKey($key) {$this->key = $key; }
34 34
   public function authenticate($service) {/*noop*/}
35 35
   public function setAccessToken($accessToken) {/* noop*/}
36
-  public function getAccessToken() {return null;}
37
-  public function createAuthUrl($scope) {return null;}
36
+  public function getAccessToken() {return null; }
37
+  public function createAuthUrl($scope) {return null; }
38 38
   public function refreshToken($refreshToken) {/* noop*/}
39 39
   public function revokeToken() {/* noop*/}
40 40
 
41 41
   public function sign(Google_HttpRequest $request) {
42 42
     if ($this->key) {
43
-      $request->setUrl($request->getUrl() . ((strpos($request->getUrl(), '?') === false) ? '?' : '&')
43
+      $request->setUrl($request->getUrl().((strpos($request->getUrl(), '?') === false) ? '?' : '&')
44 44
           . 'key='.urlencode($this->key));
45 45
     }
46 46
     return $request;
Please login to merge, or discard this patch.
geodirectory-admin/google-api-php-client/src/auth/Google_LoginTicket.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -36,8 +36,8 @@  discard block
 block discarded – undo
36 36
    * @param string $payload Information from a verified authentication token.
37 37
    */
38 38
   public function __construct($envelope, $payload) {
39
-    $this->envelope = $envelope;
40
-    $this->payload = $payload;
39
+	$this->envelope = $envelope;
40
+	$this->payload = $payload;
41 41
   }
42 42
 
43 43
   /**
@@ -46,10 +46,10 @@  discard block
 block discarded – undo
46 46
    * @return
47 47
    */
48 48
   public function getUserId() {
49
-    if (array_key_exists(self::USER_ATTR, $this->payload)) {
50
-      return $this->payload[self::USER_ATTR];
51
-    }
52
-    throw new Google_AuthException("No user_id in token");
49
+	if (array_key_exists(self::USER_ATTR, $this->payload)) {
50
+	  return $this->payload[self::USER_ATTR];
51
+	}
52
+	throw new Google_AuthException("No user_id in token");
53 53
   }
54 54
 
55 55
   /**
@@ -58,6 +58,6 @@  discard block
 block discarded – undo
58 58
    * @return array
59 59
    */
60 60
   public function getAttributes() {
61
-    return array("envelope" => $this->envelope, "payload" => $this->payload);
61
+	return array("envelope" => $this->envelope, "payload" => $this->payload);
62 62
   }
63 63
 }
Please login to merge, or discard this patch.
google-api-php-client/src/auth/Google_AssertionCredentials.php 1 patch
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -45,39 +45,39 @@  discard block
 block discarded – undo
45 45
    *               application is requesting delegated access.
46 46
    */
47 47
   public function __construct(
48
-      $serviceAccountName,
49
-      $scopes,
50
-      $privateKey,
51
-      $privateKeyPassword = 'notasecret',
52
-      $assertionType = 'http://oauth.net/grant_type/jwt/1.0/bearer',
53
-      $sub = false) {
54
-    $this->serviceAccountName = $serviceAccountName;
55
-    $this->scopes = is_string($scopes) ? $scopes : implode(' ', $scopes);
56
-    $this->privateKey = $privateKey;
57
-    $this->privateKeyPassword = $privateKeyPassword;
58
-    $this->assertionType = $assertionType;
59
-    $this->sub = $sub;
60
-    $this->prn = $sub;
48
+	  $serviceAccountName,
49
+	  $scopes,
50
+	  $privateKey,
51
+	  $privateKeyPassword = 'notasecret',
52
+	  $assertionType = 'http://oauth.net/grant_type/jwt/1.0/bearer',
53
+	  $sub = false) {
54
+	$this->serviceAccountName = $serviceAccountName;
55
+	$this->scopes = is_string($scopes) ? $scopes : implode(' ', $scopes);
56
+	$this->privateKey = $privateKey;
57
+	$this->privateKeyPassword = $privateKeyPassword;
58
+	$this->assertionType = $assertionType;
59
+	$this->sub = $sub;
60
+	$this->prn = $sub;
61 61
   }
62 62
 
63 63
   public function generateAssertion() {
64
-    $now = time();
64
+	$now = time();
65 65
 
66
-    $jwtParams = array(
67
-          'aud' => Google_OAuth2::OAUTH2_TOKEN_URI,
68
-          'scope' => $this->scopes,
69
-          'iat' => $now,
70
-          'exp' => $now + self::MAX_TOKEN_LIFETIME_SECS,
71
-          'iss' => $this->serviceAccountName,
72
-    );
66
+	$jwtParams = array(
67
+		  'aud' => Google_OAuth2::OAUTH2_TOKEN_URI,
68
+		  'scope' => $this->scopes,
69
+		  'iat' => $now,
70
+		  'exp' => $now + self::MAX_TOKEN_LIFETIME_SECS,
71
+		  'iss' => $this->serviceAccountName,
72
+	);
73 73
 
74
-    if ($this->sub !== false) {
75
-      $jwtParams['sub'] = $this->sub;
76
-    } else if ($this->prn !== false) {
77
-      $jwtParams['prn'] = $this->prn;
78
-    }
74
+	if ($this->sub !== false) {
75
+	  $jwtParams['sub'] = $this->sub;
76
+	} else if ($this->prn !== false) {
77
+	  $jwtParams['prn'] = $this->prn;
78
+	}
79 79
 
80
-    return $this->makeSignedJwt($jwtParams);
80
+	return $this->makeSignedJwt($jwtParams);
81 81
   }
82 82
 
83 83
   /**
@@ -86,18 +86,18 @@  discard block
 block discarded – undo
86 86
    * @return string The signed JWT.
87 87
    */
88 88
   private function makeSignedJwt($payload) {
89
-    $header = array('typ' => 'JWT', 'alg' => 'RS256');
89
+	$header = array('typ' => 'JWT', 'alg' => 'RS256');
90 90
 
91
-    $segments = array(
92
-      Google_Utils::urlSafeB64Encode(json_encode($header)),
93
-      Google_Utils::urlSafeB64Encode(json_encode($payload))
94
-    );
91
+	$segments = array(
92
+	  Google_Utils::urlSafeB64Encode(json_encode($header)),
93
+	  Google_Utils::urlSafeB64Encode(json_encode($payload))
94
+	);
95 95
 
96
-    $signingInput = implode('.', $segments);
97
-    $signer = new Google_P12Signer($this->privateKey, $this->privateKeyPassword);
98
-    $signature = $signer->sign($signingInput);
99
-    $segments[] = Google_Utils::urlSafeB64Encode($signature);
96
+	$signingInput = implode('.', $segments);
97
+	$signer = new Google_P12Signer($this->privateKey, $this->privateKeyPassword);
98
+	$signature = $signer->sign($signingInput);
99
+	$segments[] = Google_Utils::urlSafeB64Encode($signature);
100 100
 
101
-    return implode(".", $segments);
101
+	return implode(".", $segments);
102 102
   }
103 103
 }
Please login to merge, or discard this patch.
geodirectory-admin/google-api-php-client/src/io/Google_IO.php 2 patches
Indentation   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -57,13 +57,13 @@  discard block
 block discarded – undo
57 57
    * Otherwise, return false.
58 58
    */
59 59
   protected function setCachedRequest(Google_HttpRequest $request) {
60
-    // Determine if the request is cacheable.
61
-    if (Google_CacheParser::isResponseCacheable($request)) {
62
-      Google_Client::$cache->set($request->getCacheKey(), $request);
63
-      return true;
64
-    }
60
+	// Determine if the request is cacheable.
61
+	if (Google_CacheParser::isResponseCacheable($request)) {
62
+	  Google_Client::$cache->set($request->getCacheKey(), $request);
63
+	  return true;
64
+	}
65 65
 
66
-    return false;
66
+	return false;
67 67
   }
68 68
 
69 69
   /**
@@ -73,11 +73,11 @@  discard block
 block discarded – undo
73 73
    * false if the operation was unsuccessful.
74 74
    */
75 75
   protected function getCachedRequest(Google_HttpRequest $request) {
76
-    if (false == Google_CacheParser::isRequestCacheable($request)) {
77
-      false;
78
-    }
76
+	if (false == Google_CacheParser::isRequestCacheable($request)) {
77
+	  false;
78
+	}
79 79
 
80
-    return Google_Client::$cache->get($request->getCacheKey());
80
+	return Google_Client::$cache->get($request->getCacheKey());
81 81
   }
82 82
 
83 83
   /**
@@ -87,28 +87,28 @@  discard block
 block discarded – undo
87 87
    * @return Google_HttpRequest Processed request with the enclosed entity.
88 88
    */
89 89
   protected function processEntityRequest(Google_HttpRequest $request) {
90
-    $postBody = $request->getPostBody();
91
-    $contentType = $request->getRequestHeader("content-type");
92
-
93
-    // Set the default content-type as application/x-www-form-urlencoded.
94
-    if (false == $contentType) {
95
-      $contentType = self::FORM_URLENCODED;
96
-      $request->setRequestHeaders(array('content-type' => $contentType));
97
-    }
98
-
99
-    // Force the payload to match the content-type asserted in the header.
100
-    if ($contentType == self::FORM_URLENCODED && is_array($postBody)) {
101
-      $postBody = http_build_query($postBody, '', '&');
102
-      $request->setPostBody($postBody);
103
-    }
104
-
105
-    // Make sure the content-length header is set.
106
-    if (!$postBody || is_string($postBody)) {
107
-      $postsLength = strlen($postBody);
108
-      $request->setRequestHeaders(array('content-length' => $postsLength));
109
-    }
110
-
111
-    return $request;
90
+	$postBody = $request->getPostBody();
91
+	$contentType = $request->getRequestHeader("content-type");
92
+
93
+	// Set the default content-type as application/x-www-form-urlencoded.
94
+	if (false == $contentType) {
95
+	  $contentType = self::FORM_URLENCODED;
96
+	  $request->setRequestHeaders(array('content-type' => $contentType));
97
+	}
98
+
99
+	// Force the payload to match the content-type asserted in the header.
100
+	if ($contentType == self::FORM_URLENCODED && is_array($postBody)) {
101
+	  $postBody = http_build_query($postBody, '', '&');
102
+	  $request->setPostBody($postBody);
103
+	}
104
+
105
+	// Make sure the content-length header is set.
106
+	if (!$postBody || is_string($postBody)) {
107
+	  $postsLength = strlen($postBody);
108
+	  $request->setRequestHeaders(array('content-length' => $postsLength));
109
+	}
110
+
111
+	return $request;
112 112
   }
113 113
 
114 114
   /**
@@ -120,21 +120,21 @@  discard block
 block discarded – undo
120 120
    * still current and can be re-used.
121 121
    */
122 122
   protected function checkMustRevaliadateCachedRequest($cached, $request) {
123
-    if (Google_CacheParser::mustRevalidate($cached)) {
124
-      $addHeaders = array();
125
-      if ($cached->getResponseHeader('etag')) {
126
-        // [13.3.4] If an entity tag has been provided by the origin server,
127
-        // we must use that entity tag in any cache-conditional request.
128
-        $addHeaders['If-None-Match'] = $cached->getResponseHeader('etag');
129
-      } elseif ($cached->getResponseHeader('date')) {
130
-        $addHeaders['If-Modified-Since'] = $cached->getResponseHeader('date');
131
-      }
132
-
133
-      $request->setRequestHeaders($addHeaders);
134
-      return true;
135
-    } else {
136
-      return false;
137
-    }
123
+	if (Google_CacheParser::mustRevalidate($cached)) {
124
+	  $addHeaders = array();
125
+	  if ($cached->getResponseHeader('etag')) {
126
+		// [13.3.4] If an entity tag has been provided by the origin server,
127
+		// we must use that entity tag in any cache-conditional request.
128
+		$addHeaders['If-None-Match'] = $cached->getResponseHeader('etag');
129
+	  } elseif ($cached->getResponseHeader('date')) {
130
+		$addHeaders['If-Modified-Since'] = $cached->getResponseHeader('date');
131
+	  }
132
+
133
+	  $request->setRequestHeaders($addHeaders);
134
+	  return true;
135
+	} else {
136
+	  return false;
137
+	}
138 138
   }
139 139
 
140 140
   /**
@@ -143,19 +143,19 @@  discard block
 block discarded – undo
143 143
    * @param mixed Associative array of response headers from the last request.
144 144
    */
145 145
   protected function updateCachedRequest($cached, $responseHeaders) {
146
-    if (isset($responseHeaders['connection'])) {
147
-      $hopByHop = array_merge(
148
-        self::$HOP_BY_HOP,
149
-        explode(',', $responseHeaders['connection'])
150
-      );
151
-
152
-      $endToEnd = array();
153
-      foreach($hopByHop as $key) {
154
-        if (isset($responseHeaders[$key])) {
155
-          $endToEnd[$key] = $responseHeaders[$key];
156
-        }
157
-      }
158
-      $cached->setResponseHeaders($endToEnd);
159
-    }
146
+	if (isset($responseHeaders['connection'])) {
147
+	  $hopByHop = array_merge(
148
+		self::$HOP_BY_HOP,
149
+		explode(',', $responseHeaders['connection'])
150
+	  );
151
+
152
+	  $endToEnd = array();
153
+	  foreach($hopByHop as $key) {
154
+		if (isset($responseHeaders[$key])) {
155
+		  $endToEnd[$key] = $responseHeaders[$key];
156
+		}
157
+	  }
158
+	  $cached->setResponseHeaders($endToEnd);
159
+	}
160 160
   }
161 161
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -15,10 +15,10 @@  discard block
 block discarded – undo
15 15
  * limitations under the License.
16 16
  */
17 17
 
18
-require_once GA_API_Path. 'io/Google_HttpRequest.php';
19
-require_once GA_API_Path. 'io/Google_HttpStreamIO.php';
20
-require_once GA_API_Path. 'io/Google_CurlIO.php';
21
-require_once GA_API_Path. 'io/Google_REST.php';
18
+require_once GA_API_Path.'io/Google_HttpRequest.php';
19
+require_once GA_API_Path.'io/Google_HttpStreamIO.php';
20
+require_once GA_API_Path.'io/Google_CurlIO.php';
21
+require_once GA_API_Path.'io/Google_REST.php';
22 22
 
23 23
 /**
24 24
  * Abstract IO class
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
       );
151 151
 
152 152
       $endToEnd = array();
153
-      foreach($hopByHop as $key) {
153
+      foreach ($hopByHop as $key) {
154 154
         if (isset($responseHeaders[$key])) {
155 155
           $endToEnd[$key] = $responseHeaders[$key];
156 156
         }
Please login to merge, or discard this patch.
geodirectory-admin/google-api-php-client/src/io/Google_REST.php 2 patches
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -32,11 +32,11 @@  discard block
 block discarded – undo
32 32
    *  invalid or malformed post body, invalid url)
33 33
    */
34 34
   static public function execute(Google_HttpRequest $req) {
35
-    $httpRequest = Google_Client::$io->makeRequest($req);
36
-    $decodedResponse = self::decodeHttpResponse($httpRequest);
37
-    $ret = isset($decodedResponse['data'])
38
-        ? $decodedResponse['data'] : $decodedResponse;
39
-    return $ret;
35
+	$httpRequest = Google_Client::$io->makeRequest($req);
36
+	$decodedResponse = self::decodeHttpResponse($httpRequest);
37
+	$ret = isset($decodedResponse['data'])
38
+		? $decodedResponse['data'] : $decodedResponse;
39
+	return $ret;
40 40
   }
41 41
 
42 42
   
@@ -48,32 +48,32 @@  discard block
 block discarded – undo
48 48
    * @return mixed|null
49 49
    */
50 50
   public static function decodeHttpResponse($response) {
51
-    $code = $response->getResponseHttpCode();
52
-    $body = $response->getResponseBody();
53
-    $decoded = null;
51
+	$code = $response->getResponseHttpCode();
52
+	$body = $response->getResponseBody();
53
+	$decoded = null;
54 54
     
55
-    if ((intVal($code)) >= 300) {
56
-      $decoded = json_decode($body, true);
57
-      $err = 'Error calling ' . $response->getRequestMethod() . ' ' . $response->getUrl();
58
-      if ($decoded != null && isset($decoded['error']['message'])  && isset($decoded['error']['code'])) {
59
-        // if we're getting a json encoded error definition, use that instead of the raw response
60
-        // body for improved readability
61
-        $err .= ": ({$decoded['error']['code']}) {$decoded['error']['message']}";
62
-      } else {
63
-        $err .= ": ($code) $body";
64
-      }
55
+	if ((intVal($code)) >= 300) {
56
+	  $decoded = json_decode($body, true);
57
+	  $err = 'Error calling ' . $response->getRequestMethod() . ' ' . $response->getUrl();
58
+	  if ($decoded != null && isset($decoded['error']['message'])  && isset($decoded['error']['code'])) {
59
+		// if we're getting a json encoded error definition, use that instead of the raw response
60
+		// body for improved readability
61
+		$err .= ": ({$decoded['error']['code']}) {$decoded['error']['message']}";
62
+	  } else {
63
+		$err .= ": ($code) $body";
64
+	  }
65 65
 
66
-      throw new Google_ServiceException($err, $code, null, $decoded['error']['errors']);
67
-    }
66
+	  throw new Google_ServiceException($err, $code, null, $decoded['error']['errors']);
67
+	}
68 68
     
69
-    // Only attempt to decode the response, if the response code wasn't (204) 'no content'
70
-    if ($code != '204') {
71
-      $decoded = json_decode($body, true);
72
-      if ($decoded === null || $decoded === "") {
73
-        throw new Google_ServiceException("Invalid json in service response: $body");
74
-      }
75
-    }
76
-    return $decoded;
69
+	// Only attempt to decode the response, if the response code wasn't (204) 'no content'
70
+	if ($code != '204') {
71
+	  $decoded = json_decode($body, true);
72
+	  if ($decoded === null || $decoded === "") {
73
+		throw new Google_ServiceException("Invalid json in service response: $body");
74
+	  }
75
+	}
76
+	return $decoded;
77 77
   }
78 78
 
79 79
   /**
@@ -86,43 +86,43 @@  discard block
 block discarded – undo
86 86
    * @return string $requestUrl
87 87
    */
88 88
   static function createRequestUri($servicePath, $restPath, $params) {
89
-    $requestUrl = $servicePath . $restPath;
90
-    $uriTemplateVars = array();
91
-    $queryVars = array();
92
-    foreach ($params as $paramName => $paramSpec) {
93
-      // Discovery v1.0 puts the canonical location under the 'location' field.
94
-      if (! isset($paramSpec['location'])) {
95
-        $paramSpec['location'] = $paramSpec['restParameterType'];
96
-      }
89
+	$requestUrl = $servicePath . $restPath;
90
+	$uriTemplateVars = array();
91
+	$queryVars = array();
92
+	foreach ($params as $paramName => $paramSpec) {
93
+	  // Discovery v1.0 puts the canonical location under the 'location' field.
94
+	  if (! isset($paramSpec['location'])) {
95
+		$paramSpec['location'] = $paramSpec['restParameterType'];
96
+	  }
97 97
 
98
-      if ($paramSpec['type'] == 'boolean') {
99
-        $paramSpec['value'] = ($paramSpec['value']) ? 'true' : 'false';
100
-      }
101
-      if ($paramSpec['location'] == 'path') {
102
-        $uriTemplateVars[$paramName] = $paramSpec['value'];
103
-      } else {
104
-        if (isset($paramSpec['repeated']) && is_array($paramSpec['value'])) {
105
-          foreach ($paramSpec['value'] as $value) {
106
-            $queryVars[] = $paramName . '=' . rawurlencode($value);
107
-          }
108
-        } else {
109
-          $queryVars[] = $paramName . '=' . rawurlencode($paramSpec['value']);
110
-        }
111
-      }
112
-    }
98
+	  if ($paramSpec['type'] == 'boolean') {
99
+		$paramSpec['value'] = ($paramSpec['value']) ? 'true' : 'false';
100
+	  }
101
+	  if ($paramSpec['location'] == 'path') {
102
+		$uriTemplateVars[$paramName] = $paramSpec['value'];
103
+	  } else {
104
+		if (isset($paramSpec['repeated']) && is_array($paramSpec['value'])) {
105
+		  foreach ($paramSpec['value'] as $value) {
106
+			$queryVars[] = $paramName . '=' . rawurlencode($value);
107
+		  }
108
+		} else {
109
+		  $queryVars[] = $paramName . '=' . rawurlencode($paramSpec['value']);
110
+		}
111
+	  }
112
+	}
113 113
 
114
-    if (count($uriTemplateVars)) {
115
-      $uriTemplateParser = new URI_Template_Parser($requestUrl);
116
-      $requestUrl = $uriTemplateParser->expand($uriTemplateVars);
117
-    }
118
-    //FIXME work around for the the uri template lib which url encodes
119
-    // the @'s & confuses our servers.
120
-    $requestUrl = str_replace('%40', '@', $requestUrl);
114
+	if (count($uriTemplateVars)) {
115
+	  $uriTemplateParser = new URI_Template_Parser($requestUrl);
116
+	  $requestUrl = $uriTemplateParser->expand($uriTemplateVars);
117
+	}
118
+	//FIXME work around for the the uri template lib which url encodes
119
+	// the @'s & confuses our servers.
120
+	$requestUrl = str_replace('%40', '@', $requestUrl);
121 121
 
122
-    if (count($queryVars)) {
123
-      $requestUrl .= '?' . implode($queryVars, '&');
124
-    }
122
+	if (count($queryVars)) {
123
+	  $requestUrl .= '?' . implode($queryVars, '&');
124
+	}
125 125
 
126
-    return $requestUrl;
126
+	return $requestUrl;
127 127
   }
128 128
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -54,8 +54,8 @@  discard block
 block discarded – undo
54 54
     
55 55
     if ((intVal($code)) >= 300) {
56 56
       $decoded = json_decode($body, true);
57
-      $err = 'Error calling ' . $response->getRequestMethod() . ' ' . $response->getUrl();
58
-      if ($decoded != null && isset($decoded['error']['message'])  && isset($decoded['error']['code'])) {
57
+      $err = 'Error calling '.$response->getRequestMethod().' '.$response->getUrl();
58
+      if ($decoded != null && isset($decoded['error']['message']) && isset($decoded['error']['code'])) {
59 59
         // if we're getting a json encoded error definition, use that instead of the raw response
60 60
         // body for improved readability
61 61
         $err .= ": ({$decoded['error']['code']}) {$decoded['error']['message']}";
@@ -86,12 +86,12 @@  discard block
 block discarded – undo
86 86
    * @return string $requestUrl
87 87
    */
88 88
   static function createRequestUri($servicePath, $restPath, $params) {
89
-    $requestUrl = $servicePath . $restPath;
89
+    $requestUrl = $servicePath.$restPath;
90 90
     $uriTemplateVars = array();
91 91
     $queryVars = array();
92 92
     foreach ($params as $paramName => $paramSpec) {
93 93
       // Discovery v1.0 puts the canonical location under the 'location' field.
94
-      if (! isset($paramSpec['location'])) {
94
+      if (!isset($paramSpec['location'])) {
95 95
         $paramSpec['location'] = $paramSpec['restParameterType'];
96 96
       }
97 97
 
@@ -103,10 +103,10 @@  discard block
 block discarded – undo
103 103
       } else {
104 104
         if (isset($paramSpec['repeated']) && is_array($paramSpec['value'])) {
105 105
           foreach ($paramSpec['value'] as $value) {
106
-            $queryVars[] = $paramName . '=' . rawurlencode($value);
106
+            $queryVars[] = $paramName.'='.rawurlencode($value);
107 107
           }
108 108
         } else {
109
-          $queryVars[] = $paramName . '=' . rawurlencode($paramSpec['value']);
109
+          $queryVars[] = $paramName.'='.rawurlencode($paramSpec['value']);
110 110
         }
111 111
       }
112 112
     }
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
     $requestUrl = str_replace('%40', '@', $requestUrl);
121 121
 
122 122
     if (count($queryVars)) {
123
-      $requestUrl .= '?' . implode($queryVars, '&');
123
+      $requestUrl .= '?'.implode($queryVars, '&');
124 124
     }
125 125
 
126 126
     return $requestUrl;
Please login to merge, or discard this patch.