File: users.php

package info (click to toggle)
libjs-extjs 3.4.0%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, jessie, jessie-kfreebsd, stretch
  • size: 53,188 kB
  • ctags: 3,384
  • sloc: php: 819; xml: 537; python: 60; sql: 44; makefile: 35
file content (62 lines) | stat: -rw-r--r-- 1,564 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
/**
 * @class Users
 * A simple application controller extension
 */
class Users extends ApplicationController {
    /**
     * view
     * Retrieves rows from database.
     */
    public function view() {
        $res = new Response();
        $res->success = true;
        $res->message = "Loaded data";
        $res->data = User::all();
        return $res->to_json();
    }
    /**
     * create
     */
    public function create() {
        $res = new Response();
        $rec = User::create($this->params);
        if ($rec) {
            $res->success = true;
            $res->message = "Created new User" . $rec->id;
            $res->data = $rec->to_hash();
        } else {
            $res->message = "Failed to create User";
        }
        return $res->to_json();
    }
    /**
     * update
     */
    public function update() {
        $res = new Response();
        $rec = User::update($this->id, $this->params);
        if ($rec) {
            $res->data = $rec->to_hash();
            $res->success = true;
            $res->message = 'Updated User ' . $this->id;
        } else {
            $res->message = "Failed to find that User";
        }
        return $res->to_json();
    }
    /**
     * destroy
     */
    public function destroy() {
        $res = new Response();
        if (User::destroy($this->id)) {
            $res->success = true;
            $res->message = 'Destroyed User ' . $this->id;
        } else {
            $res->message = "Failed to destroy User";
        }
        return $res->to_json();
    }
}