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'));
			}
		}
	}
	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');
		}
	}
Exemple #3
0
	public function run($widgetParams, $orient, $request)
	{
		if (Flattr::needsWidget($request))
		{
			$args = func_get_args();
			array_shift($args); // $widgetParams
			array_shift($args); // $orient
			$url = CoOrg::createFullURL($args);
			$widget = Flattr::widget($this, $request);
			$this->flattrTitle = $widget->title;
			$this->flattrDescription = $widget->description;
			$this->flattrLanguage = $widget->language;
			$this->flattrTags = $widget->tags;
			$this->flattrCategory = $widget->category;
			$this->flattrUID = $widgetParams['uid'];
			$this->flattrButton = $orient == CoOrg::PANEL_ORIENT_VERTICAL ? 'default' : 'compact';
			$this->flattrLink = $url;
			return $this->render('flattr-button');
		}
	}
	public function showURL($commentOn, $comment)
	{
		return CoOrg::createFullURL(array(
				        'blog/show',
				        $commentOn->year,
				        $commentOn->month,
				        $commentOn->day,
				        $commentOn->ID),
				        CoOrg::getDefaultLanguage(),
				        'comment'.$comment->ID
				        );
	}
	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('/');
		}
	}