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;
|
||||
@@ -98,7 +98,7 @@ class _Department extends \IPS\Node\Model
|
||||
/**
|
||||
* Get the permission array used to get the departments that a staff member has access to
|
||||
*
|
||||
* @param \IPS\Member|NULL $staff The staff member
|
||||
* @param \IPS\Member|NULL $member The staff member
|
||||
* @return array|NULL NULL indicates all departments
|
||||
*/
|
||||
public static function staffDepartmentPerms( \IPS\Member $member = NULL )
|
||||
@@ -120,6 +120,7 @@ class _Department extends \IPS\Node\Model
|
||||
/**
|
||||
* Departments that a staff member has access to
|
||||
*
|
||||
* @param \IPS\Member|NULL $member The staff member
|
||||
* @return \IPS\Patterns\ActiveRecordIterator
|
||||
*/
|
||||
public static function departmentsWithPermission( \IPS\Member $member = NULL )
|
||||
@@ -263,7 +264,7 @@ class _Department extends \IPS\Node\Model
|
||||
|
||||
if ( array_key_exists( 'dpt_packages', $values ) )
|
||||
{
|
||||
$values['dpt_packages'] = is_array( $values['dpt_packages'] ) ? implode( ',', array_map( function( $val )
|
||||
$values['dpt_packages'] = \is_array( $values['dpt_packages'] ) ? implode( ',', array_map( function( $val )
|
||||
{
|
||||
return ltrim( $val, 's' );
|
||||
}, array_keys( $values['dpt_packages'] ) ) ) : 0;
|
||||
@@ -271,14 +272,14 @@ class _Department extends \IPS\Node\Model
|
||||
|
||||
if ( array_key_exists( 'dpt_subscriptions', $values ) )
|
||||
{
|
||||
$values['dpt_subscriptions'] = is_array( $values['dpt_subscriptions'] ) ? implode( ',', array_keys( $values['dpt_subscriptions'] ) ) : 0;
|
||||
$values['dpt_subscriptions'] = \is_array( $values['dpt_subscriptions'] ) ? implode( ',', array_keys( $values['dpt_subscriptions'] ) ) : 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$values['dpt_subscriptions'] = 0;
|
||||
}
|
||||
|
||||
if ( ( array_key_exists( 'dpt_require_package', $values ) AND is_null( $values['dpt_require_package'] ) ) or $values['dpt_packages'] == 0 )
|
||||
if ( ( array_key_exists( 'dpt_require_package', $values ) AND \is_null( $values['dpt_require_package'] ) ) or ( $values['dpt_packages'] == 0 and $values['dpt_subscriptions'] == 0 ) )
|
||||
{
|
||||
$values['dpt_require_package'] = 0;
|
||||
}
|
||||
@@ -327,7 +328,7 @@ class _Department extends \IPS\Node\Model
|
||||
{
|
||||
if ( $severity->public )
|
||||
{
|
||||
if ( !$severity->departments or $severity->departments === '*' or in_array( $this->id, explode( ',', $severity->departments ) ) )
|
||||
if ( !$severity->departments or $severity->departments === '*' or \in_array( $this->id, explode( ',', $severity->departments ) ) )
|
||||
{
|
||||
$this->_availableSeverities[] = $severity;
|
||||
}
|
||||
@@ -383,6 +384,32 @@ class _Department extends \IPS\Node\Model
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* [ActiveRecord] Delete
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
foreach( \IPS\Db::i()->select( '*', 'nexus_support_fields', array( \IPS\Db::i()->findInSet( 'sf_departments', array( $this->id ) ) ) ) AS $field )
|
||||
{
|
||||
$newValue = array();
|
||||
foreach( explode( ',', $field['sf_departments'] ) AS $dpt )
|
||||
{
|
||||
if ( $dpt == $this->id )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$newValue[] = $dpt;
|
||||
}
|
||||
|
||||
\IPS\Db::i()->update( 'nexus_support_fields', array( 'sf_departments' => implode( ',', $newValue ) ), array( "sf_id=?", $field['sf_id'] ) );
|
||||
}
|
||||
|
||||
parent::delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* [Node] Get buttons to display in tree
|
||||
* Example code explains return value
|
||||
|
||||
Reference in new issue
Block a user