コード例 #1
0
ファイル: AddUser.php プロジェクト: Jazzee/Jazzee
 protected function execute(\Symfony\Component\Console\Input\InputInterface $input, \Symfony\Component\Console\Output\OutputInterface $output)
 {
     $jazzeeConfiguration = new \Jazzee\Configuration();
     $entityManager = $this->getHelper('em')->getEntityManager();
     $stub = new AdminStub();
     $stub = new AdminStub();
     $stub->em = $entityManager;
     $stub->config = $jazzeeConfiguration;
     $class = $jazzeeConfiguration->getAdminDirectoryClass();
     $directory = new $class($stub);
     $results = $directory->findByUniqueName($input->getArgument('user name'));
     if (count($results) == 0) {
         $output->write('<error>That user name is not in the directory.</error>' . PHP_EOL);
     } else {
         if (count($results) > 1) {
             $output->write('<error>This name is not unique in the directory.  It returned ' . count($results) . ' results.</error>' . PHP_EOL);
             $output->write('<error>The name belongs to:</error>' . PHP_EOL);
             foreach ($results as $arr) {
                 $output->write("<error>{$arr['lastName']}, {$arr['firstName']} ({$arr['emailAddress']})</error>" . PHP_EOL);
             }
         } else {
             $arr = $results[0];
             $user = new \Jazzee\Entity\User();
             $user->setUniqueName($arr['userName']);
             $user->setFirstName($arr['firstName']);
             $user->setLastName($arr['lastName']);
             $user->setEmail($arr['emailAddress']);
             $entityManager->persist($user);
             $entityManager->flush();
             $output->write("<info>{$arr['lastName']}, {$arr['firstName']} ({$arr['emailAddress']}) add as user #{$user->getId()}</info>" . PHP_EOL);
         }
     }
 }
コード例 #2
0
ファイル: CreateUser.php プロジェクト: Jazzee/Jazzee
 protected function execute(\Symfony\Component\Console\Input\InputInterface $input, \Symfony\Component\Console\Output\OutputInterface $output)
 {
     $jazzeeConfiguration = new \Jazzee\Configuration();
     if ($jazzeeConfiguration->getAdminDirectoryClass() != '\\Jazzee\\AdminDirectory\\Local') {
         $output->write('<error>You can only user create-user when the adminDirectoryClass is set to Jazzee\\AdminDirectory\\Local</error>' . PHP_EOL);
     }
     $entityManager = $this->getHelper('em')->getEntityManager();
     $existingUsers = $entityManager->getRepository('Jazzee\\Entity\\User')->findByUniqueName($input->getArgument('user name'));
     if (count($existingUsers) == 0) {
         $user = new \Jazzee\Entity\User();
         $user->setUniqueName($input->getArgument('user name'));
         $user->setFirstName($input->getArgument('first name'));
         $user->setLastName($input->getArgument('last name'));
         $user->setEmail($input->getArgument('email'));
         $entityManager->persist($user);
         $entityManager->flush();
         $output->write("<info>New user #{$user->getId()} created</info>" . PHP_EOL);
     } else {
         $output->write("<error>There is already a user with the name {$input->getArgument('user name')}</error>" . PHP_EOL);
     }
 }
コード例 #3
0
 /**
  * Create a preview application
  * @param \Doctrine\ORM\EntityManager $em
  * @param \Jazzee\Entity\Role $adminRole
  * @return \Jazzee\Entity\Application
  */
 protected function createPreviewApplication(\Doctrine\ORM\EntityManager $em, \Jazzee\Entity\Role $adminRole)
 {
     $newApplication = new \Jazzee\Entity\Application();
     $properties = array('contactName', 'contactEmail', 'welcome', 'statusIncompleteText', 'statusNoDecisionText', 'statusAdmitText', 'statusDenyText', 'statusAcceptText', 'statusDeclineText');
     foreach ($properties as $name) {
         $set = 'set' . ucfirst($name);
         $get = 'get' . ucfirst($name);
         $newApplication->{$set}($this->_application->{$get}());
     }
     $timeProperties = array('open', 'close', 'begin');
     foreach ($timeProperties as $name) {
         $set = 'set' . ucfirst($name);
         $get = 'get' . ucfirst($name);
         $newApplication->{$set}($this->_application->{$get}()->format('c'));
     }
     $newApplication->publish(true);
     $newApplication->visible();
     $program = new \Jazzee\Entity\Program();
     $program->setName($this->_program->getName());
     $program->setShortName($this->_program->getShortName());
     $em->persist($program);
     $newApplication->setProgram($program);
     $cycle = new \Jazzee\Entity\Cycle();
     $cycle->setName($this->_cycle->getName());
     $cycle->setStart('yesterday');
     $cycle->setEnd('next year');
     $em->persist($cycle);
     $newApplication->setCycle($cycle);
     foreach ($this->_application->getApplicationPages() as $applicationPage) {
         $newPage = $this->copyPage($em, $applicationPage->getPage());
         $newApplicationPage = new \Jazzee\Entity\ApplicationPage();
         $newApplicationPage->setApplication($newApplication);
         $newApplicationPage->setPage($newPage);
         $newApplicationPage->setWeight($applicationPage->getWeight());
         $newApplicationPage->setKind($applicationPage->getKind());
         $newApplicationPage->setTitle($applicationPage->getTitle());
         $newApplicationPage->setMin($applicationPage->getMin());
         $newApplicationPage->setMax($applicationPage->getMax());
         $newApplicationPage->setInstructions($applicationPage->getInstructions());
         $newApplicationPage->setLeadingText($applicationPage->getLeadingText());
         $newApplicationPage->setTrailingText($applicationPage->getTrailingText());
         if ($applicationPage->isRequired()) {
             $newApplicationPage->required();
         } else {
             $newApplicationPage->optional();
         }
         if ($applicationPage->showAnswerStatus()) {
             $newApplicationPage->showAnswerStatus();
         } else {
             $newApplicationPage->hideAnswerStatus();
         }
         $em->persist($newApplicationPage);
     }
     $em->persist($newApplication);
     $newRole = new \Jazzee\Entity\Role();
     $newRole->setName('Preview Access');
     $newRole->notGlobal();
     $newRole->setProgram($program);
     foreach ($adminRole->getActions() as $action) {
         $newAction = new \Jazzee\Entity\RoleAction();
         $newAction->setRole($newRole);
         $newAction->setAction($action->getAction());
         $newAction->setController($action->getController());
         $em->persist($newAction);
     }
     $em->persist($newRole);
     $user = new \Jazzee\Entity\User();
     $user->setUniqueName('previewuser');
     $user->activate();
     $user->setEmail('*****@*****.**');
     $user->setFirstName('Preview');
     $user->setLastName('Application User');
     $user->addRole($newRole);
     $user->setDefaultCycle($cycle);
     $user->setDefaultProgram($program);
     $em->persist($user);
     foreach ($this->_em->getRepository('\\Jazzee\\Entity\\Template')->findByApplication($this->_application) as $template) {
         $newTemplate = new \Jazzee\Entity\Template($template->getType());
         $newTemplate->setApplication($newApplication);
         $newTemplate->setText($template->getText());
         $newTemplate->setTitle($template->getTitle());
         $em->persist($newTemplate);
     }
     $em->flush();
     return $newApplication;
 }
コード例 #4
0
ファイル: setup_users.php プロジェクト: Jazzee/Jazzee
 /**
  * Add a user to the program
  * @param string $uniqueName
  */
 public function actionNew($uniqueName)
 {
     $uniqueName = base64_decode($uniqueName);
     if ($user = $this->_em->getRepository('\\Jazzee\\Entity\\User')->findOneBy(array('uniqueName' => $uniqueName))) {
         if (!$user->isActive()) {
             $user->activate();
             $this->_em->persist($user);
             $this->addMessage('success', "User Account Activated");
         }
     } else {
         $directory = $this->getAdminDirectory();
         $result = $directory->findByUniqueName($uniqueName);
         if (!isset($result[0])) {
             $this->addMessage('error', "Unable to find entry in directory");
             $this->redirectPath('setup/users');
         }
         $user = new \Jazzee\Entity\User();
         $user->setUniqueName($result[0]['userName']);
         $user->setFirstName($result[0]['firstName']);
         $user->setLastName($result[0]['lastName']);
         $user->setEmail($result[0]['emailAddress']);
         $this->_em->persist($user);
         $this->_em->flush();
     }
     $this->redirectPath('setup/users/edit/' . $user->getId());
 }
コード例 #5
0
ファイル: OpenID.php プロジェクト: Jazzee/Jazzee
 /**
  * @SuppressWarnings(PHPMD.ExitExpression)
  */
 public function loginUser()
 {
     $returnTo = $this->_controller->absolutePath('login');
     $realm = $this->_controller->absoluetPath('');
     if (!empty($_POST['openid_identifier'])) {
         $identifier = $_POST['openid_identifier'];
         $relayParty = new \OpenID_RelyingParty($returnTo, $realm, $identifier);
         $authRequest = $relayParty->prepare();
         $authExtension = new \OpenID_Extension_AX(\OpenID_Extension::REQUEST);
         $authExtension->set('type.email', 'http://axschema.org/contact/email');
         $authExtension->set('type.firstname', 'http://axschema.org/namePerson/first');
         $authExtension->set('type.lastname', 'http://axschema.org/namePerson/last');
         $authExtension->set('mode', 'fetch_request');
         $authExtension->set('required', 'email,firstname,lastname');
         $authRequest->addExtension($authExtension);
         header('Location: ' . $authRequest->getAuthorizeURL());
         exit(0);
     }
     $relayParty = new \OpenID_RelyingParty($returnTo, $realm);
     $arr = explode('?', $_SERVER['REQUEST_URI']);
     $queryString = isset($arr[1]) ? $arr[1] : '';
     if ($queryString) {
         $message = new \OpenID_Message($queryString, \OpenID_Message::FORMAT_HTTP);
         $result = $relayParty->verify(new \Net_URL2($returnTo), $message);
         if ($result->success()) {
             $this->_controller->getStore()->expire();
             $this->_controller->getStore()->touchAuthentication();
             $authExtension = new \OpenID_Extension_AX(\OpenID_Extension::RESPONSE, $message);
             $uniqueName = $message->get('openid.claimed_id');
             $email = $authExtension->get('value.email');
             $firstName = $authExtension->get('value.firstname');
             $lastName = $authExtension->get('value.lastname');
             $this->_controller->getStore()->set(self::SESSION_VAR_ID, $uniqueName);
             $user = $this->_controller->getEntityManager()->getRepository('\\Jazzee\\Entity\\User')->findOneBy(array('uniqueName' => $uniqueName));
             if (!$user) {
                 $user = new \Jazzee\Entity\User();
                 $user->setUniqueName($uniqueName);
             }
             $user->setFirstName($firstName);
             $user->setLastName($lastName);
             $user->setEmail($email);
             $this->_controller->getEntityManager()->persist($user);
             $this->_user = $user;
         }
     }
 }