Ejemplo n.º 1
0
 protected function beforeDelete()
 {
     // AdminUser log
     $res = new UserLogRepository();
     $res->setWhereUserId($this->getId());
     $res->deleteObjectCollection();
     // AdminUser messages - received
     $res = new UsersMessageEntityRepository();
     $res->setWhereToUserId($this->getId());
     $res->deleteObjectCollection();
     // AdminUser messages - sent
     $res = new UsersMessageEntityRepository();
     $res->setWhereFromUserId($this->getId());
     $res->deleteObjectCollection();
     // AdminUser sessions
     $res = new UsersSessionEntityRepository();
     $res->setWhereUserId($this->getId());
     $res->deleteObjectCollection();
     // App log
     $log = new AppLogEntityRepository();
     $log->setWhereUserId($this->getId());
     $log->deleteObjectCollection();
 }
Ejemplo n.º 2
0
 /**
  * Delete outdated sessions for users that are no longer logged-in
  * @return bool sessions are deleted
  */
 private function deleteOldSessions()
 {
     // 2% chance of kicking idle sessions
     if (mt_rand(0, 49)) {
         return false;
     }
     $sessions = new UsersSessionEntityRepository();
     $sessions->setOnlyOutdated();
     $sessions->deleteObjectCollection();
     return true;
 }