Ignore:
Timestamp:
02/08/12 16:43:40 (13 years ago)
Author:
hendrikvanantwerpen
bzr:base-revision:
hendrik@van-antwerpen.net-20120207191752-mbokj4rwqv8oi8bk
bzr:committer:
Hendrik van Antwerpen <hendrik@van-antwerpen.net>
bzr:file-ids:

Dev/branches/jQueryUI/api.php 244@e1b9dffa-5495-0410-85d9-cf58ec4b5d15:%2FDev%2Fbranches%2FjQueryUI%2Fapi.php
Dev/branches/jQueryUI/index.php 243@e1b9dffa-5495-0410-85d9-cf58ec4b5d15:%2FDev%2Fbranches%2FjQueryUI%2Findex.php
Dev/branches/jQueryUI/js/api.js api.js-20120207184802-m5kfm0pir6sqj2uh-2
Dev/branches/jQueryUI/js/jquery/plugins plugins-20120208154136-m6u6o9acix3zvony-2
Dev/branches/jQueryUI/js/jquery/plugins/jquery.ba-bbq.js jquery.babbq.js-20120208154136-m6u6o9acix3zvony-5
Dev/branches/jQueryUI/js/main.js 244@e1b9dffa-5495-0410-85d9-cf58ec4b5d15:%2FDev%2Fbranches%2FjQueryUI%2Fjs%2Fmain.js
Dev/branches/jQueryUI/pages/mainmenu/mainmenu.html mainmenu.html-20120207184802-m5kfm0pir6sqj2uh-4
Dev/branches/jQueryUI/pages/mainmenu/mainmenu.js mainmenu.js-20120207184802-m5kfm0pir6sqj2uh-5
Dev/branches/jQueryUI/pages/sessions sessions-20120208154136-m6u6o9acix3zvony-1
Dev/branches/jQueryUI/pages/sessions/sessions.html sessions.html-20120208154136-m6u6o9acix3zvony-3
Dev/branches/jQueryUI/pages/sessions/sessions.js sessions.js-20120208154136-m6u6o9acix3zvony-4
bzr:mapping-version:
v4
bzr:repository-uuid:
e1b9dffa-5495-0410-85d9-cf58ec4b5d15
bzr:revision-id:
hendrik@van-antwerpen.net-20120208154334-gr4a79sgxd2lp6v0
bzr:revno:
248
bzr:revprop:branch-nick:
RESEARCHTOOL
bzr:testament:

bazaar-ng testament short form 2.1
revision-id: hendrik@van-antwerpen.net-20120208154334-gr4a79sgxd2lp6v0
sha1: 5521adbc27dd512aa1572cefe88d4c14770cb488
bzr:text-parents:

Dev/branches/jQueryUI/api.php hendrik@van-antwerpen.net-20120207191752-mbokj4rwqv8oi8bk
Dev/branches/jQueryUI/index.php hendrik@van-antwerpen.net-20120207191752-mbokj4rwqv8oi8bk
Dev/branches/jQueryUI/js/api.js hendrik@van-antwerpen.net-20120207191752-mbokj4rwqv8oi8bk
Dev/branches/jQueryUI/js/jquery/plugins/jquery.ba-bbq.js
Dev/branches/jQueryUI/js/main.js hendrik@van-antwerpen.net-20120207191752-mbokj4rwqv8oi8bk
Dev/branches/jQueryUI/pages/mainmenu/mainmenu.html hendrik@van-antwerpen.net-20120207191752-mbokj4rwqv8oi8bk
Dev/branches/jQueryUI/pages/mainmenu/mainmenu.js hendrik@van-antwerpen.net-20120207191752-mbokj4rwqv8oi8bk
Dev/branches/jQueryUI/pages/sessions/sessions.html
Dev/branches/jQueryUI/pages/sessions/sessions.js
bzr:timestamp:
2012-02-08 16:43:34.436000109 +0100
bzr:user-agent:
bzr2.4.1+bzr-svn1.1.0
Message:

Introduced basic checking of login.
Added object query and create functions to API.
Fixed sessions overview page.
Added browser history mgmt.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Dev/branches/jQueryUI/api.php

    r246 r247  
    11<?php
    22
    3 require_once 'classes//master.php';
     3require_once 'classes/master.php';
    44
    55$rawInput = $HTTP_RAW_POST_DATA;
     
    2121                $user = $user_results[0];
    2222                if ($password == $user->password) {
     23                    $output['uid'] = $user->uid;
    2324                    $returnValue = 200;
    2425                }
     
    3637                $user->password = $password;
    3738                $user->save();
     39                $output['uid'] = $user->uid;
    3840                $returnValue = 200;
    3941            }
    4042            break;
    4143    }
     44
     45    if (isset($input->uid)) {
     46        $user_results = User::get(array("uid" => $input->uid));
     47        if (!empty($user_results)) {
     48            $user = $user_results[0];
     49            switch ($input->action) {
     50                case "createObject":
     51                    $uid = null;
     52                    switch (strtolower($input->args->type)) {
     53                        case "application":
     54                            $newApp = new Application(null,
     55                                            $input->args->values->title,
     56                                            $input->args->values->description,
     57                                            $input->args->values->style);
     58                            $newApp->save();
     59                            $uid = $newApp->uid;
     60                            $returnValue = 200;
     61                            break;
     62                        case "survey":
     63                            $newSurvey = new Survey(null,
     64                                            $input->args->values->title,
     65                                            $input->args->values->description,
     66                                            $user, null);
     67                            $newSurvey->save();
     68                            $uid = $newSurvey->uid;
     69                            $returnValue = 200;
     70                            break;
     71                        case "dashboard":
     72                            //TODO
     73                            break;
     74                        case "question":
     75                            $newQuestion = new Question(null,
     76                                            $input->args->values->qCode,
     77                                            $input->args->values->title,
     78                                            $input->args->values->dataType,
     79                                            $input->args->values->description,
     80                                            $input->args->values->category,
     81                                            array());
     82                            $newQuestion->save();
     83                            $uid = $newQuestion->uid;
     84                            $returnValue = 200;
     85                            break;
     86                        case "session":
     87                            $newSession = new Session(null,
     88                                            $input->args->values->title,
     89                                            $user, new DateTime(), null, null);
     90                            $newSession->save();
     91                            $uid = $newSession->uid;
     92                            $returnValue = 200;
     93                            break;
     94                    }
     95                    $output['uid'] = $uid;
     96                    break;
     97                case "getObject":
     98                    $type = $input->args->type;
     99                    $objects = $type::get(array("uid" => $input->args->uid));
     100                    if (!empty($objects)) {
     101                        $output->object = $objects[0];
     102                        $returnValue = 200;
     103                    }
     104                    break;
     105                case "getObjects":
     106                    $type = $input->args->type;
     107                    $output['objects'] = $type::get($input->args->predicates);
     108                    $returnValue = 200;
     109                    break;
     110            }
     111        } else {
     112            $returnValue = 403;
     113        }
     114    }
    42115}
    43116
    44 header("HTTP/1.1 ".$returnValue);
     117header("HTTP/1.1 " . $returnValue);
    45118header("Content-Type: application/json");
    46119header("Cache-Control: no-cache, must-revalidate");
    47120header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
    48121echo(json_encode($output));
    49 
    50122?>
Note: See TracChangeset for help on using the changeset viewer.