protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->output = $output;
     if (!($port = $input->getOption('port'))) {
         $this->logError('необходимо указать переметр <info>port</info>');
         die;
     }
     if ($project_id = $input->getOption('project_id')) {
         if (!($project = ProjectQuery::create()->findOneById($project_id))) {
             $this->logError('Project by id=' . $project_id . ' not found');
         } else {
             $this->addCustomPort($project, $port);
             //прописываем кастомный порт
         }
     } elseif ($user_name = $input->getOption('user')) {
         if (!($user = UserQuery::create()->findOneByUsername($user_name))) {
             $this->logError('Пользователь с именем <info>' . $user_name . '</info> не найден');
         } else {
             $projects = $this->getProjectService()->getProjectList($user);
             if (!count($projects)) {
                 $this->logError('У пользователя <info>' . $user_name . '</info> не найден ни один проект');
             } else {
                 foreach ($projects as $project_item) {
                     $this->addCustomPort($project_item, $port);
                 }
             }
         }
     } else {
         $this->logError('необходимо указать хотя бы один параметр (<info>project_id</info> или <info>user</info>)');
     }
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->output = $output;
     if (!($user_name = $input->getOption('user'))) {
         $this->error('Параметр user не указан');
     }
     if (!($user = UserQuery::create()->findOneByUsername($user_name))) {
         $this->error('Пользовать с именем ' . $user_name . ' не найден');
     }
     if (!($path = $input->getOption('path'))) {
         $this->error('Параметр path не указан');
     }
     $links_json = $this->getJson($path);
     if (!count($links_json)) {
         $this->error('В json-списке нет ни одной ссылки на добавление');
     }
     foreach ($links_json as $link) {
         $result = $this->getProjectService()->addProjectByLink($user, $link);
         if (!$result) {
             $this->error('не удалось добавить проект <comment>' . $link . '</comment>', false);
         } else {
             $this->log('<info>SUCCESS</info>: ' . $link);
         }
     }
 }
 public function registerAction()
 {
     if ($this->get('security.context')->isGranted('IS_AUTHENTICATED_FULLY')) {
         return $this->redirect($this->generateUrl('org_desktop'));
     }
     $request = $this->getRequest();
     $translator = $this->get('translator');
     $userAlreadyExists = false;
     $userManager = $this->get('fos_user.user_manager');
     //Create user
     $user = $userManager->createUser();
     $form = $this->createForm(new RegisterType(), $user);
     if ($request->getMethod() == 'POST') {
         $form->handleRequest($request);
         if ($form->isValid()) {
             $userAlreadyExists = count(UserQuery::create()->findByUsername($user->getUsername())) > 0;
             if (!$userAlreadyExists) {
                 $user->setEnabled(1);
                 $userManager->updateUser($user);
                 $token = new UsernamePasswordToken($user, null, 'main', $user->getRoles());
                 $this->get('security.token_storage')->setToken($token);
                 return $this->redirectToRoute('org_desktop');
             }
         }
     }
     $vars = array('form' => $form->createView());
     if ($userAlreadyExists) {
         $vars['uniqueUserError'] = $translator->trans('Użytkownik o takiej nazwie już istnieje!');
     }
     return $this->render('OrganizerBundle:Users:register.html.twig', $vars);
 }
示例#4
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->output = $output;
     $is_custom_port = $input->getOption('custom-port') == 'true';
     if ($trade_rehost = $input->getOption('trade-rehost') == 'true') {
         $rehosts = [];
     }
     $check_service = $this->getCheckService();
     if ($user_name = $input->getOption('user-name')) {
         if (!($user = UserQuery::create()->findOneByUsername($user_name))) {
             $this->logError('Пользователь с именем ' . $user_name . ' не найден');
             die;
         } else {
             $project_list = $this->getProjectService()->getProjectList($user, true, $is_custom_port);
         }
     } else {
         $project_list = $this->getProjectService()->getProjectsAll(true, $is_custom_port);
     }
     if (count($project_list)) {
         $this->log('Проектов на проверку: <info>' . count($project_list) . '</info>');
         foreach ($project_list as $project) {
             /** @var Project $project */
             $custom_port = $is_custom_port ? $project->getPort() : false;
             $project_links = $project->getLinks(true);
             //$this->log('<comment>'.$project->getTitle().'</comment> - <info>'.count($project_links).'</info> ссылок');
             if (count($project_links)) {
                 //идём по опубликованным ссылкам сайта
                 foreach ($project_links as $project_link) {
                     /** @var ProjectLink $project_link */
                     $project_link = $check_service->updateLink($project_link, $custom_port);
                     if ($project_link->getStatusCode() == 301) {
                         $this->log('<comment>' . $project->getTitle() . '</comment> ' . $project_link->getTitle() . ' <comment>' . $project_link->getStatusCode() . '</comment> <info>' . $project_link->getTotalTime() . '</info> редиректит на <comment>' . $project_link->getRedirectUrl() . '</comment>');
                         if ($trade_rehost && $project_link->getRedirectUrl() == 'http://4x4.toyota-ekaterinburg.ru/') {
                             $rehosts[] = $project->getLink();
                         }
                     }
                 }
             }
         }
         //ребилдинг доменов для трейда
         if ($trade_rehost && count($rehosts)) {
             $hosts = "";
             foreach ($rehosts as $host) {
                 if ($hosts) {
                     $hosts .= ',';
                 }
                 $hosts .= $host;
             }
             $command = "generate:hosts --domains={" . $hosts . "} --rebuild={" . $hosts . "}";
             $this->log('');
             $this->log($command);
         }
     } else {
         $this->log('нет ни одного проекта на проверку');
     }
 }
示例#5
0
 public function testSerialize()
 {
     $group = new Group();
     $group->setName('Developers');
     $user = new User();
     $user->setEmail('*****@*****.**');
     $user->setPassword('123456');
     $user->addGroup($group);
     $user->save();
     $userId = $user->getId();
     $this->assertInternalType('int', $userId);
     $serialized = serialize($user);
     UserPeer::clearInstancePool();
     $this->assertCount(0, UserPeer::$instances);
     $unserialized = unserialize($serialized);
     $fetchedUser = UserQuery::create()->findOneById($userId);
     $this->assertInstanceOf('FOS\\UserBundle\\Propel\\User', $unserialized);
     $this->assertCount(1, UserPeer::$instances);
     $this->assertTrue($fetchedUser->equals($unserialized));
     $this->assertCount(1, $unserialized->getGroups());
 }
示例#6
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->output = $output;
     if (!($user_name = $input->getOption('user_name'))) {
         $this->logError('необходимо указать пераметр <info>user_name</info>');
         die;
     }
     if (!($user = UserQuery::create()->findOneByUsername($user_name))) {
         $this->logError('Пользователь с именем <info>' . $user_name . '</info> не найден');
     } else {
         $projects = $this->getProjectService()->getProjectList($user);
         if (!count($projects)) {
             $this->logError('У пользователя <info>' . $user_name . '</info> не найден ни один проект');
         } else {
             foreach ($projects as $project_item) {
                 /** @var Project $project_item */
                 $custom_port_text = $project_item->getPort() ? ' кастомный порт:<comment>' . $project_item->getPort() . ' </comment>' : '';
                 $this->log('id:<comment>' . $project_item->getId() . '</comment> title:<comment>' . $project_item->getTitle() . '</comment>' . $custom_port_text);
             }
         }
     }
 }
 /**
  * Get the associated User object
  *
  * @param PropelPDO $con Optional Connection object.
  * @param $doQuery Executes a query to get the object if required
  * @return User The associated User object.
  * @throws PropelException
  */
 public function getUser(PropelPDO $con = null, $doQuery = true)
 {
     if ($this->aUser === null && $this->id_user !== null && $doQuery) {
         $this->aUser = UserQuery::create()->findPk($this->id_user, $con);
         /* The following can be used additionally to
               guarantee the related object contains a reference
               to this object.  This level of coupling may, however, be
               undesirable since it could result in an only partially populated collection
               in the referenced object.
               $this->aUser->addCustomListss($this);
            */
     }
     return $this->aUser;
 }
示例#8
0
 /**
  * Gets the number of User objects related by a many-to-many relationship
  * to the current object by way of the fos_user_group cross-reference table.
  *
  * @param Criteria $criteria Optional query object to filter the query
  * @param boolean $distinct Set to true to force count distinct
  * @param PropelPDO $con Optional connection object
  *
  * @return int the number of related User objects
  */
 public function countUsers($criteria = null, $distinct = false, PropelPDO $con = null)
 {
     if (null === $this->collUsers || null !== $criteria) {
         if ($this->isNew() && null === $this->collUsers) {
             return 0;
         } else {
             $query = UserQuery::create(null, $criteria);
             if ($distinct) {
                 $query->distinct();
             }
             return $query->filterByGroup($this)->count($con);
         }
     } else {
         return count($this->collUsers);
     }
 }
示例#9
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->output = $output;
     $is_custom_port = $input->getOption('custom-port') == 'true';
     $only_bad_text = $input->getOption('only-bad-text') == 'true';
     $timeout = $input->getOption('timeout') ? $input->getOption('timeout') : 15;
     $project_service = $this->getProjectService();
     $check_service = $this->getCheckService();
     if ($user_name = $input->getOption('user-name')) {
         if (!($user = UserQuery::create()->findOneByUsername($user_name))) {
             $this->logError('Пользователь с именем ' . $user_name . ' не найден');
             die;
         } else {
             $project_list = $project_service->getProjectList($user, true, $is_custom_port);
         }
     } else {
         $project_list = $project_service->getProjectsAll(true, $is_custom_port);
     }
     if (count($project_list)) {
         $this->log('Проектов на проверку: <info>' . count($project_list) . '</info>');
         foreach ($project_list as $project) {
             /** @var Project $project */
             $custom_port = $is_custom_port ? $project->getPort() : false;
             $project_links = $project->getLinks(true);
             if (!$only_bad_text) {
                 $this->log('<comment>' . $project->getTitle() . '</comment> - <info>' . count($project_links) . '</info> ссылок');
             }
             if (count($project_links)) {
                 $bad_links = array();
                 //плохие ссылки
                 //идём по опубликованным ссылкам сайта
                 foreach ($project_links as $project_link) {
                     /** @var ProjectLink $project_link */
                     $project_link = $check_service->updateLink($project_link, $custom_port, $timeout);
                     $status_log_text = $project_link->getTitle() . ' <comment>' . $project_link->getStatusCode() . '</comment> <info>' . $project_link->getTotalTime() . '</info> ' . $project_link->getLink();
                     if (!$project_link->getStatus() || !$only_bad_text) {
                         $project_link->getStatus() ? $this->log($status_log_text) : $this->logError($status_log_text);
                     }
                     if (!$project_link->getStatus()) {
                         $bad_links[$project_link->getId()] = $project_link;
                     }
                 }
                 if (!$custom_port) {
                     //если есть плохие ссылки, и проект был со статусом "всё ок", то отправляем уведомление на почту
                     if (count($bad_links) && $project->getStatus()) {
                         $project->setStatus(0)->save();
                         if (!$only_bad_text) {
                             $this->log('---------------------------------> Отправляем плохое письмо');
                         }
                         $result_send = $this->sendBadMail($project, $bad_links, $custom_port);
                         if (!$only_bad_text) {
                             $this->resultSendMail($result_send);
                             //отправляем письмо
                         }
                     } else {
                         if (!count($bad_links) && !$project->getStatus()) {
                             //нет плохих ссылок, но были, то отправляем письмо, что всё хорошо
                             $project->setStatus(1)->save();
                             if (!$only_bad_text) {
                                 $this->log('---------------------------------> Отправляем хорошее письмо');
                             }
                             $result_send = $this->sendGoodMail($project, $custom_port);
                             if (!$only_bad_text) {
                                 $this->resultSendMail($result_send);
                                 //отправляем письмо
                             }
                         }
                     }
                 }
             }
             if (!$only_bad_text) {
                 $this->log('');
             }
         }
     } else {
         $this->log('нет ни одного проекта на обновление');
     }
 }
示例#10
0
 /**
  * Removes this object from datastore and sets delete attribute.
  *
  * @param PropelPDO $con
  * @return void
  * @throws PropelException
  * @throws Exception
  * @see        BaseObject::setDeleted()
  * @see        BaseObject::isDeleted()
  */
 public function delete(PropelPDO $con = null)
 {
     if ($this->isDeleted()) {
         throw new PropelException("This object has already been deleted.");
     }
     if ($con === null) {
         $con = Propel::getConnection(UserPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     $con->beginTransaction();
     try {
         $deleteQuery = UserQuery::create()->filterByPrimaryKey($this->getPrimaryKey());
         $ret = $this->preDelete($con);
         if ($ret) {
             $deleteQuery->delete($con);
             $this->postDelete($con);
             $con->commit();
             $this->setDeleted(true);
         } else {
             $con->commit();
         }
     } catch (Exception $e) {
         $con->rollBack();
         throw $e;
     }
 }