]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/YammerImport/actions/yammeradminpanel.php
875debac929d8df2c911a4b6a3e738fa80b7c9b1
[quix0rs-gnu-social.git] / plugins / YammerImport / actions / yammeradminpanel.php
1 <?php
2 /**
3  * StatusNet, the distributed open-source microblogging tool
4  *
5  * Yammer import administration panel
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  Settings
23  * @package   StatusNet
24  * @author    Zach Copley <zach@status.net>
25  * @copyright 2010 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')) {
31     exit(1);
32 }
33
34 class YammeradminpanelAction extends AdminPanelAction
35 {
36     /**
37      * Returns the page title
38      *
39      * @return string page title
40      */
41     function title()
42     {
43         return _m('Yammer Import');
44     }
45
46     /**
47      * Instructions for using this form.
48      *
49      * @return string instructions
50      */
51     function getInstructions()
52     {
53         return _m('Yammer import tool');
54     }
55
56     /**
57      * Show the Yammer admin panel form
58      *
59      * @return void
60      */
61     function showForm()
62     {
63         $form = new YammerAdminPanelForm($this);
64         $form->show();
65         return;
66     }
67 }
68
69 class YammerAdminPanelForm extends AdminForm
70 {
71     /**
72      * ID of the form
73      *
74      * @return string ID of the form
75      */
76     function id()
77     {
78         return 'yammeradminpanel';
79     }
80
81     /**
82      * class of the form
83      *
84      * @return string class of the form
85      */
86     function formClass()
87     {
88         return 'form_settings';
89     }
90
91     /**
92      * Action of the form
93      *
94      * @return string URL of the action
95      */
96     function action()
97     {
98         return common_local_url('yammeradminpanel');
99     }
100
101     /**
102      * Data elements of the form
103      *
104      * @return void
105      */
106     function formData()
107     {
108         $this->out->element('p', array(), 'yammer import IN DA HOUSE');
109         
110         /*
111         Possible states of the yammer import process:
112         - null (not doing any sort of import)
113         - requesting-auth
114         - authenticated
115         - import-users
116         - import-groups
117         - fetch-messages
118         - import-messages
119         - done
120         */
121         $yammerState = Yammer_state::staticGet('id', 1);
122         $state = $yammerState ? $yammerState->state || null;
123         
124         switch($state)
125         {
126             case null:
127                 $this->out->element('p', array(), 'Time to start auth:');
128                 $this->showAuthForm();
129                 break;
130             case 'requesting-auth':
131                 $this->out->element('p', array(), 'Need to finish auth!');
132                 $this->showAuthForm();
133                 break;
134             case 'import-users':
135             case 'import-groups':
136             case 'import-messages':
137             case 'save-messages':
138                 $this->showImportState();
139                 break;
140             
141         }
142     }
143
144     /**
145      * Action elements
146      *
147      * @return void
148      */
149     function formActions()
150     {
151         // No submit buttons needed at bottom
152     }
153 }