Changeset 68d2d54 in github


Ignore:
Timestamp:
Jan 16, 2011 2:42:40 PM (2 years ago)
Author:
alecpl <alec@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
Children:
a76cbdd
Parents:
88007cf
Message:
  • Move action files map from index.php to steps' func.inc files
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • index.php

    r88007cf r68d2d54  
    195195 
    196196 
    197 // map task/action to a certain include file 
    198 $action_map = array( 
    199   'mail' => array( 
    200     'preview' => 'show.inc', 
    201     'print'   => 'show.inc', 
    202     'moveto'  => 'move_del.inc', 
    203     'delete'  => 'move_del.inc', 
    204     'send'    => 'sendmail.inc', 
    205     'expunge' => 'folders.inc', 
    206     'purge'   => 'folders.inc', 
    207     'remove-attachment'  => 'attachments.inc', 
    208     'display-attachment' => 'attachments.inc', 
    209     'upload' => 'attachments.inc', 
    210     'group-expand' => 'autocomplete.inc', 
    211   ), 
    212    
    213   'addressbook' => array( 
    214     'add' => 'edit.inc', 
    215     'group-create' => 'groups.inc', 
    216     'group-rename' => 'groups.inc', 
    217     'group-delete' => 'groups.inc', 
    218     'group-addmembers' => 'groups.inc', 
    219     'group-delmembers' => 'groups.inc', 
    220   ), 
    221  
    222   'settings' => array( 
    223     'folders'       => 'folders.inc', 
    224     'rename-folder' => 'folders.inc', 
    225     'delete-folder' => 'folders.inc', 
    226     'subscribe'     => 'folders.inc', 
    227     'unsubscribe'   => 'folders.inc', 
    228     'purge'         => 'folders.inc', 
    229     'folder-size'   => 'folders.inc', 
    230     'add-identity'  => 'edit_identity.inc', 
    231   ) 
    232 ); 
    233  
    234197// include task specific functions 
    235198if (is_file($incfile = 'program/steps/'.$RCMAIL->task.'/func.inc')) 
     
    239202$redirects = 0; $incstep = null; 
    240203while ($redirects < 5) { 
    241   $stepfile = !empty($action_map[$RCMAIL->task][$RCMAIL->action]) ? 
    242     $action_map[$RCMAIL->task][$RCMAIL->action] : strtr($RCMAIL->action, '-', '_') . '.inc'; 
    243      
    244204  // execute a plugin action 
    245205  if ($RCMAIL->plugins->is_plugin_task($RCMAIL->task)) { 
     
    252212  } 
    253213  // try to include the step file 
    254   else if (is_file($incfile = 'program/steps/'.$RCMAIL->task.'/'.$stepfile)) { 
     214  else if (($stepfile = $RCMAIL->get_action_file()) 
     215    && is_file($incfile = 'program/steps/'.$RCMAIL->task.'/'.$stepfile) 
     216  ) { 
    255217    include($incfile); 
    256218    $redirects++; 
  • program/include/rcmail.php

    rf5e7b353 r68d2d54  
    116116  private $texts; 
    117117  private $books = array(); 
     118  private $action_map = array(); 
    118119 
    119120 
     
    13231324      rcube_https_check(), true); 
    13241325  } 
     1326 
     1327  /** 
     1328   * Registers action aliases for current task 
     1329   * 
     1330   * @param array $map Alias-to-filename hash array 
     1331   */ 
     1332  public function register_action_map($map) 
     1333  { 
     1334    if (is_array($map)) { 
     1335      foreach ($map as $idx => $val) { 
     1336        $this->action_map[$idx] = $val; 
     1337      } 
     1338    } 
     1339  } 
     1340   
     1341  /** 
     1342   * Returns current action filename 
     1343   * 
     1344   * @param array $map Alias-to-filename hash array 
     1345   */ 
     1346  public function get_action_file() 
     1347  { 
     1348    if (!empty($this->action_map[$this->action])) { 
     1349      return $this->action_map[$this->action]; 
     1350    } 
     1351 
     1352    return strtr($this->action, '-', '_') . '.inc'; 
     1353  } 
     1354 
    13251355} 
    1326  
    1327  
  • program/steps/addressbook/func.inc

    rf5e7b353 r68d2d54  
    294294    'searchform' => array($OUTPUT, 'search_form') 
    295295)); 
     296 
     297// register action aliases 
     298$RCMAIL->register_action_map(array( 
     299    'add' => 'edit.inc', 
     300    'group-create' => 'groups.inc', 
     301    'group-rename' => 'groups.inc', 
     302    'group-delete' => 'groups.inc', 
     303    'group-addmembers' => 'groups.inc', 
     304    'group-delmembers' => 'groups.inc', 
     305)); 
  • program/steps/mail/func.inc

    rf5e7b353 r68d2d54  
    17581758)); 
    17591759 
    1760  
     1760// register action aliases 
     1761$RCMAIL->register_action_map(array( 
     1762    'preview' => 'show.inc', 
     1763    'print'   => 'show.inc', 
     1764    'moveto'  => 'move_del.inc', 
     1765    'delete'  => 'move_del.inc', 
     1766    'send'    => 'sendmail.inc', 
     1767    'expunge' => 'folders.inc', 
     1768    'purge'   => 'folders.inc', 
     1769    'remove-attachment'  => 'attachments.inc', 
     1770    'display-attachment' => 'attachments.inc', 
     1771    'upload'             => 'attachments.inc', 
     1772    'group-expand'       => 'autocomplete.inc', 
     1773)); 
  • program/steps/settings/func.inc

    rf5e7b353 r68d2d54  
    765765)); 
    766766 
     767// register action aliases 
     768$RCMAIL->register_action_map(array( 
     769    'folders'       => 'folders.inc', 
     770    'rename-folder' => 'folders.inc', 
     771    'delete-folder' => 'folders.inc', 
     772    'subscribe'     => 'folders.inc', 
     773    'unsubscribe'   => 'folders.inc', 
     774    'purge'         => 'folders.inc', 
     775    'folder-size'   => 'folders.inc', 
     776    'add-identity'  => 'edit_identity.inc', 
     777)); 
Note: See TracChangeset for help on using the changeset viewer.