Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Stream/CHANGEDB.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,8 @@
++$count;
$sql[$count][0] = '1.3.00';
$sql[$count][1] = "";

//v1.3.01
++$count;
$sql[$count][0] = '1.3.01';
$sql[$count][1] = "";
4 changes: 4 additions & 0 deletions Stream/CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
CHANGELOG
=========

v1.3.01
-------
Added file cleanup feature after a record is deleted

v1.3.00
-------
Added comprehensive file upload tracking system to monitor and manage all file uploads across the system
Expand Down
2 changes: 1 addition & 1 deletion Stream/manifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
$entryURL = 'stream.php';
$type = 'Additional';
$category = 'Other';
$version = '1.3.00';
$version = '1.3.01';
$author = "Gibbon Foundation";
$url = "https://gibbonedu.org";

Expand Down
15 changes: 15 additions & 0 deletions Stream/posts_manage_deleteProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

use Gibbon\Contracts\Filesystem\FileHandler;
use Gibbon\Module\Stream\Domain\PostGateway;
use Gibbon\Module\Stream\Domain\PostAttachmentGateway;

require_once '../../gibbon.php';

Expand All @@ -38,6 +40,8 @@
} else {
// Proceed!
$postGateway = $container->get(PostGateway::class);
$postAttachmentGateway = $container->get(PostAttachmentGateway::class);
$absolutePath = $session->get('absolutePath');
$values = $postGateway->getByID($streamPostID);

if (empty($values)) {
Expand All @@ -46,6 +50,17 @@
exit;
}

$attachments = $postAttachmentGateway->selectBy(['streamPostID' => $streamPostID], ['streamPostAttachmentID', 'thumbnail'])->fetchAll();

foreach ($attachments as $attachment) {
$fileDeleted = $container->get(FileHandler::class)->deleteFile('streamPostAttachment', $attachment['streamPostAttachmentID'], 'attachment');
if (!empty($attachment['thumbnail'])) {
@unlink($absolutePath.'/'.$attachment['thumbnail']);
}
}

$deleted = $postAttachmentGateway->deleteWhere(['streamPostID' => $streamPostID]);

$deleted = $postGateway->delete($streamPostID);

$URL .= !$deleted
Expand Down
15 changes: 6 additions & 9 deletions Stream/posts_manage_edit_deleteProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

use Gibbon\FileUploader;
use Gibbon\Domain\System\SettingGateway;
use Gibbon\Contracts\Filesystem\FileHandler;
use Gibbon\Module\Stream\Domain\PostAttachmentGateway;

$_POST['address'] = '/modules/Stream/posts_manage_edit.php';
Expand All @@ -39,7 +38,6 @@
// Proceed!
$postAttachmentGateway = $container->get(PostAttachmentGateway::class);
$absolutePath = $session->get('absolutePath');
$partialFail = false;

// Validate the required values are present
if (empty($streamPostID) || empty($streamPostAttachmentID)) {
Expand All @@ -56,19 +54,18 @@
exit;
}

// Delete the image files
if (!empty($attachment['attachment'])) {
$partialFail &= !unlink($absolutePath.'/'.$attachment['attachment']);
}
// Delete the tracked attachment file via FileHandler
$deleted = $container->get(FileHandler::class)->deleteFile('streamPostAttachment', $streamPostAttachmentID, 'attachment');

// Delete the thumbnail file directly (not tracked via FileHandler)
if (!empty($attachment['thumbnail'])) {
$partialFail &= !unlink($absolutePath.'/'.$attachment['thumbnail']);
@unlink($absolutePath.'/'.$attachment['thumbnail']);
}

// Delete the record
$deleted = $postAttachmentGateway->delete($streamPostAttachmentID);

$URL .= $partialFail || !$deleted
$URL .= !$deleted
? "&return=warning1"
: "&return=success0";

Expand Down
2 changes: 1 addition & 1 deletion Stream/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@
/**
* Sets version information.
*/
$moduleVersion = '1.3.00';
$moduleVersion = '1.3.01';
$coreVersion = '31.0.00';