public function execute($args = null) { if (!ServiceAuth::getInstance()->isAuth()) { header('Location: /login'); } else { if (empty($_POST)) { return ServiceRenderHtml::newInstance()->load('search')->render(); } $res = array(); if (isset($_POST['search1'])) { $res = CollectionProfile::newInstance()->findByWithUser('prog', $_POST['prog']); } elseif (isset($_POST['search2'])) { $res = CollectionProfile::newInstance()->findByWithUser(array('prog', 'semester'), array($_POST['prog'], $_POST['semester'])); } elseif (isset($_POST['search3'])) { $res = CollectionProfile::newInstance()->findByWithUser('sex', $_POST['sex']); } elseif (isset($_POST['search4'])) { $resx = CollectionUser_has_user::newInstance()->findByWithUserLoose('user_id1', ServiceAuth::getInstance()->getUser()->getId()); foreach ($resx as $v) { $res[] = $v->getUser2(); } } elseif (isset($_POST['search5'])) { $res = CollectionProfile::newInstance()->findAllWithUser(); } else { return ControllerError::newInstance()->execute($args); } $_SESSION['search'] = $res; header('Location: /search/result'); } }
public function execute($args = null) { if (!ServiceAuth::getInstance()->isAdmin()) { return header('Location: /admin/login'); } ServiceRenderHtml::newInstance()->load('admin/stats')->setData('res1', CollectionAction::newInstance()->countDesc())->setData('res2', CollectionUser::newInstance()->findAllWithReputation())->setData('res3', CollectionUser_has_user::newInstance()->findAllCoworkers())->render(); }
public function getUser_has_users() { if (empty($this->user_has_user)) { foreach (CollectionUser_has_user::newInstance()->findAllAssoc($this->getId()) as $v) { $this->addUser_has_user($v); } } return $this->user_has_user; }