]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - lib/applicationeditform.php
Reorganized the OAuth app URLs and more work on the register app workflow
[quix0rs-gnu-social.git] / lib / applicationeditform.php
1 <?php
2 /**
3  * StatusNet, the distributed open-source microblogging tool
4  *
5  * Form for editing an application
6  *
7  * PHP version 5
8  *
9  * LICENCE: This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU Affero General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU Affero General Public License for more details.
18  *
19  * You should have received a copy of the GNU Affero General Public License
20  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21  *
22  * @category  Form
23  * @package   StatusNet
24  * @author    Zach Copley <zach@status.net>
25  * @copyright 2009 StatusNet, Inc.
26  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
27  * @link      http://status.net/
28  */
29
30 if (!defined('STATUSNET') && !defined('LACONICA')) {
31     exit(1);
32 }
33
34 require_once INSTALLDIR . '/lib/form.php';
35
36 /**
37  * Form for editing an application
38  *
39  * @category Form
40  * @package  StatusNet
41  * @author   Zach Copley <zach@status.net>
42  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
43  * @link     http://status.net/
44  *
45  */
46
47 class ApplicationEditForm extends Form
48 {
49     /**
50      * group for user to join
51      */
52
53     var $application = null;
54
55     /**
56      * Constructor
57      *
58      * @param Action     $out   output channel
59      * @param User_group $group group to join
60      */
61
62     function __construct($out=null, $application=null)
63     {
64         parent::__construct($out);
65
66         $this->application = $application;
67     }
68
69     /**
70      * ID of the form
71      *
72      * @return string ID of the form
73      */
74
75     function id()
76     {
77         if ($this->application) {
78             return 'form_application_edit-' . $this->application->id;
79         } else {
80             return 'form_application_add';
81         }
82     }
83
84     /**
85      * class of the form
86      *
87      * @return string of the form class
88      */
89
90     function formClass()
91     {
92         return 'form_settings';
93     }
94
95     /**
96      * Action of the form
97      *
98      * @return string URL of the action
99      */
100
101     function action()
102     {
103         if ($this->application) {
104             return common_local_url('editapplication',
105                                     array('id' => $this->application->id));
106         } else {
107             return common_local_url('newapplication');
108         }
109     }
110
111     /**
112      * Name of the form
113      *
114      * @return void
115      */
116
117     function formLegend()
118     {
119         $this->out->element('legend', null, _('Register a new application'));
120     }
121
122     /**
123      * Data elements of the form
124      *
125      * @return void
126      */
127
128     function formData()
129     {
130         if ($this->application) {
131             $id                = $this->application->id;
132             $name              = $this->application->name;
133             $description       = $this->application->description; 
134             $source_url        = $this->application->source_url;
135             $organization      = $this->application->organization;
136             $homepage          = $this->application->homepage;
137             $callback_url      = $this->application->callback_url;
138             $this->type        = $this->application->type;
139             $this->access_type = $this->application->access_type;
140         } else {
141             $id                = '';
142             $name              = '';
143             $description       = '';
144             $source_url        = '';
145             $organization      = '';
146             $homepage          = '';
147             $callback_url      = '';
148             $this->type        = '';
149             $this->access_type = '';
150         }
151
152         $this->out->elementStart('ul', 'form_data');
153         $this->out->elementStart('li');
154         
155         $this->out->hidden('application_id', $id);
156         $this->out->input('name', _('Name'),
157                           ($this->out->arg('name')) ? $this->out->arg('name') : $name);
158                     
159         $this->out->elementEnd('li');
160         
161         $this->out->elementStart('li');
162         $this->out->input('description', _('Description'),
163                           ($this->out->arg('Description')) ? $this->out->arg('discription') : $description);
164         $this->out->elementEnd('li');
165         
166         $this->out->elementStart('li');
167         $this->out->input('source_url', _('Source URL'),
168                           ($this->out->arg('source_url')) ? $this->out->arg('source_url') : $source_url,
169                           _('URL of the homepage of this application'));
170         $this->out->elementEnd('li');        
171
172         $this->out->elementStart('li');
173         $this->out->input('Organization', _('Organization'),
174                           ($this->out->arg('organization')) ? $this->out->arg('organization') : $orgranization,
175                           _('Organization responsible for this application'));
176         $this->out->elementEnd('li');
177
178         $this->out->elementStart('li');
179         $this->out->input('homepage', _('Homepage'),
180                           ($this->out->arg('homepage')) ? $this->out->arg('homepage') : $homepage,
181                           _('URL of the homepage of the organization'));
182         $this->out->elementEnd('li');
183
184         $this->out->elementStart('li');
185         $this->out->input('callback_url', ('Callback URL'),
186                           ($this->out->arg('callback_url')) ? $this->out->arg('callback_url') : $callback_url,
187                           _('URL to redirect to after authentication'));
188         $this->out->elementEnd('li');
189
190         $this->out->elementStart('li');
191         $this->out->input('type', _('Application type'),
192                           ($this->out->arg('type')) ? $this->out->arg('type') : $type,
193                           _('Type of application, browser or desktop'));
194         $this->out->elementEnd('li');
195         
196         $this->out->elementStart('li');
197         $this->out->input('access_type', _('Default access'),
198                           ($this->out->arg('access_type')) ? $this->out->arg('access_type') : $access_type,
199                           _('Default access for this application: read-write, or read-only'));
200         $this->out->elementEnd('li');
201         
202         $this->out->elementEnd('ul');
203     }
204
205     /**
206      * Action elements
207      *
208      * @return void
209      */
210
211     function formActions()
212     {
213         $this->out->submit('submit', _('Save'));
214     }
215 }