/** * Logs admin into the system * @param $login * @param $password * @return \SkullyAdmin\Models\Admin|null */ public function login($login, $password) { /** @var \RedBean_SimpleModel $adminBean */ $adminBean = R::findOne('admin', "status = ? and email = ?", array(Admin::STATUS_ACTIVE, $login)); if (!empty($adminBean)) { /** @var \SkullyAdmin\Models\Admin $admin */ $admin = $adminBean->box(); if ($admin->get('password_hash') == UtilitiesHelper::toHash($password, $admin->get('salt'), $this->app->config('globalSalt'))) { $adminSessions = R::find('adminsession', "admin_id = ?", array($admin->getID())); if (!empty($adminSessions)) { R::trashAll($adminSessions); } // when everything ok, regenerate session session_regenerate_id(true); // change session ID for the current session and invalidate old session ID $adminId = $admin->getID(); $sessionId = session_id(); $adminsession = $this->app->createModel('adminsession', array("admin_id" => $adminId, "session_id" => $sessionId)); $this->app->getSession()->set('adminId', $admin->getID()); R::store($adminsession); return $admin; } } return null; }
/** * Test trashAll(). */ public function testMultiDeleteUpdate() { testpack('test multi delete and multi update'); $beans = R::dispenseLabels('bean', array('a', 'b')); $ids = R::storeAll($beans); asrt((int) R::count('bean'), 2); R::trashAll(R::batch('bean', $ids)); asrt((int) R::count('bean'), 0); testpack('test assocManager check'); $rb = new OODB(R::getWriter()); try { $rb->getAssociationManager(); fail(); } catch (RedException $e) { pass(); } }
function deletePackageCost($id) { $packageCost = R::find('packagecost', 'id=?', [$id]); R::trashAll($packageCost); }
/** * @param int $qid * * @return void */ public function delete($qid) { Facade::trash('questions', $qid); $answersToDelete = Facade::findAll('answers', 'qid = :qid', [':qid' => $qid]); Facade::trashAll($answersToDelete); }