3 * StatusNet, the distributed open-source microblogging tool
5 * Yammer import administration panel
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.
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.
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/>.
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/
30 if (!defined('STATUSNET')) {
34 class YammeradminpanelAction extends AdminPanelAction
37 * Returns the page title
39 * @return string page title
43 return _m('Yammer Import');
47 * Instructions for using this form.
49 * @return string instructions
51 function getInstructions()
53 return _m('Yammer import tool');
57 * Show the Yammer admin panel form
63 $form = new YammerAdminPanelForm($this);
68 function showStylesheets()
70 parent::showStylesheets();
71 $this->cssLink('plugins/YammerImport/css/admin.css', null, 'screen, projection, tv');
75 class YammerAdminPanelForm extends AdminForm
80 * @return string ID of the form
84 return 'yammeradminpanel';
90 * @return string class of the form
94 return 'form_settings';
100 * @return string URL of the action
104 return common_local_url('yammeradminpanel');
108 * Data elements of the form
114 $runner = YammerRunner::init();
116 switch($runner->state())
119 case 'requesting-auth':
120 $this->showAuthForm();
123 $this->showImportState($runner);
126 private function showAuthForm()
128 $this->out->element('p', array(), 'show an auth form');
131 private function showImportState(YammerRunner $runner)
133 $userCount = $runner->countUsers();
134 $groupCount = $runner->countGroups();
135 $fetchedCount = $runner->countFetchedNotices();
136 $savedCount = $runner->countSavedNotices();
140 'label' => _m("Initialize"),
141 'progress' => _m('No import running'),
142 'complete' => _m('Initiated Yammer server connection...'),
144 'requesting-auth' => array(
145 'label' => _m('Connect to Yammer'),
146 'progress' => _m('Awaiting authorization...'),
147 'complete' => _m('Connected.'),
149 'import-users' => array(
150 'label' => _m('Import user accounts'),
151 'progress' => sprintf(_m("Importing %d user...", "Importing %d users...", $userCount), $userCount),
152 'complete' => sprintf(_m("Imported %d user.", "Imported %d users.", $userCount), $userCount),
154 'import-groups' => array(
155 'label' => _m('Import user groups'),
156 'progress' => sprintf(_m("Importing %d group...", "Importing %d groups...", $groupCount), $groupCount),
157 'complete' => sprintf(_m("Imported %d group.", "Imported %d groups.", $groupCount), $groupCount),
159 'fetch-messages' => array(
160 'label' => _m('Prepare public notices for import'),
161 'progress' => sprintf(_m("Preparing %d notice...", "Preparing %d notices...", $fetchedCount), $fetchedCount),
162 'complete' => sprintf(_m("Prepared %d notice.", "Prepared %d notices.", $fetchedCount), $fetchedCount),
164 'save-messages' => array(
165 'label' => _m('Import public notices'),
166 'progress' => sprintf(_m("Importing %d notice...", "Importing %d notices...", $savedCount), $savedCount),
167 'complete' => sprintf(_m("Imported %d notice.", "Imported %d notices.", $savedCount), $savedCount),
170 'label' => _m('Done'),
171 'progress' => sprintf(_m("Import is complete!")),
172 'complete' => sprintf(_m("Import is complete!")),
175 $steps = array_keys($labels);
176 $currentStep = array_search($runner->state(), $steps);
178 $this->out->elementStart('fieldset', array('class' => 'yammer-import'));
179 $this->out->element('legend', array(), _m('Import status'));
180 foreach ($steps as $step => $state) {
181 if ($step < $currentStep) {
183 $this->progressBar($state,
185 $labels[$state]['label'],
186 $labels[$state]['complete']);
187 } else if ($step == $currentStep) {
188 // This step is in progress
189 $this->progressBar($state,
191 $labels[$state]['label'],
192 $labels[$state]['progress']);
194 // This step has not yet been done.
195 $this->progressBar($state,
197 $labels[$state]['label'],
201 $this->out->elementEnd('fieldset');
204 private function progressBar($state, $class, $label, $status)
206 // @fixme prettify ;)
207 $this->out->elementStart('div', array('class' => "import-step import-step-$state $class"));
208 $this->out->element('div', array('class' => 'import-label'), $label);
209 $this->out->element('div', array('class' => 'import-status'), $status);
210 $this->out->elementEnd('div');
218 function formActions()
220 // No submit buttons needed at bottom