public function getSessionUser($mhr_user = false) { if ($mhr_user) { return GcrChatSessionUsersTable::getInstance()->createQuery('c')->where('c.user_id = ?', $mhr_user->getObject()->id)->andWhere('c.user_eschool_id = ?', $mhr_user->getApp()->getShortName())->andWhere('c.session_id = ?', $this->id)->fetchOne(); } else { return GcrChatSessionUsersTable::getInstance()->findBySessionId($this->id); } }
public function getOtherUsers() { $this_user = $this->getUser(); $other_user_chat_sessions = GcrChatSessionUsersTable::getInstance()->createQuery('c')->where('c.session_id = ?', $this->session_id)->andWhere('c.user_id != ?', $this_user->getObject()->id)->orWhere('c.user_eschool_id != ?', $this_user->getApp()->getShortName())->orderBy('c.time_created')->execute(); $users = array(); foreach ($other_user_chat_sessions as $user_chat_session) { if ($user = $user_chat_session->getUser()) { if ($user->isLoggedIn()) { $users[] = $user; } else { $user_chat_session->delete(); } } } if (count($users) > 0) { return $users; } return false; }
public function deleteInstitutionFromSystemEntirely() { // delete each moodle instance owned by this institution foreach ($this->getEschools() as $eschool) { $eschool->deleteEschoolFromSystemEntirely(); } // delete this institution's database schema GcrDatabaseAccessPostgres::deleteSchemaFromSystem($this); // delete moodledata directory for institution exec(escapeshellcmd('rm -R ' . gcr::moodledataDir . $this->short_name . '/')); // delete password salt history for this institution Doctrine_Query::create()->delete('GcrInstitutionSaltHistory')->where('institutionid = ?', $this->id)->execute(); Doctrine_Query::create()->delete('GcrTrial t')->where('t.organization_id = ?', $this->id)->execute(); GcrChainedPaymentTable::getInstance()->createQuery('c')->delete()->where('c.user_institution_id = ?', $this->short_name)->execute(); GcrChatSessionTable::getInstance()->createQuery('c')->delete()->where('c.eschool_id = ?', $this->short_name)->execute(); GcrChatSessionUsersTable::getInstance()->createQuery('c')->delete()->where('c.user_eschool_id = ?', $this->short_name)->execute(); GcrChatSessionInviteTable::getInstance()->createQuery('c')->delete()->where('c.user_eschool_id = ?', $this->short_name)->orWhere('c.from_user_eschool_id = ?', $this->short_name)->execute(); GcrCommissionTable::getInstance()->createQuery('c')->delete()->where('c.institution_id = ?', $this->short_name)->execute(); GcrEclassroomTable::getInstance()->createQuery('e')->delete()->where('e.user_institution_id = ?', $this->short_name)->execute(); GcrEschoolMonthlyDataTable::getInstance()->createQuery('e')->delete()->where('e.eschool_id = ?', $this->short_name)->execute(); GcrUserMonthlyDataTable::getInstance()->createQuery('u')->delete()->where('u.user_institution_id = ?', $this->short_name)->execute(); GcrPayoffTable::getInstance()->createQuery('p')->delete()->where('p.user_eschool_id = ?', $this->short_name)->execute(); GcrPurchaseTable::deleteInstitutionRecords($this); GcrUserStorageS3Table::deleteBucket($this); if ($address = $this->getAddressObject()) { $address->delete(); } if ($contact1 = $this->getPersonObject()) { $contact1->delete(); } if ($contact2 = $this->getPerson2Object()) { $contact2->delete(); } $this->delete(); }