Version 5.0.13
This commit is contained in:
1 parent
b89858b2ff
commit
5efe744c5f
1407 files changed
+69690
-30177
No files matched your search
@@ -154,30 +154,6 @@ class Forums extends Core
|
||||
);
|
||||
break;
|
||||
|
||||
case 'convertForumsQuestionRatings':
|
||||
$return[ $k ] = array(
|
||||
'step_title' => 'convert_forums_question_ratings',
|
||||
'step_method' => 'convertForumsQuestionRatings',
|
||||
'ips_rows' => Db::i()->select( 'COUNT(*)', 'forums_question_ratings' ),
|
||||
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
|
||||
'per_cycle' => 200,
|
||||
'dependencies' => array( 'convertForumsTopics' ),
|
||||
'link_type' => 'forums_question_ratings',
|
||||
);
|
||||
break;
|
||||
|
||||
case 'convertForumsAnswerRatings':
|
||||
$return[ $k ] = array(
|
||||
'step_title' => 'convert_forums_answer_ratings',
|
||||
'step_method' => 'convertForumsAnswerRatings',
|
||||
'ips_rows' => Db::i()->select( 'COUNT(*)', 'forums_answer_ratings' ),
|
||||
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
|
||||
'per_cycle' => 200,
|
||||
'dependencies' => array( 'convertForumsPosts' ),
|
||||
'link_type' => 'forums_answer_ratings',
|
||||
);
|
||||
break;
|
||||
|
||||
case 'convertAttachments':
|
||||
$return[ $k ] = array(
|
||||
'step_title' => 'convert_forums_attachments',
|
||||
@@ -302,7 +278,6 @@ class Forums extends Core
|
||||
'core_ratings' => array( 'class=?', 'IPS\\forums\\Topic\\Post' ),
|
||||
'core_tags' => array( 'tag_meta_app=? AND tag_meta_area=?', 'forums', 'forums' ),
|
||||
'core_voters' => NULL,
|
||||
'forums_question_ratings' => NULL,
|
||||
'forums_topics' => NULL
|
||||
);
|
||||
break;
|
||||
@@ -311,7 +286,6 @@ class Forums extends Core
|
||||
$return['convertForumsPosts'] = array(
|
||||
'core_edit_history' => array( 'class=?', 'IPS\\forums\\Topic\\Post' ),
|
||||
'core_reputation_index' => array( 'app=? AND type=?', 'forums', 'pid' ),
|
||||
'forums_answer_ratings' => NULL,
|
||||
'forums_posts' => NULL
|
||||
);
|
||||
break;
|
||||
@@ -332,14 +306,6 @@ class Forums extends Core
|
||||
$return['convertForumsRssImported'] = array( 'forums_rss_imported' => NULL );
|
||||
break;
|
||||
|
||||
case 'convertForumsQuestionRatings':
|
||||
$return['convertForumsQuestionRatings'] = array( 'forums_question_ratings' => NULL );
|
||||
break;
|
||||
|
||||
case 'convertForumsAnswerRatings':
|
||||
$return['convertForumsAnswerRatings'] = array( 'forums_answer_ratings' => NULL );
|
||||
break;
|
||||
|
||||
case 'convertAttachments':
|
||||
$attachIds = array();
|
||||
foreach( Db::i()->select( 'attachment_id', 'core_attachments_map', array( 'location_key=?', 'forums_Forums' ) ) AS $attachment )
|
||||
@@ -1158,11 +1124,6 @@ class Forums extends Core
|
||||
$info['featured'] = 0;
|
||||
}
|
||||
|
||||
if ( !isset( $info['question_rating'] ) )
|
||||
{
|
||||
$info['question_rating'] = NULL;
|
||||
}
|
||||
|
||||
if ( !isset( $info['topic_hiddenposts'] ) )
|
||||
{
|
||||
$info['topic_hiddenposts'] = 0;
|
||||
@@ -1652,246 +1613,6 @@ class Forums extends Core
|
||||
return parent::convertRssImported( $info, 'forums_rss_import', 'forums_topics' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a question rating
|
||||
*
|
||||
* @param array $info Data to insert
|
||||
* @return int|bool The ID of the newly inserted rating, or FALSE on failure.
|
||||
*/
|
||||
public function convertForumsQuestionRating( array $info=array() ) : bool|int
|
||||
{
|
||||
/* We do not need to store an ID if one isn't present */
|
||||
$hasId = TRUE;
|
||||
if ( !isset( $info['id'] ) )
|
||||
{
|
||||
$hasId = FALSE;
|
||||
}
|
||||
|
||||
/* Everything but the date is required */
|
||||
if ( isset( $info['topic'] ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$info['topic'] = $this->software->app->getLink( $info['topic'], 'forums_topics' );
|
||||
}
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
$this->software->app->log( 'question_rating_missing_question', __METHOD__, App::LOG_WARNING, ( $hasId ) ? $info['id'] : NULL );
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->software->app->log( 'question_rating_missing_question', __METHOD__, App::LOG_WARNING, ( $hasId ) ? $info['id'] : NULL );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( isset( $info['forum'] ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$info['forum'] = $this->software->app->getLink( $info['forum'], 'forums_forums' );
|
||||
}
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
$this->software->app->log( 'question_rating_missing_forum', __METHOD__, App::LOG_WARNING, ( $hasId ) ? $info['id'] : NULL );
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->software->app->log( 'question_rating_missing_forum', __METHOD__, App::LOG_WARNING, ( $hasId ) ? $info['id'] : NULL );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( isset( $info['member'] ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$info['member'] = $this->software->app->getLink( $info['member'], 'core_members', TRUE );
|
||||
}
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
$this->software->app->log( 'question_rating_missing_member', __METHOD__, App::LOG_WARNING, ( $hasId ) ? $info['id'] : NULL );
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->software->app->log( 'question_rating_missing_member', __METHOD__, App::LOG_WARNING, ( $hasId ) ? $info['id'] : NULL );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( !isset( $info['rating'] ) )
|
||||
{
|
||||
$this->software->app->log( 'question_rating_missing_rating', __METHOD__, App::LOG_WARNING, ( $hasId ) ? $info['id'] : NULL );
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( $info['rating'] >= 1 )
|
||||
{
|
||||
$info['rating'] = 1;
|
||||
}
|
||||
else if ( $info['rating'] <= -1 ) # that always looks so weird
|
||||
{
|
||||
$info['rating'] = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->software->app->log( 'question_rating_invalid_rating', __METHOD__, App::LOG_WARNING, ( $hasId ) ? $info['id'] : NULL );
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $info['date'] ) )
|
||||
{
|
||||
if ( $info['date'] instanceof DateTime )
|
||||
{
|
||||
$info['date'] = $info['date']->getTimestamp();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$info['date'] = time();
|
||||
}
|
||||
|
||||
if ( $hasId )
|
||||
{
|
||||
$id = $info['id'];
|
||||
unset( $info['id'] );
|
||||
}
|
||||
|
||||
$inserted_id = Db::i()->insert( 'forums_question_ratings', $info, TRUE );
|
||||
|
||||
if ( $hasId )
|
||||
{
|
||||
$this->software->app->addLink( $inserted_id, $id, 'forums_question_ratings' );
|
||||
}
|
||||
|
||||
return $inserted_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an Answer Rating
|
||||
*
|
||||
* @param array $info Data to insert
|
||||
* @return int|bool The ID of the newly inserted rating, or FALSE on failure.
|
||||
*/
|
||||
public function convertForumsAnswerRating( array $info=array() ) : bool|int
|
||||
{
|
||||
/* We do not need to store an ID if one is not present */
|
||||
$hasId = TRUE;
|
||||
if ( !isset( $info['id'] ) )
|
||||
{
|
||||
$hasId = FALSE;
|
||||
}
|
||||
|
||||
/* Everything but the date is required */
|
||||
if ( isset( $info['post'] ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$info['post'] = $this->software->app->getLink( $info['post'], 'forums_posts' );
|
||||
}
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
$this->software->app->log( 'answer_rating_missing_answer', __METHOD__, App::LOG_WARNING, ( $hasId ) ? $info['id'] : NULL );
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->software->app->log( 'answer_rating_missing_answer', __METHOD__, App::LOG_WARNING, ( $hasId ) ? $info['id'] : NULL );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( isset( $info['member'] ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$info['member'] = $this->software->app->getLink( $info['member'], 'core_members', TRUE );
|
||||
}
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
$this->software->app->log( 'answer_rating_missing_member', __METHOD__, App::LOG_WARNING, ( $hasId ) ? $info['id'] : NULL );
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->software->app->log( 'answer_rating_missing_member', __METHOD__, App::LOG_WARNING, ( $hasId ) ? $info['id'] : NULL );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( !isset( $info['rating'] ) )
|
||||
{
|
||||
$this->software->app->log( 'answer_rating_missing_rating', __METHOD__, App::LOG_WARNING, ( $hasId ) ? $info['id'] : NULL );
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( $info['rating'] >= 1 )
|
||||
{
|
||||
$info['rating'] = 1;
|
||||
}
|
||||
else if ( $info['rating'] <= -1 )
|
||||
{
|
||||
$info['rating'] = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->software->app->log( 'answer_rating_invalid_rating', __METHOD__, App::LOG_WARNING, ( $hasId ) ? $info['id'] : NULL );
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $info['date'] ) )
|
||||
{
|
||||
if ( $info['date'] instanceof DateTime )
|
||||
{
|
||||
$info['date'] = $info['date']->getTimestamp();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$info['date'] = time();
|
||||
}
|
||||
|
||||
if ( isset( $info['topic'] ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$info['topic'] = $this->software->app->getLink( $info['topic'], 'forums_topics' );
|
||||
}
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
$this->software->app->log( 'answer_rating_missing_topic', __METHOD__, App::LOG_WARNING, ( $hasId ) ? $info['id'] : NULL );
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->software->app->log( 'answer_rating_missing_topic', __METHOD__, App::LOG_WARNING, ( $hasId ) ? $info['id'] : NULL );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( $hasId )
|
||||
{
|
||||
$id = $info['id'];
|
||||
unset( $info['id'] );
|
||||
}
|
||||
|
||||
$inserted_id = Db::i()->insert( 'forums_answer_ratings', $info, TRUE );
|
||||
|
||||
if ( $hasId )
|
||||
{
|
||||
$this->software->app->addLink( $inserted_id, $id, 'forums_answer_ratings' );
|
||||
}
|
||||
|
||||
return $inserted_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an Attachment
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user