Changeset 171 for Dev/trunk/classes/UserConnector.php
- Timestamp:
- 12/02/11 15:26:01 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/trunk/classes/UserConnector.php
r158 r171 10 10 * @author jkraaijeveld 11 11 */ 12 class UserConnector implements IConnector{ 13 14 protected $model; 15 protected $fileName = 'data/users/users.rdf'; 12 class UserConnector extends Connector{ 16 13 17 14 /** 18 * Constructor for RespondentConnector.15 * Constructor for UserConnector. 19 16 */ 20 17 public function __construct() 21 18 { 19 $this->fileName = 'data/users/users.rdf'; 22 20 //Ensure the required folder for this connector exists 23 21 if (!is_dir('data/users/')) 24 22 mkdir('data/users/'); 25 }26 27 /**28 * function load()29 * Loads the file into the standard MemModel.30 */31 public function load() {32 //Get the Memory Model from the ModelFactory33 $this->model = ModelFactory::getDefaultModel();34 //Ensure the required file exists before loading35 if(file_exists($this->fileName))36 $this->model->load($this->fileName);37 }38 39 /**40 * function save()41 * Saves the MemModel into the given file.42 */43 public function save() {44 $this->model->saveAs($this->fileName,'rdf');45 23 } 46 24 … … 53 31 public function get($arguments) { 54 32 $this->load(); 55 //Determine which arguments are supplied56 $keys = array_keys($arguments);57 //Set default values for arguments58 $uid = ""; $name = ""; $password = "";59 //Set the arguments if they are supplied60 if(in_array("uid", $keys))61 $uid = "predicates:uid \"".$arguments["uid"]."\"";62 if(in_array("name", $keys))63 $name = 'predicates:name \''.$arguments["name"].'\'';64 if(in_array("password", $keys))65 $password = "predicates:password \"".$arguments["password"]."\"";66 67 33 //Create the querystring 68 34 $querystring = ' … … 76 42 predicates:name ?name ; 77 43 predicates:password ?password ; 78 ' . $ uid . $name . $password. '44 ' . $this->createArguments($arguments) . ' 79 45 }'; 80 46 //Query the model 81 47 $results = $this->model->sparqlQuery($querystring); 82 48 $users = array(); 83 49 if(!empty($results))
Note: See TracChangeset
for help on using the changeset viewer.