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') { ...@@ -38,17 +38,30 @@ if ($protocol != 'HTTP/1.1') {
$data = new StdClass; $data = new StdClass;
$USER = new User(); $USER = new User();
$USER->find_by_mobileuploadtoken(param_variable('token'));
$data->owner = $USER->get('id'); // id of owner
$folder = param_variable('foldername'); try {
$artefact = ArtefactTypeFolder::get_folder_by_name($folder, null, $data->owner); // id of folder you're putting the file into $USER->find_by_mobileuploadtoken(param_variable('token'));
if ( ! $artefact ) { }
header($protocol." 500 Upload folder '$folder' does not exit"); catch (AuthUnknownUserException $e) {
header($protocol.' 500 Invalid user token');
exit; exit;
} }
$data->parent = $artefact->id; $data->owner = $USER->get('id'); // id of owner
$folder = param_variable('foldername');
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;
}
if ( $data->parent == 0 ) $data->parent = null; if ( $data->parent == 0 ) $data->parent = null;
$originalname = $_FILES['userfile']['name']; $originalname = $_FILES['userfile']['name'];
...@@ -68,5 +81,6 @@ catch (UploadException $e) { ...@@ -68,5 +81,6 @@ catch (UploadException $e) {
exit; 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 { ...@@ -93,8 +93,7 @@ class User {
'sesskey' => '', 'sesskey' => '',
'ctime' => null, 'ctime' => null,
'views' => array(), 'views' => array(),
'showhomeinfo' => 1, 'showhomeinfo' => 1
'mobileuploadtoken'=> null,
); );
$this->attributes = array(); $this->attributes = array();
...@@ -260,10 +259,9 @@ class User { ...@@ -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 * @throws AuthUnknownUserException If the user cannot be found.
* deleted users _can_ be found
*/ */
public function find_by_mobileuploadtoken($token) { public function find_by_mobileuploadtoken($token) {
...@@ -295,6 +293,17 @@ class User { ...@@ -295,6 +293,17 @@ class User {
return $this; 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. * 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