Commit 71f2ced7 authored by Alan McNatty's avatar Alan McNatty

Debugging and had a go at getting the upgrade / install bits right

parent 84a5025d
......@@ -192,6 +192,14 @@ if (get_config('homepageinfo')) {
'help' => 'true'
);
}
if (get_config('allowmobileuploads')) {
$elements['mobileuploadtoken'] = array(
'type' => 'text',
'title' => get_string('mobileuploadtoken', 'account'),
'description' => get_string('mobileuploadtokendescription', 'account'),
'defaultvalue' => isset($prefs->mobileuploadtoken) ? $prefs->mobileuploadtoken : get_config('mobileuploadtoken')
);
}
$elements['submit'] = array(
'type' => 'submit',
'value' => get_string('save')
......
......@@ -437,6 +437,13 @@ $siteoptionform = array(
'defaultvalue' => get_config('registerterms'),
'disabled' => in_array('registerterms', $OVERRIDDEN),
),
'allowmobileuploads' => array(
'type' => 'checkbox',
'title' => get_string('allowmobileuploads', 'admin'),
'description' => get_string('allowmobileuploadsdescription', 'admin'),
'defaultvalue' => get_config('allowmobileuploads'),
'disabled' => in_array('allowmobileuploads', $OVERRIDDEN),
),
),
),
)
......@@ -466,7 +473,7 @@ function siteoptions_submit(Pieform $form, $values) {
'tagssideblockmaxtags', 'country', 'viewmicroheaders', 'userscanchooseviewthemes',
'remoteavatars', 'userscanhiderealnames', 'antispam', 'spamhaus', 'surbl', 'anonymouscomments',
'proxyaddress', 'proxyauthmodel', 'proxyauthcredentials',
'homepageinfo', 'showonlineuserssideblock', 'registerterms',
'homepageinfo', 'showonlineuserssideblock', 'registerterms', 'allowmobileuploads',
'creategroups', 'createpublicgroups', 'allowgroupcategories',
);
$oldlanguage = get_config('lang');
......
......@@ -41,7 +41,14 @@ $USER = new User();
$USER->find_by_mobileuploadtoken(param_variable('token'));
$data->owner = $USER->get('id'); // id of owner
$data->parent = ArtefactTypeFolder::get_folder_by_name(param_variable('foldername'), null, $USER->get('id')); // id of folder you're putting the file into
$folder = param_variable('foldername');
$artefact = ArtefactTypeFolder::get_folder_by_name($folder, null, $data->owner); // id of folder you're putting the file into
if ( ! $artefact ) {
header($protocol." 500 Upload folder '$folder' does not exit");
exit;
}
$data->parent = $artefact->id;
if ( $data->parent == 0 ) $data->parent = null;
$originalname = $_FILES['userfile']['name'];
......
......@@ -94,6 +94,7 @@ class User {
'ctime' => null,
'views' => array(),
'showhomeinfo' => 1,
'mobileuploadtoken'=> null,
);
$this->attributes = array();
......@@ -258,6 +259,43 @@ class User {
return $this;
}
/**
* Populates this object with the user record identified by a mobile IMEI
*
* @throws AuthUnknownUserException If the user cannot be found. Note that
* deleted users _can_ be found
*/
public function find_by_mobileuploadtoken($token) {
if (!is_string($token)) {
throw new InvalidArgumentException('Input parameters must be strings to create a User object from token');
}
$sql = 'SELECT
u.*,
' . db_format_tsfield('u.expiry', 'expiry') . ',
' . db_format_tsfield('u.lastlogin', 'lastlogin') . ',
' . db_format_tsfield('u.lastlastlogin', 'lastlastlogin') . ',
' . db_format_tsfield('u.lastaccess', 'lastaccess') . ',
' . db_format_tsfield('u.suspendedctime', 'suspendedctime') . ',
' . db_format_tsfield('u.ctime', 'ctime') . '
FROM
{usr} u
LEFT JOIN {usr_account_preference} p ON u.id = p.usr
WHERE p.field=\'mobileuploadtoken\' and p.value = ?
';
$user = get_record_sql($sql, array($token));
if (false == $user) {
throw new AuthUnknownUserException("User with mobile upload token \"$token\" is not known");
}
$this->populate($user);
return $this;
}
/**
* Set stuff that needs to be initialised once before a user record is created.
*/
......
......@@ -69,6 +69,9 @@ $string['hiderealnamedescription'] = 'Check this box if you have set a display n
$string['showhomeinfo'] = 'Show information about Mahara on the home page';
$string['mobileuploadtoken'] = 'Mobile upload token.';
$string['mobileuploadtokendescription'] = 'Enter a token here and on your phone to enable uploads (note: it will change automatically after each upload. <br/>If you have any problems - simply reset it here and on your phone.';
$string['prefssaved'] = 'Preferences saved';
$string['prefsnotsaved'] = 'Failed to save your Preferences!';
......
......@@ -237,6 +237,8 @@ $string['pathtoclam'] = 'Path to clam';
$string['pathtoclamdescription'] = 'The filesystem path to clamscan or clamdscan';
$string['registerterms'] = 'Registration agreement';
$string['registertermsdescription'] = "Force users to agree to the Terms and Conditions before registration. You should edit your site's Terms and Conditions page before enabling this option.";
$string['allowmobileuploads'] = 'Allow Mobile Uploads';
$string['allowmobileuploadsdescription'] = 'If enabled users will have the option of setting an authentication token - content uploaded with this token will be saved as artefacts.';
$string['remoteavatars'] = 'Display remote avatars';
$string['remoteavatarsdescription'] = 'If checked, the <a href="http://www.gravatar.com">Gravatar</a> service will be used for users\' default profile icons.';
$string['searchplugin'] = 'Search plugin';
......
......@@ -106,6 +106,7 @@
<FIELD NAME="authinstance" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="1" />
<FIELD NAME="ctime" TYPE="datetime" NOTNULL="false" />
<FIELD NAME="showhomeinfo" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="1" />
<FIELD NAME="mobileuploadtoken" TYPE="char" LENGTH="255" NOTNULL="true"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" />
......
......@@ -2193,5 +2193,11 @@ function xmldb_core_upgrade($oldversion=0) {
);
}
if ($oldversion < 2010100821) {
execute_sql('ALTER TABLE {usr} ADD COLUMN mobileuploadtoken CHARACTER VARYING(255)');
set_config('mobileuploadtoken', 1);
}
return $status;
}
......@@ -700,6 +700,7 @@ function core_install_firstcoredata_defaults() {
set_config('userscanchooseviewthemes', 1);
set_config('anonymouscomments', 1);
set_config('homepageinfo', 1);
set_config('mobileuploadtoken', '');
set_config('showonlineuserssideblock', 1);
set_config('footerlinks', serialize(array('privacystatement', 'about', 'contactus')));
set_config('searchusernames', 1);
......
......@@ -206,6 +206,7 @@ function expected_account_preferences() {
'hiderealname' => 0,
'multipleblogs' => 0,
'showhomeinfo' => 1,
'mobileuploadtoken' => '',
);
}
......
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