Commit 009fa91f authored by Nigel McNie's avatar Nigel McNie Committed by Nigel McNie
Browse files
parents 4c9f6c33 00d5a555
......@@ -53,6 +53,7 @@ $siteoptionform = form(array(
'title' => get_string('language'),
'description' => get_string('sitelanguagedescription'),
'defaultvalue' => get_config('language'),
'collapseifoneoption' => true,
'options' => $langoptions,
),
'theme' => array(
......@@ -60,6 +61,7 @@ $siteoptionform = form(array(
'title' => get_string('theme'),
'description' => get_string('sitethemedescription'),
'defaultvalue' => get_config('theme'),
'collapseifoneoption' => true,
'options' => $themeoptions,
),
'viruschecking' => array(
......
<?php
/**
* This program is part of Mahara
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* @package mahara
* @subpackage admin
* @author Penny Leach <penny@catalyst.net.nz>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006,2007 Catalyst IT Ltd http://catalyst.net.nz
*
*/
define('INTERNAL', 1);
define('ADMIN', 1);
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
$plugins = array();
foreach (plugin_types() as $plugin) {
$plugins[$plugin] = array();
$plugins[$plugin]['installed'] = array();
$plugins[$plugin]['notinstalled'] = array();
if ($installed = get_records($plugin . '_installed')) {
foreach ($installed as $i) {
$plugins[$plugin]['installed'][$i->name] = array();
if ($plugin == 'artefact') {
safe_require('artefact','internal');
$types = call_static_method(generate_class_name('artefact', $i->name), 'get_artefact_types');
$plugins[$plugin]['installed'][$i->name]['types'] = array();
foreach ($types as $t) {
$classname = generate_artefact_class_name($t);
if ($collapseto = call_static_method($classname, 'collapse_config')) {
$plugins[$plugin]['installed'][$i->name]['types'][$collapseto] = true;
}
else {
$plugins[$plugin]['installed'][$i->name]['types'][$t] =
call_static_method($classname, 'has_config');
}
}
}
else {
$classname = generate_class_name($plugin, $i->name);
safe_require($plugin, $i->name);
if (call_static_method($classname, 'has_config')) {
$plugins[$plugin]['installed'][$i->name]['config'] = true;
}
}
}
}
$dirhandle = opendir(get_config('docroot') . $plugin);
while (false !== ($dir = readdir($dirhandle))) {
if (strpos($dir, '.') === 0) {
continue;
}
if (!is_dir(get_config('docroot') . $plugin . '/' . $dir)) {
continue;
}
if (array_key_exists($dir, $plugins[$plugin]['installed'])) {
continue;
}
$plugins[$plugin]['notinstalled'][] = $dir;
}
}
$smarty = smarty();
$smarty->assign('plugins', $plugins);
$smarty->display('admin/plugins/index.tpl');
?>
......@@ -29,15 +29,37 @@ defined('INTERNAL') || die();
class PluginArtefactInternal extends PluginArtefact {
public static function get_artefact_types() {
return array('file', 'folder', 'image',
'firstname', 'lastname', 'studentid',
'preferredname', 'introduction',
'email', 'officialwebsite', 'personalwebsite',
'blog', 'address', 'town', 'city',
'country', 'homenumber', 'businessnumber',
'mobilenumber', 'faxnumber', 'icqnumber',
'msnnumber'
);
return array(
'firstname',
'lastname',
'studentid',
'preferredname',
'introduction',
'emailaddress',
'officialwebsite',
'personalwebsite',
'blogaddress',
'postaladdress',
'town',
'cityregion',
'country',
'homephone',
'businessphone',
'mobilephone',
'faxnumber',
'icqnumber',
'msnchat',
'aimscreenname',
'yahoochat',
'skypeusername',
'jabberusername',
'occupation',
'industry',
'icon',
'file',
'folder',
'image',
);
}
public static function get_plugin_name() {
......@@ -130,9 +152,23 @@ class ArtefactTypeProfile extends ArtefactType {
'studentid' => 'text',
'email' => 'text');
}
public static function has_config() {
return true;
}
public static function get_config_options() {
return array(); // @todo
}
}
class ArtefactTypeProfileField extends ArtefactTypeProfile {
public static function collapse_config() {
return 'profile';
}
}
class ArtefactTypeCachedProfile extends ArtefactTypeProfile {
class ArtefactTypeCachedProfileField extends ArtefactTypeProfileField {
public function commit() {
$this->commit_basic();
......@@ -148,29 +184,96 @@ class ArtefactTypeCachedProfile extends ArtefactTypeProfile {
}
class ArtefactTypeFirstname extends ArtefactTypeCachedProfile {}
class ArtefactTypeLastname extends ArtefactTypeCachedProfile {}
class ArtefactTypePreferredname extends ArtefactTypeCachedProfile {}
class ArtefactTypeEmail extends ArtefactTypeCachedProfile {}
class ArtefactTypeStudentid extends ArtefactTypeProfile {}
class ArtefactTypeIntroduction extends ArtefactTypeProfile {}
class ArtefactTypeOfficialwebsite extends ArtefactTypeProfile {}
class ArtefactTypePersonalwebsite extends ArtefactTypeProfile {}
class ArtefactTypeBlog extends ArtefactTypeProfile {}
class ArtefactTypeAddress extends ArtefactTypeProfile {}
class ArtefactTypeTown extends ArtefactTypeProfile {}
class ArtefactTypeCity extends ArtefactTypeProfile {}
class ArtefactTypeCountry extends ArtefactTypeProfile {}
class ArtefactTypeHomenumber extends ArtefactTypeProfile {}
class ArtefactTypeBusinessnumber extends ArtefactTypeProfile {}
class ArtefactTypeMobilenumber extends ArtefactTypeProfile {}
class ArtefactTypeFaxnumber extends ArtefactTypeProfile {}
class ArtefactTypeIcqnumber extends ArtefactTypeProfile {}
class ArtefactTypeMsnnumber extends ArtefactTypeProfile {}
class ArtefactTypeFolder extends ArtefactTypeProfile {}
class ArtefactTypeFile extends ArtefactTypeProfile {}
class ArtefactTypeImage extends ArtefactTypeFile {}
class ArtefactTypeFirstname extends ArtefactTypeCachedProfileField {}
class ArtefactTypeLastname extends ArtefactTypeCachedProfileField {}
class ArtefactTypePreferredname extends ArtefactTypeCachedProfileField {}
class ArtefactTypeEmail extends ArtefactTypeCachedProfileField {}
class ArtefactTypeStudentid extends ArtefactTypeProfileField {}
class ArtefactTypeIntroduction extends ArtefactTypeProfileField {}
class ArtefactTypeOfficialwebsite extends ArtefactTypeProfileField {}
class ArtefactTypePersonalwebsite extends ArtefactTypeProfileField {}
class ArtefactTypeBlog extends ArtefactTypeProfileField {}
class ArtefactTypeAddress extends ArtefactTypeProfileField {}
class ArtefactTypeTown extends ArtefactTypeProfileField {}
class ArtefactTypeCity extends ArtefactTypeProfileField {}
class ArtefactTypeCountry extends ArtefactTypeProfileField {}
class ArtefactTypeHomenumber extends ArtefactTypeProfileField {}
class ArtefactTypeBusinessnumber extends ArtefactTypeProfileField {}
class ArtefactTypeMobilenumber extends ArtefactTypeProfileField {}
class ArtefactTypeFaxnumber extends ArtefactTypeProfileField {}
class ArtefactTypeIcqnumber extends ArtefactTypeProfileField {}
class ArtefactTypeMsnnumber extends ArtefactTypeProfileField {}
class ArtefactTypeFolder extends ArtefactType {
public function commit() {
$this->commit_basic();
}
public function delete() {
$this->delete_basic();
}
public function render($format, $options) {
}
public function get_icon() {
}
public static function get_render_list() {
}
public static function can_render_to($format) {
}
public static function collapse_config() {
return 'file';
}
}
class ArtefactTypeFile extends ArtefactType {
public function commit() {
$this->commit_basic();
}
public function delete() {
$this->delete_basic();
}
public function render($format, $options) {
}
public function get_icon() {
}
public static function get_render_list() {
}
public static function can_render_to($format) {
}
public static function has_config() {
return true;
}
public static function get_config_options() {
return array(); // @todo
}
}
class ArtefactTypeImage extends ArtefactTypeFile {
public static function collapse_config() {
return 'file';
}
}
?>
......@@ -380,6 +380,18 @@ abstract class ArtefactType {
return $type;
}
public static function has_config() {
return false;
}
public static function get_config_options() {
return array();
}
public static function collapse_config() {
return false;
}
}
// helper functions for artefacts in general
......
......@@ -195,6 +195,10 @@ class AuthInternal extends Auth {
* Plugin configuration class. Nothing special required for this plugin...
*/
class PluginAuthInternal extends Plugin {
static function has_config() {
return true;
}
}
?>
......@@ -449,6 +449,7 @@ function auth_draw_login_page($message=null, Form $form=null) {
}
$smarty = smarty();
$smarty->assign('login_form', $loginform);
$smarty->assign('loginmessage', get_string('loginto', 'mahara', get_config('sitename')));
$smarty->display('login.tpl');
exit;
}
......
......@@ -89,9 +89,10 @@ function contactus_submit($values) {
json_reply('local', get_string('nositecontactaddress'));
}
// email_user requires firstname, lastname to be set, so put something in
$to = new StdClass;
$to->firstname = get_config('sitename');
$to->lastname = 'contact email';
$to->lastname = get_string('contactaddress');
$to->email = $contactemail;
$fromnames = explode(' ',$values['name']);
......@@ -99,7 +100,6 @@ function contactus_submit($values) {
json_reply('local', get_string('nosendernamefound'));
}
$from = new StdClass;
//$from->preferredname = $values['name'];
$from->firstname = $fromnames[0];
$from->lastname = count($fromnames) < 2 ? $fromnames[0] : implode(' ',array_slice($fromnames,1));
$from->email = $values['email'];
......
......@@ -266,6 +266,10 @@ MochiKit.Base.update(MochiKit.Signal.Event.prototype, {
typeof(this._event.charCode) == 'undefined') { // IE
k.code = this._event.keyCode;
k.string = String.fromCharCode(k.code);
} else if (this._event.keyCode &&
this._event.charCode == 0) { // FF
k.code = this._event.keyCode;
k.string = '';
}
this._key = k;
......
......@@ -42,6 +42,7 @@ $string['confirmpassword'] = 'Confirm password';
$string['loggedoutok'] = 'You have been logged out successfully';
$string['login'] = 'Log In';
$string['loginfailed'] = 'You have not provided the correct credentials to log in. Please check your username and password are correct.';
$string['loginto'] = 'Log in to %s';
$string['newpassword'] = 'New Password';
$string['password'] = 'Password';
$string['passworddesc'] = 'Your password';
......@@ -226,4 +227,6 @@ $string['activity'] = 'Recent activity';
$string['emailname'] = 'Mahara System'; // robot!
$string['save'] = 'Save';
$string['update'] = 'Update';
$string['config'] = 'Config';
?>
......@@ -668,6 +668,7 @@
<STATEMENT NAME="insert config" TYPE="insert" TABLE="config">
<SENTENCES>
<SENTENCE TEXT="(field, value) VALUES ('session_timeout', 1800)" />
<SENTENCE TEXT="(field, value) VALUES ('sitename', 'Mahara')" />
</SENTENCES>
</STATEMENT>
<STATEMENT NAME="insert event types" TYPE="insert" TABLE="event_type">
......
......@@ -690,6 +690,7 @@ class Form {
* and formname_validate() to be defined.
*/
private function submit_js() {
// @todo nigel should disable all buttons on this form while the submit is happening
$result = <<<EOF
function {$this->name}_submit() {
// eventually we should check input types for wysiwyg before doing this
......
......@@ -773,6 +773,10 @@ class Plugin {
public static function postinst() {
return true;
}
public static function has_config() {
return false;
}
}
/**
......
......@@ -80,7 +80,7 @@ function &smarty($javascript = array(), $headers = array(), $strings = array())
}
// Add the required mochikit and mahara javascript files
$javascript[] = $jsroot . 'mochikit/MochiKit.js';
$javascript[] = $jsroot . 'MochiKit/MochiKit.js';
$javascript[] = $jsroot . 'mahara.js';
$javascript[] = $jsroot . 'debug.js';
foreach (maharajsstrings() as $string) {
......
......@@ -14,6 +14,7 @@
</ul>
<li><a href="editsitepage.php">EditSitePages</a></li>
<li><a href="editmenu.php">EditAdminMenu</a></li>
<li><a href="plugins">Administer Plugins</a></li>
</ul>
{if $upgrades}
......
{include file='header.tpl'}
<h2>Administration</h2>
{foreach from=$plugins key='plugintype' item='plugins'}
<h4>{$plugintype}</h4>
{assign var="installed" value=$plugins.installed}
{assign var="notinstalled" value=$plugins.notinstalled}
{foreach from=$installed key='plugin' item='data'}
{$plugin}
{if $data.config}
(<a href="pluginconfig.php?plugintype={$plugintype}&amp;pluginname={$plugin}">{str tag='config'}</a>
{/if}<br />
{if $data.types}
{foreach from=$data.types key='type' item='config'}
&nbsp;&nbsp;&nbsp;{$type}
{if $config} (<a href="pluginconfig.php?plugintype={$plugintype}&amp;pluginname={$plugin}&amp;type={$type}">{str tag='config'}</a>){/if}<br />
{/foreach}
{/if}
{/foreach}
{foreach from=$notinstalled item='plugin}
{$plugin}<br />
{/foreach}
{/foreach}
{include file='footer.tpl'}
{include file="header.tpl"}
<h2>Log in to Mahara</h2>
<h2>{$loginmessage}</h2>
<div id="loginbox"></div>
{$login_form}
......
#!/usr/bin/perl
use strict;
use warnings;
use FindBin;
use lib qq{$FindBin::Bin/lib/};
use Mahara::RandomData;
use Mahara::Config;
my $config = Mahara::Config->new(qq{$FindBin::Bin/../htdocs/config.php});
print $config->get('dbhost'), "\n";
package Mahara::Config;
use Perl6::Slurp;
use Carp;
sub new {
my ($class,$config_file) = @_;
croak 'Need to spefify config file' unless defined $config_file;
my $self = {};
$self->{config_file} = $config_file;
my $data = slurp($self->{config_file});
while ( $data =~ m{ \$cfg-> ( [^=\s]+ ) \s* = \s* ([^;]+) }gxms ) {
my ($key, $value) = ($1, $2);
$value =~ s{ \A ' ( .*? ) ' \z }{$1}xms;
$self->{config}{$key} = $value;
}
bless $self, $class;
return $self;
}
sub get {
my ($self, $key) = @_;
return $self->{config}{$key};
}
1;
package Mahara::RandomData;
1;
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