Version 4.1.19
This commit is contained in:
1 parent
28bd025b35
commit
2bd5025018
2674 files changed
+233518
-77766
No files matched your search
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Support Department Model
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @subpackage Nexus
|
||||
* @since 8 Apr 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
@@ -54,6 +54,11 @@ class _Department extends \IPS\Node\Model
|
||||
*/
|
||||
protected static $databaseIdFields = array( 'dpt_email' );
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] Multiton Map
|
||||
*/
|
||||
protected static $multitonMap = array();
|
||||
|
||||
/**
|
||||
* @brief [Node] Title prefix. If specified, will look for a language key with "{$key}_title" as the key
|
||||
*/
|
||||
@@ -88,7 +93,7 @@ class _Department extends \IPS\Node\Model
|
||||
*/
|
||||
protected function setDefaultValues()
|
||||
{
|
||||
$this->ppi = json_encode( array() );
|
||||
$this->ppi = '*';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -216,41 +221,46 @@ class _Department extends \IPS\Node\Model
|
||||
\IPS\File::claimAttachments( 'nexus-new-dpt', $this->id, NULL, 'dpt', TRUE );
|
||||
}
|
||||
|
||||
if( isset( $values['dpt_name'] ) )
|
||||
if ( array_key_exists( 'dpt_name', $values ) )
|
||||
{
|
||||
\IPS\Lang::saveCustom( 'nexus', "nexus_department_{$this->id}", $values['dpt_name'] );
|
||||
unset( $values['dpt_name'] );
|
||||
}
|
||||
|
||||
if( isset( $values['dpt_desc'] ) )
|
||||
if ( array_key_exists( 'dpt_desc', $values ) )
|
||||
{
|
||||
\IPS\Lang::saveCustom( 'nexus', "nexus_department_{$this->id}_desc", $values['dpt_desc'] );
|
||||
unset( $values['dpt_desc'] );
|
||||
}
|
||||
|
||||
if( isset( $values['dpt_ppi'] ) )
|
||||
unset( $values['dpt_desc'] );
|
||||
|
||||
if ( array_key_exists( 'dpt_ppi', $values ) )
|
||||
{
|
||||
$values['dpt_ppi'] = $values['dpt_ppi'] === '*' ? '*' : json_encode( $values['dpt_ppi'] );
|
||||
}
|
||||
|
||||
if( isset( $values['dpt_staff'] ) )
|
||||
if ( array_key_exists( 'dpt_staff', $values ) )
|
||||
{
|
||||
$values['dpt_staff'] = $values['dpt_staff'] === '*' ? '*' : implode( ',', $values['dpt_staff'] );
|
||||
}
|
||||
|
||||
if( isset( $values['dpt_ppi_tax'] ) )
|
||||
if ( array_key_exists( 'dpt_ppi_tax', $values ) )
|
||||
{
|
||||
$values['dpt_ppi_tax'] = $values['dpt_ppi_tax'] ? $values['dpt_ppi_tax']->id : NULL;
|
||||
}
|
||||
|
||||
if( isset( $values['dpt_packages'] ) )
|
||||
if ( array_key_exists( 'dpt_packages', $values ) )
|
||||
{
|
||||
$values['dpt_packages'] = is_array( $values['dpt_packages'] ) ? implode( ',', array_map( function( $val )
|
||||
{
|
||||
return ltrim( $val, 's' );
|
||||
}, array_keys( $values['dpt_packages'] ) ) ) : 0;
|
||||
}
|
||||
|
||||
|
||||
if ( ( array_key_exists( 'dpt_require_package', $values ) AND is_null( $values['dpt_require_package'] ) ) or $values['dpt_packages'] == 0 )
|
||||
{
|
||||
$values['dpt_require_package'] = 0;
|
||||
}
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
||||
@@ -342,7 +352,7 @@ class _Department extends \IPS\Node\Model
|
||||
{
|
||||
$costs = json_decode( $this->ppi, TRUE );
|
||||
|
||||
if( isset( $costs[ $currency ?: \IPS\nexus\Customer::loggedIn()->defaultCurrency() ] ) )
|
||||
if( isset( $costs[ $currency ?: \IPS\nexus\Customer::loggedIn()->defaultCurrency() ] ) AND $costs[ $currency ?: \IPS\nexus\Customer::loggedIn()->defaultCurrency() ]['amount'] )
|
||||
{
|
||||
$cost = $costs[ $currency ?: \IPS\nexus\Customer::loggedIn()->defaultCurrency() ];
|
||||
return new \IPS\nexus\Money( $cost['amount'], $cost['currency'] );
|
||||
@@ -380,4 +390,19 @@ class _Department extends \IPS\Node\Model
|
||||
|
||||
return $buttons;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get output for API
|
||||
*
|
||||
* @return array
|
||||
* @apiresponse int id ID number
|
||||
* @apiresponse string name Name
|
||||
*/
|
||||
public function apiOutput()
|
||||
{
|
||||
return array(
|
||||
'id' => $this->_id,
|
||||
'name' => $this->_title
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user