Dotclear


Ignore:
Timestamp:
04/27/11 09:06:30 (14 years ago)
Author:
Dsls <dsls@…>
Branch:
userprefs
Message:

Ported Franck & Kozlika updates for user prefs, dedicated branch

File:
1 edited

Legend:

Unmodified
Added
Removed
  • admin/index.php

    r0 r3  
    4646$__dashboard_icons = new ArrayObject(); 
    4747 
     48# Dashboard favorites 
    4849$post_count = $core->blog->getPosts(array(),true)->f(0); 
    4950$str_entries = ($post_count > 1) ? __('%d entries') : __('%d entry'); 
     
    5253$str_comments = ($comment_count > 1) ? __('%d comments') : __('%d comment'); 
    5354 
    54 $__dashboard_icons['new_post'] = new ArrayObject(array(__('New entry'),'post.php','images/menu/edit-b.png')); 
    55 $__dashboard_icons['posts'] = new ArrayObject(array(sprintf($str_entries,$post_count),'posts.php','images/menu/entries-b.png')); 
    56 $__dashboard_icons['comments'] = new ArrayObject(array(sprintf($str_comments,$comment_count),'comments.php','images/menu/comments-b.png')); 
    57 $__dashboard_icons['prefs'] = new ArrayObject(array(__('User preferences'),'preferences.php','images/menu/user-pref-b.png')); 
    58  
    59 if ($core->auth->check('admin',$core->blog->id)) 
    60 { 
    61      $__dashboard_icons['blog_pref'] = new ArrayObject(array(__('Blog settings'),'blog_pref.php','images/menu/blog-pref-b.png')); 
    62      $__dashboard_icons['blog_theme'] = new ArrayObject(array(__('Blog appearance'),'blog_theme.php','images/menu/blog-theme-b.png')); 
    63 } 
    64  
    65 $core->callBehavior('adminDashboardIcons', $core, $__dashboard_icons); 
    66  
     55$ws = $core->auth->user_prefs->addWorkspace('favorites'); 
     56$count = 0; 
     57foreach ($ws->dumpPrefs() as $k => $v) { 
     58     // User favorites only 
     59     if (!$v['global']) { 
     60          $fav = unserialize($v['value']); 
     61          if (($fav['permissions'] == '*') || $core->auth->check($fav['permissions'],$core->blog->id)) { 
     62               $count++; 
     63               $title = ($fav['name'] == 'posts' ? sprintf($str_entries,$post_count) :  
     64                    ($fav['name'] == 'comments' ? sprintf($str_comments,$comment_count) : $fav['title'])); 
     65               $__dashboard_icons[$fav['name']] = new ArrayObject(array($title,$fav['url'],$fav['large-icon'])); 
     66          } 
     67     } 
     68}     
     69if (!$count) { 
     70     // Global favorites if any 
     71     foreach ($ws->dumpPrefs() as $k => $v) { 
     72          $fav = unserialize($v['value']); 
     73          if (($fav['permissions'] == '*') || $core->auth->check($fav['permissions'],$core->blog->id)) { 
     74               $count++; 
     75               $title = ($fav['name'] == 'posts' ? sprintf($str_entries,$post_count) :  
     76                    ($fav['name'] == 'comments' ? sprintf($str_comments,$comment_count) : $fav['title'])); 
     77               $__dashboard_icons[$fav['name']] = new ArrayObject(array($title,$fav['url'],$fav['large-icon'])); 
     78          } 
     79     } 
     80} 
     81if (!$count) { 
     82     // No user or global favorites, add "user pref" and "new entry" fav 
     83     if ($core->auth->check('usage,contentadmin',$core->blog->id)) { 
     84          $__dashboard_icons['new_post'] = new ArrayObject(array(__('New entry'),'post.php','images/menu/edit-b.png')); 
     85     } 
     86     $__dashboard_icons['prefs'] = new ArrayObject(array(__('My preferences'),'preferences.php','images/menu/user-pref-b.png')); 
     87} 
    6788 
    6889# Latest news for dashboard 
     
    112133               } 
    113134               $i++; 
    114                if ($i > 7) { break; } 
     135               if ($i > 3) { break; } 
    115136          } 
    116137          $latest_news .= '</dl>'; 
Note: See TracChangeset for help on using the changeset viewer.

Sites map