Dotclear

source: admin/index.php @ 3066:aa297059d2a0

Revision 3066:aa297059d2a0, 13.4 KB checked in by Dsls, 10 years ago (diff)

Disable plugins with unmetdependencies, in admin home and plugins.php admin page. See #1842, fixed partially (need to see how to cope with themes now)

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

Sites map