[ Index ] |
|
Code source de b2evolution 2.1.0-beta |
1 <?php 2 /** 3 * This file implements the file types. 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)2005-2006 by PROGIDISTRI - {@link http://progidistri.com/}. 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 * PROGIDISTRI S.A.S. grants Francois PLANQUE the right to license 22 * PROGIDISTRI S.A.S.'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 * @author mbruneau: Marc BRUNEAU / PROGIDISTRI 31 * 32 * @version $Id: file_types.ctrl.php,v 1.1 2007/06/25 10:59:51 fplanque Exp $ 33 */ 34 if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' ); 35 36 37 // Check minimum permission: 38 $current_User->check_perm( 'options', 'view', true ); 39 40 41 $AdminUI->set_path( 'options', 'filetypes' ); 42 43 44 param( 'action', 'string' ); 45 46 if( param( 'ftyp_ID', 'integer', '', true) ) 47 {// Load file type: 48 $FiletypeCache = & get_Cache( 'FiletypeCache' ); 49 if( ($edited_Filetype = & $FiletypeCache->get_by_ID( $ftyp_ID, false )) === false ) 50 { // We could not find the file type to edit: 51 unset( $edited_Filetype ); 52 forget_param( 'ftyp_ID' ); 53 $Messages->head = T_('Cannot edit file type!'); 54 $Messages->add( T_('Requested file type does not exist any longer.'), 'error' ); 55 $action = 'nil'; 56 } 57 } 58 59 if( isset($edited_Filetype) && ($edited_Filetype !== false) ) 60 { // We are editing a division: 61 $AdminUI->append_to_titlearea( '«<a href="'.regenerate_url('action','action=edit'). 62 '">'.$edited_Filetype->dget('name').'</a>»' ); 63 } 64 65 switch( $action ) 66 { 67 68 case 'new': 69 // Check permission: 70 $current_User->check_perm( 'options', 'edit', true ); 71 72 $edited_Filetype = & new Filetype(); 73 $AdminUI->append_to_titlearea( T_('Add a file type...') ); 74 break; 75 76 case 'copy': 77 // Check permission: 78 $current_User->check_perm( 'options', 'edit', true ); 79 80 // Duplicate a file type by prefilling create form: 81 param( 'ftyp_ID', 'integer', true ); 82 $new_Filetype = $edited_Filetype; // COPY 83 $new_Filetype->ID = 0; 84 $edited_Filetype = & $new_Filetype; 85 $AdminUI->append_to_titlearea( T_('Copy file type...') ); 86 break; 87 88 case 'edit': 89 // Edit file type form...: 90 91 // Check permission: 92 $current_User->check_perm( 'options', 'edit', true ); 93 94 // Make sure we got an ftyp_ID: 95 param( 'ftyp_ID', 'integer', true ); 96 break; 97 98 case 'create': 99 // Insert new file type...: 100 $edited_Filetype = & new Filetype(); 101 102 // Check permission: 103 $current_User->check_perm( 'options', 'edit', true ); 104 105 // load data from request 106 if( $edited_Filetype->load_from_Request() ) 107 { // We could load data from form without errors: 108 // Insert in DB: 109 $edited_Filetype->dbinsert(); 110 $Messages->add( T_('New file type created.'), 'success' ); 111 112 // What next? 113 param( 'submit', 'string', true ); 114 if( $submit == T_('Record, then Create Similar') ) // TODO: do not use submit value for this! 115 { 116 $action = 'new'; 117 } 118 elseif( $submit == T_('Record, then Create New') ) // TODO: do not use submit value for this! 119 { 120 $action = 'new'; 121 $edited_Filetype = & new Filetype(); 122 } 123 else 124 { 125 $action = 'list'; 126 } 127 } 128 break; 129 130 case 'update': 131 // Edit file type form...: 132 133 // Check permission: 134 $current_User->check_perm( 'options', 'edit', true ); 135 136 // Make sure we got an ftyp_ID: 137 param( 'ftyp_ID', 'integer', true ); 138 139 // load data from request 140 if( $edited_Filetype->load_from_Request() ) 141 { // We could load data from form without errors: 142 // Update in DB: 143 $edited_Filetype->dbupdate(); 144 $Messages->add( T_('File type updated.'), 'success' ); 145 $action = 'list'; 146 } 147 break; 148 149 case 'delete': 150 // Delete file type: 151 152 // Check permission: 153 $current_User->check_perm( 'options', 'edit', true ); 154 155 // Make sure we got an ftyp_ID: 156 param( 'ftyp_ID', 'integer', true ); 157 158 if( param( 'confirm', 'integer', 0 ) ) 159 { // confirmed, Delete from DB: 160 $msg = sprintf( T_('File type «%s» deleted.'), $edited_Filetype->dget('name') ); 161 $edited_Filetype->dbdelete( true ); 162 unset( $edited_Filetype ); 163 forget_param( 'ftyp_ID' ); 164 $Messages->add( $msg, 'success' ); 165 $action = 'list'; 166 } 167 else 168 { // not confirmed, Check for restrictions: 169 if( ! $edited_Filetype->check_delete( sprintf( T_('Cannot delete file type «%s»'), $edited_Filetype->dget('name') ) ) ) 170 { // There are restrictions: 171 $action = 'view'; 172 } 173 } 174 break; 175 176 } 177 178 179 // Display <html><head>...</head> section! (Note: should be done early if actions do not redirect) 180 $AdminUI->disp_html_head(); 181 182 // Display title, menu, messages, etc. (Note: messages MUST be displayed AFTER the actions) 183 $AdminUI->disp_body_top(); 184 185 186 /** 187 * Display payload: 188 */ 189 switch( $action ) 190 { 191 case 'nil': 192 // Do nothing 193 break; 194 195 196 case 'delete': 197 // We need to ask for confirmation: 198 $edited_Filetype->confirm_delete( 199 sprintf( T_('Delete file type «%s»?'), $edited_Filetype->dget('name') ), 200 $action, get_memorized( 'action' ) ); 201 /* no break */ 202 case 'new': 203 case 'copy': 204 case 'create': // we return in this state after a validation error 205 case 'edit': 206 case 'update': // we return in this state after a validation error 207 $AdminUI->disp_payload_begin(); 208 $AdminUI->disp_view( 'files/views/_filetype.form.php' ); 209 $AdminUI->disp_payload_end(); 210 break; 211 212 213 default: 214 // No specific request, list all file types: 215 // Cleanup context: 216 forget_param( 'ftype_ID' ); 217 // Display file types list: 218 $AdminUI->disp_payload_begin(); 219 $AdminUI->disp_view( 'files/views/_filetype_list.view.php' ); 220 $AdminUI->disp_payload_end(); 221 222 } 223 224 // Display body bottom, debug info and close </html>: 225 $AdminUI->disp_global_footer(); 226 227 /* 228 * $Log: file_types.ctrl.php,v $ 229 * Revision 1.1 2007/06/25 10:59:51 fplanque 230 * MODULES (refactored MVC) 231 * 232 * Revision 1.13 2007/04/26 00:11:13 fplanque 233 * (c) 2007 234 * 235 * Revision 1.12 2006/11/26 01:42:08 fplanque 236 * doc 237 * 238 */ 239 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Thu Nov 29 23:58:50 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |