[ Index ]
 

Code source de b2evolution 2.1.0-beta

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/blogs/inc/collections/ -> coll_settings.ctrl.php (source)

   1  <?php
   2  /**

   3   * This file implements the UI controller for blog params management, including permissions.

   4   *

   5   * This file is part of the evoCore framework - {@link http://evocore.net/}

   6   * See also {@link http://sourceforge.net/projects/evocms/}.

   7   *

   8   * @copyright (c)2003-2007 by Francois PLANQUE - {@link http://fplanque.net/}

   9   * Parts of this file are copyright (c)2004-2006 by Daniel HAHLER - {@link http://thequod.de/contact}.

  10   *

  11   * {@internal License choice

  12   * - If you have received this file as part of a package, please find the license.txt file in

  13   *   the same folder or the closest folder above for complete license terms.

  14   * - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)

  15   *   then you must choose one of the following licenses before using the file:

  16   *   - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php

  17   *   - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php

  18   * }}

  19   *

  20   * {@internal Open Source relicensing agreement:

  21   * Daniel HAHLER grants Francois PLANQUE the right to license

  22   * Daniel HAHLER's contributions to this file and the b2evolution project

  23   * under any OSI approved OSS license (http://www.opensource.org/licenses/).

  24   * }}

  25   *

  26   * @package admin

  27   *

  28   * {@internal Below is a list of authors who have contributed to design/coding of this file: }}

  29   * @author fplanque: Francois PLANQUE.

  30   *

  31   * @todo (sessions) When creating a blog, provide "edit options" (3 tabs) instead of a single long "New" form (storing the new Blog object with the session data).

  32   * @todo Currently if you change the name of a blog it gets not reflected in the blog list buttons!

  33   *

  34   * @version $Id: coll_settings.ctrl.php,v 1.5 2007/11/02 02:45:51 fplanque Exp $

  35   */
  36  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  37  
  38  param_action( 'edit' );
  39  param( 'tab', 'string', 'general', true );
  40  
  41  // Check permissions on requested blog and autoselect an appropriate blog if necessary.

  42  // This will prevent a fat error when switching tabs and you have restricted perms on blog properties.

  43  if( $selected = autoselect_blog( 'blog_properties', 'edit' ) ) // Includes perm check
  44  {    // We have a blog to work on:
  45  
  46      if( set_working_blog( $selected ) )    // set $blog & memorize in user prefs
  47      {    // Selected a new blog:
  48          $BlogCache = & get_Cache( 'BlogCache' );
  49          $Blog = & $BlogCache->get_by_ID( $blog );
  50      }
  51  
  52      /**

  53       * @var Blog

  54       */
  55      $edited_Blog = & $Blog;
  56  }
  57  else
  58  {    // We could not find a blog we have edit perms on...
  59      // Note: we may still have permission to edit categories!!

  60      // redirect to blog list:

  61      header_redirect( '?ctrl=collections' );
  62      // EXITED:

  63      $Messages->add( T_('Sorry, you have no permission to edit blog properties.'), 'error' );
  64      $action = 'nil';
  65      $tab = '';
  66  }
  67  
  68  memorize_param( 'blog', 'integer', -1 );    // Needed when generating static page for example

  69  
  70  if( ( $tab == 'perm' || $tab == 'permgroup' )
  71      && ( empty($blog) || ! $Blog->advanced_perms ) )
  72  {    // We're trying to access advanced perms but they're disabled!
  73      $tab = 'features';    // the screen where you can enable advanced perms

  74      if( $action == 'update' )
  75      { // make sure we don't update anything here
  76          $action = 'edit';
  77      }
  78  }
  79  
  80  
  81  /**

  82   * Perform action:

  83   */
  84  switch( $action )
  85  {
  86      case 'edit':
  87      case 'filter1':
  88      case 'filter2':
  89          // Edit collection form (depending on tab):

  90          // Check permissions:

  91          $current_User->check_perm( 'blog_properties', 'edit', true, $blog );
  92          break;
  93  
  94  
  95      case 'update':
  96          // Update DB:

  97          // Check permissions:

  98          $current_User->check_perm( 'blog_properties', 'edit', true, $blog );
  99  
 100          switch( $tab )
 101          {
 102              case 'general':
 103              case 'urls':
 104                  if( $edited_Blog->load_from_Request( array() ) )
 105                  { // Commit update to the DB:
 106                      $edited_Blog->dbupdate();
 107                      $Messages->add( T_('The blog settings have been updated'), 'success' );
 108                  }
 109                  break;
 110  
 111              case 'features':
 112                  if( $edited_Blog->load_from_Request( array( 'features' ) ) )
 113                  { // Commit update to the DB:
 114                      $edited_Blog->dbupdate();
 115                      $Messages->add( T_('The blog settings have been updated'), 'success' );
 116                  }
 117                  break;
 118  
 119              case 'seo':
 120                  if( $edited_Blog->load_from_Request( array( 'seo' ) ) )
 121                  { // Commit update to the DB:
 122                      $edited_Blog->dbupdate();
 123                      $Messages->add( T_('The blog settings have been updated'), 'success' );
 124                  }
 125                  break;
 126  
 127              case 'skin':
 128                  if( $edited_Blog->load_from_Request( array() ) )
 129                  { // Commit update to the DB:
 130                      $edited_Blog->dbupdate();
 131                      $Messages->add( T_('The blog skin has been changed.') 
 132                                          .' <a href="'.$admin_url.'?ctrl=coll_settings&tab=skin&blog='.$edited_Blog->ID.'">'.T_('Edit...').'</a>', 'success' );
 133                      header_redirect( $edited_Blog->gen_blogurl() );
 134                  }
 135                  break;
 136  
 137              case 'advanced':
 138                  if( $edited_Blog->load_from_Request( array( 'pings' ) ) )
 139                  { // Commit update to the DB:
 140                      $edited_Blog->dbupdate();
 141                      $Messages->add( T_('The blog settings have been updated'), 'success' );
 142                  }
 143                  break;
 144  
 145              case 'perm':
 146                  blog_update_perms( $blog, 'user' );
 147                  $Messages->add( T_('The blog permissions have been updated'), 'success' );
 148                  break;
 149  
 150              case 'permgroup':
 151                  blog_update_perms( $blog, 'group' );
 152                  $Messages->add( T_('The blog permissions have been updated'), 'success' );
 153                  break;
 154          }
 155  
 156          break;
 157  }
 158  
 159  $AdminUI->set_path( 'blogs',  $tab  );
 160  
 161  
 162  /**

 163   * Display page header, menus & messages:

 164   */
 165  $blogListButtons = $AdminUI->get_html_collection_list( 'blog_properties', 'edit',
 166                                              '?ctrl=coll_settings&amp;action=edit&amp;blog=%d&amp;tab='.$tab,
 167                                              T_('List'), '?ctrl=collections&amp;blog=0' );
 168  
 169  // Display <html><head>...</head> section! (Note: should be done early if actions do not redirect)

 170  $AdminUI->disp_html_head();
 171  
 172  // Display title, menu, messages, etc. (Note: messages MUST be displayed AFTER the actions)

 173  $AdminUI->disp_body_top();
 174  
 175  
 176  // Begin payload block:

 177  $AdminUI->disp_payload_begin();
 178  
 179  
 180  // Display VIEW:

 181  switch( $AdminUI->get_path(1) )
 182  {
 183      case 'general':
 184          $next_action = 'update';
 185          $AdminUI->disp_view( 'collections/views/_coll_general.form.php' );
 186          break;
 187  
 188      case 'features':
 189          $AdminUI->disp_view( 'collections/views/_coll_features.form.php' );
 190          break;
 191  
 192      case 'skin':
 193          $AdminUI->disp_view( 'skins/views/_coll_skin.view.php' );
 194          break;
 195  
 196      case 'urls':
 197          $AdminUI->disp_view( 'collections/views/_coll_urls.form.php' );
 198          break;
 199  
 200      case 'seo':
 201          $AdminUI->disp_view( 'collections/views/_coll_seo.form.php' );
 202          break;
 203  
 204      case 'advanced':
 205          $AdminUI->disp_view( 'collections/views/_coll_advanced.form.php' );
 206          break;
 207  
 208      case 'perm':
 209          $AdminUI->disp_view( 'collections/views/_coll_user_perm.form.php' );
 210          break;
 211  
 212      case 'permgroup':
 213          $AdminUI->disp_view( 'collections/views/_coll_group_perm.form.php' );
 214          break;
 215  }
 216  
 217  // End payload block:

 218  $AdminUI->disp_payload_end();
 219  
 220  
 221  // Display body bottom, debug info and close </html>:

 222  $AdminUI->disp_global_footer();
 223  
 224  
 225  /*

 226   * $Log: coll_settings.ctrl.php,v $

 227   * Revision 1.5  2007/11/02 02:45:51  fplanque

 228   * refactored blog settings / UI

 229   *

 230   * Revision 1.4  2007/10/08 10:24:49  fplanque

 231   * UI improvement

 232   *

 233   * Revision 1.3  2007/09/29 03:42:12  fplanque

 234   * skin install UI improvements

 235   *

 236   * Revision 1.2  2007/09/28 09:28:36  fplanque

 237   * per blog advanced SEO settings

 238   *

 239   * Revision 1.1  2007/06/25 10:59:30  fplanque

 240   * MODULES (refactored MVC)

 241   *

 242   * Revision 1.17  2007/06/12 23:16:04  fplanque

 243   * non admins can no longer change admin blog perms

 244   *

 245   * Revision 1.16  2007/05/31 03:02:21  fplanque

 246   * Advanced perms now disabled by default (simpler interface).

 247   * Except when upgrading.

 248   * Enable advanced perms in blog settings -> features

 249   *

 250   * Revision 1.15  2007/05/13 18:49:54  fplanque

 251   * made autoselect_blog() more robust under PHP4

 252   *

 253   * Revision 1.14  2007/04/26 00:11:07  fplanque

 254   * (c) 2007

 255   *

 256   * Revision 1.13  2007/03/07 02:38:58  fplanque

 257   * do some recovery on incorrect $blog

 258   *

 259   * Revision 1.12  2006/12/19 20:33:35  blueyed

 260   * doc/todo

 261   *

 262   * Revision 1.11  2006/12/18 03:20:41  fplanque

 263   * _header will always try to set $Blog.

 264   * controllers can use valid_blog_requested() to make sure we have one

 265   * controllers should call set_working_blog() to change $blog, so that it gets memorized in the user settings

 266   *

 267   * Revision 1.10  2006/12/17 02:42:21  fplanque

 268   * streamlined access to blog settings

 269   *

 270   * Revision 1.9  2006/12/16 01:30:46  fplanque

 271   * Setting to allow/disable email subscriptions on a per blog basis

 272   *

 273   * Revision 1.8  2006/12/10 23:56:26  fplanque

 274   * Worfklow stuff is now hidden by default and can be enabled on a per blog basis.

 275   *

 276   * Revision 1.7  2006/12/03 19:00:30  blueyed

 277   * Moved collection perm JavaScript to the views, as per todo

 278   *

 279   * Revision 1.6  2006/12/03 16:37:14  fplanque

 280   * doc

 281   *

 282   * Revision 1.5  2006/11/24 18:27:22  blueyed

 283   * Fixed link to b2evo CVS browsing interface in file docblocks

 284   *

 285   * Revision 1.4  2006/11/18 17:57:17  blueyed

 286   * blogperms_switch_layout() moved/renamed

 287   */
 288  ?>


Généré le : Thu Nov 29 23:58:50 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics