public function getUser2() { if ($this->user2 == null) { $this->user2 = CollectionUser::newInstance()->find($this->getUser_id2()); } return $this->user2; }
public function execute($args = null) { if (!empty($_POST)) { $_POST['id'] = null; $_POST['hash'] = ServiceAuth::createHash($_POST['pass1']); $_POST['inBounds'] = 0; $_POST['outBounds'] = 0; $u = ModelUser::newInstance()->hydrate($_POST); $p = ModelProfile::newInstance(); if ($_POST['pass1'] != $_POST['pass2']) { ServiceMessage::getInstance()->addMessage('Les mots de passes ne correspondent pas', 'error'); } elseif (CollectionUser::newInstance()->findBy('login', $_POST['login'])) { ServiceMessage::getInstance()->addMessage('Ce login est déjà utilisé', 'error'); } else { if (ServiceDb::getInstance()->persist($u)) { if ($i = ServiceDb::getInstance()->lastInsertId()) { if (ServiceDb::getInstance()->persist($p->hydrate(array('user_id' => $i)))) { ServiceMessage::getInstance()->addMessage('Votre compte a bien été créé', 'success'); ServiceDb::getInstance()->persist(ModelAction::newInstance()->setUser_id($i)->setType('create')->setObject('profile')->setWhen()); return header('Location: /logout/quiet'); } else { ServiceDb::getInstance()->delete($u); ServiceMessage::getInstance()->addMessage('Une erreur est survenue #2', 'error'); } } else { ServiceMessage::getInstance()->addMessage('Une erreur est survenue #1', 'error'); } } } } ServiceRenderHtml::newInstance()->load('subscribe')->setData('hideNavigation', true)->render(); }
public function execute($args = null) { $p = ServiceRenderJson::newInstance(); if (isset($_POST['id'], $_POST['type'], $_POST['action'])) { if (!($u = CollectionUser::newInstance()->find($_POST['id']))) { $p->setData('success', false)->setData('message', 'Membre inconnu'); } else { $c = ($_POST['action'] == 'add' ? 'enable' : 'disable') . 'Type'; $r = ServiceAuth::getInstance()->getUser()->getUser_has_user($u); $r->{$c}($_POST['type']); if (ServiceDb::getInstance()->persist($r)) { $p->setData('success', true)->setData('message', 'La relation a bien été ' . ($_POST['action'] == 'add' ? 'ajoutée' : 'supprimée')); ServiceDb::getInstance()->persist(ModelAction::newInstance()->setUser_id(ServiceAuth::getInstance()->getUser()->getId())->setObject('relation')->setValue($u->getLogin() . ' (' . ModelUser_has_user::$shortNames[$_POST['type']] . ')')->setType($_POST['action'] == 'add' ? 'create' : 'delete')->setWhen()); if ($r->getType() == 0) { ServiceAuth::getInstance()->getUser()->delUser_has_user($r); ServiceDb::getInstance()->delete($r); } else { ServiceAuth::getInstance()->getUser()->addUser_has_user($r); } } else { $p->setData('message', 'L\'opération a échoué !'); } } } else { $p->setData('success', false); } $p->render(); }
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 regularAuth($login, $pass, $hashed = false) { if ($user = CollectionUser::newInstance()->findBy(array('login', 'hash'), array($login, $hashed ? $pass : self::createHash($pass)))) { session_regenerate_id(true); $this->user = $user; $this->auth = true; $this->admin = false; return true; } return false; }
public function execute($args = null) { if (!ServiceAuth::getInstance()->isAuth()) { header('Location: /login'); } else { $p = ServiceRenderHtml::newInstance()->load('profile')->setData('user', ServiceAuth::getInstance()->getUser())->setData('guest', false); if ($q = $this->getQueryNext()) { if ($q != ServiceAuth::getInstance()->getUser()->getLogin()) { if ($user = CollectionUser::newInstance()->findBy('login', $q)) { $p->setData('user', $user)->setData('guest', true); } else { $p->load('profile_not_found'); } } } $p->render(); } }