Version 4.1.2
This commit is contained in:
1 parent
3ba79295ee
commit
28bd025b35
1131 files changed
+63658
-20579
No files matched your search
@@ -612,4 +612,76 @@ class _Conversation extends \IPS\Content\Item
|
||||
$this->delete();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Particpant blurb
|
||||
*/
|
||||
public $participantBlurb = NULL;
|
||||
|
||||
/**
|
||||
* Get participant blurb
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function participantBlurb()
|
||||
{
|
||||
if( $this->participantBlurb !== NULL )
|
||||
{
|
||||
return $this->participantBlurb;
|
||||
}
|
||||
|
||||
$people = array();
|
||||
foreach( \IPS\Db::i()->select( 'member_id, name', 'core_members', array( \IPS\Db::i()->in( 'member_id', array_keys( $this->maps() ) ) ) ) as $member )
|
||||
{
|
||||
if ( $member['member_id'] === \IPS\Member::loggedIn()->member_id )
|
||||
{
|
||||
$member['name'] = ( $member['member_id'] == $this->starter_id ) ? \IPS\Member::loggedIn()->language()->addToStack('participant_you_upper') : \IPS\Member::loggedIn()->language()->addToStack('participant_you_lower');
|
||||
}
|
||||
$people[ $member['member_id'] ] = $member['name'];
|
||||
}
|
||||
|
||||
/* Move the starter to the front of the array */
|
||||
$starter = $people[ $this->starter_id ];
|
||||
unset( $people[ $this->starter_id ] );
|
||||
array_unshift( $people, $starter );
|
||||
unset( $starter );
|
||||
|
||||
if ( count( $people ) == 1 )
|
||||
{
|
||||
$id = key( $people );
|
||||
$name = array_pop( $people );
|
||||
$this->participantBlurb = \IPS\Member::loggedIn()->member_id === $id ? \IPS\Member::loggedIn()->language()->addToStack( 'participant_you_upper' ) : $name;
|
||||
}
|
||||
elseif ( count( $people ) == 2 )
|
||||
{
|
||||
$this->participantBlurb = \IPS\Member::loggedIn()->language()->addToStack( 'participant_two', FALSE, array( 'sprintf' => $people ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$count = 0;
|
||||
$others = array();
|
||||
$sprintf = array();
|
||||
foreach( $people as $id => $name )
|
||||
{
|
||||
if ( $count > 1 )
|
||||
{
|
||||
$others[] = $name;
|
||||
}
|
||||
else
|
||||
{
|
||||
$sprintf[] = $name;
|
||||
}
|
||||
|
||||
$count++;
|
||||
}
|
||||
|
||||
$sprintf[] = \IPS\Member::loggedIn()->language()->formatList( $others );
|
||||
$sprintf[] = count( $others );
|
||||
|
||||
$this->participantBlurb = \IPS\Member::loggedIn()->language()->addToStack( 'participant_three_plus', FALSE, array( 'pluralize' => array( count( $others ) ), 'sprintf' => $sprintf ) );
|
||||
}
|
||||
|
||||
return $this->participantBlurb;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user