Version 4.0.13.1

This commit is contained in:
Neo committed 2025-12-19 04:57:54 -08:00
1 parent f9e857d255
commit c6a86f0d9b
7517 files changed
+597400 -668041

No files matched your search

+136
View File
@@ -0,0 +1,136 @@
<?php
/**
* @brief Cover Photo Controller
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @since 20 May 2014
* @version SVN_VERSION_NUMBER
*/
namespace IPS\Helpers\CoverPhoto;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Cover Photo Controller
*/
abstract class _Controller extends \IPS\Dispatcher\Controller
{
/**
* Upload Cover Photo
*
* @return void
*/
protected function coverPhotoUpload()
{
$photo = $this->_coverPhotoGet();
if ( !$photo->editable )
{
\IPS\Output::i()->error( 'no_module_permission', '2S216/1', 403, '' );
}
$form = new \IPS\Helpers\Form( 'coverPhoto' );
$form->class = 'ipsForm_vertical ipsForm_noLabels';
$form->add( new \IPS\Helpers\Form\Upload( 'cover_photo', NULL, TRUE, array( 'image' => TRUE, 'minimize' => FALSE, 'maxFileSize' => ( $photo->maxSize and $photo->maxSize != -1 ) ? $photo->maxSize / 1024 : NULL, 'storageExtension' => $this->_coverPhotoStorageExtension() ) ) );
if ( $values = $form->values() )
{
try
{
$photo->delete();
}
catch ( \Exception $e ) { }
$this->_coverPhotoSet( new \IPS\Helpers\CoverPhoto( $values['cover_photo'], 0 ) );
\IPS\Output::i()->redirect( $_SERVER['HTTP_REFERER'] );
}
\IPS\Output::i()->output = $form->customTemplate( array( call_user_func_array( array( \IPS\Theme::i(), 'getTemplate' ), array( 'forms', 'core' ) ), 'popupTemplate' ) );
}
/**
* Remove Cover Photo
*
* @return void
*/
protected function coverPhotoRemove()
{
\IPS\Session::i()->csrfCheck();
$photo = $this->_coverPhotoGet();
if ( !$photo->editable )
{
\IPS\Output::i()->error( 'no_module_permission', '2S216/2', 403, '' );
}
try
{
$photo->delete();
}
catch ( \Exception $e ) { }
$this->_coverPhotoSet( new \IPS\Helpers\CoverPhoto( NULL, 0 ) );
if ( \IPS\Request::i()->isAjax() )
{
\IPS\Output::i()->json( 'OK' );
}
else
{
\IPS\Output::i()->redirect( $_SERVER['HTTP_REFERER'] );
}
}
/**
* Reposition Cover Photo
*
* @return void
*/
protected function coverPhotoPosition()
{
\IPS\Session::i()->csrfCheck();
$photo = $this->_coverPhotoGet();
if ( !$photo->editable )
{
\IPS\Output::i()->error( 'no_module_permission', '2S216/3', 403, '' );
}
$photo->offset = \IPS\Request::i()->offset;
$this->_coverPhotoSet( $photo );
if ( \IPS\Request::i()->isAjax() )
{
\IPS\Output::i()->json( 'OK' );
}
else
{
\IPS\Output::i()->redirect( $_SERVER['HTTP_REFERER'] );
}
}
/**
* Get Cover Photo Storage Extension
*
* @return string
*/
abstract protected function _coverPhotoStorageExtension();
/**
* Set Cover Photo
*
* @param \IPS\Helpers\CoverPhoto $photo New Photo
* @return void
*/
abstract protected function _coverPhotoSet( \IPS\Helpers\CoverPhoto $photo );
/**
* Get Cover Photo
*
* @return \IPS\Helpers\CoverPhoto
*/
abstract protected function _coverPhotoGet();
}
+96
View File
@@ -0,0 +1,96 @@
<?php
/**
* @brief Cover Photo Helper
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @since 20 May 2014
* @version SVN_VERSION_NUMBER
*/
namespace IPS\Helpers;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Cover Photo Helper
*/
class _CoverPhoto
{
/**
* File
*/
public $file;
/**
* Offset
*/
public $offset = 0;
/**
* Editable
*/
public $editable = FALSE;
/**
* Maximum file size
*/
public $maxSize = NULL;
/**
* Overlay
*/
public $overlay;
/**
* Object
*/
public $object;
/**
* Constructor
*
* @param \IPS\File|NULL $file The file
* @param int $offset The offset
* @param bool $editable User can edit?
*/
public function __construct( \IPS\File $file = NULL, $offset = 0, $editable = FALSE )
{
if( !\IPS\Request::i()->isAjax() )
{
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'front_core.js', 'core' ) );
}
$this->file = $file;
$this->offset = $offset;
}
/**
* Render
*
* @return string
*/
public function __toString()
{
return \IPS\Theme::i()->getTemplate( 'global', 'core' )->coverPhoto( $this->object->url(), $this );
}
/**
* Delete
*
* @return void
*/
public function delete()
{
if ( $this->file )
{
$this->file->delete();
}
}
}
Whitespace-only changes.