Commit 189646a1 authored by Aaron Wells's avatar Aaron Wells Committed by Gerrit Code Review
Browse files

Adding a sitewide config option to enable/disable skins

Bug 1168213

Change-Id: Ic5a1d6a630341955477b0544293173bcb8d57435
parent c7ed6a76
......@@ -37,6 +37,10 @@ require_once('pieforms/pieform.php');
require_once(get_config('libroot') . 'skin.php');
define('TITLE', get_string('addfontvariant', 'skin'));
if (!get_config('skins')) {
throw new FeatureNotEnabledException();
}
$font = param_alphanum('font');
$fonttitle = get_field('skin_fonts', 'title', 'name', $font);
......
......@@ -31,6 +31,10 @@ define('NOCHECKPASSWORDCHANGE', 1);
require(dirname(dirname(dirname(dirname(__FILE__)))) . '/init.php');
require_once(get_config('libroot') . 'skin.php');
if (!get_config('skins')) {
throw new FeatureNotEnabledException();
}
// We use the font title as the "family" name for the font
$family = param_variable('family', false);
if (!empty($family)) {
......
......@@ -35,6 +35,10 @@ define('SECTION_PAGE', 'deletefont');
require_once(dirname(dirname(dirname(dirname(__FILE__)))) . '/init.php');
require_once('pieforms/pieform.php');
if (!get_config('skins')) {
throw new FeatureNotEnabledException();
}
$font = param_alphanum('font');
$fontdata = null;
......
......@@ -36,6 +36,10 @@ require_once(dirname(dirname(dirname(dirname(__FILE__)))) . '/init.php');
require_once('pieforms/pieform.php');
define('TITLE', get_string('editfont', 'skin'));
if (!get_config('skins')) {
throw new FeatureNotEnabledException();
}
$font = param_alphanum('font');
$fontdata = get_record('skin_fonts', 'name', $font);
if ($fontdata == false) {
......
......@@ -37,6 +37,10 @@ require_once('pieforms/pieform.php');
require_once(get_config('libroot') . 'skin.php');
define('TITLE', get_string('installfont', 'skin'));
if (!get_config('skins')) {
throw new FeatureNotEnabledException();
}
$form = pieform(array(
'name' => 'addfontform',
// 'jsform' => true,
......
......@@ -41,6 +41,9 @@ require_once('pieforms/pieform.php');
require_once(get_config('libroot') . 'skin.php');
define('TITLE', get_string('installgwfont', 'skin'));
if (!get_config('skins')) {
throw new FeatureNotEnabledException();
}
$form = pieform(array(
'name' => 'gwfontform',
......
......@@ -33,6 +33,10 @@ require_once(get_config('libroot') . 'skin.php');
require_once('pieforms/pieform.php');
define('TITLE', get_string('sitefonts', 'skin'));
if (!get_config('skins')) {
throw new FeatureNotEnabledException();
}
$font = param_variable('font', false);
if ($font) {
$font = preg_replace(Skin::FONTNAME_FILTER_CHARACTERS, '', $font);
......
......@@ -37,6 +37,10 @@ require_once(get_config('libroot') . 'skin.php');
require_once('pieforms/pieform.php');
define('TITLE', get_string('sitefonts', 'skin'));
if (!get_config('skins')) {
throw new FeatureNotEnabledException();
}
$fontpreview = !is_null($SESSION->get('fontpreview')) ? $SESSION->get('fontpreview') : 21;
$fontsize = !is_null($SESSION->get('fontsize')) ? $SESSION->get('fontsize') : 28;
$fonttype = !is_null($SESSION->get('fonttype')) ? $SESSION->get('fonttype') : 'all'; // possible values: all, site, google
......
......@@ -37,6 +37,10 @@ require_once(get_config('libroot') . 'skin.php');
require_once('pieforms/pieform.php');
define('TITLE', get_string('siteskins', 'skin'));
if (!get_config('skins')) {
throw new FeatureNotEnabledException();
}
$limit = param_integer('limit', 6); // For 2x3 grid, showing thumbnails of view skins (2 rows with 3 thumbs each).
$offset = param_integer('offset', 0);
......
......@@ -534,3 +534,9 @@ $cfg->additionalhtlmfooter = '';
* could simply pick usernames of people's accounts they wished to steal.
*/
$cfg->usersuniquebyusername = false;
/**
* @global bool $cfg->skins Activates the "page skins" feature, which allows users to customize the CSS
* on individual pages.
*/
// $cfg->skins = false;
\ No newline at end of file
......@@ -459,7 +459,7 @@ function exception (Exception $e) {
if ($USER) {
if (!($e instanceof MaharaException) || get_class($e) == 'MaharaException') {
log_warn("An exception was thrown of class " . get_class($e) . ". \nTHIS IS BAD "
. "and should be changed to something extending MaharaException,\n"
. "and should be changed to something extending MaharaException,\n"
. "unless the exception is from a third party library.\n"
. "Original trace follows", true, false);
log_message($e->getMessage(), LOG_LEVEL_WARN, true, true, $e->getFile(), $e->getLine(), $e->getTrace());
......@@ -474,17 +474,17 @@ function exception (Exception $e) {
interface MaharaThrowable {
public function render_exception();
}
// Standard exceptions - top level exception class.
// Standard exceptions - top level exception class.
// all exceptions should extend one of these three.
/**
* Very top of the tree for exceptions in Mahara.
* Nothing should extend this directly.
* Nothing should extend this directly.
* Contains a few helper functions for all exceptions.
*/
class MaharaException extends Exception {
......@@ -514,7 +514,7 @@ class MaharaException extends Exception {
if (array_key_exists($tag, $strings)) {
return $strings[$tag];
}
return 'An error occurred';
}
......@@ -611,7 +611,7 @@ class MaharaException extends Exception {
h1 {
color: #547c22;
font-size: 20px;
font-weight: normal;
font-weight: normal;
margin: 0 0 5px 0;
padding: 0;
text-transform: capitalize;
......@@ -661,11 +661,11 @@ class SystemException extends MaharaException implements MaharaThrowable {
}
public function strings() {
return array_merge(parent::strings(),
return array_merge(parent::strings(),
array('message' => 'A nonrecoverable error occurred. '
. 'This probably means you have encountered a bug in the system'));
}
}
/**
......@@ -673,14 +673,14 @@ class SystemException extends MaharaException implements MaharaThrowable {
* Generally these will be the fault of admins
*/
class ConfigException extends MaharaException implements MaharaThrowable {
public function render_exception () {
return $this->get_string('message') . "\n\n" . $this->getMessage();
}
public function strings() {
return array_merge(parent::strings(),
array('message' => 'The environment where ' . $this->get_sitename()
return array_merge(parent::strings(),
array('message' => 'The environment where ' . $this->get_sitename()
. ' is running is misconfigured and this is causing problems. '
. 'You probably need to contact a server administrator to get this fixed. '
. 'Details, if any, follow:'));
......@@ -699,8 +699,8 @@ class UserException extends MaharaException implements MaharaThrowable {
}
public function strings() {
return array_merge(parent::strings(),
array('message' => 'Something in the way you\'re interacting with '
return array_merge(parent::strings(),
array('message' => 'Something in the way you\'re interacting with '
. $this->get_sitename()
. " is causing an error.\nDetails if any, follow:"));
}
......@@ -712,7 +712,7 @@ class UserException extends MaharaException implements MaharaThrowable {
*/
class NotFoundException extends UserException {
public function strings() {
return array_merge(parent::strings(),
return array_merge(parent::strings(),
array('message' => get_string('notfoundexception', 'error'),
'title' => get_string('notfound', 'error')));
}
......@@ -724,7 +724,7 @@ class NotFoundException extends UserException {
}
/**
/**
* The configuration that Mahara is trying to be run in is insane
*/
class ConfigSanityException extends ConfigException {
......@@ -733,6 +733,9 @@ class ConfigSanityException extends ConfigException {
}
}
class FeatureNotEnabledException extends ConfigException {
}
/**
* An SQL related error occurred
*/
......@@ -811,8 +814,8 @@ class InvalidEmailException extends EmailException {}
*/
class EmailDisabledException extends EmailException {}
/**
* Exception - artefact not found
/**
* Exception - artefact not found
*/
class ArtefactNotFoundException extends NotFoundException {}
......@@ -821,7 +824,7 @@ class ArtefactNotFoundException extends NotFoundException {}
*/
class BlockInstanceNotFoundException extends NotFoundException {}
/**
/**
* Exception - interaction instance not found
*/
class InteractionInstanceNotFoundException extends NotFoundException {}
......@@ -888,7 +891,7 @@ class SkinNotFoundException extends NotFoundException {}
*/
class AccessDeniedException extends UserException {
public function strings() {
return array_merge(parent::strings(),
return array_merge(parent::strings(),
array('message' => get_string('accessdeniedexception', 'error'),
'title' => get_string('accessdenied', 'error')));
}
......@@ -937,12 +940,12 @@ class GroupAccessDeniedException extends AccessDeniedException {
}
/**
* Exception - Access totally denied, the user won't be able to access it even if they log in
* Exception - Access totally denied, the user won't be able to access it even if they log in
* as the administrator
*/
class AccessTotallyDeniedException extends UserException {
public function strings() {
return array_merge(parent::strings(),
return array_merge(parent::strings(),
array('message' => get_string('accessdeniedexception', 'error'),
'title' => get_string('accessdenied', 'error')));
}
......
......@@ -1916,18 +1916,6 @@ function admin_nav() {
'title' => get_string('share', 'view'),
'weight' => 70,
),
'configsite/siteskins' => array(
'path' => 'configsite/siteskins',
'url' => 'admin/site/skins.php',
'title' => get_string('siteskinmenu', 'skin'),
'weight' => 75,
),
'configsite/sitefonts' => array(
'path' => 'configsite/sitefonts',
'url' => 'admin/site/fonts.php',
'title' => get_string('sitefontsmenu', 'skin'),
'weight' => 76,
),
'configsite/sitefiles' => array(
'path' => 'configsite/sitefiles',
'url' => 'artefact/file/sitefiles.php',
......@@ -2110,6 +2098,21 @@ function admin_nav() {
),
);
// Add the menu items for skins, if that feature is enabled
if (get_config('skins')) {
$menu['configsite/siteskins'] = array(
'path' => 'configsite/siteskins',
'url' => 'admin/site/skins.php',
'title' => get_string('siteskinmenu', 'skin'),
'weight' => 75,
);
$menu['configsite/sitefonts'] = array(
'path' => 'configsite/sitefonts',
'url' => 'admin/site/fonts.php',
'title' => get_string('sitefontsmenu', 'skin'),
'weight' => 76,
);
}
return $menu;
}
......
......@@ -30,6 +30,10 @@ require(dirname(dirname(__FILE__)) . '/init.php');
require_once('skin.php');
require_once('pieforms/pieform.php');
if (!get_config('skins')) {
throw new FeatureNotEnabledException();
}
$skinid = param_integer('id');
$siteskin = param_boolean('site', false);
if ($siteskin) {
......
......@@ -35,6 +35,10 @@ require_once('skin.php');
require_once('pieforms/pieform.php');
safe_require('artefact', 'file');
if (!get_config('skins')) {
throw new FeatureNotEnabledException();
}
$fieldset = param_alpha('fs', 'viewskin');
$designsiteskin = param_boolean('site', false);
......
......@@ -30,6 +30,10 @@ require_once(dirname(dirname(__FILE__)) . '/init.php');
require_once('skin.php');
require_once(get_config('docroot') . 'artefact/file/lib.php');
if (!get_config('skins')) {
throw new FeatureNotEnabledException();
}
global $USER;
$exportid = param_integer('id', 0); // id(s) of skin(s) to be exported...
$exportsiteskins = param_boolean('site', false);
......
......@@ -29,6 +29,10 @@ define('INTERNAL', true);
require_once(dirname(dirname(__FILE__)) . '/init.php');
require_once('skin.php');
if (!get_config('skins')) {
throw new FeatureNotEnabledException();
}
global $USER;
$add = param_integer('add', 0); // id of skin to add to favorites...
$del = param_integer('del', 0); // id of skin to remove from favorites...
......
......@@ -30,6 +30,10 @@ define('PUBLIC', 1);
require(dirname(dirname(__FILE__)) . '/init.php');
require_once('file.php');
if (!get_config('skins')) {
throw new FeatureNotEnabledException();
}
$family = param_variable('family');
$variant = param_variable('variant');
$format = param_variable('format');
......
......@@ -37,6 +37,10 @@ require_once('file.php');
require_once('uploadmanager.php');
define('TITLE', get_string('importskins', 'skin'));
if (!get_config('skins')) {
throw new FeatureNotEnabledException();
}
$importsiteskins = param_boolean('site', false);
if ($importsiteskins) {
if (!$USER->get('admin')) {
......
......@@ -36,6 +36,10 @@ require_once('skin.php');
require_once('pieforms/pieform.php');
define('TITLE', get_string('myskins', 'skin'));
if (!get_config('skins')) {
throw new FeatureNotEnabledException();
}
$filter = param_alpha('filter', 'all');
$limit = param_integer('limit', 6); // For 2x3 grid, showing thumbnails of view skins (2 rows with 3 thumbs each).
$offset = param_integer('offset', 0);
......
......@@ -31,6 +31,9 @@ define('NOCHECKPASSWORDCHANGE', 1);
require(dirname(dirname(__FILE__)) . '/init.php');
require_once('skin.php');
if (!get_config('skins')) {
throw new FeatureNotEnabledException();
}
$id = param_integer('skin', 0);
if ($id == 0) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment