BLUE DRAGON PHP SDK
All Classes Functions Variables Pages
RVP_PHP_SDK_Login Class Reference
Inheritance diagram for RVP_PHP_SDK_Login:
A_RVP_PHP_SDK_Security_Object A_RVP_PHP_SDK_Object

Public Member Functions

 __construct ( $in_sdk_object, $in_id, $in_data=NULL, $in_detailed_data=false)
 
 login_id ()
 
 is_logged_in ()
 
 is_manager ()
 
 is_main_admin ()
 
 set_password ( $in_new_password)
 
 user_object_id ()
 
 user_object ()
 
 security_tokens ()
 
 set_security_tokens ( $in_token_array)
 
 set_sdk_object ( $in_sdk_object)
 
 changes ()
 
 save_data ()
 
 id ()
 
 name ()
 
 set_name ( $in_new_value)
 
 lang ()
 
 set_lang ( $in_new_value)
 
 object_access ()
 
 set_object_access ( $in_new_read=NULL, $in_new_write=NULL)
 
 writeable ()
 
 last_access ()
 
 force_reload ( $in_parents=false)
 

Protected Member Functions

 _save_data ( $in_args='', $in_payload=NULL, $in_new_child_ids=NULL)
 
 _save_change_record ( $in_change_record_object)
 
 _load_data ( $in_force=false, $in_details=false, $in_parents=false)
 

Protected Attributes

 $_sdk_object
 This is the RVP_PHP_SDK object that "owns" this object.
 
 $_object_id
 This is the server unique ID of this object.
 
 $_object_data
 This is any data that was associated with this object (parsed JSON).
 
 $_details
 If true, then the last load was a "show details" load..
 
 $_plugin_path
 This is a string that is applied to fetches to get the object.
 
 $_changed_states
 This will contain an array of objects (of whatever class this is), that represent previous object states.
 

Detailed Description

Definition at line 31 of file rvp_php_sdk_login.class.php.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $in_sdk_object,
  $in_id,
  $in_data = NULL,
  $in_detailed_data = false 
)
Parameters
$in_sdk_objectREQUIRED: The "owning" SDK object.
$in_idREQUIRED: The server ID of the object. An integer.
$in_dataOPTIONAL: Parsed JSON Data for the object. Default is NULL.
$in_detailed_dataOPTIONAL: Ignored if $in_data is NULL. Default is false. If true, then the data sent in was in "detailed" format.

Definition at line 113 of file rvp_php_sdk_login.class.php.

117  {
118  parent::__construct($in_sdk_object, $in_id, $in_data, $in_detailed_data, 'people/logins');
119  }

Member Function Documentation

◆ _save_data()

_save_data (   $in_args = '',
  $in_payload = NULL,
  $in_new_child_ids = NULL 
)
protected
Returns
true, if the save was successful.
Parameters
$in_argsOPTIONAL: Default is an empty string. This is any previous arguments. This will be appeneded to the end of the list, so it should begin with an ampersand (&), and be url-encoded.
$in_payloadIGNORED. Just here to suppress PHP warnings.
$in_new_child_idsIGNORED. Just here to suppress PHP warnings.

Definition at line 39 of file rvp_php_sdk_login.class.php.

42  {
43  $tokens = $this->_object_data->security_tokens;
44 
45  $to_set = [
46  'password' => (isset($this->_object_data->password) ? $this->_object_data->password : NULL),
47  'tokens' => ((isset($tokens) && is_array($tokens)) ? implode(',', $tokens) : NULL)
48  ];
49 
50  $put_args = '';
51 
52  foreach ($to_set as $key => $value) {
53  if (isset($key) && isset($value)) {
54  $put_args .= '&'.$key.'='.urlencode(trim(strval($value)));
55  }
56  }
57 
58  return parent::_save_data($put_args.$in_args);
59  }

◆ _save_change_record()

_save_change_record (   $in_change_record_object)
protected

This is called after a successful save. It has the change record[s], and we will parse them to save the "before" object.

Returns
true, if the save was successful.
Parameters
$in_change_record_objectREQUIRED: The change response, as a parsed object.

Definition at line 67 of file rvp_php_sdk_login.class.php.

68  {
69  $ret = false;
70  if (isset($in_change_record_object->people->logins) && isset($in_change_record_object->people->logins->changed_logins) && is_array($in_change_record_object->people->logins->changed_logins) && count($in_change_record_object->people->logins->changed_logins)) {
71  foreach ($in_change_record_object->people->logins->changed_logins as $changed_login) {
72  if ($before = $changed_login->before) {
73  $this->_changed_states[] = new RVP_PHP_SDK_Login($this->_sdk_object, $before->id, $before, true);
74  $ret = true;
75  }
76  }
77  }
78 
79  return $ret;
80  }

◆ _load_data()

_load_data (   $in_force = false,
  $in_details = false,
  $in_parents = false 
)
protected

This is the specific "load some data" method. It will send a GET REST request to the API in order to fetch information about this object.

Returns
true, if it loaded the data.
Parameters
$in_forceOPTIONAL: If true (default is false), then the load will happen, even if we already have the data.
$in_detailsOPTIONAL: Default is false. If true, then the load will be a "show details" load, which could bring in a great deal more data.
$in_parentsOPTIONAL: Default is false. If true, then the load will be a "show details" load, AND it will get the "parents," which can be a time-consuming operation. This will also "force" a load.

Definition at line 88 of file rvp_php_sdk_login.class.php.

91  {
92  $ret = parent::_load_data($in_force, $in_details, $in_parents);
93 
94  if ($ret) {
95  if (isset($this->_object_data) && isset($this->_object_data->people) && isset($this->_object_data->people->logins) && is_array($this->_object_data->people->logins) && (1 == count($this->_object_data->people->logins))) {
96  $this->_object_data = $this->_object_data->people->logins[0];
97  } else {
98  $this->_object_data = NULL;
99  $this->_details = false;
100  }
101  }
102 
103  return $ret;
104  }

◆ login_id()

login_id ( )

This requires a "detailed" load.

Returns
the current login ID as a string.

Definition at line 127 of file rvp_php_sdk_login.class.php.

127  {
128  $ret = NULL;
129 
130  $this->_load_data(false, true);
131 
132  if (isset($this->_object_data) && isset($this->_object_data->login_id)) {
133  $ret = $this->_object_data->login_id;
134  }
135 
136  return $ret;
137  }
_load_data( $in_force=false, $in_details=false, $in_parents=false)

◆ is_logged_in()

is_logged_in ( )

This requires a "detailed" load.

Returns
true, if this is login is currently logged in.

Definition at line 145 of file rvp_php_sdk_login.class.php.

145  {
146  $ret = false;
147 
148  $this->_load_data(false, true);
149  if (isset($this->_object_data) && isset($this->_object_data->current_login) && $this->_object_data->current_login) {
150  $ret = true;
151  }
152 
153  return $ret;
154  }
_load_data( $in_force=false, $in_details=false, $in_parents=false)

◆ is_manager()

is_manager ( )

This requires a "detailed" load.

Returns
true, if this is a manager login.

Definition at line 162 of file rvp_php_sdk_login.class.php.

162  {
163  $ret = false;
164 
165  if ($this->is_logged_in() && isset($this->_object_data->is_manager) && $this->_object_data->is_manager) {
166  $ret = true;
167  }
168 
169  return $ret;
170  }

◆ is_main_admin()

is_main_admin ( )

This requires a "detailed" load.

Returns
true, if this is a main admin login.

Definition at line 178 of file rvp_php_sdk_login.class.php.

178  {
179  $ret = false;
180 
181  if ($this->is_manager() && isset($this->_object_data->is_main_admin) && $this->_object_data->is_main_admin) {
182  $ret = true;
183  }
184 
185  return $ret;
186  }

◆ set_password()

set_password (   $in_new_password)

Sets the password for this login. You cannot remove a password.

Returns
true, if the operation succeeded
Parameters
$in_new_passwordREQUIRED: The new cleartext password.

Definition at line 194 of file rvp_php_sdk_login.class.php.

195  {
196  $ret = false;
197 
198  $this->_load_data(false, true);
199 
200  if (isset($this->_object_data)) {
201  $this->_object_data->password = trim(strval($in_new_password));
202  $ret = $this->save_data();
203  }
204 
205  return $ret;
206  }
_load_data( $in_force=false, $in_details=false, $in_parents=false)

◆ user_object_id()

user_object_id ( )

This requires a "detailed" load.

Returns
an integer. The ID of any associated user object. It returns 0 if there is no associated user object.

Definition at line 214 of file rvp_php_sdk_login.class.php.

214  {
215  $ret = 0;
216 
217  $this->_load_data(false, true);
218 
219  if (isset($this->_object_data) && isset($this->_object_data->user_object_id)) {
220  $ret = intval($this->_object_data->user_object_id);
221  }
222 
223  return $ret;
224  }
_load_data( $in_force=false, $in_details=false, $in_parents=false)

◆ user_object()

user_object ( )

This requires a "detailed" load.

Returns
a new instance of RVP_PHP_SDK_User, if this object has an associated user.

Definition at line 232 of file rvp_php_sdk_login.class.php.

232  {
233  $ret = 0;
234 
235  $this->_load_data(false, true);
236 
237  if (isset($this->_object_data) && isset($this->_object_data->user_object_id)) {
238  $ret = intval($this->_object_data->user_object_id);
239  $ret = new RVP_PHP_SDK_User($this->_sdk_object, $this->_object_data->user_object_id);
240  }
241 
242  return $ret;
243  }
_load_data( $in_force=false, $in_details=false, $in_parents=false)

◆ security_tokens()

security_tokens ( )

This requires a "detailed" load.

Returns
an array of integer (security tokens) that comprise the "pool" for this login. It sorts the tokens, which include 1 (login) and the ID of this instance.

Definition at line 251 of file rvp_php_sdk_login.class.php.

251  {
252  $ret = [1, $this->id()];
253 
254  $this->_load_data(false, true);
255 
256  if (isset($this->_object_data) && isset($this->_object_data->security_tokens)) {
257  $ret = array_merge($ret, array_map('intval', $this->_object_data->security_tokens));
258  }
259 
260  sort($ret);
261  $ret = array_unique($ret);
262 
263  return $ret;
264  }
_load_data( $in_force=false, $in_details=false, $in_parents=false)

◆ set_security_tokens()

set_security_tokens (   $in_token_array)

Set the tokens for this ID. NOTE: For security reasons, a user is not allowed to change their own tokens. In order to set the tokens for another user, the current user must be a manager. The manager must "own" all the tokens they specify. If they specify tokens they don't "own," then those tokens will be ignored.

AN IMPORTANT NOTE ABOUT SECURITY TOKENS

There are a few rules with setting security tokens:

  • You cannot set your own security tokens. It must be done by a manager object with edit rights to your login (not user).
  • You must be a manager to edit security tokens.
  • You must "own" every single token currently in the target object, and, of course, have mod rights to that login.
  • Any security tokens that you wish to add must be ones that your login "owns." Ones you don't own will be ignored.
  • This will entirely replace all the tokens currently in the object.

The object will force-reload its data after this operation, in order to reflect the new security tokens.

Returns
true, if the operation succeeded
Parameters
$in_token_arrayREQUIRED: An array of int.

Definition at line 290 of file rvp_php_sdk_login.class.php.

291  {
292  $ret = false;
293 
294  $this->_load_data(false, true);
295 
296  if (isset($this->_object_data) && $this->_sdk_object->is_manager() && ($this->_sdk_object->current_login_id() != $this->id())) {
297  $in_vals = array_map('intval', $in_token_array);
298  $this->_object_data->security_tokens = $in_vals;
299  $ret = $this->save_data();
300  if ($ret) {
301  $ret = $this->_load_data(true, true);
302  } else {
303  $this->_load_data(true, true); // We reload the data in any case, but we don't record the result if the operation failed.
304  }
305  }
306 
307  return $ret;
308  }
_load_data( $in_force=false, $in_details=false, $in_parents=false)

◆ set_sdk_object()

set_sdk_object (   $in_sdk_object)
inherited

Simple accessor to set the "owning" SDK object.

Parameters
$in_sdk_objectREQUIRED: The "owning" SDK object.

Definition at line 148 of file a_rvp_php_sdk_object.class.php.

149  {
150  $this->_sdk_object = $in_sdk_object; // This is the RVP_PHP_SDK object that "owns" this user.
151  }

◆ changes()

changes ( )
inherited
Returns
an array of instances, representing the "before" state of this object, prior to any changes made. It should be noted that the lifetime of these changes are dependent on the lifetime of this instance.

Definition at line 157 of file a_rvp_php_sdk_object.class.php.

157  {
158  return isset($this->_changed_states) ? $this->_changed_states : [];
159  }

◆ save_data()

save_data ( )
inherited
Returns
true, if the save was successful.

Definition at line 165 of file a_rvp_php_sdk_object.class.php.

165  {
166  $ret = false;
167 
168  $ret = $this->_save_change_record($this->_save_data());
169 
170  return $ret;
171  }
_save_change_record( $in_change_record_object)
_save_data( $in_args='', $in_payload=NULL, $in_new_child_ids=NULL)

◆ id()

id ( )
inherited
Returns
the integer ID of the object; unique in the object's database.

Definition at line 177 of file a_rvp_php_sdk_object.class.php.

177  {
178  return $this->_object_id;
179  }
$_object_id
This is the server unique ID of this object.

◆ name()

name ( )
inherited

This requires a load, but not a "detailed" load.

Returns
the string name of the object. This is the generic "object_name" column that all records have.

Definition at line 187 of file a_rvp_php_sdk_object.class.php.

187  {
188  $ret = NULL;
189 
190  $this->_load_data();
191 
192  if (isset($this->_object_data) && isset($this->_object_data->name)) {
193  $ret = $this->_object_data->name;
194  }
195 
196  return $ret;
197  }
_load_data( $in_force=false, $in_details=false, $in_parents=false)

◆ set_name()

set_name (   $in_new_value)
inherited

This sets the name of the object.

Returns
true, if the save worked.
Parameters
$in_new_valueREQUIRED: A new value for the name.

Definition at line 205 of file a_rvp_php_sdk_object.class.php.

206  {
207  $ret = false;
208 
209  $this->_load_data(false, true);
210 
211  if (isset($this->_object_data)) {
212  $this->_object_data->name = $in_new_value;
213 
214  $ret = $this->save_data();
215  }
216 
217  return $ret;
218  }
_load_data( $in_force=false, $in_details=false, $in_parents=false)

◆ lang()

lang ( )
inherited

This requires a load, but not a "detailed" load.

Returns
the string for the object's "lang" (language code) field.

Definition at line 226 of file a_rvp_php_sdk_object.class.php.

226  {
227  $ret = NULL;
228 
229  $this->_load_data();
230 
231  if (isset($this->_object_data) && isset($this->_object_data->lang)) {
232  $ret = $this->_object_data->lang;
233  }
234 
235  return $ret;
236  }
_load_data( $in_force=false, $in_details=false, $in_parents=false)

◆ set_lang()

set_lang (   $in_new_value)
inherited

This sets the language ID of the object.

Returns
true, if the save worked.
Parameters
$in_new_valueREQUIRED: A new value for the language ID.

Definition at line 244 of file a_rvp_php_sdk_object.class.php.

245  {
246  $ret = false;
247 
248  $this->_load_data(false, true);
249 
250  if (isset($this->_object_data)) {
251  $this->_object_data->lang = $in_new_value;
252 
253  $ret = $this->save_data();
254  }
255 
256  return $ret;
257  }
_load_data( $in_force=false, $in_details=false, $in_parents=false)

◆ object_access()

object_access ( )
inherited

This requires a load, but not a "detailed" load.

Returns
an associative array ('read' => integer, 'write' => integer), with the tokens for the object. The tokens will only be available if they are visible to the current user, or NULL, if there are no tokens (should never happen).

Definition at line 265 of file a_rvp_php_sdk_object.class.php.

265  {
266  $ret = NULL;
267  $read_token = NULL;
268  $write_token = NULL;
269 
270  $this->_load_data();
271 
272  if (isset($this->_object_data) && isset($this->_object_data->read_token)) {
273  $read_token = intval($this->_object_data->read_token);
274  }
275 
276  if (isset($this->_object_data) && isset($this->_object_data->write_token)) {
277  $write_token = intval($this->_object_data->write_token);
278  }
279 
280  if ($read_token || $write_token) {
281  $ret = [];
282 
283  if ($read_token) {
284  $ret['read'] = $read_token;
285  }
286 
287  if ($write_token) {
288  $ret['write'] = $write_token;
289  }
290  }
291 
292  return $ret;
293  }
_load_data( $in_force=false, $in_details=false, $in_parents=false)

◆ set_object_access()

set_object_access (   $in_new_read = NULL,
  $in_new_write = NULL 
)
inherited

This sets the read and write tokens of the object.

The current login must have at least read access to each of the tokens. If a token is NULL, then the token is not changed.

Returns
true, if the save worked.
Parameters
$in_new_readOPTIONAL: A new read token. Default is NULL (no change).
$in_new_writeOPTIONAL: A new write token. Default is NULL (no change).

Definition at line 303 of file a_rvp_php_sdk_object.class.php.

305  {
306  $ret = false;
307 
308  $this->_load_data(false, true);
309 
310  if (isset($this->_object_data)) {
311  $this->_object_data->read_token = isset($in_new_read) ? intval($in_new_read) : $this->_object_data->read_token;
312  $this->_object_data->write_token = isset($in_new_write) ? intval($in_new_write) : $this->_object_data->write_token;
313 
314  $ret = $this->save_data();
315  }
316 
317  return $ret;
318  }
_load_data( $in_force=false, $in_details=false, $in_parents=false)

◆ writeable()

writeable ( )
inherited

This requires a load, but not a "detailed" load.

Returns
true, if the current login can write/modify this object.

Definition at line 326 of file a_rvp_php_sdk_object.class.php.

326  {
327  $ret = false;
328 
329  $this->_load_data();
330 
331  if (isset($this->_object_data) && isset($this->_object_data->writeable) && $this->_object_data->writeable) {
332  $ret = true;
333  }
334 
335  return $ret;
336  }
_load_data( $in_force=false, $in_details=false, $in_parents=false)

◆ last_access()

last_access ( )
inherited

This requires a load, but not a "detailed" load.

Returns
the last access date, as a timedate integer.

Definition at line 344 of file a_rvp_php_sdk_object.class.php.

344  {
345  $ret = NULL;
346 
347  $this->_load_data();
348 
349  if (isset($this->_object_data) && isset($this->_object_data->last_access)) {
350  $ret = strtotime($this->_object_data->last_access);
351  }
352 
353  return $ret;
354  }
_load_data( $in_force=false, $in_details=false, $in_parents=false)

◆ force_reload()

force_reload (   $in_parents = false)
inherited

This forces at least a detailed load.

This reloads the information, refreshing the object, if necessary.

Returns
true, if successful.
Parameters
$in_parentsOPTIONAL: Default is false. If true, then the parent info is also loaded.

Definition at line 364 of file a_rvp_php_sdk_object.class.php.

365  {
366  return $this->_load_data(true, true, $in_parents);
367  }
_load_data( $in_force=false, $in_details=false, $in_parents=false)

The documentation for this class was generated from the following file: