Dotclear


Ignore:
Timestamp:
09/03/13 14:15:53 (10 years ago)
Author:
Dsls
Branch:
default
Children:
1703:512d631f31bd, 1714:28737e5f6607, 1896:a514b85f3261
Message:

Turned cookies into user_prefs for sections folding/unfolding, closes #1573

File:
1 edited

Legend:

Unmodified
Added
Removed
  • admin/services.php

    r1538 r1699  
    2626$core->rest->addFunction('setPostMeta',array('dcRestMethods','setPostMeta')); 
    2727$core->rest->addFunction('searchMeta',array('dcRestMethods','searchMeta')); 
     28$core->rest->addFunction('setSectionFold',array('dcRestMethods','setSectionFold')); 
    2829 
    2930$core->rest->serve(); 
     
    412413          return $rsp; 
    413414     } 
     415      
     416     public static function setSectionFold($core,$get,$post) 
     417     { 
     418          if (empty($post['section'])) { 
     419               throw new Exception('No section name'); 
     420          } 
     421          if ($core->auth->user_prefs->toggles === null) { 
     422               $core->auth->user_prefs->addWorkspace('toggles'); 
     423          } 
     424          $section = $post['section']; 
     425          $status = isset($post['value']) && ($post['value'] != 0); 
     426          if ($core->auth->user_prefs->toggles->prefExists('unfolded_sections')) { 
     427               $toggles = explode(',',trim($core->auth->user_prefs->toggles->unfolded_sections)); 
     428          } else { 
     429               $toggles = array(); 
     430          } 
     431          $k = array_search($section,$toggles); 
     432          if ($status) { // true == Fold section ==> remove it from unfolded list 
     433               if ($k !== false) { 
     434                    unset($toggles[$k]); 
     435               }  
     436          } else { // false == unfold section ==> add it to unfolded list 
     437               if ($k === false) { 
     438                    $toggles[]=$section; 
     439               };  
     440          } 
     441          $core->auth->user_prefs->toggles->put('unfolded_sections',join(',',$toggles)); 
     442          return true; 
     443     } 
     444           
     445      
    414446} 
    415447?> 
Note: See TracChangeset for help on using the changeset viewer.

Sites map