Advertisement
saitanay

Untitled

May 30th, 2015
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.03 KB | None | 0 0
  1. diff --git a/simple_fb_connect.admin.inc b/simple_fb_connect.admin.inc
  2. index a019d98..e44a95b 100644
  3. --- a/simple_fb_connect.admin.inc
  4. +++ b/simple_fb_connect.admin.inc
  5. @@ -7,7 +7,7 @@
  6. function simple_fb_connect_api_keys_settings($form, &$form_state) {
  7. // Check that Facebook PHP SDK is properly installed and that the version is 4.0.x
  8. $sdk = libraries_detect('facebook-php-sdk-v4');
  9. - if (!is_array($sdk) || !$sdk['installed'] || $sdk['version'] < '4.0' || $sdk['version'] >= '4.1') {
  10. + if ( !is_array($sdk) || !$sdk['installed'] || $sdk['version'] < '4.0' || $sdk['version'] >= '4.1') {
  11. drupal_set_message(t('Facebook PHP SDK not poperly installed. Check README.txt and Drupal status report!'), 'error');
  12. }
  13.  
  14. diff --git a/simple_fb_connect.api.php b/simple_fb_connect.api.php
  15. index 753e066..85084c3 100644
  16. --- a/simple_fb_connect.api.php
  17. +++ b/simple_fb_connect.api.php
  18. @@ -4,6 +4,7 @@
  19. * @file
  20. * Hooks provided by the Simple FB Connect module.
  21. */
  22. +
  23. /**
  24. * @addtogroup hooks
  25. * @{
  26. @@ -26,6 +27,7 @@ function hook_simple_fb_connect_register_alter(&$fields, $fb_user_profile) {
  27. // Implement this hook in your own module to modify $fields array
  28. }
  29.  
  30. +
  31. /**
  32. * This hook allows other modules to add permissions to $scope array
  33. *
  34. diff --git a/simple_fb_connect.install b/simple_fb_connect.install
  35. index 9861e7b..ad46359 100644
  36. --- a/simple_fb_connect.install
  37. +++ b/simple_fb_connect.install
  38. @@ -36,7 +36,7 @@ function simple_fb_connect_requirements($phase) {
  39. $requirements['facebook-php-sdk-v4']['severity'] = REQUIREMENT_ERROR;
  40. $requirements['facebook-php-sdk-v4']['description'] = $t('Facebook PHP SDK v4 library not found. See README.txt');
  41. }
  42. - elseif (($sdk['version'] < '4.0') || ($sdk['version'] >= '4.1')) {
  43. + elseif ( ($sdk['version'] < '4.0') || ($sdk['version'] >= '4.1') ) {
  44. $requirements['facebook-php-sdk-v4']['value'] = $t('Unsupported version detected');
  45. $requirements['facebook-php-sdk-v4']['severity'] = REQUIREMENT_ERROR;
  46. $requirements['facebook-php-sdk-v4']['description'] = $t('Version @version detected. See README.txt', array('@version' => $sdk['version']));
  47. diff --git a/simple_fb_connect.module b/simple_fb_connect.module
  48. index abe6979..5cb08e7 100644
  49. --- a/simple_fb_connect.module
  50. +++ b/simple_fb_connect.module
  51. @@ -68,7 +68,7 @@ function simple_fb_connect_permission() {
  52. function simple_fb_connect_login($returned_from_fb = NULL) {
  53. // Check that Facebook PHP SDK is properly installed and that the version is 4.0.x
  54. $sdk = libraries_detect('facebook-php-sdk-v4');
  55. - if (!is_array($sdk) || !$sdk['installed'] || $sdk['version'] < '4.0' || $sdk['version'] >= '4.1') {
  56. + if ( !is_array($sdk) || !$sdk['installed'] || $sdk['version'] < '4.0' || $sdk['version'] >= '4.1') {
  57. drupal_set_message(t('Facebook PHP SDK not poperly installed. Contact site administrator.'), 'error');
  58. drupal_goto("user");
  59. }
  60. @@ -89,7 +89,7 @@ function simple_fb_connect_login($returned_from_fb = NULL) {
  61.  
  62. // Save the post login URL to $_SESSION if it was explicitly defined.
  63. $destination = drupal_get_destination();
  64. - if (!url_is_external($destination['destination']) && $destination['destination'] != 'user/simple-fb-connect') {
  65. + if ( !url_is_external($destination['destination']) && $destination['destination'] != 'user/simple-fb-connect' ) {
  66. $_SESSION['simple_fb_connect']['post_login_url'] = $destination['destination'];
  67. // We need to unset the GET parameter so that we actually redirect the user to FB
  68. unset($_GET['destination']);
  69. @@ -277,7 +277,9 @@ function simple_fb_connect_create_user($fb_user_profile, $session) {
  70. // log new user creation
  71. if ($account) {
  72. watchdog(
  73. - 'simple_fb_connect', 'New user created: @username', array('@username' => $drupal_username_generated), WATCHDOG_NOTICE
  74. + 'simple_fb_connect', 'New user created: @username',
  75. + array('@username' => $drupal_username_generated),
  76. + WATCHDOG_NOTICE
  77. );
  78. return $account;
  79. }
  80. @@ -285,7 +287,10 @@ function simple_fb_connect_create_user($fb_user_profile, $session) {
  81.  
  82. // Something went wrong
  83. watchdog(
  84. - 'simple_fb_connect', 'Could not create new user.', array(), WATCHDOG_ERROR
  85. + 'simple_fb_connect',
  86. + 'Could not create new user.',
  87. + array(),
  88. + WATCHDOG_ERROR
  89. );
  90. return FALSE;
  91. }
  92. @@ -303,15 +308,19 @@ function simple_fb_connect_get_fb_profile($session) {
  93. $request = new FacebookRequest($session, 'GET', '/me');
  94. $object = $request->execute()->getGraphObject();
  95. return $object;
  96. - }
  97. - catch (FacebookRequestException $ex) {
  98. + } catch (FacebookRequestException $ex) {
  99. watchdog(
  100. - 'simple_fb_connect', 'Could not load FB user profile: FacebookRequestException. Error details: @message', array('@message' => json_encode($ex->getResponse())), WATCHDOG_ERROR
  101. + 'simple_fb_connect',
  102. + 'Could not load FB user profile: FacebookRequestException. Error details: @message',
  103. + array('@message' => json_encode($ex->getResponse())),
  104. + WATCHDOG_ERROR
  105. );
  106. - }
  107. - catch (\Exception $ex) {
  108. + } catch (\Exception $ex) {
  109. watchdog(
  110. - 'simple_fb_connect', 'Could not load FB user profile: Unhandled exception. Error details: @message', array('@message' => $ex->getMessage()), WATCHDOG_ERROR
  111. + 'simple_fb_connect',
  112. + 'Could not load FB user profile: Unhandled exception. Error details: @message',
  113. + array('@message' => $ex->getMessage()),
  114. + WATCHDOG_ERROR
  115. );
  116. }
  117.  
  118. @@ -354,18 +363,25 @@ function simple_fb_connect_get_fb_profile_pic($session) {
  119. }
  120. else {
  121. watchdog(
  122. - 'simple_fb_connect', 'Could not save FB profile picture. Check that directory is writeable: @destination', array('@destination' => $destination), WATCHDOG_ERROR
  123. + 'simple_fb_connect',
  124. + 'Could not save FB profile picture. Check that directory is writeable: @destination',
  125. + array('@destination' => $destination),
  126. + WATCHDOG_ERROR
  127. );
  128. }
  129. - }
  130. - catch (FacebookRequestException $ex) {
  131. + } catch (FacebookRequestException $ex) {
  132. watchdog(
  133. - 'simple_fb_connect', 'Could not load FB profile picture: FacebookRequestException. Error details: @message', array('@message' => json_encode($ex->getResponse())), WATCHDOG_ERROR
  134. + 'simple_fb_connect',
  135. + 'Could not load FB profile picture: FacebookRequestException. Error details: @message',
  136. + array('@message' => json_encode($ex->getResponse())),
  137. + WATCHDOG_ERROR
  138. );
  139. - }
  140. - catch (\Exception $ex) {
  141. + } catch (\Exception $ex) {
  142. watchdog(
  143. - 'simple_fb_connect', 'Could not load FB profile picture: Unhandled exception. Error details: @message', array('@message' => $ex->getMessage()), WATCHDOG_ERROR
  144. + 'simple_fb_connect',
  145. + 'Could not load FB profile picture: Unhandled exception. Error details: @message',
  146. + array('@message' => $ex->getMessage()),
  147. + WATCHDOG_ERROR
  148. );
  149. }
  150.  
  151. @@ -410,7 +426,10 @@ function simple_fb_connect_initialize() {
  152. }
  153. else {
  154. watchdog(
  155. - 'simple_fb_connect', 'Could not initialize FB App. Define APP ID and APP SECRET on module settings.', array(), WATCHDOG_ERROR
  156. + 'simple_fb_connect',
  157. + 'Could not initialize FB App. Define APP ID and APP SECRET on module settings.',
  158. + array(),
  159. + WATCHDOG_ERROR
  160. );
  161. return FALSE;
  162. }
  163. @@ -428,25 +447,32 @@ function simple_fb_connect_initialize() {
  164. function simple_fb_connect_save_session($helper) {
  165. try {
  166. $session = $helper->getSessionFromRedirect();
  167. - }
  168. - catch (FacebookRequestException $ex) {
  169. + } catch (FacebookRequestException $ex) {
  170. // When Facebook returns an error
  171. watchdog(
  172. - 'simple_fb_connect', 'Could not save FB session. FacebookRequestException: @message', array('@message' => json_encode($ex->getResponse())), WATCHDOG_ERROR
  173. + 'simple_fb_connect',
  174. + 'Could not save FB session. FacebookRequestException: @message',
  175. + array('@message' => json_encode($ex->getResponse())),
  176. + WATCHDOG_ERROR
  177. );
  178. return FALSE;
  179. - }
  180. - catch (\Exception $ex) {
  181. + } catch (\Exception $ex) {
  182. // When validation fails or other local issues
  183. watchdog(
  184. - 'simple_fb_connect', 'Could not save FB session. Exception: @message', array('@message' => $ex->getMessage()), WATCHDOG_ERROR
  185. + 'simple_fb_connect',
  186. + 'Could not save FB session. Exception: @message',
  187. + array('@message' => $ex->getMessage()),
  188. + WATCHDOG_ERROR
  189. );
  190. return FALSE;
  191. }
  192.  
  193. if (!$session) {
  194. watchdog(
  195. - 'simple_fb_connect', 'Facebook did not return an exception but session was NULL (user might have closed the dialog)', array(), WATCHDOG_ERROR
  196. + 'simple_fb_connect',
  197. + 'Facebook did not return an exception but session was NULL (user might have closed the dialog)',
  198. + array(),
  199. + WATCHDOG_ERROR
  200. );
  201. return FALSE;
  202. }
  203. @@ -478,17 +504,21 @@ function simple_fb_connect_get_session() {
  204. try {
  205. $session->validate();
  206. return $session;
  207. - }
  208. - catch (FacebookRequestException $ex) {
  209. + } catch (FacebookRequestException $ex) {
  210. // Session not valid, Graph API returned an exception with the reason.
  211. watchdog(
  212. - 'simple_fb_connect', 'Could not load FB session. FacebookRequestException: @message', array('@message' => json_encode($ex->getResponse())), WATCHDOG_NOTICE
  213. + 'simple_fb_connect',
  214. + 'Could not load FB session. FacebookRequestException: @message',
  215. + array('@message' => json_encode($ex->getResponse())),
  216. + WATCHDOG_NOTICE
  217. );
  218. - }
  219. - catch (\Exception $ex) {
  220. + } catch (\Exception $ex) {
  221. // Graph API returned info, but it may mismatch the current app or have expired.
  222. watchdog(
  223. - 'simple_fb_connect', 'Could not load FB session. Exception: @message', array('@message' => $ex->getMessage()), WATCHDOG_ERROR
  224. + 'simple_fb_connect',
  225. + 'Could not load FB session. Exception: @message',
  226. + array('@message' => $ex->getMessage()),
  227. + WATCHDOG_ERROR
  228. );
  229. }
  230. }
  231. @@ -512,8 +542,8 @@ function simple_fb_connect_libraries_info() {
  232. 'pattern' => '@Stable-(\d*\.\d*\.\d*)@'
  233. ),
  234. 'xautoload' => function($adapter) {
  235. - $adapter->add('Facebook', 'src');
  236. -},
  237. + $adapter->add('Facebook', 'src');
  238. + },
  239. );
  240. return $libraries;
  241. }
  242. @@ -577,7 +607,7 @@ function simple_fb_connect_get_post_login_url() {
  243. $post_login_url = variable_get('simple_fb_connect_post_login_url', 'user');
  244.  
  245. // If we have stored the destination to $_SESSION, use that instead
  246. - if (isset($_SESSION) && isset($_SESSION['simple_fb_connect']) && isset($_SESSION['simple_fb_connect']['post_login_url'])) {
  247. + if ( isset($_SESSION) && isset($_SESSION['simple_fb_connect']) && isset($_SESSION['simple_fb_connect']['post_login_url']) ) {
  248. $post_login_url = $_SESSION['simple_fb_connect']['post_login_url'];
  249. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement