~fkhan-zivios/zivios/devel

« back to all changes in this revision

Viewing changes to application/modules/samba/controllers/ShareController.php

  • Committer: Faraz Khan
  • Date: 2008-09-15 13:29:33 UTC
  • Revision ID: fkhan@zivios.org-20080915132933-d27jml5l29xw4gsr
Initial release to bazaar, code in sync with 0.5.0-release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
 
 
3
/**
 
4
 * Copyright (c) 2008 Zivios, LLC.
 
5
 *
 
6
 * This file is part of Zivios.
 
7
 *
 
8
 * Zivios is free software: you can redistribute it and/or modify
 
9
 * it under the terms of the GNU General Public License as published by
 
10
 * the Free Software Foundation, either version 3 of the License, or
 
11
 * (at your option) any later version.
 
12
 *
 
13
 * Zivios is distributed in the hope that it will be useful,
 
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
 * GNU General Public License for more details.
 
17
 *
 
18
 * You should have received a copy of the GNU General Public License
 
19
 * along with Zivios.  If not, see <http://www.gnu.org/licenses/>.
 
20
 *
 
21
 * @package             mod_samba
 
22
 * @copyright   Copyright (c) 2008 Zivios, LLC. (http://www.zivios.org)
 
23
 * @license             http://www.zivios.org/legal/license
 
24
 * @version             $Id$
 
25
 * @lastchangeddate $LastChangedDate$
 
26
 **/
 
27
 
 
28
 
 
29
class Samba_ShareController extends Ecl_Controller
 
30
{
 
31
 
 
32
    public function dashboardAction()
 
33
    {
 
34
 
 
35
        $this->render('edit');
 
36
    }
 
37
 
 
38
    public function _init()
 
39
    {
 
40
        if ((!isset($this->json->operate_dn) || $this->json->operate_dn ==""))
 
41
                throw new Ecl_Exception("Invalid called to _init(). Operate DN missing");
 
42
 
 
43
 
 
44
 
 
45
            $this->view->obj = Ecl_Ldap_Cache::loadDn($this->json->operate_dn);
 
46
 
 
47
    }
 
48
 
 
49
 
 
50
    public function editAction()
 
51
    {
 
52
        if (isset($this->json)) {
 
53
            if ($this->json->action == 'update') {
 
54
                Ecl_Log::debug($this->json);
 
55
                $sambashare = $this->view->obj;
 
56
                $sambashare->setProperty('cn',$this->json->cn);
 
57
                if (isset($this->json->browseable)) $browseable = 'yes'; else $browseable = 'no';
 
58
 
 
59
                $sambashare->setProperty('emssharecfgcomment',$this->json->comment);
 
60
                $sambashare->setProperty('emssharecfgbrowseable',$browseable);
 
61
 
 
62
                if (isset($this->json->writeable)) $writeable = 'yes'; else $writeable = 'no';
 
63
                $sambashare->setProperty('emssharecfgwriteable',$writeable);
 
64
                $sambashare->setProperty('emssharecfgcreatemask','0700');
 
65
                $sambashare->setProperty('emssharecfgdirmask','0700');
 
66
                $sambashare->setProperty('emssharecfgvalidusers','%S');
 
67
                if ($writeable == 'yes') $readonly = 'no'; else $readonly = 'yes';
 
68
                $sambashare->setProperty('emssharecfgreadonly',$readonly);
 
69
 
 
70
                if (isset($this->json->guestok)) $guestok = 'yes'; else $guestok = 'no';
 
71
                $sambashare->setProperty('emssharecfgguestok',$guestok);
 
72
 
 
73
                $sambashare->setProperty('emssharepath',$this->json->path);
 
74
                $trans = $sambashare->update();
 
75
                $trans->process();
 
76
                $this->_createPopupReturn(0, "Share Added Successfully");
 
77
                $this->_jsCallBack('nodeDetails', array($sambashare->getdn()));
 
78
            }
 
79
        }
 
80
    }
 
81
 
 
82
    public function addShareAction()
 
83
    {
 
84
 
 
85
        if (isset($this->json)) {
 
86
            if ($this->json->action == 'add') {
 
87
                Ecl_Log::debug($this->json);
 
88
                $sambashare = new SambaShare();
 
89
                $sambashare->init();
 
90
                $sambashare->setProperty('cn',$this->json->cn);
 
91
                if (isset($this->json->browseable)) $browseable = 'yes'; else $browseable = 'no';
 
92
 
 
93
                $sambashare->setProperty('emssharecfgcomment',$this->json->comment);
 
94
                $sambashare->setProperty('emssharecfgbrowseable',$browseable);
 
95
 
 
96
                if (isset($this->json->writeable)) $writeable = 'yes'; else $writeable = 'no';
 
97
                $sambashare->setProperty('emssharecfgwriteable',$writeable);
 
98
                $sambashare->setProperty('emssharecfgcreatemask','0700');
 
99
                $sambashare->setProperty('emssharecfgdirmask','0700');
 
100
                $sambashare->setProperty('emssharecfgvalidusers','%S');
 
101
                if ($writeable == 'yes') $readonly = 'no'; else $readonly = 'yes';
 
102
                $sambashare->setProperty('emssharecfgreadonly',$readonly);
 
103
 
 
104
                if (isset($this->json->guestok)) $guestok = 'yes'; else $guestok = 'no';
 
105
                $sambashare->setProperty('emssharecfgguestok',$guestok);
 
106
 
 
107
                $sambashare->setProperty('emssharepath',$this->json->path);
 
108
                $trans = $sambashare->add($this->view->obj);
 
109
                $trans->process();
 
110
                $this->_createPopupReturn(0, "Share Added Successfully");
 
111
                $this->_jsCallBack('nodeDetails', array($sambashare->getdn()));
 
112
                $this->_refreshTreeView($this->view->obj->getdn());
 
113
            }
 
114
        }
 
115
 
 
116
        $this->render('add');
 
117
    }
 
118
 
 
119
 
 
120
 
 
121
 
 
122
 
 
123
}
 
124