Dotclear

Changeset 3161:468195e4ad8b


Ignore:
Timestamp:
02/05/16 17:05:45 (10 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
default
Message:

Use new pref type 'array' for some prefs, addresses #1833

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • admin/media.php

    r3153 r3161  
    146146     $nb_last_dirs = (integer)($core->auth->user_prefs->interface->media_nb_last_dirs); 
    147147     if ($nb_last_dirs > 0) { 
    148           $last_dirs = @unserialize($core->auth->user_prefs->interface->media_last_dirs); 
     148          $last_dirs = $core->auth->user_prefs->interface->media_last_dirs; 
    149149          if (!is_array($last_dirs)) { 
    150150               $last_dirs = array(); 
     
    163163          } 
    164164          // Store new list 
    165           $core->auth->user_prefs->interface->put('media_last_dirs',serialize($last_dirs)); 
     165          $core->auth->user_prefs->interface->put('media_last_dirs',$last_dirs); 
    166166     } 
    167167} 
     
    404404if ($nb_last_dirs > 0) { 
    405405     if (!is_array($last_dirs)) { 
    406           $last_dirs = @unserialize($core->auth->user_prefs->interface->media_last_dirs); 
     406          $last_dirs = $core->auth->user_prefs->interface->media_last_dirs; 
    407407     } 
    408408     if (is_array($last_dirs)) { 
  • inc/admin/class.dc.favorites.php

    r3075 r3161  
    5252 
    5353          if ($this->ws->prefExists('favorites')) { 
    54                $this->local_prefs = @unserialize($this->ws->getLocal('favorites')); 
    55                $this->global_prefs = @unserialize($this->ws->getGlobal('favorites')); 
     54               $this->local_prefs = $this->ws->getLocal('favorites'); 
     55               $this->global_prefs = $this->ws->getGlobal('favorites'); 
    5656               // Since we never know what user puts through user:preferences ... 
    5757               if (!is_array($this->local_prefs)) { 
     
    106106               $fattr = $this->fav_defs[$p]; 
    107107          } 
    108           $fattr = array_merge (array('id' => null,'class'=>null),$fattr); 
     108          $fattr = array_merge(array('id' => null,'class' => null),$fattr); 
    109109          if (isset($fattr['permissions'])) { 
    110110               if (is_bool($fattr['permissions']) && !$fattr['permissions'] ) { 
     
    158158          $u = explode('?',$_SERVER['REQUEST_URI']); 
    159159          // Loop over prefs to enable active favorites 
    160           foreach ($this->user_prefs as $k=>&$v) { 
     160          foreach ($this->user_prefs as $k => &$v) { 
    161161               if (isset($v['active_cb']) && is_callable($v['active_cb'])) { 
    162162                    // Use callback if defined to match whether favorite is active or not 
     
    164164               } else { 
    165165                    // Failback active detection. We test against URI name & parameters 
    166                     $v['active']=true; // true until something proves it is false 
     166                    $v['active'] = true; // true until something proves it is false 
    167167                    $u = explode('?',$v['url'],2); 
    168168                    if (!preg_match('/'.preg_quote($u[0],"/").'/',$_SERVER['REQUEST_URI'])) { 
     
    203203               } 
    204204          } 
    205           $this->ws->put('favorites',serialize($this->global_prefs),'string','User favorites',true,true); 
    206           $this->ws->put('favorites',serialize($this->local_prefs)); 
     205          $this->ws->put('favorites',$this->global_prefs,'array','User favorites',true,true); 
     206          $this->ws->put('favorites',$this->local_prefs); 
    207207          $this->user_prefs = $this->getFavorites($this->local_prefs); 
    208208     } 
     
    271271     */ 
    272272     public function setFavoriteIDs($ids,$global=false) { 
    273           $this->ws->put('favorites',serialize($ids),null,null,true,$global); 
     273          $this->ws->put('favorites',$ids,null,null,true,$global); 
    274274     } 
    275275 
     
    307307     */ 
    308308     public function appendMenu($menu) { 
    309           foreach ($this->user_prefs as $k=>$v) { 
     309          foreach ($this->user_prefs as $k => $v) { 
    310310               $menu['Favorites']->addItem( 
    311311                    $v['title'], 
     
    330330     */ 
    331331     public function appendDashboardIcons($icons) { 
    332           foreach ($this->user_prefs as $k=>$v) { 
     332          foreach ($this->user_prefs as $k => $v) { 
    333333               if (isset($v['dashboard_cb']) && is_callable($v['dashboard_cb'])) { 
    334334                    $v = new ArrayObject($v); 
     
    368368     */ 
    369369      public function registerMultiple($data) { 
    370           foreach ($data as $k=>$v) { 
     370          foreach ($data as $k => $v) { 
    371371               $this->register($k,$v); 
    372372          } 
  • inc/dbschema/upgrade.php

    r3159 r3161  
    486486                    settings2array('pings','pings_uris'); 
    487487                    settings2array('system','simpleMenu'); 
     488                    prefs2array('dashboard','favorites'); 
     489                    prefs2array('interface','media_last_dirs'); 
    488490               } 
    489491 
     
    558560          "AND pref_ws = '%s' ". 
    559561          "AND pref_type = 'string'"; 
    560      $rs = $core->con->select(sprintf($strReqSelect,$pref,$ns)); 
     562     $rs = $core->con->select(sprintf($strReqSelect,$pref,$ws)); 
    561563     while ($rs->fetch()) { 
    562564          $value = json_encode(unserialize($rs->pref_value)); 
  • plugins/userPref/index.php

    r3091 r3161  
    2727     try 
    2828     { 
    29           foreach ($_POST['s'] as $ws => $s) 
    30           { 
     29          foreach ($_POST['s'] as $ws => $s) { 
    3130               $core->auth->user_prefs->addWorkspace($ws); 
    32  
    33                foreach ($s as $k => $v)      { 
     31               foreach ($s as $k => $v) { 
     32                    if ($_POST['s_type'][$ws][$k] == 'array') { 
     33                         $v = json_decode($v,true); 
     34                    } 
    3435                    $core->auth->user_prefs->$ws->put($k,$v); 
    3536               } 
     
    5051     try 
    5152     { 
    52           foreach ($_POST['gs'] as $ws => $s) 
    53           { 
     53          foreach ($_POST['gs'] as $ws => $s) { 
    5454               $core->auth->user_prefs->addWorkspace($ws); 
    55  
    56                foreach ($s as $k => $v)      { 
     55               foreach ($s as $k => $v) { 
     56                    if ($_POST['gs_type'][$ws][$k] == 'array') { 
     57                         $v = json_decode($v,true); 
     58                    } 
    5759                    $core->auth->user_prefs->$ws->put($k,$v,null,null,true,true); 
    5860               } 
     
    7678          array(__('yes') => 1, __('no') => 0),$s['value'] ? 1 : 0); 
    7779     } else { 
    78           $field = form::field(array($field_name.'['.$ws.']['.$id.']',$field_name.'_'.$ws.'_'.$id),40,null, 
    79           html::escapeHTML($s['value'])); 
    80      } 
     80          if ($s['type'] == 'array') { 
     81               $field = form::field(array($field_name.'['.$ws.']['.$id.']',$field_name.'_'.$ws.'_'.$id),40,null, 
     82               html::escapeHTML(json_encode($s['value']))); 
     83          } else { 
     84               $field = form::field(array($field_name.'['.$ws.']['.$id.']',$field_name.'_'.$ws.'_'.$id),40,null, 
     85               html::escapeHTML($s['value'])); 
     86          } 
     87     } 
     88     $type = form::hidden(array($field_name.'_type'.'['.$ws.']['.$id.']',$field_name.'_'.$ws.'_'.$id.'_type'), 
     89          html::escapeHTML($s['type'])); 
    8190 
    8291     $slabel = $strong_label ? '<strong>%s</strong>' : '%s'; 
     
    8695     '<td scope="row"><label for="'.$field_name.'_'.$ws.'_'.$id.'">'.sprintf($slabel,html::escapeHTML($id)).'</label></td>'. 
    8796     '<td>'.$field.'</td>'. 
    88      '<td>'.$s['type'].'</td>'. 
     97     '<td>'.$s['type'].$type.'</td>'. 
    8998     '<td>'.html::escapeHTML($s['label']).'</td>'. 
    9099     '</tr>'; 
Note: See TracChangeset for help on using the changeset viewer.

Sites map