setUserDefaultBlog($core->auth->userID(),$core->blog->id); http::redirect('index.php'); } catch (Exception $e) { $core->error->add($e->getMessage()); } } dcPage::check('usage,contentadmin'); # Logout if (!empty($_GET['logout'])) { $core->session->destroy(); if (isset($_COOKIE['dc_admin'])) { unset($_COOKIE['dc_admin']); setcookie('dc_admin',false,-600,'','',DC_ADMIN_SSL); } http::redirect('auth.php'); exit; } # Plugin install $plugins_install = $core->plugins->installModules(); # Check dashboard module prefs $ws = $core->auth->user_prefs->addWorkspace('dashboard'); if (!$core->auth->user_prefs->dashboard->prefExists('doclinks')) { if (!$core->auth->user_prefs->dashboard->prefExists('doclinks',true)) { $core->auth->user_prefs->dashboard->put('doclinks',true,'boolean','',null,true); } $core->auth->user_prefs->dashboard->put('doclinks',true,'boolean'); } if (!$core->auth->user_prefs->dashboard->prefExists('dcnews')) { if (!$core->auth->user_prefs->dashboard->prefExists('dcnews',true)) { $core->auth->user_prefs->dashboard->put('dcnews',true,'boolean','',null,true); } $core->auth->user_prefs->dashboard->put('dcnews',true,'boolean'); } if (!$core->auth->user_prefs->dashboard->prefExists('quickentry')) { if (!$core->auth->user_prefs->dashboard->prefExists('quickentry',true)) { $core->auth->user_prefs->dashboard->put('quickentry',false,'boolean','',null,true); } $core->auth->user_prefs->dashboard->put('quickentry',false,'boolean'); } // Handle folded/unfolded sections in admin from user preferences $ws = $core->auth->user_prefs->addWorkspace('toggles'); if (!$core->auth->user_prefs->toggles->prefExists('unfolded_sections')) { $core->auth->user_prefs->toggles->put('unfolded_sections','','string','Folded sections in admin',null,true); } # Dashboard icons $__dashboard_icons = new ArrayObject(); # Dashboard favorites $post_count = $core->blog->getPosts(array(),true)->f(0); $str_entries = ($post_count > 1) ? __('%d entries') : __('%d entry'); $comment_count = $core->blog->getComments(array(),true)->f(0); $str_comments = ($comment_count > 1) ? __('%d comments') : __('%d comment'); $ws = $core->auth->user_prefs->addWorkspace('favorites'); $count = 0; foreach ($ws->dumpPrefs() as $k => $v) { // User favorites only if (!$v['global']) { $fav = unserialize($v['value']); if (($fav['permissions'] == '*') || $core->auth->check($fav['permissions'],$core->blog->id)) { if (dc_valid_fav($fav['url'])) { $count++; $title = ($fav['name'] == 'posts' ? sprintf($str_entries,$post_count) : ($fav['name'] == 'comments' ? sprintf($str_comments,$comment_count) : $fav['title'])); $__dashboard_icons[$fav['name']] = new ArrayObject(array(__($title),$fav['url'],$fav['large-icon'])); # Let plugins set their own title for favorite on dashboard $core->callBehavior('adminDashboardFavsIcon',$core,$fav['name'],$__dashboard_icons[$fav['name']]); } } } } if (!$count) { // Global favorites if any foreach ($ws->dumpPrefs() as $k => $v) { $fav = unserialize($v['value']); if (($fav['permissions'] == '*') || $core->auth->check($fav['permissions'],$core->blog->id)) { if (dc_valid_fav($fav['url'])) { $count++; $title = ($fav['name'] == 'posts' ? sprintf($str_entries,$post_count) : ($fav['name'] == 'comments' ? sprintf($str_comments,$comment_count) : $fav['title'])); $__dashboard_icons[$fav['name']] = new ArrayObject(array(__($title),$fav['url'],$fav['large-icon'])); # Let plugins set their own title for favorite on dashboard $core->callBehavior('adminDashboardFavsIcon',$core,$fav['name'],$__dashboard_icons[$fav['name']]); } } } } if (!$count) { // No user or global favorites, add "user pref" and "new entry" fav if ($core->auth->check('usage,contentadmin',$core->blog->id)) { $__dashboard_icons['new_post'] = new ArrayObject(array(__('New entry'),'post.php','images/menu/edit-b.png')); } $__dashboard_icons['prefs'] = new ArrayObject(array(__('My preferences'),'preferences.php','images/menu/user-pref-b.png')); } # Latest news for dashboard $__dashboard_items = new ArrayObject(array(new ArrayObject,new ArrayObject)); $dashboardItem = 0; if ($core->auth->user_prefs->dashboard->dcnews) { try { if (empty($__resources['rss_news'])) { throw new Exception(); } $feed_reader = new feedReader; $feed_reader->setCacheDir(DC_TPL_CACHE); $feed_reader->setTimeout(2); $feed_reader->setUserAgent('Dotclear - http://www.dotclear.org/'); $feed = $feed_reader->parse($__resources['rss_news']); if ($feed) { $latest_news = '

'.__('Dotclear news').'

'; $i = 1; foreach ($feed->items as $item) { $dt = isset($item->link) ? ''. $item->title.' ' : $item->title; if ($i < 3) { $latest_news .= '
'.$dt.'
'. '

'.dt::dt2str(__('%d %B %Y:'),$item->pubdate,'Europe/Paris').' '. ''.text::cutString(html::clean($item->content),120).'...

'; } else { $latest_news .= '
'.$dt.'
'. '
'.dt::dt2str(__('%d %B %Y:'),$item->pubdate,'Europe/Paris').'
'; } $i++; if ($i > 2) { break; } } $latest_news .= '
'; $__dashboard_items[$dashboardItem][] = $latest_news; $dashboardItem++; } } catch (Exception $e) {} } # Documentation links if ($core->auth->user_prefs->dashboard->doclinks) { if (!empty($__resources['doc'])) { $doc_links = '

'.__('Documentation and support').'

'; $__dashboard_items[$dashboardItem][] = $doc_links; $dashboardItem++; } } $core->callBehavior('adminDashboardItems', $core, $__dashboard_items); # Dashboard content $dashboardContents = ''; $__dashboard_contents = new ArrayObject(array(new ArrayObject,new ArrayObject)); $core->callBehavior('adminDashboardContents', $core, $__dashboard_contents); /* DISPLAY -------------------------------------------------------- */ dcPage::open(__('Dashboard'), dcPage::jsToolBar(). dcPage::jsLoad('js/_index.js'). # --BEHAVIOR-- adminDashboardHeaders $core->callBehavior('adminDashboardHeaders'), dcPage::breadcrumb( array( ''.__('Dashboard').' : '.html::escapeHTML($core->blog->name).'' => '' ), false) ); # Dotclear updates notifications if ($core->auth->isSuperAdmin() && is_readable(DC_DIGESTS)) { $updater = new dcUpdate(DC_UPDATE_URL,'dotclear',DC_UPDATE_VERSION,DC_TPL_CACHE.'/versions'); $new_v = $updater->check(DC_VERSION); $version_info = $new_v ? $updater->getInfoURL() : ''; if ($updater->getNotify() && $new_v) { echo '

'.sprintf(__('Dotclear %s is available!'),$new_v).'

'. '

'.sprintf(__('Upgrade now'),$new_v).' '. ''.__('Remind me later').''. ($version_info ? '

'. '

'.__('Information about this version').'' : '').'

'. '
'; } } if ($core->auth->getInfo('user_default_blog') != $core->blog->id && $core->auth->blog_count > 1) { echo '

'.__('Make this blog my default blog').'

'; } if ($core->blog->status == 0) { echo '

'.__('This blog is offline').'.

'; } elseif ($core->blog->status == -1) { echo '

'.__('This blog is removed').'.

'; } if (!defined('DC_ADMIN_URL') || !DC_ADMIN_URL) { echo '

'. sprintf(__('%s is not defined, you should edit your configuration file.'),'DC_ADMIN_URL'). ' '.__('See documentation for more information.'). '

'; } if (!defined('DC_ADMIN_MAILFROM') || !DC_ADMIN_MAILFROM) { echo '

'. sprintf(__('%s is not defined, you should edit your configuration file.'),'DC_ADMIN_MAILFROM'). ' '.__('See documentation for more information.'). '

'; } $err = array(); # Check cache directory if ( $core->auth->isSuperAdmin() ) { if (!is_dir(DC_TPL_CACHE) || !is_writable(DC_TPL_CACHE)) { $err[] = '

'.__("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.").'

'; } } else { if (!is_dir(DC_TPL_CACHE) || !is_writable(DC_TPL_CACHE)) { $err[] = '

'.__("The cache directory does not exist or is not writable. You should contact your administrator.").'

'; } } # Check public directory if ( $core->auth->isSuperAdmin() ) { if (!is_dir($core->blog->public_path) || !is_writable($core->blog->public_path)) { $err[] = '

'.__("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).").'

'; } } else { if (!is_dir($core->blog->public_path) || !is_writable($core->blog->public_path)) { $err[] = '

'.__("There is no writable root directory for the media manager. You should contact your administrator.").'

'; } } # Error list if (count($err) > 0) { echo '

Erreur :

'. '
'; } # Plugins install messages if (!empty($plugins_install['success'])) { echo '
'.__('Following plugins have been installed:').'
'; } if (!empty($plugins_install['failure'])) { echo '
'.__('Following plugins have not been installed:').'
'; } # Errors modules notifications if ($core->auth->isSuperAdmin()) { $list = array(); foreach ($core->plugins->getErrors() as $k => $error) { $list[] = '
  • '.$error.'
  • '; } if (count($list) > 0) { echo '

    '.__('Some plugins are installed twice:').'

    '. '
    '; } } # Dashboard columns (processed first, as we need to know the result before displaying the icons.) $dashboardItems = ''; foreach ($__dashboard_items as $i) { if ($i->count() > 0) { $dashboardItems .= ''; foreach ($i as $v) { $dashboardItems .= $v; } $dashboardItems .= ''; } } # Dashboard icons echo '
    '; foreach ($__dashboard_icons as $i) { echo '

    '. '
    '.$i[0].'

    '; } echo '
    '; if ($core->auth->user_prefs->dashboard->quickentry) { if ($core->auth->check('usage,contentadmin',$core->blog->id)) { # Getting categories $categories_combo = dcAdminCombos::getCategoriesCombo( $core->blog->getCategories(array('post_type'=>'post')) ); echo '
    '. '

    '.__('Quick entry').'

    '. '
    '. '

    '.__('New entry').'

    '. '

    '. form::field('post_title',20,255,'','maximal'). '

    '. '

    '. form::textarea('post_content',50,7). '

    '. '

    '. form::combo('cat_id',$categories_combo).'

    '. ($core->auth->check('categories', $core->blog->id) ? '
    '. '

    '.__('Add a new category').'

    '. '

    '. form::field('new_cat_title',30,255,'','').'

    '. '

    '. form::combo('new_cat_parent',$categories_combo,'',''). '

    '. '

    '.__('This category will be created when you will save your post.').'

    '. '
    ' : ''). '

    '. ($core->auth->check('publish',$core->blog->id) ? '' : ''). $core->formNonce(). form::hidden('post_status',-2). form::hidden('post_format',$core->auth->getOption('post_format')). form::hidden('post_excerpt',''). form::hidden('post_lang',$core->auth->getInfo('user_lang')). form::hidden('post_notes',''). '

    '. '
    '. '
    '; } } foreach ($__dashboard_contents as $i) { if ($i->count() > 0) { $dashboardContents .= ''; foreach ($i as $v) { $dashboardContents .= $v; } $dashboardContents .= ''; } } //$class = ' '.(($dashboardItems != '') && ($dashboardContents != '') ? 'two-boxes' : 'one-box'); if ($dashboardContents != '' || $dashboardItems != '') { echo //'
    '. '
    '; echo '
    '. $dashboardItems.$dashboardContents. '
    '; //echo ($dashboardContents ? '
    '.$dashboardContents.'
    ' : ''); //echo ($dashboardItems ? '
    '.$dashboardItems.'
    ' : ''); echo '
    '; } echo '
    '; dcPage::close(); ?>