Index: drupalgapps.module
===================================================================
--- drupalgapps.module	(revision 519)
+++ drupalgapps.module	(working copy)
@@ -22,19 +22,18 @@
       $output = '<p>'. t('Google Apps framework for Drupal') .'</p>';
       $output .= '<p>'. t('This Module is the core of Google Apps framework. It has following tasks to handle : ') .'</p>';
       $output .= '<ol><li>'. t('Impliment Wrapper of  <a href = "@provision">Google Apps provisioning api</a> ( CRUD and more of Google apps user account )', array('@provision' => 'http://code.google.com/apis/apps/gdata_provisioning_api_v2.0_reference.htm')) .'</li>';
-      $output .= '<li>'. t('<a href=@clientlogin>Client Login</a> Authentication for Provisioning API', array('@clientlogin' => 'http://code.google.com/apis/accounts/docs/AuthForInstalledApps.html#ClientLogin')) .'</li>';
-      $output .= '<li>'. t('The Core : developed to assist develop wrapper/application of/using other Google Apps  APIs , which are not yet covered.  ') .'</li></ol>';
+      $output .= '<li>'. t('<a href="@clientlogin">Client Login</a> Authentication for Provisioning API', array('@clientlogin' => 'http://code.google.com/apis/accounts/docs/AuthForInstalledApps.html#ClientLogin')) .'</li>';
+      $output .= '<li>'. t('The Core : developed to assist develop wrapper/application of/using other Google Apps  APIs , which are not yet covered.') .'</li></ol>';
       break;
   }
   return $output;
 
-  
+
 }
 
 
-function drupalgapps_page()
-{
-    return drupal_get_form('drupalgapps_form');
+function drupalgapps_page() {
+  return drupal_get_form('drupalgapps_form');
 }
 
 /*
@@ -54,226 +53,186 @@
  *          ii. Enter the Email id ( validate for email type ) (optional)
  */
 
+
 /*
- * implimentation of hook_form
+ * Implementation of hook_form().
  */
+function drupalgapps_form($formstate) {
+  $form = array();
 
-function drupalgapps_form($formstate)
-{
-    $form=array();
+  $form['domain_info'] = array(
+    '#type' =>'fieldset',
+    '#title'=> t('Domain information'),
+    '#description' => t('Detail about the Domain , on which Google apps is impliemented which you intend use this module for.'),
+    '#collapsible'=> TRUE,
+    '#collapsed' => FALSE,
+  );
 
-    $form['domain_info']=array(
+  $form['domain_info']['domain_name'] = array(
+    '#type' => t('textfield'),
+    '#title'=> t('Enter the Domain name '),
+    '#description' => t('domain name for which you/your organisation has/have registered Google Apps. Example : www.example.com'),
+    '#size' => 30,
+    '#required' => TRUE,
+    '#default_value' => variable_get('gapps_domain_name', ''),
+  );
 
-        '#type' =>'fieldset',
-        '#title'=> t('Domain information'),
-        '#description' => t('Detail about the Domain , on which Google apps is impliemented which you intend use this module for.'),
-        '#collapsible'=> TRUE,
-        '#collapsed' => FALSE,
+  $form['domain_info']['organisation'] = array(
+    '#type' => t('textfield'),
+    '#title'=> t('Organisation Name (Optional)'),
+    '#description' => t('Organisation to which this domain belong or The organisation which is going to use  Google apps on this Domain. Which ever more specific.'),
+    '#size' => 30,
+    '#default_value' => variable_get('gapps_organisation_name', ''),
+  );
 
-        );
-
-    $form['domain_info']['domain_name'] = array(
-
-        '#type' => t('textfield'),
-        '#title'=> t('Enter the Domain name '),
-        '#description' => t('domain name for which you/your organisation has/have registered Google Apps. Example : www.example.com'),
-        '#size' => 30,
-        '#required' => TRUE,
-        '#default_value' => variable_get('gapps_domain_name',''),
-
-        );
-
-    $form['domain_info']['organisation'] = array(
-
-        '#type' => t('textfield'),
-        '#title'=> t('Organisation Name (Optional)'),
-        '#description' => t('Organisation to which this domain belong or The organisation which is going to use  Google apps on this Domain. Which ever more specific.'),
-        '#size' => 30,
-        '#default_value' => variable_get('gapps_organisation_name',''),
-
-        );
-
-
-   $form['admin_credentials'] = array(
-
+  $form['admin_credentials'] = array(
     '#type' => 'fieldset',
     '#title' => t('Administrator credentials'),
-    '#description' => 'Administrator account details used for fetching Authentication token',
+    '#description' => t('Administrator account details used for fetching Authentication token'),
     '#collapsible' => TRUE,
     '#collapsed' => FALSE,
-
   );
 
   $form['admin_credentials']['admin_email'] = array(
-
     '#type' => 'textfield',
     '#title' => t('Email'),
     '#required' => TRUE,
     '#default_value' => 'admin@example.com',
-    '#description' => 'Enter the ADMIN EMAIL ( full ) . Preferably you should create a seperate email id with admin rights (privilages), and donot use anywhere esle, i.e Specially/only used by this module. The reason being, the password for that email/account should not be changed, else you will also have to update in this modules setting immediately, else this module and all the modules using this module will be disabled',
+    '#description' => t('Enter the ADMIN EMAIL (ful ) . Preferably you should create a seperate email id with admin rights (privilages), and donot use anywhere esle, i.e Specially/only used by this module. The reason being, the password for that email/account should not be changed, else you will also have to update in this modules setting immediately, else this module and all the modules using this module will be disabled'),
     '#size' => 30,
-    '#default_value' => trim(aes_decrypt(variable_get('gapps_admin_email',''))),
-
+    '#default_value' => trim(aes_decrypt(variable_get('gapps_admin_email', ''))),
   );
 
   $form['admin_credentials']['admin_password'] = array(
-
     '#type' => 'textfield',
     '#title' => t('Password for the admin email'),
     '#required' => TRUE,
     '#size' => 30,
-    '#default_value' => trim(aes_decrypt(variable_get('gapps_admin_password',''))),
-
+    '#default_value' => trim(aes_decrypt(variable_get('gapps_admin_password', ''))),
   );
 
 
-    $form['token_policy'] = array(
-
+  $form['token_policy'] = array(
     '#type' => 'fieldset' ,
     '#title' => t('Token Renewal Policy'),
     '#collapsible'=>TRUE,
     '#collapsed' => FALSE,
     '#description' => t('This section deals with all the setting related to token storage, renewal and logging'),
+  );
 
-    );
-
-    $form['token_policy']['renewal_rate'] = array(
-
+  $form['token_policy']['renewal_rate'] = array(
     '#type' => 'select',
-    '#title' => t('Revewal rate of auth. token ( in Hours)'),
-    '#options' =>drupal_map_assoc(range(1,23)),
-    '#default_value' => variable_get('gapps_token_renewal_rate',23),
+    '#title' => t('Revewal rate of auth. token (in Hours)'),
+    '#options' => drupal_map_assoc(range(1, 23)),
+    '#default_value' => variable_get('gapps_token_renewal_rate', 23),
     '#description' => t('ONLY FOR ADVANCED USERS.<br/> DO NOT change it untill you have knowledge about the Authentication token involved in provisioning API authentication.<br/><br/> Though, the authenication token used for provisioning API expires every 24 hours, but to eliminate any last minute glichtes, by DEFAULT the module runs the cron job and renew the token in every 23 hrs.  '),
+  );
 
-);
+  $form['token_policy']['on_failure'] = array(
+    '#type' => 'fieldset' ,
+    '#title'=> t('On Event when failure occurs while fetching Token'),
+    '#description' => t('Action to be taken when the module is unable to fetch the Authentication token for Google Apps'),
+    '#collapsible' => TRUE,
+    '#collapsed' => FALSE,
+  );
 
-     $form['token_policy']['on_failure'] = array(
+  $form['token_policy']['on_failure']['send_email'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Send Email to Administrator'),
+    '#default_value' => variable_get('gapps_email_send_option', 1),
+    '#description' => t('Enabled by default. On enabling this , Drupal will mail admin if token expires or get revoked or anyother reason due to which Provisioning API doesnot function.'),
+  );
 
-        '#type' => 'fieldset' ,
-        '#title'=> 'On Event when failure occurs while fecthing Token ',
-        '#description' => 'Action to be taken when the module is unable to fetch the Authentication token for Google Apps',
-        '#collapsible' => TRUE,
-        '#collapsed' => False,
+  $form['token_policy']['on_failure']['failure_email'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Email address to send the warning email (optional )'),
+    '#description' => t('If left Empty, the email will be sent to the administrator account used to fetch the authentication token, i.e. Enter above.'),
+    '#size' => 30,
+    '#required' => FALSE,
+    '#default_value' => variable_get('gapps_failure_email', ''),
+  );
 
-      );
+  $form['proxy_config'] = array(
+    '#type' => 'fieldset',
+    '#title'=> t('Proxy configuration of the Web-Server'),
+    '#collapsible' => TRUE,
+    '#collapsed' => FALSE,
+  );
 
-      $form['token_policy']['on_failure']['send_email'] = array(
+  $form['proxy_config']['proxy'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Proxy Server Details'),
+    '#description' => t('If your webserver is under any procy server, through which it is accessing Internet, Please enter Proxy server IP address and port Details in form <b>[ip address]:[port]</b> , eg : 172.16.68.6:3128'),
+    '#size' => 30,
+    '#required' => FALSE,
+    '#default_value' => variable_get('gapps_proxy', ''),
+  );
 
-          '#type' => 'checkbox',
-          '#title' => 'Send Email to Administrator',
-          '#default_value' => variable_get('gapps_email_send_option',1),
-          '#description' => 'Enabled by default. On enabling this , Drupal will mail admin if token expires or get revoked or anyother reason due to which Provisioning API doesnot function.',
-        );
+  $form['submit'] = array(
+    '#type' => 'submit',
+    '#value' => t('Save'),
+  );
 
-      $form['token_policy']['on_failure']['failure_email'] = array(
-
-          '#type' => 'textfield',
-          '#title' => 'Email address to send the warning email (optional )',
-          '#description' => 'If left Empty, the email will be sent to the administrator account used to fetch the authentication token, i.e. Enter above.',
-          '#size' => 30,
-          '#required' => FALSE,
-          '#default_value' => variable_get('gapps_failure_email',''),
-
-        );
-
-        $form['proxy_config']= array(
-          '#type' => 'fieldset',
-          '#title'=> 'Proxy configuration of the Web-Server',
-          '#collapsible' => TRUE,
-          '#collapsed' => False,
-
-
-        );
-
-        $form['proxy_config']['proxy'] = array(
-            '#type' => 'textfield',
-            '#title' => 'Proxy Server Details',
-            '#description' => ' If your webserver is under any procy server, through which it is accessing Internet, Please enter Proxy server IP address and port Details in form <b>[ip address]:[port]</b> , eg : 172.16.68.6:3128',
-            '#size' => 30,
-            '#required' => FALSE,
-            '#default_value'=>variable_get('gapps_proxy',''),
-
-        );
-
-        $form['submit'] = array(
-
-            '#type' => 'submit',
-            '#value' => 'Save',
-        );
-
-
-
   return $form;
  //  return system_settings_form($form);
-
 }
 
 
-function drupalgapps_form_submit($form_id,&$form_state){
+function drupalgapps_form_submit($form_id, &$form_state) {
+  $admin_email = valid_email_address($form_state['values']['admin_email']);
+  $failure_email = valid_email_address($form_state['values']['failure_email']);
 
+  if (!$admin_email) {
+    form_set_error('admin_email', 'Email address entered is not Valid');
+  }
+  elseif ($form_state['values']['failure_email'] != NULL && !$failure_email) {
+    form_set_error('failure_email', 'Email address entered is not Valid');
+  }
+  else {
+    $domain_name = $form_state['values']['domain_name'];
+    variable_set('gapps_domain_name', $domain_name);
 
-    $admin_email =valid_email_address($form_state['values']['admin_email']);
-    $failure_email=valid_email_address($form_state['values']['failure_email']);
+    $organisation_name = $form_state['values']['organisation'];
+    variable_set('gapps_organisation_name', $organisation_name);
 
-    
+    $admin_email_address = $form_state['values']['admin_email'];
+    $encrypted_admin_email = aes_encrypt($admin_email_address);
+    variable_set('gapps_admin_email', $encrypted_admin_email);
 
+    $admin_email_password = $form_state['values']['admin_password'];
+    $encrypted_admin_password = aes_encrypt($admin_email_password);
+    variable_set('gapps_admin_password', $encrypted_admin_password);
 
-    if(!$admin_email)
-      {
-        form_set_error('admin_email','Email address entered is not Valid');
-      }
-    elseif($form_state['values']['failure_email']!=NULL && !$failure_email)
-      {
-        form_set_error('failure_email','Email address entered is not Valid');
-      }
-    else
-    {
-       
-    $domain_name=$form_state['values']['domain_name'];
-        variable_set('gapps_domain_name', $domain_name);
+    $renewal_rate = $form_state['values']['renewal_rate'];
+    variable_set('gapps_token_renewal_rate', $renewal_rate);
 
-    $organisation_name=$form_state['values']['organisation'];
-        variable_set('gapps_organisation_name', $organisation_name);
+    $email_send_option = $form_state['values']['send_email'];
+    variable_set('gapps_email_send_option', $email_send_option);
 
-    $admin_email_address=$form_state['values']['admin_email'];
-        $encrypted_admin_email = aes_encrypt($admin_email_address);
-        variable_set('gapps_admin_email',$encrypted_admin_email);
+    $failure_email_address = $form_state['values']['failure_email'];
+    variable_set('gapps_failure_email', $failure_email_address);
 
-    $admin_email_password=$form_state['values']['admin_password'];
-        $encrypted_admin_password = aes_encrypt($admin_email_password);
-        variable_set('gapps_admin_password',$encrypted_admin_password);
-
-    $renewal_rate=$form_state['values']['renewal_rate'];
-        variable_set('gapps_token_renewal_rate',$renewal_rate);
-
-    $email_send_option=$form_state['values']['send_email'];
-        variable_set('gapps_email_send_option',$email_send_option);
-
-    $failure_email_address=$form_state['values']['failure_email'];
-        variable_set('gapps_failure_email',$failure_email_address);
-
-    $proxy_address=$form_state['values']['proxy'];
-    if($proxy_address)
-    {
-        variable_set('gapps_proxy',$proxy_address);
-              }
-    else
-    {variable_set('gapps_proxy',NULL);}
-
-        drupalgapps_get_authtoken();
+    $proxy_address = $form_state['values']['proxy'];
+    if ($proxy_address) {
+      variable_set('gapps_proxy', $proxy_address);
     }
+    else {
+      variable_set('gapps_proxy', NULL);
+    }
 
+    drupalgapps_get_authtoken();
+  }
 
 }
 
 /*
- * The function to fecth the Authentication token
+ * The function to fetch the Authentication token
  */
 
 function drupalgapps_get_authtoken() {
-    
 
-  /*$form['drupalgapps_settings'] = array(
+  /*
+  $form['drupalgapps_settings'] = array(
     '#type' => 'textfield',
     '#title' => t('Maximum number of links'),
     '#default_value' => '2',
@@ -281,195 +240,150 @@
     '#maxlength' => 2,
     '#description' => t("The maximum number of links to display in the block."),
     '#required' => TRUE,
-  );*/
+  );
+  */
 
 
-$admin_api_email = trim(aes_decrypt(variable_get('gapps_admin_email','')));
-$admin_api_password = trim(aes_decrypt(variable_get('gapps_admin_password','')));
+  $admin_api_email = trim(aes_decrypt(variable_get('gapps_admin_email', '')));
+  $admin_api_password = trim(aes_decrypt(variable_get('gapps_admin_password', '')));
+  $proxy_add = variable_get('gapps_proxy', NULL);
+  if ($proxy_add) {
+    $proxy_exist = 1;
+  }
+  else {
+    $proxy_exist = 0;
+  }
 
 
-$proxy_add = variable_get('gapps_proxy',NULL);
+  $http_proxy_status = '0';
+  $proxy_address = '';
+  $headerdata = "&Email=".urlencode($admin_api_email)."&Passwd=".$admin_api_password."&accountType=HOSTED&service=apps";
 
+  $headerfields = array(
+    'Content-type' => 'application/x-www-form-urlencoded',
+    'Content-Length' => strlen($headerdata)
+  );
+  //$headerfields = $headerfields."\nContent-Length :".strlen($headerdata);
 
-     
 
+  $curl_post_request = curl_init();
+  curl_setopt($curl_post_request, CURLOPT_URL, 'https://www.google.com/accounts/ClientLogin');
+  curl_setopt($curl_post_request, CURLOPT_RETURNTRANSFER, 1);
+  curl_setopt($curl_post_request, CURLOPT_HTTPHEADER, array($headerfields));
+  curl_setopt($curl_post_request, CURLOPT_POSTFIELDS, $headerdata);
+  curl_setopt($curl_post_request, CURLOPT_HTTPPROXYTUNNEL, $proxy_exist);
+  curl_setopt($curl_post_request, CURLOPT_PROXY, $proxy_add );
+  curl_setopt($curl_post_request, CURLOPT_SSL_VERIFYPEER, FALSE);
+  curl_setopt($curl_post_request, CURLOPT_SSL_VERIFYHOST,  2);
+  $response = curl_exec($curl_post_request);
 
-     if($proxy_add){
-         $proxy_exist=1;
-     }
-     else
-     {
-         $proxy_exist=0;
-     }
 
+  /*
+   * Get the respose code
+   *
+   * HTTP 200 : Success --> Token fetched
+   * HTTP 403 : Access forbidden --> Token not Fetched
+   */
 
-$http_proxy_status = '0';
-$proxy_address = '';
-$headerdata="&Email=".urlencode($admin_api_email)."&Passwd=".$admin_api_password."&accountType=HOSTED&service=apps";
+  $response_code = curl_getinfo($curl_post_request, CURLINFO_HTTP_CODE);
+  curl_close($curl_post_request);
+  $response = substr($response, strpos($response, "Auth") + 5, strlen($response));
+  drupal_set_message($response);
+  if ($response_code == '200') {
+    drupal_set_message(t('Authentication Token fetched'), 'status');
+    watchdog('Google Apps', 'Authentication token fetched properly.', array(), WATCHDOG_NOTICE);
+    variable_set ("gapps_prov_api_auth_token", $response);  //Store authentication token in drupal variable
+  }
+  elseif ($response_code == '403') {
+    drupal_set_message('Unable to fetch Token . Please Re-check the credentials', 'error');
+    drupalgapp_failure_warning($admin_api_email);
+  }
 
-$headerfields=array(
-                    'Content-type' => 'application/x-www-form-urlencoded',
-                    'Content-Length' => strlen($headerdata)
-                   );
-//$headerfields=$headerfields."\nContent-Length :".strlen($headerdata);
+  /*
+   * CURL options and thier purpose :
+   *
+   * CURLOPT_SSL_VERIFYPEER  : FALSE to stop cURL from verifying the peer's certificate.
+   * CURLOPT_SSL_VERIFYHOST  : 2 to check the existence of a common name and also verify that it matches the hostname provided. 1 to check the existence of a common name in the SSL peer certificate.
+   * CURLOPT_HTTPPROXYTUNNEL : TRUE to tunnel through a given HTTP proxy.
+   * CURLOPT_PROXY           : The HTTP proxy to tunnel requests through.
+   */
 
-
-$curl_post_request = curl_init();
-
-    curl_setopt($curl_post_request, CURLOPT_URL,'https://www.google.com/accounts/ClientLogin');
-    curl_setopt($curl_post_request, CURLOPT_RETURNTRANSFER,1);
-    curl_setopt($curl_post_request, CURLOPT_HTTPHEADER, array($headerfields));
-    curl_setopt($curl_post_request, CURLOPT_POSTFIELDS, $headerdata);
-    curl_setopt($curl_post_request, CURLOPT_HTTPPROXYTUNNEL,$proxy_exist);
-    curl_setopt($curl_post_request, CURLOPT_PROXY,$proxy_add );
-    curl_setopt($curl_post_request, CURLOPT_SSL_VERIFYPEER, FALSE);
-    curl_setopt($curl_post_request, CURLOPT_SSL_VERIFYHOST,  2);
-
-$response = curl_exec($curl_post_request);
-
-
-/*
- * Get the respose code
- *
- * HTTP 200 : Success --> Token fetched
- * HTTP 403 : Access forbidden --> Token not Fetched
- */
-
-$response_code=curl_getinfo($curl_post_request, CURLINFO_HTTP_CODE);
-
-curl_close($curl_post_request);
-
-$response = substr($response, strpos($response, "Auth") + 5, strlen($response));
-
-drupal_set_message($response);
-
-    if($response_code=='200')
-        {
-
-        drupal_set_message('Authentication Token fetched', 'status');
-
-        watchdog('Google Apps','Authentication token fecthed properly.', array(), WATCHDOG_NOTICE);
-
-        variable_set ("gapps_prov_api_auth_token", $response);  //Store authentication token in drupal variable
-
-
-        }
-    elseif($response_code=='403')
-        {
-   
-        drupal_set_message('Unable to fetch Token . Please Re-check the credentials','error');
-
-        drupalgapp_failure_warning($admin_api_email);
-
-        }
-
-    /*
-     * CURL options and thier purpose :
-     *
-     * CURLOPT_SSL_VERIFYPEER  : FALSE to stop cURL from verifying the peer's certificate.
-     * CURLOPT_SSL_VERIFYHOST  : 2 to check the existence of a common name and also verify that it matches the hostname provided. 1 to check the existence of a common name in the SSL peer certificate.
-     * CURLOPT_HTTPPROXYTUNNEL : TRUE to tunnel through a given HTTP proxy.
-     * CURLOPT_PROXY           : The HTTP proxy to tunnel requests through.
-     */
-
-
-$gaccount='betatest';
-$firstname='beta';
-$lastname='test';
-$password='moonshine';
-
-$username = 'ankur.saxena';
-
-
-
-
-    
+  $gaccount = 'betatest';
+  $firstname = 'beta';
+  $lastname = 'test';
+  $password = 'moonshine';
+  $username = 'ankur.saxena';
 }
 
-/*
- * Implimentation of hook_menu
+/**
+ * Implementation of hook_menu().
  */
-
 function drupalgapps_menu() {
-
   $items = array();
 
-$items['admin/settings/drupalgapps'] = array(
-   'title' => t('DrupalGapps module settings'),
+  $items['admin/settings/drupalgapps'] = array(
+    'title' => t('DrupalGapps module settings'),
     'description' => t('Description of your DrupalGapps settings page'),
     'page callback' => 'drupalgapps_page',
     //'page arguments' => array('drupalgapps_admin'),
     'access arguments' => array('administer drupalgapps'),
     'type' => MENU_NORMAL_ITEM,
-   );
+  );
 
   return $items;
 }
 
-/*
- * implimentation of Hook_perm
- *
+/**
+ * Implementation of hook_perm().
  */
-function drupalgapps_perm(){
-
-    return array('administer drupalgapps');
+function drupalgapps_perm() {
+  return array('administer drupalgapps');
 }
 
 
 /*
  * Implementation of hook_cron()
  *
- * After the time interval set by default ( 23 hrs) or administrator, it fetches the authentication token for provisioning API
- *
+ * After the time interval set by default ( 23 hrs) or administrator, it fetches
+ * the authentication token for provisioning API
  */
-
-function drupalgapps_cron(){
-
-    //Fectch auth token
-
-    watchdog('Google Apps','Cron run to fetch auth token.', array(), WATCHDOG_NOTICE);
-
-    drupalgapps_get_authtoken();
-
+function drupalgapps_cron() {
+  // Fetch auth token
+  watchdog('Google Apps', 'Cron run to fetch auth token.', array(), WATCHDOG_NOTICE);
+  drupalgapps_get_authtoken();
 }
 
-/* 
- * Using  elysia cron module's API, Scheduling the renewal of authentication token 
- *   
+/**
+ * Using  elysia cron module's API, Scheduling the renewal of authentication
+ * token.
  */
-
 function module_cronapi($op, $job = NULL) {
   switch ($op) {
     case 'list':
       return array(
-        'drupalgapps_cron' => 'Google apps authentication token renewal taks',
+        'drupalgapps_cron' => 'Google apps authentication token renewal tasks',
       );
     case 'rule':
-      return '* */'.variable_get('gapps_token_renewal_rate', 23).' * * *';
-   }
+      return '* */' . variable_get('gapps_token_renewal_rate', 23) . ' * * *';
+  }
 }
 
 
-/*
- *
- * Implementation hook_quiz_finished()
- * performs actions like sending quiz results over email at the end of quiz.
- */
-
 function drupalgapp_failure_warning($admin_api_email) {
   global $user;
 
+  if (!variable_get('clean_url', '0')) {
+    $gapps_admin_path = '/?q=admin/settings/drupalgapps';
+  }
+  else {
+    $gapps_admin_path = '/admin/settings/drupalgapps';
+  }
 
-if(variable_get('clean_url','0')==0)
-$gapps_admin_path='/?q=admin/settings/drupalgapps';
-else
-$gapps_admin_path='/admin/settings/drupalgapps';
 
-
-  //function to send results over email
-$params['subject'] = t('[@site_name] @severity_desc: Alert from your web site', array(
-      '@site_name' => variable_get('site_name', 'Drupal'),
-      '@severity_desc' =>t('Critical'),
+  // Function to send results over email.
+  $params['subject'] = t('[@site_name] @severity_desc: Alert from your web site', array(
+    '@site_name' => variable_get('site_name', 'Drupal'),
+    '@severity_desc' => t('Critical'),
   ));
 
   $params['message']  = "\nSite:         @base_url";
@@ -486,73 +400,55 @@
     '@name'          => 'Administrator',
     '@link'          => $GLOBALS['base_url'].$gapps_admin_path,
     '@message'       => 'DrupalGapps module is unable to fetch authentication token for provisioning API. Hence all CRUD action on Google apps user accounts ( Google apps user management) has been halted. Probable reason could be : ',
-    '@reason1'       => '1. The admin account credentials being used to fecth Auth. token havent changed .',
+    '@reason1'       => '1. The admin account credentials being used to fetch Auth. token havent changed .',
     '@reason2'       => '2. There is a problem in Internet connection on your webserver.',
   ));
 
 
+  if (variable_get('gapps_failure_email', NULL) != NULL) {
+    drupal_mail('drupalgapps', 'warning', variable_get('gapps_failure_email', variable_get('site_mail', NULL)), user_preferred_language($account), $params, NULL, TRUE);
+  }
+  else {
+    drupal_mail('drupalgapps', 'warning', $admin_api_email, user_preferred_language($account), $params, NULL, TRUE);
+  }
 
-   if(variable_get('gapps_failure_email',NULL)!=NULL)
-    {
-       drupal_mail('drupalgapps', 'warning', variable_get('gapps_failure_email', variable_get('site_mail',NULL)),user_preferred_language($account), $params,NULL,TRUE);
-    }
-   else
-    {
-        drupal_mail('drupalgapps', 'warning', $admin_api_email, user_preferred_language($account), $params,NULL,TRUE);
-    }
+  watchdog('Google Apps', 'Critical : unable to fetch Authentication token from Google . Google Apps User account managament is halted . Most probably Problem arised because of the Admin creditential. Check them. ', array(), WATCHDOG_CRITICAL, l(t('DrupalGapps Settings'), 'admin/settings/drupalgapps'));
 
-  watchdog('Google Apps','Critical : unable to fetch Authentication token from Google . Google Apps User account managament is halted . Most probably Problem arised because of the Admin creditential. Check them. ', array(), WATCHDOG_CRITICAL, l(t('DrupalGapps Settings'), 'admin/settings/drupalgapps'));
-   
-  
 }
 
 
-/*
- *
- * Implementation of hook_mail
- * sends quiz result to user email
+/**
+ * Implementation of hook_mail().
  */
-
 function drupalgapps_mail($key, &$message, $params) {
   global $user;
- 
+
   switch ($key) {
     case 'warning':
       $message['subject'] = $params['subject'];
       $message['body'] = $params['message'];
-      
-    break;
+      break;
   }
 }
 
 
-/*
- * Google Apps API : wrapper of provisioning API
- *
- *
+/**
+ * Google Apps API : wrapper of provisioning API.
  */
+function drupalgapps_make_gaccount($gaccount, $firstname, $lastname, $password, $quota = '', $changePassword = TRUE, $suspended = FALSE, $admin = FALSE) {
+  $auth = variable_get('gapps_prov_api_auth_token', NULL);
+  $proxy_add = variable_get('gapps_proxy', NULL);
+  if ($proxy_add) {
+    $proxy_exist = 1;
+  }
+  else {
+    $proxy_exist = 0;
+  }
 
-function drupalgapps_make_gaccount($gaccount,$firstname,$lastname,$password, $quota="",$changePassword=TRUE,$suspended=FALSE, $admin=FALSE)
-{
+  drupal_set_message($proxy_add);
 
-     $auth=variable_get('gapps_prov_api_auth_token',NULL);    $proxy_add = variable_get('gapps_proxy',NULL);
 
-    
-     
-     
-
-     if($proxy_add){
-         $proxy_exist=1;
-     }
-     else
-     {
-         $proxy_exist=0;
-     }
-
-     drupal_set_message($proxy_add);
-
-
-$data = <<<XML
+  $data = <<<XML
 <?xml version="1.0" encoding="UTF-8"?>
 <atom:entry xmlns:atom="http://www.w3.org/2005/Atom"
 xmlns:apps="http://schemas.google.com/apps/2006">
@@ -567,73 +463,68 @@
 
  // $header="Authorization: GoogleLogin auth=DQAAAH4AAACdyei2Q271TJ-66IpnQijWT9MYhiGsmg3L2wGDVY6piy1Ca4WXd0jm_XGbbgAQcpzwbRohR-UecAbN1Dog2O3KOTNDgstBxR-eSAz5-ze4oQtS4h5JAMXpw_-T2P5R29LpWafbJaPkyAoqdg12F5nqRpapo_bUEiIV9tFxbzJhxA ";
   //drupal_set_message($auth);
-  $header="Authorization: GoogleLogin auth=".$auth." ";
-drupal_set_message($header);
-  $header=$header."\nContent-type: application/atom+xml";
-  $header=$header."\nContent-Length :".strlen($data);
+  $header = 'Authorization: GoogleLogin auth=' . $auth . ' ';
+  drupal_set_message($header);
+  $header = $header . "\nContent-type: application/atom+xml";
+  $header = $header . "\nContent-Length :" . strlen($data);
+
   $ch = curl_init();
-  curl_setopt($ch, CURLOPT_URL,'https://apps-apis.google.com/a/feeds/jiitu.org/user/2.0');
-  curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
+  curl_setopt($ch, CURLOPT_URL, 'https://apps-apis.google.com/a/feeds/jiitu.org/user/2.0');
+  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
   curl_setopt($ch, CURLOPT_HTTPHEADER, array($header));
   curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
-  curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL,$proxy_exist);
+  curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, $proxy_exist);
   curl_setopt($ch, CURLOPT_PROXY, $proxy_add);
   curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
   curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,  2);
   $result = curl_exec($ch);
-  $code= curl_getinfo($ch, CURLINFO_HTTP_CODE);
+  $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
 
+  if ($code) {
+    switch ($code) {
+      case 200:
+      case 201:
+      case 202:
+        drupal_set_message('Account Created');
+        break;
+      case 400:
+        drupal_set_message('Error 400');
+        break;
+      case 415:
+        drupal_set_message('Error 415');
+        break;
 
-
-      if ($code) {
-
-        switch ($code) {
-          case 200:
-          case 201:
-          case 202:
-            drupal_set_message('Account Created');
-            break;
-          case 400:
-              drupal_set_message('Error 400');
-              break;
-         case 415:
-              drupal_set_message('Error 415');
-              break;
-
-          default;
-            watchdog('drupalgapps', t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), WATCHDOG_WARNING);
-            drupal_set_message(t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), 'error');
-            return FALSE;
-        }
-      }
-      else {
-        watchdog('drupalgapps', t('The HTTPS request to Google seems to be broken like hell  (unknown error).'), WATCHDOG_WARNING);
-        drupal_set_message(t('The HTTPS request to Google seems to be broken like hell (unknown error).'), 'error');
+      default;
+        watchdog('drupalgapps', t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), WATCHDOG_WARNING);
+        drupal_set_message(t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), 'error');
         return FALSE;
-      }
+    }
+  }
+  else {
+    watchdog('drupalgapps', t('The HTTPS request to Google seems to be broken like hell  (unknown error).'), WATCHDOG_WARNING);
+    drupal_set_message(t('The HTTPS request to Google seems to be broken like hell (unknown error).'), 'error');
+    return FALSE;
+  }
 
-    watchdog('Google Apps','response code : '.$code, array(), WATCHDOG_CRITICAL, l(t('DrupalGapps Settings'), 'admin/settings/drupalgapps'));
-
+  watchdog('Google Apps', 'response code : '.$code, array(), WATCHDOG_CRITICAL, l(t('DrupalGapps Settings'), 'admin/settings/drupalgapps'));
 }
 
 
 
-//TODO : Refactoring : rather then having so much arguments , just pass $gaccount as an array. with fname, lastname, password and key and value
+// @TODO : Refactoring : rather then having so much arguments , just pass $gaccount as an array. with fname, lastname, password and key and value
 
-//TODO : Refactoring : Modularize the CURL calls by implimenting a function
+// @TODO : Refactoring : Modularize the CURL calls by implimenting a function
 
-//TODO : Refactoring : picking up XML files should be modularised
+// @TODO : Refactoring : picking up XML files should be modularised
 
 
 /*
 
-function drupalgapps_task_gaccount($parameters)
-{
+function drupalgapps_task_gaccount($parameters) {
+  $auth = variable_get('gapps_prov_api_auth_token', '');
+  $proxy_add = variable_get('gapps_proxy', '');
 
-
- $auth=variable_get('gapps_prov_api_auth_token','');    $proxy_add = variable_get('gapps_proxy','');
-
-$post_data = '
+  $post_data = '
     <atom:entry xmlns:atom="http://www.w3.org/2005/Atom"
       xmlns:apps="http://schemas.google.com/apps/2006">
         <atom:category scheme="http://schemas.google.com/g/2005#kind"
@@ -647,23 +538,19 @@
     </atom:entry>
   ';
 
-//Some more XML
+  //Some more XML
 
-
-     $httpresult = drupal_http_request('https://apps-apis.google.com/a/feeds/jiitu.org/user/2.0',
+   $httpresult = drupal_http_request('https://apps-apis.google.com/a/feeds/jiitu.org/user/2.0',
                                 array(  'Authorization' => "GoogleLogin auth=".$auth,
                                         'Content-Type' => "application/atom+xml"),
    add                             'POST',
                                 $post_data);
 
 
-drupal_set_message($httpresult);
+  drupal_set_message($httpresult);
+  drupal_set_message($httpresult->code);
 
-drupal_set_message($httpresult->code);
-
-
   if (is_object($httpresult)) {
-
     switch ($httpresult->code) {
       case 200:
       case 201:
@@ -673,7 +560,7 @@
       case 400:
           drupal_set_message('Error 400');
           break;
-     case 415:
+      case 415:
           drupal_set_message('Error 415');
           break;
 
@@ -689,213 +576,186 @@
     return FALSE;
   }
 
-watchdog('Google Apps','response code : '.$response_code, array(), WATCHDOG_CRITICAL, l(t('DrupalGapps Settings'), 'admin/settings/drupalgapps'));
-
-
-
+  watchdog('Google Apps', 'response code : '.$response_code, array(), WATCHDOG_CRITICAL, l(t('DrupalGapps Settings'), 'admin/settings/drupalgapps'));
 }
 
-
 */
 
 
-//Retrieving a User Account
+/**
+ * Retrieve a user account.
+ */
+function drupalgapps_retrieve_gaccount($username) {
+  drupal_set_message($username);
 
-function drupalgapps_retrieve_gaccount($username)
-{
+  $auth = variable_get('gapps_prov_api_auth_token', '');
+  $proxy_add = variable_get('gapps_proxy', '');
 
-    drupal_set_message($username);
+  if ($proxy_add) {
+    $proxy_exist = 1;
+  }
+  else {
+    $proxy_exist = 0;
+  }
 
-      $auth=variable_get('gapps_prov_api_auth_token','');
-   $proxy_add = variable_get('gapps_proxy','');
+  drupal_set_message($proxy_add);
+  $url = 'https://apps-apis.google.com/a/feeds/jiitu.org/user/2.0/' . $username;
+  drupal_set_message($auth);
+  $header = "Authorization: GoogleLogin auth=".$auth." ";
+  drupal_set_message($header);
 
-   if($proxy_add){
-         $proxy_exist=1;
-     }
-     else
-     {
-         $proxy_exist=0;
-     }
-
-drupal_set_message($proxy_add);
-    $url = 'https://apps-apis.google.com/a/feeds/jiitu.org/user/2.0/'.$username;
-
-    drupal_set_message($auth);
-
-  $header="Authorization: GoogleLogin auth=".$auth." ";
-drupal_set_message($header);
-
   $ch = curl_init();
-  curl_setopt($ch, CURLOPT_URL,$url);
-  curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
-  curl_setopt($ch, CURLOPT_HTTPGET,TRUE);
+  curl_setopt($ch, CURLOPT_URL, $url);
+  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+  curl_setopt($ch, CURLOPT_HTTPGET, TRUE);
   curl_setopt($ch, CURLOPT_HTTPHEADER, array($header));
   curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, $proxy_exist);
   curl_setopt($ch, CURLOPT_PROXY, $proxy_add);
   curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
   curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,  2);
 
-$result = curl_exec($ch);
+  $result = curl_exec($ch);
+  $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
 
-  $code= curl_getinfo($ch, CURLINFO_HTTP_CODE);
+  drupal_set_message($result);
+  $result = urlencode($result);
+  drupal_set_message($result);
 
-drupal_set_message($result);
-$result = urlencode($result);
-drupal_set_message($result);
+  if ($code) {
+    switch ($code) {
+      case 200:
+      case 201:
+      case 202:
+        drupal_set_message('Account Retrieved');
+        break;
+      case 400:
+        drupal_set_message('Error 400');
+        break;
+      case 415:
+        drupal_set_message('Error 415');
+        break;
 
-
-
-      if ($code) {
-
-        switch ($code) {
-          case 200:
-          case 201:
-          case 202:
-            drupal_set_message('Account Retrieved');
-            break;
-          case 400:
-              drupal_set_message('Error 400');
-              break;
-         case 415:
-              drupal_set_message('Error 415');
-              break;
-
-          default;
-            watchdog('drupalgapps', t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), WATCHDOG_WARNING);
-            drupal_set_message(t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), 'error');
-            return FALSE;
-        }
-      }
-      else {
-        watchdog('drupalgapps', t('The HTTPS request to Google seems to be broken like hell  (unknown error).'), WATCHDOG_WARNING);
-        drupal_set_message(t('The HTTPS request to Google seems to be broken like hell (unknown error).'), 'error');
+      default;
+        watchdog('drupalgapps', t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), WATCHDOG_WARNING);
+        drupal_set_message(t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), 'error');
         return FALSE;
-      }
+    }
+  }
+  else {
+    watchdog('drupalgapps', t('The HTTPS request to Google seems to be broken like hell  (unknown error).'), WATCHDOG_WARNING);
+    drupal_set_message(t('The HTTPS request to Google seems to be broken like hell (unknown error).'), 'error');
+    return FALSE;
+  }
 
-    watchdog('Google Apps','response code : '.$code, array(), WATCHDOG_CRITICAL, l(t('DrupalGapps Settings'), 'admin/settings/drupalgapps'));
+  watchdog('Google Apps', 'response code : '.$code, array(), WATCHDOG_CRITICAL, l(t('DrupalGapps Settings'), 'admin/settings/drupalgapps'));
 
-
-
-
-return ;
+  return;
 }
 
 
-//Updating a User Account
+/**
+ * Update a user account.
+ */
+function drupalgapps_update_gaccount($gaccount, $firstname = NULL, $lastname = NULL, $password = NULL, $changePassword = NULL, $quota = NULL, $suspended = NULL, $admin = NULL) {
 
-function drupalgapps_update_gaccount($gaccount,$firstname=NULL, $lastname=NULL, $password=NULL, $changePassword=NULL, $quota=NULL, $suspended=NULL, $admin=NULL)
-{
+  $auth = variable_get('gapps_prov_api_auth_token', '');    $proxy_add = variable_get('gapps_proxy', '');
 
-     $auth=variable_get('gapps_prov_api_auth_token','');    $proxy_add = variable_get('gapps_proxy','');
+  if ($proxy_add) {
+    $proxy_exist = 1;
+  }
+  else {
+    $proxy_exist = 0;
+  }
 
-if($proxy_add){
-         $proxy_exist=1;
-     }
-     else
-     {
-         $proxy_exist=0;
-     }
-
-    $data = '
-        <atom:entry xmlns:atom="http://www.w3.org/2005/Atom"
+  $data = '<atom:entry xmlns:atom="http://www.w3.org/2005/Atom"
           xmlns:apps="http://schemas.google.com/apps/2006">
             <atom:category scheme="http://schemas.google.com/g/2005#kind"
                 term="http://schemas.google.com/apps/2006#user"/>
       ';
-      if (  ($password) || ($suspended !== NULL) || ($changePassword !== NULL)) {
-        $post_data .= '<apps:login'.
-          ($password?' password="'.$password.'" ':'').
-          (($suspended !== NULL)?'suspended="'.($suspended?'true':'false').'" ':'').
-          (($changePassword !== NULL)?'changePasswordAtNextLogin="'.($changePassword?'true':'false').'" ':'').
-          '/>';
-      }
-      if ($quota) {
-        $post_data .= '<apps:quota limit="'.$quota.'"/>';
-      }
-      if ($firstname || $lastname) {
-        $post_data .= '<apps:name'.
-          ($lastname?' familyName="'.$lastname.'"':'').
-          ($firstname?' givenName="'.$firstname.'"':'').
-          '/>';
-      }
-      $data .= '
-        </atom:entry>
-      ';
+  if (($password) || ($suspended !== NULL) || ($changePassword !== NULL)) {
+    $post_data .= '<apps:login' .
+      ($password ? ' password="' . $password . '" ' : '') .
+      (($suspended !== NULL) ? 'suspended="' . ($suspended ? 'true' : 'false') . '" ' : '') .
+      (($changePassword !== NULL) ? 'changePasswordAtNextLogin="' . ($changePassword ? 'true' : 'false') . '" ' : '') .
+      '/>';
+  }
+  if ($quota) {
+    $post_data .= '<apps:quota limit="' . $quota . '"/>';
+  }
+  if ($firstname || $lastname) {
+    $post_data .= '<apps:name' .
+      ($lastname ? ' familyName="' . $lastname . '"' : '') .
+      ($firstname ? ' givenName="' . $firstname . '"' : '') .
+      '/>';
+  }
+  $data .= '</atom:entry>';
 
+  $auth = variable_get('gapps_prov_api_auth_token', '');
+  $proxy_add = variable_get('gapps_proxy', '');
 
-     $auth=variable_get('gapps_prov_api_auth_token','');    $proxy_add = variable_get('gapps_proxy','');
+  $url = 'https://apps-apis.google.com/a/feeds/jiitu.org/user/2.0/' . $username;
 
+  $header = "Authorization: GoogleLogin auth=" . $auth;
+  $header = $header . "\nContent-type: application/atom+xml";
+  $header = $header . "\nContent-Length :" . strlen($data);
 
-    $url = 'https://apps-apis.google.com/a/feeds/jiitu.org/user/2.0/'.$username;
-
-$header="Authorization: GoogleLogin auth=".$auth;
-$header=$header."\nContent-type: application/atom+xml";
-$header=$header."\nContent-Length :".strlen($data);
-
-$ch = curl_init();
-  curl_setopt($ch, CURLOPT_URL,$url);
-  curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
+  $ch = curl_init();
+  curl_setopt($ch, CURLOPT_URL, $url);
+  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
   curl_setopt($ch, CURLOPT_HTTPHEADER, array($header));
   curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
-  curl_setopt($ch, CURLOPT_PUT,TRUE);
+  curl_setopt($ch, CURLOPT_PUT, TRUE);
   curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, $proxy_exist);
   curl_setopt($ch, CURLOPT_PROXY, $proxy_add);
   curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
   curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,  2);
   $result = curl_exec($ch);
-  $code= curl_getinfo($ch, CURLINFO_HTTP_CODE);
+  $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
 
-
-
-      if ($code) {
-
-        switch ($code) {
-          case 200:
-          case 201:
-          case 202:
-            drupal_set_message('Account Created');
-            break;
-          case 400:
-              drupal_set_message('Error 400');
-              break;
-         case 415:
-              drupal_set_message('Error 415');
-              break;
-
-          default;
-            watchdog('drupalgapps', t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), WATCHDOG_WARNING);
-            drupal_set_message(t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), 'error');
-            return FALSE;
-        }
-      }
-      else {
-        watchdog('drupalgapps', t('The HTTPS request to Google seems to be broken like hell  (unknown error).'), WATCHDOG_WARNING);
-        drupal_set_message(t('The HTTPS request to Google seems to be broken like hell (unknown error).'), 'error');
+  if ($code) {
+    switch ($code) {
+      case 200:
+      case 201:
+      case 202:
+        drupal_set_message('Account Created');
+        break;
+      case 400:
+        drupal_set_message('Error 400');
+        break;
+      case 415:
+        drupal_set_message('Error 415');
+        break;
+      default;
+        watchdog('drupalgapps', t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), WATCHDOG_WARNING);
+        drupal_set_message(t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), 'error');
         return FALSE;
-      }
+    }
+  }
+  else {
+    watchdog('drupalgapps', t('The HTTPS request to Google seems to be broken like hell  (unknown error).'), WATCHDOG_WARNING);
+    drupal_set_message(t('The HTTPS request to Google seems to be broken like hell (unknown error).'), 'error');
+    return FALSE;
+  }
 
-    watchdog('Google Apps','response code : '.$code, array(), WATCHDOG_CRITICAL, l(t('DrupalGapps Settings'), 'admin/settings/drupalgapps'));
-
-
-
+  watchdog('Google Apps', 'response code : ' . $code, array(), WATCHDOG_CRITICAL, l(t('DrupalGapps Settings'), 'admin/settings/drupalgapps'));
 }
 
-function drupalgapps_rename_gaccount($oldname,$newname)
-{
+/**
+ * Rename a Google user account.
+ */
+function drupalgapps_rename_gaccount($oldname, $newname) {
+  $auth = variable_get('gapps_prov_api_auth_token', '');
+  $proxy_add = variable_get('gapps_proxy', '');
 
+  if ($proxy_add) {
+    $proxy_exist = 1;
+  }
+  else {
+    $proxy_exist = 0;
+  }
 
-     $auth=variable_get('gapps_prov_api_auth_token','');    $proxy_add = variable_get('gapps_proxy','');
 
-if($proxy_add){
-         $proxy_exist=1;
-     }
-     else
-     {
-         $proxy_exist=0;
-     }
-
-
-    $data =<<<XML
+  $data =<<<XML
         <?xml version="1.0" encoding="UTF-8"?>
     <atom:entry xmlns:atom="http://www.w3.org/2005/Atom"
      xmlns:apps="http://schemas.google.com/apps/2006"
@@ -913,154 +773,132 @@
     </atom:entry>
 XML;
 
-  
 
-     $auth=variable_get('gapps_prov_api_auth_token','');    $proxy_add = variable_get('gapps_proxy','');
 
+  $auth = variable_get('gapps_prov_api_auth_token', '');
+  $proxy_add = variable_get('gapps_proxy', '');
+  $url = 'https://apps-apis.google.com/a/feeds/jiitu.org/user/2.0/' . $username;
 
-    $url = 'https://apps-apis.google.com/a/feeds/jiitu.org/user/2.0/'.$username;
+  $header = "Authorization: GoogleLogin auth=" . $auth;
+  $header = $header . "\nContent-type: application/atom+xml";
+  $header = $header . "\nContent-Length :" . strlen($data);
 
-$header="Authorization: GoogleLogin auth=".$auth;
-$header=$header."\nContent-type: application/atom+xml";
-$header=$header."\nContent-Length :".strlen($data);
-
-$ch = curl_init();
-  curl_setopt($ch, CURLOPT_URL,$url);
-  curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
+  $ch = curl_init();
+  curl_setopt($ch, CURLOPT_URL, $url);
+  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
   curl_setopt($ch, CURLOPT_HTTPHEADER, array($header));
   curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
-  curl_setopt($ch, CURLOPT_PUT,TRUE);
+  curl_setopt($ch, CURLOPT_PUT, TRUE);
   curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, $proxy_exist);
   curl_setopt($ch, CURLOPT_PROXY, $proxy_add);
   curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
   curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,  2);
   $result = curl_exec($ch);
-  $code= curl_getinfo($ch, CURLINFO_HTTP_CODE);
+  $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
 
-
-
-      if ($code) {
-
-        switch ($code) {
-          case 200:
-          case 201:
-          case 202:
-            drupal_set_message('User renaming successful');
-            break;
-          case 400:
-              drupal_set_message('Error 400');
-              break;
-         case 415:
-              drupal_set_message('Error 415');
-              break;
-
-          default;
-            watchdog('Google Apps', t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), WATCHDOG_WARNING);
-            drupal_set_message(t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), 'error');
-            return FALSE;
-        }
-      }
-      else {
-        watchdog('Google Apps', t('The HTTPS request to Google seems to be broken like hell  (unknown error).'), WATCHDOG_WARNING);
-        drupal_set_message(t('The HTTPS request to Google seems to be broken like hell (unknown error).'), 'error');
+  if ($code) {
+    switch ($code) {
+      case 200:
+      case 201:
+      case 202:
+        drupal_set_message('User renaming successful');
+        break;
+      case 400:
+        drupal_set_message('Error 400');
+        break;
+      case 415:
+        drupal_set_message('Error 415');
+        break;
+      default;
+        watchdog('Google Apps', t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), WATCHDOG_WARNING);
+        drupal_set_message(t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), 'error');
         return FALSE;
-      }
+    }
+  }
+  else {
+    watchdog('Google Apps', t('The HTTPS request to Google seems to be broken like hell  (unknown error).'), WATCHDOG_WARNING);
+    drupal_set_message(t('The HTTPS request to Google seems to be broken like hell (unknown error).'), 'error');
+    return FALSE;
+  }
 
-
-    watchdog('Google Apps','response code : '.$code, array(), WATCHDOG_CRITICAL, l(t('DrupalGapps Settings'), 'admin/settings/drupalgapps'));
-
-
-
+  watchdog('Google Apps', 'response code : ' . $code, array(), WATCHDOG_CRITICAL, l(t('DrupalGapps Settings'), 'admin/settings/drupalgapps'));
 }
 
 
+/**
+ * Delete a Google user account.
+ */
+function drupalgapps_delete_gaccount($username) {
+  $auth = variable_get('gapps_prov_api_auth_token', '');
+  $proxy_add = variable_get('gapps_proxy', '');
 
-function drupalgapps_delete_gaccount($username)
-{
+  if ($proxy_add) {
+    $proxy_exist = 1;
+  }
+  else {
+    $proxy_exist = 0;
+  }
 
+  $url = 'https://apps-apis.google.com/a/feeds/jiitu.org/user/2.0/' . $username;
+  $header = "Authorization: GoogleLogin auth=" . $auth;
 
-     $auth=variable_get('gapps_prov_api_auth_token','');    $proxy_add = variable_get('gapps_proxy','');
-
-
-if($proxy_add){
-         $proxy_exist=1;
-     }
-     else
-     {
-         $proxy_exist=0;
-     }
-
-    $url = 'https://apps-apis.google.com/a/feeds/jiitu.org/user/2.0/'.$username;
-
-$header="Authorization: GoogleLogin auth=".$auth;
-
-
-$ch = curl_init();
-  curl_setopt($ch, CURLOPT_URL,$url);
-  curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
+  $ch = curl_init();
+  curl_setopt($ch, CURLOPT_URL, $url);
+  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
   curl_setopt($ch, CURLOPT_HTTPHEADER, array($header));
   curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
-  curl_setopt($ch, CURLOPT_CUSTOMREQUEST,'DELETE');
+  curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
   curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, $proxy_exist);
   curl_setopt($ch, CURLOPT_PROXY, $proxy_add);
   curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
   curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,  2);
   $result = curl_exec($ch);
-  $code= curl_getinfo($ch, CURLINFO_HTTP_CODE);
+  $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
 
-
-
-      if ($code) {
-
-        switch ($code) {
-          case 200:
-          case 201:
-          case 202:
-            drupal_set_message('User Deleted successful');
-            break;
-          case 400:
-              drupal_set_message('Error 400');
-              break;
-         case 415:
-              drupal_set_message('Error 415');
-              break;
-
-          default;
-            watchdog('Google Apps', t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), WATCHDOG_WARNING);
-            drupal_set_message(t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), 'error');
-            return FALSE;
-        }
-      }
-      else {
-        watchdog('Google Apps', t('The HTTPS request to Google seems to be broken like hell  (unknown error).'), WATCHDOG_WARNING);
-        drupal_set_message(t('The HTTPS request to Google seems to be broken like hell (unknown error).'), 'error');
+  if ($code) {
+    switch ($code) {
+      case 200:
+      case 201:
+      case 202:
+        drupal_set_message('User Deleted successful');
+        break;
+      case 400:
+        drupal_set_message('Error 400');
+        break;
+      case 415:
+        drupal_set_message('Error 415');
+        break;
+      default;
+        watchdog('Google Apps', t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), WATCHDOG_WARNING);
+        drupal_set_message(t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), 'error');
         return FALSE;
-      }
+    }
+  }
+  else {
+    watchdog('Google Apps', t('The HTTPS request to Google seems to be broken like hell  (unknown error).'), WATCHDOG_WARNING);
+    drupal_set_message(t('The HTTPS request to Google seems to be broken like hell (unknown error).'), 'error');
+    return FALSE;
+  }
 
+  watchdog('Google Apps', 'response code : ' . $code, array(), WATCHDOG_CRITICAL, l(t('DrupalGapps Settings'), 'admin/settings/drupalgapps'));
 
-    watchdog('Google Apps','response code : '.$code, array(), WATCHDOG_CRITICAL, l(t('DrupalGapps Settings'), 'admin/settings/drupalgapps'));
-
-
 }
 
-//Creating a Nickname
+/**
+ * Create a Google nickname.
+ */
+function drupalgapps_create_nickname($gaccount, $nickname) {
+  $auth = variable_get('gapps_prov_api_auth_token', '');    $proxy_add = variable_get('gapps_proxy', '');
 
-function drupalgapps_create_nickname($gaccount,$nickname)
-{
+  if ($proxy_add) {
+    $proxy_exist = 1;
+  }
+  else {
+    $proxy_exist = 0;
+  }
 
 
-     $auth=variable_get('gapps_prov_api_auth_token','');    $proxy_add = variable_get('gapps_proxy','');
-
-if($proxy_add){
-         $proxy_exist=1;
-     }
-     else
-     {
-         $proxy_exist=0;
-     }
-
-
-     $data=<<<XML
+  $data=<<<XML
         <atom:entry xmlns:atom="http://www.w3.org/2005/Atom"
           xmlns:apps="http://schemas.google.com/apps/2006">
             <atom:category scheme="http://schemas.google.com/g/2005#kind"
@@ -1071,12 +909,12 @@
 XML;
 
 
- $header="Authorization: GoogleLogin auth=".$auth;
-  $header=$header."\nContent-type: application/atom+xml";
-  $header=$header."\nContent-Length :".strlen($data);
+  $header = "Authorization: GoogleLogin auth=" . $auth;
+  $header = $header . "\nContent-type: application/atom+xml";
+  $header = $header . "\nContent-Length :" . strlen($data);
   $ch = curl_init();
-  curl_setopt($ch, CURLOPT_URL,'https://apps-apis.google.com/a/feeds/domain/nickname/2.0');
-  curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
+  curl_setopt($ch, CURLOPT_URL, 'https://apps-apis.google.com/a/feeds/domain/nickname/2.0');
+  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
   curl_setopt($ch, CURLOPT_HTTPHEADER, array($header));
   curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
   curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, $proxy_exist);
@@ -1084,208 +922,173 @@
   curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
   curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,  2);
   $result = curl_exec($ch);
-  $code= curl_getinfo($ch, CURLINFO_HTTP_CODE);
+  $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
 
+  if ($code) {
+    switch ($code) {
+      case 200:
+      case 201:
+      case 202:
+        drupal_set_message('Nickname Created');
+        break;
+      case 400:
+        drupal_set_message('Error 400');
+        break;
+      case 415:
+        drupal_set_message('Error 415');
+        break;
 
-
-      if ($code) {
-
-        switch ($code) {
-          case 200:
-          case 201:
-          case 202:
-            drupal_set_message('Nickname Created');
-            break;
-          case 400:
-              drupal_set_message('Error 400');
-              break;
-         case 415:
-              drupal_set_message('Error 415');
-              break;
-
-          default;
-            watchdog('drupalgapps', t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), WATCHDOG_WARNING);
-            drupal_set_message(t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), 'error');
-            return FALSE;
-        }
-      }
-      else {
-        watchdog('drupalgapps', t('The HTTPS request to Google seems to be broken like hell  (unknown error).'), WATCHDOG_WARNING);
-        drupal_set_message(t('The HTTPS request to Google seems to be broken like hell (unknown error).'), 'error');
+      default;
+        watchdog('drupalgapps', t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), WATCHDOG_WARNING);
+        drupal_set_message(t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), 'error');
         return FALSE;
-      }
+    }
+  }
+  else {
+    watchdog('drupalgapps', t('The HTTPS request to Google seems to be broken like hell  (unknown error).'), WATCHDOG_WARNING);
+    drupal_set_message(t('The HTTPS request to Google seems to be broken like hell (unknown error).'), 'error');
+    return FALSE;
+  }
 
-    watchdog('Google Apps','response code : '.$code, array(), WATCHDOG_CRITICAL, l(t('DrupalGapps Settings'), 'admin/settings/drupalgapps'));
-
-
-
+  watchdog('Google Apps', 'response code : ' . $code, array(), WATCHDOG_CRITICAL, l(t('DrupalGapps Settings'), 'admin/settings/drupalgapps'));
 }
 
-//Retrieving a Nickname
+/**
+ * Retrieve a Google nickname.
+ */
+function drupalgapps_retrieve_nickname($username) {
+  $auth = variable_get('gapps_prov_api_auth_token', '');
+  $proxy_add = variable_get('gapps_proxy', '');
 
-function drupalgapps_retrieve_nickname($username)
-{
+  if ($proxy_add) {
+    $proxy_exist = 1;
+  }
+  else {
+    $proxy_exist = 0;
+  }
 
-    
 
-     $auth=variable_get('gapps_prov_api_auth_token','');    $proxy_add = variable_get('gapps_proxy','');
+  $url = 'https://apps-apis.google.com/a/feeds/jiitu.org/user/2.0/' . $username;
+  $header = "Authorization: GoogleLogin auth=" . $auth;
 
-if($proxy_add){
-         $proxy_exist=1;
-     }
-     else
-     {
-         $proxy_exist=0;
-     }
-
-
-    $url = 'https://apps-apis.google.com/a/feeds/jiitu.org/user/2.0/'.$username;
-
-    $header="Authorization: GoogleLogin auth=".$auth;
-
-
   $ch = curl_init();
-  curl_setopt($ch, CURLOPT_URL,$url);
-  curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
-  curl_setopt($ch, CURLOPT_HTTPGET,TRUE);
+  curl_setopt($ch, CURLOPT_URL, $url);
+  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+  curl_setopt($ch, CURLOPT_HTTPGET, TRUE);
   curl_setopt($ch, CURLOPT_HTTPHEADER, array($header));
   curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, $proxy_exist);
   curl_setopt($ch, CURLOPT_PROXY, $proxy_add);
   curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
   curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,  2);
+  $result = curl_exec($ch);
+  $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
 
-$result = curl_exec($ch);
+  if ($code) {
+    switch ($code) {
+      case 200:
+      case 201:
+      case 202:
+        drupal_set_message('Nickname Retrieved');
+        break;
+      case 400:
+        drupal_set_message('Error 400');
+        break;
+      case 415:
+        drupal_set_message('Error 415');
+        break;
 
-  $code= curl_getinfo($ch, CURLINFO_HTTP_CODE);
-
-
-
-
-
-      if ($code) {
-
-        switch ($code) {
-          case 200:
-          case 201:
-          case 202:
-            drupal_set_message('Nickname Retrieved');
-            break;
-          case 400:
-              drupal_set_message('Error 400');
-              break;
-         case 415:
-              drupal_set_message('Error 415');
-              break;
-
-          default;
-            watchdog('drupalgapps', t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), WATCHDOG_WARNING);
-            drupal_set_message(t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), 'error');
-            return FALSE;
-        }
-      }
-      else {
-        watchdog('drupalgapps', t('The HTTPS request to Google seems to be broken like hell  (unknown error).'), WATCHDOG_WARNING);
-        drupal_set_message(t('The HTTPS request to Google seems to be broken like hell (unknown error).'), 'error');
+      default;
+        watchdog('drupalgapps', t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), WATCHDOG_WARNING);
+        drupal_set_message(t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), 'error');
         return FALSE;
-      }
+    }
+  }
+  else {
+    watchdog('drupalgapps', t('The HTTPS request to Google seems to be broken like hell  (unknown error).'), WATCHDOG_WARNING);
+    drupal_set_message(t('The HTTPS request to Google seems to be broken like hell (unknown error).'), 'error');
+    return FALSE;
+  }
 
-    watchdog('Google Apps','response code : '.$code, array(), WATCHDOG_CRITICAL, l(t('DrupalGapps Settings'), 'admin/settings/drupalgapps'));
-
-
-
-
-return ;
+  watchdog('Google Apps', 'response code : ' . $code, array(), WATCHDOG_CRITICAL, l(t('DrupalGapps Settings'), 'admin/settings/drupalgapps'));
+  return ;
 }
 
-//Deleting a Nickname
+/**
+ * Delete a Google nickname.
+ */
+function drupalgapps_delete_nickname($username) {
+  $auth = variable_get('gapps_prov_api_auth_token', '');
+  $proxy_add = variable_get('gapps_proxy', '');
 
+  if ($proxy_add) {
+    $proxy_exist = 1;
+  }
+  else {
+    $proxy_exist = 0;
+  }
 
-function drupalgapps_delete_nickname($username)
-{
 
+  $url = 'https://apps-apis.google.com/a/feeds/domain/nickname/2.0/' . $username;
+  $header = "Authorization: GoogleLogin auth=" . $auth;
 
-     $auth=variable_get('gapps_prov_api_auth_token','');    $proxy_add = variable_get('gapps_proxy','');
-
-if($proxy_add){
-         $proxy_exist=1;
-     }
-     else
-     {
-         $proxy_exist=0;
-     }
-
-
-    $url = 'https://apps-apis.google.com/a/feeds/domain/nickname/2.0/'.$username;
-
-$header="Authorization: GoogleLogin auth=".$auth;
-
-
-$ch = curl_init();
-  curl_setopt($ch, CURLOPT_URL,$url);
-  curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
+  $ch = curl_init();
+  curl_setopt($ch, CURLOPT_URL, $url);
+  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
   curl_setopt($ch, CURLOPT_HTTPHEADER, array($header));
   curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
-  curl_setopt($ch, CURLOPT_CUSTOMREQUEST,'DELETE');
+  curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
   curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, $proxy_exist);
   curl_setopt($ch, CURLOPT_PROXY, $proxy_add);
   curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
   curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,  2);
   $result = curl_exec($ch);
-  $code= curl_getinfo($ch, CURLINFO_HTTP_CODE);
+  $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
 
+  if ($code) {
+    switch ($code) {
+      case 200:
+      case 201:
+      case 202:
+        drupal_set_message('Nickname Deleted successful');
+        break;
+      case 400:
+        drupal_set_message('Error 400');
+        break;
+      case 415:
+        drupal_set_message('Error 415');
+        break;
 
-
-      if ($code) {
-
-        switch ($code) {
-          case 200:
-          case 201:
-          case 202:
-            drupal_set_message('Nickname Deleted successful');
-            break;
-          case 400:
-              drupal_set_message('Error 400');
-              break;
-         case 415:
-              drupal_set_message('Error 415');
-              break;
-
-          default;
-            watchdog('Google Apps', t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), WATCHDOG_WARNING);
-            drupal_set_message(t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), 'error');
-            return FALSE;
-        }
-      }
-      else {
-        watchdog('Google Apps', t('The HTTPS request to Google seems to be broken like hell  (unknown error).'), WATCHDOG_WARNING);
-        drupal_set_message(t('The HTTPS request to Google seems to be broken like hell (unknown error).'), 'error');
+      default;
+        watchdog('Google Apps', t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), WATCHDOG_WARNING);
+        drupal_set_message(t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), 'error');
         return FALSE;
-      }
+    }
+  }
+  else {
+    watchdog('Google Apps', t('The HTTPS request to Google seems to be broken like hell  (unknown error).'), WATCHDOG_WARNING);
+    drupal_set_message(t('The HTTPS request to Google seems to be broken like hell (unknown error).'), 'error');
+    return FALSE;
+  }
 
-
-    watchdog('Google Apps','response code : '.$code, array(), WATCHDOG_CRITICAL, l(t('DrupalGapps Settings'), 'admin/settings/drupalgapps'));
-
-
+  watchdog('Google Apps', 'response code : ' . $code, array(), WATCHDOG_CRITICAL, l(t('DrupalGapps Settings'), 'admin/settings/drupalgapps'));
 }
 
 
-//Creating a Group
+/**
+ * Create a Google user group.
+ */
+function drupalgapps_create_group($group_id, $group_name, $description, $email_permission) {
+  $auth = variable_get('gapps_prov_api_auth_token', '');
+  $proxy_add = variable_get('gapps_proxy', '');
 
-function drupalgapps_create_group($group_id,$group_name,$description,$email_permission)
-{
+  if ($proxy_add) {
+    $proxy_exist = 1;
+  }
+  else {
+    $proxy_exist = 0;
+  }
 
-
-     $auth=variable_get('gapps_prov_api_auth_token','');    $proxy_add = variable_get('gapps_proxy','');
-
-if($proxy_add){
-         $proxy_exist=1;
-     }
-     else
-     {
-         $proxy_exist=0;
-     }
-
-     $data=<<<XML
+  $data=<<<XML
         <atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:apps="http://schemas.google.com/apps/2006" xmlns:gd="http://schemas.google.com/g/2005">
   <apps:property name="groupId" value="'.$group_id.'"></apps:property>
   <apps:property name="groupName" value="'.$group_name.'"></apps:property>
@@ -1295,13 +1098,13 @@
 XML;
 
 
- $header="Authorization: GoogleLogin auth=".$auth;
-  $header=$header."\nContent-type: application/atom+xml";
-  $header=$header."\nContent-Length :".strlen($data);
-  
+  $header = "Authorization: GoogleLogin auth=" . $auth;
+  $header = $header . "\nContent-type: application/atom+xml";
+  $header = $header . "\nContent-Length :" . strlen($data);
+
   $ch = curl_init();
-  curl_setopt($ch, CURLOPT_URL,'https://apps-apis.google.com/a/feeds/domain/nickname/2.0');
-  curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
+  curl_setopt($ch, CURLOPT_URL, 'https://apps-apis.google.com/a/feeds/domain/nickname/2.0');
+  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
   curl_setopt($ch, CURLOPT_HTTPHEADER, array($header));
   curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
   curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, $proxy_exist);
@@ -1309,324 +1112,279 @@
   curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
   curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,  2);
   $result = curl_exec($ch);
-  $code= curl_getinfo($ch, CURLINFO_HTTP_CODE);
+  $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
 
+  if ($code) {
+    switch ($code) {
+      case 200:
+      case 201:
+      case 202:
+        drupal_set_message('Group  Created');
+        break;
+      case 400:
+        drupal_set_message('Error 400');
+        break;
+      case 415:
+        drupal_set_message('Error 415');
+        break;
 
-
-      if ($code) {
-
-        switch ($code) {
-          case 200:
-          case 201:
-          case 202:
-            drupal_set_message('Group  Created');
-            break;
-          case 400:
-              drupal_set_message('Error 400');
-              break;
-         case 415:
-              drupal_set_message('Error 415');
-              break;
-
-          default;
-            watchdog('drupalgapps', t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), WATCHDOG_WARNING);
-            drupal_set_message(t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), 'error');
-            return FALSE;
-        }
-      }
-      else {
-        watchdog('drupalgapps', t('The HTTPS request to Google seems to be broken like hell  (unknown error).'), WATCHDOG_WARNING);
-        drupal_set_message(t('The HTTPS request to Google seems to be broken like hell (unknown error).'), 'error');
+      default;
+        watchdog('drupalgapps', t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), WATCHDOG_WARNING);
+        drupal_set_message(t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), 'error');
         return FALSE;
-      }
+    }
+  }
+  else {
+    watchdog('drupalgapps', t('The HTTPS request to Google seems to be broken like hell  (unknown error).'), WATCHDOG_WARNING);
+    drupal_set_message(t('The HTTPS request to Google seems to be broken like hell (unknown error).'), 'error');
+    return FALSE;
+  }
 
-    watchdog('Google Apps','response code : '.$code, array(), WATCHDOG_CRITICAL, l(t('DrupalGapps Settings'), 'admin/settings/drupalgapps'));
-
-
-
+  watchdog('Google Apps', 'response code : '.$code, array(), WATCHDOG_CRITICAL, l(t('DrupalGapps Settings'), 'admin/settings/drupalgapps'));
 }
 
 
 
-//Updating a Group
+/**
+ * Update a Google user group.
+ */
+function drupalgapps_update_group($group_id, $group_name, $description, $email_permission) {
+  $auth = variable_get('gapps_prov_api_auth_token', '');
+  $proxy_add = variable_get('gapps_proxy', '');
 
-function drupalgapps_update_group($group_id,$group_name,$description,$email=NULL_permission)
-{
+  if ($proxy_add) {
+    $proxy_exist = 1;
+  }
+  else {
+    $proxy_exist = 0;
+  }
 
-     $auth=variable_get('gapps_prov_api_auth_token','');    $proxy_add = variable_get('gapps_proxy','');
 
-if($proxy_add){
-         $proxy_exist=1;
-     }
-     else
-     {
-         $proxy_exist=0;
-     }
-
-
-    $data = '
+  $data = '
         <atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:apps="http://schemas.google.com/apps/2006" xmlns:gd="http://schemas.google.com/g/2005">
         <apps:property name="groupId" value="'.$group_id.'"></apps:property>
-';
-if ($group_name) {
-        $data .= '<apps:property name="groupName" value="'.$group_name.'"></apps:property>';
-      }
-if ($description) {
-        $data .= '<apps:property name="description" value="'.$description.'"></apps:property>';
-      }
-if ($email_permission) {
-        $data .= '<apps:property name="emailPermission" value="'.$email_permission.'"></apps:property>';
-      }
-$data .= '</atom:entry>
-      ';
+  ';
+  if ($group_name) {
+    $data .= '<apps:property name="groupName" value="'.$group_name.'"></apps:property>';
+  }
+  if ($description) {
+    $data .= '<apps:property name="description" value="'.$description.'"></apps:property>';
+  }
+  if ($email_permission) {
+    $data .= '<apps:property name="emailPermission" value="'.$email_permission.'"></apps:property>';
+  }
+  $data .= '</atom:entry>';
 
+  $auth = variable_get('gapps_prov_api_auth_token', '');
+  $proxy_add = variable_get('gapps_proxy', '');
+  $url = 'https://apps-apis.google.com/a/feeds/group/2.0/domain/' . $group_id;
 
-     $auth=variable_get('gapps_prov_api_auth_token','');    $proxy_add = variable_get('gapps_proxy','');
+  $header = "Authorization: GoogleLogin auth=" . $auth;
+  $header = $header . "\nContent-type: application/atom+xml";
+  $header = $header . "\nContent-Length :" . strlen($data);
 
-
-    $url = 'https://apps-apis.google.com/a/feeds/group/2.0/domain/'.$group_id;
-
-$header="Authorization: GoogleLogin auth=".$auth;
-$header=$header."\nContent-type: application/atom+xml";
-$header=$header."\nContent-Length :".strlen($data);
-
-$ch = curl_init();
-  curl_setopt($ch, CURLOPT_URL,$url);
-  curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
+  $ch = curl_init();
+  curl_setopt($ch, CURLOPT_URL, $url);
+  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
   curl_setopt($ch, CURLOPT_HTTPHEADER, array($header));
   curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
-  curl_setopt($ch, CURLOPT_PUT,TRUE);
+  curl_setopt($ch, CURLOPT_PUT, TRUE);
   curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, $proxy_exist);
   curl_setopt($ch, CURLOPT_PROXY, $proxy_add);
   curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
   curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,  2);
   $result = curl_exec($ch);
-  $code= curl_getinfo($ch, CURLINFO_HTTP_CODE);
+  $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
 
 
 
-      if ($code) {
+  if ($code) {
+    switch ($code) {
+      case 200:
+      case 201:
+      case 202:
+        drupal_set_message('Group updated');
+        break;
+      case 400:
+        drupal_set_message('Error 400');
+        break;
+      case 415:
+        drupal_set_message('Error 415');
+        break;
 
-        switch ($code) {
-          case 200:
-          case 201:
-          case 202:
-            drupal_set_message('Group updated');
-            break;
-          case 400:
-              drupal_set_message('Error 400');
-              break;
-         case 415:
-              drupal_set_message('Error 415');
-              break;
-
-          default;
-            watchdog('drupalgapps', t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), WATCHDOG_WARNING);
-            drupal_set_message(t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), 'error');
-            return FALSE;
-        }
-      }
-      else {
-        watchdog('drupalgapps', t('The HTTPS request to Google seems to be broken like hell  (unknown error).'), WATCHDOG_WARNING);
-        drupal_set_message(t('The HTTPS request to Google seems to be broken like hell (unknown error).'), 'error');
+      default;
+        watchdog('drupalgapps', t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), WATCHDOG_WARNING);
+        drupal_set_message(t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), 'error');
         return FALSE;
-      }
+    }
+  }
+  else {
+    watchdog('drupalgapps', t('The HTTPS request to Google seems to be broken like hell  (unknown error).'), WATCHDOG_WARNING);
+    drupal_set_message(t('The HTTPS request to Google seems to be broken like hell (unknown error).'), 'error');
+    return FALSE;
+  }
 
-    watchdog('Google Apps','response code : '.$code, array(), WATCHDOG_CRITICAL, l(t('DrupalGapps Settings'), 'admin/settings/drupalgapps'));
+  watchdog('Google Apps', 'response code : ' . $code, array(), WATCHDOG_CRITICAL, l(t('DrupalGapps Settings'), 'admin/settings/drupalgapps'));
 
-
-
 }
 
 
-//Retrieving a Group
+/**
+ * Retrieve a Google user group.
+ */
+function drupalgapps_retrieve_groups($member_id) {
+  $auth = variable_get('gapps_prov_api_auth_token', '');
+  $proxy_add = variable_get('gapps_proxy', '');
 
+  if ($proxy_add) {
+    $proxy_exist = 1;
+  }
+  else {
+    $proxy_exist = 0;
+  }
 
-function drupalgapps_retrieve_groups($member_id)
-{
 
+  $url = 'https://apps-apis.google.com/a/feeds/group/2.0/domain/?member=' . $member_id . '[&[directOnly=]]';
+  $header = "Authorization: GoogleLogin auth=" . $auth;
 
-     $auth=variable_get('gapps_prov_api_auth_token','');    $proxy_add = variable_get('gapps_proxy','');
-
-if($proxy_add){
-         $proxy_exist=1;
-     }
-     else
-     {
-         $proxy_exist=0;
-     }
-
-
-    $url = 'https://apps-apis.google.com/a/feeds/group/2.0/domain/?member='.$member_id.'[&[directOnly=]]';
-
-  $header="Authorization: GoogleLogin auth=".$auth;
-
-
   $ch = curl_init();
-  curl_setopt($ch, CURLOPT_URL,$url);
-  curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
-  curl_setopt($ch, CURLOPT_HTTPGET,TRUE);
+  curl_setopt($ch, CURLOPT_URL, $url);
+  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+  curl_setopt($ch, CURLOPT_HTTPGET, TRUE);
   curl_setopt($ch, CURLOPT_HTTPHEADER, array($header));
   curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, $proxy_exist);
   curl_setopt($ch, CURLOPT_PROXY, $proxy_add);
   curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
   curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,  2);
+  $result = curl_exec($ch);
+  $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
 
-$result = curl_exec($ch);
+  if ($code) {
+    switch ($code) {
+      case 200:
+      case 201:
+      case 202:
+        drupal_set_message('Groups Retrieved');
+        break;
+      case 400:
+        drupal_set_message('Error 400');
+        break;
+      case 415:
+        drupal_set_message('Error 415');
+        break;
 
-  $code= curl_getinfo($ch, CURLINFO_HTTP_CODE);
-
-
-
-
-
-      if ($code) {
-
-        switch ($code) {
-          case 200:
-          case 201:
-          case 202:
-            drupal_set_message('Groups Retrieved');
-            break;
-          case 400:
-              drupal_set_message('Error 400');
-              break;
-         case 415:
-              drupal_set_message('Error 415');
-              break;
-
-          default;
-            watchdog('drupalgapps', t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), WATCHDOG_WARNING);
-            drupal_set_message(t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), 'error');
-            return FALSE;
-        }
-      }
-      else {
-        watchdog('drupalgapps', t('The HTTPS request to Google seems to be broken like hell  (unknown error).'), WATCHDOG_WARNING);
-        drupal_set_message(t('The HTTPS request to Google seems to be broken like hell (unknown error).'), 'error');
+      default;
+        watchdog('drupalgapps', t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), WATCHDOG_WARNING);
+        drupal_set_message(t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), 'error');
         return FALSE;
-      }
+    }
+  }
+  else {
+    watchdog('drupalgapps', t('The HTTPS request to Google seems to be broken like hell  (unknown error).'), WATCHDOG_WARNING);
+    drupal_set_message(t('The HTTPS request to Google seems to be broken like hell (unknown error).'), 'error');
+    return FALSE;
+  }
 
-    watchdog('Google Apps','response code : '.$code, array(), WATCHDOG_CRITICAL, l(t('DrupalGapps Settings'), 'admin/settings/drupalgapps'));
-
-
-
-
-return ;
+  watchdog('Google Apps', 'response code : ' . $code, array(), WATCHDOG_CRITICAL, l(t('DrupalGapps Settings'), 'admin/settings/drupalgapps'));
+  return;
 }
 
 
 
-//Deleting a Group
+/**
+ * Delete a Google user group.
+ */
+function drupalgapps_delete_group($group_id) {
+  $auth = variable_get('gapps_prov_api_auth_token', '');
+  $proxy_add = variable_get('gapps_proxy', '');
 
-function drupalgapps_delete_group($group_id)
-{
+  if ($proxy_add) {
+    $proxy_exist = 1;
+  }
+  else {
+    $proxy_exist = 0;
+  }
 
+  $url = 'https://apps-apis.google.com/a/feeds/group/2.0/domain/' . $group_id;
+  $header = "Authorization: GoogleLogin auth=" . $auth;
 
-     $auth=variable_get('gapps_prov_api_auth_token','');    $proxy_add = variable_get('gapps_proxy','');
-
-if($proxy_add){
-         $proxy_exist=1;
-     }
-     else
-     {
-         $proxy_exist=0;
-     }
-
-
-    $url = 'https://apps-apis.google.com/a/feeds/group/2.0/domain/'.$group_id;
-
-$header="Authorization: GoogleLogin auth=".$auth;
-
-
-$ch = curl_init();
-  curl_setopt($ch, CURLOPT_URL,$url);
-  curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
+  $ch = curl_init();
+  curl_setopt($ch, CURLOPT_URL, $url);
+  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
   curl_setopt($ch, CURLOPT_HTTPHEADER, array($header));
   curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
-  curl_setopt($ch, CURLOPT_CUSTOMREQUEST,'DELETE');
+  curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
   curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, $proxy_exist);
   curl_setopt($ch, CURLOPT_PROXY, $proxy_add);
   curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
   curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,  2);
   $result = curl_exec($ch);
-  $code= curl_getinfo($ch, CURLINFO_HTTP_CODE);
+  $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
 
+  if ($code) {
+    switch ($code) {
+      case 200:
+      case 201:
+      case 202:
+        drupal_set_message('Group Deleted successful');
+        break;
+      case 400:
+        drupal_set_message('Error 400');
+        break;
+      case 415:
+        drupal_set_message('Error 415');
+        break;
 
-
-      if ($code) {
-
-        switch ($code) {
-          case 200:
-          case 201:
-          case 202:
-            drupal_set_message('Group Deleted successful');
-            break;
-          case 400:
-              drupal_set_message('Error 400');
-              break;
-         case 415:
-              drupal_set_message('Error 415');
-              break;
-
-          default;
-            watchdog('Google Apps', t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), WATCHDOG_WARNING);
-            drupal_set_message(t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), 'error');
-            return FALSE;
-        }
-      }
-      else {
-        watchdog('Google Apps', t('The HTTPS request to Google seems to be broken like hell  (unknown error).'), WATCHDOG_WARNING);
-        drupal_set_message(t('The HTTPS request to Google seems to be broken like hell (unknown error).'), 'error');
+      default;
+        watchdog('Google Apps', t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), WATCHDOG_WARNING);
+        drupal_set_message(t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), 'error');
         return FALSE;
-      }
+    }
+  }
+  else {
+    watchdog('Google Apps', t('The HTTPS request to Google seems to be broken like hell  (unknown error).'), WATCHDOG_WARNING);
+    drupal_set_message(t('The HTTPS request to Google seems to be broken like hell (unknown error).'), 'error');
+    return FALSE;
+  }
 
-
-    watchdog('Google Apps','response code : '.$code, array(), WATCHDOG_CRITICAL, l(t('DrupalGapps Settings'), 'admin/settings/drupalgapps'));
-
-
+  watchdog('Google Apps', 'response code : ' . $code, array(), WATCHDOG_CRITICAL, l(t('DrupalGapps Settings'), 'admin/settings/drupalgapps'));
 }
 
 
 
-//Adding a Member to a Group
+/**
+ * Add a member to a Google group.
+ */
+function drupalgapps_add_member($group_id, $member_id) {
+  $auth = variable_get('gapps_prov_api_auth_token', '');
+  $proxy_add = variable_get('gapps_proxy', '');
 
-function drupalgapps_add_member($group_id,$member_id)
-{
+  if ($proxy_add) {
+    $proxy_exist = 1;
+  }
+  else {
+    $proxy_exist = 0;
+  }
 
 
-     $auth=variable_get('gapps_prov_api_auth_token','');    $proxy_add = variable_get('gapps_proxy','');
-
-if($proxy_add){
-         $proxy_exist=1;
-     }
-     else
-     {
-         $proxy_exist=0;
-     }
-
-
-     $data=<<<XML
+  $data=<<<XML
        <?xml version="1.0" encoding="UTF-8"?>
 <atom:entry xmlns:atom="http://www.w3.org/2005/Atom"
     xmlns:apps="http://schemas.google.com/apps/2006"
     xmlns:gd="http://schemas.google.com/g/2005">
     <apps:property name="memberId" value="'.$member_id.'"/>
 </atom:entry>
-
 XML;
 
 
-$url='https://apps-apis.google.com/a/feeds/group/2.0/domain/'.$group_id.'/member';
+  $url = 'https://apps-apis.google.com/a/feeds/group/2.0/domain/' . $group_id . '/member';
+  $header = "Authorization: GoogleLogin auth=" . $auth;
+  $header = $header . "\nContent-type: application/atom+xml";
+  $header = $header . "\nContent-Length :" . strlen($data);
 
-
- $header="Authorization: GoogleLogin auth=".$auth;
-  $header=$header."\nContent-type: application/atom+xml";
-  $header=$header."\nContent-Length :".strlen($data);
-
   $ch = curl_init();
-  curl_setopt($ch, CURLOPT_URL,$url);
-  curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
+  curl_setopt($ch, CURLOPT_URL, $url);
+  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
   curl_setopt($ch, CURLOPT_HTTPHEADER, array($header));
   curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
   curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, $proxy_exist);
@@ -1634,84 +1392,73 @@
   curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
   curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,  2);
   $result = curl_exec($ch);
-  $code= curl_getinfo($ch, CURLINFO_HTTP_CODE);
+  $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
 
+  if ($code) {
+    switch ($code) {
+      case 200:
+      case 201:
+      case 202:
+        drupal_set_message('member Added');
+        break;
+      case 400:
+        drupal_set_message('Error 400');
+        break;
+      case 415:
+        drupal_set_message('Error 415');
+        break;
 
-
-      if ($code) {
-
-        switch ($code) {
-          case 200:
-          case 201:
-          case 202:
-            drupal_set_message('member Added');
-            break;
-          case 400:
-              drupal_set_message('Error 400');
-              break;
-         case 415:
-              drupal_set_message('Error 415');
-              break;
-
-          default;
-            watchdog('drupalgapps', t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), WATCHDOG_WARNING);
-            drupal_set_message(t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), 'error');
-            return FALSE;
-        }
-      }
-      else {
-        watchdog('drupalgapps', t('The HTTPS request to Google seems to be broken like hell  (unknown error).'), WATCHDOG_WARNING);
-        drupal_set_message(t('The HTTPS request to Google seems to be broken like hell (unknown error).'), 'error');
+      default;
+        watchdog('drupalgapps', t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), WATCHDOG_WARNING);
+        drupal_set_message(t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), 'error');
         return FALSE;
-      }
+    }
+  }
+  else {
+    watchdog('drupalgapps', t('The HTTPS request to Google seems to be broken like hell  (unknown error).'), WATCHDOG_WARNING);
+    drupal_set_message(t('The HTTPS request to Google seems to be broken like hell (unknown error).'), 'error');
+    return FALSE;
+  }
 
-    watchdog('Google Apps','response code : '.$code, array(), WATCHDOG_CRITICAL, l(t('DrupalGapps Settings'), 'admin/settings/drupalgapps'));
-
-
-
+  watchdog('Google Apps', 'response code : ' . $code, array(), WATCHDOG_CRITICAL, l(t('DrupalGapps Settings'), 'admin/settings/drupalgapps'));
 }
 
 
-#TODO : Add the domain name at the end of the group_id and member_id
+// @TODO : Add the domain name at the end of the group_id and member_id
 
 
-//Adding a Group to a Group
+/**
+ * Add a Google group to a group.
+ */
+function drupalgapps_add_group($group_id) {
+  $auth = variable_get('gapps_prov_api_auth_token', '');
+  $proxy_add = variable_get('gapps_proxy', '');
 
-function drupalgapps_add_group($group_id)
-{
+  if ($proxy_add) {
+    $proxy_exist = 1;
+  }
+  else {
+    $proxy_exist = 0;
+  }
 
 
-     $auth=variable_get('gapps_prov_api_auth_token','');    $proxy_add = variable_get('gapps_proxy','');
-
-if($proxy_add){
-         $proxy_exist=1;
-     }
-     else
-     {
-         $proxy_exist=0;
-     }
-
-
-     $data=<<<XML
+  $data=<<<XML
        <?xml version="1.0" encoding="UTF-8"?>
 <atom:entry xmlns:atom="http://www.w3.org/2005/Atom"
     xmlns:apps="http://schemas.google.com/apps/2006"
     xmlns:gd="http://schemas.google.com/g/2005">
     <apps:property name="memberId" value="'.$group_id.'"/>
 </atom:entry>
-
 XML;
 
-$url='https://apps-apis.google.com/a/feeds/group/2.0/domain/'.$group_id.'/member';
+  $url = 'https://apps-apis.google.com/a/feeds/group/2.0/domain/' . $group_id . '/member';
+  $header = "Authorization: GoogleLogin auth=" . $auth;
+  $header = $header . "\nContent-type: application/atom+xml";
+  $header = $header . "\nContent-Length :" . strlen($data);
 
-
- $header="Authorization: GoogleLogin auth=".$auth;
-  $header=$header."\nContent-type: application/atom+xml";
-  $header=$header."\nContent-Length :".strlen($data);
-
   $ch = curl_init();
-  curl_setopt($ch, CURLOPT_URL,$url);
-  curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
+  curl_setopt($ch, CURLOPT_URL, $url);
+  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
   curl_setopt($ch, CURLOPT_HTTPHEADER, array($header));
   curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
   curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, $proxy_exist);
@@ -1719,284 +1466,235 @@
   curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
   curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,  2);
   $result = curl_exec($ch);
-  $code= curl_getinfo($ch, CURLINFO_HTTP_CODE);
+  $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
 
+  if ($code) {
+    switch ($code) {
+      case 200:
+      case 201:
+      case 202:
+        drupal_set_message('member Added');
+        break;
+      case 400:
+        drupal_set_message('Error 400');
+        break;
+      case 415:
+        drupal_set_message('Error 415');
+        break;
 
-
-      if ($code) {
-
-        switch ($code) {
-          case 200:
-          case 201:
-          case 202:
-            drupal_set_message('member Added');
-            break;
-          case 400:
-              drupal_set_message('Error 400');
-              break;
-         case 415:
-              drupal_set_message('Error 415');
-              break;
-
-          default;
-            watchdog('drupalgapps', t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), WATCHDOG_WARNING);
-            drupal_set_message(t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), 'error');
-            return FALSE;
-        }
-      }
-      else {
-        watchdog('drupalgapps', t('The HTTPS request to Google seems to be broken like hell  (unknown error).'), WATCHDOG_WARNING);
-        drupal_set_message(t('The HTTPS request to Google seems to be broken like hell (unknown error).'), 'error');
+      default;
+        watchdog('drupalgapps', t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), WATCHDOG_WARNING);
+        drupal_set_message(t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), 'error');
         return FALSE;
-      }
+    }
+  }
+  else {
+    watchdog('drupalgapps', t('The HTTPS request to Google seems to be broken like hell  (unknown error).'), WATCHDOG_WARNING);
+    drupal_set_message(t('The HTTPS request to Google seems to be broken like hell (unknown error).'), 'error');
+    return FALSE;
+  }
 
-    watchdog('Google Apps','response code : '.$code, array(), WATCHDOG_CRITICAL, l(t('DrupalGapps Settings'), 'admin/settings/drupalgapps'));
-
-
-
+  watchdog('Google Apps', 'response code : ' . $code, array(), WATCHDOG_CRITICAL, l(t('DrupalGapps Settings'), 'admin/settings/drupalgapps'));
 }
 
 
-//Retrieving All Members of a Group
+/**
+ * Retrieve all members of a Google group.
+ */
+function drupalgapps_retrieve_group_members($group_id) {
+  $auth = variable_get('gapps_prov_api_auth_token', '');
+  $proxy_add = variable_get('gapps_proxy', '');
 
-function drupalgapps_retrieve_group_members($group_id)
-{
+  if ($proxy_add) {
+    $proxy_exist = 1;
+  }
+  else {
+    $proxy_exist = 0;
+  }
 
 
-     $auth=variable_get('gapps_prov_api_auth_token','');    $proxy_add = variable_get('gapps_proxy','');
+  $url = 'https://apps-apis.google.com/a/feeds/group/2.0/domain/' . $group_id . '/member[?[start=]]';
+  $header = "Authorization: GoogleLogin auth=" . $auth;
 
-if($proxy_add){
-         $proxy_exist=1;
-     }
-     else
-     {
-         $proxy_exist=0;
-     }
-
-
-    $url = 'https://apps-apis.google.com/a/feeds/group/2.0/domain/'.$group_id.'/member[?[start=]]';
-
-  $header="Authorization: GoogleLogin auth=".$auth;
-
-
   $ch = curl_init();
-  curl_setopt($ch, CURLOPT_URL,$url);
-  curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
-  curl_setopt($ch, CURLOPT_HTTPGET,TRUE);
+  curl_setopt($ch, CURLOPT_URL, $url);
+  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+  curl_setopt($ch, CURLOPT_HTTPGET, TRUE);
   curl_setopt($ch, CURLOPT_HTTPHEADER, array($header));
   curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, $proxy_exist);
   curl_setopt($ch, CURLOPT_PROXY, $proxy_add);
   curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
   curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,  2);
+  $result = curl_exec($ch);
+  $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
 
-$result = curl_exec($ch);
+  if ($code) {
+    switch ($code) {
+      case 200:
+      case 201:
+      case 202:
+        drupal_set_message('Groups members Retrieved');
+        break;
+      case 400:
+        drupal_set_message('Error 400');
+        break;
+      case 415:
+        drupal_set_message('Error 415');
+        break;
 
-  $code= curl_getinfo($ch, CURLINFO_HTTP_CODE);
-
-
-
-
-
-      if ($code) {
-
-        switch ($code) {
-          case 200:
-          case 201:
-          case 202:
-            drupal_set_message('Groups members Retrieved');
-            break;
-          case 400:
-              drupal_set_message('Error 400');
-              break;
-         case 415:
-              drupal_set_message('Error 415');
-              break;
-
-          default;
-            watchdog('drupalgapps', t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), WATCHDOG_WARNING);
-            drupal_set_message(t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), 'error');
-            return FALSE;
-        }
-      }
-      else {
-        watchdog('drupalgapps', t('The HTTPS request to Google seems to be broken like hell  (unknown error).'), WATCHDOG_WARNING);
-        drupal_set_message(t('The HTTPS request to Google seems to be broken like hell (unknown error).'), 'error');
+      default;
+        watchdog('drupalgapps', t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), WATCHDOG_WARNING);
+        drupal_set_message(t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), 'error');
         return FALSE;
-      }
+    }
+  }
+  else {
+    watchdog('drupalgapps', t('The HTTPS request to Google seems to be broken like hell  (unknown error).'), WATCHDOG_WARNING);
+    drupal_set_message(t('The HTTPS request to Google seems to be broken like hell (unknown error).'), 'error');
+    return FALSE;
+  }
 
-    watchdog('Google Apps','response code : '.$code, array(), WATCHDOG_CRITICAL, l(t('DrupalGapps Settings'), 'admin/settings/drupalgapps'));
-
-
-
-
-return ;
+  watchdog('Google Apps', 'response code : ' . $code, array(), WATCHDOG_CRITICAL, l(t('DrupalGapps Settings'), 'admin/settings/drupalgapps'));
+  return;
 }
 
-//Removing a Member from a Group
+/**
+ * Retrieve a member from a Google group.
+ */
+function drupalgapps_retrieve_group_member($group_id, $member_id) {
+  $auth = variable_get('gapps_prov_api_auth_token', '');
+  $proxy_add = variable_get('gapps_proxy', '');
 
-function drupalgapps_retrieve_group_member($group_id,$member_id)
-{
+  if ($proxy_add) {
+    $proxy_exist = 1;
+  }
+  else {
+    $proxy_exist = 0;
+  }
 
 
-     $auth=variable_get('gapps_prov_api_auth_token','');    $proxy_add = variable_get('gapps_proxy','');
+  $url = 'https://apps-apis.google.com/a/feeds/group/2.0/domain/' . $group_id . '/member/' . $member_id;
+  $header = "Authorization: GoogleLogin auth=" . $auth;
 
-if($proxy_add){
-         $proxy_exist=1;
-     }
-     else
-     {
-         $proxy_exist=0;
-     }
-
-
-    $url = 'https://apps-apis.google.com/a/feeds/group/2.0/domain/'.$group_id.'/member/'.$member_id;
-
-  $header="Authorization: GoogleLogin auth=".$auth;
-
-
   $ch = curl_init();
-  curl_setopt($ch, CURLOPT_URL,$url);
-  curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
-  curl_setopt($ch, CURLOPT_HTTPGET,TRUE);
+  curl_setopt($ch, CURLOPT_URL, $url);
+  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+  curl_setopt($ch, CURLOPT_HTTPGET, TRUE);
   curl_setopt($ch, CURLOPT_HTTPHEADER, array($header));
   curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, $proxy_exist);
   curl_setopt($ch, CURLOPT_PROXY, $proxy_add);
   curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
   curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,  2);
+  $result = curl_exec($ch);
+  $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
 
-$result = curl_exec($ch);
+  if ($code) {
+    switch ($code) {
+      case 200:
+      case 201:
+      case 202:
+        drupal_set_message('Groups Retrieved');
+        break;
+      case 400:
+          drupal_set_message('Error 400');
+          break;
+      case 415:
+          drupal_set_message('Error 415');
+          break;
 
-  $code= curl_getinfo($ch, CURLINFO_HTTP_CODE);
-
-
-
-
-
-      if ($code) {
-
-        switch ($code) {
-          case 200:
-          case 201:
-          case 202:
-            drupal_set_message('Groups Retrieved');
-            break;
-          case 400:
-              drupal_set_message('Error 400');
-              break;
-         case 415:
-              drupal_set_message('Error 415');
-              break;
-
-          default;
-            watchdog('drupalgapps', t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), WATCHDOG_WARNING);
-            drupal_set_message(t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), 'error');
-            return FALSE;
-        }
-      }
-      else {
-        watchdog('drupalgapps', t('The HTTPS request to Google seems to be broken like hell  (unknown error).'), WATCHDOG_WARNING);
-        drupal_set_message(t('The HTTPS request to Google seems to be broken like hell (unknown error).'), 'error');
+      default;
+        watchdog('drupalgapps', t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), WATCHDOG_WARNING);
+        drupal_set_message(t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), 'error');
         return FALSE;
-      }
+    }
+  }
+  else {
+    watchdog('drupalgapps', t('The HTTPS request to Google seems to be broken like hell  (unknown error).'), WATCHDOG_WARNING);
+    drupal_set_message(t('The HTTPS request to Google seems to be broken like hell (unknown error).'), 'error');
+    return FALSE;
+  }
 
-    watchdog('Google Apps','response code : '.$code, array(), WATCHDOG_CRITICAL, l(t('DrupalGapps Settings'), 'admin/settings/drupalgapps'));
-
-
-
-
-return ;
+  watchdog('Google Apps', 'response code : ' . $code, array(), WATCHDOG_CRITICAL, l(t('DrupalGapps Settings'), 'admin/settings/drupalgapps'));
+  return;
 }
 
-//Removing a Group member
+/**
+ * Remove a Google group member.
+ */
+function drupalgapps_delete_member($group_id, $member_id) {
+  $auth = variable_get('gapps_prov_api_auth_token', '');
+  $proxy_add = variable_get('gapps_proxy', '');
 
-function drupalgapps_delete_member($group_id,$member_id)
-{
+  if ($proxy_add) {
+    $proxy_exist = 1;
+  }
+  else {
+    $proxy_exist = 0;
+  }
 
 
-     $auth=variable_get('gapps_prov_api_auth_token','');    $proxy_add = variable_get('gapps_proxy','');
+  $url = 'https://apps-apis.google.com/a/feeds/group/2.0/domain/' . $group_id . '/member/' . $member_id;
+  $header = "Authorization: GoogleLogin auth=" . $auth;
 
-if($proxy_add){
-         $proxy_exist=1;
-     }
-     else
-     {
-         $proxy_exist=0;
-     }
-
-
-    $url = 'https://apps-apis.google.com/a/feeds/group/2.0/domain/'.$group_id.'/member/'.$member_id;
-
-$header="Authorization: GoogleLogin auth=".$auth;
-
-
-$ch = curl_init();
-  curl_setopt($ch, CURLOPT_URL,$url);
-  curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
+  $ch = curl_init();
+  curl_setopt($ch, CURLOPT_URL, $url);
+  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
   curl_setopt($ch, CURLOPT_HTTPHEADER, array($header));
   curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
-  curl_setopt($ch, CURLOPT_CUSTOMREQUEST,'DELETE');
+  curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
   curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, $proxy_exist);
   curl_setopt($ch, CURLOPT_PROXY, $proxy_add);
   curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
   curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,  2);
   $result = curl_exec($ch);
-  $code= curl_getinfo($ch, CURLINFO_HTTP_CODE);
+  $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
 
+  if ($code) {
+    switch ($code) {
+      case 200:
+      case 201:
+      case 202:
+        drupal_set_message('Group Deleted successful');
+        break;
+      case 400:
+        drupal_set_message('Error 400');
+        break;
+      case 415:
+        drupal_set_message('Error 415');
+        break;
 
-
-      if ($code) {
-
-        switch ($code) {
-          case 200:
-          case 201:
-          case 202:
-            drupal_set_message('Group Deleted successful');
-            break;
-          case 400:
-              drupal_set_message('Error 400');
-              break;
-         case 415:
-              drupal_set_message('Error 415');
-              break;
-
-          default;
-            watchdog('Google Apps', t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), WATCHDOG_WARNING);
-            drupal_set_message(t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), 'error');
-            return FALSE;
-        }
-      }
-      else {
-        watchdog('Google Apps', t('The HTTPS request to Google seems to be broken like hell  (unknown error).'), WATCHDOG_WARNING);
-        drupal_set_message(t('The HTTPS request to Google seems to be broken like hell (unknown error).'), 'error');
+      default;
+        watchdog('Google Apps', t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), WATCHDOG_WARNING);
+        drupal_set_message(t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), 'error');
         return FALSE;
-      }
+    }
+  }
+  else {
+    watchdog('Google Apps', t('The HTTPS request to Google seems to be broken like hell  (unknown error).'), WATCHDOG_WARNING);
+    drupal_set_message(t('The HTTPS request to Google seems to be broken like hell (unknown error).'), 'error');
+    return FALSE;
+  }
 
-
-    watchdog('Google Apps','response code : '.$code, array(), WATCHDOG_CRITICAL, l(t('DrupalGapps Settings'), 'admin/settings/drupalgapps'));
-
-
+  watchdog('Google Apps', 'response code : ' . $code, array(), WATCHDOG_CRITICAL, l(t('DrupalGapps Settings'), 'admin/settings/drupalgapps'));
 }
 
 
-//Adding an Owner member to a Group
+/**
+ * Add an owner member to a Google group.
+ */
+function drupalgapps_add_owner($group_id, $email) {
+  $auth = variable_get('gapps_prov_api_auth_token', '');
+  $proxy_add = variable_get('gapps_proxy', '');
 
+  if ($proxy_add) {
+    $proxy_exist = 1;
+  }
+  else {
+    $proxy_exist = 0;
+  }
 
-function drupalgapps_add_owner($group_id,$email)
-{
 
-
-     $auth=variable_get('gapps_prov_api_auth_token','');    $proxy_add = variable_get('gapps_proxy','');
-
-if($proxy_add){
-         $proxy_exist=1;
-     }
-     else
-     {
-         $proxy_exist=0;
-     }
-
-
-     $data=<<<XML
+  $data=<<<XML
       <?xml version="1.0" encoding="UTF-8"?>
 <atom:entry xmlns:atom="http://www.w3.org/2005/Atom"
     xmlns:apps="http://schemas.google.com/apps/2006"
@@ -2005,16 +1703,14 @@
 </atom:entry>
 XML;
 
-$url='https://apps-apis.google.com/a/feeds/group/2.0/domain/'.$group_id.'/owner';
+  $url = 'https://apps-apis.google.com/a/feeds/group/2.0/domain/' . $group_id . '/owner';
+  $header = "Authorization: GoogleLogin auth=" . $auth;
+  $header = $header . "\nContent-type: application/atom+xml";
+  $header = $header . "\nContent-Length :" . strlen($data);
 
-
- $header="Authorization: GoogleLogin auth=".$auth;
-  $header=$header."\nContent-type: application/atom+xml";
-  $header=$header."\nContent-Length :".strlen($data);
-
   $ch = curl_init();
-  curl_setopt($ch, CURLOPT_URL,$url);
-  curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
+  curl_setopt($ch, CURLOPT_URL, $url);
+  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
   curl_setopt($ch, CURLOPT_HTTPHEADER, array($header));
   curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
   curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, $proxy_exist);
@@ -2022,63 +1718,54 @@
   curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
   curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,  2);
   $result = curl_exec($ch);
-  $code= curl_getinfo($ch, CURLINFO_HTTP_CODE);
+  $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
 
+  if ($code) {
+    switch ($code) {
+      case 200:
+      case 201:
+      case 202:
+        drupal_set_message('member Added');
+        break;
+      case 400:
+        drupal_set_message('Error 400');
+        break;
+      case 415:
+        drupal_set_message('Error 415');
+        break;
 
-
-      if ($code) {
-
-        switch ($code) {
-          case 200:
-          case 201:
-          case 202:
-            drupal_set_message('member Added');
-            break;
-          case 400:
-              drupal_set_message('Error 400');
-              break;
-         case 415:
-              drupal_set_message('Error 415');
-              break;
-
-          default;
-            watchdog('drupalgapps', t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), WATCHDOG_WARNING);
-            drupal_set_message(t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), 'error');
-            return FALSE;
-        }
-      }
-      else {
-        watchdog('drupalgapps', t('The HTTPS request to Google seems to be broken like hell  (unknown error).'), WATCHDOG_WARNING);
-        drupal_set_message(t('The HTTPS request to Google seems to be broken like hell (unknown error).'), 'error');
+      default;
+        watchdog('drupalgapps', t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), WATCHDOG_WARNING);
+        drupal_set_message(t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), 'error');
         return FALSE;
-      }
+    }
+  }
+  else {
+    watchdog('drupalgapps', t('The HTTPS request to Google seems to be broken like hell  (unknown error).'), WATCHDOG_WARNING);
+    drupal_set_message(t('The HTTPS request to Google seems to be broken like hell (unknown error).'), 'error');
+    return FALSE;
+  }
 
-    watchdog('Google Apps','response code : '.$code, array(), WATCHDOG_CRITICAL, l(t('DrupalGapps Settings'), 'admin/settings/drupalgapps'));
-
-
-
+  watchdog('Google Apps', 'response code : ' . $code, array(), WATCHDOG_CRITICAL, l(t('DrupalGapps Settings'), 'admin/settings/drupalgapps'));
 }
 
 
-//Adding an Owner group to a Group
+/**
+ * Add an owner group to a Google group.
+ */
+function drupalgapps_add_ownergroup($group_id, $group_email) {
+  $auth = variable_get('gapps_prov_api_auth_token', '');
+  $proxy_add = variable_get('gapps_proxy', '');
 
+  if ($proxy_add) {
+    $proxy_exist = 1;
+  }
+  else {
+    $proxy_exist = 0;
+  }
 
-function drupalgapps_add_ownergroup($group_id,$group_email)
-{
 
-
-     $auth=variable_get('gapps_prov_api_auth_token','');    $proxy_add = variable_get('gapps_proxy','');
-
-if($proxy_add){
-         $proxy_exist=1;
-     }
-     else
-     {
-         $proxy_exist=0;
-     }
-
-
-     $data=<<<XML
+  $data=<<<XML
       <?xml version="1.0" encoding="UTF-8"?>
 <atom:entry xmlns:atom="http://www.w3.org/2005/Atom"
     xmlns:apps="http://schemas.google.com/apps/2006"
@@ -2087,16 +1774,14 @@
 </atom:entry>
 XML;
 
-$url='https://apps-apis.google.com/a/feeds/group/2.0/domain/'.$group_id.'/owner';
+  $url = 'https://apps-apis.google.com/a/feeds/group/2.0/domain/' . $group_id . '/owner';
+  $header = "Authorization: GoogleLogin auth=" . $auth;
+  $header = $header . "\nContent-type: application/atom+xml";
+  $header = $header . "\nContent-Length :" . strlen($data);
 
-
- $header="Authorization: GoogleLogin auth=".$auth;
-  $header=$header."\nContent-type: application/atom+xml";
-  $header=$header."\nContent-Length :".strlen($data);
-
   $ch = curl_init();
-  curl_setopt($ch, CURLOPT_URL,$url);
-  curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
+  curl_setopt($ch, CURLOPT_URL, $url);
+  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
   curl_setopt($ch, CURLOPT_HTTPHEADER, array($header));
   curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
   curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, $proxy_exist);
@@ -2104,187 +1789,154 @@
   curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
   curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,  2);
   $result = curl_exec($ch);
-  $code= curl_getinfo($ch, CURLINFO_HTTP_CODE);
+  $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
 
+  if ($code) {
+    switch ($code) {
+      case 200:
+      case 201:
+      case 202:
+        drupal_set_message('group owner  Added');
+        break;
+      case 400:
+        drupal_set_message('Error 400');
+        break;
+      case 415:
+        drupal_set_message('Error 415');
+        break;
 
-
-      if ($code) {
-
-        switch ($code) {
-          case 200:
-          case 201:
-          case 202:
-            drupal_set_message('group owner  Added');
-            break;
-          case 400:
-              drupal_set_message('Error 400');
-              break;
-         case 415:
-              drupal_set_message('Error 415');
-              break;
-
-          default;
-            watchdog('drupalgapps', t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), WATCHDOG_WARNING);
-            drupal_set_message(t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), 'error');
-            return FALSE;
-        }
-      }
-      else {
-        watchdog('drupalgapps', t('The HTTPS request to Google seems to be broken like hell  (unknown error).'), WATCHDOG_WARNING);
-        drupal_set_message(t('The HTTPS request to Google seems to be broken like hell (unknown error).'), 'error');
+      default;
+        watchdog('drupalgapps', t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), WATCHDOG_WARNING);
+        drupal_set_message(t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), 'error');
         return FALSE;
-      }
+    }
+  }
+  else {
+    watchdog('drupalgapps', t('The HTTPS request to Google seems to be broken like hell  (unknown error).'), WATCHDOG_WARNING);
+    drupal_set_message(t('The HTTPS request to Google seems to be broken like hell (unknown error).'), 'error');
+    return FALSE;
+  }
 
-    watchdog('Google Apps','response code : '.$code, array(), WATCHDOG_CRITICAL, l(t('DrupalGapps Settings'), 'admin/settings/drupalgapps'));
-
-
-
+  watchdog('Google Apps', 'response code : ' . $code, array(), WATCHDOG_CRITICAL, l(t('DrupalGapps Settings'), 'admin/settings/drupalgapps'));
 }
 
 
-//Retrieving an Owner of a Group
+/**
+ * Retrieve an owner of a Google group.
+ */
+function drupalgapps_retrieve_group_owner($group_id) {
+  $auth = variable_get('gapps_prov_api_auth_token', '');
+  $proxy_add = variable_get('gapps_proxy', '');
 
-function drupalgapps_retrieve_group_owner($group_id)
-{
+  if ($proxy_add) {
+    $proxy_exist = 1;
+  }
+  else {
+    $proxy_exist = 0;
+  }
 
+  $url = 'https://apps-apis.google.com/a/feeds/group/2.0/domain/' . $group_id . '/owner';
+  $header = "Authorization: GoogleLogin auth=" . $auth;
 
-     $auth=variable_get('gapps_prov_api_auth_token','');    $proxy_add = variable_get('gapps_proxy','');
-
-if($proxy_add){
-         $proxy_exist=1;
-     }
-     else
-     {
-         $proxy_exist=0;
-     }
-
-
-
-    $url = 'https://apps-apis.google.com/a/feeds/group/2.0/domain/'.$group_id.'/owner';
-
-  $header="Authorization: GoogleLogin auth=".$auth;
-
-
   $ch = curl_init();
-  curl_setopt($ch, CURLOPT_URL,$url);
-  curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
-  curl_setopt($ch, CURLOPT_HTTPGET,TRUE);
+  curl_setopt($ch, CURLOPT_URL, $url);
+  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+  curl_setopt($ch, CURLOPT_HTTPGET, TRUE);
   curl_setopt($ch, CURLOPT_HTTPHEADER, array($header));
   curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, $proxy_exist);
   curl_setopt($ch, CURLOPT_PROXY, $proxy_add);
   curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
   curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,  2);
+  $result = curl_exec($ch);
+  $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
 
-$result = curl_exec($ch);
+  if ($code) {
+    switch ($code) {
+      case 200:
+      case 201:
+      case 202:
+        drupal_set_message('Groups Retrieved');
+        break;
+      case 400:
+        drupal_set_message('Error 400');
+        break;
+      case 415:
+        drupal_set_message('Error 415');
+        break;
 
-  $code= curl_getinfo($ch, CURLINFO_HTTP_CODE);
-
-
-      if ($code) {
-
-        switch ($code) {
-          case 200:
-          case 201:
-          case 202:
-            drupal_set_message('Groups Retrieved');
-            break;
-          case 400:
-              drupal_set_message('Error 400');
-              break;
-         case 415:
-              drupal_set_message('Error 415');
-              break;
-
-          default;
-            watchdog('drupalgapps', t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), WATCHDOG_WARNING);
-            drupal_set_message(t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), 'error');
-            return FALSE;
-        }
-      }
-      else {
-        watchdog('drupalgapps', t('The HTTPS request to Google seems to be broken like hell  (unknown error).'), WATCHDOG_WARNING);
-        drupal_set_message(t('The HTTPS request to Google seems to be broken like hell (unknown error).'), 'error');
+      default;
+        watchdog('drupalgapps', t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), WATCHDOG_WARNING);
+        drupal_set_message(t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), 'error');
         return FALSE;
-      }
+    }
+  }
+  else {
+    watchdog('drupalgapps', t('The HTTPS request to Google seems to be broken like hell  (unknown error).'), WATCHDOG_WARNING);
+    drupal_set_message(t('The HTTPS request to Google seems to be broken like hell (unknown error).'), 'error');
+    return FALSE;
+  }
 
-    watchdog('Google Apps','response code : '.$code, array(), WATCHDOG_CRITICAL, l(t('DrupalGapps Settings'), 'admin/settings/drupalgapps'));
-
-
-
-
-return ;
+  watchdog('Google Apps', 'response code : ' . $code, array(), WATCHDOG_CRITICAL, l(t('DrupalGapps Settings'), 'admin/settings/drupalgapps'));
+  return;
 }
 
+/**
+ * Remove an owner from a Google group.
+ */
+function drupalgapps_delete_owner($group_id, $owner_email) {
+  $auth = variable_get('gapps_prov_api_auth_token', '');
+  $proxy_add = variable_get('gapps_proxy', '');
 
+  if ($proxy_add) {
+    $proxy_exist = 1;
+  }
+  else {
+    $proxy_exist = 0;
+  }
 
-//Removing an Owner from a Group
 
+  $url = 'https://apps-apis.google.com/a/feeds/group/2.0/domain/' . $group_id . '/owner/' . $owner_email;
+  $header = "Authorization: GoogleLogin auth=" . $auth;
 
-function drupalgapps_delete_owner($group_id,$owner_email)
-{
-
-
-     $auth=variable_get('gapps_prov_api_auth_token','');    $proxy_add = variable_get('gapps_proxy','');
-
-if($proxy_add){
-         $proxy_exist=1;
-     }
-     else
-     {
-         $proxy_exist=0;
-     }
-
-
-    $url = 'https://apps-apis.google.com/a/feeds/group/2.0/domain/'.$group_id.'/owner/'.$owner_email;
-
-$header="Authorization: GoogleLogin auth=".$auth;
-
-
-$ch = curl_init();
-  curl_setopt($ch, CURLOPT_URL,$url);
-  curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
+  $ch = curl_init();
+  curl_setopt($ch, CURLOPT_URL, $url);
+  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
   curl_setopt($ch, CURLOPT_HTTPHEADER, array($header));
   curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
-  curl_setopt($ch, CURLOPT_CUSTOMREQUEST,'DELETE');
+  curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
   curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, $proxy_exist);
   curl_setopt($ch, CURLOPT_PROXY, $proxy_add);
   curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
   curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,  2);
   $result = curl_exec($ch);
-  $code= curl_getinfo($ch, CURLINFO_HTTP_CODE);
+  $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
 
+  if ($code) {
+    switch ($code) {
+      case 200:
+      case 201:
+      case 202:
+        drupal_set_message('Group owner Deleted successful');
+        break;
+      case 400:
+        drupal_set_message('Error 400');
+        break;
+      case 415:
+        drupal_set_message('Error 415');
+        break;
 
-
-      if ($code) {
-
-        switch ($code) {
-          case 200:
-          case 201:
-          case 202:
-            drupal_set_message('Group owner Deleted successful');
-            break;
-          case 400:
-              drupal_set_message('Error 400');
-              break;
-         case 415:
-              drupal_set_message('Error 415');
-              break;
-
-          default;
-            watchdog('Google Apps', t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), WATCHDOG_WARNING);
-            drupal_set_message(t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), 'error');
-            return FALSE;
-        }
-      }
-      else {
-        watchdog('Google Apps', t('The HTTPS request to Google seems to be broken like hell  (unknown error).'), WATCHDOG_WARNING);
-        drupal_set_message(t('The HTTPS request to Google seems to be broken like hell (unknown error).'), 'error');
+      default;
+        watchdog('Google Apps', t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), WATCHDOG_WARNING);
+        drupal_set_message(t('The HTTPS request to Google seems to be broken (HTTP %code).', array('%code' => $httpresult->code)), 'error');
         return FALSE;
-      }
+    }
+  }
+  else {
+    watchdog('Google Apps', t('The HTTPS request to Google seems to be broken like hell  (unknown error).'), WATCHDOG_WARNING);
+    drupal_set_message(t('The HTTPS request to Google seems to be broken like hell (unknown error).'), 'error');
+    return FALSE;
+  }
 
-
-    watchdog('Google Apps','response code : '.$code, array(), WATCHDOG_CRITICAL, l(t('DrupalGapps Settings'), 'admin/settings/drupalgapps'));
-
-
+  watchdog('Google Apps', 'response code : ' . $code, array(), WATCHDOG_CRITICAL, l(t('DrupalGapps Settings'), 'admin/settings/drupalgapps'));
 }
 
