Changeset 274
- Timestamp:
- 02/20/12 16:27:19 (13 years ago)
- Location:
- Dev/branches/rest-dojo-ui
- Files:
-
- 6 added
- 2 deleted
- 25 edited
- 4 copied
Legend:
- Unmodified
- Added
- Removed
-
Dev/branches/rest-dojo-ui/client/index.html
r263 r274 13 13 <body class="claro"> 14 14 <div id="header" class="mainHeader"> 15 <div id="title" class="mainTitle">Research Facilitator Tool</div>16 15 <div id="menu" class="mainMenu" data-dojo-type="dijit.MenuBar"> 17 <span data-dojo-type="rft.ui.MenuBarLink" data-dojo-props="pageId:'sessions'">Sessions</span> 18 <span data-dojo-type="rft.ui.MenuBarLink" data-dojo-props="pageId:'surveys'">Surveys</span> 19 <span data-dojo-type="rft.ui.MenuBarLink" data-dojo-props="pageId:'results'">Results</span> 20 <span data-dojo-type="rft.ui.MenuBarLink" data-dojo-props="pageId:'test1'">Test 1</span> 21 <span data-dojo-type="rft.ui.MenuBarLink" data-dojo-props="pageId:'test2'">Test 2</span> 22 <span data-dojo-type="rft.ui.MenuBarLink" data-dojo-props="pageId:'test3'">Test 3</span> 16 <div data-dojo-type="dijit.MenuBarItem" data-dojo-props="disabled: true">Research Facilitator Tool</div> 17 <div data-dojo-type="rft.ui.MenuBarLink" data-dojo-props="pageId:'sessions'">Sessions</div> 18 <div data-dojo-type="dijit.PopupMenuBarItem"> 19 <span>Content</span> 20 <div data-dojo-type="dijit.DropDownMenu"> 21 <div data-dojo-type="rft.ui.MenuLink" data-dojo-props="pageId:'surveys'">Surveys</div> 22 <div data-dojo-type="rft.ui.MenuLink" data-dojo-props="pageId:'questions'">Questions</div> 23 <div data-dojo-type="rft.ui.MenuLink" data-dojo-props="pageId:'applications'">Applications</div> 24 <div data-dojo-type="rft.ui.MenuLink" data-dojo-props="pageId:'dashboards'">Dashboards</div> 25 </div> 26 </div> 27 <div data-dojo-type="rft.ui.MenuBarLink" data-dojo-props="pageId:'results'">Results</div> 28 <div data-dojo-type="dijit.MenuBarItem" id="loginMenu" style="float:right;">Login/Register</div> 23 29 </div> 24 <div id="userinfo" class="mainUserInfo">Login</div>25 30 </div> 26 31 27 <div id="content" data-dojo-type="dijit.layout.ContentPane" >32 <div id="content" data-dojo-type="dijit.layout.ContentPane" style="width: 100%; height: 100%;"> 28 33 </div> 29 34 -
Dev/branches/rest-dojo-ui/client/rft/api.js
r256 r274 10 10 rawBody: json.toJson(args) 11 11 }); 12 },13 createObject: function(type, args) {14 var d = new Deferred();15 this.post("createObject",16 {17 type: type,18 values: args19 })20 .then(function(data) {21 d.resolve(data.uid);22 },function(){23 d.reject();24 });25 return d.promise;26 },27 getObject: function(type, uid) {28 var d = new Deferred();29 this.post("getObject",30 {31 type: type,32 uid: uid33 })34 .then(function(data) {35 d.resolve(data.object);36 },function(){37 d.reject();38 });39 return d.promise;40 },41 getObjects: function(type, predicates) {42 var d = new Deferred();43 this.post("getObjects",44 {45 type: type,46 predicates: predicates47 })48 .then(function(data) {49 d.resolve(data.objects);50 },function(){51 d.reject();52 });53 return d.promise;54 },55 deleteObject: function(type, uid) {56 var d = new Deferred();57 d.reject();58 return d.promise;59 12 } 60 } 13 }; 61 14 }); -
Dev/branches/rest-dojo-ui/client/rft/auth.js
r260 r274 20 20 post("/login", 21 21 { 22 username:username,22 email:username, 23 23 password:password 24 24 }) … … 49 49 post("/register", 50 50 { 51 username:username,51 email:username, 52 52 password:password 53 53 }) -
Dev/branches/rest-dojo-ui/client/rft/content.js
r264 r274 92 92 return dfd.promise; 93 93 } 94 currentPage = null; 94 95 } 95 96 … … 99 100 100 101 // load html 101 var pageUrl = ' pages'+hri.path()+'.html';102 var pageUrl = 'rft/pages'+hri.path()+'.html'; 102 103 xhr.get({ 103 104 url: pageUrl, … … 107 108 // initialize page or create error message 108 109 .then(function(html){ 109 currentPage = new _Page({ 110 templateString: html, 111 pageQuery: hri.args() 112 }); 113 contentPane.set('content',currentPage); 110 contentPane.set('content',html); 111 var rootNode = contentPane.containerNode.firstChild; 112 currentPage = dijit.byNode(rootNode); 113 if ( !currentPage ) { 114 currentPage = new _Page({},rootNode); 115 } 114 116 dfd.resolve(); 115 117 },function(){ 116 currentPage = new _Page({ 117 templateString: "<div>Page "+hri.path()+" not found.</div>" 118 }); 119 contentPane.set('content',currentPage); 118 contentPane.set('content',"<div>Page "+hri.path()+" not found.</div>"); 120 119 dfd.reject(); 121 120 }); -
Dev/branches/rest-dojo-ui/client/rft/css/main.css
r256 r274 5 5 } 6 6 7 .mainTitle {8 display: block;9 float: left;10 border-right: 1px solid;11 padding-right: 5px;12 margin-right: 5px;13 }14 15 7 .mainMenu { 16 display: block; 17 float: left; 18 } 19 20 .mainUserInfo { 21 display: block; 22 float: right; 23 border-left: 1px solid; 24 padding-left: 5px; 25 margin-left: 5px; 8 width: 100%; 26 9 } 27 10 -
Dev/branches/rest-dojo-ui/client/rft/run.js
r263 r274 1 1 require([ 2 2 'dijit/form/Form', 3 'dijit/form/TextBox', 4 'dijit/form/Button', 5 'dijit/form/Textarea', 3 6 'dojo/store/JsonRest', 4 7 'dojo/data/ObjectStore', … … 6 9 'dijit/layout/ContentPane', 7 10 'dijit/layout/TabContainer', 11 'dijit/layout/AccordionContainer', 8 12 'dijit/MenuBar', 9 13 'dijit/MenuBarItem', 14 'dijit/PopupMenuBarItem', 15 'dijit/DropDownMenu', 10 16 'rft/ui/MenuBarLink', 17 'rft/ui/MenuLink', 18 'rft/ui/QuestionWidget', 19 'rft/pages/questions' // could this be done dynamically? 11 20 ]); 12 21 13 22 require(['dojo/_base/window','dojo/parser', 'rft/ui/LoginDialog', 14 23 'dojo/dom', 'dojo/_base/connect', 'rft/auth', 'rft/content', 15 'dojo/domReady!' ,],24 'dojo/domReady!' ], 16 25 function(win,parser,LoginDialog,dom,connect,auth,content) { 17 26 parser.parse(); … … 27 36 }); 28 37 29 connect.connect(dom.byId(' userinfo'),'click',function(){38 connect.connect(dom.byId('loginMenu'),'click',function(){ 30 39 login.show(); 31 40 }); 41 32 42 }); -
Dev/branches/rest-dojo-ui/client/rft/ui/LoginDialog.html
r263 r274 9 9 <form data-dojo-type="dijit.form.Form" data-dojo-attach-point="loginForm"> 10 10 <fieldset> 11 <label for=" username" class="loginLabel">Email</label>12 <input data-dojo-type="dijit.form.TextBox" name=" username" type="text" class="loginInput" />11 <label for="email" class="loginLabel">Email</label> 12 <input data-dojo-type="dijit.form.TextBox" name="email" type="text" class="loginInput" /> 13 13 <label for="password" class="loginLabel">Password</label> 14 14 <input data-dojo-type="dijit.form.TextBox" name="password" type="password" class="loginInput" /> 15 15 </fieldset> 16 <button type="submit" data-dojo-type="dijit.form.Button" data-dojo-attach-event="onClick:onLogin">Login</button> 17 <button type="button" data-dojo-type="dijit.form.Button" data-dojo-attach-event="onClick:onCancel">Cancel</button> 16 <div style="float: right;"> 17 <button type="button" data-dojo-type="dijit.form.Button" data-dojo-attach-event="onClick:onRegister">Register</button> 18 <button type="submit" data-dojo-type="dijit.form.Button" data-dojo-attach-event="onClick:onLogin">Login</button> 19 </div> 18 20 </form> 19 <div data-dojo-attach-point="loginErrors" ></div>21 <div data-dojo-attach-point="loginErrors" style="clear: both; color: red;"></div> 20 22 </div> 21 23 </div> -
Dev/branches/rest-dojo-ui/client/rft/ui/LoginDialog.js
r263 r274 6 6 templateString: template, 7 7 widgetsInTemplate: true, 8 title: "Login ",8 title: "Login/Register", 9 9 baseClass: "rftLoginDialog", 10 10 startup: function() { … … 20 20 this.loginErrors.innerHTML = ''; 21 21 var data = this.loginForm.get('value'); 22 auth.login(data. username,data.password)22 auth.login(data.email,data.password) 23 23 .then(lang.hitch(this,function() { 24 24 this.hide(); … … 29 29 event.stop(evt); 30 30 return false; 31 }, 32 onRegister: function() { 33 this.loginErrors.innerHTML = ''; 34 var data = this.loginForm.get('value'); 35 auth.register(data.email,data.password) 36 .then(lang.hitch(this,function() { 37 this.hide(); 38 content.initial(); 39 }),lang.hitch(this,function() { 40 this.loginErrors.innerHTML = 'Register failed.'; 41 })); 31 42 } 32 43 }); -
Dev/branches/rest-dojo-ui/client/rft/ui/MenuLink.js
r270 r274 1 define(['dojo/_base/declare','dijit/Menu BarItem','../content'],2 function(declare,Menu BarItem,content){3 return declare('rft.ui.Menu BarLink',[MenuBarItem],{1 define(['dojo/_base/declare','dijit/MenuItem','../content'], 2 function(declare,MenuItem,content){ 3 return declare('rft.ui.MenuLink',[MenuItem],{ 4 4 options:{ 5 5 pageId: null -
Dev/branches/rest-dojo-ui/client/rft/ui/_Page.js
r263 r274 1 define(['dojo/_base/declare','dojo/_base/lang','dojo/_base/array','dojo/parser','dojo/query','dojo/_base/Deferred', 2 'dijit/_WidgetBase','dijit/_TemplatedMixin','dijit/_WidgetsInTemplateMixin','rft/ui/_PageController'], 3 function(declare,lang,array,parser,query,Deferred,_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,_PageController){ 4 return declare('rft.ui._Page',[_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,_PageController],{ 5 _controllerLoaded: false, 6 _hasStarted: false, 7 _triggeredOnVisit: false, 8 pageController: null, /* class derived from rft.ui._PageController, mixed in at creation */ 9 buildRendering: function() { 1 define(['dojo/_base/declare','dojo/_base/lang','dojo/_base/array','dojo/parser','dojo/query','dojo/dom-attr','dojo/_base/connect','dijit','dijit/_WidgetBase','dijit/_Container','dijit/_Contained'], 2 function(declare,lang,array,parser,query,attr,connect,dijit,_WidgetBase,_Container,_Contained){ 3 return declare('rft.ui._Page',[_WidgetBase],{ 4 startup: function() { 10 5 this.inherited(arguments); 11 var dfd = new Deferred(); 12 var mixinType = this.domNode.getAttribute("data-rft-mixin"); 13 if ( mixinType ) { 14 require([mixinType],lang.hitch(this,function(SomePageController){ 15 declare.safeMixin(this,new SomePageController()); 16 dfd.resolve(); 17 })); 18 } else { 19 dfd.resolve(); 20 } 21 dfd.then(lang.hitch(this,function(){ 22 var methods = query('> script[type^="rft/method"]',this.domNode).orphan(); 23 array.forEach(methods,lang.hitch(this,function(s){ 24 var method = s.getAttribute("data-rft-method"); 25 var func = parser._functionFromScript(s); 26 this[method] = func; 27 })); 28 this._controllerLoaded = true; 29 this._triggerOnVisit(); 6 this._attachPointsAndEvents(); 7 this.onVisit(); 8 }, 9 _attachPointsAndEvents: function() { 10 query('*[data-rft-attach-point]'/*, this.domNode*/).forEach(lang.hitch(this,function(node){ 11 var point = attr.get(node,'data-rft-attach-point'); 12 var widget = dijit.byId(attr.get(node,'id')); 13 this[point] = widget || node; 14 })); 15 query('*[data-rft-attach-event]'/*, this.domNode*/).forEach(lang.hitch(this,function(node){ 16 var event = attr.get(node,'data-rft-attach-event').split(':'); 17 var eventName = event[0]; 18 var eventHandler = event[1]; 19 var widget = dijit.byId(attr.get(node,'id')); 20 if ( widget ) { 21 this.connect(widget,eventName,lang.hitch(this,eventHandler)); 22 } else { 23 this.connect(node,eventName,lang.hitch(this,eventHandler)); 24 } 25 })); 26 query('> script[type^="rft/method"]',this.domNode) 27 .orphan().forEach(lang.hitch(this,function(s){ 28 var methodName = s.getAttribute("data-rft-method"); 29 var func = parser._functionFromScript(s); 30 this[methodName] = func; 30 31 })); 31 32 }, 32 startup: function() { 33 this.inherited(arguments); 34 this._hasStarted = true; 35 this._triggerOnVisit(); 36 }, 37 _triggerOnVisit: function() { 38 if ( this._controllerLoaded && this._hasStarted && !this._triggeredOnVisit ) { 39 this._triggeredOnVisit = false; 40 this.onVisit(); 41 } 42 } 33 /** Event fired after startup of all widgets is complete */ 34 onVisit: function(){}, 35 /** Event fired before leaving the page. Return false to prevent */ 36 onLeave: function(){} 43 37 }); 44 38 }); -
Dev/branches/rest-dojo-ui/log.txt
r257 r274 1 * Replaced jQuery with Dojo for more extensive widgets. 2 * Removed some unused JS libraries (d3,RGraph). 3 * Changed API to use REST conventions. It is able to login and access 4 database objects. I used the tonic library for that. 5 * Login dialog and one page work. The page features a list which is 6 coupled to our REST store with sessions. 1 * [Client] Moved pages in subtree of rft/, allowing controllers next to them. 2 * [Client] Created questions page, gives overview and allows adding. 3 * [Client] Page controllers inherit from _Page, because the previous mechanism wasn't working. 4 * [Client] Added new user registration. 5 * [Server] Changed user passwords to passwordHash/passwordSalt combination. 6 * [Server] Added simple object marshalling and unmarshalling to preserve types. 7 * [Server] Added ResearchToolObjectInterface with static create() method. Implemented for all model classes. -
Dev/branches/rest-dojo-ui/server/api.php
r263 r274 46 46 47 47 $user = null; 48 $data = null;49 48 if (!empty($request->data)) { 50 $data = json_decode($request->data, true); 51 } 52 if (!empty($data)) { 53 $user = Auth::login($data['username'], sha1($data['password'])); 49 $user = Auth::login($request->data['email'], $request->data['password']); 54 50 if (!$user) { 55 throw new ResponseException("Incorrect usernameand password", Response::UNAUTHORIZED);51 throw new ResponseException("Incorrect email and password", Response::UNAUTHORIZED); 56 52 } 57 53 set_session_cookie($response, $user); … … 59 55 $user = restore_session($response); 60 56 } 61 $response->body = json_encode($user); 57 $response->body = $user; 58 return $response; 59 } 60 61 } 62 63 /** 64 * @uri /register 65 */ 66 class RegisterResource extends Resource { 67 68 function post($request) { 69 $response = new Response($request); 70 71 $user = null; 72 if (!empty($request->data)) { 73 $user = Auth::register($request->data['email'], $request->data['password']); 74 set_session_cookie($response, $user); 75 } else { 76 throw new ResponseException("No email and password provided.",Response::BADREQUEST); 77 } 78 $response->body = $user; 62 79 return $response; 63 80 } … … 83 100 $type = $this->getType($request); 84 101 $objects = $type::get(array()); 85 //$objects = array_map(function($val) { return array('uid' => $val->uid); }, $objects); 86 87 $response->body = json_encode($objects); 102 103 $response->body = $objects; 88 104 return $response; 89 105 } … … 94 110 95 111 $type = $this->getType($request); 96 $data = json_decode($request->data);97 112 $onlyAdd = $request->ifNoneMatch('*'); 98 113 $onlyUpdate = $request->ifMatch('*'); 99 114 100 115 $object = FALSE; 101 if (isset($ data->uid)) {102 $objects = $type::get(array('uid' => $ data->uid));116 if (isset($request->data->uid)) { 117 $objects = $type::get(array('uid' => $request->data->uid)); 103 118 if (!empty($objects)) { 104 119 $object = $objects[0]; … … 116 131 $response->code = Response::OK; 117 132 } 118 foreach ($ data as $key => $val) {133 foreach ($request->data as $key => $val) { 119 134 $object->$key = $val; 120 135 } 121 $object->save(); 122 123 $response->body = json_encode($object); 136 if (!$object->save()) { 137 throw new ResponseException("Save failed", Response::INTERNALSERVERERROR); 138 } 139 140 $response->body = $object; 124 141 return $response; 125 142 } … … 150 167 } 151 168 152 $response->body = json_encode($objects[0]);169 $response->body = $objects[0]; 153 170 return $response; 154 171 } … … 159 176 160 177 $info = $this->getTypeAndUid($request); 161 $data = json_decode($request->data);162 178 $onlyAdd = $request->ifNoneMatch('*'); 163 179 $onlyUpdate = $request->ifMatch('*'); … … 179 195 $response->code = Response::OK; 180 196 } 181 foreach ($ data as $key => $val) {197 foreach ($request->data as $key => $val) { 182 198 $object->$key = $val; 183 199 } 184 $object->save(); 185 186 $response->body = json_encode($object); 200 if (!$object->save()) { 201 throw new ResponseException("Save failed", Response::INTERNALSERVERERROR); 202 } 203 204 $response->body = $object; 187 205 return $response; 188 206 } 189 207 190 208 function delete($request) { 191 restore_session( );209 restore_session(new Response($request)); 192 210 throw new ReponseException("Delete not implemented", Response::METHODNOTALLOWED); 193 211 } … … 202 220 $request->baseUri = $baseUri; 203 221 } 204 222 $request->data = Marshaller::unmarshall(json_decode($request->data)); 205 223 try { 206 224 $resource = $request->loadResource(); … … 208 226 } catch (ResponseException $e) { 209 227 $response = $e->response($request); 210 $response->body = json_encode(array('errorMsg' => $response->body));228 $response->body = array('errorMsg' => $response->body); 211 229 } catch (Exception $e) { 212 230 $response = new Response($request); 213 231 $response->code = Response::INTERNALSERVERERROR; 214 $response->body = json_encode(array('errorMsg' => "Unhandled exception: " . $e));232 $response->body = array('errorMsg' => "Unhandled exception: " . $e); 215 233 } 216 234 add_default_headers($response); 235 $response->body = json_encode(Marshaller::marshall($response->body)); 217 236 $response->output(); 237 218 238 ?> -
Dev/branches/rest-dojo-ui/server/classes/Auth.php
r256 r274 5 5 class Auth { 6 6 7 public static function login($username, $password) { 8 $user_results = User::get(array("name" => $username)); 9 if (!empty($user_results)) { 10 $user = $user_results[0]; 11 if (sha1($password) == $user->password) { 12 return $user; 13 } 7 public static function register($email, $password) { 8 $user_results = User::get(array("email" => $email)); 9 if ( !empty($user_results) ) { 10 throw new Exception("User with email $email already exists."); 14 11 } 15 return false; 12 $salt = rand(); 13 $user = new User(null,$email,sha1($password.$salt),$salt); 14 $user->save(); 15 return $user; 16 } 17 18 public static function login($email, $password) { 19 $user_results = User::get(array("email" => $email)); 20 if (empty($user_results)) { 21 throw new Exception("User with email $email not found."); 22 } 23 $user = $user_results[0]; 24 if (sha1($password.$user->passwordSalt) != $user->passwordHash) { 25 throw new Exception("Wrong password."); 26 } 27 return $user; 16 28 } 17 29 18 30 public static function restore($session) { 19 31 $user_results = User::get(array("uid" => $session)); 20 if ( !empty($user_results)) {21 return $user_results[0];32 if (empty($user_results)) { 33 throw new Exception("Session with id $session not found."); 22 34 } 23 return false;35 return $user_results[0]; 24 36 } 25 37 -
Dev/branches/rest-dojo-ui/server/classes/models/Answer.php
r271 r274 18 18 public static function create($obj) 19 19 { 20 return new Answer($obj->uid, $obj->question, $obj->values) 20 return new Answer($obj->uid, $obj->question, $obj->values); 21 21 } 22 22 -
Dev/branches/rest-dojo-ui/server/classes/models/AnswerSet.php
r271 r274 187 187 return $answers; 188 188 } 189 190 public static function create($obj) { 191 return new AnswerSet($obj->uid, $obj->survey, $obj->respondent, $obj->datetime, $obj->answers); 192 } 193 189 194 } 190 195 -
Dev/branches/rest-dojo-ui/server/classes/models/Application.php
r256 r274 113 113 return $applications; 114 114 } 115 116 public static function create($obj) { 117 return new Application($obj->uid, $obj->title, $obj->description, $obj->style); 118 } 115 119 } 116 120 -
Dev/branches/rest-dojo-ui/server/classes/models/ApplicationInstance.php
r263 r274 167 167 168 168 } 169 170 public static function create($obj) { 171 return new ApplicationInstance($obj->uid, $obj->application, 172 $obj->starttime, $obj->endtime, $obj->open, $obj->playerresults, 173 $obj->groupresults, $obj->periodicresults); 174 } 169 175 } 170 176 ?> -
Dev/branches/rest-dojo-ui/server/classes/models/ResearchToolObject.php
r256 r274 11 11 12 12 13 abstract class ResearchToolObject {13 abstract class ResearchToolObject implements ResearchToolObjectInterface { 14 14 15 public $uid ;15 public $uid = null; 16 16 17 public function getUid() { 18 return $this->uid; 19 } 20 17 21 public function evaluate() 18 22 { … … 79 83 } 80 84 85 interface ResearchToolObjectInterface { 86 function getUid(); 87 static function get($arguments); 88 static function create($obj); 89 function evaluate(); 90 function save(); 91 } 92 81 93 ?> -
Dev/branches/rest-dojo-ui/server/classes/models/Respondent.php
r256 r274 16 16 17 17 public $email; 18 public $password; 18 public $passwordHash; 19 public $passwordSalt; 19 20 20 21 /** … … 24 25 * @param type password 25 26 */ 26 public function __construct($uid = null, $email = null, $password = null)27 public function __construct($uid = null, $email = null, $passwordHash = null, $passwordSalt = null) 27 28 { 28 29 if(!isset($uid)) … … 33 34 $this->uid = $uid; 34 35 $this->email = $email; 35 $this->password = $password; 36 $this->passwordHash = $passwordHash; 37 $this->passwordSalt = $passwordSalt; 36 38 } 37 39 /** … … 64 66 $model->add(new Statement($resourceRespondent,$predicateName,$literalRespondentName)); 65 67 66 $literalPassword = new Literal($this->password); 67 $predicatePassword = new Resource(PASSWORD); 68 $model->add(new Statement($resourceRespondent,$predicatePassword,$literalPassword)); 68 $literalPasswordHash = new Literal($this->passwordHash); 69 $predicatePasswordHash = new Resource(PASSWORDHASH); 70 $model->add(new Statement($resourceRespondent,$predicatePasswordHash,$literalPasswordHash)); 71 72 $literalPasswordSalt = new Literal($this->passwordSalt); 73 $predicatePasswordSalt = new Resource(PASSWORDSALT); 74 $model->add(new Statement($resourceRespondent,$predicatePasswordSalt,$literalPasswordSalt)); 75 69 76 $model->saveAs(Respondent::$filename, 'rdf'); 70 77 return true; … … 85 92 PREFIX predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '> 86 93 PREFIX resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '> 87 SELECT ?uid, ?email, ?password 94 SELECT ?uid, ?email, ?passwordHash, ?passwordSalt 88 95 WHERE 89 96 { … … 91 98 predicates:uid ?uid ; 92 99 predicates:email ?email ; 93 predicates:password ?password ; 100 predicates:passwordHash ?passwordHash ; 101 predicates:passwordSalt ?passwordSalt ; 94 102 ' . ResearchToolObject::createArguments($arguments) . ' 95 103 }'; … … 102 110 foreach($results as $result) 103 111 { 104 $respondents[] = new Respondent($result['?uid']->label, $result['?email']->label, $result['?password ']->label);112 $respondents[] = new Respondent($result['?uid']->label, $result['?email']->label, $result['?passwordHash']->label, $result['?passwordSalt']->label); 105 113 } 106 114 } 107 115 return $respondents; 108 116 } 117 118 public static function create($obj) { 119 return new Respondent($obj->uid, $obj->email, $obj->passwordHash, $obj->passwordSalt); 120 } 121 109 122 } 110 123 111 112 113 114 124 ?> -
Dev/branches/rest-dojo-ui/server/classes/models/ResultSet.php
r263 r274 158 158 return $answersets; 159 159 } 160 161 public static function create($obj) { 162 return new ResultSet($obj->uid, $obj->answersets, $obj->playerresults, 163 $obj->groupresults, $obj->periodicresults); 164 } 160 165 } -
Dev/branches/rest-dojo-ui/server/classes/models/Session.php
r263 r274 24 24 * @param type $title 25 25 * @param type $creator 26 * @param type $ datetime26 * @param type $creationdate 27 27 * @param type $pipeline 28 28 */ 29 public function __construct($uid = null, $title = null, $creator = null, $ datetime = null, $pipeline = null)29 public function __construct($uid = null, $title = null, $creator = null, $creationdate = null, $pipeline = null) 30 30 { 31 31 if(!isset($uid)) … … 36 36 $this->title = $title; 37 37 $this->creator = $creator; 38 $this->creationdate = $ datetime;38 $this->creationdate = $creationdate; 39 39 $this->pipeline = $pipeline; 40 40 } … … 141 141 } 142 142 } 143 144 $model->saveAs(Session::$filename, 'rdf'); 145 return true; 143 144 return $model->saveAs(Session::$filename, 'rdf'); 146 145 } 147 146 … … 320 319 } 321 320 321 public static function create($obj) { 322 return new Session($obj->uid, $obj->title, $obj->creator, 323 $obj->creationdate, $obj->pipeline); 324 } 325 322 326 } 323 327 324 325 328 ?> -
Dev/branches/rest-dojo-ui/server/classes/models/SessionInstance.php
r263 r274 235 235 } 236 236 237 public static function create($obj) { 238 return new SessionInstance($obj->uid, $obj->title, $obj->location, 239 $obj->facilitator, $obj->starttime, $obj->endtime, $obj->notes, 240 $obj->session, $obj->resultset); 241 } 237 242 238 243 } 244 245 ?> -
Dev/branches/rest-dojo-ui/server/classes/models/Survey.php
r263 r274 169 169 } 170 170 171 public static function create($obj) { 172 return new Survey($obj->uid, $obj->title, $obj->description, 173 $obj->creator, $obj->questions); 174 } 171 175 172 176 } -
Dev/branches/rest-dojo-ui/server/classes/models/SurveyInstance.php
r271 r274 242 242 } 243 243 244 public static function create($obj) { 245 return new SurveyInstance($obj->uid, $obj->survey, $obj->starttime, 246 $obj->endtime, $obj->open, $obj->presetanswers, 247 $obj->answersets); 248 } 249 244 250 } 245 251 -
Dev/branches/rest-dojo-ui/server/classes/models/User.php
r256 r274 17 17 18 18 public $email; 19 public $password; 19 public $passwordHash; 20 public $passwordSalt; 20 21 21 22 /** … … 23 24 * If the user does not yet exist in the database, call with null as first parameter 24 25 */ 25 public function __construct($uid = null, $email = null, $password = null) {26 public function __construct($uid = null, $email = null, $passwordHash = null, $passwordSalt = null) { 26 27 if(!isset($uid)) 27 28 { … … 30 31 $this->uid = $uid; 31 32 $this->email = $email; 32 $this->password = sha1($password); 33 $this->passwordHash = $passwordHash; 34 $this->passwordSalt = $passwordSalt; 33 35 } 34 36 … … 60 62 $model->add(new Statement($resourceUser,$predicateName,$literalUserName)); 61 63 62 $literalPassword = new Literal($this->password); 63 $predicatePassword = new Resource(PASSWORD); 64 $model->add(new Statement($resourceUser,$predicatePassword,$literalPassword)); 64 $literalPasswordHash = new Literal($this->passwordHash); 65 $predicatePasswordHash = new Resource(PASSWORDHASH); 66 $model->add(new Statement($resourceUser,$predicatePasswordHash,$literalPasswordHash)); 67 68 $literalPasswordSalt = new Literal($this->passwordSalt); 69 $predicatePasswordSalt = new Resource(PASSWORDSALT); 70 $model->add(new Statement($resourceUser,$predicatePasswordSalt,$literalPasswordSalt)); 65 71 66 72 $model->saveAs(User::$filename, 'rdf'); … … 82 88 PREFIX predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '> 83 89 PREFIX resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '> 84 SELECT ?uid, ?email, ?password 90 SELECT ?uid, ?email, ?passwordHash, ?passwordSalt 85 91 WHERE 86 92 { … … 88 94 predicates:uid ?uid ; 89 95 predicates:email ?email ; 90 predicates:password ?password ; 96 predicates:passwordHash ?passwordHash ; 97 predicates:passwordSalt ?passwordSalt ; 91 98 ' . ResearchToolObject::createArguments($arguments) . ' 92 99 }'; … … 99 106 foreach($results as $result) 100 107 { 101 $users[] = new User($result['?uid']->label, $result['?email']->label, $result['?password ']->label);108 $users[] = new User($result['?uid']->label, $result['?email']->label, $result['?passwordHash']->label, $result['?passwordSalt']->label); 102 109 } 103 110 } 104 111 return $users; 105 112 } 113 114 public static function create($obj) { 115 return new User($obj->uid, $obj->email,$obj->passwordHash,$obj->passwordSalt); 116 } 117 106 118 } 107 119 -
Dev/branches/rest-dojo-ui/server/rdfConstants.php
r271 r274 30 30 define('UID',SURVEYTOOL_PREDICATES_NAMESPACE . 'uid'); 31 31 define('EMAIL',SURVEYTOOL_PREDICATES_NAMESPACE . 'email'); 32 define('PASSWORD',SURVEYTOOL_PREDICATES_NAMESPACE . 'password'); 32 define('PASSWORDHASH',SURVEYTOOL_PREDICATES_NAMESPACE . 'passwordHash'); 33 define('PASSWORDSALT',SURVEYTOOL_PREDICATES_NAMESPACE . 'passwordSalt'); 33 34 define('CREATOR',SURVEYTOOL_PREDICATES_NAMESPACE . 'creator'); 34 35 define('TITLE',SURVEYTOOL_PREDICATES_NAMESPACE . 'title');
Note: See TracChangeset
for help on using the changeset viewer.