Commit 521decbd authored by Nigel McNie's avatar Nigel McNie Committed by Nigel McNie
Browse files
parents e3c6d9d9 ca63462a
<?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 Richard Mansfield <richard@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);
require(dirname(dirname(__FILE__)) . '/init.php');
$pagename = clean_requestdata('pagename', PARAM_ALPHAEXT, REQUEST_EITHER);
$data['pagename'] = $pagename;
try {
$page = get_record('site_content','name',$pagename);
$data['content'] = $page->content;
$data['success'] = 1;
}
catch (Exception $e) {
$data['success'] = 0;
$data['errormessage'] = $e->getMessage();
}
echo json_encode($data);
?>
<?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 Richard Mansfield <richard.mansfield@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);
require(dirname(dirname(__FILE__)).'/init.php');
require_once('form.php');
$sitepages = get_records('site_content');
$pageoptions = array();
foreach ($sitepages as $page) {
$pageoptions[$page->name] = get_string($page->name);
}
asort($pageoptions);
$f = array(
'name' => 'editsitepage',
'method' => 'post',
'onsubmit' => 'return submitForm(\'editsitepage\',\'savesitepage.json.php\');',
'action' => '',
'elements' => array(
'pagename' => array(
'type' => 'select',
'title' => get_string('pagename'),
'value' => 'home',
'options' => $pageoptions
),
'pagetext' => array(
'name' => 'pagetext',
'type' => 'wysiwyg',
'rows' => 25,
'cols' => 85,
'title' => get_string('pagecontent'),
'description' => get_string('textdesc'),
'value' => 'blah',
'rules' => array(
'required' => true
)
),
'submit' => array(
'value' => get_string('savechanges'),
'type' => 'submit',
)
)
);
$form = form($f);
$js = array('mochikit','mahara');
if (use_html_editor()) {
array_unshift($js,'tinymce');
}
$ijs = <<< EOJS
setEditorContent = function(content) { $('pagetext').innerHTML = content; };
function onLoad() {
requestPageText();
connect('pagename', 'onchange', requestPageText);
if (typeof(tinyMCE) != 'undefined') {
setEditorContent = tinyMCE.setContent;
}
}
function requestPageText() {
var d = loadJSONDoc('editchangepage.json.php',{'pagename':$('pagename').value});
d.addCallback(function(data) {
if (data.success) {
setEditorContent(data.content);
}
else {
displayMessage({'message':get_string('failedloadingpagecontent', $('pagename').value),
'type':'error'});
}
});
}
addLoadEvent(onLoad);
EOJS;
$jsstrings = array('requiredfieldempty','noresponse');
$smarty = smarty($js,array(),$jsstrings);
$smarty->assign('pageeditform', $form);
$smarty->assign('INLINEJAVASCRIPT', $ijs);
$smarty->display('admin/editsitepage.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 admin
* @author Richard Mansfield <richard.mansfield@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);
require(dirname(dirname(__FILE__)) . '/init.php');
$pagename = clean_requestdata('pagename', PARAM_ALPHAEXT, REQUEST_EITHER);
$pagetext = clean_requestdata('pagetext', PARAM_CLEANHTML, REQUEST_EITHER);
$result = array();
global $USER;
$data = new StdClass;
$data->name = $pagename;
$data->content = $pagetext;
$data->mtime = db_format_timestamp(time());
try {
$user = get_record('usr','username',$USER->username);
$data->muser = $user->id;
update_record('site_content',$data,'name');
$result['success'] = 'ok';
$result['message'] = get_string('savedsuccessfully');
}
catch (Exception $e) {
$result['success'] = 'error';
$result['message'] = $e->getMessage();
}
echo json_encode($result);
?>
<?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 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', 'mycontacts');
define('SUBMENUITEM', 'myaddressbook');
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
$smarty = smarty();
$smarty->display('contacts/addressbook/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 core
* @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', 'mycontacts');
define('SUBMENUITEM', 'mycommunities');
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
$smarty = smarty();
$smarty->display('contacts/communities/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 core
* @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', 'mycontacts');
define('SUBMENUITEM', 'myownedcommunities');
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
$smarty = smarty();
$smarty->display('contacts/communities/owned.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 core
* @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', 'mycontacts');
define('SUBMENUITEM', 'mygroups');
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
$smarty = smarty();
$smarty->display('contacts/groups/index.tpl');
?>
......@@ -18,28 +18,21 @@
*
* @package mahara
* @subpackage core
* @author Penny Leach <penny@catalyst.net.nz>
* @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('PUBLIC', 1);
define('MENUITEM', 'mycontacts');
define('SUBMENUITEM', 'myfriends');
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');
$smarty->display('contacts/index.tpl');
?>
// Expects strings array
function get_string(s) {
// @todo Still need to sprintf these strings.
var flatargs = flattenArguments(arguments);
if (arguments.length > 1) {
argstr = '(' + flatargs.slice(1).join(',') + ')';
} else {
argstr = '';
}
if (typeof(strings) == 'undefined' || typeof(strings[s]) == 'undefined') {
return '[[[' + s + argstr + ']]]';
}
return strings[s] + argstr;
}
// Expects strings array
function get_string(s) {
// @todo Still need to sprintf these strings.
var flatargs = flattenArguments(arguments);
if (arguments.length > 1) {
argstr = '(' + flatargs.slice(1).join(',') + ')';
} else {
argstr = '';
}
if (typeof(strings) == 'undefined' || typeof(strings[s]) == 'undefined') {
return '[[[' + s + argstr + ']]]';
}
return strings[s] + argstr;
}
// Appends a status message to the end of elemid
function displayMessage(m, /* optional */ elemid) {
var color = 'red';
if (m.type == 'ok') {
color = 'green';
}
else if (m.type == 'info') {
color = '#aa6;';
}
if (typeof(elemid) == 'undefined') {
elemid = 'messages';
}
$(elemid).appendChild(DIV({'style':'color:'+color+';'},m.message));
}
// Tests if elements with the 'required' class have content and
// displays the appropriate message.
// Uses the html output from form.php to find the title of required
// fields: <label for="elementid">Element title</label>
function testRequired(e,formid) {
if (hasElementClass(e,'required') && e.value == '') {
var labels = getElementsByTagAndClassName('label',null,formid);
for (var j = 0; j < labels.length; j++) {
if (getNodeAttribute(labels[j],'for') == e.name) {
displayMessage({'message':get_string('requiredfieldempty',scrapeText(labels[j])),
'type':'error'});
return false;
}
}
displayMessage({'message':get_string('requiredfieldempty'),'type':'error'});
return false;
}
return true;
}
// Gets form elements, submits them to a url via post, and waits for a
// JSON response containing the result of the submission.
function submitForm(formid,url) {
if (typeof(tinyMCE) != 'undefined') {
tinyMCE.triggerSave();
}
var formelements = getElementsByTagAndClassName(null,formid,formid);
var data = {};
for (var i = 0; i < formelements.length; i++) {
if (testRequired(formelements[i])) {
data[formelements[i].name] = formelements[i].value;
}
else {
return false;
}
}
var req = getXMLHttpRequest();
req.open('POST',url);
req.setRequestHeader('Content-type','application/x-www-form-urlencoded');
var d = sendXMLHttpRequest(req,queryString(data));
d.addCallback(function (result) {
var data = evalJSONRequest(result);
displayMessage({'message':data.message,'type':data.success});
});
d.addErrback(function() { displayMessage(get_string('unknownerror'),'error'); });
displayMessage({'message':get_string('processingform'),'type':'info'});
return false;
}
function displayMessage(m) {
var color = 'red';
if (m.type == 'ok') {
color = 'green';
}
else if (m.type == 'info') {
color = '#aa6;';
}
var elemid = 'messages';
if (arguments.length > 1 && typeof(arguments[1]) == 'string') {
elemid = arguments[1];
}
$(elemid).appendChild(DIV({'style':'color:'+color+';'},m.message));
}
......@@ -17,8 +17,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* @package mahara
* @subpackage core or plugintype/pluginname
* @author Your Name <you@example.org>
* @subpackage lang
* @author Richard Mansfield <richard.mansfield@catalyst.net.nz>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006,2007 Catalyst IT Ltd http://catalyst.net.nz
*
......
......@@ -26,13 +26,19 @@
defined('INTERNAL') || die();
$string['about'] = 'About';
$string['home'] = 'Home';
$string['loggedouthome'] = 'Logged out Home';
$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['password'] = 'Password';
$string['passworddesc'] = 'Your password';
$string['passwordhelp'] = 'The password you use to access the system.';
$string['privacy'] = 'Privacy';
$string['sessiontimedout'] = 'Your session has timed out, please enter your login details to continue';
$string['termsandconditions'] = 'Terms and conditions';
$string['uploadcopyright'] = 'Upload copyright';
$string['username'] = 'Username';
$string['usernamedesc'] = 'Your username';
$string['usernamehelp'] = 'The username you have been given to access this system.';
......@@ -46,4 +52,10 @@ $string['termsandconditions'] = 'Terms and Conditions';
$string['privacystatement'] = 'Privacy Statement';
$string['about'] = 'About';
$string['contactus'] = 'Contact Us';
$string['myfriends'] = 'My Friends';
$string['myaddressbook'] = 'My Addressbook';
$string['mycommunities'] = 'My Communities';
$string['myownedcommunities'] = 'My Owned Communities';
$string['mygroups'] = 'My Groups';
?>
<?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 form/element
* @author Nigel McNie <nigel@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();
/**
* Renders a button. Custom buttons are rendered nearly the same as
* normal submit buttons, only their name is changed (for use by the Form class
* internally).
*
* @param array $element The element to render
* @param Form $form The form to render the element for
* @return string The HTML for the element
*/
function form_render_button($element, $form) {
return '<input type="button"'
. Form::element_attributes($element)
. ' value="' . hsc($form->get_value($element)) . '">';
}
?>
......@@ -450,7 +450,15 @@ function is_hash($array) {
return !empty($diff);
}
/**
*
* Check whether to use the wysiwyg html editor or a plain textarea.
* @todo check user setting from db and browser capability
*
*/
function use_html_editor() {
return true;
}
/**
* Function to check if a directory exists and optionally create it.
......@@ -686,6 +694,33 @@ function main_nav() {
'name' => 'mycontacts',
'link' =>