Commit 73689206 authored by Alan McNatty's avatar Alan McNatty
Browse files

Added the refresh mobileuploadtoken feature/functionality and removed the...

Added the refresh mobileuploadtoken feature/functionality and removed the erroneous mobileuploadtoken from usr object
parent d0548af9
......@@ -38,17 +38,30 @@ if ($protocol != 'HTTP/1.1') {
$data = new StdClass;
$USER = new User();
$USER->find_by_mobileuploadtoken(param_variable('token'));
try {
$USER->find_by_mobileuploadtoken(param_variable('token'));
}
catch (AuthUnknownUserException $e) {
header($protocol.' 500 Invalid user token');
exit;
}
$data->owner = $USER->get('id'); // id of owner
$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 ) {
if ( $folder == 'Home' ) {
$data->parent = null;
} else {
$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;
$data->parent = $artefact->id;
}
if ( $data->parent == 0 ) $data->parent = null;
$originalname = $_FILES['userfile']['name'];
......@@ -68,5 +81,6 @@ catch (UploadException $e) {
exit;
}
echo 'foo';
// Here we need to create a new hash - update our own store of it and return it too the handset
echo $USER->refresh_mobileuploadtoken();
......@@ -93,8 +93,7 @@ class User {
'sesskey' => '',
'ctime' => null,
'views' => array(),
'showhomeinfo' => 1,
'mobileuploadtoken'=> null,
'showhomeinfo' => 1
);
$this->attributes = array();
......@@ -260,10 +259,9 @@ class User {
}
/**
* Populates this object with the user record identified by a mobile IMEI
* Populates this object with the user record identified by a mobile 'token'
*
* @throws AuthUnknownUserException If the user cannot be found. Note that
* deleted users _can_ be found
* @throws AuthUnknownUserException If the user cannot be found.
*/
public function find_by_mobileuploadtoken($token) {
......@@ -295,6 +293,17 @@ class User {
return $this;
}
/**
* Refreshes a users mobile 'token' and returns it
*
*/
public function refresh_mobileuploadtoken() {
$new_token = md5( uniqid() );
$this->set_account_preference('mobileuploadtoken', $new_token);
$this->set('lastaccess', time());
$this->commit();
return $new_token;
}
/**
* Set stuff that needs to be initialised once before a user record is created.
......
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