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'));
			}
		}
	}
Пример #2
0
	protected function doRender($tpl, $base = null)
	{
		$theme = CoOrg::getTheme();
		if ($theme != 'default')
		{
			$file = $this->_viewsPath.$theme.'/'.$tpl.'.html.tpl';
			if (!file_exists($file))
			{
				$file = $this->_viewsPath.'default/'.$tpl.'.html.tpl';
			}
		}
		else
		{
			$file = $this->_viewsPath.'default/'.$tpl.'.html.tpl';
		}
		if ($base)
		{
			$tpl = $this->_smarty->createTemplate('extends:'.$base.'|'.$file, $this->_data);
		}
		else
		{
			$tpl = $this->_smarty->createTemplate($file, $this->_data);
		}
		return $tpl->fetch();
	}
Пример #3
0
	protected function renderInput()
	{
		$input = '<input type="'.$this->_type.'" name="'.$this->_name.'" '. 'id="'.$this->getID().'"';
		if ($this->_value)
		{
			$this->_inputAttributes->value = $this->_value;
		}
		else
		{
			// It is possible that the same inputis rendered more than once
			// (eg for the ListInput), and the value is changed to null.
			unset($this->_inputAttributes->value);
		}
		$input .= $this->renderOptions();
		$input .= '/><br />';
		if ($this->_autocomplete)
		{
			$input .= '<script>';
			if ($this->_autocomplete)
			{
				$input .= 'CoOrgAutoSuggest($("#'.$this->getID().'"), "'.CoOrg::createURL($this->_autocomplete) .'")';
			}
			$input .= '</script>';
		}
		return $input;
	}
Пример #4
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');
		}
	}
Пример #5
0
	/**
	 * @Acl allow blog-writer
	 * @Acl allow blog-admin
	*/
	public function index($page = 1)
	{
		$this->_adminTab = 'BlogManageAdminTab';
		$blogPager = Blog::blogs(CoOrg::getLanguage());
		$this->blogs = $blogPager->execute($page, 15);
		$this->blogpager = $blogPager;
		$this->render('admin/index');
	}
Пример #6
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();
	}
Пример #7
0
	public function run($widgetParams,
	                    $request, $year = null, $month = null, 
	                              $day = null, $id = null)
	{
		$feeds = false;
		$controller = substr($request, 0, strpos($request, '/'));
		$admin = false;
		if ($controller == 'admin')
		{
			$admin = true;
			$subrequest = substr($request, strpos($request, '/') + 1);
			$controller = substr($subrequest, 0, strpos($subrequest, '/'));
		}
		
		$globalFeed = new stdClass;
		$globalFeed->title = t('ATOM Blog feed');
		$globalFeed->type = 'application/atom+xml';
		$globalFeed->url = CoOrg::createURL('blog.atom/latest');
		
		if ($request == 'blog/show')
		{
			$feeds = array();
			
			$feeds[] = $globalFeed;
			
			$commentsFeed = new stdClass;
			$commentsFeed->title = t('Comments');
			$commentsFeed->type = 'application/atom+xml';
			$commentsFeed->url = CoOrg::createURL(array('blog.atom/show', $year, $month, $day, $id));
			
			$feeds[] = $commentsFeed;
		}
		else if ($admin && $controller = 'blog')
		{
			$feeds = array();
			
			$feeds[] = $globalFeed;
			$commentsFeed = new stdClass;
			$commentsFeed->title = t('Unmoderated comments');
			$commentsFeed->type = 'application/atom+xml';
			$commentsFeed->url = CoOrg::createURL('blog.atom/comment/unmoderated');
			$feeds[] = $commentsFeed;
		}
		else if ($controller == 'blog' || $request == 'home/index')
		{
			$feeds = array();
			
			$feeds[] = $globalFeed;
		}
		
		if ($feeds)
		{
			$this->feeds = $feeds;
			return $this->render('widgets/feeds-links');
		}
	}
Пример #8
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;
	}
Пример #9
0
	public static function url($action, $language, $data)
	{
		if ($action == 'show')
		{
			return CoOrg::createURL(array('page', 'show', $data), $language);
		}
		else
		{
			return CoOrg::createURL(array('page', $action), $language);
		}
	}
Пример #10
0
function smarty_helper_pager_generateLink($params, $page)
{
	foreach ($params as &$p)
	{
		if ($p == '.*.')
		{
			$p = $page;
		}
	}
	return CoOrg::createURL(array_values($params));
}
Пример #11
0
function smarty_modifier_static($param, $plugin = null)
{
	$static = CoOrg::staticFile($param, $plugin);
	if (is_array($static))
	{
		CoOrgSmarty::$_static_array = $static;
		return $static[0];
	}
	else
	{
		return $static;
	}
}
Пример #12
0
	public function render($tpl, $app = false, $base = 'base')
	{
		if ($base == 'base' && $app == false)
		{
			CoOrg::loadPluginInfo('admin');
			$this->_adminTabs = Admin::tabs($this->_adminModule, $this->_adminTab);

			parent::render($tpl, false, 'base.html.tpl|'.Controller::getTemplatePath('admin.html.tpl', 'admin'));
		}
		else
		{
			parent::render($tpl, $app, $base);
		}
	}
Пример #13
0
	public function postsave()
	{
		if ($this->_value instanceof IFileUpload && $this->_value->error() == UPLOAD_ERR_OK)
		{
			$dataM = CoOrg::getDataManager($this->_dataPath);
			if ($this->_oldValue)
			{
				$file = $dataM->get($this->_oldValue);
				if ($file) $file->delete();
			}
			$this->_value->store();
		}
		parent::postsave();
	}
Пример #14
0
function smarty_block_a($params, $contents, $smarty)
{
	if ($contents !== NULL)
	{
		$stock = @$params['coorgStock'];
		unset($params['coorgStock']);
		$title = @$params['coorgTitle'];
		unset($params['coorgTitle']);
		$l = @$params['coorgLanguage'];
		unset($params['coorgLanguage']);
		$anchor = array_key_exists('coorgAnchor', $params) ? $params['coorgAnchor'] : null;
		unset($params['coorgAnchor']);
		$request = $params['request'];
		if ($request[0] != '#')
		{
			$urlParams = array($request);
			unset($params['request']);
			$urlParams = array_merge($urlParams, array_values($params));
			$url = CoOrg::createURL($urlParams, $l ? $l : null, $anchor);
		}
		else
		{
			$url = $request;
		}
		
		$a = '<a href="'.htmlspecialchars($url).'"'.
		         ($title ? ' title="'.$title.'"' : '').'>';
		if ($stock)
		{
			$stockInfo = CoOrg::stocks($stock);
			$a .= '<img src="'.CoOrg::staticFile($stockInfo['img']).'"
			            alt="'.$stockInfo['alt'].'"
			            title="'.$stockInfo['title'].'"/>';
			if ($stockInfo['text'])
			{
				$a .= $stockInfo['text'];
			}
			else if ($contents)
			{
				$a .= $contents;
			}
		}
		else
		{
			$a .= $contents;
		}
		$a .= '</a>';
		return $a;
	}
}
Пример #15
0
	public function render()
	{
		if (! $this->_stock)
		{
			return '<input type="submit" name="'.$this->_name.'" value="'.$this->_label.'"'.$this->renderOptions().'/>';
		}
		else
		{
			$stockInfo = CoOrg::stocks($this->_stock);
			$button = '<img src="'.CoOrg::staticFile($stockInfo['img']).'"
			                alt="'.$stockInfo['alt'].'"
			                title="'.$stockInfo['title'].'"/>';
			return '<button type="submit" name="'.$name.'" value="_"'.$this->renderOptions().'>'.$button.'</button>';
		}
	}
	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');	
	}
Пример #17
0
	public static function owns($user, $object)
	{
		CoOrg::loadPluginInfo('acl');
		$class = get_class($object);
		while ($class && ! array_key_exists($class, self::$_ownerMethods)) {
			$class = get_parent_class($class);
		}
		if ($class)
		{
			return self::$_ownerMethods[$class]->owns($user, $object);
		}
		else
		{
			return false;
		}
	}
Пример #18
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();
	}
Пример #19
0
function smarty_block_button($params, $contents, $smarty)
{
	if ($contents !== NULL)
	{
		$confirm = @$params['coorgConfirm'];
		unset($params['coorgConfirm']);
		
		if ($confirm)
		{
			$confirm = htmlspecialchars($confirm);
			$confirm = str_replace('\'', '\\\'', $confirm);
		}
		
		$form = '<form action="'.CoOrg::createURL(explode('/', $params['request'])).
		              '" method="post" class="normal-post-url"'.
		              ($confirm ? '  onsubmit="return confirm(\''.$confirm.'\');"' : '').
		              '>';
		
		foreach ($params as $key => $value)
		{
			if (strpos($key, 'param_') === 0)
			{
				$name = substr($key, 6);
				$form .= '<input type="hidden" name="'.$name.'" value="'.htmlspecialchars($value).'"/>';
			}
		}
		
		$stock = @$params['coorgStock'];
		unset($params['coorgStock']);
		if ($stock)
		{
			$stockInfo = CoOrg::stocks($stock);
			$contents = '<img src="'.CoOrg::staticFile($stockInfo['img']).'"
			            alt="'.$stockInfo['alt'].'"
			            title="'.$stockInfo['title'].'"/>';
			if ($stockInfo['text'])
			{
				$contents = $stockInfo['text'];
			}
		}
		
		$form .= '<button type="submit">'.$contents.'</button>';
		$form .= '</form>';
		return $form;
	}
}
Пример #20
0
	public static function url($action, $language, $data)
	{
		if ($action == 'show')
		{
			$dataArray = explode('/', $data, 2);
			$dateArray = explode('-', $dataArray[0]);
			return CoOrg::createURL(array('blog', 'show', $dateArray[0],
			                               $dateArray[1], $dateArray[2],
			                               $dataArray[1]), $language);
		}
		else if ($action == 'latest')
		{
			return CoOrg::createURL(array('blog'), $language);
		}
		else
		{
			return CoOrg::createURL(array('blog', $action), $language);
		}
	}
Пример #21
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');
		}
	}
Пример #22
0
	/**
	 * @before find $name
	*/
	public function edit($name, $language = null)
	{
		$this->menu = $this->_menu;
		
		if ($language)
		{
			$adminLanguage = $language;
		}
		else
		{
			$adminLanguage = CoOrg::getLanguage();
		}
		$this->adminlanguage = $adminLanguage;
		$this->providerActionCombos = Menu::providerActionCombos($adminLanguage);
		$newEntry = new MenuEntry;
		$newEntry->menuID = $name;
		$newEntry->language = $adminLanguage;
		$this->newEntry = $newEntry;
		$this->render('edit');
	}
Пример #23
0
	public function show($id, $language = null)
	{
		if ($language == null)
		{
			$language = CoOrg::getLanguage();
		}
		else
		{
			$this->viewingTranslation = true;
		}
		$page = Page::get($id, $language);
		if ($page != null)
		{
			$this->page = $page;
			$this->render('show');
		}
		else
		{
			$this->error(t('Page not found'));
			$this->notFound();
		}
	}
Пример #24
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();
	}
Пример #25
0
function smarty_function_aside($params, $smarty)
{
	if (array_key_exists('name', $params))
	{
		if (!array_key_exists('preview', $params))
		{
			return CoOrg::aside($params['name'], $smarty);
		}
		else
		{
			if (array_key_exists('edit', $params) && $params['edit'])
			{
				$edit = true;
				$widgetID = $params['editWidgetID'];
			}	
			return CoOrg::aside($params['name'], $smarty, true, $edit, $widgetID);
		}
	}
	else
	{
		return CoOrg::aside(null, $smarty);
	}
}
Пример #26
0
	public function __set($name, $value)
	{
		if ($name == 'entryID')
		{
			$p = explode('/', $value, 3);
			
			CoOrg::loadPluginInfo('menu');
			if (!class_exists($p[0]))
			{
				$this->entryID_error = t('Provider not found');
				return;
			}
			
			$this->provider = $p[0];
			if (count($p) > 1)
			{
				$this->action = $p[1];
				
				if (count($p) > 2)
				{
					$this->data = $p[2];
				}
				else
				{
					$this->data = null;
				}
				$this->url = call_user_func(array($p[0], 'url'), $this->action, $this->language, $this->data);
			}
			else
			{
				$this->action = 'do';
				$this->url = call_user_func(array($p[0], 'url'), $this->data, $this->language);
			}
		}
		parent::__set($name, $value);
	}
Пример #27
0
copy($configFile, 'config/temp.config.tests.php');
$configFile = 'config/temp.config.tests.php';
define('COORG_TEST_CONFIG_CLEAN', $configFile.'.clean');
define('COORG_TEST_CONFIG', $configFile);

$config = new Config($configFile);
$config->set('mollom/public', 'valid-pub-key');
$config->set('mollom/private', 'valid-priv-key');
$config->set('mollom/serverlist', array('valid-server-list'));
$config->set('enabled_plugins', array('search', 'spam', 'admin', 'menu', 'user', 'comments', 'user-admin', 'blog', 'page', 'puntstudio-users'));
$config->set('site/title', 'The Site');
$config->save();
copy($configFile, 'config/temp.config.tests.php.clean');
DB::open($config->get('dbdsn'), $config->get('dbuser'), $config->get('dbpass'));

CoOrg::init($config, 'coorg/testing/plugins-app', 'plugins'); // Load the models


function prepare($plugins)
{
	foreach (array_reverse($plugins) as $p)
	{
		if (file_exists('plugins/'.$p.'/install.php'))
		{
			include_once 'plugins/'.$p.'/install.php';
			
			$f = str_replace('-', '_', $p);
			call_user_func($f.'_delete_db', true);
		}
	}
	
Пример #28
0
<?php

CoOrg::resreg('alpha', 'somefile.css', '2010-10-03');
CoOrg::resreg('alpha', 'onlydefault.css', '2010-10-03');
CoOrg::resreg('alpha', 'extends.css', 'baseV', true);
?>
Пример #29
0
	public function __construct()
	{
		$this->name = t('Manage users');
		$this->url = CoOrg::createURL('admin/user');
		$this->priority = 1;
	}
Пример #30
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'));
	}