File modules/cms/action/FolderAction.class.php
Last commit: Sat Mar 19 12:10:34 2022 +0100 dankert Removed support for: Export, Import, Compress, Uncompress, Extract. This is more comfortable via WebDAV.
1 <?php 2 3 namespace cms\action; 4 5 use cms\base\Configuration; 6 use cms\model\Permission; 7 use cms\model\Folder; 8 9 /** 10 * Action-Klasse zum Bearbeiten eines Ordners. 11 * 12 * @author Jan Dankert 13 */ 14 15 class FolderAction extends ObjectAction 16 { 17 /** 18 * @var Folder 19 */ 20 protected $folder; 21 22 public function __construct() 23 { 24 parent::__construct(); 25 } 26 27 28 public function init() 29 { 30 $folder = new Folder( $this->request->getId() ); 31 $folder->load(); 32 33 $this->lastModified( $folder->lastchangeDate); 34 35 $this->setBaseObject($folder); 36 } 37 38 39 protected function setBaseObject($folder ) { 40 41 $this->folder = $folder; 42 43 parent::setBaseObject( $folder ); 44 } 45 46 47 48 49 50 /** 51 * Ermittelt die maximale Gr��e einer hochzuladenden Datei.<br> 52 * Der Wert wird aus der PHP- und OpenRat-Konfiguration ermittelt.<br> 53 * 54 * @return Integer maximale Dateigroesse in Bytes 55 */ 56 protected function maxFileSize() 57 { 58 // When querying memory size values: 59 // Many ini memory size values, such as upload_max_filesize, 60 // are stored in the php.ini file in shorthand notation. 61 // ini_get() will return the exact string stored in the php.ini file 62 // and NOT its integer equivalent. 63 64 $_10GB = 10 * 1024 * 1024 * 1024; // 10GB 65 $sizes = []; 66 67 foreach( ['upload_max_filesize','post_max_size','memory_limit'] as $setting ) 68 { 69 $memLimit = $this->stringToBytes(ini_get($setting)); 70 71 if ($memLimit ) 72 $sizes[] = $memLimit; 73 } 74 75 $confMaxSize = Configuration::subset(['content','file'])->get('max_file_size',$_10GB) * 1024; 76 77 if ( $confMaxSize ) 78 $sizes[] = $confMaxSize; 79 80 return min($sizes); // Using the minimum of all sizes. 81 } 82 83 /** 84 * Umwandlung von abgek�rzten Bytewerten ("Shorthand Notation") wie 85 * "4M" oder "500K" in eine ganzzahlige Byteanzahl.<br> 86 * <br> 87 * Quelle: http://de.php.net/manual/de/function.ini-get.php 88 * 89 * @param String Abgek�rzter Bytewert 90 * @return Integer Byteanzahl 91 */ 92 protected function stringToBytes($val) 93 { 94 $val = trim($val); 95 $last = strtolower($val[strlen($val)-1]); 96 $val = intval($val); 97 // Achtung: Der Trick ist das "Fallthrough", kein "break" vorhanden! 98 switch($last) 99 { 100 case 'g': 101 $val *= 1024; 102 case 'm': 103 $val *= 1024; 104 case 'k': 105 $val *= 1024; 106 } 107 108 return intval($val); 109 } 110 111 112 /** 113 * Is it allowed to add a new object? 114 * @return bool 115 */ 116 protected function hasPermissionToAddAnyObject() { 117 118 return 119 $this->folder->hasRight( Permission::ACL_CREATE_FILE ) || 120 $this->folder->hasRight( Permission::ACL_CREATE_FOLDER ) || 121 $this->folder->hasRight( Permission::ACL_CREATE_LINK ) || 122 $this->folder->hasRight( Permission::ACL_CREATE_PAGE ); 123 } 124 }
Downloadmodules/cms/action/FolderAction.class.php
History Sat, 19 Mar 2022 12:10:34 +0100 dankert Removed support for: Export, Import, Compress, Uncompress, Extract. This is more comfortable via WebDAV. Sun, 5 Dec 2021 20:33:24 +0100 dankert Cleanup: Removed unusable properties from class 'Value' and 'BaseObject'. Fri, 3 Dec 2021 23:27:44 +0100 dankert New: Only allowed methods are shown in the dropdown menu; Some security enhancements. Sat, 6 Mar 2021 02:50:20 +0100 Jan Dankert New: Enable actions for guest users. Fri, 26 Feb 2021 01:06:01 +0100 Jan Dankert Refactoring accessing the request parameter values. Mon, 4 Jan 2021 19:03:18 +0100 Jan Dankert Refactoring: ACL class is renamed to Permission, because most RBAC/DMAC concepts are calling it a permission. Wed, 18 Nov 2020 00:18:10 +0100 Jan Dankert Refactoring Part 2: Removing all unnecessary methods in the action base classes. Tue, 17 Nov 2020 23:51:00 +0100 Jan Dankert Refactoring: Every Actionmethod has now its own class. Sun, 15 Nov 2020 21:41:39 +0100 Jan Dankert Fix: Reordering of folder content. Wed, 11 Nov 2020 23:24:28 +0100 Jan Dankert Fixing editing value of files,images,texts. Wed, 11 Nov 2020 20:52:26 +0100 Jan Dankert Fix: Advanced view for folder was broken. Sun, 1 Nov 2020 00:36:50 +0100 Jan Dankert Refactoring: Only using the configuration object. Wed, 14 Oct 2020 23:49:54 +0200 Jan Dankert Refactoring: Creating the target instance with a Factory (Java style); Asynchronous publishing of files. Sun, 4 Oct 2020 23:51:41 +0200 Jan Dankert Fix: Now compatible with PHP 7.4. Fri, 2 Oct 2020 23:11:48 +0200 Jan Dankert Cleanup: No '.inputholder' any more, notices with links to objects. Tue, 29 Sep 2020 22:17:11 +0200 Jan Dankert Refactoring: Do not use global constants. Sat, 26 Sep 2020 13:11:23 +0200 Jan Dankert Refactoring: No global variables any more. All constants are capsulated by classes. Sat, 26 Sep 2020 12:20:43 +0200 Jan Dankert Refactoring: No global variables like $SESS any more. All constants are capsulated by classes. Sat, 26 Sep 2020 10:32:02 +0200 Jan Dankert Refactoring: No global $conf array any more. Sat, 26 Sep 2020 04:03:53 +0200 Jan Dankert Refactoring: read language keys with a class. Mon, 21 Sep 2020 22:48:59 +0200 Jan Dankert Complexe refactoring: Moving all generation logic from the model (Value,Page,File) to generators classes. Fri, 18 Sep 2020 23:04:13 +0200 Jan Dankert Refactoring: Renaming module "cms/publish" to "cms/generator" Thu, 10 Sep 2020 18:30:16 +0200 Jan Dankert Some code cleanup, killing the old "checkMenu()"-methods. Thu, 27 Aug 2020 00:32:27 +0200 Jan Dankert Cleanup: Remove unused template components page,tree; remove unused action method 'structure'. Mon, 17 Aug 2020 22:52:37 +0200 Jan Dankert Cleanup: Killing the old odd 'GLOBAL_' message prefixes. Sun, 23 Feb 2020 04:01:30 +0100 Jan Dankert Refactoring with Namespaces for the cms modules, part 1: moving.