Commit 9d51effc authored by Alan McNatty's avatar Alan McNatty
Browse files

Merge branch 'master' of git://gitorious.org/mahara/mahara

parents 5ac85994 c1468bcf
all:
@echo "Run 'make imageoptim' to losslessly optimise all images"
@echo "Run 'make minaccept' to run the quick pre-commit tests"
@echo "Run 'make checksignoff' to check that your commits are all Signed-off-by"
@echo "Run 'make push' to push your changes to the repo"
imageoptim:
......@@ -12,5 +13,16 @@ imageoptim:
minaccept:
@find htdocs/ -type f -name "*.php" | xargs -n 1 -P 2 php -l && echo All good!
push: minaccept
checksignoff:
@branch=`git status | head -1 | sed 's/.* On branch //'`; \
commits=`git log origin/$$branch.. | grep "^commit" | wc -l`; \
signed=`git log origin/$$branch.. | grep "Signed-off-by: " | wc -l`; \
if test "$$commits" -ne "$$signed"; then \
echo "$$(($$commits - $$signed)) commit(s) on $$branch not signed off ($$signed/$$commits)"; \
false; \
else \
echo "All commits signed!"; \
fi
push: minaccept checksignoff
git push
......@@ -74,13 +74,16 @@ else if ($delete) {
$strids = join(',', $ids);
$userid = $USER->get('id');
db_begin();
// Remove parent pointers to messages we're about to delete
// Use temp table in subselect for Mysql compat.
execute_sql("
UPDATE {notification_internal_activity}
SET parent = NULL
WHERE parent IN (
SELECT id
FROM {notification_internal_activity}
WHERE id IN ($strids) AND usr = ?
FROM (
SELECT id FROM {notification_internal_activity} WHERE id IN ($strids) AND usr = ?
) AS temp
)",
array($userid)
);
......
......@@ -172,7 +172,6 @@ $deleteall = pieform(array(
'type' => 'submit',
'value' => get_string('deleteallnotifications', 'activity'),
'confirm' => get_string('reallydeleteallnotifications', 'activity'),
'class' => 'btn-del',
),
),
));
......
......@@ -44,7 +44,6 @@ if (!empty($member)) {
if ($institutions[$i->institution]->registerallowed) {
$elements[] = array(
'type' => 'submit',
'class' => 'btn-del',
'name' => '_leave_' . $i->institution,
'confirm' => get_string('reallyleaveinstitution'),
'title' => get_string('youareamemberof', 'mahara', $institutions[$i->institution]->displayname),
......
......@@ -87,15 +87,15 @@ function displaymenuitems(itemlist) {
// Creates one table row
function formatrow (item) {
// item has id, type, name, link, linkedto
var del = INPUT({'type':'button','class':'button','value':{$getstring['delete']}});
connect(del, 'onclick', function () { delitem(item.id); });
var edit = INPUT({'type':'button','class':'button','value':{$getstring['edit']}});
var edit = INPUT({'type':'button','class':'s icon btn-edit','value':{$getstring['edit']}});
connect(edit, 'onclick', function () { edititem(item); });
var del = INPUT({'type':'button','class':'s icon btn-del','value':{$getstring['delete']}});
connect(del, 'onclick', function () { delitem(item.id); });
var cells = map(
partial(TD,null),
[
item.name,
[del,edit]
[edit,del]
]
);
return TR({'id':'menuitem_'+item.id},cells);
......@@ -197,4 +197,4 @@ $smarty->assign('INLINEJAVASCRIPT', $ijs);
$smarty->assign('optionform', $optionform);
$smarty->display('admin/groups/groupcategories.tpl');
?>
\ No newline at end of file
?>
<?php
/**
* Mahara: Electronic portfolio, weblog, resume builder and social networking
* Copyright (C) 2006-2009 Catalyst IT Ltd and others; see:
* http://wiki.mahara.org/Contributors
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*
* @package mahara
* @subpackage core
* @author Ruslan Kabalin <ruslan.kabalin@luns.net.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2010 Lancaster University Network Services Limited
* http://www.luns.net.uk
*
*/
define('INTERNAL', 1);
define('ADMIN', 1);
define('JSON', 1);
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
require_once('group.php');
require_once('searchlib.php');
$query = param_variable('query', '');
$offset = param_integer('offset', 0);
$limit = 10;
$data = build_grouplist_html($query, $limit, $offset, $count);
$data['count'] = $count;
$data['offset'] = $offset;
$data['query'] = $query;
json_reply(false, array('data' => $data));
?>
......@@ -38,67 +38,45 @@ require_once('searchlib.php');
$query = param_variable('query', '');
$offset = param_integer('offset', 0);
$limit = param_integer('limit', 10);
$limit = 10;
$data = build_grouplist_html($query, $limit, $offset);
$searchform = pieform(array(
'name' => 'search',
'method' => 'post',
'renderer' => 'oneline',
'elements' => array(
'query' => array(
'type' => 'text',
'defaultvalue' => $query,
),
'search' => array(
'submit' => array(
'type' => 'submit',
'value' => get_string('search'),
),
),
));
function search_submit(Pieform $form, $values) {
redirect(get_config('wwwroot') . 'admin/groups/groups.php?query=' . urlencode($values['query']));
}
$groups = search_group($query, $limit, $offset, 'all');
if ($ids = array_map(create_function('$a', 'return intval($a->id);'), $groups['data'])) {
$sumsql = "(m.role = 'admin')";
if (is_postgres()) {
$sumsql .= '::int';
}
// Member & admin counts
$ids = join(',', $ids);
$counts = get_records_sql_assoc("
SELECT m.group, COUNT(m.member) AS members, SUM($sumsql) AS admins
FROM {group_member} m
WHERE m.group IN ($ids)
GROUP BY m.group",
array()
);
}
$js = <<< EOF
addLoadEvent(function () {
p = {$data['pagination_js']}
connect('search_submit', 'onclick', function (event) {
replaceChildNodes('messages');
var params = {'query': $('search_query').value};
p.sendQuery(params);
event.stop();
});
});
EOF;
foreach ($groups['data'] as &$group) {
$group->visibility = $group->public ? get_string('Public', 'group') : get_string('Members', 'group');
$group->admins = empty($counts[$group->id]->admins) ? 0 : $counts[$group->id]->admins;
$group->members = empty($counts[$group->id]->members) ? 0 : $counts[$group->id]->members;
}
$pagination = build_pagination(array(
'url' => get_config('wwwroot') . 'admin/groups/groups.php?query=' . $query,
'count' => $groups['count'],
'limit' => $limit,
'offset' => $offset,
'resultcounttextsingular' => get_string('group', 'group'),
'resultcounttextplural' => get_string('groups', 'group'),
));
$smarty = smarty();
$smarty = smarty(array('paginator'));
$smarty->assign('PAGEHEADING', TITLE);
$smarty->assign('INLINEJAVASCRIPT', $js);
$smarty->assign('searchform', $searchform);
$smarty->assign('groups', $groups);
$smarty->assign('pagination', $pagination);
$smarty->assign('results', $data);
$smarty->display('admin/groups/groups.tpl');
function search_submit(Pieform $form, $values) {
redirect(get_config('wwwroot') . 'admin/groups/groups.php' . (!empty($values['query']) ? '?query=' . urlencode($values['query']) : ''));
}
?>
......@@ -88,17 +88,17 @@ function formatrow (item) {
// item has id, type, name, link, linkedto
var type = eval(item.type);
var linkedto = A({'href':item.linkedto},item.linktext);
var del = INPUT({'type':'button','class':'button','value':{$getstring['delete']}});
connect(del, 'onclick', function () { delitem(item.id); });
var edit = INPUT({'type':'button','class':'button','value':{$getstring['edit']}});
connect(edit, 'onclick', function () { edititem(item); });
var del = INPUT({'type':'button','class':'button','value':{$getstring['delete']}});
connect(del, 'onclick', function () { delitem(item.id); });
var cells = map(
partial(TD,null),
[
type,
item.name,
linkedto,
[del,edit,contextualHelpIcon(null, null, 'core', 'admin', null, 'adminmenuedit')]
[edit,del,contextualHelpIcon(null, null, 'core', 'admin', null, 'adminmenuedit')]
]
);
return TR({'id':'menuitem_'+item.id},cells);
......
......@@ -130,6 +130,9 @@ $elements = array(
),
);
if (!$USER->get('admin')) {
unset ($elements['authinstance']['defaultvalue']);
}
$form = pieform(array(
'name' => 'adduser',
......
......@@ -187,12 +187,14 @@ function updateSsoOptions() {
}
addLoadEvent(
function() {
connect('auth_config_parent', 'onchange', authloginmsgVisibility);
authloginmsgVisibility();
if ($('auth_config_parent')) {
connect('auth_config_parent', 'onchange', authloginmsgVisibility);
authloginmsgVisibility();
}
if ($('auth_config_ssodirection')) {
connect('auth_config_ssodirection', 'onchange', updateSsoOptions);
updateSsoOptions();
}
updateSsoOptions();
}
);
EOF;
......
......@@ -162,6 +162,29 @@ $siteform = pieform(array(
'elements' => $elements,
));
function edituser_site_validate(Pieform $form, $values) {
global $USER, $SESSION;
if (!$user = get_record('usr', 'id', $values['id'])) {
return false;
}
$maxquotaenabled = get_config_plugin('artefact', 'file', 'maxquotaenabled');
$maxquota = get_config_plugin('artefact', 'file', 'maxquota');
if ($maxquotaenabled && $values['quota'] > $maxquota) {
$form->set_error('quota', get_string('maxquotaexceededform', 'artefact.file', display_size($maxquota)));
$SESSION->add_error_msg(get_string('maxquotaexceeded', 'artefact.file', display_size($maxquota)));
}
// Check that the external username isn't already in use
if (isset($values['remoteusername']) &&
$usedby = get_record_select('auth_remote_user',
'authinstance = ? AND remoteusername = ? AND localusr != ?',
array($values['authinstance'], $values['remoteusername'], $values['id']))
) {
$usedbyuser = get_field('usr', 'username', 'id', $usedby->localusr);
$SESSION->add_error_msg(get_string('duplicateremoteusername', 'auth', $usedbyuser));
$form->set_error('remoteusername', get_string('duplicateremoteusernameformerror', 'auth'));
}
}
function edituser_site_submit(Pieform $form, $values) {
if (!$user = get_record('usr', 'id', $values['id'])) {
......@@ -249,7 +272,7 @@ if (empty($suspended)) {
'reason' => array(
'type' => 'textarea',
'rows' => 5,
'cols' => 60,
'cols' => 28,
'title' => get_string('reason'),
'description' => get_string('suspendedreasondescription', 'admin'),
),
......@@ -352,7 +375,7 @@ $elements = array(
),
);
$allinstitutions = get_records_assoc('institution');
$allinstitutions = get_records_assoc('institution', '', '', 'displayname');
foreach ($user->get('institutions') as $i) {
$elements[$i->institution.'_settings'] = array(
'type' => 'fieldset',
......@@ -510,13 +533,17 @@ $smarty->assign('siteform', $siteform);
$smarty->assign('institutions', count($allinstitutions) > 1);
$smarty->assign('institutionform', $institutionform);
if ($id != $USER->get('id') && is_null($USER->get('parentuser'))) {
$loginas = get_string('loginasuser', 'admin', $user->username);
} else {
$loginas = null;
}
$smarty->assign('loginas', $loginas);
$smarty->assign('loginas', $id != $USER->get('id') && is_null($USER->get('parentuser')));
$smarty->assign('PAGEHEADING', TITLE . ': ' . display_name($user));
# Only allow deletion and suspension of a user if the viewed user is not
# the current user; or if they are the current user, they're not the only
# admin
if ($id != $USER->get('id') || count_records('usr', 'admin', 1, 'deleted', 0) > 1) {
$smarty->assign('suspendable', ($USER->get('admin') || !$user->get('admin') && !$user->get('staff')));
$smarty->assign('deletable', $USER->get('admin'));
}
$smarty->display('admin/users/edit.tpl');
?>
<?php
/**
* Mahara: Electronic portfolio, weblog, resume builder and social networking
* Copyright (C) 2006-2009 Catalyst IT Ltd and others; see:
* http://wiki.mahara.org/Contributors
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*
* @package mahara
* @subpackage core
* @author Ruslan Kabalin <ruslan.kabalin@luns.net.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2010 Lancaster University Network Services Limited
* http://www.luns.net.uk
*
*/
define('INTERNAL', 1);
define('INSTITUTIONALADMIN', 1);
define('JSON', 1);
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
$query = param_variable('query', '');
$offset = param_integer('offset', 0);
$limit = 20;
// Get a list of institutions
require_once(get_config('libroot') . 'institution.php');
if (!$USER->get('admin')) { // Filter the list for institutional admins
$filter = $USER->get('admininstitutions');
$showdefault = false;
}
else {
$filter = false;
$showdefault = true;
}
$data = build_institutions_html($filter, $showdefault, $query, $limit, $offset, $count);
$data['count'] = $count;
$data['limit'] = $limit;
$data['offset'] = $offset;
$data['query'] = $query;
json_reply(false, array('data' => $data));
?>
......@@ -33,13 +33,16 @@ define('SECTION_PLUGINNAME', 'admin');
define('SECTION_PAGE', 'institutions');
require_once('pieforms/pieform.php');
define('MENUITEM', 'manageinstitutions/institutions');
$smarty = smarty(array('lib/pieforms/static/core/pieforms.js'));
$institution = param_variable('i', '');
$add = param_boolean('add');
$edit = param_boolean('edit');
$delete = param_boolean('delete');
$query = param_variable('query', '');
$offset = param_integer('offset', 0);
$limit = 20;
if (!$USER->get('admin')) {
// Institutional admins with only 1 institution go straight to the edit page for that institution
// They cannot add or delete institutions, or edit an institution they don't administer
......@@ -129,7 +132,9 @@ if ($institution || $add) {
)
)
);
$smarty->assign('delete_form', pieform($form));
$deleteform = pieform($form);
$smarty = smarty();
$smarty->assign('delete_form', $deleteform);
$smarty->assign('institutionname', get_field('institution', 'displayname', 'name', $institution));
$smarty->display('admin/users/institutions.tpl');
exit;
......@@ -175,7 +180,6 @@ if ($institution || $add) {
$data->theme = 'sitedefault';
$data->defaultmembershipperiod = null;
$lockedprofilefields = array();
$smarty->assign('add', true);
$authtypes = auth_get_available_auth_types();
}
......@@ -333,15 +337,13 @@ if ($institution || $add) {
'value' => array(get_string('submit'), get_string('cancel'))
);
$smarty->assign('instancestring', $instancestring);
$smarty->assign('institution_form', pieform(array(
$institutionform = pieform(array(
'name' => 'institution',
'renderer' => 'table',
'plugintype' => 'core',
'pluginname' => 'admin',
'elements' => $elements
)));
));
}
else {
......@@ -352,12 +354,49 @@ else {
$showdefault = false;
}
else {
$smarty->assign('siteadmin', true);
$filter = false;
$showdefault = true;
}
$institutions = Institution::count_members($filter, $showdefault);
$smarty->assign('institutions', $institutions);
$data = build_institutions_html($filter, $showdefault, $query, $limit, $offset, $count);
$smarty = smarty(array('lib/pieforms/static/core/pieforms.js', 'paginator'));
$smarty->assign('results', $data);
$smarty->assign('countinstitutions', $count);
/*search institution form*/
$searchform = pieform(array(
'name' => 'search',
'renderer' => 'oneline',
'elements' => array(
'query' => array(
'type' => 'text',
'defaultvalue' => $query
),
'submit' => array(
'type' => 'submit',
'value' => get_string('search')
)
)
));
$smarty->assign('searchform', $searchform);
$js = <<< EOF
addLoadEvent(function () {
p = {$data['pagination_js']}
connect('search_submit', 'onclick', function (event) {
replaceChildNodes('messages');
var params = {'query': $('search_query').value};
p.sendQuery(params);
event.stop();
});
});
EOF;
$smarty->assign('INLINEJAVASCRIPT', $js);
$smarty->assign('siteadmin', $USER->get('admin'));
$smarty->assign('PAGEHEADING', get_string('admininstitutions', 'admin'));
$smarty->display('admin/users/institutions.tpl');
exit;
}
function institution_validate(Pieform $form, $values) {
......@@ -389,10 +428,10 @@ function institution_submit(Pieform $form, $values) {
}
$newinstitution->theme = (empty($values['theme']) || $values['theme'] == 'sitedefault') ? null : $values['theme'];
if ($institution != 'mahara') {
$newinstitution->expiry = db_format_timestamp($values['expiry']);
$newinstitution->defaultmembershipperiod = ($values['defaultmembershipperiod']) ? intval($values['defaultmembershipperiod']) : null;
if ($USER->get('admin')) {
$newinstitution->maxuseraccounts = ($values['maxuseraccounts']) ? intval($values['maxuseraccounts']) : null;
$newinstitution->expiry = db_format_timestamp($values['expiry']);
}
}
......@@ -574,14 +613,28 @@ if ($institution && $institution != 'mahara') {
$suspendformdef['successcallback'] = 'institution_unsuspend_submit';
$suspendform_top = pieform($suspendformdef);
}
}
}
function search_submit(Pieform $form, $values) {
redirect('/admin/users/institutions.php' . (!empty($values['query']) ? '?query=' . urlencode($values['query']) : ''));
}
$smarty = smarty();
$smarty->assign('institution_form', $institutionform);
$smarty->assign('instancestring', $instancestring);
$smarty->assign('add', $add);
if (isset($suspended)) {
if ($suspended) {
$smarty->assign('suspended', get_string('suspendedinstitutionmessage', 'admin'));
}
if (isset($suspendform)) {
$smarty->assign('suspendform', $suspendform);
if (isset($suspendform_top)) {
$smarty->assign('suspendform_top', $suspendform_top);
}
}
if ($suspended) {
$smarty->assign('suspended', get_string('suspendedinstitutionmessage', 'admin'));
}
}
$smarty->assign('PAGEHEADING', get_string('admininstitutions', 'admin'));
......
......@@ -44,6 +44,7 @@ $sql = '
LEFT OUTER JOIN {usr_institution} ui
ON (ui.usr = u.id' . ($USER->get('admin') ? '' : ' AND ui.institution IN ('
. join(',',array_map('db_quote', array_keys($USER->get('institutions')))) . ')') . ')
WHERE u.deleted = 0
GROUP BY
u.id, u.username, u.firstname, u.lastname, u.preferredname, u.admin, u.staff,
a.activity, a.method
......
......@@ -627,6 +627,12 @@ function submit_view_for_assessment($username, $viewid) {
}
}
$view->commit();
// Lock view contents
require_once(get_config('docroot') . 'artefact/lib.php');
ArtefactType::update_locked($user->get('id'));
return $data;
}
......
......@@ -31,5 +31,6 @@ $string['title'] = 'Blog';
$string['description'] = 'Display an entire blog';
$string['defaulttitledescription'] = 'If you leave this blank, the title of the blog will be used';
$string['postsperpage'] = 'Posts per page';
?>
......@@ -57,6 +57,7 @@ class PluginBlocktypeBlog extends PluginBlocktype {
}
public static function render_instance(BlockInstance $instance, $editing=false) {
global $exporter;
$configdata = $instance->get('configdata');
$result = '';
......@@ -64,6 +65,7 @@ class PluginBlocktypeBlog extends PluginBlocktype {
require_once(get_config('docroot') . 'artefact/lib.php');
$blog = $instance->get_artefact_instance($configdata['artefactid']);
$configdata['hidetitle'] = true;
$configdata['countcomments'] = true;