Commit bcede6bd authored by Nigel McNie's avatar Nigel McNie
Browse files

Merge branch 'master' of git+ssh://git.catalyst.net.nz/git/public/mahara

Conflicts:

	htdocs/admin/site/options.php
parents c8886109 d2b4fed1
......@@ -62,7 +62,7 @@ foreach ($activitytypes as $type) {
else {
$section = 'activity';
}
$elements[$type->id] = array(
$elements['activity_'.$type->id] = array(
'defaultvalue' => $dv,
'type' => 'select',
'title' => get_string('type' . $type->name, $section),
......@@ -72,8 +72,8 @@ foreach ($activitytypes as $type) {
)
);
if (!empty($type->admin)) {
$elements[$type->id]['rules']['required'] = false;
$elements[$type->id]['options']['none'] = get_string('none');
$elements['activity_'.$type->id]['rules']['required'] = false;
$elements['activity_'.$type->id]['options']['none'] = get_string('none');
}
}
......@@ -104,11 +104,11 @@ function activityprefs_submit(Pieform $form, $values) {
$userid = $USER->get('id');
foreach ($activitytypes as $type) {
if ($values[$type->id] == 'none') {
if ($values['activity_'.$type->id] == 'none') {
$USER->set_activity_preference($type->id, null);
}
else {
$USER->set_activity_preference($type->id, $values[$type->id]);
$USER->set_activity_preference($type->id, $values['activity_'.$type->id]);
}
}
$form->json_reply(PIEFORM_OK, get_string('prefssaved', 'account'));
......
......@@ -165,11 +165,18 @@ function siteoptions_submit(Pieform $form, $values) {
$fields = array('sitename','lang','theme','pathtofile', 'pathtoclam',
'defaultaccountlifetime', 'defaultaccountinactiveexpire', 'defaultaccountinactivewarn',
'allowpublicviews', 'searchplugin');
'allowpublicviews','artefactviewinactivitytime', 'searchplugin');
$oldlanguage = get_config('lang');
foreach ($fields as $field) {
if (!set_config($field, $values[$field])) {
siteoptions_fail($form, $field);
}
}
if ($oldlanguage != $values['lang']) {
safe_require('artefact', 'file');
ArtefactTypeFolder::change_public_folder_name($oldlanguage, $values['lang']);
}
// submitted sessionlifetime is in minutes; db entry session_timeout is in seconds
if (!set_config('session_timeout', $values['sessionlifetime'] * 60)) {
siteoptions_fail($form, 'sessionlifetime');
......
......@@ -773,7 +773,10 @@ class ArtefactTypeFolder extends ArtefactTypeFileBase {
}
public static function admin_public_folder_id() {
$name = get_string('adminpublicdirname', 'admin');
// There is one public files directory and many admins, so the
// name of the directory uses the site language rather than
// the language of the admin who first creates it.
$name = get_string_from_language(get_config('lang'), 'adminpublicdirname', 'admin');
$folderid = get_field_sql('
SELECT
a.id
......@@ -786,7 +789,8 @@ class ArtefactTypeFolder extends ArtefactTypeFileBase {
if (!$folderid) {
global $USER;
if (get_field('usr', 'admin', 'id', $USER->id)) {
$description = get_string('adminpublicdirdescription', 'admin');
$description = get_string_from_language(get_config('lang'),
'adminpublicdirdescription', 'admin');
$data = (object) array('title' => $name,
'description' => $description,
'owner' => $USER->id,
......@@ -801,6 +805,32 @@ class ArtefactTypeFolder extends ArtefactTypeFileBase {
return $folderid;
}
public static function change_public_folder_name($oldlang, $newlang) {
$oldname = get_string_from_language($oldlang, 'adminpublicdirname', 'admin');
$folderid = get_field_sql('
SELECT
a.id
FROM {artefact} a
INNER JOIN {artefact_file_files} f ON a.id = f.artefact
WHERE a.title = ?
AND a.artefacttype = ?
AND f.adminfiles = 1
AND a.parent IS NULL', array($oldname, 'folder'));
if (!$folderid) {
return;
}
$name = get_string_from_language($newlang, 'adminpublicdirname', 'admin');
$description = get_string_from_language($newlang, 'adminpublicdirdescription', 'admin');
if (!empty($name)) {
$artefact = artefact_instance_from_id($folderid);
$artefact->set('title', $name);
$artefact->set('description', $description);
$artefact->commit();
}
}
public static function get_folder_by_name($name, $parentfolderid=null, $userid=null) {
if (empty($userid)) {
global $USER;
......@@ -841,6 +871,24 @@ class ArtefactTypeFolder extends ArtefactTypeFileBase {
'_default' => $wwwroot . 'artefact/file/?folder=' . $id,
);
}
public static function change_language($userid, $oldlang, $newlang) {
$oldname = get_string_from_language($oldlang, 'feedbackattachdirname', 'view');
$artefact = ArtefactTypeFolder::get_folder_by_name($oldname, null, $userid);
if (empty($artefact)) {
return;
}
$name = get_string_from_language($newlang, 'feedbackattachdirname', 'view');
$description = get_string_from_language($newlang, 'feedbackattachdirdesc', 'view');
if (!empty($name)) {
$artefact = artefact_instance_from_id($artefact->id);
$artefact->set('title', $name);
$artefact->set('description', $description);
$artefact->commit();
}
}
}
class ArtefactTypeImage extends ArtefactTypeFile {
......
......@@ -234,12 +234,13 @@ class ArtefactTypeProfile extends ArtefactType {
return array(
'firstname' => 'text',
'lastname' => 'text',
'email' => 'emaillist',
'email' => 'emaillist',
);
}
public static function get_public_fields() {
$all = self::get_all_fields();
$alwaysp = self::get_always_public_fields();
$p = array();
if ($pub = get_config_plugin('artefact', 'internal', 'profilepublic')) {
$public = explode(',', $pub);
......@@ -250,7 +251,13 @@ class ArtefactTypeProfile extends ArtefactType {
foreach ($public as $pf) {
$p[$pf] = $all[$pf];
}
return $p;
return array_merge($p, $alwaysp);
}
public static function get_always_public_fields() {
return array(
'introduction' => 'wysiwyg'
);
}
public static function has_config() {
......@@ -261,6 +268,7 @@ class ArtefactTypeProfile extends ArtefactType {
$mandatory = self::get_mandatory_fields();
$public = self::get_public_fields();
$alwaysmandatory = self::get_always_mandatory_fields();
$alwayspublic = self::get_always_public_fields();
$form = array(
'renderer' => 'multicolumntable',
'elements' => array(
......@@ -295,6 +303,10 @@ class ArtefactTypeProfile extends ArtefactType {
'type' => 'checkbox',
);
if (isset($alwayspublic[$field])) {
$form['elements'][$field . '_public']['value'] = 'checked';
$form['elements'][$field . '_public']['disabled'] = true;
}
}
$form['elements']['emptyrow'] = array(
......
......@@ -657,7 +657,6 @@ class LiveUser extends User {
if (is_null($id)) {
$id = $this->get('id');
}
$this->commit();
$this->find_by_id($id);
$this->activityprefs = load_activity_preferences($id);
$this->accountprefs = load_account_preferences($id);
......
......@@ -409,7 +409,7 @@ class BlockInstance {
}
if ($new) {
$cancel = get_string('remove', 'view');
$cancel = get_string('remove');
$elements['removeoncancel'] = array('type' => 'hidden', 'value' => 1);
$elements['sure'] = array('type' => 'hidden', 'value' => 1);
}
......
......@@ -130,7 +130,7 @@ $commview = get_config('wwwroot') . 'group/view.php';
$releaseviewstr = get_string('releaseview', 'group');
$tutorstr = get_string('tutor', 'group');
$memberstr = get_string('member', 'group');
$removestr = get_string('remove', 'group');
$removestr = get_string('remove');
$declinestr = get_string('declinerequest', 'group');
$updatefailedstr = get_string('updatefailed', 'group');
$requeststr = get_string('sendrequest', 'group');
......
......@@ -183,6 +183,7 @@ $string['currentfriends'] = 'Current Friends';
$string['pendingfriends'] = 'Pending friends';
$string['backtofriendslist'] = 'Back to Friends List';
$string['findnewfriends'] = 'Find New Friends';
$string['Views'] = 'Views';
$string['seeallviews'] = 'See all %s views...';
$string['noviewstosee'] = 'None that you can see :(';
$string['whymakemeyourfriend'] = 'This is why you should make me your friend:';
......@@ -196,6 +197,8 @@ $string['addtomyfriends'] = 'Add to My Friends!';
$string['friendshiprequested'] = 'Friendship requested!';
$string['existingfriend'] = 'existing friend';
$string['nosearchresultsfound'] = 'No search results found :(';
$string['friend'] = 'friend';
$string['friends'] = 'friends';
$string['friendlistfailure'] = 'Failed to modify your friends list';
$string['userdoesntwantfriends'] = 'This user doesn\'t want any new friends';
......
......@@ -46,6 +46,7 @@ $string['loading'] = 'Loading ...';
$string['showtags'] = 'Show my tags';
$string['errorprocessingform'] = 'There was an error with submitting this form. Please check the marked fields and try again.';
$string['description'] = 'Description';
$string['remove'] = 'Remove';
$string['no'] = 'No';
$string['yes'] = 'Yes';
......@@ -333,6 +334,7 @@ $string['myportfolio'] = 'My Portfolio';
$string['myviews'] = ' My Views';
$string['settings'] = 'Settings';
$string['myfriends'] = 'My Friends';
$string['findfriends'] = 'Find Friends';
$string['groups'] = 'Groups';
$string['mygroups'] = 'My Groups';
$string['findgroups'] = 'Find Groups';
......
......@@ -180,7 +180,6 @@ $string['blockinstanceconfiguredsuccessfully'] = 'Block configured successfully'
$string['addnewblockhere'] = 'Add new block here';
$string['add'] = 'Add';
$string['addcolumn'] = 'Add Column';
$string['remove'] = 'Remove';
$string['removecolumn'] = 'Remove this column';
$string['moveblockleft'] = 'Move this block left';
$string['moveblockdown'] = 'Move this block down';
......
......@@ -44,7 +44,7 @@ function pieform_element_viewacl(Pieform $form, $element) {
$presets = array('public', 'loggedin', 'friends');
}
else {
$presets = array('loggedinu', 'friends');
$presets = array('loggedin', 'friends');
}
if ($value) {
foreach ($value as $key => &$item) {
......
......@@ -1705,6 +1705,10 @@ function profile_sideblock() {
$data = array(
'id' => $USER->get('id'),
);
$saveduser = $USER->get('parentuser');
if (!empty($saveduser) && $saveduser->name) {
$data['realuser'] = $saveduser->name;
}
$data['unreadnotifications'] = call_static_method(generate_class_name('notification', 'internal'), 'unread_count', $USER->get('id'));
$data['unreadnotificationsmessage'] = $data['unreadnotifications'] == 1 ? get_string('unreadmessage') : get_string('unreadmessages');
$invitedgroups = get_invited_groups();
......
......@@ -115,8 +115,8 @@ function set_account_preference($userid, $field, $value) {
/**
* Change language-specific stuff in the db for a user. Currently
* just changes the name of the 'blogfiles' folder in the user's files
* area.
* just changes the name of the 'blogfiles' and 'assessmentfiles'
* folders in the user's files area.
*
* @param int $userid user id to set preference for
* @param string $oldlang old language
......@@ -127,6 +127,10 @@ function change_language($userid, $oldlang, $newlang) {
safe_require('artefact', 'blog');
ArtefactTypeBlogPost::change_language($userid, $oldlang, $newlang);
}
if (get_field('artefact_installed', 'active', 'name', 'file')) {
safe_require('artefact', 'file');
ArtefactTypeFolder::change_language($userid, $oldlang, $newlang);
}
}
/**
......
......@@ -366,7 +366,7 @@ EOF;
}
// ---------- sideblock stuff ----------
if (!defined('INSTALLER') && (defined('MENUITEM') && substr(MENUITEM, 0, 5) != 'admin')) {
if (!defined('INSTALLER') && (!defined('MENUITEM') || substr(MENUITEM, 0, 5) != 'admin')) {
if (get_config('installed')) {
$data = site_menu();
if (!empty($data)) {
......@@ -1583,19 +1583,24 @@ function main_nav() {
'title' => get_string('mygroups'),
'weight' => 10
),
array(
'path' => 'groups/myfriends',
'url' => 'user/',
'title' => get_string('myfriends'),
'weight' => 20,
),
array(
'path' => 'groups/find',
'url' => 'group/find.php',
'title' => get_string('findgroups'),
'weight' => 20
),
array(
'path' => 'groups/myfriends',
'url' => 'user/myfriends.php',
'title' => get_string('myfriends'),
'weight' => 30
),
array(
'path' => 'groups/findfriends',
'url' => 'user/find.php',
'title' => get_string('findfriends'),
'weight' => 40
),
array(
'path' => 'settings',
'url' => 'account/',
......@@ -1767,7 +1772,7 @@ function searchform() {
require_once('pieforms/pieform.php');
return pieform(array(
'name' => 'searchform',
'action' => get_config('wwwroot') . 'search.php',
'action' => get_config('wwwroot') . 'user/find.php',
'renderer' => 'oneline',
'autofocus' => false,
'validate' => false,
......
<?php
/**
* Mahara: Electronic portfolio, weblog, resume builder and social networking
* Copyright (C) 2006-2007 Catalyst IT Ltd (http://www.catalyst.net.nz)
*
* 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 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('init.php');
define('SECTION_PLUGINTYPE', 'core');
define('SECTION_PLUGINNAME', 'search');
define('SECTION_PAGE', 'search');
define('TITLE', get_string('search'));
// If there is no query posted, the 'results' section of the page will
// stay invisible until a query is submitted.
$query = param_variable('query','');
$noresults = get_string('noresultsfound');
$wwwroot = get_config('wwwroot');
safe_require('artefact', 'internal');
$userfields = ArtefactTypeProfile::get_public_fields();
$userfieldstrings = array(get_string('name'));
foreach ($userfields as $k => $v) {
$userfieldstrings[] = get_string($k, 'artefact.internal');
}
$userfields = json_encode(array_keys($userfields));
$ncols = count($userfieldstrings);
$userfieldstrings = json_encode($userfieldstrings);
$javascript = <<<EOF
var userfields = {$userfields};
var userfieldstrings = {$userfieldstrings};
var results = new TableRenderer(
'searchresults',
'{$wwwroot}json/search.php',
[]
);
results.statevars.push('query');
results.statevars.push('type');
results.emptycontent = '{$noresults}';
results.updatecallback = function (d) {
if (d.type == 'user') {
results.linkspan = {$ncols};
if (!$('userfields')) {
appendChildNodes(results.thead, TR({'id':'userfields'},
map(partial(TH, null), userfieldstrings)));
}
}
else {
results.linkspan = 1;
removeElement('userfields');
if ($('userfields')) {
removeElement('userfields');
}
}
}
results.rowfunction = function(r,n,d) {
if ( d.type == 'group' ) {
return TR({'class':'r'+(n%2)},
TD(null,A({'href':'group/view.php?id=' + r.id},r.name)));
}
var row = TR({'class':'r'+(n%2)},TD(null,A({'href':'user/view.php?id=' + r.id},r.name)));
for (var i = 0; i < userfields.length; i++) {
if (r[userfields[i]]) {
if (userfields[i] == 'introduction') {
var td = TD();
td.innerHTML = r[userfields[i]];
appendChildNodes(row, td);
}
else {
appendChildNodes(row, TD(null, r[userfields[i]]));
}
}
else {
appendChildNodes(row, TD(null));
}
}
return row;
}
function doSearch() {
results.query = $('search_query').value;
results.type = $('search_type').options[$('search_type').selectedIndex].value;
results.offset = 0;
results.doupdate();
}
EOF;
$smarty = smarty(array('tablerenderer'));
if (isset($_REQUEST['query'])) {
$javascript .= ' results.query = ' . json_encode($query) . ";\n";
$javascript .= " results.updateOnLoad();\n";
$smarty->assign('search_query_value', $query);
}
$smarty->assign('INLINEJAVASCRIPT', $javascript);
$smarty->display('search.tpl');
?>
{include file="header.tpl"}
{include file="columnfullstart.tpl"}
<div class="searchform">
<h2>{str tag="search"}</h2>
<form action="" method="get" onsubmit="doSearch(); return false;">
<label>{str tag=Query}:
<input type="text" name="search_query" id="search_query" value="{$search_query_value|escape}">
</label>
<select id="search_type">
<option value="user">{str tag=users}</option>
<option value="group">{str tag=groups}</option>
</select>
<input type="submit" class="submit" value="{str tag='go'}">
</form>
</div>
<div id="seachresults">
<h3>{str tag="Results"}</h3>
<table id="searchresults" class="hidden tablerenderer">
<tbody>
</tbody>
</table>
</div>
{include file="columnfullend.tpl"}
{include file="footer.tpl"}
......@@ -65,3 +65,8 @@
<a href="{$WWWROOT}?logout">{str tag="logout"}</a>
| <a href="{$WWWROOT}account/">{str tag="settings"}</a>
</div>
{if $data.realuser}
<div>
<a href="{$WWWROOT}admin/users/changeuser.php?restore=1">{str tag=becomeadminagain section=admin args=$data.realuser}</a>
</div>
{/if}
{include file="header.tpl"}
{include file="sidebar.tpl"}
{include file="columnleftstart.tpl"}
<h2>{$heading}</h2>
{include file="columnleftend.tpl"}
{include file="footer.tpl"}
{include file="header.tpl"}
{include file="sidebar.tpl"}
{include file="columnleftstart.tpl"}
<h2>{$heading}</h2>
<div id="friendslistcontainer">
{$form}
{if $users}
<table id="friendslist">
{foreach from=$users item=user}
<tr class="r{cycle values=1,0}">
{include file="user/user.tpl" user=$user }
</tr>
{/foreach}
</table>
</div>
<div class="center">
{$pagination}
{else}
</div>
<div class="message">
{$message}
</div>
{/if}
{include file="columnleftend.tpl"}
{include file="footer.tpl"}
{if $user->pending}
<td class="pending">
<div class="fl">
<img src="{$WWWROOT}thumb.php?type=profileicon&amp;size=40x40&amp;id={$user->id}">
</div>
<table class="friendinfo">
<tr>
<th>
<div class="fr">
{$user->accept}
</div>
<h3>
<a href="{$WWWROOT}user/view.php?id={$user->id}">
{$user->id|display_name|escape}
</a>
- {str tag='pending' section='group'}
</h3>
</th>
</tr>
<tr>
<td id="friendinfo_{$user->id}">
{if $user->introduction}
<p>
{$user->introduction|escape}
</p>
{/if}
<div class="pending">
<div>
<strong>
{str tag='whymakemeyourfriend' section='group'}
{user->reason}
</strong>
</div>
<div/>
<div>
<ul>
<li>
<a href="{$WWWROOT}user/denyrequest.php?id={$user->id}">
{str tag='denyrequest' section='group'}
</a>
</li>
{if $user->messages == 1}
<li>
<a href="{$WWWROOT}user/sendmessage.php?id={$user->id}">
{str tag='sendmessage' section='group'}
</a>
</li>
{/if}
</ul>
</div>
</td>
</tr>
</table>
</td>
{else}
<td>
<div class="fl">