Version 4.1.19

This commit is contained in:
Neo committed 2025-12-19 05:38:56 -08:00
1 parent 28bd025b35
commit 2bd5025018
2674 files changed
+233518 -77766

No files matched your search

@@ -2,9 +2,9 @@
/**
* @brief Support Severity 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 9 Apr 2014
* @version SVN_VERSION_NUMBER
@@ -54,6 +54,11 @@ class _Severity extends \IPS\Node\Model
*/
protected static $databaseIdFields = array( 'sev_default' );
/**
* @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
*/
@@ -80,6 +85,51 @@ class _Severity extends \IPS\Node\Model
'module' => 'support',
'all' => 'severities_manage'
);
/**
* Load Record
*
* @see \IPS\Db::build
* @param int|string $id ID
* @param string $idField The database column that the $id parameter pertains to (NULL will use static::$databaseColumnId)
* @param mixed $extraWhereClause Additional where clause(s) (see \IPS\Db::build for details)
* @return static
* @throws \InvalidArgumentException
* @throws \OutOfRangeException
*/
public static function load( $id, $idField=NULL, $extraWhereClause=NULL )
{
try
{
return parent::load( $id, $idField, $extraWhereClause );
}
catch ( \OutOfRangeException $e )
{
/* Severity is required. If none are set as the fault (for example, bad data from upgrade), find or create one */
if ( $id === TRUE and $idField === 'sev_default' and $extraWhereClause === NULL )
{
try
{
$return = parent::constructFromData( \IPS\Db::i()->select( '*', 'nexus_support_severities' )->first() );
}
catch ( \UnderflowException $e )
{
$return = new static;
$return->id = 1;
$return->color = '000';
$return->public = TRUE;
$return->position = 1;
$return->departments = '*';
}
$return->default = TRUE;
$return->save();
return $return;
}
throw $e;
}
}
/**
* [Node] Add/Edit Form
@@ -91,7 +141,7 @@ class _Severity extends \IPS\Node\Model
{
$form->addHeader( 'severity_settings' );
$form->add( new \IPS\Helpers\Form\Translatable( 'sev_name', NULL, TRUE, array( 'app' => 'nexus', 'key' => ( $this->id ? "nexus_severity_{$this->id}" : NULL ) ) ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'sev_default', $this->default ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'sev_default', $this->default, FALSE, array( 'disabled' => $this->default ) ) );
$form->addHeader( 'severity_submissions' );
$form->add( new \IPS\Helpers\Form\YesNo( 'sev_public', $this->public, FALSE, array( 'togglesOn' => array( 'sev_departments', 'sev_desc' ) ) ) );
$form->add( new \IPS\Helpers\Form\Node( 'sev_departments', ( $this->departments and $this->departments !== '*' ) ? explode( ',', $this->departments ) : 0, FALSE, array( 'class' => 'IPS\nexus\Support\Department', 'multiple' => TRUE, 'zeroVal' => 'all' ), NULL, NULL, NULL, 'sev_departments' ) );
@@ -101,7 +151,6 @@ class _Severity extends \IPS\Node\Model
'textArea' => TRUE
), NULL, NULL, NULL, 'sev_desc' ) );
$form->addHeader( 'severity_acp_list' );
$form->add( new \IPS\Helpers\Form\Upload( 'sev_icon', $this->icon ? \IPS\File::get( 'nexus_Support', $this->icon ) : NULL, FALSE, array( 'storageExtension' => 'nexus_Support', 'image' => TRUE ) ) );
$form->add( new \IPS\Helpers\Form\Color( 'sev_color', $this->color ?: '000' ) );
}
@@ -124,9 +173,17 @@ class _Severity extends \IPS\Node\Model
unset( $values['sev_name'] );
}
if( isset( $values['sev_desc'] ) )
if( array_key_exists( 'sev_desc', $values ) )
{
\IPS\Lang::saveCustom( 'nexus', "nexus_severity_{$this->id}_desc", $values['sev_desc'] );
if ( $values['sev_desc'] )
{
\IPS\Lang::saveCustom( 'nexus', "nexus_severity_{$this->id}_desc", $values['sev_desc'] );
}
else
{
\IPS\Lang::deleteCustom( 'nexus', "nexus_severity_{$this->id}_desc" );
}
unset( $values['sev_desc'] );
}
@@ -177,4 +234,19 @@ class _Severity 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
);
}
}