Version 4.6.0
This commit is contained in:
1 parent
f79dcf067a
commit
517a5e1f70
2036 files changed
+110041
-26162
No files matched your search
+72
-115
@@ -1015,9 +1015,10 @@ abstract class _Model extends \IPS\Patterns\ActiveRecord
|
||||
* Get last comment time
|
||||
*
|
||||
* @note This should return the last comment time for this node only, not for children nodes
|
||||
* @param \IPS\Member|NULL $member MemberObject
|
||||
* @return \IPS\DateTime|NULL
|
||||
*/
|
||||
public function getLastCommentTime()
|
||||
public function getLastCommentTime( \IPS\Member $member = NULL )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
@@ -1599,6 +1600,54 @@ abstract class _Model extends \IPS\Patterns\ActiveRecord
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Constant allow anonymous items
|
||||
*/
|
||||
const ANON_ITEMS = 1;
|
||||
|
||||
/**
|
||||
* @brief Constant allow anonymous comments
|
||||
*/
|
||||
const ANON_COMMENTS = 2;
|
||||
|
||||
/**
|
||||
* [Node] Does the currently logged in user have permission to post anonymously in this node?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function canPostAnonymously( $where = 0 )
|
||||
{
|
||||
if ( ! isset( static::$contentItemClass ) or ! \in_array( 'IPS\Content\Anonymous', class_implements( static::$contentItemClass ) ) )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if( ! \IPS\Member::loggedIn()->member_id or ! \IPS\Member::loggedIn()->group['gbw_can_post_anonymously'] )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* 1 means both items and comments */
|
||||
if ( $this->allow_anonymous === 1 )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* We are not checking the where, so either is fine */
|
||||
if ( $where === 0 and $this->allow_anonymous > 0 )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* 2 means comments only */
|
||||
if ( $where === static::ANON_COMMENTS and $this->allow_anonymous === 2 )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* !Front-end permissions */
|
||||
|
||||
@@ -2826,114 +2875,6 @@ abstract class _Model extends \IPS\Patterns\ActiveRecord
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Cached array of IDs a member has posted in
|
||||
*/
|
||||
protected $contentPostedIn = array();
|
||||
|
||||
/**
|
||||
* Retrieve an array of IDs a member has posted in.
|
||||
*
|
||||
* @param \IPS\Member|NULL $member The member (NULL for currently logged in member)
|
||||
* @param array|NULL $inSet If supplied, checks will be restricted to only the ids provided
|
||||
* @param array|NULL $additionalWhere Additional where clause
|
||||
* @param array|NULL $commentJoinWhere Additional join clause for comments table
|
||||
* @return array An array of content item ids
|
||||
*/
|
||||
public function contentPostedIn( $member=NULL, $inSet=NULL, $additionalWhere=NULL, $commentJoinWhere=NULL )
|
||||
{
|
||||
if ( $member === NULL )
|
||||
{
|
||||
$member = \IPS\Member::loggedIn();
|
||||
}
|
||||
|
||||
if( !$member->member_id )
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
if ( !isset( static::$contentItemClass ) )
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
$_key = md5( $member->member_id . json_encode( $inSet ) );
|
||||
|
||||
if( isset( $this->contentPostedIn[ $_key ] ) )
|
||||
{
|
||||
return $this->contentPostedIn[ $_key ];
|
||||
}
|
||||
|
||||
$contentItemClass = static::$contentItemClass;
|
||||
$idColumn = static::$databaseColumnId;
|
||||
|
||||
if ( !$contentItemClass::$commentClass )
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
$commentClass = $contentItemClass::$commentClass;
|
||||
|
||||
if ( $contentItemClass::$firstCommentRequired AND \is_array( $inSet ) AND $additionalWhere === NULL AND $commentJoinWhere === NULL )
|
||||
{
|
||||
/* We can do this from one table */
|
||||
$contentItemClass = static::$contentItemClass;
|
||||
$commentClass = $contentItemClass::$commentClass;
|
||||
|
||||
$where = array(
|
||||
array( $commentClass::$databaseTable . '.' . $commentClass::$databasePrefix . $commentClass::$databaseColumnMap['item'] . ' IN(' . implode( ',', $inSet ) . ')' ),
|
||||
array( $commentClass::$databaseTable . '.' . $commentClass::$databasePrefix . $commentClass::$databaseColumnMap['author'] . '=? ', $member->member_id )
|
||||
);
|
||||
|
||||
$items = \IPS\Db::i()->select( $commentClass::$databaseTable . '.' . $commentClass::$databasePrefix . $commentClass::$databaseColumnMap['item'], $commentClass::$databaseTable, $where, NULL, NULL, NULL, NULL, \IPS\Db::SELECT_DISTINCT );
|
||||
|
||||
$ids = array();
|
||||
foreach( $items AS $item )
|
||||
{
|
||||
$ids[$item] = $item;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$where = array();
|
||||
|
||||
if ( $contentItemClass::$firstCommentRequired )
|
||||
{
|
||||
$where[] = array( '(' . $commentClass::$databaseTable . '.' . $commentClass::$databasePrefix . $commentClass::$databaseColumnMap['author'] . '=? )', $member->member_id );
|
||||
}
|
||||
else
|
||||
{
|
||||
$where[] = array( $contentItemClass::$databaseTable . '.' . $contentItemClass::$databasePrefix . $contentItemClass::$databaseColumnMap['container'] . '=?', $this->$idColumn );
|
||||
$where[] = array( '(' . $commentClass::$databaseTable . '.' . $commentClass::$databasePrefix . $commentClass::$databaseColumnMap['author'] . '=? OR ' . $contentItemClass::$databaseTable . '.' . $contentItemClass::$databasePrefix . $contentItemClass::$databaseColumnMap['author'] . '=?)', $member->member_id, $member->member_id );
|
||||
}
|
||||
|
||||
if( \is_array( $inSet ) AND \count( $inSet ) )
|
||||
{
|
||||
$where[] = array( $contentItemClass::$databaseTable . '.' . $contentItemClass::$databasePrefix . $contentItemClass::$databaseColumnId . ' IN(' . implode( ',', $inSet ) . ')' );
|
||||
}
|
||||
|
||||
if ( $additionalWhere )
|
||||
{
|
||||
$where[] = $additionalWhere;
|
||||
}
|
||||
|
||||
$joinClause = array( $commentClass::$databasePrefix . $commentClass::$databaseColumnMap['item'] . '=' . $contentItemClass::$databaseTable . '.' . $contentItemClass::$databasePrefix . $contentItemClass::$databaseColumnId );
|
||||
|
||||
$items = \IPS\Db::i()->select( $contentItemClass::$databaseTable . '.' . $contentItemClass::$databasePrefix . $contentItemClass::$databaseColumnId, $contentItemClass::$databaseTable, $where, NULL, NULL, NULL, NULL, \IPS\Db::SELECT_DISTINCT );
|
||||
$items->join( $commentClass::$databaseTable, ( $commentJoinWhere !== NULL ) ? array( $joinClause, $commentJoinWhere ) : $joinClause );
|
||||
|
||||
$ids = array();
|
||||
foreach( $items AS $item )
|
||||
{
|
||||
$ids[$item] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
$this->contentPostedIn[ $_key ] = $ids;
|
||||
|
||||
return $ids;
|
||||
}
|
||||
|
||||
/**
|
||||
* Alter permissions for an individual group
|
||||
*
|
||||
@@ -3142,7 +3083,12 @@ abstract class _Model extends \IPS\Patterns\ActiveRecord
|
||||
{
|
||||
\IPS\Lang::deleteCustom( ( static::$permApp !== NULL ) ? static::$permApp : 'core', static::$titleLangPrefix . $this->_id . static::$descriptionLangSuffix );
|
||||
}
|
||||
|
||||
|
||||
/* Delete Rss Imports */
|
||||
foreach( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'core_rss_import', array( 'rss_import_class=? AND rss_import_node_id=?', \get_called_class() , $this->id ) ), 'IPS\core\Rss\Import' ) as $import )
|
||||
{
|
||||
$import->delete();
|
||||
}
|
||||
return parent::delete();
|
||||
}
|
||||
|
||||
@@ -3653,11 +3599,12 @@ abstract class _Model extends \IPS\Patterns\ActiveRecord
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
\IPS\Db::i()->insert( 'core_ratings', array(
|
||||
'class' => \get_called_class(),
|
||||
'item_id' => $this->$idColumn,
|
||||
'member' => \IPS\Member::loggedIn()->member_id,
|
||||
'rating' => $values['rating'],
|
||||
'ip' => \IPS\Request::i()->ipAddress()
|
||||
'class' => \get_called_class(),
|
||||
'item_id' => $this->$idColumn,
|
||||
'member' => \IPS\Member::loggedIn()->member_id,
|
||||
'rating' => $values['rating'],
|
||||
'ip' => \IPS\Request::i()->ipAddress(),
|
||||
'rating_date' => time()
|
||||
), TRUE );
|
||||
|
||||
if ( isset( static::$ratingColumnMap['rating_average'] ) )
|
||||
@@ -3753,4 +3700,14 @@ abstract class _Model extends \IPS\Patterns\ActiveRecord
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* [Node] Get the fully qualified node type (mostly for Pages because Pages is Pages)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function fullyQualifiedType()
|
||||
{
|
||||
return static::$nodeTitle . '_sg';
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user