Commit c446f03f authored by Nigel McNie's avatar Nigel McNie Committed by Nigel McNie
Browse files
parents e5712fd4 6f19950e
......@@ -25,6 +25,10 @@
*/
define('INTERNAL',1);
// uncomment if this page is public (doesn't require login)
// defined('PUBLIC', 1);
// uncomment and set if this page isn't public
// defined('MENUITEM', 'TODO');
require('init.php');
// Your code here
......
<?php
/**
* This program is part of mahara
* 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
......
<?php
/**
* This program is part of mahara
* 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
......
<?php
/**
* This program is part of mahara
* 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
......
<?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 artefact/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
*
*/
define('INTERNAL', 1);
define('MENUITEM', 'myfiles');
require(dirname(dirname(dirname(dirname(__FILE__)))) . '/init.php');
$smarty = smarty();
$smarty->display('artefact:internal:files/index.tpl');
?>
<?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 lang
* @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();
$string['myprofile'] = 'My Profile';
$string['myfiles'] = 'My Files';
......@@ -38,6 +38,19 @@ class PluginArtefactInternal extends PluginArtefact {
return 'internal';
}
public static function menu_items() {
return array(
array(
'name' => 'myprofile',
'link' => 'profile/',
),
array(
'name' => 'myfiles',
'link' => 'files/',
),
);
}
public static function postinst() {
$types = self::get_artefact_types();
$plugin = self::get_plugin_name();
......
<?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 artefact/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
*
*/
define('INTERNAL', 1);
define('MENUITEM', 'myprofile');
require(dirname(dirname(dirname(dirname(__FILE__)))) . '/init.php');
$smarty = smarty();
$smarty->display('artefact:internal:profile/index.tpl');
?>
{include file="header.tpl"}
{include file="adminmenu.tpl"}
<div class="content">
Files page
</div>
{include file="footer.tpl"}
{include file="header.tpl"}
{include file="adminmenu.tpl"}
<div class="content">
Profile page
</div>
{include file="footer.tpl"}
<?php
/**
* This program is part of mahara
* 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
......@@ -30,4 +30,4 @@ $config = new StdClass;
$config->version = 2006100500;
$config->release = '0.1';
?>
\ No newline at end of file
?>
......@@ -194,6 +194,7 @@ function auth_setup () {
// If the system is not installed, let the user through in the hope that
// they can fix this little problem :)
if (!get_config('installed')) {
$SESSION->logout();
log_debug('system not installed, letting user through');
return;
}
......@@ -240,7 +241,7 @@ function auth_setup () {
return;
}
log_debug('no session or old session, and page is private hello');
log_debug('no session or old session, and page is private');
auth_draw_login_page($form);
exit;
}
......
<?php
/**
* This program is part of Maraha.
* 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
......
<?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 core
* @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('PUBLIC', 1);
define('MENUITEM', 'mycontacts');
require(dirname(dirname(__FILE__)) . '/init.php');
// check to see if we're installed...
if (!get_config('version')) {
redirect(get_config('wwwroot') . 'admin/index.php');
}
$smarty = smarty();
if (!$SESSION->is_logged_in()) {
require_once('form.php');
$smarty->assign('login_form', form(auth_get_login_form()));
}
$smarty->display('index.tpl');
?>
......@@ -24,14 +24,24 @@
*
*/
define('INTERNAL',1);
define('INTERNAL', 1);
define('PUBLIC', 1);
define('MENUITEM', 'home');
require('init.php');
// check to see if we're installed...
if (!get_config('version')) {
if (!get_config('installed')) {
redirect(get_config('wwwroot') . 'admin/index.php');
}
$smarty = smarty();
if (!$SESSION->is_logged_in()) {
require_once('form.php');
$smarty->assign('login_form', form(auth_get_login_form()));
}
$smarty->display('index.tpl');
?>
......@@ -36,4 +36,14 @@ $string['sessiontimedout'] = 'Your session has timed out, please enter your logi
$string['username'] = 'Username';
$string['usernamedesc'] = 'Your username';
$string['usernamehelp'] = 'The username you have been given to access this system.';
// menu
$string['home'] = 'Home';
$string['mycontacts'] = 'My Contacts';
// footer
$string['termsandconditions'] = 'Terms and Conditions';
$string['privacystatement'] = 'Privacy Statement';
$string['about'] = 'About';
$string['contactus'] = 'Contact Us';
?>
<?php
<?php
/**
* This program is part of moodle
* 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
......
......@@ -130,6 +130,13 @@ class Form {
*/
private $action = '';
/**
* The javascript function that the form will be submitted to.
*
* @var string
*/
private $onsubmit = '';
/**
* The tab index for this particular form.
*
......@@ -202,6 +209,7 @@ class Form {
$form_defaults = array(
'method' => 'post',
'action' => '',
'onsubmit' => '',
'elements' => array()
);
$data = array_merge($form_defaults, $data);
......@@ -212,8 +220,8 @@ class Form {
$data['method'] = 'get';
}
$this->method = $data['method'];
$this->action = $data['action'];
$this->onsubmit = $data['onsubmit'];
if (isset($data['renderer'])) {
$this->renderer = $data['renderer'];
......@@ -377,9 +385,10 @@ class Form {
*/
public function build() {
$result = '<form';
foreach (array('name', 'method', 'action') as $attribute) {
foreach (array('name', 'method', 'action', 'onsubmit') as $attribute) {
$result .= ' ' . $attribute . '="' . $this->{$attribute} . '"';
}
$result .= ' id="' . $this->name . '"';
if ($this->fileupload) {
$result .= ' enctype="multipart/form-data"';
}
......@@ -667,7 +676,7 @@ class Form {
* @return string The attributes for the element
*/
public static function element_attributes($element, $exclude=array()) {
static $attributes = array('accesskey', 'class', 'dir', 'id', 'lang', 'maxlength', 'name', 'size', 'style', 'tabindex');
static $attributes = array('accesskey', 'class', 'dir', 'id', 'lang', 'maxlength', 'name', 'onclick', 'size', 'style', 'tabindex');
$elementattributes = array_diff($attributes, $exclude);
$result = '';
foreach ($elementattributes as $attribute) {
......@@ -756,15 +765,18 @@ function form_render_element($element, Form $form) {
throw new FormException('No form renderer specified for form "' . $form->get_name() . '"');
}
$element['id'] = Form::make_id($element);
$element['class'] = Form::make_class($element);
$newelement = $element;
$newelement['class'] = (isset($newelement['class'])
? $newelement['class'] . ' ' . $form->get_name() : '');
$builtelement = $function($newelement, $form);
// Prepare the prefix and suffix
$prefix = (isset($element['prefix'])) ? $element['prefix'] : '';
$suffix = (isset($element['suffix'])) ? $element['suffix'] : '';
return $prefix . $rendererfunction($function($element, $form), $element) . $suffix;
return $prefix . $rendererfunction($builtelement, $element) . $suffix;
}
?>
......@@ -509,6 +509,15 @@ function safe_require($plugintype, $pluginname, $filename='lib.php', $function='
}
/**
* Returns the list of site content pages
* @return array of names
*/
function site_content_pages() {
return array('about','home','loggedouthome','privacy','termsandconditions','uploadcopyright');
}
/**
* This function returns the list of plugintypes we currently care about
* @return array of names
......@@ -521,14 +530,6 @@ function plugin_types() {
return $pluginstocheck;
}
/**
* Returns the list of site content pages
* @return array of names
*/
function site_content_pages() {
return array('about','home','loggedouthome','privacy','termsandconditions','uploadcopyright');
}
/**
* Helper to call a static method when you do not know the name of the class
* you want to call the method on. PHP5 does not support $class::method().
......@@ -540,25 +541,11 @@ function call_static_method($class, $method) {
return call_user_func_array(array($class, $method), $args);
}
/**
* Given a series of arguments, builds a Mahara coding style class name,
* prefixed with 'Plugin'.
*
* @todo perhaps this should be renamed? (plugin_class_name or similar)
* @param mixed A list of strings to be used in generating the class name
* @return string A mahara class name
*/
function generate_class_name() {
$args = func_get_args();
return 'Plugin' . implode('', array_map('ucfirst', $args));
}
/**
* Redirects a user to the given location. Once called, the script will exit.
*
* @param string $location The place to redirect the user to. Should be an
* absolute URL.
*/
function redirect($location) {
if (headers_sent()) {
throw new Exception('Headers already sent when redirect() was called');
......@@ -568,17 +555,9 @@ function redirect($location) {
exit;
}
/**
* Handles an internal system event
*
* @param string event name of event
* @param mixed data data to pass to the handle function
* eg new user object etc.
*
*/
function event_occured($event, $data) {
function handle_event($event) {
if (!$e = get_record('event_type','name',$event)) {
throw new Exception("Invalid event type $event");
throw new Exception("Invalid event");
}
$plugintypes = plugin_types();
foreach ($plugintypes as $name) {
......@@ -586,7 +565,7 @@ function event_occured($event, $data) {
foreach ($subs as $sub) {
$classname = 'Plugin' . ucfirst($name) . ucfirst($sub->plugin);
try {
call_static_method($classname, $sub->callfunction, $data);
call_static_method($classname, $sub->callfunction);
}
catch (Exception $e) {
log_warn("Event $event caused an exception from plugin $classname "
......@@ -650,4 +629,58 @@ class Plugin {
}
}
/**
* Builds the main navigation menu and returns it as a data structure
*
* @return $mainnav a data structure containing the main navigation
* @todo martyn this is probably quite expenvise, perhaps it needs teh caching
*/
function main_nav() {
$wwwroot = get_config('wwwroot');
$menu = array(
array(
'name' => 'home',
'section' => 'mahara',
'link' => $wwwroot,
),
);
if ($plugins = get_rows('artefact_installed')) {
foreach ($plugins as &$plugin) {
safe_require('artefact', $plugin['name'], 'lib.php', 'require_once');
$plugin_menu = call_static_method(generate_class_name('artefact',$plugin['name']), 'menu_items');
foreach ($plugin_menu as &$menu_item) {
$menu_item['link'] = $wwwroot . 'artefact/' . $plugin['name'] . '/' . $menu_item['link'];
$menu_item['section'] = 'artefact.' . $plugin['name'];
}
$menu = array_merge($menu, $plugin_menu);
}
}
$menu[] = array(
'name' => 'mycontacts',
'link' => $wwwroot . 'contacts/',
'section' => 'mahara',
);
if (defined('MENUITEM')) {
foreach ( $menu as &$item ) {
if ($item['name'] == MENUITEM) {
$item['selected'] = true;
}
}
}
else {
$menu[0]['selected'] = true;
}
log_debug($menu);
return $menu;
}
?>
......@@ -148,6 +148,15 @@ class Session {
);
}
/**
* Determines if the user is currently logged in
*
* @return boolean
*/
public function is_logged_in() {
return ($this->get('logout_time') > 0 ? true : false);
}
/**
* Adds a message that indicates something was successful
......
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