Esempio n. 1
0
 /**
  * Get a property for this object.
  *
  * @param string $name the name of the property to retrieve.
  * @throws Exception the property does not exist for this object.
  * @return string the associated property.
  */
 public function __get($name)
 {
     if ($name == "start") {
         return $this->start();
     }
     /*
             else if ($name == "last_sign_in_time")
                 return $this->lastEventTime('sign_in');
             else if ($name == "sign_up_time")
                 return $this->lastEventTime('sign_up');
             else if ($name == "last_password_reset_time")
                 return $this->lastEventTime('password_reset_request');
             else if ($name == "last_verification_request_time")
                 return $this->lastEventTime('verification_request');
             else if ($name == "primary_group")
                 return $this->getPrimaryGroup();
             else if ($name == "theme")
                 return $this->getPrimaryGroup()->theme;
             else if ($name == "icon")
                 return $this->getPrimaryGroup()->icon;
             else if ($name == "landing_page")
                 return $this->getPrimaryGroup()->landing_page;
             else */
     return parent::__get($name);
 }
Esempio n. 2
0
 /**
  * Create a new User object.
  *
  */
 public function __construct($properties = [])
 {
     // Set default locale, if not specified
     if (!isset($properties['locale'])) {
         $properties['locale'] = static::$app->site->default_locale;
     }
     parent::__construct($properties);
 }
 /**
  * store : Function to save OAuth records into database
  */
 public function store($force_create = false)
 {
     // Initialize creation time for new OAuthUser records
     if (!isset($this->_id) || $force_create) {
         $this->created_at = date("Y-m-d H:i:s");
     }
     // Update the record
     parent::store();
 }
Esempio n. 4
0
 /**
  * Delete this group from the database, along with any linked user and authorization rules
  *
  */
 public function delete()
 {
     // Remove all user associations
     $this->users()->detach();
     // Remove all group auth rules
     $auth_table = Database::getSchemaTable('authorize_group')->name;
     Capsule::table($auth_table)->where("group_id", $this->id)->delete();
     // Reassign any primary users to the current default primary group
     $default_primary_group = Group::where('is_default', GROUP_DEFAULT_PRIMARY)->first();
     $user_table = Database::getSchemaTable('user')->name;
     Capsule::table($user_table)->where('primary_group_id', $this->id)->update(["primary_group_id" => $default_primary_group->id]);
     // TODO: assign user to the default primary group as well?
     // Delete the group
     $result = parent::delete();
     return $result;
 }
Esempio n. 5
0
 /**
  * Delete this user from the database, along with any linked groups and authorization rules
  *
  * @return bool true if the deletion was successful, false otherwise.
  */
 public function delete()
 {
     // Remove all group associations
     $this->groups()->detach();
     // Remove all user auth rules
     $auth_table = Database::getSchemaTable('authorize_user')->name;
     Capsule::table($auth_table)->where("user_id", $this->id)->delete();
     // Remove all user events
     $event_table = Database::getSchemaTable('user_event')->name;
     Capsule::table($event_table)->where("user_id", $this->id)->delete();
     // Delete the user
     $result = parent::delete();
     return $result;
 }
Esempio n. 6
0
 public function save()
 {
     parent::save();
     if (strpos($this->alphaId, 'ZZZ') === FALSE) {
         return false;
     }
     $alpha1 = $this->originCity ? mb_substr($this->originCity, 0, 2) : 'X' . rand(1, 9);
     $alpha2 = $this->destinationCity ? mb_substr($this->destinationCity, 0, 2) : 'Y' . rand(1, 9);
     $number = 1;
     $alphaId = mb_strtoupper($alpha1 . '-' . str_pad($number, 2, "0", STR_PAD_LEFT) . '-' . $alpha2);
     while (self::alphaIdExists($alphaId, $this->user_id)) {
         $number++;
         $alphaId = mb_strtoupper($alpha1 . '-' . str_pad($number, 2, "0", STR_PAD_LEFT) . '-' . $alpha2);
     }
     $this->alphaId = $alphaId;
     return $this->save();
 }