viewrework.json.php 3.12 KB
Newer Older
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
<?php
/**
 * This program is part of Mahara
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 *
 * @package    mahara
 * @subpackage core
 * @author     Nigel McNie <nigel@catalyst.net.nz>
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL
 * @copyright  (C) 2006,2007 Catalyst IT Ltd http://catalyst.net.nz
 *
 */

define('INTERNAL', 1);
define('JSON', 1);
define('PUBLIC', 1);
require(dirname(__FILE__) . '/init.php');
31
require(dirname(__FILE__) . '/viewlib.php');
32

33
$view   = param_integer('view');
Penny Leach's avatar
Penny Leach committed
34
$view = new View($view);
35
36
37
38
39
40
41
42
43
44
45
46
$action = param_alphanumext('action');

switch ($action) {
case 'delete_blockinstance':
    // @todo
    json_reply(false, false);
    break;
case 'blocktype_list':
    $category = param_alpha('category');
    // TODO:
    //
    // Where I can get to:
47
48
    // Static version: Clicking buttons = response, but no action.
    // Dynamic version: Actions = response, but no action performed.
49
50
    //
    // What can be done:
Nigel McNie's avatar
Nigel McNie committed
51
52
    // [done] Add column: js should make room for it, put in the raw html (note: need to generate column raw html in a function then!)
    // [done] Remove column: js should destroy the existing column, hopefully moving the blocks to other columns (could be implemented as move move delete?)
53
54
55
    // Moving block instances: js should drag+drop, do ajax stub request. static should send response
    // Add block: js should be done by drag and drop. static should respond
    //
56
    // Where I'm up to:
57
    // Drag+Drop move blockinstances
Nigel McNie's avatar
Nigel McNie committed
58
59
60
61
62
    // ...
    // Fix up all the stuff that works with javascript to work in the non javascript version
    // Clean up view_process_changes() and related things
    // ...
    // Blocktype adding to view (but only after the change can be reflected in the database!)
63
    //
64
    $data = view_build_blocktype_list($category, true);
65
66
    json_reply(false, array('message' => false, 'data' => $data));
    break;
67
68
case 'add_column':
    $column = param_integer('column');
Penny Leach's avatar
Penny Leach committed
69
    if (view_add_column($view->id, $column)) {
70
        json_reply(false, array('message' => false, 'data' => view_build_column($view, $column, true)));
71
72
73
74
75
76
    }
    else {
        json_reply(true, 'Failed to add column');
    }
case 'remove_column':
    $column = param_integer('column');
Penny Leach's avatar
Penny Leach committed
77
    if (view_remove_column($view->id, $column)) {
78
79
80
81
82
83
84
        // Just do it - no message
        json_reply(false, false);
    }
    else {
        json_reply(true, 'Failed to remove column');
    }
    break;
85
86
87
}

json_reply(true, 'Unknown action "' . $action . '"');
88

89
?>