Version 4.7.8

This commit is contained in:
Neo committed 2025-12-19 16:10:42 -08:00
1 parent 7b7404e741
commit fd22d99e69
688 files changed
+19814 -10890

No files matched your search

@@ -62,4 +62,86 @@ class _attachments extends \IPS\Dispatcher\Controller
\IPS\Output::i()->breadcrumb[] = array( NULL, \IPS\Member::loggedIn()->language()->addToStack('my_attachments') );
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('myAttachments')->template( (string) $table, \IPS\Db::i()->select( 'SUM(attach_filesize)', 'core_attachments', array( 'attach_member_id=?', \IPS\Member::loggedIn()->member_id ) )->first(), \IPS\Db::i()->select( 'COUNT(*)', 'core_attachments', array( 'attach_member_id=?', \IPS\Member::loggedIn()->member_id ) )->first() );
}
/**
* Rotate imate
*
* @return void
*/
protected function rotate()
{
\IPS\Session::i()->csrfCheck();
/* Get attachment to make sure it's valid */
try
{
$attachment = \IPS\Db::i()->select( '*', 'core_attachments', [ 'attach_id=? and attach_is_image=?', \IPS\Request::i()->id, 1 ] )
->join( 'core_attachments_map', 'core_attachments.attach_id=core_attachments_map.attachment_id' )
->first();
}
catch( \UnderflowException $e )
{
\IPS\Output::i()->json( array( 'error' => 'node_error' ) );
}
/* Check Permission */
$exploded = explode( '_', $attachment['location_key'] );
try
{
$extensions = \IPS\Application::load( $exploded[0] )->extensions( 'core', 'EditorLocations' );
if ( isset( $extensions[ $exploded[1] ] ) )
{
$attachmentItem = $extensions[ $exploded[1] ]->attachmentLookup( $attachment[ 'id1' ], $attachment[ 'id2' ], $attachment[ 'id3' ] );
}
}
catch ( \OutOfRangeException $e )
{
\IPS\Output::i()->json( array( 'error' => 'no_permission' ) );
}
/* If we have permission to edit the post, we're going to save the rotation angle */
if( $attachmentItem->author()->member_id == \IPS\Member::loggedIn()->member_id OR $attachmentItem->canEdit() )
{
$baseRotation = $attachment['attach_img_rotate'];
$temp = false;
}
else
{
$baseRotation = \IPS\Request::i()->current ?? 0;
$temp = true;
}
$angle = \IPS\Request::i()->direction == 'right' ? 90 : -90;
$rotation = $baseRotation + $angle;
/* Make sure we don't rotate to some stupid number */
if( $rotation >= 360 )
{
$rotation -= 360;
}
elseif( $rotation <= -360 )
{
$rotation += 360;
}
/* Store the angle for the future */
if( !$temp )
{
\IPS\Db::i()->update( 'core_attachments', [ 'attach_img_rotate' => $rotation ], [ 'attach_id=?', $attachment[ 'attach_id' ] ] );
}
if( \IPS\Request::i()->isAjax() )
{
\IPS\Output::i()->json( [
'rotate' => $rotation,
'message' => \IPS\Member::loggedIn()->language()->addToStack('gallery_image_rotated'),
'fileId' => \IPS\Request::i()->id,
'saved' => $temp ? 0 : 1
] );
}
else
{
\IPS\Output::i()->redirect( $attachmentItem->url() );
}
}
}