Commit 30646108 authored by Martyn Smith's avatar Martyn Smith Committed by Martyn Smith
Browse files
parents 81f73567 85b1cd1d
......@@ -24,9 +24,9 @@
*
*/
define('INTERNAL',1);
define('ADMIN',1);
define('MENUITEM','adminhome');
define('INTERNAL', 1);
define('ADMIN', 1);
define('MENUITEM', 'adminhome');
require(dirname(dirname(__FILE__)).'/init.php');
require(get_config('libroot') . 'upgrade.php');
......
......@@ -27,14 +27,32 @@
define('INTERNAL', 1);
define('ADMIN', 1);
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
require_once('form.php');
$plugintype = param_alpha('plugintype');
$pluginname = param_alpha('pluginname');
$type = param_alpha('type', null);
if ($plugintype == 'artefact' && empty($type)) {
safe_require($plugintype, $pluginname);
if ($plugintype == 'artefact') {
$type = param_alpha('type');
$classname = generate_artefact_class_name($type);
}
else {
$type = null;
$classname = generate_class_name($plugintype, $pluginname);
}
if (!call_static_method($classname, 'has_config')) {
throw new InvalidArgumentException("$classname doesn't have config options available");
}
$form = call_static_method($classname, 'get_config_options');
$smarty = smarty();
//$smarty->assign('form', form($form));
$smarty->assign('plugintype', $plugintype);
$smarty->assign('pluginname', $pluginname);
$smarty->assign('type', $type);
$smarty->display('admin/plugins/pluginconfig.tpl');
?>
\ No newline at end of file
......@@ -115,8 +115,8 @@ function uploadcsv_validate(Form $form, $values) {
return;
}
$username = $line[0];
$email = $line[1];
$password = $line[2];
$password = $line[1];
$email = $line[2];
safe_require('auth', 'internal', 'lib.php', 'require_once');
if (!AuthInternal::is_username_valid($username)) {
......@@ -128,12 +128,6 @@ function uploadcsv_validate(Form $form, $values) {
return;
}
require_once('form/rules/email.php');
if (form_rule_email($email) !== null) {
$form->set_error('file', get_string('uploadcsverrorinvalidemail', 'admin', $i));
return;
}
// Note: only checks for valid form are done here, none of the checks
// like whether the password is too easy. The user is going to have to
// change their password on first login anyway.
......@@ -142,6 +136,19 @@ function uploadcsv_validate(Form $form, $values) {
return;
}
safe_require('artefact', 'internal');
$fieldcounter = 2;
foreach (ArtefactTypeProfile::get_mandatory_fields() as $field => $type) {
$fieldcounter++;
if (!isset($line[$fieldcounter])) {
$form->set_error('file', get_string('uploadcsverrormandatoryfieldnotspecified', 'admin', $i, $field));
return;
}
// @todo validate the mandatory fields somehow. In theory, this should
// just involve calling a method on a class.
}
// All OK!
$CSVDATA[] = $line;
}
......@@ -155,16 +162,19 @@ function uploadcsv_submit($values) {
global $SESSION, $CSVDATA;
log_info('Inserting users from the CSV file');
foreach ($CSVDATA as $record) {
log_debug('adding user ' . $record->username);
// @todo when penny has done the profile field setting stuff...
//$user = new StdClass;
//$user->username = $record[0];
//$user->password = $record[2];
//$user->institution = $values['institution'];
//$user->passwordchange = 1;
//$user->firstname = ???;
//$user->lastname = ???;
//$user->email = $record[1];
log_debug('adding user ' . $record[0]);
$user = new StdClass;
$user->username = $record[0];
$user->password = $record[1];
$user->institution = $values['institution'];
$user->passwordchange = 1;
$id = insert_record('usr', $user, 'id', true);
$i = 2;
safe_require('artefact', 'internal', 'lib.php');
foreach (ArtefactTypeProfile::get_mandatory_fields() as $field => $type) {
set_profile_field($id, $field, $record[$i++]);
}
}
log_info('Inserted ' . count($CSVDATA) . ' records');
......
......@@ -196,9 +196,13 @@ class AuthInternal extends Auth {
*/
class PluginAuthInternal extends Plugin {
static function has_config() {
public static function has_config() {
return true;
}
public static function get_config_options() {
return array();
}
}
?>
......@@ -217,6 +217,11 @@ function auth_setup () {
$SESSION->add_err_msg(get_string('accessforbiddentoadminsection'));
redirect(get_config('wwwroot'));
}
elseif (!$SESSION->get('admin')) {
// The user never was an admin
$SESSION->add_err_msg(get_string('accessforbiddentoadminsection'));
redirect(get_config('wwwroot'));
}
}
$USER = $SESSION->renew();
auth_check_password_change();
......@@ -298,7 +303,7 @@ function auth_check_password_change() {
$authtype = auth_get_authtype_for_institution($USER->institution);
$authclass = 'Auth' . ucfirst($authtype);
$url = '';
safe_require('auth', $authtype, 'lib.php', 'require_once');
safe_require('auth', $authtype);
// @todo auth preference for a password change screen for all auth methods other than internal
if (
......@@ -367,7 +372,7 @@ function change_password_validate(Form $form, $values) {
$authtype = auth_get_authtype_for_institution($USER->institution);
$authclass = 'Auth' . ucfirst($authtype);
$authlang = 'auth.' . $authtype;
safe_require('auth', $authtype, 'lib.php', 'require_once');
safe_require('auth', $authtype);
// @todo this could be done by a custom form rule... 'password' => $user
password_validate($form, $values, $USER);
......@@ -582,7 +587,7 @@ function login_submit($values) {
$institution = (isset($values['login_institution'])) ? $values['login_institution'] : 'mahara';
$authtype = auth_get_authtype_for_institution($institution);
safe_require('auth', $authtype, 'lib.php', 'require_once');
safe_require('auth', $authtype);
$authclass = 'Auth' . ucfirst($authtype);
try {
......
......@@ -117,6 +117,7 @@ $string['uploadcsverrorinvalidemail'] = 'Error on line %s of your file: The e-ma
$string['uploadcsverrorinvalidpassword'] = 'Error on line %s of your file: The password for this user is not in correct form';
$string['uploadcsverrorinvalidusername'] = 'Error on line %s of your file: The username for this user is not in correct form';
$string['uploadcsverrorincorrectfieldcount'] = 'Line %s of the file does not have the correct number of fields';
$string['uploadcsverrormandatoryfieldnotspecified'] = 'Line %s of the file does not have the required "%s" field';
$string['uploadcsvfile'] = 'Upload CSV File';
$string['uploadcsvfiledescription'] = 'You may use this facility to upload new users via a <acronym title="Comma Separated Values">CSV</acronym> file. Each record in the file must have a username, e-mail address and password.';
......
......@@ -35,6 +35,7 @@ $string['nextpage'] = 'Next page';
$string['prevpage'] = 'Previous page';
// auth
$string['accessforbiddentoadminsection'] = 'You are forbidden from accessing the administration section';
$string['accountexpired'] = 'Sorry, your account has expired';
$string['accountsuspended'] = 'Your account has been suspeneded as of %s. The reason for your suspension is:<blockquote>%s</blockquote>';
$string['changepassword'] = 'Change Password';
......
......@@ -208,6 +208,59 @@
<KEY NAME="subscruk" TYPE="unique" FIELDS="plugin,event,callfunction" />
</KEYS>
</TABLE>
<!-- search plugin tables -->
<TABLE NAME="search_installed">
<FIELDS>
<FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" />
<FIELD NAME="version" TYPE="int" LENGTH="10" NOTNULL="true" />
<FIELD NAME="release" TYPE="text" LENGTH="small" NOTNULL="true" />
<FIELD NAME="active" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="1" />
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="name" />
</KEYS>
</TABLE>
<TABLE NAME="search_config">
<FIELDS>
<FIELD NAME="plugin" TYPE="char" LENGTH="100" NOTNULL="true" />
<FIELD NAME="field" TYPE="char" LENGTH="100" NOTNULL="true" />
<FIELD NAME="value" TYPE="text" LENGTH="small" NOTNULL="true" />
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="plugin,field" />
<KEY NAME="pluginfk" TYPE="foreign" FIELDS="plugin" REFTABLE="search_installed" REFFIELDS="name" />
</KEYS>
</TABLE>
<TABLE NAME="search_cron">
<FIELDS>
<FIELD NAME="plugin" TYPE="char" LENGTH="255" NOTNULL="true" />
<FIELD NAME="callfunction" TYPE="char" LENGTH="255" NOTNULL="true" />
<FIELD NAME="nextrun" TYPE="datetime" NOTNULL="false" />
<FIELD NAME="minute" TYPE="char" LENGTH="25" NOTNULL="true" DEFAULT="*" />
<FIELD NAME="hour" TYPE="char" LENGTH="25" NOTNULL="true" DEFAULT="*" />
<FIELD NAME="day" TYPE="char" LENGTH="25" NOTNULL="true" DEFAULT="*" />
<FIELD NAME="month" TYPE="char" LENGTH="25" NOTNULL="true" DEFAULT="*" />
<FIELD NAME="dayofweek" TYPE="char" LENGTH="25" NOTNULL="true" DEFAULT="*" />
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="plugin,callfunction" />
<KEY NAME="pluginfk" TYPE="foreign" FIELDS="plugin" REFTABLE="search_installed" REFFIELDS="name" />
</KEYS>
</TABLE>
<TABLE NAME="search_event_subscription">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" SEQUENCE="true" NOTNULL="true" />
<FIELD NAME="plugin" TYPE="char" LENGTH="255" NOTNULL="true" />
<FIELD NAME="event" TYPE="char" LENGTH="50" NOTNULL="true" />
<FIELD NAME="callfunction" TYPE="char" LENGTH="255" NOTNULL="true" />
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" />
<KEY NAME="pluginfk" TYPE="foreign" FIELDS="plugin" REFTABLE="search_installed" REFFIELDS="name" />
<KEY NAME="eventfk" TYPE="foreign" FIELDS="event" REFTABLE="event_type" REFFIELDS="name" />
<KEY NAME="subscruk" TYPE="unique" FIELDS="plugin,event,callfunction" />
</KEYS>
</TABLE>
<!-- artefact plugin tables -->
<TABLE NAME="artefact_installed">
<FIELDS>
......
......@@ -642,7 +642,7 @@ function get_site_page_content($pagename) {
function plugin_types() {
static $pluginstocheck;
if (empty($pluginstocheck)) {
$pluginstocheck = array('artefact', 'auth', 'notification');
$pluginstocheck = array('artefact', 'auth', 'notification', 'search');
}
return $pluginstocheck;
}
......
......@@ -163,7 +163,6 @@ function set_profile_field($userid, $field, $value) {
safe_require('artefact', 'internal');
$classname = generate_artefact_class_name($field);
$profile = new $classname(0, array('owner' => $userid));
$profile->set('owner', $userid);
$profile->set('title', $value);
$profile->commit();
......
......@@ -27,7 +27,7 @@
defined('INTERNAL') || die();
/**
* The internal authentication method, which authenticates users against the
* The internal search plugin which searches against the
* Mahara database.
*/
class PluginSearchInternal extends PluginSearch {
......
<?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 search-internal
* @author Martyn Smith <martyn@catalyst.net.nz>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006,2007 Catalyst IT Ltd http://catalyst.net.nz
*
*/
defined('INTERNAL') || die();
$config->version = 2006111600;
$config->release = '0.1';
?>
\ No newline at end of file
......@@ -30,7 +30,7 @@ defined('INTERNAL') || die();
* Base search class. Provides a common interface with which searches can be
* carried out.
*/
abstract class PluginSearch {
abstract class PluginSearch extends Plugin {
/**
* Given a query string and limits, return an array of matching users
......
{include file='header.tpl'}
<h2>Administration</h2>
<h2>Plugin Administration</h2>
{foreach from=$plugins key='plugintype' item='plugins'}
<h4>{str tag='plugintype'}: {$plugintype}</h4>
......
{include file='header.tpl'}
<h2>Plugin Administration: {$plugintype}: {$pluginname}{if $type}: {$type}{/if}</h2>
{include file='footer.tpl'}
Supports Markdown
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