Skip to content
This repository has been archived by the owner on Aug 2, 2020. It is now read-only.

Commit

Permalink
Merge pull request #1 from samerton/master
Browse files Browse the repository at this point in the history
Default admin perms + minor fixes
  • Loading branch information
sirhypernova authored Dec 19, 2017
2 parents dbc10b0 + fd5336a commit 0f305c0
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
16 changes: 15 additions & 1 deletion init.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,23 @@
*/

// Ensure module has been installed
$cache->setCache('modulescache');

$module_installed = $cache->retrieve('FileManager');
if(!$module_installed){

// Update main admin group permissions
$group = $queries->getWhere('groups', array('id', '=', 2));
$group = $group[0];

$group_permissions = json_decode($group->permissions, TRUE);
$group_permissions['admincp.files'] = 1;
$group_permissions['files.view'] = 1;
$group_permissions['files.write'] = 1;

$group_permissions = json_encode($group_permissions);
$queries->update('groups', 2, array('permissions' => $group_permissions));

$cache->store('FileManager', 1);
} else {
// Installed
}
Expand Down
2 changes: 1 addition & 1 deletion pages/main/includes/footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
});
var imgdata = null;
var pdfdata = null;
<?php if (isset($_GET['medit']) && isset($edit) && is_a($edit,'File') || is_a($edit,'Folder')) { ?>
<?php if (isset($_GET['medit']) && (isset($edit) && is_a($edit,'File') || is_a($edit,'Folder'))) { ?>
$('#edit-modal').modal('open');
$('#edit-file-content').trigger('autoresize');
<?php }
Expand Down
18 changes: 10 additions & 8 deletions pages/main/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@
$filedir = FM_ROOT_DIR;
$afiles = new Files (false,FM_ROOT_DIR,unserialize(FM_ALLOWED_EXTENSIONS),FM_MAX_SIZE);

if (isset($_GET['delete']) && $user->hasPermission('files.write') || $user->data()->id == 1) {
if (isset($_GET['delete']) && ($user->hasPermission('files.write') || $user->data()->id == 1)) {
$file = $afiles->get($_GET['delete']);
if ($file) {
$file->delete();
}
}

if (isset($_GET['edit']) && $user->hasPermission('files.write') || $user->data()->id == 1) {
if (isset($_GET['edit']) && ($user->hasPermission('files.write') || $user->data()->id == 1)) {
$file = $afiles->get($_GET['edit']);
if ($file && isset($_POST['edit-file-sub']) && is_a($file,'File') && $file->editable) {
$file->edit((isset($_POST['edit-file-content'])?$_POST['edit-file-content']:null),(isset($_POST['edit-file-name'])?$_POST['edit-file-name']:null));
Expand All @@ -70,21 +70,21 @@
}
}

if (isset($_GET['rndir']) && $user->hasPermission('files.write') || $user->data()->id == 1) {
if (isset($_GET['rndir']) && ($user->hasPermission('files.write') || $user->data()->id == 1)) {
$dir = $afiles->get($_GET['rndir']);
if ($dir && isset($_POST['edit-file-name']) && is_a($dir,'Folder')) {
$dir->rename($_POST['edit-file-name']);
}
}

if (isset($_GET['unzip']) && $user->hasPermission('files.write') || $user->data()->id == 1) {
if (isset($_GET['unzip']) && ($user->hasPermission('files.write') || $user->data()->id == 1)) {
$file = $afiles->get($_GET['unzip']);
if ($file->ext == 'zip') {
$file->unzip();
}
}

if (isset($_POST['file-upload-sub']) && $user->hasPermission('files.write') || $user->data()->id == 1) {
if (isset($_POST['file-upload-sub']) && ($user->hasPermission('files.write') || $user->data()->id == 1)) {
if (isset($_GET['dir'])) {
$dir = $afiles->get($_GET['dir']);
$dir->upload($_FILES['file-upload']);
Expand All @@ -93,7 +93,7 @@
}
}

if (isset($_POST['new-file-sub']) && $user->hasPermission('files.write') || $user->data()->id == 1) {
if (isset($_POST['new-file-sub']) && ($user->hasPermission('files.write') || $user->data()->id == 1)) {
if (!isset($_POST['new-file-type'])) {
$type = 'file';
} else {
Expand Down Expand Up @@ -126,7 +126,7 @@
die();
}

if (isset($_GET['zip']) && $user->hasPermission('files.write') || $user->data()->id == 1) {
if (isset($_GET['zip']) && ($user->hasPermission('files.write') || $user->data()->id == 1)) {
$file = $afiles->get($_GET['zip']);
if (is_a($file,'Folder')) {
$lfile = $file->zip();
Expand Down Expand Up @@ -180,7 +180,6 @@
<?php
if (isset($_GET['medit'])) {
$edit = $afiles->get($_GET['medit']);
}
?>
<div class="modal" id="edit-modal">
<form action="<?php echo (isset($_GET['medit'])?'?route=/files/&edit='.$_GET['medit']:null).(isset($_GET['dir'])?'&dir='.$_GET['dir']:null); ?>" method="POST" enctype="multipart/form-data">
Expand All @@ -203,6 +202,9 @@
</div>
</form>
</div>
<?php
}
?>
<div class="modal" id="new-modal">
<form action="<?php echo (isset($_GET['dir'])?'?route=/files/&dir='.$_GET['dir']:null); ?>" method="POST" enctype="multipart/form-data">
<div class="modal-content">
Expand Down

0 comments on commit 0f305c0

Please sign in to comment.