mirror of
https://github.com/Yetangitu/ampache
synced 2025-10-05 19:41:55 +02:00
Add an action to clean expired shared objects (fix #618)
This commit is contained in:
parent
e082fe3e4d
commit
e237e1e706
4 changed files with 26 additions and 0 deletions
BIN
images/icon_clean.png
Normal file
BIN
images/icon_clean.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 859 B |
|
@ -74,6 +74,12 @@ class Share extends database_object
|
|||
return Dba::write($sql, $params);
|
||||
}
|
||||
|
||||
public static function gc()
|
||||
{
|
||||
$sql = "DELETE FROM `share` WHERE (`expire_days` > 0 AND (`creation_date` + (`expire_days` * 86400)) < " . time() . ") OR (`max_counter` > 0 AND `counter` >= `max_counter`)";
|
||||
Dba::write($sql);
|
||||
}
|
||||
|
||||
public static function delete_shares($object_type, $object_id)
|
||||
{
|
||||
$sql = "DELETE FROM `share` WHERE `object_type` = ? AND `object_id` = ?";
|
||||
|
|
12
share.php
12
share.php
|
@ -108,6 +108,18 @@ switch ($action) {
|
|||
}
|
||||
UI::show_footer();
|
||||
exit;
|
||||
case 'clean':
|
||||
if (AmpConfig::get('demo_mode')) {
|
||||
UI::access_denied();
|
||||
exit;
|
||||
}
|
||||
|
||||
UI::show_header();
|
||||
Share::gc();
|
||||
$next_url = AmpConfig::get('web_path') . '/stats.php?action=share';
|
||||
show_confirmation(T_('Shared Objects cleaned'), T_('Expired shared objects have been cleaned.'), $next_url);
|
||||
UI::show_footer();
|
||||
exit;
|
||||
case 'external_share':
|
||||
if (AmpConfig::get('demo_mode')) {
|
||||
UI::access_denied();
|
||||
|
|
|
@ -21,5 +21,13 @@
|
|||
*/
|
||||
?>
|
||||
<?php UI::show_box_top(T_('Share')); ?>
|
||||
<div id="information_actions">
|
||||
<ul>
|
||||
<li>
|
||||
<a href="<?php echo AmpConfig::get('web_path'); ?>/share.php?action=clean"><?php echo UI::get_icon('clean', T_('Clean')); ?> Clean expired shared objects</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<?php require_once AmpConfig::get('prefix') . '/templates/show_stats_share.inc.php'; ?>
|
||||
<?php UI::show_box_bottom(); ?>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue