Version 4.7.8
This commit is contained in:
1 parent
7b7404e741
commit
fd22d99e69
688 files changed
+19814
-10890
No files matched your search
+95
-26
@@ -320,7 +320,7 @@ abstract class _Item extends \IPS\Content
|
||||
case 'hidden_reviews':
|
||||
$val = 0;
|
||||
break;
|
||||
|
||||
|
||||
case 'is_future_entry':
|
||||
$val = ( $time->getTimestamp() > time() ) ? 1 : 0;
|
||||
break;
|
||||
@@ -425,7 +425,7 @@ abstract class _Item extends \IPS\Content
|
||||
{
|
||||
$commentClass = static::$commentClass;
|
||||
|
||||
$comment = $commentClass::create( $obj, $values[ static::$formLangPrefix . 'content' ], TRUE, ( !$member->real_name ) ? NULL : $member->real_name, $obj->hidden() ? FALSE : NULL, $member );
|
||||
$comment = $commentClass::create( $obj, $values[ static::$formLangPrefix . 'content' ], TRUE, ( !$member->real_name ) ? NULL : $member->real_name, $obj->hidden() ? FALSE : NULL, $member, $time );
|
||||
|
||||
$idColumn = static::$databaseColumnId;
|
||||
$commentIdColumn = $commentClass::$databaseColumnId;
|
||||
@@ -560,6 +560,7 @@ abstract class _Item extends \IPS\Content
|
||||
{
|
||||
$val = $val ? $val->pid : NULL;
|
||||
}
|
||||
|
||||
foreach ( \is_array( static::$databaseColumnMap[ $k ] ) ? static::$databaseColumnMap[ $k ] : array( static::$databaseColumnMap[ $k ] ) as $column )
|
||||
{
|
||||
$this->$column = $val;
|
||||
@@ -579,6 +580,12 @@ abstract class _Item extends \IPS\Content
|
||||
$this->setTags( $values[ static::$formLangPrefix . 'tags' ] ?: array() );
|
||||
}
|
||||
|
||||
/* Future Publishing */
|
||||
if( static::canFuturePublish( NULL, $this->containerWrapper() ) and isset( static::$databaseColumnMap['future_date'] ) and isset( $values[ static::$formLangPrefix . 'date'] ) )
|
||||
{
|
||||
$this->setFuturePublishingDates( $values );
|
||||
}
|
||||
|
||||
/* Post before registering */
|
||||
if ( isset( $values['guest_email'] ) and ( !$this->containerWrapper() or !$this->containerWrapper()->can( 'add', \IPS\Member::loggedIn(), FALSE ) ) )
|
||||
{
|
||||
@@ -591,6 +598,29 @@ abstract class _Item extends \IPS\Content
|
||||
\IPS\Request::i()->setCookie( 'post_before_register', $this->_logPostBeforeRegistering( $values['guest_email'], isset( \IPS\Request::i()->cookie['post_before_register'] ) ? \IPS\Request::i()->cookie['post_before_register'] : NULL ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set future publishing dates
|
||||
*
|
||||
* @param array $values Values from form
|
||||
* @return void
|
||||
*/
|
||||
protected function setFuturePublishingDates( array $values )
|
||||
{
|
||||
$time = $values[ static::$formLangPrefix . 'date' ] instanceof \IPS\DateTime ? $values[ static::$formLangPrefix . 'date' ] : new \IPS\DateTime;
|
||||
|
||||
if( isset( static::$databaseColumnMap['date'] ) )
|
||||
{
|
||||
$column = static::$databaseColumnMap['date'];
|
||||
$this->$column = ( $time->getTimestamp() > time() ) ? $time->getTimestamp() : time();
|
||||
}
|
||||
|
||||
if( isset( static::$databaseColumnMap['future_date'] ) )
|
||||
{
|
||||
$column = static::$databaseColumnMap['future_date'];
|
||||
$this->$column = $time->getTimestamp();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Can a given member create this type of content?
|
||||
@@ -688,7 +718,7 @@ abstract class _Item extends \IPS\Content
|
||||
/* Title */
|
||||
if ( isset( static::$databaseColumnMap['title'] ) )
|
||||
{
|
||||
$return['title'] = new \IPS\Helpers\Form\Text( static::$formLangPrefix . 'title', $item ? $item->mapped('title') : ( isset( \IPS\Request::i()->title ) ? \IPS\Request::i()->title : NULL ), TRUE, array( 'maxLength' => \IPS\Settings::i()->max_title_length ?: 255, 'bypassProfanity' => \IPS\Helpers\Form\Text::BYPASS_PROFANITY_SWAP ) );
|
||||
$return['title'] = new \IPS\Helpers\Form\Text( static::$formLangPrefix . 'title', isset( \IPS\Request::i()->title ) ? \IPS\Request::i()->title : $item?->mapped( 'title' ), TRUE, array( 'maxLength' => \IPS\Settings::i()->max_title_length ?: 255, 'bypassProfanity' => \IPS\Helpers\Form\Text::BYPASS_PROFANITY_SWAP ) );
|
||||
$return['title']->rowClasses[] = 'ipsFieldRow_primary';
|
||||
$return['title']->rowClasses[] = 'ipsFieldRow_fullWidth';
|
||||
}
|
||||
@@ -856,20 +886,69 @@ abstract class _Item extends \IPS\Content
|
||||
/* Create form element */
|
||||
if ( $canCreatePoll )
|
||||
{
|
||||
$return['poll'] = new \IPS\Helpers\Form\Poll( static::$formLangPrefix . 'poll', $existingPoll, FALSE, array( 'allowPollOnly' => TRUE ) );
|
||||
$return['poll'] = new \IPS\Helpers\Form\Poll( static::$formLangPrefix . 'poll', $existingPoll, FALSE, array( 'allowPollOnly' => TRUE, 'itemClass' => \get_called_class() ) );
|
||||
}
|
||||
}
|
||||
|
||||
/* Future date */
|
||||
if ( \in_array( 'IPS\Content\FuturePublishing', class_implements( \get_called_class() ) ) and static::canFuturePublish( NULL, $container ) and isset( static::$databaseColumnMap['future_date'] ) )
|
||||
/* Show the future date field for new items or while editing an item, but only if the item wasn't published yet */
|
||||
if ( static::supportsPublishDate( $item ) and static::canFuturePublish( NULL, $container ) )
|
||||
{
|
||||
$column = static::$databaseColumnMap['future_date'];
|
||||
$return['date'] = new \IPS\Helpers\Form\Date( static::$formLangPrefix . 'date', ( $item and $item->$column ) ? \IPS\DateTime::ts( $item->$column ) : 0, FALSE, array( 'time' => TRUE, 'unlimited' => 0, 'unlimitedLang' => 'immediately'), NULL, NULL, NULL, static::$formLangPrefix . 'date' );
|
||||
$return['date'] = static::getPublishDateField( $item );
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Date Field for the publish date
|
||||
*
|
||||
* @param \IPS\Content|NULL $item
|
||||
* @return \IPS\Helpers\Form\Date
|
||||
*/
|
||||
protected static function getPublishDateField( \IPS\Content $item = NULL ): \IPS\Helpers\Form\Date
|
||||
{
|
||||
/* If it's not published, we don't want to allow any past times */
|
||||
$column = static::$databaseColumnMap['future_date'];
|
||||
|
||||
$minFutureTime = static::getMinimumPublishDate();
|
||||
$unlimited = 0;
|
||||
$unlimitedLang = 'immediately';
|
||||
if( $item )
|
||||
{
|
||||
$unlimited = NULL;
|
||||
$unlimitedLang = NULL;
|
||||
}
|
||||
|
||||
return new \IPS\Helpers\Form\Date( static::$formLangPrefix . 'date', ( $item and $item->$column ) ? \IPS\DateTime::ts( $item->$column ) : 0, FALSE, array( 'time' => TRUE, 'unlimited' => $unlimited, 'unlimitedLang' => $unlimitedLang, 'min' => $minFutureTime ), NULL, NULL, NULL, static::$formLangPrefix . 'date' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Can the publish date be changed while editing the item?
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public static bool $allowPublishDateWhileEditing = FALSE;
|
||||
|
||||
/**
|
||||
* Whether this content supports future publish dates
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected static function supportsPublishDate( ?\IPS\Content\Item $item ): bool
|
||||
{
|
||||
return \in_array( 'IPS\Content\FuturePublishing', class_implements( \get_called_class() ) ) and isset( static::$databaseColumnMap['future_date'] ) AND ( ( $item AND ( $item->isFutureDate() OR static::$allowPublishDateWhileEditing ) OR !$item ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the earliest publish date for the new content item , should be the current timestamp for most content types
|
||||
*
|
||||
* @return \IPS\DateTime|null
|
||||
*/
|
||||
protected static function getMinimumPublishDate(): ?\IPS\DateTime
|
||||
{
|
||||
return \IPS\DateTime::create();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the tags form element
|
||||
*
|
||||
@@ -1150,6 +1229,13 @@ abstract class _Item extends \IPS\Content
|
||||
$column = $commentClass::$databaseColumnMap['content'];
|
||||
$idField = $commentClass::$databaseColumnId;
|
||||
|
||||
/* Update the comment date, in case the topic scheduled publish date has changed */
|
||||
if( isset( $values[ static::$formLangPrefix . 'date' ] ) and $values[ static::$formLangPrefix . 'date' ] instanceof \IPS\DateTime and isset( $commentClass::$databaseColumnMap['date'] ) )
|
||||
{
|
||||
$dateColumn = $commentClass::$databaseColumnMap['date'];
|
||||
$commentObj->$dateColumn = $values[ static::$formLangPrefix . 'date' ]->getTimestamp();
|
||||
}
|
||||
|
||||
if ( $commentObj instanceof \IPS\Content\EditHistory and \IPS\Settings::i()->edit_log )
|
||||
{
|
||||
$editIsPublic = \IPS\Member::loggedIn()->group['g_append_edit'] ? $values['comment_log_edit'] : TRUE;
|
||||
@@ -1244,16 +1330,6 @@ abstract class _Item extends \IPS\Content
|
||||
$this->publish();
|
||||
}
|
||||
}
|
||||
elseif ( $container AND ! $this->$column )
|
||||
{
|
||||
if ( $values[ static::$formLangPrefix . 'date' ] instanceof \IPS\DateTime AND $values[ static::$formLangPrefix . 'date' ]->getTimestamp() > time() )
|
||||
{
|
||||
/* Was not future, but now is */
|
||||
$dateColumn = static::$databaseColumnMap['future_date'];
|
||||
$this->$dateColumn = $values[ static::$formLangPrefix . 'date' ]->getTimestamp();
|
||||
$this->unPublish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Post anonymously */
|
||||
@@ -8503,7 +8579,7 @@ abstract class _Item extends \IPS\Content
|
||||
|
||||
$this->$future = 1;
|
||||
}
|
||||
|
||||
|
||||
$this->save();
|
||||
$this->onUnpublish( $member );
|
||||
|
||||
@@ -8541,12 +8617,6 @@ abstract class _Item extends \IPS\Content
|
||||
$this->$future = 0;
|
||||
}
|
||||
|
||||
if ( isset( static::$databaseColumnMap['date'] ) )
|
||||
{
|
||||
$dateField = \is_array( static::$databaseColumnMap['date'] ) ? static::$databaseColumnMap['date'][0] : static::$databaseColumnMap['date'];
|
||||
$this->$dateField = time();
|
||||
}
|
||||
|
||||
$this->save();
|
||||
$this->onPublish( $member );
|
||||
|
||||
@@ -8649,7 +8719,6 @@ abstract class _Item extends \IPS\Content
|
||||
*/
|
||||
public function onUnpublish( $member )
|
||||
{
|
||||
$container = NULL;
|
||||
if ( method_exists( $this, 'container' ) )
|
||||
{
|
||||
try
|
||||
|
||||
Reference in new issue
Block a user