Esempio n. 1
0
 public function __construct(Application $app, $force = false)
 {
     if ($force) {
         $this->remove_lock_file();
     }
     if ($this->lock_exists()) {
         throw new Exception_Setup_UpgradeAlreadyStarted('The upgrade is already started');
     }
     $this->app = $app;
     $checker = new MailChecker($app['phraseanet.appbox']);
     if ($checker->hasWrongEmailUsers()) {
         throw new \Exception_Setup_FixBadEmailAddresses('Please fix the database before starting');
     }
     $this->write_lock();
     return $this;
 }
Esempio n. 2
0
 protected function doExecute(InputInterface $input, OutputInterface $output)
 {
     $output->writeln("Processing...");
     /** @var appbox $appBox */
     $appBox = $this->getService('phraseanet.appbox');
     $checker = new MailChecker($appBox);
     $bad_users = $checker->getWrongEmailUsers();
     foreach ($bad_users as $email => $users) {
         if ($input->getOption('list')) {
             $this->write_infos($email, $users, $output, $appBox);
         } elseif ($this->manage_group($email, $users, $output, $appBox) === false) {
             break;
         }
         $output->writeln("");
     }
     $output->write('Finished !', true);
     return 0;
 }
Esempio n. 3
0
 public function __construct(Application $app, $force = false)
 {
     if ($force) {
         self::remove_lock_file();
     }
     if (self::lock_exists()) {
         throw new Exception_Setup_UpgradeAlreadyStarted('The upgrade is already started');
     }
     $this->appbox = $app['phraseanet.appbox'];
     if (version_compare($this->appbox->get_version(), '3.9', '<') && count(MailChecker::getWrongEmailUsers($app)) > 0) {
         throw new \Exception_Setup_FixBadEmailAddresses('Please fix the database before starting');
     }
     $this->write_lock();
     return $this;
 }
Esempio n. 4
0
 protected function doExecute(InputInterface $input, OutputInterface $output)
 {
     $output->writeln("Processing...");
     $bad_users = [];
     if (version_compare($this->getService('phraseanet.appbox')->get_version(), '3.9', '<')) {
         $bad_users = MailChecker::getWrongEmailUsers($this->container);
     }
     foreach ($bad_users as $email => $users) {
         if ($input->getOption('list')) {
             $this->write_infos($email, $users, $output, $this->getService('phraseanet.appbox'));
         } elseif ($this->manage_group($email, $users, $output, $this->getService('phraseanet.appbox')) === false) {
             break;
         }
         $output->writeln("");
     }
     $output->write('Finished !', true);
     return 0;
 }
Esempio n. 5
0
 public function testMailChecker()
 {
     $conn = self::$DI['app']['phraseanet.appbox']->get_connection();
     $now = new \DateTime();
     $stmt = $conn->prepare('CREATE TEMPORARY TABLE usr_tmp (usr_id INT, usr_mail VARCHAR(50), usr_login VARCHAR(50), last_conn DATETIME);');
     $stmt->execute();
     $stmt->closeCursor();
     $stmt = $conn->prepare('INSERT INTO usr_tmp (usr_id, usr_mail, usr_login, last_conn) VALUES(1, "*****@*****.**", "login1", "' . $now->format('Y-m-D H:i:s') . '");');
     $stmt->execute();
     $stmt->closeCursor();
     $stmt = $conn->prepare('INSERT INTO usr_tmp (usr_id, usr_mail, usr_login, last_conn) VALUES(2, "*****@*****.**", "login2", "' . $now->format('Y-m-D H:i:s') . '");');
     $stmt->execute();
     $stmt->closeCursor();
     unset($stmt);
     $users = MailChecker::getWrongEmailUsers(self::$DI['app'], 'usr_tmp');
     $this->assertEquals(1, count($users));
     $this->assertEquals(2, count($users['*****@*****.**']));
 }
Esempio n. 6
0
 public function testItHasNoDuplicateEmailUsers()
 {
     $checker = new MailChecker(self::$DI['app']['phraseanet.appbox'], 'usr_tmp');
     $this->assertFalse($checker->hasWrongEmailUsers());
 }