Commit eefbc041 authored by Penny Leach's avatar Penny Leach
Browse files
parents 0f4792d2 50cde32d
......@@ -37,7 +37,7 @@ if ($install) {
if (!get_config('installed')) {
try {
// Install the default institution
// @todo Transaction!!!
db_begin();
$institution = new StdClass;
$institution->name = 'mahara';
$institution->displayname = 'No Institution';
......@@ -54,9 +54,13 @@ if ($install) {
$user->firstname = 'Admin';
$user->lastname = 'User';
$user->email = 'admin@example.org';
insert_record('usr', $user);
$user->id = insert_record('usr', $user, 'id', true);
set_profile_field($user->id, 'email', $user->email);
set_profile_field($user->id, 'firstname', $user->firstname);
set_profile_field($user->id, 'lastname', $user->lastname);
set_config('installed', true);
db_commit();
}
catch (SQLException $e) {
echo json_encode(array(
......
......@@ -328,7 +328,30 @@ class ArtefactTypeCachedProfileField extends ArtefactTypeProfileField {
class ArtefactTypeFirstname extends ArtefactTypeCachedProfileField {}
class ArtefactTypeLastname extends ArtefactTypeCachedProfileField {}
class ArtefactTypePreferredname extends ArtefactTypeCachedProfileField {}
class ArtefactTypeEmail extends ArtefactTypeProfileField {}
class ArtefactTypeEmail extends ArtefactTypeProfileField {
public function commit() {
$this->commit_basic();
$email_record = get_record('artefact_internal_profile_email', 'owner', $this->owner, 'email', $this->title);
// we've created a new artefact that doesn't have a profile email thingy.
// we assume that it's a validated email, and set it to primary (if there isn't already one)
if(!$email_record) {
$principal = get_record('artefact_internal_profile_email', 'owner', $this->owner, 'principal', 1);
insert_record(
'artefact_internal_profile_email',
(object) array(
'owner' => $this->owner,
'email' => $this->title,
'verified' => 1,
'principal' => ( $principal ? 0 : 1 ),
'artefact' => $this->id,
)
);
}
}
}
class ArtefactTypeStudentid extends ArtefactTypeProfileField {}
class ArtefactTypeIntroduction extends ArtefactTypeProfileField {}
......
......@@ -98,10 +98,12 @@ $elements['submit'] = array(
);
$profileform = form(array(
'name' => 'profileform',
'ajaxpost' => true,
'method' => 'post',
'elements' => $elements,
'name' => 'profileform',
'plugintype' => 'artefact',
'pluginname' => 'internal',
'ajaxpost' => true,
'method' => 'post',
'elements' => $elements,
));
function profileform_validate(Form $form, $values) {
......
......@@ -309,9 +309,11 @@ function auth_check_password_change() {
require_once('form.php');
$form = array(
'name' => 'change_password',
'method' => 'post',
'elements' => array(
'name' => 'change_password',
'method' => 'post',
'plugintype' => 'auth',
'pluginname' => 'internal',
'elements' => array(
'passwords' => array(
'type' => 'fieldset',
'legend' => get_string('newpassword'),
......@@ -523,10 +525,12 @@ function auth_get_login_form() {
}
$form = array(
'name' => 'login',
'method' => 'post',
'action' => $action,
'elements' => $elements,
'name' => 'login',
'method' => 'post',
'action' => $action,
'plugintype' => 'auth',
'pluginname' => 'internal',
'elements' => $elements,
'iscancellable' => false
);
......
......@@ -35,10 +35,12 @@ require('init.php');
if (!$SESSION->is_logged_in()) {
require_once('form.php');
$loginform = get_login_form_js(form(array(
'name' => 'login',
'renderer' => 'div',
'submit' => false,
'elements' => array(
'name' => 'login',
'renderer' => 'div',
'submit' => false,
'plugintype' => 'auth',
'pluginname' => 'internal',
'elements' => array(
'login' => array(
'type' => 'fieldset',
'legend' => get_string('login'),
......
......@@ -5,6 +5,7 @@ function TableRenderer(target, source, columns, options) {
this.columns = columns;
this.paginate = true;
this.statevars = ['offset','limit'];
this.emptycontent = false; // Something to display when no results are found
addLoadEvent(function() {
self.table = target;
......@@ -36,6 +37,10 @@ function TableRenderer(target, source, columns, options) {
appendChildNodes(ref, tr);
});
}
if (self.emptycontent) {
$(self.table).parentNode.insertBefore(DIV(null,self.emptycontent),$(self.table));
}
});
this.renderdata = function(data) {
......@@ -89,6 +94,16 @@ function TableRenderer(target, source, columns, options) {
self.offset = data.offset;
self.count = data.count;
if (self.emptycontent) {
if (self.count > 0) {
hideElement($(self.table).previousSibling)
showElement(self.table);
}
else {
hideElement(self.table);
showElement($(self.table).previousSibling);
}
}
self.renderdata(data);
},
function (error) {
......
......@@ -27,8 +27,16 @@
defined('INTERNAL') || die();
// General form strings
$string['add'] = 'Add';
$string['cancel'] = 'Cancel';
$string['delete'] = 'Delete';
$string['edit'] = 'Edit';
$string['save'] = 'Save';
$string['submit'] = 'Submit';
$string['update'] = 'Update';
$string['no'] = 'no';
$string['yes'] = 'yes';
$string['nextpage'] = 'Next page';
$string['prevpage'] = 'Previous page';
......@@ -124,12 +132,6 @@ $string['weeks'] = 'weeks';
$string['months'] = 'months';
$string['years'] = 'years';
// Boolean site option
$string['no'] = 'no';
$string['yes'] = 'yes';
$string['add'] = 'Add';
$string['delete'] = 'Delete';
$string['edit'] = 'Edit';
// Site content pages
$string['sitecontentnotfound'] = '%s text not available';
......@@ -190,8 +192,6 @@ $string['changepassword'] = 'Change password';
$string['activity'] = 'Recent activity';
$string['emailname'] = 'Mahara System'; // robot!
$string['save'] = 'Save';
$string['update'] = 'Update';
$string['config'] = 'Config';
......@@ -210,4 +210,11 @@ $string['heightshort'] = 'h';
$string['nohelpfound'] = 'There was no help found for this item';
// Search
$string['search'] = 'Search';
$string['query'] = 'Query';
$string['querydescription'] = 'The words to be searched for';
$string['results'] = 'Results';
$string['noresultsfound'] = 'No results found';
$string['resultsfor'] = 'Results matching "%s"';
?>
......@@ -956,7 +956,7 @@ function main_nav() {
),
array(
'name' => 'activityprefs',
'link' => $wwwroot . 'account/activity/preferences',
'link' => $wwwroot . 'account/activity/preferences/',
'section' => 'mahara',
),
array(
......
......@@ -28,19 +28,21 @@ define('INTERNAL', 1);
require('init.php');
require_once('form.php');
//@todo: Show 'no results found' for an empty query.
$query = param_variable('query');
/* If there is no query posted, the 'results' section of the page will
stay invisible until a query is submitted. */
$query = @param_variable('query','');
//@todo: Add form with search box
$searchform = form(array(
'name' => 'search',
'method' => 'post',
'ajaxpost' => true,
'ajaxsuccessfunction' => 'updatesearch()',
'ajaxsuccessfunction' => 'newsearch()',
'action' => '',
'elements' => array(
'query' => array(
'type' => 'text',
'id' => 'query',
'title' => get_string('query'),
'description' => get_string('querydescription'),
'defaultvalue' => $query,
......@@ -53,10 +55,11 @@ $searchform = form(array(
));
function search_submit($values) {
json_reply(false,get_string('querysubmitted'));
json_reply(false,'');
}
$equery = json_encode($query);
//@todo: Show 'no results found' for an empty query.
$noresults = get_string('noresultsfound');
$javascript = <<<JAVASCRIPT
var results = new TableRenderer(
......@@ -68,20 +71,29 @@ var results = new TableRenderer(
]
);
function updatesearch() {
function newsearch() {
showElement($('results'));
results.query = $('query').value;
results.offset = 0;
results.doupdate();
}
results.query = {$equery};
results.statevars.push('query');
results.updateOnLoad();
results.emptycontent = '{$noresults}';
JAVASCRIPT;
if (!empty($query)) {
$equery = json_encode($query);
$javascript .= 'results.query = ' . $equery . ";\n";
$javascript .= "results.updateOnLoad();\n";
}
$smarty = smarty(array('tablerenderer'));
$smarty->assign('INLINEJAVASCRIPT', $javascript);
$smarty->assign('SEARCHFORM', $searchform);
$smarty->assign('QUERYPOSTED', !empty($query));
$smarty->display('results.tpl');
?>
......@@ -3,19 +3,27 @@
{include file="adminmenu.tpl"}
<div class="content">
<h2>{str tag="search"}</h2>
{$SEARCHFORM}
<h2>{str tag="results"}</h2>
<table id="searchresults">
<thead>
<tr>
<th>{str section=artefact.internal tag="name"}</th>
<th>{str section=artefact.internal tag="institution"}</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<div class="searchform">
<h2>{str tag="search"}</h2>
{$SEARCHFORM}
</div>
{if ($QUERYPOSTED)}
<div id="results">
{else}
<div id="results" style="display:none;">
{/if}
<h2>{str tag="results"}</h2>
<table id="searchresults">
<thead>
<tr>
<th>{str section=artefact.internal tag="name"}</th>
<th>{str section=artefact.internal tag="institution"}</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
{include file="footer.tpl"}
......@@ -4,6 +4,11 @@
<div class="content">
<h3>{$NAME}</h3>
<table><tbody>
{foreach from=$PROFILE item=item}
<tr><td>{str section=artefact.internal tag=$item.name}</td><td>{$item.value}</td></tr>
{/foreach}
</tbody></table>
</div>
{include file="footer.tpl"}
......@@ -29,15 +29,23 @@ require('init.php');
$userid = param_integer('id','');
$profile = array();
if (!$user = @get_record('usr', 'id', $userid)) {
$name = get_string('usernotfound');
}
else {
$name = display_name($user);
safe_require('artefact', 'internal', 'lib.php');
$publicfields = ArtefactTypeProfile::get_public_fields();
foreach ($publicfields as $pf => $type) {
$profile[$pf]['name'] = $pf;
$profile[$pf]['value'] = '[]';
}
}
$smarty = smarty();
$smarty->assign('NAME',$name);
$smarty->assign('PROFILE',$profile);
$smarty->display('viewuser.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