Commit c0891dc7 authored by Martyn Smith's avatar Martyn Smith Committed by Martyn Smith
Browse files
parent 778a4e67
<?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('MENUITEM', 'account');
define('SUBMENUITEM', 'activity');
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
$smarty = smarty();
$smarty->display('account/activity/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 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('MENUITEM', 'account');
define('SUBMENUITEM', 'activityprefs');
require(dirname(dirname(dirname(dirname(__FILE__)))) . '/init.php');
$smarty = smarty();
$smarty->display('account/activity/preferences/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 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('MENUITEM', 'account');
define('SUBMENUITEM', 'changepassword');
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
$smarty = smarty();
$smarty->display('account/changepassword/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 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('MENUITEM', 'account');
define('SUBMENUITEM', 'accountprefs');
require(dirname(dirname(__FILE__)) . '/init.php');
$smarty = smarty();
$smarty->display('account/index.tpl');
?>
......@@ -25,6 +25,7 @@
*/
define('INTERNAL', 1);
define('ADMIN', 1);
require(dirname(dirname(__FILE__)) . '/init.php');
$pagename = clean_requestdata('pagename', PARAM_ALPHAEXT, REQUEST_EITHER);
......
......@@ -25,6 +25,7 @@
*/
define('INTERNAL',1);
define('ADMIN', 1);
require(dirname(dirname(__FILE__)).'/init.php');
require_once('form.php');
......
......@@ -25,6 +25,7 @@
*/
define('INTERNAL', 1);
define('ADMIN', 1);
require(dirname(dirname(__FILE__)) . '/init.php');
$pagename = clean_requestdata('pagename', PARAM_ALPHAEXT, REQUEST_EITHER);
......
......@@ -25,6 +25,7 @@
*/
define('INTERNAL', 1);
define('ADMIN', 1);
define('INSTALLER', 1);
require(dirname(dirname(__FILE__)) . '/init.php');
require(get_config('libroot') . 'upgrade.php');
......
......@@ -25,6 +25,7 @@
*/
define('INTERNAL', 1);
define('ADMIN', 1);
define('INSTALLER', 1);
require(dirname(dirname(__FILE__)).'/init.php');
......
......@@ -87,5 +87,12 @@ $string['creategroup'] = 'Add new group';
$string['groupname'] = 'Group name';
$string['groupdescription'] = 'Group description';
// my account
$string['account'] = 'My account';
$string['accountprefs'] = 'Account preferences';
$string['activityprefs'] = 'Activity preferences';
$string['changepassword'] = 'Change password';
$string['activity'] = 'Recent activity';
$string['emailname'] = 'Mahara System'; // robot!
?>
......@@ -64,7 +64,7 @@ function activity_occured($activitytype, $data) {
* <b>maharamessage</b> must contain $users, an array of userids.
* <b>usermessage</b> must contain $userto, id of recipient user.
* <b>feedback</b> must contain either $view (id of view) or $artefact (id of artefact)
* <b>watchlist</b> must contain either $view (id of view) or $artefact (id of artefact)
* <b>watchlist</b> must contain either $view (id of view) or $artefact (id of artefact) or $community (id of community)
* <b>newview</b> must contain $owner userid of view owner AND $view (id of new view)
*/
function handle_activity($activitytype, $data) {
......@@ -101,11 +101,11 @@ function handle_activity($activitytype, $data) {
case 'watchlist':
if ($data->view) {
$sql = 'SELECT u.*, p.method
FROM ' . $prefix . 'watchlist_view wv
FROM ' . $prefix . 'usr_watchlist_view wv
JOIN ' . $prefix . 'usr u
ON wa.user = u.id
JOIN ' . $prefix . 'usr_preference p
ON p.user = u.id
ON p.usr = u.id
WHERE pc.activity = ?
AND wv.view = ?
';
......@@ -113,18 +113,30 @@ function handle_activity($activitytype, $data) {
}
else if ($data->artefact) {
$sql = 'SELECT DISTINCT u.*, p.method
FROM ' . $prefix . 'watchlist_artefact wa
FROM ' . $prefix . 'usr_watchlist_artefact wa
JOIN ' . $prefix . 'artefact_parent_cache pc
ON (pc.parent = wa.artefact OR pc.artefact = wa.artefact)
JOIN ' . $prefix . 'usr u
ON wa.user = u.id
JOIN ' . $prefix . 'usr_preference p
ON p.user = u.id
ON p.usr = u.id
WHERE pc.activity = ?
AND (pc.parent = ? OR wa.artefact = ?)
';
$users = get_records_sql($sql, array('watchlist', $data->artefact));
}
else if ($data->community) {
$sql = 'SELECT DISTINCT u.*, p.method
FROM ' . $prefix . 'usr_watchlist_community c
JOIN ' . $prefix . 'usr u
ON c.usr = u.id
JOIN ' . $prefix . 'usr_preference p
ON p.usr = u.id
WHERE pc.activity = ?
AND c.community = ?
';
$users = get_records_sql($sql, array('watchlist', $data->community));
}
else {
throw new InvalidArgumentException("Invalid watchlist type");
}
......@@ -180,7 +192,7 @@ function activity_get_users($activitytype, $userids=null, $userobjs=null, $admin
$sql = 'SELECT u.*, p.method
FROM ' . get_config('dbprefix') .'usr u
JOIN ' . get_config('dbprefix') . 'usr_activity_preference p
ON p.user = u.id
ON p.usr = u.id
WHERE p.activity = ? ';
if (!empty($adminonly)) {
$sql .= ' AND u.admin = ? ';
......
......@@ -446,10 +446,6 @@ class Form {
foreach ($this->elements as $name => $elem) {
$result .= form_render_element($elem, $this);
}
$function = 'form_renderer_' . $this->renderer . '_messages';
if (function_exists($function)) {
$result .= $function($this->name);
}
$function = 'form_renderer_' . $this->renderer . '_footer';
if (function_exists($function)) {
$result .= $function();
......@@ -619,23 +615,29 @@ class Form {
}
}
$rdata = $function($element['name']);
$errmsgid = $element['name'] . '_errmsg';
$errmsgid = $element['name'] . '_msg';
$result .= 'if (!(' . $rdata->condition . ")){" ;
$result .= $this->name . '_set_error(\'' . $errmsgid . '\',\''
. $rdata->message . "');ok=false;}\n";
$result .= 'else{' . $this->name . '_rem_error(\'' . $errmsgid . "');}\n";
}
}
if ($element['type'] == 'submit' || $element['type'] == 'submitcancel') {
$submitname = $element['name'];
}
}
$result .= "return ok;\n}\n";
$js_error_function = 'form_renderer_' . $this->renderer . '_error_js';
if (!function_exists($js_error_function)) {
$js_messages_function = 'form_renderer_' . $this->renderer . '_messages_js';
if (!function_exists($js_messages_function)) {
@include_once('form/renderers/' . $this->renderer . '.php');
if (!function_exists($js_error_function)) {
throw new FormException('No such renderer error function "' . $js_error_function . '"');
if (!function_exists($js_messages_function)) {
throw new FormException('No renderer message function "' . $js_messages_function . '"');
}
if (!isset($submitname)) {
throw new FormException('Submit element required for js messages');
}
}
return $result . $js_error_function($this->name);
return $result . $js_messages_function($this->name,$submitname);
//return $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 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 submit and cancel button
*
* @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_submitcancel($element, Form $form) {
require_once('submit.php');
require_once('cancel.php');
$submitelement = $element;
$submitelement['value'] = $element['value'][0];
$cancelelement = $element;
$cancelelement['value'] = $element['value'][1];
return form_render_submit($submitelement, $form) . ' ' . form_render_cancel($cancelelement, $form);
}
?>
......@@ -86,7 +86,7 @@ function form_renderer_table($builtelement, $rawelement) {
$result .= hsc($rawelement['error']);
}
else {
$result .= "\t<tr style=\"display:none\" id=\"" . $rawelement['id'] . "_errmsg\"><td>";
$result .= "\t<tr style=\"display:none\" id=\"" . $rawelement['id'] . "_msg\"><td>";
}
$result .= "</td>\n\t</tr>\n";
......@@ -94,19 +94,14 @@ function form_renderer_table($builtelement, $rawelement) {
}
function form_renderer_table_header() {
return "<table cellspacing=\"0\" border=\"0\">\n";
return "<table cellspacing=\"0\" border=\"0\"><tbody>\n";
}
function form_renderer_table_footer() {
return "</table>\n";
return "</tbody></table>\n";
}
function form_renderer_table_messages($formid) {
// Element to hold messages relating to the whole form (used in javascript submission).
return "\t<tr id=\"" . $formid . "_msg\"><td colspan=\"2\" class=\"errmsg\"></td></tr>\n";
}
function form_renderer_table_error_js($id) {
function form_renderer_table_messages_js($id, $submitid) {
$result = 'function ' . $id . '_set_error(id,m) {';
$result .= "swapDOM($(id),TR({'id':id},TD({'colspan':2,'class':'errmsg'},m)));";
$result .= "}\n";
......@@ -114,10 +109,10 @@ function form_renderer_table_error_js($id) {
$result .= "swapDOM($(id),TR({'id':id,'style':'display:none;'},TD(null)));";
$result .= "}\n";
$result .= 'function ' . $id . '_message(m,type) {';
$result .= "replaceChildNodes($('" . $id . "_msg'),TD({'colspan':2,'class':type},m));";
$result .= "swapDOM($('" . $submitid . "_msg'),TR({'id':'" . $submitid
. "_msg'},TD({'colspan':2,'class':type},m)));";
$result .= "}\n";
return $result;
}
?>
......@@ -47,11 +47,10 @@ function form_rule_required($field) {
* string The error message, if the value is invalid.
*/
function form_rule_required_js($id) {
$r = new StdClass;
$r->condition = '$(\'' . $id . '\').value != \'\'';
$r->message = get_string('This field is required');
return $r;
}
?>
......@@ -845,6 +845,33 @@ function main_nav() {
),
),
);
$menu[] = array(
'name' => 'account',
'link' => $wwwroot . 'account/',
'section' => 'mahara',
'submenu' => array(
array(
'name' => 'accountprefs',
'link' => $wwwroot . 'account/',
'section' => 'mahara',
),
array(
'name' => 'activity',
'link' => $wwwroot . 'account/activity/',
'section' => 'mahara',
),
array(
'name' => 'activityprefs',
'link' => $wwwroot . 'account/activity/preferences',
'section' => 'mahara',
),
array(
'name' => 'changepassword',
'link' => $wwwroot . 'account/changepassword',
'section' => 'mahara',
),
),
);
if (defined('MENUITEM')) {
......
......@@ -207,6 +207,13 @@ function theme_get_image_path($imagelocation, $pluginlocation='') {
}
}
/**
* cleans incoming request data.
*
* @param string $paramname key to look for in request
* @param int $paramtype type of parameter to clean to (see constants.php)
* @param int $where where to fetch it (post, get either (see constants.php))
*/
function clean_requestdata($paramname,$paramtype,$where=REQUEST_EITHER) {
$cleanversion = '';
if ($where == REQUEST_POST || $where == REQUEST_EITHER) { // post overrides get for either
......
......@@ -45,7 +45,7 @@ class PluginNotificationEmail extends PluginNotification {
$messagebody = get_string('emailbodynoreply', 'notification.email')
. $data->message;
}
$prefurl = get_config('wwwroot') . 'account/activityprefs.php';
$prefurl = get_config('wwwroot') . 'account/activity/preferences/';
$messagebody .= "\n\n" . get_string('emailbodyending', 'notification.email', $prefurl);
email_user($user, $userfrom, $subject, $messagebody);
}
......
......@@ -89,7 +89,7 @@ class PluginNotificationEmaildigest extends PluginNotification {
}
$body .= "\n\n";
}
$prefurl = get_config('wwwroot') . 'account/activityprefs.php';
$prefurl = get_config('wwwroot') . 'account/activity/preferences/';
$body .= "\n\n" . get_string('emailbodyending', 'notification.emaildigest', $prefurl);
try {
email_user($user->user, null, $subject, $body);
......
{include file="header.tpl"}
{include file="adminmenu.tpl"}
<h2>{str tag="account"}</h2>
<div class="content">
Content from database here
</div>
{include file="footer.tpl"}
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