Dotclear

source: admin/index.php @ 3557:c5a964cbc258

Revision 3557:c5a964cbc258, 14.5 KB checked in by franck <carnet.franck.paul@…>, 8 years ago (diff)

Add an (super-admin) option to disable Dotclear updates check — update locales

Line 
1<?php
2# -- BEGIN LICENSE BLOCK ---------------------------------------
3#
4# This file is part of Dotclear 2.
5#
6# Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear
7# Licensed under the GPL version 2.0 license.
8# See LICENSE file or
9# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
10#
11# -- END LICENSE BLOCK -----------------------------------------
12
13if (!empty($_GET['pf'])) {
14     require dirname(__FILE__).'/../inc/load_plugin_file.php';
15     exit;
16}
17
18if (!empty($_GET['vf'])) {
19     require dirname(__FILE__).'/../inc/load_var_file.php';
20     exit;
21}
22
23require dirname(__FILE__).'/../inc/admin/prepend.php';
24
25if (!empty($_GET['default_blog'])) {
26     try {
27          $core->setUserDefaultBlog($core->auth->userID(),$core->blog->id);
28          $core->adminurl->redirect("admin.home");
29     } catch (Exception $e) {
30          $core->error->add($e->getMessage());
31     }
32}
33
34dcPage::check('usage,contentadmin');
35
36if ($core->plugins->disableDepModules($core->adminurl->get('admin.home',array()))) {
37     exit;
38}
39
40# Logout
41if (!empty($_GET['logout'])) {
42     $core->session->destroy();
43     if (isset($_COOKIE['dc_admin'])) {
44          unset($_COOKIE['dc_admin']);
45          setcookie('dc_admin',false,-600,'','',DC_ADMIN_SSL);
46     }
47     $core->adminurl->redirect("admin.auth");
48     exit;
49}
50
51# Plugin install
52$plugins_install = $core->plugins->installModules();
53
54# Check dashboard module prefs
55$ws = $core->auth->user_prefs->addWorkspace('dashboard');
56if (!$core->auth->user_prefs->dashboard->prefExists('doclinks')) {
57     if (!$core->auth->user_prefs->dashboard->prefExists('doclinks',true)) {
58          $core->auth->user_prefs->dashboard->put('doclinks',true,'boolean','',null,true);
59     }
60     $core->auth->user_prefs->dashboard->put('doclinks',true,'boolean');
61}
62if (!$core->auth->user_prefs->dashboard->prefExists('dcnews')) {
63     if (!$core->auth->user_prefs->dashboard->prefExists('dcnews',true)) {
64          $core->auth->user_prefs->dashboard->put('dcnews',true,'boolean','',null,true);
65     }
66     $core->auth->user_prefs->dashboard->put('dcnews',true,'boolean');
67}
68if (!$core->auth->user_prefs->dashboard->prefExists('quickentry')) {
69     if (!$core->auth->user_prefs->dashboard->prefExists('quickentry',true)) {
70          $core->auth->user_prefs->dashboard->put('quickentry',false,'boolean','',null,true);
71     }
72     $core->auth->user_prefs->dashboard->put('quickentry',false,'boolean');
73}
74if (!$core->auth->user_prefs->dashboard->prefExists('nodcupdate')) {
75     if (!$core->auth->user_prefs->dashboard->prefExists('nodcupdate',true)) {
76          $core->auth->user_prefs->dashboard->put('nodcupdate',false,'boolean','',null,true);
77     }
78     $core->auth->user_prefs->dashboard->put('nodcupdate',false,'boolean');
79}
80
81// Handle folded/unfolded sections in admin from user preferences
82$ws = $core->auth->user_prefs->addWorkspace('toggles');
83if (!$core->auth->user_prefs->toggles->prefExists('unfolded_sections')) {
84     $core->auth->user_prefs->toggles->put('unfolded_sections','','string','Folded sections in admin',null,true);
85}
86
87
88# Dashboard icons
89$__dashboard_icons = new ArrayObject();
90
91$favs = $core->favs->getUserFavorites();
92$core->favs->appendDashboardIcons($__dashboard_icons);
93
94# Check plugins and themes update from repository
95$checkStoreUpdate = function($mod, $url, $img, $icon)
96{
97     $repo = new dcStore($mod, $url);
98     $upd = $repo->get(true);
99     if (!empty($upd)) {
100          $icon[0] .= '<br />'.sprintf(__('An update is available', '%s updates are available.', count($upd)),count($upd));
101          $icon[1] .= '#update';
102          $icon[2] = 'images/menu/'.$img.'-b-update.png';
103     }
104};
105if (isset($__dashboard_icons['plugins'])) {
106     $checkStoreUpdate($core->plugins, $core->blog->settings->system->store_plugin_url, 'plugins', $__dashboard_icons['plugins']);
107}
108if (isset($__dashboard_icons['blog_theme'])) {
109     $themes = new dcThemes($core);
110     $themes->loadModules($core->blog->themes_path, null);
111     $checkStoreUpdate($themes, $core->blog->settings->system->store_theme_url, 'blog-theme', $__dashboard_icons['blog_theme']);
112}
113
114# Latest news for dashboard
115$__dashboard_items = new ArrayObject(array(new ArrayObject(),new ArrayObject()));
116
117$dashboardItem = 0;
118
119if ($core->auth->user_prefs->dashboard->dcnews) {
120     try
121     {
122          if (empty($__resources['rss_news'])) {
123               throw new Exception();
124          }
125
126          $feed_reader = new feedReader;
127          $feed_reader->setCacheDir(DC_TPL_CACHE);
128          $feed_reader->setTimeout(2);
129          $feed_reader->setUserAgent('Dotclear - http://www.dotclear.org/');
130          $feed = $feed_reader->parse($__resources['rss_news']);
131          if ($feed)
132          {
133               $latest_news = '<div class="box medium dc-box"><h3>'.__('Dotclear news').'</h3><dl id="news">';
134               $i = 1;
135               foreach ($feed->items as $item)
136               {
137                    $dt = isset($item->link) ? '<a href="'.$item->link.'" class="outgoing" title="'.$item->title.'">'.
138                         $item->title.' <img src="images/outgoing-blue.png" alt="" /></a>' : $item->title;
139
140                    if ($i < 3) {
141                         $latest_news .=
142                         '<dt>'.$dt.'</dt>'.
143                         '<dd><p><strong>'.dt::dt2str(__('%d %B %Y:'),$item->pubdate,'Europe/Paris').'</strong> '.
144                         '<em>'.text::cutString(html::clean($item->content),120).'...</em></p></dd>';
145                    } else {
146                         $latest_news .=
147                         '<dt>'.$dt.'</dt>'.
148                         '<dd>'.dt::dt2str(__('%d %B %Y:'),$item->pubdate,'Europe/Paris').'</dd>';
149                    }
150                    $i++;
151                    if ($i > 2) { break; }
152               }
153               $latest_news .= '</dl></div>';
154               $__dashboard_items[$dashboardItem][] = $latest_news;
155               $dashboardItem++;
156          }
157     }
158     catch (Exception $e) {}
159}
160
161# Documentation links
162if ($core->auth->user_prefs->dashboard->doclinks) {
163     if (!empty($__resources['doc']))
164     {
165          $doc_links = '<div class="box small dc-box"><h3>'.__('Documentation and support').'</h3><ul>';
166
167          foreach ($__resources['doc'] as $k => $v) {
168               $doc_links .= '<li><a class="outgoing" href="'.$v.'" title="'.$k.'">'.$k.
169               ' <img src="images/outgoing-blue.png" alt="" /></a></li>';
170          }
171
172          $doc_links .= '</ul></div>';
173          $__dashboard_items[$dashboardItem][] = $doc_links;
174          $dashboardItem++;
175     }
176}
177
178$core->callBehavior('adminDashboardItems', $core, $__dashboard_items);
179
180# Dashboard content
181$__dashboard_contents = new ArrayObject(array(new ArrayObject,new ArrayObject));
182$core->callBehavior('adminDashboardContents', $core, $__dashboard_contents);
183
184# Editor stuff
185$admin_post_behavior = '';
186if ($core->auth->user_prefs->dashboard->quickentry) {
187     if ($core->auth->check('usage,contentadmin',$core->blog->id))
188     {
189          $post_format = $core->auth->getOption('post_format');
190          $post_editor = $core->auth->getOption('editor');
191          if ($post_editor && !empty($post_editor[$post_format])) {
192               // context is not post because of tags not available
193               $admin_post_behavior = $core->callBehavior('adminPostEditor', $post_editor[$post_format], 'quickentry', array('#post_content'),$post_format);
194          }
195     }
196}
197
198/* DISPLAY
199-------------------------------------------------------- */
200dcPage::open(__('Dashboard'),
201     dcPage::jsLoad('js/_index.js').
202     $admin_post_behavior.
203     # --BEHAVIOR-- adminDashboardHeaders
204     $core->callBehavior('adminDashboardHeaders'),
205     dcPage::breadcrumb(
206          array(
207          __('Dashboard').' : '.html::escapeHTML($core->blog->name) => ''
208          ),
209          array('home_link' =>false)
210     )
211);
212
213# Dotclear updates notifications
214if ($core->auth->isSuperAdmin() && !DC_NOT_UPDATE && is_readable(DC_DIGESTS) && !$core->auth->user_prefs->dashboard->nodcupdate)
215{
216     $updater = new dcUpdate(DC_UPDATE_URL,'dotclear',DC_UPDATE_VERSION,DC_TPL_CACHE.'/versions');
217     $new_v = $updater->check(DC_VERSION);
218     $version_info = $new_v ? $updater->getInfoURL() : '';
219
220     if ($updater->getNotify() && $new_v) {
221          // Check PHP version required
222          if (version_compare(phpversion(),$updater->getPHPVersion()) >= 0) {
223               echo
224               '<div class="dc-update"><h3>'.sprintf(__('Dotclear %s is available!'),$new_v).'</h3> '.
225               '<p><a class="button submit" href="'.$core->adminurl->get("admin.update").'">'.sprintf(__('Upgrade now'),$new_v).'</a> '.
226               '<a class="button" href="'.$core->adminurl->get("admin.update", array('hide_msg' => 1)).'">'.__('Remind me later').'</a>'.
227               ($version_info ? ' </p>'.
228               '<p class="updt-info"><a href="'.$version_info.'">'.__('Information about this version').'</a>' : '').'</p>'.
229               '</div>';
230          } else {
231               echo '<p class="info">'.
232                    sprintf(__('A new version of Dotclear is available but needs PHP version ≥ %s, your\'s is currently %s'),
233                         $updater->getPHPVersion(),phpversion()).
234                    '</p>';
235          }
236     } else {
237          if (version_compare(phpversion(),DC_NEXT_REQUIRED_PHP,'<')) {
238               echo '<p class="info">'.
239                    sprintf(__('The next versions of Dotclear will not support PHP version < %s, your\'s is currently %s'),
240                         DC_NEXT_REQUIRED_PHP,phpversion()).
241                    '</p>';
242          }
243     }
244}
245
246if ($core->auth->getInfo('user_default_blog') != $core->blog->id && $core->auth->getBlogCount() > 1) {
247     echo
248     '<p><a href="'.$core->adminurl->get("admin.home",array('default_blog' => 1)).'" class="button">'.__('Make this blog my default blog').'</a></p>';
249}
250
251if ($core->blog->status == 0) {
252     echo '<p class="static-msg">'.__('This blog is offline').'.</p>';
253} elseif ($core->blog->status == -1) {
254     echo '<p class="static-msg">'.__('This blog is removed').'.</p>';
255}
256
257if (!defined('DC_ADMIN_URL') || !DC_ADMIN_URL) {
258     echo
259     '<p class="static-msg">'.
260     sprintf(__('%s is not defined, you should edit your configuration file.'),'DC_ADMIN_URL').
261     ' '.__('See <a href="http://dotclear.org/documentation/2.0/admin/config">documentation</a> for more information.').
262     '</p>';
263}
264
265if (!defined('DC_ADMIN_MAILFROM') || !DC_ADMIN_MAILFROM) {
266     echo
267     '<p class="static-msg">'.
268     sprintf(__('%s is not defined, you should edit your configuration file.'),'DC_ADMIN_MAILFROM').
269     ' '.__('See <a href="http://dotclear.org/documentation/2.0/admin/config">documentation</a> for more information.').
270     '</p>';
271}
272
273$err = array();
274
275# Check cache directory
276if ( $core->auth->isSuperAdmin() ) {
277     if (!is_dir(DC_TPL_CACHE) || !is_writable(DC_TPL_CACHE)) {
278          $err[] = '<p>'.__("The cache directory does not exist or is not writable. You must create this directory with sufficient rights and affect this location to \"DC_TPL_CACHE\" in inc/config.php file.").'</p>';
279     }
280} else {
281     if (!is_dir(DC_TPL_CACHE) || !is_writable(DC_TPL_CACHE)) {
282          $err[] = '<p>'.__("The cache directory does not exist or is not writable. You should contact your administrator.").'</p>';
283     }
284}
285
286# Check public directory
287if ( $core->auth->isSuperAdmin() ) {
288     if (!is_dir($core->blog->public_path) || !is_writable($core->blog->public_path)) {
289          $err[] = '<p>'.__("There is no writable directory /public/ at the location set in about:config \"public_path\". You must create this directory with sufficient rights (or change this setting).").'</p>';
290     }
291} else {
292     if (!is_dir($core->blog->public_path) || !is_writable($core->blog->public_path)) {
293          $err[] = '<p>'.__("There is no writable root directory for the media manager. You should contact your administrator.").'</p>';
294     }
295}
296
297# Error list
298if (count($err) > 0) {
299     echo '<div class="error"><p><strong>'.__('Error:').'</strong></p>'.
300     '<ul><li>'.implode("</li><li>",$err).'</li></ul></div>';
301}
302
303# Plugins install messages
304if (!empty($plugins_install['success']))
305{
306     echo '<div class="success">'.__('Following plugins have been installed:').'<ul>';
307     foreach ($plugins_install['success'] as $k => $v) {
308          echo '<li>'.$k.'</li>';
309     }
310     echo '</ul></div>';
311}
312if (!empty($plugins_install['failure']))
313{
314     echo '<div class="error">'.__('Following plugins have not been installed:').'<ul>';
315     foreach ($plugins_install['failure'] as $k => $v) {
316          echo '<li>'.$k.' ('.$v.')</li>';
317     }
318     echo '</ul></div>';
319}
320# Errors modules notifications
321if ($core->auth->isSuperAdmin())
322{
323     $list = $core->plugins->getErrors();
324     if (!empty($list)) {
325          echo
326          '<div class="error" id="module-errors" class="error"><p>'.__('Errors have occured with following plugins:').'</p> '.
327          '<ul><li>'.implode("</li>\n<li>", $list).'</li></ul></div>';
328     }
329}
330
331# Dashboard items and contents (processed first, as we need to know the result before displaying the icons.)
332$dashboardItems = '';
333foreach ($__dashboard_items as $i)
334{
335     foreach ($i as $v) {
336          $dashboardItems .= $v;
337     }
338}
339$dashboardContents = '';
340foreach ($__dashboard_contents as $i)
341{
342     foreach ($i as $v) {
343          $dashboardContents .= $v;
344     }
345}
346
347# Dashboard elements: icons then boxes (items then contents)
348echo '<div id="dashboard-main">';
349
350if (!$core->auth->user_prefs->dashboard->nofavicons) {
351     # Dashboard icons
352     echo '<div id="icons">';
353     foreach ($__dashboard_icons as $i)
354     {
355          echo
356          '<p><a href="'.$i[1].'"><img src="'.dc_admin_icon_url($i[2]).'" alt="" />'.
357          '<br /><span>'.$i[0].'</span></a></p>';
358     }
359     echo '</div>';
360}
361
362if ($core->auth->user_prefs->dashboard->quickentry) {
363     if ($core->auth->check('usage,contentadmin',$core->blog->id))
364     {
365          # Getting categories
366          $categories_combo = dcAdminCombos::getCategoriesCombo(
367               $core->blog->getCategories(array())
368          );
369
370          echo
371          '<div id="quick">'.
372          '<h3>'.__('Quick entry').sprintf(' &rsaquo; %s',$core->auth->getOption('post_format')).'</h3>'.
373          '<form id="quick-entry" action="'.$core->adminurl->get('admin.post').'" method="post" class="fieldset">'.
374          '<h4>'.__('New entry').'</h4>'.
375          '<p class="col"><label for="post_title" class="required"><abbr title="'.__('Required field').'">*</abbr> '.__('Title:').'</label>'.
376          form::field('post_title',20,255,'','maximal').
377          '</p>'.
378          '<p class="area"><label class="required" '.
379          'for="post_content"><abbr title="'.__('Required field').'">*</abbr> '.__('Content:').'</label> '.
380          form::textarea('post_content',50,10).
381          '</p>'.
382          '<p><label for="cat_id" class="classic">'.__('Category:').'</label> '.
383          form::combo('cat_id',$categories_combo).'</p>'.
384          ($core->auth->check('categories', $core->blog->id)
385               ? '<div>'.
386               '<p id="new_cat" class="q-cat">'.__('Add a new category').'</p>'.
387               '<p class="q-cat"><label for="new_cat_title">'.__('Title:').'</label> '.
388               form::field('new_cat_title',30,255,'','').'</p>'.
389               '<p class="q-cat"><label for="new_cat_parent">'.__('Parent:').'</label> '.
390               form::combo('new_cat_parent',$categories_combo,'','').
391               '</p>'.
392               '<p class="form-note info clear">'.__('This category will be created when you will save your post.').'</p>'.
393               '</div>'
394               : '').
395          '<p><input type="submit" value="'.__('Save').'" name="save" /> '.
396          ($core->auth->check('publish',$core->blog->id)
397               ? '<input type="hidden" value="'.__('Save and publish').'" name="save-publish" />'
398               : '').
399          $core->formNonce().
400          form::hidden('post_status',-2).
401          form::hidden('post_format',$core->auth->getOption('post_format')).
402          form::hidden('post_excerpt','').
403          form::hidden('post_lang',$core->auth->getInfo('user_lang')).
404          form::hidden('post_notes','').
405          '</p>'.
406          '</form>'.
407          '</div>';
408     }
409}
410
411if ($dashboardContents != '' || $dashboardItems != '') {
412     echo
413     '<div id="dashboard-boxes">'.
414     ($dashboardItems != '' ? '<div class="db-items">'.$dashboardItems.'</div>' : '').
415     ($dashboardContents != '' ? '<div class="db-contents">'.$dashboardContents.'</div>' : '').
416     '</div>';
417}
418
419echo '</div>'; #end dashboard-main
420dcPage::helpBlock('core_dashboard');
421dcPage::close();
Note: See TracBrowser for help on using the repository browser.

Sites map