Commit 718ad8a1 authored by Nigel McNie's avatar Nigel McNie Committed by Nigel McNie
Browse files
parents 995371a7 df0ea467
......@@ -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) {
......
......@@ -36,6 +36,8 @@ $key = param_variable('key');
$row = get_record('artefact_internal_profile_email', 'email', $email, 'key', $key, null,null,'owner,artefact,email,verified,' . db_format_tsfield('expiry'));
$smarty = smarty();
if ($row && $row->expiry > time()) {
if ($row->artefact) {
$artefact = new ArtefactTypeEmail($row->artefact);
......@@ -63,11 +65,12 @@ if ($row && $row->expiry > time()) {
);
set_cookie('validated_email', $row->email);
$smarty->assign('message', get_string('emailactiviationsucceeded', 'artefact.internal'));
}
else {
// BAD(tm)
$smarty->assign('message', get_string('emailactiviationfailed', 'artefact.internal'));
}
// @todo how about some page content
$smarty->display('artefact:internal:profile/validate.tpl');
?>
{include file="header.tpl"}
{include file="adminmenu.tpl"}
<div class="content">
<h2>{str section="artefact.internal" tag="emailactivation"}</h2>
<p>
{$message|escape}
</p>
</div>
{include file="footer.tpl"}
......@@ -25,6 +25,7 @@
*/
defined('INTERNAL') || die();
define('ARTEFACT_FORMAT_LISTITEM', 1);
/**
* Exception - artefact not found
......
......@@ -71,7 +71,7 @@ var ctxHelp = new Array();
var ctxHelp_selected;
var container;
function contextualHelp(formName, helpName, pluginType, pluginName, language) {
function contextualHelp(formName, helpName, pluginType, pluginName, page) {
var tooltip = $('tooltip');
log(tooltip);
log(ctxHelp_selected);
......@@ -97,12 +97,26 @@ function contextualHelp(formName, helpName, pluginType, pluginName, language) {
log('no help for this key yet, getting...');
ctxHelp[key] = new Object();
processingStart();
var d = loadJSONDoc('../lang/' + language + '/help/' + formName + '.' + helpName + '.html');
var url = '../json/help.php?plugintype=' + pluginType + '&pluginname=' + pluginName;
if (page) {
url += '&page=' + page;
}
else {
url += '&form=' + formName + '&element=' + helpName;
}
var d = loadJSONDoc(url);
d.addCallbacks(
function (data) {
ctxHelp[key].content = data;
container.innerHTML = ctxHelp[key].content;
processingStop();
if (data.error) {
ctxHelp[key].content = data.message;
container.innerHTML = ctxHelp[key].content;
processingStop();
}
else {
ctxHelp[key].content = data.content;
container.innerHTML = ctxHelp[key].content;
processingStop();
}
},
function () {
ctxHelp[key].content = '<p>Sorry, no help for this element could be found</p>';
......
......@@ -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) {
......
<?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);
require(dirname(dirname(__FILE__)) . '/init.php');
json_headers();
$plugintype = param_alpha('plugintype');
$pluginname = param_alpha('pluginname');
$page = param_alpha('page', null);
$form = param_alpha('form', null);
$element = param_alpha('element', null);
$location = get_config('docroot') ;
$file = 'help/';
if ($plugintype != 'core') {
$location .= $plugintype . '/' . $pluginname . '/lang/';
}
else {
$location .= 'lang/';
}
if ($page) {
$file .= $page . '.html';
}
else if (!empty($form) && !empty($element)) {
$file .= 'forms/' . $form . '.' . $element . '.html';
}
else if (!empty($form) && empty($element)) {
$file .= 'forms/' . $form . '.html';
}
else {
json_reply(true, get_string('nohelpfound'));
}
// now we have to try and locate the help file
$lang = current_language();
if ($lang == 'en.utf8') {
$trieden = true;
}
else {
$trieden = false;
}
// try the current language
$langfile = $location . $lang . '/' . $file;
if (is_readable($langfile)) {
$data = file_get_contents($langfile);
}
// if it's not found, try the parent language if there is one...
if (empty($data) && empty($trieden)) {
$langfile = $location . $lang . '/langconfig.php';
if ($parentlang = get_string_from_file('parentlanguage', $langfile)) {
if ($parentlang == 'en.utf8') {
$trieden = true;
}
$langfile = $location . $parentlang . '/' . $file;
if (is_readable($langfile)) {
$data = file_get_contents($langfile);
}
}
}
// if it's STILL not found, and we haven't already tried english ...
if (empty($data) && empty($trieden)) {
$langfile = $location . 'en.utf8/' . $file;
if (is_readable($langfile)) {
$data = file_get_contents($langfile);
}
}
if (empty($data)) {
json_reply(true, get_string('nohelpfound'));
}
$json = array('error' => false, 'content' => $data);
echo json_encode($json);
exit;
?>
......@@ -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';
......@@ -125,12 +133,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';
......@@ -191,8 +193,6 @@ $string['changepassword'] = 'Change password';
$string['activity'] = 'Recent activity';
$string['emailname'] = 'Mahara System'; // robot!
$string['save'] = 'Save';
$string['update'] = 'Update';
$string['config'] = 'Config';
......@@ -209,4 +209,13 @@ $string['height'] = 'Height';
$string['widthshort'] = 'w';
$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"';
?>
......@@ -104,8 +104,9 @@ class FormRendererMultiColumnTable {
}
// Contextual help
if (!empty($rawelement['help'])) {
$result .= ' <span class="help"><a href="#" title="'
. hsc($rawelement['help']) . '">?</a></span>';
$result .= get_help_icon($form->get_property('plugintype'),
$form->get_property('pluginname'),
$form->get_name(), $rawelement['name']);
}
$result .= "</td>\n\t";
}
......
......@@ -77,10 +77,10 @@ function form_renderer_table(Form $form, $builtelement, $rawelement) {
// Contextual help
if (!empty($rawelement['help'])) {
$result .= ' <span class="help"><a href="" onclick="contextualHelp(\'' . $form->get_name() . "', '"
. $rawelement['name'] . "', '" . $form->get_property('plugintype') . "', '"
. $form->get_property('pluginname') . "', '" . $form->get_property('language') . "'); return false;\">"
. '?</a></span>';
$result .= get_help_icon($form->get_property('plugintype'),
$form->get_property('pluginname'),
$form->get_name(), $rawelement['name']);
}
$result .= "</td>\n\t</tr>\n";
......
......@@ -971,4 +971,15 @@ function getoptions_country() {
);
}
/**
*
*/
function get_help_icon($plugintype, $pluginname, $form, $element, $page='') {
return ' <span class="help"><a href="" onclick="contextualHelp(\'' . $form . "', '"
. $element . "', '" . $plugintype . "', '"
. $pluginname . "', '" . $page . "'); return false;\">"
. '?</a></span>';
}
?>
......@@ -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