@@ -32,41 +32,48 @@ class AssetHelper extends EveryDataStoreHelper {
3232 public static function createFolder ($ folderName , $ parentFolder = null ) {
3333 $ member = self ::getMember ();
3434 if ($ member ) {
35- $ Folder = $ parentFolder ? Folder::find_or_make (strtolower ($ parentFolder ->Filename . '/ ' . $ folderName )) : Folder::find_or_make (strtolower ($ folderName ));
36- if ($ Folder ) {
37- $ AdministratorsGroup = Group::get ()->filter (array ('Title ' => 'Administrators ' ))->First ();
38- $ editorGroups = $ member ->CurrentDataStore ()->Groups ()->filter (array (
35+ $ folder = $ parentFolder ? Folder::find_or_make (strtolower ($ parentFolder ->Filename . '/ ' . $ folderName )) : Folder::find_or_make (strtolower ($ folderName ));
36+ if ($ folder ) {
37+ self ::setAssetPermissions ($ folder );
38+ return $ folder ;
39+ }
40+ }
41+ }
42+
43+ /**
44+ * Sets permissions for folder
45+ * @param DataObject $folder
46+ */
47+ public static function setAssetPermissions ($ asset ){
48+ $ administratorsGroup = Group::get ()->filter (array ('Title ' => 'Administrators ' ))->First ();
49+ $ editorGroups = self ::getCurrentDataStore ()->Groups ()->filter (array (
3950 'Permissions.Code ' => array ('CREATE_FILE ' , 'EDIT_FILE ' , 'VIEW_FILE ' , 'DELETE_FILE ' )
4051 ));
4152
4253 if ($ editorGroups ) {
43- $ Folder ->CanEditType = 'OnlyTheseUsers ' ;
54+ $ asset ->CanEditType = 'OnlyTheseUsers ' ;
4455 foreach ($ editorGroups as $ editorGroup ) {
45- $ Folder ->EditorGroups ()->add ($ editorGroup );
56+ $ asset ->EditorGroups ()->add ($ editorGroup );
4657 }
4758 }
4859
49- $ viewerGroups = $ member -> CurrentDataStore ()->Groups ()->filter (array (
60+ $ viewerGroups = self :: getCurrentDataStore ()->Groups ()->filter (array (
5061 'Permissions.Code ' => array ('VIEW_FILE ' )
5162 ));
5263
5364 if ($ viewerGroups ) {
54- $ Folder ->CanViewType = 'OnlyTheseUsers ' ;
65+ $ asset ->CanViewType = 'OnlyTheseUsers ' ;
5566 foreach ($ viewerGroups as $ viewerGroup ) {
56- $ Folder ->ViewerGroups ()->add ($ viewerGroup );
67+ $ asset ->ViewerGroups ()->add ($ viewerGroup );
5768 }
5869 }
5970
60- if ($ AdministratorsGroup ) {
61- $ Folder ->EditorGroups ()->add ($ AdministratorsGroup );
62- $ Folder ->ViewerGroups ()->add ($ AdministratorsGroup );
71+ if ($ administratorsGroup ) {
72+ $ asset ->EditorGroups ()->add ($ administratorsGroup );
73+ $ asset ->ViewerGroups ()->add ($ administratorsGroup );
6374 }
64-
65- return $ Folder ;
66- }
67- }
6875 }
69-
76+
7077 /**
7178 * This function inspects if folder exists
7279 * @param integer $folderID
@@ -169,6 +176,7 @@ public static function createFileFromLocale($fileObject, $localFilePath, $output
169176 }
170177
171178
179+
172180 /**
173181 * This function creates file hash
174182 * @param string $path
0 commit comments