Version 4.5.0
This commit is contained in:
1 parent
1a0c7fd3c2
commit
f79dcf067a
3791 files changed
+248032
-76372
No files matched your search
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\Support;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -69,7 +69,7 @@ class _Stream extends \IPS\Patterns\ActiveRecord
|
||||
/**
|
||||
* Get my stream
|
||||
*
|
||||
* @return \IPS\nexus\Support\Stream
|
||||
* @return static
|
||||
*/
|
||||
public static function myStream()
|
||||
{
|
||||
@@ -88,7 +88,9 @@ class _Stream extends \IPS\Patterns\ActiveRecord
|
||||
/**
|
||||
* Load
|
||||
*
|
||||
* @param mixed $keyOrId The key or ID number
|
||||
* @param mixed $id The key or ID number
|
||||
* @param string|NULL $idField The field to search `$id` in
|
||||
* @param mixed $extraWhereClause Extra where clause or NULL
|
||||
* @return \IPS\nexus\Support\Stream
|
||||
*/
|
||||
public static function load( $id, $idField=NULL, $extraWhereClause=NULL )
|
||||
@@ -155,12 +157,12 @@ class _Stream extends \IPS\Patterns\ActiveRecord
|
||||
* Customer Stream
|
||||
*
|
||||
* @param \IPS\nexus\Customer $customer The customer
|
||||
* @return \IPS\nexus\Support\Stream
|
||||
* @return static
|
||||
*/
|
||||
public static function customer( \IPS\nexus\Customer $customer )
|
||||
{
|
||||
$return = new static;
|
||||
$return->title = sprintf( \IPS\Member::loggedIn()->language()->get( 'members_support_requests' ), $customer->cm_name );
|
||||
$return->title = sprintf( \IPS\Member::loggedIn()->language()->get( 'members_support_requests' ), $customer->member_id ? $customer->cm_name : $customer->email );
|
||||
$return->departments = NULL;
|
||||
$return->statuses = NULL;
|
||||
$return->severities = NULL;
|
||||
@@ -179,7 +181,7 @@ class _Stream extends \IPS\Patterns\ActiveRecord
|
||||
* Create from form
|
||||
*
|
||||
* @param array $values Values from the form
|
||||
* @return \IPS\nexus\Support\Stream
|
||||
* @return static
|
||||
*/
|
||||
public static function createFromForm( $values )
|
||||
{
|
||||
@@ -200,16 +202,25 @@ class _Stream extends \IPS\Patterns\ActiveRecord
|
||||
*/
|
||||
public function updateFromForm( $values )
|
||||
{
|
||||
foreach ( array( 'r_started', 'r_last_new_reply', 'r_last_reply', 'r_last_staff_reply' ) as $k )
|
||||
{
|
||||
if ( \is_array( $values[ $k ] ) and isset( $values[ $k ][2] ) and $values[ $k ][2] != 'h' )
|
||||
{
|
||||
$values[ $k ][1] = \IPS\Helpers\Form\Interval::convertValue( $values[ $k ][1], $values[ $k ][2], \IPS\Helpers\Form\Interval::HOURS );
|
||||
unset( $values[ $k ][2] );
|
||||
}
|
||||
}
|
||||
|
||||
$this->departments = $values['r_department'] ?: NULL;
|
||||
$this->statuses = $values['r_status'] ?: NULL;
|
||||
$this->severities = $values['r_severity'] ?: NULL;
|
||||
$this->staff = $values['r_staff'] ?: NULL;
|
||||
$this->from_email = $values['r_email'] ?: NULL;
|
||||
$this->search_term = $values['r_search'] ?: NULL;
|
||||
$this->started = $values['r_started'] ?: NULL;
|
||||
$this->last_new_reply = $values['r_last_new_reply'] ?: NULL;
|
||||
$this->last_reply = $values['r_last_reply'] ?: NULL;
|
||||
$this->last_staff_reply = $values['r_last_staff_reply'] ?: NULL;
|
||||
$this->started = $values['r_started'][1] ? json_encode($values['r_started']): NULL;
|
||||
$this->last_new_reply = $values['r_last_new_reply'][1] ? json_encode($values['r_last_new_reply']): NULL;
|
||||
$this->last_reply = $values['r_last_reply'][1] ? json_encode($values['r_last_reply']): NULL;
|
||||
$this->last_staff_reply = $values['r_last_staff_reply'][1] ? json_encode($values['r_last_staff_reply']): NULL;
|
||||
$this->tracked = (bool) $values['r_tracked'];
|
||||
}
|
||||
|
||||
@@ -223,7 +234,7 @@ class _Stream extends \IPS\Patterns\ActiveRecord
|
||||
{
|
||||
$return = parent::__get( $key );
|
||||
|
||||
if ( $return !== NULL and in_array( $key, array( 'departments', 'statuses', 'severities', 'staff' ) ) and $return !== 'me' )
|
||||
if ( $return !== NULL and \in_array( $key, array( 'departments', 'statuses', 'severities', 'staff' ) ) and $return !== 'me' )
|
||||
{
|
||||
$return = explode( ',', $return );
|
||||
}
|
||||
@@ -241,7 +252,7 @@ class _Stream extends \IPS\Patterns\ActiveRecord
|
||||
*/
|
||||
public function __set( $key, $value )
|
||||
{
|
||||
if ( is_array( $value ) and in_array( $key, array( 'departments', 'statuses', 'severities', 'staff' ) ) )
|
||||
if ( \is_array( $value ) and \in_array( $key, array( 'departments', 'statuses', 'severities', 'staff' ) ) )
|
||||
{
|
||||
$value = implode( ',', $value );
|
||||
}
|
||||
@@ -265,7 +276,7 @@ class _Stream extends \IPS\Patterns\ActiveRecord
|
||||
/* Streams */
|
||||
$form->addTab('streams');
|
||||
$form->add( new \IPS\Helpers\Form\Custom( 'stream', $selectedStream ? $selectedStream->id : 'custom', FALSE, array(
|
||||
'getHtml' => function( $input ) {
|
||||
'getHtml' => function( $input ) {
|
||||
return \IPS\Theme::i()->getTemplate('support')->filterFormStream( $input, \IPS\nexus\Support\Stream::myStreams( \IPS\Member::loggedIn() ) );
|
||||
}
|
||||
) ) );
|
||||
@@ -322,10 +333,11 @@ class _Stream extends \IPS\Patterns\ActiveRecord
|
||||
return \IPS\Theme::i()->getTemplate('support')->filterFormTime( $input );
|
||||
}
|
||||
);
|
||||
$form->add( new \IPS\Helpers\Form\Custom( 'r_started', $this->started, FALSE, $timeFrameOptions ) );
|
||||
$form->add( new \IPS\Helpers\Form\Custom( 'r_last_new_reply', $this->last_new_reply, FALSE, $timeFrameOptions ) );
|
||||
$form->add( new \IPS\Helpers\Form\Custom( 'r_last_reply', $this->last_reply, FALSE, $timeFrameOptions ) );
|
||||
$form->add( new \IPS\Helpers\Form\Custom( 'r_last_staff_reply', $this->last_staff_reply, FALSE, $timeFrameOptions ) );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Custom( 'r_started', \is_int( $this->started ) ? array( 0 => '<', 1 => $this->started ) : json_decode( $this->started ), FALSE, $timeFrameOptions ) );
|
||||
$form->add( new \IPS\Helpers\Form\Custom( 'r_last_new_reply', \is_int( $this->last_new_reply ) ? array( 0 => '<', 1 => $this->last_new_reply ) : json_decode( $this->last_new_reply ), FALSE, $timeFrameOptions ) );
|
||||
$form->add( new \IPS\Helpers\Form\Custom( 'r_last_reply', \is_int( $this->last_reply ) ? array( 0 => '<', 1 => $this->last_reply ) : json_decode( $this->last_reply ), FALSE, $timeFrameOptions ) );
|
||||
$form->add( new \IPS\Helpers\Form\Custom( 'r_last_staff_reply', \is_int( $this->last_staff_reply ) ? array( 0 => '<', 1 => $this->last_staff_reply ) : json_decode( $this->last_staff_reply ), FALSE, $timeFrameOptions ) );
|
||||
|
||||
/* Return */
|
||||
return $form;
|
||||
@@ -421,7 +433,19 @@ class _Stream extends \IPS\Patterns\ActiveRecord
|
||||
{
|
||||
if ( $this->$k )
|
||||
{
|
||||
$where[] = array( "r_{$k}<?", time() - ( 3600 * $this->$k ) );
|
||||
if ( \is_int( $this->$k ) )
|
||||
{
|
||||
$operand = $this->$k;
|
||||
$operator = '<';
|
||||
}
|
||||
else
|
||||
{
|
||||
$limit = json_decode( $this->$k );
|
||||
// This looks backwards, but if we say "greater than 5 days" we want to know if the date is less than the resulting timestamp
|
||||
$operator = ( $limit[0] == 'gt' ) ? '<' : '>';
|
||||
$operand = $limit[1];
|
||||
}
|
||||
$where[] = array( "r_{$k}{$operator}?", time() - ( 3600 * $operand ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -433,7 +457,7 @@ class _Stream extends \IPS\Patterns\ActiveRecord
|
||||
* Get count
|
||||
*
|
||||
* @param $member Staff member, or NULL for no permission restriction
|
||||
* @return \IPS\Patterns\ActiveRecordIterator
|
||||
* @return int
|
||||
*/
|
||||
public function count( $member = NULL )
|
||||
{
|
||||
@@ -443,7 +467,10 @@ class _Stream extends \IPS\Patterns\ActiveRecord
|
||||
/**
|
||||
* Get results
|
||||
*
|
||||
* @param $member Staff member, or NULL for no permission restriction
|
||||
* @param \IPS\Member|NULL $member Staff member, or NULL for no permission restriction
|
||||
* @param string $order Order by clause
|
||||
* @param int $page Page number
|
||||
* @param int $perPage Number of results per page
|
||||
* @return \IPS\Patterns\ActiveRecordIterator
|
||||
*/
|
||||
public function results( $member = NULL, $order='r_id DESC', $page = 1, $perPage = 25 )
|
||||
|
||||
Reference in new issue
Block a user