users can delete there files in one click

add "delete all my files" button to file user so users can delete there files in one click
and add log to cache
This commit is contained in:
munjoob
2018-12-14 00:52:30 +02:00
parent ba80f36b6d
commit e15bce475b
5 changed files with 88 additions and 2 deletions

View File

@@ -61,7 +61,10 @@ return array(
'LOGOUT_ERROR' => 'هناك مشكلة بالخروج',
#'FILECP' => 'إدارة الملفات',
'DEL_SELECTED' => 'حذف المحدد',
#'EDIT_U_FILES' => 'إدارة ملفاتك',
'DEL_ALL' => 'حذف كل ملفاتي',
'ALL_DELETED' => 'تم حذف كل ملفاتك',
'NO_FILES_DELETE' => 'لا تملك ملفات لحذفها',
#'EDIT_U_FILES' => 'إدارة ملفاتك',
'FILES_UPDATED' => 'تم تحديث الملفات بنجاح',
'PUBLIC_USER_FILES' => 'مجلد ملفات العضو',
'FILEUSER' => 'مجلد ملفات',

View File

@@ -50,6 +50,9 @@ return array(
'LOGOUT_SUCCESFUL' => 'Logged out successfully.',
'LOGOUT_ERROR' => 'Logout Error!',
'DEL_SELECTED' => 'Delete selected',
'DEL_ALL' => 'Delete all my files',
'ALL_DELETED' => 'All files has been deleted',
'NO_FILES_DELETE' => 'There is no files to delete them',
'FILES_UPDATED' => 'File updated successfully.',
'PUBLIC_USER_FILES' => 'User files' folder',
'FILEUSER' => 'files' folder',

View File

@@ -85,6 +85,7 @@
<div class="row justify-content-between mb-5">
<div class="col col-md-auto"><input type="submit" name="submit_files" class="btn btn-outline-danger" value="{lang.DEL_SELECTED}" /></div>
<div class="col col-md-auto"><input type="submit" name="submit_all_files" class="btn btn-outline-danger" value="{lang.DEL_ALL}" /></div>
<div class="col col-md-auto">[ <a href="javascript:void(0);" onclick="checkAll(document.c, '_del', 'su');" title="{lang.CHECK_ALL}">{lang.CHECK_ALL}</a> ]</div>
</div>

View File

@@ -108,6 +108,7 @@
<IF NAME="user_himself">
<!-- button -->
<div class="left_button"><input type="submit" name="submit_files" value="{lang.DEL_SELECTED}" /></div>
<div class="left_button"><input type="submit" name="submit_all_files" value="{lang.DEL_ALL}" /></div>
<div class="right_button">[ <a href="javascript:void(0);" onclick="checkAll(document.c, '_del', 'su');" title="{lang.CHECK_ALL}">{lang.CHECK_ALL}</a> ]</div>
{H_FORM_KEYS}
<!-- @end-button -->

80
ucp.php
View File

@@ -381,8 +381,10 @@ switch (g('go'))
if($nums_rows != 0)
{
$no_results = false;
if (!ip('submit_all_files')) // in delete all files we do not need any limit;
{
$query['LIMIT'] = "$start, $perpage";
}
is_array($plugin_run_result = Plugins::getInstance()->run('qr_select_files_in_fileuser', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
$result = $SQL->build($query);
@@ -457,6 +459,37 @@ switch (g('go'))
$sizes += $row['size'];
}
}
if (ip('submit_all_files') && $user_himself)
{
is_array($plugin_run_result = Plugins::getInstance()->run('submit_in_all_fileuser', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
//delete all files
foreach($arr as $row)
{
@kleeja_unlink($row['folder'] . '/' . $row['name'] );
//delete thumb
if (file_exists($row['folder'] . '/thumbs/' . $row['name'] ))
{
@kleeja_unlink($row['folder'] . '/thumbs/' . $row['name'] );
}
$ids[] = $row['id'];
if($is_image)
{
$imgs_num++;
}
else
{
$files_num++;
}
$sizes += $r['size'];
}
}
}
$SQL->freeresult($result_p);
@@ -498,6 +531,51 @@ switch (g('go'))
kleeja_info($lang['NO_FILE_SELECTED'], '', true, $linkgoto, 2);
}
}
if (ip('submit_all_files') && $user_himself)
{
if(isset($ids) && !empty($ids))
{
$query_del = array(
'DELETE' => "{$dbprefix}files",
'WHERE' => "id IN (" . implode(',', $ids) . ")"
);
is_array($plugin_run_result = Plugins::getInstance()->run('qr_del_files_in_filecp', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
$SQL->build($query_del);
if(($files_num <= $stat_files) && ($imgs_num <= $stat_imgs))
{
//update number of stats
$update_query = array(
'UPDATE' => "{$dbprefix}stats",
'SET' => "sizes=sizes-$sizes,files=files-$files_num, imgs=imgs-$imgs_num",
);
$SQL->build($update_query);
}
//write all delete log for current user for last time only
$log_msg=$usrcp->name()." has deleted all his/her files at this time : " . date('H:i a, d-m-Y') . "] \r\n".
"files numbers:".$files_num."\r\n".
"images numbers:".$imgs_num."\r\n";
$last_id=PATH . 'cache/'.$usrcp->id(); //based on user id
file_put_contents($last_id,$log_msg);
//delete all files , show msg
kleeja_info($lang['ALL_DELETED'], '', true, $linkgoto, 2);
}
else
{
//no file selected, show msg
kleeja_info($lang['NO_FILES_DELETE'], '', true, $linkgoto, 2);
}
}
}#num result
is_array($plugin_run_result = Plugins::getInstance()->run('end_fileuser', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook