Пример #1
0
	public function save($username, $email, $password, $passwordConfirmation)
	{
		$user = new User($username, $email);
		$user->password = $password;
		$user->passwordConfirmation = $passwordConfirmation;
		
		try
		{
			$key = $user->save();
			$profile = new UserProfile;
			$profile->user = $user;
			$profile->save();
			$mail = $this->mail();
			$mail->username = $username;
			$mail->activationURL = CoOrg::createFullURL(array('user/activate', $username, $key));
			$mail->site = CoOrg::config()->get('site/title');
			$mail->to($email)->subject(t('Complete your registration'))
			     ->send('mails/registration');
			$this->notice(t('We have sent an email to confirm your registration'));
			$this->redirect('/');
		}
		catch (ValidationException $e)
		{
			$this->error(t('We could not complete your registration'));
			$this->user = $user;
			$this->render('create');
		}
	}
	protected function beforeSuccess($commentOn, $comment)
	{
		if ($comment->spamStatus == PropertySpamStatus::UNKNOWN)
		{
			$this->notice('Your comment will be moderated, and will appear on a later time on the site');
			
			$config = CoOrg::config();
			$secondsSinceLastMail = time() - $config->get($this->_configName . '/last-moderation-mail');
			$minSecondsBetweenMails = 60*60*24*$config->get($this->_configName . '/moderation-time');
			if ($secondsSinceLastMail > $minSecondsBetweenMails)
			{
				$config->set($this->_configName . '/last-moderation-mail', time());
				$config->save();
				$receiver = $config->get($this->_configName . '/moderation-email');
				$mail = $this->mail();
				$mail->title = $comment->title;
				$mail->body = $comment->comment;
				$mail->date = $comment->timePosted;
				$mail->messageURL = $this->showURL($commentOn, $comment);
				$mail->moderationURL = CoOrg::createFullURL(array($this->_commentRequests->queue));
				$mail->totalModerationQueue = Comment::moderationQueueLength($this->_commentClass);
				$site = $config->get('site/title');
				$mail->site = $site;
				$mail->to($receiver)
				     ->subject(t('%site: New comment to moderate', array('site' => $site)))
				     ->send(Controller::getTemplatePath('mails/newcomment', 'comments'));
			}
		}
	}
Пример #3
0
	public function save()
	{
		parent::validate('');
		CoOrg::config()->set('blog/enableComments', $this->enableComments);
		CoOrg::config()->set('blog/enableCommentsFor', $this->enableCommentsFor);
		CoOrg::config()->set('blog/moderation-email', $this->moderationEmail);
		CoOrg::config()->set('blog/moderation-time', $this->moderationTime);
		CoOrg::config()->save();
	}
Пример #4
0
	public function run($controller)
	{
		$class = new stdClass;
		$class->language = CoOrg::getLanguage();
		$class->tags = array();
		$class->category = 'text';
		$class->title = CoOrg::config()->get('site/title');
		$class->description = CoOrg::config()->get('site/subtitle');
		return $class;
	}
Пример #5
0
	public function testCoOrgURLOnHome()
	{
		CoOrg::config()->set('path', '/the/path/');
		CoOrg::process('en/');
		$this->assertEquals(array('coorgRequest' => '',
		                          'coorgUrl' => '/the/path/en',
		                          'staticPath' => '/the/path/static/',
		                          'coorgLanguage' => 'en',
		                          'language' => 'en'),
		                    CoOrgSmarty::$vars);
	}
	public function testSaveOutdatedServerList()
	{
		$this->login('uberadmin');
	
		CoOrg::config()->set('mollom/serverlist', array('outdated'));
		
		$this->request('admin/mollom/save', array('publicKey' => 'valid-pub-key',
		                                       'privateKey' => 'valid-priv-key'));
	
		$config = MollomConfig::get();
		$this->assertEquals('valid-pub-key', $config->publicKey);
		$this->assertEquals('valid-priv-key', $config->privateKey);
		$this->assertFlashNotice('Mollom configuration saved');
		$this->assertRedirected('admin/mollom');	
	}
Пример #7
0
	public function save()
	{
		$this->validate('');
		$config = CoOrg::config();
		$config->set('site/title', $this->title);
		$config->set('site/subtitle', $this->subtitle);
		$config->set('site/author', $this->siteAuthor);
		$config->set('site/email', $this->siteContactEmail);
		$config->set('dbdsn', $this->databaseConnection);
		$config->set('dbuser', $this->databaseUser);
		$config->set('dbpass', $this->databasePassword);
		$this->friendlyURL = true;
		$config->set('path', $this->sitePath);
		$config->set('site/uuid', $this->UUID);
		$config->set('defaultLanguage', $this->defaultLanguage);
		$config->save();
	}
Пример #8
0
	public function get()
	{
		if (is_string($this->_value))
		{
			$dataP = CoOrg::getDataPath($this->_dataPath);
			return CoOrg::config()->get('path').$dataP.'/'.$this->_value;
		}
		else if ($this->_value && $this->_value instanceof IFileUpload && $this->_value->isValid())
		{
			return CoOrg::config()->get('path').$this->_value->temppath();
		}
		else if ($this->_oldValue)
		{
			$dataP = CoOrg::getDataPath($this->_dataPath);
			return CoOrg::config()->get('path').$dataP.'/'.$this->_oldValue;
		}
		else
		{
			return null;
		}
	}
Пример #9
0
	public function save()
	{
		parent::validate('');
		Mollom::setPublicKey($this->publicKey);
		Mollom::setPrivateKey($this->privateKey);
		Mollom::setServerList(CoOrg::config()->get('mollom/serverlist'));
		try
		{
			if (!Mollom::verifyKey())
			{
				$this->publicKey_error = t('Invalid keys');
				throw new ValidationException($this);
			}
		}
		catch (ServerListException $e)
		{
			CoOrg::config()->set('mollom/serverlist', Mollom::getServerList());
			try
			{
				if (!Mollom::verifyKey())
				{
					$this->publicKey_error = t('Invalid keys');
					CoOrg::config()->save(); // Save the new serverlist
					throw new ValidationException($this);
				}
			}
			catch (InternalException $e)
			{
				
			}
			catch (ServerListException $e)
			{
			}
		}
		CoOrg::config()->set('mollom/public', $this->publicKey);
		CoOrg::config()->set('mollom/private', $this->privateKey);
		CoOrg::config()->save();
	}
Пример #10
0
	public function testCreateForNonEnglishDefaultInEnglish()
	{
		CoOrg::config()->set('urlPrefix', ':language');
		CoOrg::setDefaultLanguage('nl');
		$entry = new MenuEntry;
		$entry->menuID = 'main';
		$entry->title = 'Blog no 7';
		$entry->language = 'en';
		$entry->entryID = 'BlogMenuEntryProvider/show/2010-05-04/blog-no-7';
		$entry->save();
		$this->assertEquals('en/blog/show/2010/05/04/blog-no-7', $entry->url);
	}
	public function testSaveNonConfigurable()
	{
		$this->login('dvorak');
		$this->request('admin/layout/save',
			array('panelID' => 'navigation-left',
			      'widgetName' => 'blog/archive'));

		$config = CoOrg::config();
		$this->assertEquals(array(array('widgetID' => 'menu/menu', 'menu' => 'someMenu'), 
		                          'blog/archive'),
						    $config->get('aside/navigation-left'));
		$this->assertRedirected('admin/layout');
	}
	public function renew($username, $resetKey)
	{
		$user = User::getUserByName($username);
		$password = $user->generateNewPassword($resetKey);
		if ($password)
		{
			$user->save();
			
			$site = CoOrg::config()->get('site/title');
			$mail = $this->mail();
			$mail->username = $user->username;
			$mail->newpassword = $password;
			$mail->loginURL = CoOrg::createFullURL(array('user/login'));
			$mail->site = $site;
			$mail->to($user->email)
			     ->subject(t('%site: Your new password', array('site' => $site)))
			     ->send('mails/passwordrenew');
			$this->notice('A mail has been sent to you, containing your new password');
			$this->redirect('/');
		}
		else
		{
			$this->error(t('Invalid key'));
			$this->redirect('/');
		}
	}
Пример #13
0
	private function addTemplateDirs($smarty)
	{
		$theme = CoOrg::config()->get('theme');
		if ($theme && $theme != 'default')
		{
			$smarty->addTemplateDir($this->_tplPath.'/'.$theme);
		}
		$smarty->addTemplateDir($this->_tplPath.'/default/');
	}
Пример #14
0
	public function testThemes()
	{
		CoOrg::config()->set('path', '/');
		CoOrg::config()->set('theme', 'testtheme');
		CoOrg::process('/');
		
		$this->assertEquals('/static/testtheme/mockfile.css?v=testtheme',
		                    CoOrg::staticFile('mockfile.css'));

		$this->assertEquals('/static/default/onlydefault.css?v=A',
		                    CoOrg::staticFile('onlydefault.css'));
		                    
		$this->assertEquals('/coorg/tests/mocks/plugins/alpha/static/testtheme/somefile.css?v=alphaV',
		                    CoOrg::staticFile('somefile.css', 'alpha'));
		
		$this->assertEquals('/coorg/tests/mocks/plugins/alpha/static/default/onlydefault.css?v=2010-10-03',
		                    CoOrg::staticFile('onlydefault.css', 'alpha'));
		                    
		$this->assertEquals(array(
			'/coorg/tests/mocks/plugins/alpha/static/default/extends.css?v=baseV',
			'/coorg/tests/mocks/plugins/alpha/static/testtheme/extends.css?v=extendsV'),
		                    CoOrg::staticFile('extends.css', 'alpha'));

		$this->assertEquals(array(
			'/static/default/extends.css?v=baseV',
			'/static/testtheme/extends.css?v=extendsV'),
		                    CoOrg::staticFile('extends.css'));
	}
Пример #15
0
	public function testSaveOtherConfiguration()
	{
		CoOrg::config()->set('blog/enableComments', false);
		CoOrg::config()->set('blog/enableCommentsFor', 0);
		$this->login();
		$this->request('blog/save', array('title' => 'My Blog Title',
		                                  'text' => 'My blog contents',
		                                  'tags' => array()));

		$this->assertFlashNotice('Your blog item is saved');
		
		$year = date('Y');
		$month = date('m');
		$day = date('d');
		$this->assertRedirected('blog/show/'.$year.'/'.$month.'/'.$day.'/my-blog-title');
		$blog = Blog::getBlog($year, $month, $day, 'my-blog-title', 'en');
		$this->assertFalse($blog->commentsAllowed);
		$this->assertNull($blog->commentsCloseDate);
	}
	public function testSaveAnonymousUnknownWithModerationMail()
	{
		CoOrg::config()->set('blog/moderation-email', '*****@*****.**');
		CoOrg::config()->set('blog/moderation-time', 1);
		CoOrg::config()->set('blog/last-moderation-mail', time()-60*60*33); // Last mail sent 33 hours ago
		$this->request('blog/comment/save', array(
			'blogID' => 'some-other-blog',
			'blogDate' => '2010-04-10',
			'blogLanguage' => 'en',
			'comment' => 'UNKNOWN BODY',
			'name' => 'My Anon',
			'email' => '*****@*****.**'));
		
		$this->assertFlashNotice('Your comment will be moderated, and will appear on a later time on the site');
		$this->assertRedirected('blog/show/2010/4/10/some-other-blog');
		
		$blog = Blog::getBlog('2010', '04', '10', 'some-other-blog', 'en');
		$this->assertEquals(1, count($blog->comments));
		$this->assertMailSent('*****@*****.**', 'The Site: New comment to moderate',
		                      'plugins/comments/views/default/mails/newcomment',
		                      array('totalModerationQueue' => '2', // This new one + 1 in DB
		                            'title' => 'RE: Some Other Blog',
		                            'body' => 'UNKNOWN BODY',
		                            'date' => '**?**',
		                            'messageURL' => 'http://www.test.info/blog/show/2010/4/10/some-other-blog#comment'.$blog->comments[0]->ID,
		                            'moderationURL' => 'http://www.test.info/admin/blog/comment',
		                            'site' => 'The Site'));
		$config = new Config(COORG_TEST_CONFIG);
		$this->assertLessThan(2, abs(time() - $config->get('blog/last-moderation-mail')));
	}
Пример #17
0
	public function testFeedbackProblem()
	{
		CoOrg::config()->set('mollom/serverlist', array('outdated'));
		
		$this->assertTrue(MollomMessage::feedback('some-sess-id', 'profanity'));
	}
Пример #18
0
	protected function find($panelID, $widgetID)
	{
		$this->_panel = CoOrg::config()->get('aside/'.$panelID);
		if ($this->_panel === null)
		{
			$this->error(t('Panel not found'));
			$this->redirect('admin/layout');
		}
		$widgetID = (int)$widgetID;
		if ($widgetID >= count($this->_panel))
		{
			$this->error(t('Widget not found'));
			$this->redirect('admin/layout');
		}
		
		$this->_widget = $this->_panel[$widgetID];
		return true;
	}
Пример #19
0
	private function prepare()
	{
		Mollom::setPublicKey(CoOrg::config()->get('mollom/public'));
		Mollom::setPrivateKey(CoOrg::config()->get('mollom/private'));
		Mollom::setServerList(CoOrg::config()->get('mollom/serverlist'));
	}
	public function testSaveConfig()
	{
		$this->login('uberadmin');
		$this->request('admin/blog/configsave', array(
		                    'enableComments' => 'on',
		                    'enableCommentsFor' => 14,
		                    'moderationEmail' => '*****@*****.**',
		                    'moderationTime' => 2
		));
		
		$this->assertFlashNotice('Saved blog configuration');
		$this->assertRedirected('admin/blog/config');
		$this->assertTrue(CoOrg::config()->get('blog/enableComments'));
		$this->assertEquals(14, CoOrg::config()->get('blog/enableCommentsFor'));
		$this->assertEquals(2, CoOrg::config()->get('blog/moderation-time'));
		$this->assertEquals('*****@*****.**', CoOrg::config()->get('blog/moderation-email'));
	}