Commit 484b2abe authored by Brenda Wallace's avatar Brenda Wallace Committed by Nigel McNie
Browse files

"Register your Mahara" button in the admin section - initial work by Brenda.

parent a37dd7e8
......@@ -36,10 +36,12 @@ else {
define('TITLE', get_string('installation', 'admin'));
}
require(get_config('libroot') . 'upgrade.php');
require(get_config('libroot') . 'register.php');
$smarty = smarty();
$upgrades = check_upgrades();
$register = register_site();
if (isset($upgrades['core']) && !empty($upgrades['core']->install)) {
$smarty->assign('installing', true);
......@@ -50,6 +52,6 @@ if (isset($upgrades['core']) && !empty($upgrades['core']->install)) {
// normal admin page starts here
$smarty->assign('upgrades', $upgrades);
$smarty->display('admin/index.tpl');
$smarty->assign('register', $register);
?>
$smarty->display('admin/index.tpl');
......@@ -48,6 +48,7 @@ $string['performinginstallsandupgrades'] = 'Performing installs and upgrades...'
$string['runupgrade'] = 'Run upgrade';
$string['successfullyinstalled'] = 'Successfully installed Mahara!';
$string['thefollowingupgradesareready'] = 'The following upgrades are ready:';
$string['registerthismaharasite'] = 'Register this Mahara site';
$string['upgradeloading'] = 'Loading...';
$string['upgrades'] = 'Upgrades';
$string['upgradesuccess'] = 'Successfully upgraded';
......
<?php
/**
* @file Register a mahara site
*/
/**
* @defgroup Registration Registration
* Send site information to mahara.org
*
*/
defined('INTERNAL') || die();
require_once('pieforms/pieform.php');
/**
* Class to use for registration exceptions
* @ingroup Registration
*/
class RegistrationException extends SystemException {}
/**
* @return string that is the registation form
* @ingroup Registration
*/
function register_site() {
//TODO translate
$last = get_config('last_registration_success');
$info = 'Send the following data to mahara.org: <ul>';
$data = registration_data();
foreach($data as $key=>$val) {
$info .= '<li>'. htmlentities("$key = $val") .'</li>';
}
$info .= '</ul>';
if ($last) {
$info .= '<p>Last sent: '. format_date($last) .'</p>';
}
$form = array(
'name' => 'register',
'autofocus' => false,
'elements' => array(
'whatsent' => array('type' => 'fieldset', 'legend' => 'Register your mahara site', 'collapsible' => true, 'collapsed' => ($last ? true : false), //collapse if they've sent before
'elements' =>
array(
'info' => array('type' => 'markup', 'value'=> $info),
)
),
'register' => array('type' => 'submit', 'value' => 'Register'),
)
);
return pieform($form);
}
/**
* Runs when registration form is submitted
*/
function register_submit() {
$data = registration_data();
$request = array(
CURLOPT_URL => 'http://mahara.org.gargi.wgtn.cat-it.co.nz/mahara-registration.php',
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => $data,
);
$result = http_request($request);
GLOBAL $SESSION;
//TODO Translate needed
if ($result->data != '1') {
$SESSION->add_error_msg('Registation failed' . print_r($result, true));
}
else {
set_config('last_registration_success', strtotime('now'));
$SESSION->add_ok_msg('Registation successful');
}
redirect('/admin');
}
function registration_data() {
foreach(array('dbtype', 'sitename', 'lang', 'wwwroot', 'theme', 'release') as $key) {
$data_to_send[$key] = get_config($key);
}
foreach(array('usr', 'view', 'artefact', 'group', 'block_instance', 'institution') as $key) {
$data_to_send[$key . '_count'] = count_records($key);
}
return $data_to_send;
}
......@@ -26,7 +26,15 @@
{/foreach}
</table>
</div>
{/if}<ul>
{/if}
{if $register}
<div id="registersite">
<div class="register">
{$register}
</div>
</div>
{/if}
<ul>
<li><h3>{str tag=configsite section=admin}</h3>
<ul>
<li><strong><a href="{$WWWROOT}admin/site/options.php">{str tag=siteoptions section=admin}</a></strong> - {str tag=siteoptionsdescription section=admin}</li>
......@@ -65,6 +73,7 @@
</ul>
</li>
</ul></div>
{$siteregisterform}
{include file="columnfullend.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