Passed
Push — 1.10.x ( 767d99...288426 )
by Yannick
44:51
created
main/auth/cas/lib/CAS/PGTStorage/pgt-db.php 4 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
   /**
63 63
    * This method returns the PEAR DB URL to use to connect to the database.
64 64
    *
65
-   * @return a PEAR DB URL
65
+   * @return string PEAR DB URL
66 66
    *
67 67
    * @private
68 68
    */
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
   /**
106 106
    * This method returns the name of the table where PGT's are stored.
107 107
    *
108
-   * @return the name of a table.
108
+   * @return string name of a table.
109 109
    *
110 110
    * @private
111 111
    */
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
    * This method returns an informational string giving the type of storage
123 123
    * used by the object (used for debugging purposes).
124 124
    *
125
-   * @return an informational string.
125
+   * @return string informational string.
126 126
    * @public
127 127
    */
128 128
   function getStorageType()
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
   /**
149 149
    * The class constructor, called by CASClient::SetPGTStorageDB().
150 150
    *
151
-   * @param $cas_parent the CASClient instance that creates the object.
151
+   * @param CASClient $cas_parent the CASClient instance that creates the object.
152 152
    * @param $user the user to access the data with
153 153
    * @param $password the user's password
154 154
    * @param $database_type the type of the database hosting the data
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
    * @hideinitializer
58 58
    * @private
59 59
    */
60
-  var $_url='';
60
+  var $_url = '';
61 61
 
62 62
   /**
63 63
    * This method returns the PEAR DB URL to use to connect to the database.
@@ -159,18 +159,18 @@  discard block
 block discarded – undo
159 159
    *
160 160
    * @public
161 161
    */
162
-  function PGTStorageDB($cas_parent,$user,$password,$database_type,$hostname,$port,$database,$table)
162
+  function PGTStorageDB($cas_parent, $user, $password, $database_type, $hostname, $port, $database, $table)
163 163
     {
164 164
       phpCAS::traceBegin();
165 165
 
166 166
       // call the ancestor's constructor
167 167
       $this->PGTStorage($cas_parent);
168 168
 
169
-      if ( empty($database_type) ) $database_type = CAS_PGT_STORAGE_DB_DEFAULT_DATABASE_TYPE;
170
-      if ( empty($hostname) ) $hostname = CAS_PGT_STORAGE_DB_DEFAULT_HOSTNAME;
171
-      if ( $port==0 ) $port = CAS_PGT_STORAGE_DB_DEFAULT_PORT;
172
-      if ( empty($database) ) $database = CAS_PGT_STORAGE_DB_DEFAULT_DATABASE;
173
-      if ( empty($table) ) $table = CAS_PGT_STORAGE_DB_DEFAULT_TABLE;
169
+      if (empty($database_type)) $database_type = CAS_PGT_STORAGE_DB_DEFAULT_DATABASE_TYPE;
170
+      if (empty($hostname)) $hostname = CAS_PGT_STORAGE_DB_DEFAULT_HOSTNAME;
171
+      if ($port == 0) $port = CAS_PGT_STORAGE_DB_DEFAULT_PORT;
172
+      if (empty($database)) $database = CAS_PGT_STORAGE_DB_DEFAULT_DATABASE;
173
+      if (empty($table)) $table = CAS_PGT_STORAGE_DB_DEFAULT_TABLE;
174 174
 
175 175
       // build and store the PEAR DB URL
176 176
       $this->_url = $database_type.':'.'//'.$user.':'.$password.'@'.$hostname.':'.$port.'/'.$database;
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
     {
193 193
       phpCAS::traceBegin();
194 194
       // if the storage has already been initialized, return immediatly
195
-      if ( $this->isInitialized() )
195
+      if ($this->isInitialized())
196 196
 		return;
197 197
       // call the ancestor's method (mark as initialized)
198 198
       parent::init();
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 
206 206
       // try to connect to the database
207 207
       $this->_link = DB::connect($this->getURL());
208
-      if ( DB::isError($this->_link) ) {
208
+      if (DB::isError($this->_link)) {
209 209
 	phpCAS::error('could not connect to database ('.DB::errorMessage($this->_link).')');
210 210
       }
211 211
       var_dump($this->_link);
Please login to merge, or discard this patch.
Braces   +18 added lines, -7 removed lines patch added patch discarded remove patch
@@ -166,11 +166,21 @@  discard block
 block discarded – undo
166 166
       // call the ancestor's constructor
167 167
       $this->PGTStorage($cas_parent);
168 168
 
169
-      if ( empty($database_type) ) $database_type = CAS_PGT_STORAGE_DB_DEFAULT_DATABASE_TYPE;
170
-      if ( empty($hostname) ) $hostname = CAS_PGT_STORAGE_DB_DEFAULT_HOSTNAME;
171
-      if ( $port==0 ) $port = CAS_PGT_STORAGE_DB_DEFAULT_PORT;
172
-      if ( empty($database) ) $database = CAS_PGT_STORAGE_DB_DEFAULT_DATABASE;
173
-      if ( empty($table) ) $table = CAS_PGT_STORAGE_DB_DEFAULT_TABLE;
169
+      if ( empty($database_type) ) {
170
+          $database_type = CAS_PGT_STORAGE_DB_DEFAULT_DATABASE_TYPE;
171
+      }
172
+      if ( empty($hostname) ) {
173
+          $hostname = CAS_PGT_STORAGE_DB_DEFAULT_HOSTNAME;
174
+      }
175
+      if ( $port==0 ) {
176
+          $port = CAS_PGT_STORAGE_DB_DEFAULT_PORT;
177
+      }
178
+      if ( empty($database) ) {
179
+          $database = CAS_PGT_STORAGE_DB_DEFAULT_DATABASE;
180
+      }
181
+      if ( empty($table) ) {
182
+          $table = CAS_PGT_STORAGE_DB_DEFAULT_TABLE;
183
+      }
174 184
 
175 185
       // build and store the PEAR DB URL
176 186
       $this->_url = $database_type.':'.'//'.$user.':'.$password.'@'.$hostname.':'.$port.'/'.$database;
@@ -192,8 +202,9 @@  discard block
 block discarded – undo
192 202
     {
193 203
       phpCAS::traceBegin();
194 204
       // if the storage has already been initialized, return immediatly
195
-      if ( $this->isInitialized() )
196
-		return;
205
+      if ( $this->isInitialized() ) {
206
+      		return;
207
+      }
197 208
       // call the ancestor's method (mark as initialized)
198 209
       parent::init();
199 210
       
Please login to merge, or discard this patch.
Indentation   +140 added lines, -140 removed lines patch added patch discarded remove patch
@@ -45,175 +45,175 @@
 block discarded – undo
45 45
 
46 46
 class PGTStorageDB extends PGTStorage
47 47
 {
48
-  /** 
49
-   * @addtogroup internalPGTStorageDB
50
-   * @{ 
51
-   */
52
-
53
-  /**
54
-   * a string representing a PEAR DB URL to connect to the database. Written by
55
-   * PGTStorageDB::PGTStorageDB(), read by getURL().
56
-   *
57
-   * @hideinitializer
58
-   * @private
59
-   */
60
-  var $_url='';
61
-
62
-  /**
63
-   * This method returns the PEAR DB URL to use to connect to the database.
64
-   *
65
-   * @return a PEAR DB URL
66
-   *
67
-   * @private
68
-   */
69
-  function getURL()
48
+    /** 
49
+     * @addtogroup internalPGTStorageDB
50
+     * @{ 
51
+     */
52
+
53
+    /**
54
+     * a string representing a PEAR DB URL to connect to the database. Written by
55
+     * PGTStorageDB::PGTStorageDB(), read by getURL().
56
+     *
57
+     * @hideinitializer
58
+     * @private
59
+     */
60
+    var $_url='';
61
+
62
+    /**
63
+     * This method returns the PEAR DB URL to use to connect to the database.
64
+     *
65
+     * @return a PEAR DB URL
66
+     *
67
+     * @private
68
+     */
69
+    function getURL()
70 70
     {
71
-      return $this->_url;
71
+        return $this->_url;
72 72
     }
73 73
 
74
-  /**
75
-   * The handle of the connection to the database where PGT's are stored. Written by
76
-   * PGTStorageDB::init(), read by getLink().
77
-   *
78
-   * @hideinitializer
79
-   * @private
80
-   */
81
-  var $_link = null;
82
-
83
-  /**
84
-   * This method returns the handle of the connection to the database where PGT's are 
85
-   * stored.
86
-   *
87
-   * @return a handle of connection.
88
-   *
89
-   * @private
90
-   */
91
-  function getLink()
74
+    /**
75
+     * The handle of the connection to the database where PGT's are stored. Written by
76
+     * PGTStorageDB::init(), read by getLink().
77
+     *
78
+     * @hideinitializer
79
+     * @private
80
+     */
81
+    var $_link = null;
82
+
83
+    /**
84
+     * This method returns the handle of the connection to the database where PGT's are 
85
+     * stored.
86
+     *
87
+     * @return a handle of connection.
88
+     *
89
+     * @private
90
+     */
91
+    function getLink()
92 92
     {
93
-      return $this->_link;
93
+        return $this->_link;
94 94
     }
95 95
 
96
-  /**
97
-   * The name of the table where PGT's are stored. Written by 
98
-   * PGTStorageDB::PGTStorageDB(), read by getTable().
99
-   *
100
-   * @hideinitializer
101
-   * @private
102
-   */
103
-  var $_table = '';
104
-
105
-  /**
106
-   * This method returns the name of the table where PGT's are stored.
107
-   *
108
-   * @return the name of a table.
109
-   *
110
-   * @private
111
-   */
112
-  function getTable()
96
+    /**
97
+     * The name of the table where PGT's are stored. Written by 
98
+     * PGTStorageDB::PGTStorageDB(), read by getTable().
99
+     *
100
+     * @hideinitializer
101
+     * @private
102
+     */
103
+    var $_table = '';
104
+
105
+    /**
106
+     * This method returns the name of the table where PGT's are stored.
107
+     *
108
+     * @return the name of a table.
109
+     *
110
+     * @private
111
+     */
112
+    function getTable()
113 113
     {
114
-      return $this->_table;
114
+        return $this->_table;
115 115
     }
116 116
 
117
-  // ########################################################################
118
-  //  DEBUGGING
119
-  // ########################################################################
117
+    // ########################################################################
118
+    //  DEBUGGING
119
+    // ########################################################################
120 120
   
121
-  /**
122
-   * This method returns an informational string giving the type of storage
123
-   * used by the object (used for debugging purposes).
124
-   *
125
-   * @return an informational string.
126
-   * @public
127
-   */
128
-  function getStorageType()
121
+    /**
122
+     * This method returns an informational string giving the type of storage
123
+     * used by the object (used for debugging purposes).
124
+     *
125
+     * @return an informational string.
126
+     * @public
127
+     */
128
+    function getStorageType()
129 129
     {
130
-      return "database";
130
+        return "database";
131 131
     }
132 132
 
133
-  /**
134
-   * This method returns an informational string giving informations on the
135
-   * parameters of the storage.(used for debugging purposes).
136
-   *
137
-   * @public
138
-   */
139
-  function getStorageInfo()
133
+    /**
134
+     * This method returns an informational string giving informations on the
135
+     * parameters of the storage.(used for debugging purposes).
136
+     *
137
+     * @public
138
+     */
139
+    function getStorageInfo()
140 140
     {
141
-      return 'url=`'.$this->getURL().'\', table=`'.$this->getTable().'\'';
141
+        return 'url=`'.$this->getURL().'\', table=`'.$this->getTable().'\'';
142 142
     }
143 143
 
144
-  // ########################################################################
145
-  //  CONSTRUCTOR
146
-  // ########################################################################
144
+    // ########################################################################
145
+    //  CONSTRUCTOR
146
+    // ########################################################################
147 147
   
148
-  /**
149
-   * The class constructor, called by CASClient::SetPGTStorageDB().
150
-   *
151
-   * @param $cas_parent the CASClient instance that creates the object.
152
-   * @param $user the user to access the data with
153
-   * @param $password the user's password
154
-   * @param $database_type the type of the database hosting the data
155
-   * @param $hostname the server hosting the database
156
-   * @param $port the port the server is listening on
157
-   * @param $database the name of the database
158
-   * @param $table the name of the table storing the data
159
-   *
160
-   * @public
161
-   */
162
-  function PGTStorageDB($cas_parent,$user,$password,$database_type,$hostname,$port,$database,$table)
148
+    /**
149
+     * The class constructor, called by CASClient::SetPGTStorageDB().
150
+     *
151
+     * @param $cas_parent the CASClient instance that creates the object.
152
+     * @param $user the user to access the data with
153
+     * @param $password the user's password
154
+     * @param $database_type the type of the database hosting the data
155
+     * @param $hostname the server hosting the database
156
+     * @param $port the port the server is listening on
157
+     * @param $database the name of the database
158
+     * @param $table the name of the table storing the data
159
+     *
160
+     * @public
161
+     */
162
+    function PGTStorageDB($cas_parent,$user,$password,$database_type,$hostname,$port,$database,$table)
163 163
     {
164
-      phpCAS::traceBegin();
164
+        phpCAS::traceBegin();
165 165
 
166
-      // call the ancestor's constructor
167
-      $this->PGTStorage($cas_parent);
166
+        // call the ancestor's constructor
167
+        $this->PGTStorage($cas_parent);
168 168
 
169
-      if ( empty($database_type) ) $database_type = CAS_PGT_STORAGE_DB_DEFAULT_DATABASE_TYPE;
170
-      if ( empty($hostname) ) $hostname = CAS_PGT_STORAGE_DB_DEFAULT_HOSTNAME;
171
-      if ( $port==0 ) $port = CAS_PGT_STORAGE_DB_DEFAULT_PORT;
172
-      if ( empty($database) ) $database = CAS_PGT_STORAGE_DB_DEFAULT_DATABASE;
173
-      if ( empty($table) ) $table = CAS_PGT_STORAGE_DB_DEFAULT_TABLE;
169
+        if ( empty($database_type) ) $database_type = CAS_PGT_STORAGE_DB_DEFAULT_DATABASE_TYPE;
170
+        if ( empty($hostname) ) $hostname = CAS_PGT_STORAGE_DB_DEFAULT_HOSTNAME;
171
+        if ( $port==0 ) $port = CAS_PGT_STORAGE_DB_DEFAULT_PORT;
172
+        if ( empty($database) ) $database = CAS_PGT_STORAGE_DB_DEFAULT_DATABASE;
173
+        if ( empty($table) ) $table = CAS_PGT_STORAGE_DB_DEFAULT_TABLE;
174 174
 
175
-      // build and store the PEAR DB URL
176
-      $this->_url = $database_type.':'.'//'.$user.':'.$password.'@'.$hostname.':'.$port.'/'.$database;
175
+        // build and store the PEAR DB URL
176
+        $this->_url = $database_type.':'.'//'.$user.':'.$password.'@'.$hostname.':'.$port.'/'.$database;
177 177
 
178
-      // XXX should use setURL and setTable
179
-      phpCAS::traceEnd();
178
+        // XXX should use setURL and setTable
179
+        phpCAS::traceEnd();
180 180
     }
181 181
   
182
-  // ########################################################################
183
-  //  INITIALIZATION
184
-  // ########################################################################
182
+    // ########################################################################
183
+    //  INITIALIZATION
184
+    // ########################################################################
185 185
   
186
-  /**
187
-   * This method is used to initialize the storage. Halts on error.
188
-   *
189
-   * @public
190
-   */
191
-  function init()
186
+    /**
187
+     * This method is used to initialize the storage. Halts on error.
188
+     *
189
+     * @public
190
+     */
191
+    function init()
192 192
     {
193
-      phpCAS::traceBegin();
194
-      // if the storage has already been initialized, return immediatly
195
-      if ( $this->isInitialized() )
196
-		return;
197
-      // call the ancestor's method (mark as initialized)
198
-      parent::init();
193
+        phpCAS::traceBegin();
194
+        // if the storage has already been initialized, return immediatly
195
+        if ( $this->isInitialized() )
196
+        return;
197
+        // call the ancestor's method (mark as initialized)
198
+        parent::init();
199 199
       
200
-	  //include phpDB library (the test was introduced in release 0.4.8 for 
201
-	  //the integration into Tikiwiki).
202
-	  if (!class_exists('DB')) {
203
-		include_once('DB.php');
204
-	  }
205
-
206
-      // try to connect to the database
207
-      $this->_link = DB::connect($this->getURL());
208
-      if ( DB::isError($this->_link) ) {
209
-	    phpCAS::error('could not connect to database ('.DB::errorMessage($this->_link).')');
210
-      }
211
-      // Dump into trace
212
-      var_dump($this->_link);
213
-      phpCAS::traceBEnd();
200
+        //include phpDB library (the test was introduced in release 0.4.8 for 
201
+        //the integration into Tikiwiki).
202
+        if (!class_exists('DB')) {
203
+        include_once('DB.php');
204
+        }
205
+
206
+        // try to connect to the database
207
+        $this->_link = DB::connect($this->getURL());
208
+        if ( DB::isError($this->_link) ) {
209
+        phpCAS::error('could not connect to database ('.DB::errorMessage($this->_link).')');
210
+        }
211
+        // Dump into trace
212
+        var_dump($this->_link);
213
+        phpCAS::traceBEnd();
214 214
     }
215 215
 
216
-  /** @} */
216
+    /** @} */
217 217
 }
218 218
 
219 219
 ?>
220 220
\ No newline at end of file
Please login to merge, or discard this patch.
main/auth/cas/lib/CAS/PGTStorage/pgt-file.php 5 patches
Doc Comments   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
    * This method returns an informational string giving the type of storage
99 99
    * used by the object (used for debugging purposes).
100 100
    *
101
-   * @return an informational string.
101
+   * @return string informational string.
102 102
    * @public
103 103
    */
104 104
   function getStorageType()
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
    * This method returns an informational string giving informations on the
111 111
    * parameters of the storage.(used for debugging purposes).
112 112
    *
113
-   * @return an informational string.
113
+   * @return string informational string.
114 114
    * @public
115 115
    */
116 116
   function getStorageInfo()
@@ -125,9 +125,9 @@  discard block
 block discarded – undo
125 125
   /**
126 126
    * The class constructor, called by CASClient::SetPGTStorageFile().
127 127
    *
128
-   * @param $cas_parent the CASClient instance that creates the object.
129
-   * @param $format the format used to store the PGT's (`plain' and `xml' allowed).
130
-   * @param $path the path where the PGT's should be stored
128
+   * @param CASClient $cas_parent the CASClient instance that creates the object.
129
+   * @param string $format the format used to store the PGT's (`plain' and `xml' allowed).
130
+   * @param string $path the path where the PGT's should be stored
131 131
    *
132 132
    * @public
133 133
    */
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
    *
203 203
    * @param $pgt_iou the PGT iou.
204 204
    *
205
-   * @return a filename
205
+   * @return string filename
206 206
    * @private
207 207
    */
208 208
   function getPGTIouFilename($pgt_iou)
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
    *
244 244
    * @param $pgt_iou the PGT iou
245 245
    *
246
-   * @return the corresponding PGT, or FALSE on error
246
+   * @return false|string corresponding PGT, or FALSE on error
247 247
    *
248 248
    * @public
249 249
    */
Please login to merge, or discard this patch.
Switch Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -163,12 +163,12 @@
 block discarded – undo
163 163
       $this->_path = $path;
164 164
       // check the format and store it
165 165
       switch ($format) {
166
-      case CAS_PGT_STORAGE_FILE_FORMAT_PLAIN:
167
-      case CAS_PGT_STORAGE_FILE_FORMAT_XML:
168
-	$this->_format = $format;
169
-	break;
170
-      default:
171
-	phpCAS::error('unknown PGT file storage format (`'.CAS_PGT_STORAGE_FILE_FORMAT_PLAIN.'\' and `'.CAS_PGT_STORAGE_FILE_FORMAT_XML.'\' allowed)');
166
+          case CAS_PGT_STORAGE_FILE_FORMAT_PLAIN:
167
+          case CAS_PGT_STORAGE_FILE_FORMAT_XML:
168
+	    $this->_format = $format;
169
+	    break;
170
+          default:
171
+	    phpCAS::error('unknown PGT file storage format (`'.CAS_PGT_STORAGE_FILE_FORMAT_PLAIN.'\' and `'.CAS_PGT_STORAGE_FILE_FORMAT_XML.'\' allowed)');
172 172
       }
173 173
       phpCAS::traceEnd();      
174 174
     }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -131,17 +131,17 @@  discard block
 block discarded – undo
131 131
    *
132 132
    * @public
133 133
    */
134
-  function PGTStorageFile($cas_parent,$format,$path)
134
+  function PGTStorageFile($cas_parent, $format, $path)
135 135
     {
136 136
       phpCAS::traceBegin();
137 137
       // call the ancestor's constructor
138 138
       $this->PGTStorage($cas_parent);
139 139
 
140
-      if (empty($format) ) $format = CAS_PGT_STORAGE_FILE_DEFAULT_FORMAT;
141
-      if (empty($path) ) $path = CAS_PGT_STORAGE_FILE_DEFAULT_PATH;
140
+      if (empty($format)) $format = CAS_PGT_STORAGE_FILE_DEFAULT_FORMAT;
141
+      if (empty($path)) $path = CAS_PGT_STORAGE_FILE_DEFAULT_PATH;
142 142
 
143 143
       // check that the path is an absolute path
144
-      if (getenv("OS")=="Windows_NT"){
144
+      if (getenv("OS") == "Windows_NT") {
145 145
       	
146 146
       	 if (!preg_match('`^[a-zA-Z]:`', $path)) {
147 147
 	     	phpCAS::error('an absolute path is needed for PGT storage to file');
@@ -151,13 +151,13 @@  discard block
 block discarded – undo
151 151
       else
152 152
       {
153 153
       
154
-      	if ( $path[0] != '/' ) {
154
+      	if ($path[0] != '/') {
155 155
 			phpCAS::error('an absolute path is needed for PGT storage to file');
156 156
       	}
157 157
 
158 158
       	// store the path (with a leading and trailing '/')      
159
-      	$path = preg_replace('|[/]*$|','/',$path);
160
-      	$path = preg_replace('|^[/]*|','/',$path);
159
+      	$path = preg_replace('|[/]*$|', '/', $path);
160
+      	$path = preg_replace('|^[/]*|', '/', $path);
161 161
       }
162 162
       
163 163
       $this->_path = $path;
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
     {
187 187
       phpCAS::traceBegin();
188 188
       // if the storage has already been initialized, return immediatly
189
-      if ( $this->isInitialized() )
189
+      if ($this->isInitialized())
190 190
 	return;
191 191
       // call the ancestor's method (mark as initialized)
192 192
       parent::init();
@@ -222,12 +222,12 @@  discard block
 block discarded – undo
222 222
    *
223 223
    * @public
224 224
    */
225
-  function write($pgt,$pgt_iou)
225
+  function write($pgt, $pgt_iou)
226 226
     {
227 227
       phpCAS::traceBegin();
228 228
       $fname = $this->getPGTIouFilename($pgt_iou);
229
-      if ( $f=fopen($fname,"w") ) {
230
-	if ( fputs($f,$pgt) === FALSE ) {
229
+      if ($f = fopen($fname, "w")) {
230
+	if (fputs($f, $pgt) === FALSE) {
231 231
 	  phpCAS::error('could not write PGT to `'.$fname.'\'');
232 232
 	}
233 233
 	fclose($f);
@@ -252,10 +252,10 @@  discard block
 block discarded – undo
252 252
       phpCAS::traceBegin();
253 253
       $pgt = FALSE;
254 254
       $fname = $this->getPGTIouFilename($pgt_iou);
255
-      if ( !($f=fopen($fname,"r")) ) {
255
+      if (!($f = fopen($fname, "r"))) {
256 256
 	phpCAS::trace('could not open `'.$fname.'\'');
257 257
       } else {
258
-	if ( ($pgt=fgets($f)) === FALSE ) {
258
+	if (($pgt = fgets($f)) === FALSE) {
259 259
 	  phpCAS::trace('could not read PGT from `'.$fname.'\'');
260 260
 	} 
261 261
 	fclose($f);
Please login to merge, or discard this patch.
Braces   +10 added lines, -6 removed lines patch added patch discarded remove patch
@@ -137,8 +137,12 @@  discard block
 block discarded – undo
137 137
       // call the ancestor's constructor
138 138
       $this->PGTStorage($cas_parent);
139 139
 
140
-      if (empty($format) ) $format = CAS_PGT_STORAGE_FILE_DEFAULT_FORMAT;
141
-      if (empty($path) ) $path = CAS_PGT_STORAGE_FILE_DEFAULT_PATH;
140
+      if (empty($format) ) {
141
+          $format = CAS_PGT_STORAGE_FILE_DEFAULT_FORMAT;
142
+      }
143
+      if (empty($path) ) {
144
+          $path = CAS_PGT_STORAGE_FILE_DEFAULT_PATH;
145
+      }
142 146
 
143 147
       // check that the path is an absolute path
144 148
       if (getenv("OS")=="Windows_NT"){
@@ -147,8 +151,7 @@  discard block
 block discarded – undo
147 151
 	     	phpCAS::error('an absolute path is needed for PGT storage to file');
148 152
       	}
149 153
       	
150
-      }
151
-      else
154
+      } else
152 155
       {
153 156
       
154 157
       	if ( $path[0] != '/' ) {
@@ -186,8 +189,9 @@  discard block
 block discarded – undo
186 189
     {
187 190
       phpCAS::traceBegin();
188 191
       // if the storage has already been initialized, return immediatly
189
-      if ( $this->isInitialized() )
190
-	return;
192
+      if ( $this->isInitialized() ) {
193
+      	return;
194
+      }
191 195
       // call the ancestor's method (mark as initialized)
192 196
       parent::init();
193 197
       phpCAS::traceEnd();      
Please login to merge, or discard this patch.
Indentation   +181 added lines, -181 removed lines patch added patch discarded remove patch
@@ -44,231 +44,231 @@
 block discarded – undo
44 44
 
45 45
 class PGTStorageFile extends PGTStorage
46 46
 {
47
-  /** 
48
-   * @addtogroup internalPGTStorageFile 
49
-   * @{ 
50
-   */
47
+    /** 
48
+     * @addtogroup internalPGTStorageFile 
49
+     * @{ 
50
+     */
51 51
 
52
-  /**
53
-   * a string telling where PGT's should be stored on the filesystem. Written by
54
-   * PGTStorageFile::PGTStorageFile(), read by getPath().
55
-   *
56
-   * @private
57
-   */
58
-  var $_path;
52
+    /**
53
+     * a string telling where PGT's should be stored on the filesystem. Written by
54
+     * PGTStorageFile::PGTStorageFile(), read by getPath().
55
+     *
56
+     * @private
57
+     */
58
+    var $_path;
59 59
 
60
-  /**
61
-   * This method returns the name of the directory where PGT's should be stored 
62
-   * on the filesystem.
63
-   *
64
-   * @return the name of a directory (with leading and trailing '/')
65
-   *
66
-   * @private
67
-   */
68
-  function getPath()
60
+    /**
61
+     * This method returns the name of the directory where PGT's should be stored 
62
+     * on the filesystem.
63
+     *
64
+     * @return the name of a directory (with leading and trailing '/')
65
+     *
66
+     * @private
67
+     */
68
+    function getPath()
69 69
     {
70
-      return $this->_path;
70
+        return $this->_path;
71 71
     }
72 72
 
73
-  /**
74
-   * a string telling the format to use to store PGT's (plain or xml). Written by
75
-   * PGTStorageFile::PGTStorageFile(), read by getFormat().
76
-   *
77
-   * @private
78
-   */
79
-  var $_format;
73
+    /**
74
+     * a string telling the format to use to store PGT's (plain or xml). Written by
75
+     * PGTStorageFile::PGTStorageFile(), read by getFormat().
76
+     *
77
+     * @private
78
+     */
79
+    var $_format;
80 80
 
81
-  /**
82
-   * This method returns the format to use when storing PGT's on the filesystem.
83
-   *
84
-   * @return a string corresponding to the format used (plain or xml).
85
-   *
86
-   * @private
87
-   */
88
-  function getFormat()
81
+    /**
82
+     * This method returns the format to use when storing PGT's on the filesystem.
83
+     *
84
+     * @return a string corresponding to the format used (plain or xml).
85
+     *
86
+     * @private
87
+     */
88
+    function getFormat()
89 89
     {
90
-      return $this->_format;
90
+        return $this->_format;
91 91
     }
92 92
 
93
-  // ########################################################################
94
-  //  DEBUGGING
95
-  // ########################################################################
93
+    // ########################################################################
94
+    //  DEBUGGING
95
+    // ########################################################################
96 96
   
97
-  /**
98
-   * This method returns an informational string giving the type of storage
99
-   * used by the object (used for debugging purposes).
100
-   *
101
-   * @return an informational string.
102
-   * @public
103
-   */
104
-  function getStorageType()
97
+    /**
98
+     * This method returns an informational string giving the type of storage
99
+     * used by the object (used for debugging purposes).
100
+     *
101
+     * @return an informational string.
102
+     * @public
103
+     */
104
+    function getStorageType()
105 105
     {
106
-      return "file";
106
+        return "file";
107 107
     }
108 108
 
109
-  /**
110
-   * This method returns an informational string giving informations on the
111
-   * parameters of the storage.(used for debugging purposes).
112
-   *
113
-   * @return an informational string.
114
-   * @public
115
-   */
116
-  function getStorageInfo()
109
+    /**
110
+     * This method returns an informational string giving informations on the
111
+     * parameters of the storage.(used for debugging purposes).
112
+     *
113
+     * @return an informational string.
114
+     * @public
115
+     */
116
+    function getStorageInfo()
117 117
     {
118
-      return 'path=`'.$this->getPath().'\', format=`'.$this->getFormat().'\'';
118
+        return 'path=`'.$this->getPath().'\', format=`'.$this->getFormat().'\'';
119 119
     }
120 120
 
121
-  // ########################################################################
122
-  //  CONSTRUCTOR
123
-  // ########################################################################
121
+    // ########################################################################
122
+    //  CONSTRUCTOR
123
+    // ########################################################################
124 124
   
125
-  /**
126
-   * The class constructor, called by CASClient::SetPGTStorageFile().
127
-   *
128
-   * @param $cas_parent the CASClient instance that creates the object.
129
-   * @param $format the format used to store the PGT's (`plain' and `xml' allowed).
130
-   * @param $path the path where the PGT's should be stored
131
-   *
132
-   * @public
133
-   */
134
-  function PGTStorageFile($cas_parent,$format,$path)
125
+    /**
126
+     * The class constructor, called by CASClient::SetPGTStorageFile().
127
+     *
128
+     * @param $cas_parent the CASClient instance that creates the object.
129
+     * @param $format the format used to store the PGT's (`plain' and `xml' allowed).
130
+     * @param $path the path where the PGT's should be stored
131
+     *
132
+     * @public
133
+     */
134
+    function PGTStorageFile($cas_parent,$format,$path)
135 135
     {
136
-      phpCAS::traceBegin();
137
-      // call the ancestor's constructor
138
-      $this->PGTStorage($cas_parent);
136
+        phpCAS::traceBegin();
137
+        // call the ancestor's constructor
138
+        $this->PGTStorage($cas_parent);
139 139
 
140
-      if (empty($format) ) $format = CAS_PGT_STORAGE_FILE_DEFAULT_FORMAT;
141
-      if (empty($path) ) $path = CAS_PGT_STORAGE_FILE_DEFAULT_PATH;
140
+        if (empty($format) ) $format = CAS_PGT_STORAGE_FILE_DEFAULT_FORMAT;
141
+        if (empty($path) ) $path = CAS_PGT_STORAGE_FILE_DEFAULT_PATH;
142 142
 
143
-      // check that the path is an absolute path
144
-      if (getenv("OS")=="Windows_NT"){
143
+        // check that the path is an absolute path
144
+        if (getenv("OS")=="Windows_NT"){
145 145
       	
146
-      	 if (!preg_match('`^[a-zA-Z]:`', $path)) {
147
-	     	phpCAS::error('an absolute path is needed for PGT storage to file');
148
-      	}
146
+            if (!preg_match('`^[a-zA-Z]:`', $path)) {
147
+                phpCAS::error('an absolute path is needed for PGT storage to file');
148
+            }
149 149
       	
150
-      }
151
-      else
152
-      {
150
+        }
151
+        else
152
+        {
153 153
       
154
-      	if ( $path[0] != '/' ) {
155
-			phpCAS::error('an absolute path is needed for PGT storage to file');
156
-      	}
154
+            if ( $path[0] != '/' ) {
155
+            phpCAS::error('an absolute path is needed for PGT storage to file');
156
+            }
157 157
 
158
-      	// store the path (with a leading and trailing '/')      
159
-      	$path = preg_replace('|[/]*$|','/',$path);
160
-      	$path = preg_replace('|^[/]*|','/',$path);
161
-      }
158
+            // store the path (with a leading and trailing '/')      
159
+            $path = preg_replace('|[/]*$|','/',$path);
160
+            $path = preg_replace('|^[/]*|','/',$path);
161
+        }
162 162
       
163
-      $this->_path = $path;
164
-      // check the format and store it
165
-      switch ($format) {
166
-      case CAS_PGT_STORAGE_FILE_FORMAT_PLAIN:
163
+        $this->_path = $path;
164
+        // check the format and store it
165
+        switch ($format) {
166
+        case CAS_PGT_STORAGE_FILE_FORMAT_PLAIN:
167 167
       case CAS_PGT_STORAGE_FILE_FORMAT_XML:
168
-	$this->_format = $format;
169
-	break;
170
-      default:
171
-	phpCAS::error('unknown PGT file storage format (`'.CAS_PGT_STORAGE_FILE_FORMAT_PLAIN.'\' and `'.CAS_PGT_STORAGE_FILE_FORMAT_XML.'\' allowed)');
172
-      }
173
-      phpCAS::traceEnd();      
168
+    $this->_format = $format;
169
+    break;
170
+        default:
171
+    phpCAS::error('unknown PGT file storage format (`'.CAS_PGT_STORAGE_FILE_FORMAT_PLAIN.'\' and `'.CAS_PGT_STORAGE_FILE_FORMAT_XML.'\' allowed)');
172
+        }
173
+        phpCAS::traceEnd();      
174 174
     }
175 175
 
176
-  // ########################################################################
177
-  //  INITIALIZATION
178
-  // ########################################################################
176
+    // ########################################################################
177
+    //  INITIALIZATION
178
+    // ########################################################################
179 179
   
180
-  /**
181
-   * This method is used to initialize the storage. Halts on error.
182
-   *
183
-   * @public
184
-   */
185
-  function init()
180
+    /**
181
+     * This method is used to initialize the storage. Halts on error.
182
+     *
183
+     * @public
184
+     */
185
+    function init()
186 186
     {
187
-      phpCAS::traceBegin();
188
-      // if the storage has already been initialized, return immediatly
189
-      if ( $this->isInitialized() )
190
-	return;
191
-      // call the ancestor's method (mark as initialized)
192
-      parent::init();
193
-      phpCAS::traceEnd();      
187
+        phpCAS::traceBegin();
188
+        // if the storage has already been initialized, return immediatly
189
+        if ( $this->isInitialized() )
190
+    return;
191
+        // call the ancestor's method (mark as initialized)
192
+        parent::init();
193
+        phpCAS::traceEnd();      
194 194
     }
195 195
 
196
-  // ########################################################################
197
-  //  PGT I/O
198
-  // ########################################################################
196
+    // ########################################################################
197
+    //  PGT I/O
198
+    // ########################################################################
199 199
 
200
-  /**
201
-   * This method returns the filename corresponding to a PGT Iou.
202
-   *
203
-   * @param $pgt_iou the PGT iou.
204
-   *
205
-   * @return a filename
206
-   * @private
207
-   */
208
-  function getPGTIouFilename($pgt_iou)
200
+    /**
201
+     * This method returns the filename corresponding to a PGT Iou.
202
+     *
203
+     * @param $pgt_iou the PGT iou.
204
+     *
205
+     * @return a filename
206
+     * @private
207
+     */
208
+    function getPGTIouFilename($pgt_iou)
209 209
     {
210
-      phpCAS::traceBegin();
211
-      $filename = $this->getPath().$pgt_iou.'.'.$this->getFormat();
212
-      phpCAS::traceEnd($filename);
213
-      return $filename;
210
+        phpCAS::traceBegin();
211
+        $filename = $this->getPath().$pgt_iou.'.'.$this->getFormat();
212
+        phpCAS::traceEnd($filename);
213
+        return $filename;
214 214
     }
215 215
   
216
-  /**
217
-   * This method stores a PGT and its corresponding PGT Iou into a file. Echoes a
218
-   * warning on error.
219
-   *
220
-   * @param $pgt the PGT
221
-   * @param $pgt_iou the PGT iou
222
-   *
223
-   * @public
224
-   */
225
-  function write($pgt,$pgt_iou)
216
+    /**
217
+     * This method stores a PGT and its corresponding PGT Iou into a file. Echoes a
218
+     * warning on error.
219
+     *
220
+     * @param $pgt the PGT
221
+     * @param $pgt_iou the PGT iou
222
+     *
223
+     * @public
224
+     */
225
+    function write($pgt,$pgt_iou)
226 226
     {
227
-      phpCAS::traceBegin();
228
-      $fname = $this->getPGTIouFilename($pgt_iou);
229
-      if ( $f=fopen($fname,"w") ) {
230
-	if ( fputs($f,$pgt) === FALSE ) {
231
-	  phpCAS::error('could not write PGT to `'.$fname.'\'');
232
-	}
233
-	fclose($f);
234
-      } else {
235
-	phpCAS::error('could not open `'.$fname.'\'');
236
-      }
237
-      phpCAS::traceEnd();      
227
+        phpCAS::traceBegin();
228
+        $fname = $this->getPGTIouFilename($pgt_iou);
229
+        if ( $f=fopen($fname,"w") ) {
230
+    if ( fputs($f,$pgt) === FALSE ) {
231
+        phpCAS::error('could not write PGT to `'.$fname.'\'');
232
+    }
233
+    fclose($f);
234
+        } else {
235
+    phpCAS::error('could not open `'.$fname.'\'');
236
+        }
237
+        phpCAS::traceEnd();      
238 238
     }
239 239
 
240
-  /**
241
-   * This method reads a PGT corresponding to a PGT Iou and deletes the 
242
-   * corresponding file.
243
-   *
244
-   * @param $pgt_iou the PGT iou
245
-   *
246
-   * @return the corresponding PGT, or FALSE on error
247
-   *
248
-   * @public
249
-   */
250
-  function read($pgt_iou)
240
+    /**
241
+     * This method reads a PGT corresponding to a PGT Iou and deletes the 
242
+     * corresponding file.
243
+     *
244
+     * @param $pgt_iou the PGT iou
245
+     *
246
+     * @return the corresponding PGT, or FALSE on error
247
+     *
248
+     * @public
249
+     */
250
+    function read($pgt_iou)
251 251
     {
252
-      phpCAS::traceBegin();
253
-      $pgt = FALSE;
254
-      $fname = $this->getPGTIouFilename($pgt_iou);
255
-      if ( !($f=fopen($fname,"r")) ) {
256
-	phpCAS::trace('could not open `'.$fname.'\'');
257
-      } else {
258
-	if ( ($pgt=fgets($f)) === FALSE ) {
259
-	  phpCAS::trace('could not read PGT from `'.$fname.'\'');
260
-	} 
261
-	fclose($f);
262
-      }
252
+        phpCAS::traceBegin();
253
+        $pgt = FALSE;
254
+        $fname = $this->getPGTIouFilename($pgt_iou);
255
+        if ( !($f=fopen($fname,"r")) ) {
256
+    phpCAS::trace('could not open `'.$fname.'\'');
257
+        } else {
258
+    if ( ($pgt=fgets($f)) === FALSE ) {
259
+        phpCAS::trace('could not read PGT from `'.$fname.'\'');
260
+    } 
261
+    fclose($f);
262
+        }
263 263
 
264
-      // delete the PGT file
265
-      @unlink($fname);
264
+        // delete the PGT file
265
+        @unlink($fname);
266 266
 
267
-      phpCAS::traceEnd($pgt);
268
-      return $pgt;
267
+        phpCAS::traceEnd($pgt);
268
+        return $pgt;
269 269
     }
270 270
   
271
-  /** @} */
271
+    /** @} */
272 272
   
273 273
 }
274 274
 
Please login to merge, or discard this patch.
main/auth/cas/lib/CAS/PGTStorage/pgt-main.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
   /**
127 127
    * This method returns an error message set by PGTStorage::setErrorMessage().
128 128
    *
129
-   * @return an error message when set by PGTStorage::setErrorMessage(), FALSE
129
+   * @return boolean error message when set by PGTStorage::setErrorMessage(), FALSE
130 130
    * otherwise.
131 131
    *
132 132
    * @public
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
   /**
154 154
    * This method tells if the storage has already been intialized.
155 155
    *
156
-   * @return a boolean
156
+   * @return boolean boolean
157 157
    *
158 158
    * @protected
159 159
    */
Please login to merge, or discard this patch.
Indentation   +131 added lines, -131 removed lines patch added patch discarded remove patch
@@ -44,167 +44,167 @@
 block discarded – undo
44 44
 
45 45
 class PGTStorage
46 46
 {
47
-  /** 
48
-   * @addtogroup internalPGTStorage
49
-   * @{ 
50
-   */
51
-
52
-  // ########################################################################
53
-  //  CONSTRUCTOR
54
-  // ########################################################################
47
+    /** 
48
+     * @addtogroup internalPGTStorage
49
+     * @{ 
50
+     */
51
+
52
+    // ########################################################################
53
+    //  CONSTRUCTOR
54
+    // ########################################################################
55 55
   
56
-  /**
57
-   * The constructor of the class, should be called only by inherited classes.
58
-   *
59
-   * @param $cas_parent the CASclient instance that creates the current object.
60
-   *
61
-   * @protected
62
-   */
63
-  function PGTStorage($cas_parent)
56
+    /**
57
+     * The constructor of the class, should be called only by inherited classes.
58
+     *
59
+     * @param $cas_parent the CASclient instance that creates the current object.
60
+     *
61
+     * @protected
62
+     */
63
+    function PGTStorage($cas_parent)
64 64
     {
65
-      phpCAS::traceBegin();
66
-      if ( !$cas_parent->isProxy() ) {
67
-	phpCAS::error('defining PGT storage makes no sense when not using a CAS proxy'); 
68
-      }
69
-      phpCAS::traceEnd();
65
+        phpCAS::traceBegin();
66
+        if ( !$cas_parent->isProxy() ) {
67
+    phpCAS::error('defining PGT storage makes no sense when not using a CAS proxy'); 
68
+        }
69
+        phpCAS::traceEnd();
70 70
     }
71 71
 
72
-  // ########################################################################
73
-  //  DEBUGGING
74
-  // ########################################################################
72
+    // ########################################################################
73
+    //  DEBUGGING
74
+    // ########################################################################
75 75
   
76
-  /**
77
-   * This virtual method returns an informational string giving the type of storage
78
-   * used by the object (used for debugging purposes).
79
-   *
80
-   * @public
81
-   */
82
-  function getStorageType()
76
+    /**
77
+     * This virtual method returns an informational string giving the type of storage
78
+     * used by the object (used for debugging purposes).
79
+     *
80
+     * @public
81
+     */
82
+    function getStorageType()
83 83
     {
84
-      phpCAS::error(__CLASS__.'::'.__FUNCTION__.'() should never be called'); 
84
+        phpCAS::error(__CLASS__.'::'.__FUNCTION__.'() should never be called'); 
85 85
     }
86 86
 
87
-  /**
88
-   * This virtual method returns an informational string giving informations on the
89
-   * parameters of the storage.(used for debugging purposes).
90
-   *
91
-   * @public
92
-   */
93
-  function getStorageInfo()
87
+    /**
88
+     * This virtual method returns an informational string giving informations on the
89
+     * parameters of the storage.(used for debugging purposes).
90
+     *
91
+     * @public
92
+     */
93
+    function getStorageInfo()
94 94
     {
95
-      phpCAS::error(__CLASS__.'::'.__FUNCTION__.'() should never be called'); 
95
+        phpCAS::error(__CLASS__.'::'.__FUNCTION__.'() should never be called'); 
96 96
     }
97 97
 
98
-  // ########################################################################
99
-  //  ERROR HANDLING
100
-  // ########################################################################
98
+    // ########################################################################
99
+    //  ERROR HANDLING
100
+    // ########################################################################
101 101
   
102
-  /**
103
-   * string used to store an error message. Written by PGTStorage::setErrorMessage(),
104
-   * read by PGTStorage::getErrorMessage().
105
-   *
106
-   * @hideinitializer
107
-   * @private
108
-   * @deprecated not used.
109
-   */
110
-  var $_error_message=FALSE;
111
-
112
-  /**
113
-   * This method sets en error message, which can be read later by 
114
-   * PGTStorage::getErrorMessage().
115
-   *
116
-   * @param $error_message an error message
117
-   *
118
-   * @protected
119
-   * @deprecated not used.
120
-   */
121
-  function setErrorMessage($error_message)
102
+    /**
103
+     * string used to store an error message. Written by PGTStorage::setErrorMessage(),
104
+     * read by PGTStorage::getErrorMessage().
105
+     *
106
+     * @hideinitializer
107
+     * @private
108
+     * @deprecated not used.
109
+     */
110
+    var $_error_message=FALSE;
111
+
112
+    /**
113
+     * This method sets en error message, which can be read later by 
114
+     * PGTStorage::getErrorMessage().
115
+     *
116
+     * @param $error_message an error message
117
+     *
118
+     * @protected
119
+     * @deprecated not used.
120
+     */
121
+    function setErrorMessage($error_message)
122 122
     {
123
-      $this->_error_message = $error_message;
123
+        $this->_error_message = $error_message;
124 124
     }
125 125
 
126
-  /**
127
-   * This method returns an error message set by PGTStorage::setErrorMessage().
128
-   *
129
-   * @return an error message when set by PGTStorage::setErrorMessage(), FALSE
130
-   * otherwise.
131
-   *
132
-   * @public
133
-   * @deprecated not used.
134
-   */
135
-  function getErrorMessage()
126
+    /**
127
+     * This method returns an error message set by PGTStorage::setErrorMessage().
128
+     *
129
+     * @return an error message when set by PGTStorage::setErrorMessage(), FALSE
130
+     * otherwise.
131
+     *
132
+     * @public
133
+     * @deprecated not used.
134
+     */
135
+    function getErrorMessage()
136 136
     {
137
-      return $this->_error_message;
137
+        return $this->_error_message;
138 138
     }
139 139
 
140
-  // ########################################################################
141
-  //  INITIALIZATION
142
-  // ########################################################################
143
-
144
-  /**
145
-   * a boolean telling if the storage has already been initialized. Written by 
146
-   * PGTStorage::init(), read by PGTStorage::isInitialized().
147
-   *
148
-   * @hideinitializer
149
-   * @private
150
-   */
151
-  var $_initialized = FALSE;
152
-
153
-  /**
154
-   * This method tells if the storage has already been intialized.
155
-   *
156
-   * @return a boolean
157
-   *
158
-   * @protected
159
-   */
160
-  function isInitialized()
140
+    // ########################################################################
141
+    //  INITIALIZATION
142
+    // ########################################################################
143
+
144
+    /**
145
+     * a boolean telling if the storage has already been initialized. Written by 
146
+     * PGTStorage::init(), read by PGTStorage::isInitialized().
147
+     *
148
+     * @hideinitializer
149
+     * @private
150
+     */
151
+    var $_initialized = FALSE;
152
+
153
+    /**
154
+     * This method tells if the storage has already been intialized.
155
+     *
156
+     * @return a boolean
157
+     *
158
+     * @protected
159
+     */
160
+    function isInitialized()
161 161
     {
162
-      return $this->_initialized;
162
+        return $this->_initialized;
163 163
     }
164 164
 
165
-  /**
166
-   * This virtual method initializes the object.
167
-   *
168
-   * @protected
169
-   */
170
-  function init()
165
+    /**
166
+     * This virtual method initializes the object.
167
+     *
168
+     * @protected
169
+     */
170
+    function init()
171 171
     {
172
-      $this->_initialized = TRUE;
172
+        $this->_initialized = TRUE;
173 173
     }
174 174
 
175
-  // ########################################################################
176
-  //  PGT I/O
177
-  // ########################################################################
178
-
179
-  /**
180
-   * This virtual method stores a PGT and its corresponding PGT Iuo.
181
-   * @note Should never be called.
182
-   *
183
-   * @param $pgt the PGT
184
-   * @param $pgt_iou the PGT iou
185
-   *
186
-   * @protected
187
-   */
188
-  function write($pgt,$pgt_iou)
175
+    // ########################################################################
176
+    //  PGT I/O
177
+    // ########################################################################
178
+
179
+    /**
180
+     * This virtual method stores a PGT and its corresponding PGT Iuo.
181
+     * @note Should never be called.
182
+     *
183
+     * @param $pgt the PGT
184
+     * @param $pgt_iou the PGT iou
185
+     *
186
+     * @protected
187
+     */
188
+    function write($pgt,$pgt_iou)
189 189
     {
190
-      phpCAS::error(__CLASS__.'::'.__FUNCTION__.'() should never be called'); 
190
+        phpCAS::error(__CLASS__.'::'.__FUNCTION__.'() should never be called'); 
191 191
     }
192 192
 
193
-  /**
194
-   * This virtual method reads a PGT corresponding to a PGT Iou and deletes
195
-   * the corresponding storage entry.
196
-   * @note Should never be called.
197
-   *
198
-   * @param $pgt_iou the PGT iou
199
-   *
200
-   * @protected
201
-   */
202
-  function read($pgt_iou)
193
+    /**
194
+     * This virtual method reads a PGT corresponding to a PGT Iou and deletes
195
+     * the corresponding storage entry.
196
+     * @note Should never be called.
197
+     *
198
+     * @param $pgt_iou the PGT iou
199
+     *
200
+     * @protected
201
+     */
202
+    function read($pgt_iou)
203 203
     {
204
-      phpCAS::error(__CLASS__.'::'.__FUNCTION__.'() should never be called'); 
204
+        phpCAS::error(__CLASS__.'::'.__FUNCTION__.'() should never be called'); 
205 205
     }
206 206
 
207
-  /** @} */
207
+    /** @} */
208 208
   
209 209
 } 
210 210
 
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
   function PGTStorage($cas_parent)
64 64
     {
65 65
       phpCAS::traceBegin();
66
-      if ( !$cas_parent->isProxy() ) {
66
+      if (!$cas_parent->isProxy()) {
67 67
 	phpCAS::error('defining PGT storage makes no sense when not using a CAS proxy'); 
68 68
       }
69 69
       phpCAS::traceEnd();
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
    * @private
108 108
    * @deprecated not used.
109 109
    */
110
-  var $_error_message=FALSE;
110
+  var $_error_message = FALSE;
111 111
 
112 112
   /**
113 113
    * This method sets en error message, which can be read later by 
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
    *
186 186
    * @protected
187 187
    */
188
-  function write($pgt,$pgt_iou)
188
+  function write($pgt, $pgt_iou)
189 189
     {
190 190
       phpCAS::error(__CLASS__.'::'.__FUNCTION__.'() should never be called'); 
191 191
     }
Please login to merge, or discard this patch.
main/auth/courses_controller.php 2 patches
Doc Comments   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,6 +33,7 @@  discard block
 block discarded – undo
33 33
      * render to courses_list view
34 34
      * @param string   	action
35 35
      * @param string    confirmation message(optional)
36
+     * @param string $action
36 37
      */
37 38
     public function courses_list($action, $message = '')
38 39
     {
@@ -79,7 +80,7 @@  discard block
 block discarded – undo
79 80
     /**
80 81
      * It's used for listing courses with categories,
81 82
      * render to courses_categories view
82
-     * @param $action
83
+     * @param string $action
83 84
      * @param string $category_code
84 85
      * @param string $message
85 86
      * @param string $error
Please login to merge, or discard this patch.
Spacing   +17 added lines, -18 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
      * @param string   $message confirmation message(optional)
62 62
      * @param string   $error error message(optional)
63 63
      */
64
-    public function categories_list($action, $message='', $error='')
64
+    public function categories_list($action, $message = '', $error = '')
65 65
     {
66 66
         $data = array();
67 67
         $data['user_course_categories'] = $this->model->get_user_course_categories();
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 
117 117
         // we need only the course codes as these will be used to match against the courses of the category
118 118
         if ($user_courses != '') {
119
-            foreach($user_courses as $key => $value) {
119
+            foreach ($user_courses as $key => $value) {
120 120
                 $user_coursecodes[] = $value['code'];
121 121
             }
122 122
         }
@@ -385,13 +385,13 @@  discard block
 block discarded – undo
385 385
                     $html .= '</strong>';
386 386
                 } else {
387 387
                     if (!empty($categoryCourses)) {
388
-                        $html .= '<a href="' . getCourseCategoryUrl(
388
+                        $html .= '<a href="'.getCourseCategoryUrl(
389 389
                                 1,
390 390
                                 $limit['length'],
391 391
                                 $categoryCode,
392 392
                                 $hiddenLinks,
393 393
                                 $action
394
-                            ) . '">';
394
+                            ).'">';
395 395
                         $html .= "$categoryName ($categoryCourses)";
396 396
                         $html .= '</a>';
397 397
                     } else {
@@ -412,13 +412,13 @@  discard block
 block discarded – undo
412 412
                         if ($code == $subCategory1Code) {
413 413
                             $html .= "<strong>$subCategory1Name ($subCategory1Courses)</strong>";
414 414
                         } else {
415
-                            $html .= '<a href="' . getCourseCategoryUrl(
415
+                            $html .= '<a href="'.getCourseCategoryUrl(
416 416
                                     1,
417 417
                                     $limit['length'],
418 418
                                     $categoryCode,
419 419
                                     $hiddenLinks,
420 420
                                     $action
421
-                                ) . '">';
421
+                                ).'">';
422 422
                             $html .= "$subCategory1Name ($subCategory1Courses)";
423 423
                             $html .= '</a>';
424 424
                         }
@@ -436,13 +436,13 @@  discard block
 block discarded – undo
436 436
                                 if ($code == $subCategory2Code) {
437 437
                                     $html .= "<strong>$subCategory2Name ($subCategory2Courses)</strong>";
438 438
                                 } else {
439
-                                    $html .= '<a href="' . getCourseCategoryUrl(
439
+                                    $html .= '<a href="'.getCourseCategoryUrl(
440 440
                                             1,
441 441
                                             $limit['length'],
442 442
                                             $categoryCode,
443 443
                                             $hiddenLinks,
444 444
                                             $action
445
-                                        ) . '">';
445
+                                        ).'">';
446 446
                                     $html .= "$subCategory2Name ($subCategory2Courses)";
447 447
                                     $html .= '</a>';
448 448
                                 }
@@ -460,13 +460,13 @@  discard block
 block discarded – undo
460 460
                                         if ($code == $subCategory3Code) {
461 461
                                             $html .= "<strong>$subCategory3Name ($subCategory3Courses)</strong>";
462 462
                                         } else {
463
-                                            $html .= '<a href="' . getCourseCategoryUrl(
463
+                                            $html .= '<a href="'.getCourseCategoryUrl(
464 464
                                                     1,
465 465
                                                     $limit['length'],
466 466
                                                     $categoryCode,
467 467
                                                     $hiddenLinks,
468 468
                                                     $action
469
-                                                ) . '">';
469
+                                                ).'">';
470 470
                                             $html .= "$subCategory3Name ($subCategory3Courses)";
471 471
                                             $html .= '</a>';
472 472
                                         }
@@ -593,7 +593,7 @@  discard block
 block discarded – undo
593 593
         $icon = '<em class="fa fa-smile-o"></em>';
594 594
 
595 595
         return Display::div(
596
-            $icon . ' ' . get_lang("AlreadyRegisteredToSession"),
596
+            $icon.' '.get_lang("AlreadyRegisteredToSession"),
597 597
             array('class' => 'info-catalog')
598 598
         );
599 599
     }
@@ -605,7 +605,7 @@  discard block
 block discarded – undo
605 605
      */
606 606
     public function getSessionIcon($sessionName)
607 607
     {
608
-        return Display::return_icon('window_list.png', $sessionName, null,ICON_SIZE_MEDIUM);
608
+        return Display::return_icon('window_list.png', $sessionName, null, ICON_SIZE_MEDIUM);
609 609
     }
610 610
 
611 611
     /**
@@ -626,8 +626,7 @@  discard block
 block discarded – undo
626 626
         $pageTotal = intval(ceil(intval($countSessions) / $limit['length']));
627 627
         // Do NOT show pagination if only one page or less
628 628
         $cataloguePagination = $pageTotal > 1 ?
629
-            getCataloguePagination($limit['current'], $limit['length'], $pageTotal) :
630
-            '';
629
+            getCataloguePagination($limit['current'], $limit['length'], $pageTotal) : '';
631 630
         $sessionsBlocks = $this->getFormatedSessionsBlock($sessions);
632 631
 
633 632
         // Get session list catalogue URL
@@ -638,13 +637,13 @@  discard block
 block discarded – undo
638 637
         $tpl = new Template();
639 638
         $tpl->assign('show_courses', CoursesAndSessionsCatalog::showCourses());
640 639
         $tpl->assign('show_sessions', CoursesAndSessionsCatalog::showSessions());
641
-        $tpl->assign('show_tutor', (api_get_setting('show_session_coach')==='true' ? true : false));
640
+        $tpl->assign('show_tutor', (api_get_setting('show_session_coach') === 'true' ? true : false));
642 641
         $tpl->assign('course_url', $courseUrl);
643 642
         $tpl->assign('catalog_pagination', $cataloguePagination);
644 643
         $tpl->assign('hidden_links', $hiddenLinks);
645 644
         $tpl->assign('search_token', Security::get_token());
646 645
         $tpl->assign('search_date', $date);
647
-        $tpl->assign('web_session_courses_ajax_url', api_get_path(WEB_AJAX_PATH) . 'course.ajax.php');
646
+        $tpl->assign('web_session_courses_ajax_url', api_get_path(WEB_AJAX_PATH).'course.ajax.php');
648 647
         $tpl->assign('sessions', $sessionsBlocks);
649 648
         $tpl->assign('already_subscribed_label', $this->getAlreadyRegisteredInSessionLabel());
650 649
 
@@ -671,7 +670,7 @@  discard block
 block discarded – undo
671 670
 
672 671
         $tpl->assign('show_courses', CoursesAndSessionsCatalog::showCourses());
673 672
         $tpl->assign('show_sessions', CoursesAndSessionsCatalog::showSessions());
674
-        $tpl->assign('show_tutor', (api_get_setting('show_session_coach')==='true' ? true : false));
673
+        $tpl->assign('show_tutor', (api_get_setting('show_session_coach') === 'true' ? true : false));
675 674
         $tpl->assign('course_url', $courseUrl);
676 675
         $tpl->assign('already_subscribed_label', $this->getAlreadyRegisteredInSessionLabel());
677 676
         $tpl->assign('hidden_links', $hiddenLinks);
@@ -702,7 +701,7 @@  discard block
 block discarded – undo
702 701
         $tpl = new Template();
703 702
         $tpl->assign('show_courses', CoursesAndSessionsCatalog::showCourses());
704 703
         $tpl->assign('show_sessions', CoursesAndSessionsCatalog::showSessions());
705
-        $tpl->assign('show_tutor', (api_get_setting('show_session_coach')==='true' ? true : false));
704
+        $tpl->assign('show_tutor', (api_get_setting('show_session_coach') === 'true' ? true : false));
706 705
         $tpl->assign('course_url', $courseUrl);
707 706
         $tpl->assign('already_subscribed_label', $this->getAlreadyRegisteredInSessionLabel());
708 707
         $tpl->assign('hidden_links', $hiddenLinks);
Please login to merge, or discard this patch.
auth/external_login/facebook-php-sdk/src/Facebook/Entities/AccessToken.php 3 patches
Doc Comments   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -62,6 +62,7 @@  discard block
 block discarded – undo
62 62
    * @param string $accessToken
63 63
    * @param int $expiresAt
64 64
    * @param string|null machineId
65
+   * @param string $machineId
65 66
    */
66 67
   public function __construct($accessToken, $expiresAt = 0, $machineId = null)
67 68
   {
@@ -97,7 +98,7 @@  discard block
 block discarded – undo
97 98
   /**
98 99
    * Getter for machineId.
99 100
    *
100
-   * @return string|null
101
+   * @return string
101 102
    */
102 103
   public function getMachineId()
103 104
   {
@@ -191,11 +192,11 @@  discard block
 block discarded – undo
191 192
   /**
192 193
    * Get a valid code from an access token.
193 194
    *
194
-   * @param AccessToken|string $accessToken
195
+   * @param AccessToken $accessToken
195 196
    * @param string|null $appId
196 197
    * @param string|null $appSecret
197 198
    *
198
-   * @return AccessToken
199
+   * @return string
199 200
    */
200 201
   public static function getCodeFromAccessToken($accessToken, $appId = null, $appSecret = null)
201 202
   {
Please login to merge, or discard this patch.
Indentation   +245 added lines, -245 removed lines patch added patch discarded remove patch
@@ -35,119 +35,119 @@  discard block
 block discarded – undo
35 35
 class AccessToken
36 36
 {
37 37
 
38
-  /**
39
-   * The access token.
40
-   *
41
-   * @var string
42
-   */
43
-  protected $accessToken;
44
-
45
-  /**
46
-   * A unique ID to identify a client.
47
-   *
48
-   * @var string
49
-   */
50
-  protected $machineId;
51
-
52
-  /**
53
-   * Date when token expires.
54
-   *
55
-   * @var \DateTime|null
56
-   */
57
-  protected $expiresAt;
58
-
59
-  /**
60
-   * Create a new access token entity.
61
-   *
62
-   * @param string $accessToken
63
-   * @param int $expiresAt
64
-   * @param string|null machineId
65
-   */
66
-  public function __construct($accessToken, $expiresAt = 0, $machineId = null)
67
-  {
38
+    /**
39
+     * The access token.
40
+     *
41
+     * @var string
42
+     */
43
+    protected $accessToken;
44
+
45
+    /**
46
+     * A unique ID to identify a client.
47
+     *
48
+     * @var string
49
+     */
50
+    protected $machineId;
51
+
52
+    /**
53
+     * Date when token expires.
54
+     *
55
+     * @var \DateTime|null
56
+     */
57
+    protected $expiresAt;
58
+
59
+    /**
60
+     * Create a new access token entity.
61
+     *
62
+     * @param string $accessToken
63
+     * @param int $expiresAt
64
+     * @param string|null machineId
65
+     */
66
+    public function __construct($accessToken, $expiresAt = 0, $machineId = null)
67
+    {
68 68
     $this->accessToken = $accessToken;
69 69
     if ($expiresAt) {
70
-      $this->setExpiresAtFromTimeStamp($expiresAt);
70
+        $this->setExpiresAtFromTimeStamp($expiresAt);
71 71
     }
72 72
     $this->machineId = $machineId;
73
-  }
74
-
75
-  /**
76
-   * Setter for expires_at.
77
-   *
78
-   * @param int $timeStamp
79
-   */
80
-  protected function setExpiresAtFromTimeStamp($timeStamp)
81
-  {
73
+    }
74
+
75
+    /**
76
+     * Setter for expires_at.
77
+     *
78
+     * @param int $timeStamp
79
+     */
80
+    protected function setExpiresAtFromTimeStamp($timeStamp)
81
+    {
82 82
     $dt = new \DateTime();
83 83
     $dt->setTimestamp($timeStamp);
84 84
     $this->expiresAt = $dt;
85
-  }
86
-
87
-  /**
88
-   * Getter for expiresAt.
89
-   *
90
-   * @return \DateTime|null
91
-   */
92
-  public function getExpiresAt()
93
-  {
85
+    }
86
+
87
+    /**
88
+     * Getter for expiresAt.
89
+     *
90
+     * @return \DateTime|null
91
+     */
92
+    public function getExpiresAt()
93
+    {
94 94
     return $this->expiresAt;
95
-  }
96
-
97
-  /**
98
-   * Getter for machineId.
99
-   *
100
-   * @return string|null
101
-   */
102
-  public function getMachineId()
103
-  {
95
+    }
96
+
97
+    /**
98
+     * Getter for machineId.
99
+     *
100
+     * @return string|null
101
+     */
102
+    public function getMachineId()
103
+    {
104 104
     return $this->machineId;
105
-  }
106
-
107
-  /**
108
-   * Determines whether or not this is a long-lived token.
109
-   *
110
-   * @return bool
111
-   */
112
-  public function isLongLived()
113
-  {
105
+    }
106
+
107
+    /**
108
+     * Determines whether or not this is a long-lived token.
109
+     *
110
+     * @return bool
111
+     */
112
+    public function isLongLived()
113
+    {
114 114
     if ($this->expiresAt) {
115
-      return $this->expiresAt->getTimestamp() > time() + (60 * 60 * 2);
115
+        return $this->expiresAt->getTimestamp() > time() + (60 * 60 * 2);
116 116
     }
117 117
     return false;
118
-  }
119
-
120
-  /**
121
-   * Checks the validity of the access token.
122
-   *
123
-   * @param string|null $appId Application ID to use
124
-   * @param string|null $appSecret App secret value to use
125
-   * @param string|null $machineId
126
-   *
127
-   * @return boolean
128
-   */
129
-  public function isValid($appId = null, $appSecret = null, $machineId = null)
130
-  {
118
+    }
119
+
120
+    /**
121
+     * Checks the validity of the access token.
122
+     *
123
+     * @param string|null $appId Application ID to use
124
+     * @param string|null $appSecret App secret value to use
125
+     * @param string|null $machineId
126
+     *
127
+     * @return boolean
128
+     */
129
+    public function isValid($appId = null, $appSecret = null, $machineId = null)
130
+    {
131 131
     $accessTokenInfo = $this->getInfo($appId, $appSecret);
132 132
     $machineId = $machineId ?: $this->machineId;
133 133
     return static::validateAccessToken($accessTokenInfo, $appId, $machineId);
134
-  }
135
-
136
-  /**
137
-   * Ensures the provided GraphSessionInfo object is valid,
138
-   *   throwing an exception if not.  Ensures the appId matches,
139
-   *   that the machineId matches if it's being used,
140
-   *   that the token is valid and has not expired.
141
-   *
142
-   * @param GraphSessionInfo $tokenInfo
143
-   * @param string|null $appId Application ID to use
144
-   * @param string|null $machineId
145
-   *
146
-   * @return boolean
147
-   */
148
-  public static function validateAccessToken(GraphSessionInfo $tokenInfo,
149
-                                             $appId = null, $machineId = null)
150
-  {
134
+    }
135
+
136
+    /**
137
+     * Ensures the provided GraphSessionInfo object is valid,
138
+     *   throwing an exception if not.  Ensures the appId matches,
139
+     *   that the machineId matches if it's being used,
140
+     *   that the token is valid and has not expired.
141
+     *
142
+     * @param GraphSessionInfo $tokenInfo
143
+     * @param string|null $appId Application ID to use
144
+     * @param string|null $machineId
145
+     *
146
+     * @return boolean
147
+     */
148
+    public static function validateAccessToken(GraphSessionInfo $tokenInfo,
149
+                                                $appId = null, $machineId = null)
150
+    {
151 151
     $targetAppId = FacebookSession::_getTargetAppId($appId);
152 152
 
153 153
     $appIdIsValid = $tokenInfo->getAppId() == $targetAppId;
@@ -156,90 +156,90 @@  discard block
 block discarded – undo
156 156
 
157 157
     // Not all access tokens return an expiration. E.g. an app access token.
158 158
     if ($tokenInfo->getExpiresAt() instanceof \DateTime) {
159
-      $accessTokenIsStillAlive = $tokenInfo->getExpiresAt()->getTimestamp() >= time();
159
+        $accessTokenIsStillAlive = $tokenInfo->getExpiresAt()->getTimestamp() >= time();
160 160
     } else {
161
-      $accessTokenIsStillAlive = true;
161
+        $accessTokenIsStillAlive = true;
162 162
     }
163 163
 
164 164
     return $appIdIsValid && $machineIdIsValid && $accessTokenIsValid && $accessTokenIsStillAlive;
165
-  }
166
-
167
-  /**
168
-   * Get a valid access token from a code.
169
-   *
170
-   * @param string $code
171
-   * @param string|null $appId
172
-   * @param string|null $appSecret
173
-   * @param string|null $machineId
174
-   *
175
-   * @return AccessToken
176
-   */
177
-  public static function getAccessTokenFromCode($code, $appId = null, $appSecret = null, $machineId = null)
178
-  {
165
+    }
166
+
167
+    /**
168
+     * Get a valid access token from a code.
169
+     *
170
+     * @param string $code
171
+     * @param string|null $appId
172
+     * @param string|null $appSecret
173
+     * @param string|null $machineId
174
+     *
175
+     * @return AccessToken
176
+     */
177
+    public static function getAccessTokenFromCode($code, $appId = null, $appSecret = null, $machineId = null)
178
+    {
179 179
     $params = array(
180
-      'code' => $code,
181
-      'redirect_uri' => '',
180
+        'code' => $code,
181
+        'redirect_uri' => '',
182 182
     );
183 183
 
184 184
     if ($machineId) {
185
-      $params['machine_id'] = $machineId;
185
+        $params['machine_id'] = $machineId;
186 186
     }
187 187
 
188 188
     return static::requestAccessToken($params, $appId, $appSecret);
189
-  }
190
-
191
-  /**
192
-   * Get a valid code from an access token.
193
-   *
194
-   * @param AccessToken|string $accessToken
195
-   * @param string|null $appId
196
-   * @param string|null $appSecret
197
-   *
198
-   * @return AccessToken
199
-   */
200
-  public static function getCodeFromAccessToken($accessToken, $appId = null, $appSecret = null)
201
-  {
189
+    }
190
+
191
+    /**
192
+     * Get a valid code from an access token.
193
+     *
194
+     * @param AccessToken|string $accessToken
195
+     * @param string|null $appId
196
+     * @param string|null $appSecret
197
+     *
198
+     * @return AccessToken
199
+     */
200
+    public static function getCodeFromAccessToken($accessToken, $appId = null, $appSecret = null)
201
+    {
202 202
     $accessToken = (string) $accessToken;
203 203
 
204 204
     $params = array(
205
-      'access_token' => $accessToken,
206
-      'redirect_uri' => '',
205
+        'access_token' => $accessToken,
206
+        'redirect_uri' => '',
207 207
     );
208 208
 
209 209
     return static::requestCode($params, $appId, $appSecret);
210
-  }
211
-
212
-  /**
213
-   * Exchanges a short lived access token with a long lived access token.
214
-   *
215
-   * @param string|null $appId
216
-   * @param string|null $appSecret
217
-   *
218
-   * @return AccessToken
219
-   */
220
-  public function extend($appId = null, $appSecret = null)
221
-  {
210
+    }
211
+
212
+    /**
213
+     * Exchanges a short lived access token with a long lived access token.
214
+     *
215
+     * @param string|null $appId
216
+     * @param string|null $appSecret
217
+     *
218
+     * @return AccessToken
219
+     */
220
+    public function extend($appId = null, $appSecret = null)
221
+    {
222 222
     $params = array(
223
-      'grant_type' => 'fb_exchange_token',
224
-      'fb_exchange_token' => $this->accessToken,
223
+        'grant_type' => 'fb_exchange_token',
224
+        'fb_exchange_token' => $this->accessToken,
225 225
     );
226 226
 
227 227
     return static::requestAccessToken($params, $appId, $appSecret);
228
-  }
229
-
230
-  /**
231
-   * Request an access token based on a set of params.
232
-   *
233
-   * @param array $params
234
-   * @param string|null $appId
235
-   * @param string|null $appSecret
236
-   *
237
-   * @return AccessToken
238
-   *
239
-   * @throws FacebookRequestException
240
-   */
241
-  public static function requestAccessToken(array $params, $appId = null, $appSecret = null)
242
-  {
228
+    }
229
+
230
+    /**
231
+     * Request an access token based on a set of params.
232
+     *
233
+     * @param array $params
234
+     * @param string|null $appId
235
+     * @param string|null $appSecret
236
+     *
237
+     * @return AccessToken
238
+     *
239
+     * @throws FacebookRequestException
240
+     */
241
+    public static function requestAccessToken(array $params, $appId = null, $appSecret = null)
242
+    {
243 243
     $response = static::request('/oauth/access_token', $params, $appId, $appSecret);
244 244
     $data = $response->getResponse();
245 245
 
@@ -248,133 +248,133 @@  discard block
 block discarded – undo
248 248
      * @see https://github.com/facebook/facebook-php-sdk-v4/issues/36
249 249
      */
250 250
     if (is_array($data)) {
251
-      if (isset($data['access_token'])) {
251
+        if (isset($data['access_token'])) {
252 252
         $expiresAt = isset($data['expires']) ? time() + $data['expires'] : 0;
253 253
         return new static($data['access_token'], $expiresAt);
254
-      }
254
+        }
255 255
     } elseif($data instanceof \stdClass) {
256
-      if (isset($data->access_token)) {
256
+        if (isset($data->access_token)) {
257 257
         $expiresAt = isset($data->expires_in) ? time() + $data->expires_in : 0;
258 258
         $machineId = isset($data->machine_id) ? (string) $data->machine_id : null;
259 259
         return new static((string) $data->access_token, $expiresAt, $machineId);
260
-      }
260
+        }
261 261
     }
262 262
 
263 263
     throw FacebookRequestException::create(
264
-      $response->getRawResponse(),
265
-      $data,
266
-      401
264
+        $response->getRawResponse(),
265
+        $data,
266
+        401
267 267
     );
268
-  }
269
-
270
-  /**
271
-   * Request a code from a long lived access token.
272
-   *
273
-   * @param array $params
274
-   * @param string|null $appId
275
-   * @param string|null $appSecret
276
-   *
277
-   * @return string
278
-   *
279
-   * @throws FacebookRequestException
280
-   */
281
-  public static function requestCode(array $params, $appId = null, $appSecret = null)
282
-  {
268
+    }
269
+
270
+    /**
271
+     * Request a code from a long lived access token.
272
+     *
273
+     * @param array $params
274
+     * @param string|null $appId
275
+     * @param string|null $appSecret
276
+     *
277
+     * @return string
278
+     *
279
+     * @throws FacebookRequestException
280
+     */
281
+    public static function requestCode(array $params, $appId = null, $appSecret = null)
282
+    {
283 283
     $response = static::request('/oauth/client_code', $params, $appId, $appSecret);
284 284
     $data = $response->getResponse();
285 285
 
286 286
     if (isset($data->code)) {
287
-      return (string) $data->code;
287
+        return (string) $data->code;
288 288
     }
289 289
 
290 290
     throw FacebookRequestException::create(
291
-      $response->getRawResponse(),
292
-      $data,
293
-      401
291
+        $response->getRawResponse(),
292
+        $data,
293
+        401
294 294
     );
295
-  }
296
-
297
-  /**
298
-   * Send a request to Graph with an app access token.
299
-   *
300
-   * @param string $endpoint
301
-   * @param array $params
302
-   * @param string|null $appId
303
-   * @param string|null $appSecret
304
-   *
305
-   * @return \Facebook\FacebookResponse
306
-   *
307
-   * @throws FacebookRequestException
308
-   */
309
-  protected static function request($endpoint, array $params, $appId = null, $appSecret = null)
310
-  {
295
+    }
296
+
297
+    /**
298
+     * Send a request to Graph with an app access token.
299
+     *
300
+     * @param string $endpoint
301
+     * @param array $params
302
+     * @param string|null $appId
303
+     * @param string|null $appSecret
304
+     *
305
+     * @return \Facebook\FacebookResponse
306
+     *
307
+     * @throws FacebookRequestException
308
+     */
309
+    protected static function request($endpoint, array $params, $appId = null, $appSecret = null)
310
+    {
311 311
     $targetAppId = FacebookSession::_getTargetAppId($appId);
312 312
     $targetAppSecret = FacebookSession::_getTargetAppSecret($appSecret);
313 313
 
314 314
     if (!isset($params['client_id'])) {
315
-      $params['client_id'] = $targetAppId;
315
+        $params['client_id'] = $targetAppId;
316 316
     }
317 317
     if (!isset($params['client_secret'])) {
318
-      $params['client_secret'] = $targetAppSecret;
318
+        $params['client_secret'] = $targetAppSecret;
319 319
     }
320 320
 
321 321
     // The response for this endpoint is not JSON, so it must be handled
322 322
     //   differently, not as a GraphObject.
323 323
     $request = new FacebookRequest(
324
-      FacebookSession::newAppSession($targetAppId, $targetAppSecret),
325
-      'GET',
326
-      $endpoint,
327
-      $params
324
+        FacebookSession::newAppSession($targetAppId, $targetAppSecret),
325
+        'GET',
326
+        $endpoint,
327
+        $params
328 328
     );
329 329
     return $request->execute();
330
-  }
331
-
332
-  /**
333
-   * Get more info about an access token.
334
-   *
335
-   * @param string|null $appId
336
-   * @param string|null $appSecret
337
-   *
338
-   * @return GraphSessionInfo
339
-   */
340
-  public function getInfo($appId = null, $appSecret = null)
341
-  {
330
+    }
331
+
332
+    /**
333
+     * Get more info about an access token.
334
+     *
335
+     * @param string|null $appId
336
+     * @param string|null $appSecret
337
+     *
338
+     * @return GraphSessionInfo
339
+     */
340
+    public function getInfo($appId = null, $appSecret = null)
341
+    {
342 342
     $params = array('input_token' => $this->accessToken);
343 343
 
344 344
     $request = new FacebookRequest(
345
-      FacebookSession::newAppSession($appId, $appSecret),
346
-      'GET',
347
-      '/debug_token',
348
-      $params
345
+        FacebookSession::newAppSession($appId, $appSecret),
346
+        'GET',
347
+        '/debug_token',
348
+        $params
349 349
     );
350 350
     $response = $request->execute()->getGraphObject(GraphSessionInfo::className());
351 351
 
352 352
     // Update the data on this token
353 353
     if ($response->getExpiresAt()) {
354
-      $this->expiresAt = $response->getExpiresAt();
354
+        $this->expiresAt = $response->getExpiresAt();
355 355
     }
356 356
 
357 357
     return $response;
358
-  }
359
-
360
-  /**
361
-   * Returns the access token as a string.
362
-   *
363
-   * @return string
364
-   */
365
-  public function __toString()
366
-  {
358
+    }
359
+
360
+    /**
361
+     * Returns the access token as a string.
362
+     *
363
+     * @return string
364
+     */
365
+    public function __toString()
366
+    {
367 367
     return $this->accessToken;
368
-  }
369
-
370
-  /**
371
-   * Returns true if the access token is an app session token.
372
-   *
373
-   * @return bool
374
-   */
375
-  public function isAppSession()
376
-  {
368
+    }
369
+
370
+    /**
371
+     * Returns true if the access token is an app session token.
372
+     *
373
+     * @return bool
374
+     */
375
+    public function isAppSession()
376
+    {
377 377
     return strpos($this->accessToken, "|") !== false;
378
-  }
378
+    }
379 379
 
380 380
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -252,7 +252,7 @@
 block discarded – undo
252 252
         $expiresAt = isset($data['expires']) ? time() + $data['expires'] : 0;
253 253
         return new static($data['access_token'], $expiresAt);
254 254
       }
255
-    } elseif($data instanceof \stdClass) {
255
+    } elseif ($data instanceof \stdClass) {
256 256
       if (isset($data->access_token)) {
257 257
         $expiresAt = isset($data->expires_in) ? time() + $data->expires_in : 0;
258 258
         $machineId = isset($data->machine_id) ? (string) $data->machine_id : null;
Please login to merge, or discard this patch.
external_login/facebook-php-sdk/src/Facebook/Entities/SignedRequest.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
   /**
64 64
    * Returns the raw signed request data.
65 65
    *
66
-   * @return string|null
66
+   * @return string
67 67
    */
68 68
   public function getRawSignedRequest()
69 69
   {
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
    * Returns a property from the signed request data if available.
85 85
    *
86 86
    * @param string $key
87
-   * @param mixed|null $default
87
+   * @param integer $default
88 88
    *
89 89
    * @return mixed|null
90 90
    */
Please login to merge, or discard this patch.
Indentation   +255 added lines, -255 removed lines patch added patch discarded remove patch
@@ -33,99 +33,99 @@  discard block
 block discarded – undo
33 33
 class SignedRequest
34 34
 {
35 35
 
36
-  /**
37
-   * @var string
38
-   */
39
-  public $rawSignedRequest;
40
-
41
-  /**
42
-   * @var array
43
-   */
44
-  public $payload;
45
-
46
-  /**
47
-   * Instantiate a new SignedRequest entity.
48
-   *
49
-   * @param string|null $rawSignedRequest The raw signed request.
50
-   * @param string|null $state random string to prevent CSRF.
51
-   * @param string|null $appSecret
52
-   */
53
-  public function __construct($rawSignedRequest = null, $state = null, $appSecret = null)
54
-  {
36
+    /**
37
+     * @var string
38
+     */
39
+    public $rawSignedRequest;
40
+
41
+    /**
42
+     * @var array
43
+     */
44
+    public $payload;
45
+
46
+    /**
47
+     * Instantiate a new SignedRequest entity.
48
+     *
49
+     * @param string|null $rawSignedRequest The raw signed request.
50
+     * @param string|null $state random string to prevent CSRF.
51
+     * @param string|null $appSecret
52
+     */
53
+    public function __construct($rawSignedRequest = null, $state = null, $appSecret = null)
54
+    {
55 55
     if (!$rawSignedRequest) {
56
-      return;
56
+        return;
57 57
     }
58 58
 
59 59
     $this->rawSignedRequest = $rawSignedRequest;
60 60
     $this->payload = static::parse($rawSignedRequest, $state, $appSecret);
61
-  }
62
-
63
-  /**
64
-   * Returns the raw signed request data.
65
-   *
66
-   * @return string|null
67
-   */
68
-  public function getRawSignedRequest()
69
-  {
61
+    }
62
+
63
+    /**
64
+     * Returns the raw signed request data.
65
+     *
66
+     * @return string|null
67
+     */
68
+    public function getRawSignedRequest()
69
+    {
70 70
     return $this->rawSignedRequest;
71
-  }
72
-
73
-  /**
74
-   * Returns the parsed signed request data.
75
-   *
76
-   * @return array|null
77
-   */
78
-  public function getPayload()
79
-  {
71
+    }
72
+
73
+    /**
74
+     * Returns the parsed signed request data.
75
+     *
76
+     * @return array|null
77
+     */
78
+    public function getPayload()
79
+    {
80 80
     return $this->payload;
81
-  }
82
-
83
-  /**
84
-   * Returns a property from the signed request data if available.
85
-   *
86
-   * @param string $key
87
-   * @param mixed|null $default
88
-   *
89
-   * @return mixed|null
90
-   */
91
-  public function get($key, $default = null)
92
-  {
81
+    }
82
+
83
+    /**
84
+     * Returns a property from the signed request data if available.
85
+     *
86
+     * @param string $key
87
+     * @param mixed|null $default
88
+     *
89
+     * @return mixed|null
90
+     */
91
+    public function get($key, $default = null)
92
+    {
93 93
     if (isset($this->payload[$key])) {
94
-      return $this->payload[$key];
94
+        return $this->payload[$key];
95 95
     }
96 96
     return $default;
97
-  }
98
-
99
-  /**
100
-   * Returns user_id from signed request data if available.
101
-   *
102
-   * @return string|null
103
-   */
104
-  public function getUserId()
105
-  {
97
+    }
98
+
99
+    /**
100
+     * Returns user_id from signed request data if available.
101
+     *
102
+     * @return string|null
103
+     */
104
+    public function getUserId()
105
+    {
106 106
     return $this->get('user_id');
107
-  }
108
-
109
-  /**
110
-   * Checks for OAuth data in the payload.
111
-   *
112
-   * @return boolean
113
-   */
114
-  public function hasOAuthData()
115
-  {
107
+    }
108
+
109
+    /**
110
+     * Checks for OAuth data in the payload.
111
+     *
112
+     * @return boolean
113
+     */
114
+    public function hasOAuthData()
115
+    {
116 116
     return isset($this->payload['oauth_token']) || isset($this->payload['code']);
117
-  }
118
-
119
-  /**
120
-   * Creates a signed request from an array of data.
121
-   *
122
-   * @param array $payload
123
-   * @param string|null $appSecret
124
-   *
125
-   * @return string
126
-   */
127
-  public static function make(array $payload, $appSecret = null)
128
-  {
117
+    }
118
+
119
+    /**
120
+     * Creates a signed request from an array of data.
121
+     *
122
+     * @param array $payload
123
+     * @param string|null $appSecret
124
+     *
125
+     * @return string
126
+     */
127
+    public static function make(array $payload, $appSecret = null)
128
+    {
129 129
     $payload['algorithm'] = 'HMAC-SHA256';
130 130
     $payload['issued_at'] = time();
131 131
     $encodedPayload = static::base64UrlEncode(json_encode($payload));
@@ -134,20 +134,20 @@  discard block
 block discarded – undo
134 134
     $encodedSig = static::base64UrlEncode($hashedSig);
135 135
 
136 136
     return $encodedSig.'.'.$encodedPayload;
137
-  }
138
-
139
-  /**
140
-   * Validates and decodes a signed request and returns
141
-   * the payload as an array.
142
-   *
143
-   * @param string $signedRequest
144
-   * @param string|null $state
145
-   * @param string|null $appSecret
146
-   *
147
-   * @return array
148
-   */
149
-  public static function parse($signedRequest, $state = null, $appSecret = null)
150
-  {
137
+    }
138
+
139
+    /**
140
+     * Validates and decodes a signed request and returns
141
+     * the payload as an array.
142
+     *
143
+     * @param string $signedRequest
144
+     * @param string|null $state
145
+     * @param string|null $appSecret
146
+     *
147
+     * @return array
148
+     */
149
+    public static function parse($signedRequest, $state = null, $appSecret = null)
150
+    {
151 151
     list($encodedSig, $encodedPayload) = static::split($signedRequest);
152 152
 
153 153
     // Signature validation
@@ -159,228 +159,228 @@  discard block
 block discarded – undo
159 159
     $data = static::decodePayload($encodedPayload);
160 160
     static::validateAlgorithm($data);
161 161
     if ($state) {
162
-      static::validateCsrf($data, $state);
162
+        static::validateCsrf($data, $state);
163 163
     }
164 164
 
165 165
     return $data;
166
-  }
167
-
168
-  /**
169
-   * Validates the format of a signed request.
170
-   *
171
-   * @param string $signedRequest
172
-   *
173
-   * @throws FacebookSDKException
174
-   */
175
-  public static function validateFormat($signedRequest)
176
-  {
166
+    }
167
+
168
+    /**
169
+     * Validates the format of a signed request.
170
+     *
171
+     * @param string $signedRequest
172
+     *
173
+     * @throws FacebookSDKException
174
+     */
175
+    public static function validateFormat($signedRequest)
176
+    {
177 177
     if (strpos($signedRequest, '.') !== false) {
178
-      return;
178
+        return;
179 179
     }
180 180
 
181 181
     throw new FacebookSDKException(
182
-      'Malformed signed request.', 606
182
+        'Malformed signed request.', 606
183 183
     );
184
-  }
185
-
186
-  /**
187
-   * Decodes a raw valid signed request.
188
-   *
189
-   * @param string $signedRequest
190
-   *
191
-   * @returns array
192
-   */
193
-  public static function split($signedRequest)
194
-  {
184
+    }
185
+
186
+    /**
187
+     * Decodes a raw valid signed request.
188
+     *
189
+     * @param string $signedRequest
190
+     *
191
+     * @returns array
192
+     */
193
+    public static function split($signedRequest)
194
+    {
195 195
     static::validateFormat($signedRequest);
196 196
 
197 197
     return explode('.', $signedRequest, 2);
198
-  }
199
-
200
-  /**
201
-   * Decodes the raw signature from a signed request.
202
-   *
203
-   * @param string $encodedSig
204
-   *
205
-   * @returns string
206
-   *
207
-   * @throws FacebookSDKException
208
-   */
209
-  public static function decodeSignature($encodedSig)
210
-  {
198
+    }
199
+
200
+    /**
201
+     * Decodes the raw signature from a signed request.
202
+     *
203
+     * @param string $encodedSig
204
+     *
205
+     * @returns string
206
+     *
207
+     * @throws FacebookSDKException
208
+     */
209
+    public static function decodeSignature($encodedSig)
210
+    {
211 211
     $sig = static::base64UrlDecode($encodedSig);
212 212
 
213 213
     if ($sig) {
214
-      return $sig;
214
+        return $sig;
215 215
     }
216 216
 
217 217
     throw new FacebookSDKException(
218
-      'Signed request has malformed encoded signature data.', 607
218
+        'Signed request has malformed encoded signature data.', 607
219 219
     );
220
-  }
221
-
222
-  /**
223
-   * Decodes the raw payload from a signed request.
224
-   *
225
-   * @param string $encodedPayload
226
-   *
227
-   * @returns array
228
-   *
229
-   * @throws FacebookSDKException
230
-   */
231
-  public static function decodePayload($encodedPayload)
232
-  {
220
+    }
221
+
222
+    /**
223
+     * Decodes the raw payload from a signed request.
224
+     *
225
+     * @param string $encodedPayload
226
+     *
227
+     * @returns array
228
+     *
229
+     * @throws FacebookSDKException
230
+     */
231
+    public static function decodePayload($encodedPayload)
232
+    {
233 233
     $payload = static::base64UrlDecode($encodedPayload);
234 234
 
235 235
     if ($payload) {
236
-      $payload = json_decode($payload, true);
236
+        $payload = json_decode($payload, true);
237 237
     }
238 238
 
239 239
     if (is_array($payload)) {
240
-      return $payload;
240
+        return $payload;
241 241
     }
242 242
 
243 243
     throw new FacebookSDKException(
244
-      'Signed request has malformed encoded payload data.', 607
244
+        'Signed request has malformed encoded payload data.', 607
245 245
     );
246
-  }
247
-
248
-  /**
249
-   * Validates the algorithm used in a signed request.
250
-   *
251
-   * @param array $data
252
-   *
253
-   * @throws FacebookSDKException
254
-   */
255
-  public static function validateAlgorithm(array $data)
256
-  {
246
+    }
247
+
248
+    /**
249
+     * Validates the algorithm used in a signed request.
250
+     *
251
+     * @param array $data
252
+     *
253
+     * @throws FacebookSDKException
254
+     */
255
+    public static function validateAlgorithm(array $data)
256
+    {
257 257
     if (isset($data['algorithm']) && $data['algorithm'] === 'HMAC-SHA256') {
258
-      return;
258
+        return;
259 259
     }
260 260
 
261 261
     throw new FacebookSDKException(
262
-      'Signed request is using the wrong algorithm.', 605
262
+        'Signed request is using the wrong algorithm.', 605
263 263
     );
264
-  }
265
-
266
-  /**
267
-   * Hashes the signature used in a signed request.
268
-   *
269
-   * @param string $encodedData
270
-   * @param string|null $appSecret
271
-   *
272
-   * @return string
273
-   *
274
-   * @throws FacebookSDKException
275
-   */
276
-  public static function hashSignature($encodedData, $appSecret = null)
277
-  {
264
+    }
265
+
266
+    /**
267
+     * Hashes the signature used in a signed request.
268
+     *
269
+     * @param string $encodedData
270
+     * @param string|null $appSecret
271
+     *
272
+     * @return string
273
+     *
274
+     * @throws FacebookSDKException
275
+     */
276
+    public static function hashSignature($encodedData, $appSecret = null)
277
+    {
278 278
     $hashedSig = hash_hmac(
279
-      'sha256', $encodedData, FacebookSession::_getTargetAppSecret($appSecret), $raw_output = true
279
+        'sha256', $encodedData, FacebookSession::_getTargetAppSecret($appSecret), $raw_output = true
280 280
     );
281 281
 
282 282
     if ($hashedSig) {
283
-      return $hashedSig;
283
+        return $hashedSig;
284 284
     }
285 285
 
286 286
     throw new FacebookSDKException(
287
-      'Unable to hash signature from encoded payload data.', 602
287
+        'Unable to hash signature from encoded payload data.', 602
288 288
     );
289
-  }
290
-
291
-  /**
292
-   * Validates the signature used in a signed request.
293
-   *
294
-   * @param string $hashedSig
295
-   * @param string $sig
296
-   *
297
-   * @throws FacebookSDKException
298
-   */
299
-  public static function validateSignature($hashedSig, $sig)
300
-  {
289
+    }
290
+
291
+    /**
292
+     * Validates the signature used in a signed request.
293
+     *
294
+     * @param string $hashedSig
295
+     * @param string $sig
296
+     *
297
+     * @throws FacebookSDKException
298
+     */
299
+    public static function validateSignature($hashedSig, $sig)
300
+    {
301 301
     if (mb_strlen($hashedSig) === mb_strlen($sig)) {
302
-      $validate = 0;
303
-      for ($i = 0; $i < mb_strlen($sig); $i++) {
302
+        $validate = 0;
303
+        for ($i = 0; $i < mb_strlen($sig); $i++) {
304 304
         $validate |= ord($hashedSig[$i]) ^ ord($sig[$i]);
305
-      }
306
-      if ($validate === 0) {
305
+        }
306
+        if ($validate === 0) {
307 307
         return;
308
-      }
308
+        }
309 309
     }
310 310
 
311 311
     throw new FacebookSDKException(
312
-      'Signed request has an invalid signature.', 602
312
+        'Signed request has an invalid signature.', 602
313 313
     );
314
-  }
315
-
316
-  /**
317
-   * Validates a signed request against CSRF.
318
-   *
319
-   * @param array $data
320
-   * @param string $state
321
-   *
322
-   * @throws FacebookSDKException
323
-   */
324
-  public static function validateCsrf(array $data, $state)
325
-  {
314
+    }
315
+
316
+    /**
317
+     * Validates a signed request against CSRF.
318
+     *
319
+     * @param array $data
320
+     * @param string $state
321
+     *
322
+     * @throws FacebookSDKException
323
+     */
324
+    public static function validateCsrf(array $data, $state)
325
+    {
326 326
     if (isset($data['state']) && $data['state'] === $state) {
327
-      return;
327
+        return;
328 328
     }
329 329
 
330 330
     throw new FacebookSDKException(
331
-      'Signed request did not pass CSRF validation.', 604
331
+        'Signed request did not pass CSRF validation.', 604
332 332
     );
333
-  }
334
-
335
-  /**
336
-   * Base64 decoding which replaces characters:
337
-   *   + instead of -
338
-   *   / instead of _
339
-   * @link http://en.wikipedia.org/wiki/Base64#URL_applications
340
-   *
341
-   * @param string $input base64 url encoded input
342
-   *
343
-   * @return string decoded string
344
-   */
345
-  public static function base64UrlDecode($input)
346
-  {
333
+    }
334
+
335
+    /**
336
+     * Base64 decoding which replaces characters:
337
+     *   + instead of -
338
+     *   / instead of _
339
+     * @link http://en.wikipedia.org/wiki/Base64#URL_applications
340
+     *
341
+     * @param string $input base64 url encoded input
342
+     *
343
+     * @return string decoded string
344
+     */
345
+    public static function base64UrlDecode($input)
346
+    {
347 347
     $urlDecodedBase64 = strtr($input, '-_', '+/');
348 348
     static::validateBase64($urlDecodedBase64);
349 349
     return base64_decode($urlDecodedBase64);
350
-  }
351
-
352
-  /**
353
-   * Base64 encoding which replaces characters:
354
-   *   + instead of -
355
-   *   / instead of _
356
-   * @link http://en.wikipedia.org/wiki/Base64#URL_applications
357
-   *
358
-   * @param string $input string to encode
359
-   *
360
-   * @return string base64 url encoded input
361
-   */
362
-  public static function base64UrlEncode($input)
363
-  {
350
+    }
351
+
352
+    /**
353
+     * Base64 encoding which replaces characters:
354
+     *   + instead of -
355
+     *   / instead of _
356
+     * @link http://en.wikipedia.org/wiki/Base64#URL_applications
357
+     *
358
+     * @param string $input string to encode
359
+     *
360
+     * @return string base64 url encoded input
361
+     */
362
+    public static function base64UrlEncode($input)
363
+    {
364 364
     return strtr(base64_encode($input), '+/', '-_');
365
-  }
366
-
367
-  /**
368
-   * Validates a base64 string.
369
-   *
370
-   * @param string $input base64 value to validate
371
-   *
372
-   * @throws FacebookSDKException
373
-   */
374
-  public static function validateBase64($input)
375
-  {
365
+    }
366
+
367
+    /**
368
+     * Validates a base64 string.
369
+     *
370
+     * @param string $input base64 value to validate
371
+     *
372
+     * @throws FacebookSDKException
373
+     */
374
+    public static function validateBase64($input)
375
+    {
376 376
     $pattern = '/^[a-zA-Z0-9\/\r\n+]*={0,2}$/';
377 377
     if (preg_match($pattern, $input)) {
378
-      return;
378
+        return;
379 379
     }
380 380
 
381 381
     throw new FacebookSDKException(
382
-      'Signed request contains malformed base64 encoding.', 608
382
+        'Signed request contains malformed base64 encoding.', 608
383 383
     );
384
-  }
384
+    }
385 385
 
386 386
 }
Please login to merge, or discard this patch.
main/auth/external_login/facebook.inc.php 3 patches
Unused Use Statements   -6 removed lines patch added patch discarded remove patch
@@ -18,14 +18,8 @@
 block discarded – undo
18 18
 use Facebook\FacebookSession;
19 19
 use Facebook\FacebookRedirectLoginHelper;
20 20
 use Facebook\FacebookRequest;
21
-use Facebook\FacebookResponse;
22 21
 use Facebook\FacebookSDKException;
23 22
 use Facebook\FacebookRequestException;
24
-use Facebook\FacebookAuthorizationException;
25
-use Facebook\GraphObject;
26
-use Facebook\Entities\AccessToken;
27
-use Facebook\HttpClients\FacebookCurlHttpClient;
28
-use Facebook\HttpClients\FacebookHttpable;
29 23
 
30 24
 require_once dirname(__FILE__) . '/functions.inc.php';
31 25
 
Please login to merge, or discard this patch.
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,15 +1,15 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Licence: GPL
4
- * Please contact CBlue regarding any licences issues.
5
- * Author: [email protected]
6
- *  Copyright: CBlue SPRL, 20XX
7
- *
8
- * External login module : FACEBOOK
9
- *
10
- * This files provides the facebookConnect()  and facebook_get_url functions
11
- * Please edit the facebook.conf.php file to adapt it to your fb application parameter
12
- */
3
+     * Licence: GPL
4
+     * Please contact CBlue regarding any licences issues.
5
+     * Author: [email protected]
6
+     *  Copyright: CBlue SPRL, 20XX
7
+     *
8
+     * External login module : FACEBOOK
9
+     *
10
+     * This files provides the facebookConnect()  and facebook_get_url functions
11
+     * Please edit the facebook.conf.php file to adapt it to your fb application parameter
12
+     */
13 13
 
14 14
 require_once dirname(__FILE__) . '/../../inc/global.inc.php';
15 15
 require_once dirname(__FILE__) . '/facebook.init.php';
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -11,9 +11,9 @@  discard block
 block discarded – undo
11 11
  * Please edit the facebook.conf.php file to adapt it to your fb application parameter
12 12
  */
13 13
 
14
-require_once dirname(__FILE__) . '/../../inc/global.inc.php';
15
-require_once dirname(__FILE__) . '/facebook.init.php';
16
-require_once dirname(__FILE__) . '/facebook-php-sdk/autoload.php';
14
+require_once dirname(__FILE__).'/../../inc/global.inc.php';
15
+require_once dirname(__FILE__).'/facebook.init.php';
16
+require_once dirname(__FILE__).'/facebook-php-sdk/autoload.php';
17 17
 
18 18
 use Facebook\FacebookSession;
19 19
 use Facebook\FacebookRedirectLoginHelper;
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 use Facebook\HttpClients\FacebookCurlHttpClient;
28 28
 use Facebook\HttpClients\FacebookHttpable;
29 29
 
30
-require_once dirname(__FILE__) . '/functions.inc.php';
30
+require_once dirname(__FILE__).'/functions.inc.php';
31 31
 
32 32
 // dont rename $facebook_config to $facebookConfig otherwise get a "Facebook\\FacebookSDKException"
33 33
 FacebookSession::setDefaultApplication($facebook_config['appId'], $facebook_config['secret']);
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
             $locale = $graphObject->getProperty('locale');
58 58
             $language = facebookPluginGetLanguage($locale);
59 59
             if (!$language) {
60
-                $language='en_US';
60
+                $language = 'en_US';
61 61
             }
62 62
 
63 63
             //Checks if user already exists in chamilo
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
                     $_user['user_id'] = $chamilo_uid;
86 86
                     $_user['uidReset'] = true;
87 87
                     $_SESSION['_user'] = $_user;
88
-                    header('Location:' . api_get_path(WEB_PATH));
88
+                    header('Location:'.api_get_path(WEB_PATH));
89 89
                     exit();
90 90
                 } else {
91 91
                     return false;
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
                 $_user['user_id'] = $chamilo_uid;
99 99
                 $_user['uidReset'] = true;
100 100
                 $_SESSION['_user'] = $_user;
101
-                header('Location:' . api_get_path(WEB_PATH));
101
+                header('Location:'.api_get_path(WEB_PATH));
102 102
                 exit();
103 103
             }
104 104
         }
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 {
118 118
     global $facebook_config;
119 119
     $helper = new FacebookRedirectLoginHelper($facebook_config['return_url']);
120
-    $loginUrl =   $helper->getLoginUrl(
120
+    $loginUrl = $helper->getLoginUrl(
121 121
         array('scope' => 'email')
122 122
     );
123 123
 
Please login to merge, or discard this patch.
main/auth/external_login/functions.inc.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -148,7 +148,7 @@
 block discarded – undo
148 148
  *      - language
149 149
  *      - courses : string of all courses code separated by '|'
150 150
  *      - admin : boolean
151
- * @return boolean
151
+ * @return boolean|null
152 152
  * @author ndiechburg <[email protected]>
153 153
  * */
154 154
 function external_update_user($new_user) {
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
     //Those are the mandatory fields for user creation.
21 21
     //See external_add_user function for all the fields you can have.
22 22
     $table = USERINFO_TABLE;
23
-    $sql = "SELECT * from $table where username='" . Database::escape_string($login) . "'";
23
+    $sql = "SELECT * from $table where username='".Database::escape_string($login)."'";
24 24
     $result = Database::query($sql);
25 25
 
26 26
     if (Database::num_rows($result) == 0) { //false password
Please login to merge, or discard this patch.
Braces   +37 added lines, -24 removed lines patch added patch discarded remove patch
@@ -95,30 +95,43 @@
 block discarded – undo
95 95
  * */
96 96
 function external_add_user($u) {
97 97
     //Setting default
98
-    if (empty($u['password']))
99
-        $u['password'] = null;
100
-    if (empty($u['status']))
101
-        $u['status'] = 5;
102
-    if (!isset($u['official_code']))
103
-        $u['official_code'] = '';
104
-    if (!isset($u['language']))
105
-        $u['language'] = '';
106
-    if (!isset($u['phone']))
107
-        $u['phone'] = '';
108
-    if (!isset($u['picture_uri']))
109
-        $u['picture_uri'] = '';
110
-    if (!isset($u['auth_source']))
111
-        $u['auth_source'] = PLATFORM_AUTH_SOURCE;
112
-    if (!isset($u['expiration_date']))
113
-        $u['expiration_date'] = '0000-00-00 00:00:00';
114
-    if (!isset($u['active']))
115
-        $u['active'] = 1;
116
-    if (!isset($u['hr_dept_id']))
117
-        $u['hr_dept_id'] = 0; //id of responsible HR
118
-    if (!isset($u['extra']))
119
-        $u['extra'] = null;
120
-    if (!isset($u['encrypt_method']))
121
-        $u['encrypt_method'] = '';
98
+    if (empty($u['password'])) {
99
+            $u['password'] = null;
100
+    }
101
+    if (empty($u['status'])) {
102
+            $u['status'] = 5;
103
+    }
104
+    if (!isset($u['official_code'])) {
105
+            $u['official_code'] = '';
106
+    }
107
+    if (!isset($u['language'])) {
108
+            $u['language'] = '';
109
+    }
110
+    if (!isset($u['phone'])) {
111
+            $u['phone'] = '';
112
+    }
113
+    if (!isset($u['picture_uri'])) {
114
+            $u['picture_uri'] = '';
115
+    }
116
+    if (!isset($u['auth_source'])) {
117
+            $u['auth_source'] = PLATFORM_AUTH_SOURCE;
118
+    }
119
+    if (!isset($u['expiration_date'])) {
120
+            $u['expiration_date'] = '0000-00-00 00:00:00';
121
+    }
122
+    if (!isset($u['active'])) {
123
+            $u['active'] = 1;
124
+    }
125
+    if (!isset($u['hr_dept_id'])) {
126
+            $u['hr_dept_id'] = 0;
127
+    }
128
+    //id of responsible HR
129
+    if (!isset($u['extra'])) {
130
+            $u['extra'] = null;
131
+    }
132
+    if (!isset($u['encrypt_method'])) {
133
+            $u['encrypt_method'] = '';
134
+    }
122 135
 
123 136
     $chamilo_uid = UserManager::create_user($u['firstname'], $u['lastname'], $u['status'], $u['email'], $u['username'], $u['password'], $u['official_code'], $u['language'], $u['phone'], $u['picture_uri'], $u['auth_source'], $u['expiration_date'], $u['active'], $u['hr_dept_id'], $u['extra'], $u['encrypt_method']);
124 137
     return $chamilo_uid;
Please login to merge, or discard this patch.
main/auth/external_login/ldap.inc.php 2 patches
Doc Comments   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 /**
29 29
  * Establishes a connection to the LDAP server and sets the protocol version
30 30
  *
31
- * @return resource ldap link identifier or false
31
+ * @return boolean ldap link identifier or false
32 32
  * @author ndiechburg <[email protected]>
33 33
  * */
34 34
 function extldap_connect()
@@ -77,6 +77,7 @@  discard block
 block discarded – undo
77 77
 /**
78 78
  * Authenticate user on external ldap server and return user ldap entry if that succeeds
79 79
  *
80
+ * @param string $password
80 81
  * @return mixed false if user cannot authenticate on ldap, user ldap entry if tha succeeds
81 82
  * @author ndiechburg <[email protected]>
82 83
  * Modified by [email protected]
@@ -237,7 +238,7 @@  discard block
 block discarded – undo
237 238
 
238 239
 /**
239 240
  * Imports all LDAP users into Chamilo
240
- * @return bool false on error, true otherwise
241
+ * @return false|null false on error, true otherwise
241 242
  */
242 243
 function extldap_import_all_users()
243 244
 {
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -303,7 +303,7 @@
 block discarded – undo
303 303
 
304 304
     // TODO the password, if encrypted at the source, will be encrypted twice, which makes it useless. Try to fix that.
305 305
     $passwordKey = isset($extldap_user_correspondance['password']) ? $extldap_user_correspondance['password'] : 'userPassword';
306
-    $password        = $data[$passwordKey][0];
306
+    $password = $data[$passwordKey][0];
307 307
 
308 308
     // To ease management, we add the step-year (etape-annee) code
309 309
     //$official_code = $etape."-".$annee;
Please login to merge, or discard this patch.