Merge remote-tracking branch 'origin/develop' into feature/b931

# Conflicts:
#	.idea/inspectionProfiles/Combodo.xml
#	application/cmdbabstract.class.inc.php
#	core/attributedef.class.inc.php
#	css/light-grey.css
#	css/light-grey.scss
This commit is contained in:
Eric
2018-09-25 12:03:44 +02:00
33 changed files with 1404 additions and 139 deletions

View File

@@ -1,6 +1,11 @@
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<option name="LINE_SEPARATOR" value="&#10;" />
<option name="RIGHT_MARGIN" value="320" />
<HTMLCodeStyleSettings>
<option name="HTML_DO_NOT_INDENT_CHILDREN_OF" value="html,body,thead,tbody,tfoot,script,style" />
<option name="HTML_DO_NOT_ALIGN_CHILDREN_OF_MIN_LINES" value="4" />
</HTMLCodeStyleSettings>
<PHPCodeStyleSettings>
<option name="CONCAT_SPACES" value="false" />
<option name="PHPDOC_BLANK_LINE_BEFORE_TAGS" value="true" />
@@ -13,6 +18,7 @@
<option name="PHPDOC_USE_FQCN" value="true" />
</PHPCodeStyleSettings>
<codeStyleSettings language="PHP">
<option name="RIGHT_MARGIN" value="320" />
<option name="BLANK_LINES_AFTER_PACKAGE" value="1" />
<option name="BRACE_STYLE" value="2" />
<option name="ELSE_ON_NEW_LINE" value="true" />

View File

View File

@@ -0,0 +1,14 @@
#!/usr/bin/env bash
set -x
# create target dirs
mkdir -p var
mkdir -p toolkit
# cleanup target dirs
rm -rf toolkit/*
# fill target dirs
curl http://www.combodo.com/documentation/iTopDataModelToolkit-2.3.zip | tar xvz --directory toolkit
cp -r .jenkins/configuration/default-environment/unattended_install/* toolkit

View File

@@ -0,0 +1,11 @@
#!/usr/bin/env bash
set -x
# on the root dir
composer install
# under the test dir
cd test
composer install

13
.jenkins/bin/init/debug.sh Executable file
View File

@@ -0,0 +1,13 @@
#!/usr/bin/env bash
set -x
whoami
pwd
ls
echo "$BRANCH_NAME:${BRANCH_NAME}"
echo "printenv :"
printenv

8
.jenkins/bin/tests/phpunit.sh Executable file
View File

@@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -x
cd test
export DEBUG_UNIT_TEST="0"
php vendor/bin/phpunit --log-junit ../var/test/phpunit-log.junit.xml --teamcity

View File

@@ -0,0 +1,6 @@
#!/usr/bin/env bash
set -x
cd toolkit
php unattended_install.php default-params.xml

View File

@@ -0,0 +1,285 @@
<?php
/**
*
* Configuration file, generated by the iTop configuration wizard
*
* The file is used in MetaModel::LoadConfig() which does all the necessary initialization job
*
*/
$MySettings = array(
// access_message: Message displayed to the users when there is any access restriction
// default: 'iTop is temporarily frozen, please wait... (the admin team)'
'access_message' => 'iTop is temporarily frozen, please wait... (the admin team)',
// access_mode: Access mode: ACCESS_READONLY = 0, ACCESS_ADMIN_WRITE = 2, ACCESS_FULL = 3
// default: 3
'access_mode' => 3,
'allowed_login_types' => 'form|basic|external',
// apc_cache.enabled: If set, the APC cache is allowed (the PHP extension must also be active)
// default: true
'apc_cache.enabled' => true,
// apc_cache.query_ttl: Time to live set in APC for the prepared queries (seconds - 0 means no timeout)
// default: 3600
'apc_cache.query_ttl' => 3600,
// app_root_url: Root URL used for navigating within the application, or from an email to the application (you can put $SERVER_NAME$ as a placeholder for the server's name)
// default: ''
'app_root_url' => 'http://127.0.0.1/itop/svn/trunk/',
// buttons_position: Position of the forms buttons: bottom | top | both
// default: 'both'
'buttons_position' => 'both',
// cas_include_path: The path where to find the phpCAS library
// default: '/usr/share/php'
'cas_include_path' => '/usr/share/php',
// cron_max_execution_time: Duration (seconds) of the page cron.php, must be shorter than php setting max_execution_time and shorter than the web server response timeout
// default: 600
'cron_max_execution_time' => 600,
// csv_file_default_charset: Character set used by default for downloading and uploading data as a CSV file. Warning: it is case sensitive (uppercase is preferable).
// default: 'ISO-8859-1'
'csv_file_default_charset' => 'ISO-8859-1',
'csv_import_charsets' => array (
),
// csv_import_history_display: Display the history tab in the import wizard
// default: false
'csv_import_history_display' => false,
// date_and_time_format: Format for date and time display (per language)
// default: array (
// 'default' =>
// array (
// 'date' => 'Y-m-d',
// 'time' => 'H:i:s',
// 'date_time' => '$date $time',
// ),
// )
'date_and_time_format' => array (
'default' =>
array (
'date' => 'Y-m-d',
'time' => 'H:i:s',
'date_time' => '$date $time',
),
'FR FR' =>
array (
'date' => 'd/m/Y',
'time' => 'H:i:s',
'date_time' => '$date $time',
),
),
'db_host' => '',
'db_name' => 'itop_ci_main',
'db_pwd' => 'c8mb0do',
'db_subname' => '',
'db_user' => 'root',
// deadline_format: The format used for displaying "deadline" attributes: any string with the following placeholders: $date$, $difference$
// default: '$difference$'
'deadline_format' => '$difference$',
'default_language' => 'EN US',
// disable_attachments_download_legacy_portal: Disable attachments download from legacy portal
// default: true
'disable_attachments_download_legacy_portal' => true,
// draft_attachments_lifetime: Lifetime (in seconds) of drafts' attachments and inline images: after this duration, the garbage collector will delete them.
// default: 3600
'draft_attachments_lifetime' => 3600,
// email_asynchronous: If set, the emails are sent off line, which requires cron.php to be activated. Exception: some features like the email test utility will force the serialized mode
// default: false
'email_asynchronous' => false,
// email_default_sender_address: Default address provided in the email from header field.
// default: ''
'email_default_sender_address' => '',
// email_default_sender_label: Default label provided in the email from header field.
// default: ''
'email_default_sender_label' => '',
// email_transport: Mean to send emails: PHPMail (uses the function mail()) or SMTP (implements the client protocole)
// default: 'PHPMail'
'email_transport' => 'SMTP',
// email_transport_smtp.host: host name or IP address (optional)
// default: 'localhost'
'email_transport_smtp.host' => 'smtp.combodo.com',
// email_transport_smtp.password: Authentication password (optional)
// default: ''
'email_transport_smtp.password' => '++combodo++',
// email_transport_smtp.port: port number (optional)
// default: 25
'email_transport_smtp.port' => 25,
// email_transport_smtp.username: Authentication user (optional)
// default: ''
'email_transport_smtp.username' => 'test2@combodo.com',
// email_validation_pattern: Regular expression to validate/detect the format of an eMail address
// default: '[a-zA-Z0-9._&\'-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z0-9-]{2,}'
'email_validation_pattern' => '[a-zA-Z0-9._&\'-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z0-9-]{2,}',
'encryption_key' => '@iT0pEncr1pti0n!',
'ext_auth_variable' => '$_SERVER[\'REMOTE_USER\']',
'fast_reload_interval' => '60',
// graphviz_path: Path to the Graphviz "dot" executable for graphing objects lifecycle
// default: '/usr/bin/dot'
'graphviz_path' => '/usr/bin/dot',
// inline_image_max_display_width: The maximum width (in pixels) when displaying images inside an HTML formatted attribute. Images will be displayed using this this maximum width.
// default: '250'
'inline_image_max_display_width' => 250,
// inline_image_max_storage_width: The maximum width (in pixels) when uploading images to be used inside an HTML formatted attribute. Images larger than the given size will be downsampled before storing them in the database.
// default: '1600'
'inline_image_max_storage_width' => 1600,
// link_set_attribute_qualifier: Link set from string: attribute qualifier (encloses both the attcode and the value)
// default: '\''
'link_set_attribute_qualifier' => '\'',
// link_set_attribute_separator: Link set from string: attribute separator
// default: ';'
'link_set_attribute_separator' => ';',
// link_set_item_separator: Link set from string: line separator
// default: '|'
'link_set_item_separator' => '|',
// link_set_value_separator: Link set from string: value separator (between the attcode and the value itself
// default: ':'
'link_set_value_separator' => ':',
'log_global' => true,
'log_issue' => true,
'log_notification' => true,
'log_web_service' => true,
// max_combo_length: The maximum number of elements in a drop-down list. If more then an autocomplete will be used
// default: 50
'max_combo_length' => 50,
'max_display_limit' => '15',
// max_linkset_output: Maximum number of items shown when getting a list of related items in an email, using the form $this->some_list$. 0 means no limit.
// default: 100
'max_linkset_output' => 100,
'min_display_limit' => '10',
// online_help: Hyperlink to the online-help web page
// default: 'http://www.combodo.com/itop-help'
'online_help' => 'http://www.combodo.com/itop-help',
// php_path: Path to the php executable in CLI mode
// default: 'php'
'php_path' => 'php',
// portal_tickets: CSV list of classes supported in the portal
// default: 'UserRequest'
'portal_tickets' => 'UserRequest',
'query_cache_enabled' => true,
// search_manual_submit: Force manual submit of search requests (class => true)
// default: false
'search_manual_submit' => array (
'Person' => true,
),
'secure_connection_required' => false,
// session_name: The name of the cookie used to store the PHP session id
// default: 'iTop'
'session_name' => 'iTop',
// shortcut_actions: Actions that are available as direct buttons next to the "Actions" menu
// default: 'UI:Menu:Modify,UI:Menu:New'
'shortcut_actions' => 'UI:Menu:Modify,UI:Menu:New',
// source_dir: Source directory for the datamodel files. (which gets compiled to env-production).
// default: ''
'source_dir' => 'datamodels/2.x/',
'standard_reload_interval' => '300',
// synchro_trace: Synchronization details: none, display, save (includes 'display')
// default: 'none'
'synchro_trace' => 'none',
// timezone: Timezone (reference: http://php.net/manual/en/timezones.php). If empty, it will be left unchanged and MUST be explicitely configured in PHP
// default: 'Europe/Paris'
'timezone' => 'Europe/Paris',
// tracking_level_linked_set_default: Default tracking level if not explicitely set at the attribute level, for AttributeLinkedSet (defaults to NONE in case of a fresh install, LIST otherwise - this to preserve backward compatibility while upgrading from a version older than 2.0.3 - see TRAC #936)
// default: 1
'tracking_level_linked_set_default' => 0,
// url_validation_pattern: Regular expression to validate/detect the format of an URL (URL attributes and Wiki formatting for Text attributes)
// default: '(https?|ftp)\\://([a-zA-Z0-9+!*(),;?&=\\$_.-]+(\\:[a-zA-Z0-9+!*(),;?&=\\$_.-]+)?@)?([a-zA-Z0-9-.]{3,})(\\:[0-9]{2,5})?(/([a-zA-Z0-9%+\\$_-]\\.?)+)*/?(\\?[a-zA-Z+&\\$_.-][a-zA-Z0-9;:[\\]@&%=+/\\$_.-]*)?(#[a-zA-Z_.-][a-zA-Z0-9+\\$_.-]*)?'
'url_validation_pattern' => '(https?|ftp)\\://([a-zA-Z0-9+!*(),;?&=\\$_.-]+(\\:[a-zA-Z0-9+!*(),;?&=\\$_.-]+)?@)?([a-zA-Z0-9-.]{3,})(\\:[0-9]{2,5})?(/([a-zA-Z0-9%+\\$_-]\\.?)+)*/?(\\?[a-zA-Z+&\\$_.-][a-zA-Z0-9;:[\\]@&%=+/\\$_.-]*)?(#[a-zA-Z_.-][a-zA-Z0-9+\\$_.-]*)?',
);
/**
*
* Modules specific settings
*
*/
$MyModuleSettings = array(
'itop-attachments' => array (
'allowed_classes' => array (
0 => 'Ticket',
),
'position' => 'relations',
'preview_max_width' => 290,
),
'itop-backup' => array (
'mysql_bindir' => '',
'week_days' => 'monday, tuesday, wednesday, thursday, friday',
'time' => '23:30',
'retention_count' => 5,
'enabled' => true,
'debug' => false,
),
'molkobain-console-tooltips' => array (
'decoration_class' => 'fas fa-question',
'enabled' => true,
),
);
/**
*
* Data model modules to be loaded. Names are specified as relative paths
*
*/
$MyModules = array(
'addons' => array (
'user rights' => 'addons/userrights/userrightsprofile.class.inc.php',
),
);
?>

View File

@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?>
<installation>
<mode>upgrade</mode>
<preinstall>
<copies type="array"/>
</preinstall>
<source_dir>datamodels/2.x/</source_dir>
<datamodel_version>2.5.0</datamodel_version>
<previous_configuration_file>/var/lib/jenkins/workspace/iTop-CI/unattended_install/default-config-itop.php</previous_configuration_file>
<extensions_dir>extensions</extensions_dir>
<target_env>production</target_env>
<workspace_dir></workspace_dir>
<database>
<server></server>
<user>root</user>
<pwd>c8mb0do</pwd>
<name>itop_ci</name>
<db_tls_enabled></db_tls_enabled>
<db_tls_ca></db_tls_ca>
<prefix></prefix>
</database>
<url>http://127.0.0.1/itop/svn/trunk/</url>
<graphviz_path>/usr/bin/dot</graphviz_path>
<admin_account>
<user>admin</user>
<pwd>admin</pwd>
<language>EN US</language>
</admin_account>
<language>EN US</language>
<selected_modules type="array">
<item>authent-external</item>
<item>authent-local</item>
<item>itop-backup</item>
<item>itop-config</item>
<item>itop-profiles-itil</item>
<item>itop-sla-computation</item>
<item>itop-tickets</item>
<item>itop-welcome-itil</item>
<item>itop-config-mgmt</item>
<item>itop-attachments</item>
<item>itop-datacenter-mgmt</item>
<item>itop-endusers-devices</item>
<item>itop-storage-mgmt</item>
<item>itop-virtualization-mgmt</item>
<item>itop-bridge-virtualization-storage</item>
<item>itop-service-mgmt</item>
<item>itop-request-mgmt</item>
<item>itop-portal</item>
<item>itop-portal-base</item>
<item>itop-change-mgmt</item>
</selected_modules>
<selected_extensions type="array">
<item>itop-config-mgmt-core</item>
<item>itop-config-mgmt-datacenter</item>
<item>itop-config-mgmt-end-user</item>
<item>itop-config-mgmt-storage</item>
<item>itop-config-mgmt-virtualization</item>
<item>itop-service-mgmt-enterprise</item>
<item>itop-ticket-mgmt-simple-ticket</item>
<item>itop-ticket-mgmt-simple-ticket-enhanced-portal</item>
<item>itop-change-mgmt-simple</item>
</selected_extensions>
<sample_data>1</sample_data>
<old_addon></old_addon>
<options>
<generate_config>1</generate_config>
</options>
<mysql_bindir></mysql_bindir>
</installation>

View File

@@ -0,0 +1,190 @@
<?php
//this scrit will be run under the ./toolkit directory, relatively to the document root
require_once('../approot.inc.php');
require_once(APPROOT.'/application/utils.inc.php');
require_once(APPROOT.'/application/clipage.class.inc.php');
require_once(APPROOT.'/core/config.class.inc.php');
require_once(APPROOT.'/core/log.class.inc.php');
require_once(APPROOT.'/core/kpi.class.inc.php');
require_once(APPROOT.'/core/cmdbsource.class.inc.php');
require_once(APPROOT.'/setup/setuppage.class.inc.php');
require_once(APPROOT.'/setup/wizardcontroller.class.inc.php');
require_once(APPROOT.'/setup/wizardsteps.class.inc.php');
require_once(APPROOT.'/setup/applicationinstaller.class.inc.php');
/////////////////////////////////////////////////
$sParamFile = utils::ReadParam('response_file', 'default-params.xml', true /* CLI allowed */, 'raw_data');
$bCheckConsistency = (utils::ReadParam('check_consistency', '0', true /* CLI allowed */) == '1');
$oParams = new XMLParameters($sParamFile);
$sMode = $oParams->Get('mode');
if ($sMode == 'install')
{
echo "Installation mode detected.\n";
$bClean = utils::ReadParam('clean', false, true /* CLI allowed */);
if ($bClean)
{
echo "Cleanup mode detected.\n";
$sTargetEnvironment = $oParams->Get('target_env', '');
if ($sTargetEnvironment == '')
{
$sTargetEnvironment = 'production';
}
$sTargetDir = APPROOT.'env-'.$sTargetEnvironment;
// Configuration file
$sConfigFile = APPCONF.$sTargetEnvironment.'/'.ITOP_CONFIG_FILE;
if (file_exists($sConfigFile))
{
echo "Trying to delete the configuration file: '$sConfigFile'.\n";
@chmod($sConfigFile, 0770); // RWX for owner and group, nothing for others
unlink($sConfigFile);
}
else
{
echo "No config file to delete ($sConfigFile does not exist).\n";
}
// env-xxx directory
if (file_exists($sTargetDir))
{
if (is_dir($sTargetDir))
{
echo "Emptying the target directory '$sTargetDir'.\n";
SetupUtils::tidydir($sTargetDir);
}
else
{
die("ERROR the target dir '$sTargetDir' exists, but is NOT a directory !!!\nExiting.\n");
}
}
else
{
echo "No target directory to delete ($sTargetDir does not exist).\n";
}
// Database
$aDBSettings = $oParams->Get('database', array());
$sDBServer = $aDBSettings['server'];
$sDBUser = $aDBSettings['user'];
$sDBPwd = $aDBSettings['pwd'];
$sDBName = $aDBSettings['name'];
$sDBPrefix = $aDBSettings['prefix'];
if ($sDBPrefix != '')
{
die("Cleanup not implemented for a partial database (prefix= '$sDBPrefix')\nExiting.");
}
$oMysqli = new mysqli($sDBServer, $sDBUser, $sDBPwd);
if ($oMysqli->connect_errno)
{
die("Cannot connect to the MySQL server (".$mysqli->connect_errno . ") ".$mysqli->connect_error."\nExiting");
}
else
{
if ($oMysqli->select_db($sDBName))
{
echo "Deleting database '$sDBName'\n";
$oMysqli->query("DROP DATABASE `$sDBName`");
}
else
{
echo "The database '$sDBName' does not seem to exist. Nothing to cleanup.\n";
}
}
}
}
$bHasErrors = false;
$aChecks = SetupUtils::CheckBackupPrerequisites(APPROOT.'data'); // mmm should be the backup destination dir
$aSelectedModules = $oParams->Get('selected_modules');
$sSourceDir = $oParams->Get('source_dir', 'datamodels/latest');
$sExtensionDir = $oParams->Get('extensions_dir', 'extensions');
$aChecks = array_merge($aChecks, SetupUtils::CheckSelectedModules($sSourceDir, $sExtensionDir, $aSelectedModules));
foreach($aChecks as $oCheckResult)
{
switch($oCheckResult->iSeverity)
{
case CheckResult::ERROR:
$bHasErrors = true;
$sHeader = "Error";
break;
case CheckResult::WARNING:
$sHeader = "Warning";
break;
case CheckResult::INFO:
default:
$sHeader = "Info";
break;
}
echo $sHeader.": ".$oCheckResult->sLabel;
if (strlen($oCheckResult->sDescription))
{
echo ' - '.$oCheckResult->sDescription;
}
echo "\n";
}
if ($bHasErrors)
{
echo "Encountered stopper issues. Aborting...\n";
die;
}
$bFoundIssues = false;
$bInstall = utils::ReadParam('install', true, true /* CLI allowed */);
if ($bInstall)
{
echo "Starting the unattended installation...\n";
$oWizard = new ApplicationInstaller($oParams);
$bRes = $oWizard->ExecuteAllSteps();
if (!$bRes)
{
echo "\nencountered installation issues!";
$bFoundIssues = true;
}
}
else
{
echo "No installation requested.\n";
}
if (!$bFoundIssues && $bCheckConsistency)
{
echo "Checking data model consistency.\n";
ob_start();
$sCheckRes = '';
try
{
MetaModel::CheckDefinitions(false);
$sCheckRes = ob_get_clean();
}
catch(Exception $e)
{
$sCheckRes = ob_get_clean()."\nException: ".$e->getMessage();
}
if (strlen($sCheckRes) > 0)
{
echo $sCheckRes;
echo "\nfound consistency issues!";
$bFoundIssues = true;
}
}
if (!$bFoundIssues)
{
// last line: used to check the install
// the only way to track issues in case of Fatal error or even parsing error!
echo "\ninstalled!";
exit;
}

62
Jenkinsfile vendored Normal file
View File

@@ -0,0 +1,62 @@
pipeline {
agent any
stages {
stage('init') {
parallel {
stage('debug') {
steps {
sh './.jenkins/bin/init/debug.sh'
}
}
stage('append files to project') {
steps {
sh './.jenkins/bin/init/append_files.sh'
}
}
stage('composer install') {
steps {
sh './.jenkins/bin/init/composer_install.sh'
}
}
}
}
stage('unattended_install') {
parallel {
stage('unattended_install default env') {
steps {
sh './.jenkins/bin/unattended_install/default_env.sh'
}
}
}
}
stage('test') {
parallel {
stage('phpunit') {
steps {
sh './.jenkins/bin/tests/phpunit.sh'
}
}
}
}
}
post {
always {
junit 'var/test/phpunit-log.junit.xml'
}
failure {
slackSend(channel: "#jenkins-itop", color: '#FF0000', message: "Ho no! Build failed! (${currentBuild.result}), Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL})")
}
}
environment {
DEBUG_UNIT_TEST = '0'
}
options {
timeout(time: 20, unit: 'MINUTES')
}
}

View File

@@ -398,6 +398,18 @@ EOF
$this->aFieldsMap[$sAttCode] = $sInputId;
}
/**
* @param \WebPage $oPage
* @param bool $bEditMode
*
* @throws \CoreException
* @throws \CoreUnexpectedValue
* @throws \DictExceptionMissingString
* @throws \MissingQueryArgument
* @throws \MySQLException
* @throws \MySQLHasGoneAwayException
* @throws \OQLException
*/
function DisplayBareRelations(WebPage $oPage, $bEditMode = false)
{
$aRedundancySettings = $this->FindVisibleRedundancySettings();
@@ -2042,6 +2054,18 @@ EOF
break;
case 'ObjectAttcodeSet':
$iFieldSize = $oAttDef->GetMaxSize();
if (is_array($sDisplayValue))
{
$sDisplayValue = implode(', ', $sDisplayValue);
}
$sHTMLValue = "<div class=\"field_input_zone field_input_string\"><input title=\"$sHelpText\" type=\"text\" maxlength=\"$iFieldSize\" name=\"attr_{$sFieldPrefix}{$sAttCode}{$sNameSuffix}\" value=\"".htmlentities($sDisplayValue, ENT_QUOTES, 'UTF-8')."\" id=\"$iId\"/></div>{$sValidationSpan}{$sReloadSpan}";
$aEventsList[] ='validate';
$aEventsList[] ='keyup';
$aEventsList[] ='change';
break;
case 'String':
default:
$aEventsList[] = 'validate';

View File

@@ -652,16 +652,21 @@ class DisplayBlock
if (isset($aExtraParams['update_history']) && true == $aExtraParams['update_history'])
{
$sSearchFilter = $this->m_oSet->GetFilter()->serialize();
// Limit the size of the URL (N°1585 - request uri too long)
if (strlen($sSearchFilter) < SERVER_MAX_URL_LENGTH)
{
$seventAttachedData = json_encode(array(
'filter' => $sSearchFilter,
'breadcrumb_id' => "ui-search-".$this->m_oSet->GetClass(),
'breadcrumb_label' => MetaModel::GetName($this->m_oSet->GetClass()),
'breadcrumb_max_count' => utils::GetConfig()->Get('breadcrumb.max_count'),
'breadcrumb_instance_id' => MetaModel::GetConfig()->GetItopInstanceid(),
'breadcrumb_icon' => utils::GetAbsoluteUrlAppRoot().'images/breadcrumb-search.png'
));
$seventAttachedData = json_encode(array(
'filter' => $this->m_oSet->GetFilter()->serialize(),
'breadcrumb_id' => "ui-search-".$this->m_oSet->GetClass(),
'breadcrumb_label' => MetaModel::GetName($this->m_oSet->GetClass()),
'breadcrumb_max_count' => utils::GetConfig()->Get('breadcrumb.max_count'),
'breadcrumb_instance_id'=> MetaModel::GetConfig()->GetItopInstanceid(),
'breadcrumb_icon' => utils::GetAbsoluteUrlAppRoot().'images/breadcrumb-search.png'
));
$oPage->add_ready_script("$('body').trigger('update_history.itop', [$seventAttachedData])");
$oPage->add_ready_script("$('body').trigger('update_history.itop', [$seventAttachedData])");
}
}
}
break;

View File

@@ -50,10 +50,23 @@ require_once(APPROOT.'/core/contexttag.class.inc.php');
session_name('itop-'.md5(APPROOT));
session_start();
$sSwitchEnv = utils::ReadParam('switch_env', null);
if (($sSwitchEnv != null) && (file_exists(APPCONF.$sSwitchEnv.'/'.ITOP_CONFIG_FILE)))
$bAllowCache = true;
if (($sSwitchEnv != null) && (file_exists(APPCONF.$sSwitchEnv.'/'.ITOP_CONFIG_FILE)) && isset($_SESSION['itop_env']) && ($_SESSION['itop_env'] !== $sSwitchEnv))
{
$_SESSION['itop_env'] = $sSwitchEnv;
$sEnv = $sSwitchEnv;
$bAllowCache = false;
// Reset the opcache since otherwise the PHP "model" files may still be cached !!
if (function_exists('opcache_reset'))
{
// Zend opcode cache
opcache_reset();
}
if (function_exists('apc_clear_cache'))
{
// APC(u) cache
apc_clear_cache();
}
// TODO: reset the credentials as well ??
}
else if (isset($_SESSION['itop_env']))
@@ -66,4 +79,4 @@ else
$_SESSION['itop_env'] = ITOP_DEFAULT_ENV;
}
$sConfigFile = APPCONF.$sEnv.'/'.ITOP_CONFIG_FILE;
MetaModel::Startup($sConfigFile, false /* $bModelOnly */, true /* $bAllowCache */, false /* $bTraceSourceFiles */, $sEnv);
MetaModel::Startup($sConfigFile, false /* $bModelOnly */, $bAllowCache, false /* $bTraceSourceFiles */, $sEnv);

View File

@@ -36,6 +36,8 @@ define('ITOP_DEFAULT_CONFIG_FILE', APPCONF.ITOP_DEFAULT_ENV.'/'.ITOP_CONFIG_FILE
define('SERVER_NAME_PLACEHOLDER', '$SERVER_NAME$');
define('SERVER_MAX_URL_LENGTH', 2048);
class FileUploadException extends Exception
{
}
@@ -1046,12 +1048,16 @@ class utils
$oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/tabularfieldsselector.js');
$oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/jquery.dragtable.js');
$oPage->add_linked_stylesheet(utils::GetAbsoluteUrlAppRoot().'css/dragtable.css');
$aResult = array(
new SeparatorPopupMenuItem(),
$aResult = array();
if (strlen($sUrl) < SERVER_MAX_URL_LENGTH)
{
$aResult[] = new SeparatorPopupMenuItem();
// Static menus: Email this page, CSV Export & Add to Dashboard
new URLPopupMenuItem('UI:Menu:EMail', Dict::S('UI:Menu:EMail'), "mailto:?body=".urlencode($sUrl).' '), // Add an extra space to make it work in Outlook
);
$aResult[] = new URLPopupMenuItem('UI:Menu:EMail', Dict::S('UI:Menu:EMail'),
"mailto:?body=".urlencode($sUrl).' ' // Add an extra space to make it work in Outlook
);
}
if (UserRights::IsActionAllowed($param->GetFilter()->GetClass(), UR_ACTION_BULK_READ, $param) != UR_ALLOWED_NO)
{

View File

@@ -223,7 +223,14 @@ class ActionEmail extends ActionNotification
return implode(', ', $aRecipients);
}
/**
* @param \Trigger $oTrigger
* @param array $aContextArgs
*
* @throws \CoreException
* @throws \CoreUnexpectedValue
* @throws \CoreWarning
*/
public function DoExecute($oTrigger, $aContextArgs)
{
if (MetaModel::IsLogEnabledNotification())
@@ -292,6 +299,14 @@ class ActionEmail extends ActionNotification
}
/**
* @param \Trigger $oTrigger
* @param array $aContextArgs
* @param \EventNotification $oLog
*
* @return string
* @throws \CoreException
*/
protected function _DoExecute($oTrigger, $aContextArgs, &$oLog)
{
$sPreviousUrlMaker = ApplicationContext::SetUrlMakerClass();

View File

@@ -9347,6 +9347,283 @@ class AttributePropertySet extends AttributeTable
}
}
/**
* An unordered multi values attribute
*
* Class AttributeSet
*/
class AttributeSet extends AttributeDBFieldVoid
{
static public function ListExpectedParams()
{
return array_merge(parent::ListExpectedParams(), array('is_null_allowed'));
}
public function GetDefaultValue(DBObject $oHostObject = null)
{
return null;
}
public function IsNullAllowed()
{
return $this->Get("is_null_allowed");
}
public function GetEditClass()
{
return "List";
}
public function GetEditValue($value, $oHostObj = null)
{
if (is_string($value))
{
return $value;
}
if (is_array($value))
{
return implode(', ', $value);
}
return '';
}
protected function GetSQLCol($bFullSpec = false)
{
$iLen = $this->GetMaxSize();
return "VARCHAR($iLen)"
.CMDBSource::GetSqlStringColumnDefinition()
.($bFullSpec ? $this->GetSQLColSpec() : '');
}
public function GetMaxSize()
{
return 255;
}
/**
* @param array $aCols
* @param string $sPrefix
*
* @return mixed
* @throws \CoreException
* @throws \Exception
*/
public function FromSQLToValue($aCols, $sPrefix = '')
{
$sValue = $aCols["$sPrefix"];
return $this->MakeRealValue($sValue, null);
}
/**
* @param $aCols
* @param string $sPrefix
*
* @return mixed
* @throws \Exception
*/
public function FromImportToValue($aCols, $sPrefix = '')
{
$sValue = $aCols["$sPrefix"];
return $this->MakeRealValue($sValue, null);
}
/**
* force an allowed value (type conversion and possibly forces a value as mySQL would do upon writing!
*
* @param $proposedValue
* @param \DBObject $oHostObj
*
* @return mixed
* @throws \Exception
*/
public function MakeRealValue($proposedValue, $oHostObj)
{
if (empty($proposedValue))
{
return array();
}
if (is_string($proposedValue))
{
$proposedValue = trim("$proposedValue");
$proposedValue = explode(',', $proposedValue);
$aValues = array();
foreach($proposedValue as $sValue)
{
$sValue = trim($sValue);
$aValues[$sValue] = $sValue;
}
return $aValues;
}
if (is_array($proposedValue))
{
return $proposedValue;
}
throw new CoreUnexpectedValue("Wrong format");
}
/**
* Get the value from a given string (plain text, CSV import)
*
* @param string $sProposedValue
* @param bool $bLocalizedValue
* @param string $sSepItem
* @param string $sSepAttribute
* @param string $sSepValue
* @param string $sAttributeQualifier
*
* @return mixed null if no match could be found
* @throws \Exception
*/
public function MakeValueFromString($sProposedValue, $bLocalizedValue = false, $sSepItem = null, $sSepAttribute = null, $sSepValue = null, $sAttributeQualifier = null)
{
return $this->MakeRealValue($sProposedValue, null);
}
public function GetNullValue()
{
return null;
}
public function IsNull($proposedValue)
{
return empty($proposedValue);
}
/**
* To be overloaded for localized enums
*
* @param $sValue
*
* @return string label corresponding to the given value (in plain text)
* @throws \CoreWarning
* @throws \Exception
*/
public function GetValueLabel($sValue)
{
if (is_array($sValue))
{
return implode(', ', $sValue);
}
return $sValue;
}
/**
* @param string $sValue
* @param null $oHostObj
*
* @return string
* @throws \CoreWarning
*/
public function GetAsPlainText($sValue, $oHostObj = null)
{
return $this->GetValueLabel($sValue);
}
/**
* @param $value
*
* @return string
* @throws \CoreWarning
*/
public function ScalarToSQL($value)
{
if (empty($value))
{
return '';
}
if (is_array($value))
{
return implode(', ', $value);
}
return $value;
}
/**
* @param $value
* @param \DBObject $oHostObject
* @param bool $bLocalize
*
* @return string|null
*
* @throws \CoreException
* @throws \Exception
*/
public function GetAsHTML($value, $oHostObject = null, $bLocalize = true)
{
if (is_array($value))
{
return implode(', ', $value);
}
return $value;
}
}
class AttributeObjectAttCodeSet extends AttributeSet
{
static public function ListExpectedParams()
{
return array_merge(parent::ListExpectedParams(), array('class'));
}
public function GetEditClass()
{
return "ObjectAttcodeSet";
}
public function GetMaxSize()
{
return 255;
}
/**
* force an allowed value (type conversion and possibly forces a value as mySQL would do upon writing!
*
* @param $proposedValue
* @param \DBObject $oHostObj
*
* @return mixed
* @throws \Exception
*/
public function MakeRealValue($proposedValue, $oHostObj)
{
$aAllowedAttributes = array();
$sClass = '';
if (!empty($oHostObj))
{
$sTargetClass = $this->Get('class');
$sClass = $oHostObj->Get($sTargetClass);
$aAllowedAttributes = MetaModel::GetAttributesList($sClass);
}
if (is_string($proposedValue) && !empty($proposedValue))
{
$proposedValue = trim("$proposedValue");
$proposedValue = explode(',', $proposedValue);
$aValues = array();
foreach($proposedValue as $sValue)
{
$sAttCode = trim($sValue);
if (empty($aAllowedAttributes) || in_array($sAttCode, $aAllowedAttributes))
{
$aValues[$sAttCode] = $sAttCode;
}
else
{
throw new CoreUnexpectedValue("The attribute {$sAttCode} does not exist in class {$sClass}");
}
}
return $aValues;
}
return $proposedValue;
}
}
/**
* The attribute dedicated to the friendly name automatic attribute (not written)
*

View File

@@ -1,5 +1,5 @@
<?php
// Copyright (C) 2010-2017 Combodo SARL
// Copyright (C) 2010-2018 Combodo SARL
//
// This file is part of iTop.
//
@@ -292,6 +292,7 @@ abstract class DBObject implements iDisplay
}
else
{
/** @var \AttributeCustomFields $oAttDef */
$value = $oAttDef->ReadValue($this);
$bIsDefined = true;
}
@@ -370,6 +371,7 @@ abstract class DBObject implements iDisplay
// Setting an external key with a whole object (instead of just an ID)
// let's initialize also the external fields that depend on it
// (useful when building objects in memory and not from a query)
/** @var \AttributeExternalKey $oAttDef */
if ( (get_class($value) != $oAttDef->GetTargetClass()) && (!is_subclass_of($value, $oAttDef->GetTargetClass())))
{
throw new CoreUnexpectedValue("Trying to set the value of '$sAttCode', to an object of class '".get_class($value)."', whereas it's an ExtKey to '".$oAttDef->GetTargetClass()."'. Ignored");
@@ -377,8 +379,10 @@ abstract class DBObject implements iDisplay
foreach(MetaModel::ListAttributeDefs(get_class($this)) as $sCode => $oDef)
{
/** @var \AttributeExternalField $oDef */
if ($oDef->IsExternalField() && ($oDef->GetKeyAttCode() == $sAttCode))
{
/** @var \DBObject $value */
$this->m_aCurrValues[$sCode] = $value->Get($oDef->GetExtAttCode());
$this->m_aLoadedAtt[$sCode] = true;
}
@@ -390,6 +394,7 @@ abstract class DBObject implements iDisplay
// Invalidate the corresponding fields so that they get reloaded in case they are needed (See Get())
foreach(MetaModel::ListAttributeDefs(get_class($this)) as $sCode => $oDef)
{
/** @var \AttributeExternalKey $oDef */
if ($oDef->IsExternalField() && ($oDef->GetKeyAttCode() == $sAttCode))
{
$this->m_aCurrValues[$sCode] = $this->GetDefaultValue($sCode);
@@ -411,6 +416,7 @@ abstract class DBObject implements iDisplay
foreach (MetaModel::ListMetaAttributes(get_class($this), $sAttCode) as $sMetaAttCode => $oMetaAttDef)
{
/** @var \AttributeMetaEnum $oMetaAttDef */
$this->_Set($sMetaAttCode, $oMetaAttDef->MapValue($this));
}
@@ -459,11 +465,13 @@ abstract class DBObject implements iDisplay
$oExtFieldAtt = MetaModel::FindExternalField(get_class($this), $sExtKeyAttCode, $sRemoteAttCode);
if (!is_null($oExtFieldAtt))
{
/** @var \AttributeExternalField $oExtFieldAtt */
return $this->GetStrict($oExtFieldAtt->GetCode());
}
else
{
$oKeyAttDef = MetaModel::GetAttributeDef(get_class($this), $sExtKeyAttCode);
/** @var \AttributeExternalKey $oKeyAttDef */
$sRemoteClass = $oKeyAttDef->GetTargetClass();
$oRemoteObj = MetaModel::GetObject($sRemoteClass, $this->GetStrict($sExtKeyAttCode), false);
if (is_null($oRemoteObj))
@@ -520,6 +528,7 @@ abstract class DBObject implements iDisplay
// Let's get the object and compute all of the corresponding attributes
// (i.e not only the requested attribute)
//
/** @var \AttributeExternalField $oAttDef */
$sExtKeyAttCode = $oAttDef->GetKeyAttCode();
if (($iRemote = $this->Get($sExtKeyAttCode)) && ($iRemote > 0)) // Objects in memory have negative IDs
@@ -528,6 +537,7 @@ abstract class DBObject implements iDisplay
// Note: "allow all data" must be enabled because the external fields are always visible
// to the current user even if this is not the case for the remote object
// This is consistent with the behavior of the lists
/** @var \AttributeExternalKey $oExtKeyAttDef */
$oRemote = MetaModel::GetObject($oExtKeyAttDef->GetTargetClass(), $iRemote, true, true);
}
else
@@ -537,6 +547,7 @@ abstract class DBObject implements iDisplay
foreach(MetaModel::ListAttributeDefs(get_class($this)) as $sCode => $oDef)
{
/** @var \AttributeExternalField $oDef */
if ($oDef->IsExternalField() && ($oDef->GetKeyAttCode() == $sExtKeyAttCode))
{
if ($oRemote)
@@ -665,6 +676,7 @@ abstract class DBObject implements iDisplay
$oAttDef = MetaModel::GetAttributeDef(get_class($this), $sAttCode);
if ($oAttDef->IsExternalField())
{
/** @var \AttributeExternalField $oAttDef */
$sTargetClass = $oAttDef->GetTargetClass();
$objkey = $this->Get($oAttDef->GetKeyAttCode());
// Note: "allow all data" must be enabled because the external fields are always visible
@@ -719,6 +731,7 @@ abstract class DBObject implements iDisplay
if ($oAtt->IsExternalKey(EXTKEY_ABSOLUTE))
{
//return $this->Get($sAttCode.'_friendlyname');
/** @var \AttributeExternalKey $oAtt */
$sTargetClass = $oAtt->GetTargetClass(EXTKEY_ABSOLUTE);
$iTargetKey = $this->Get($sAttCode);
if ($iTargetKey < 0)
@@ -746,6 +759,7 @@ abstract class DBObject implements iDisplay
if ($oAtt->IsExternalKey())
{
/** @var \AttributeExternalKey $oAtt */
$sTargetClass = $oAtt->GetTargetClass();
if ($this->IsNew())
{
@@ -1246,6 +1260,7 @@ abstract class DBObject implements iDisplay
{
if (!MetaModel::SkipCheckExtKeys())
{
/** @var \AttributeExternalKey $oAtt */
$sTargetClass = $oAtt->GetTargetClass();
$oTargetObj = MetaModel::GetObject($sTargetClass, $toCheck, false /*must be found*/, true /*allow all data*/);
if (is_null($oTargetObj))
@@ -1364,7 +1379,7 @@ abstract class DBObject implements iDisplay
// Note: $aReasonInfo['name'] could be reported (the task owning the attribute)
$oAttDef = MetaModel::GetAttributeDef(get_class($this), $sAttCode);
$sAttLabel = $oAttDef->GetLabel();
foreach($aReasons as $aReasonInfo)
if (!empty($aReasons))
{
// Todo: associate the attribute code with the error
$this->m_aCheckIssues[] = Dict::Format('UI:AttemptingToSetASlaveAttribute_Name', $sAttLabel);
@@ -1401,6 +1416,11 @@ abstract class DBObject implements iDisplay
// check if it is allowed to delete the existing object from the database
// a displayable error is returned
/**
* @param \DeletionPlan $oDeletionPlan
*
* @throws \CoreException
*/
protected function DoCheckToDelete(&$oDeletionPlan)
{
$this->m_aDeleteIssues = array(); // Ok
@@ -1414,6 +1434,7 @@ abstract class DBObject implements iDisplay
{
$oDeletionPlan->AddToDelete($oReplica, DEL_SILENT);
}
/** @var \SynchroDataSource $oDataSource */
$oDataSource = $aSourceData['source'];
if ($oDataSource->GetKey() == SynchroExecution::GetCurrentTaskId())
{
@@ -1451,7 +1472,12 @@ abstract class DBObject implements iDisplay
}
}
public function CheckToDelete(&$oDeletionPlan)
/**
* @param \DeletionPlan $oDeletionPlan
*
* @return bool
*/
public function CheckToDelete(&$oDeletionPlan)
{
$this->MakeDeletionPlan($oDeletionPlan);
$oDeletionPlan->ComputeResults();
@@ -1535,6 +1561,11 @@ abstract class DBObject implements iDisplay
return (count($aChanges) != 0);
}
/**
* @param \DBObject $oSibling
*
* @return bool
*/
public function Equals($oSibling)
{
if (get_class($oSibling) != get_class($this))
@@ -1599,6 +1630,7 @@ abstract class DBObject implements iDisplay
if ($oAttDef->LoadFromDB()) continue;
if (!array_key_exists($sAttCode, $this->m_aTouchedAtt)) continue;
if (array_key_exists($sAttCode, $this->m_aModifiedAtt) && ($this->m_aModifiedAtt[$sAttCode] == false)) continue;
/** @var \AttributeCustomFields $oAttDef */
$oAttDef->WriteValue($this, $this->m_aCurrValues[$sAttCode]);
}
}
@@ -1622,7 +1654,7 @@ abstract class DBObject implements iDisplay
{
$sValues = implode(', ', self::$m_aBulkInsertItems[$sClass][$sTable]);
$sInsertSQL = "INSERT INTO `$sTable` ($sColumns) VALUES $sValues";
$iNewKey = CMDBSource::InsertInto($sInsertSQL);
CMDBSource::InsertInto($sInsertSQL);
}
}
@@ -1636,7 +1668,7 @@ abstract class DBObject implements iDisplay
{
$sTable = MetaModel::DBGetTable($sTableClass);
// Abstract classes or classes having no specific attribute do not have an associated table
if ($sTable == '') return;
if ($sTable == '') return false;
$sClass = get_class($this);
@@ -1812,6 +1844,7 @@ abstract class DBObject implements iDisplay
$oSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT TriggerOnObjectCreate AS t WHERE t.target_class IN ('$sClassList')"));
while ($oTrigger = $oSet->Fetch())
{
/** @var \Trigger $oTrigger */
$oTrigger->DoActivate($this->ToArgs('this'));
}
@@ -1835,8 +1868,6 @@ abstract class DBObject implements iDisplay
// Abstract classes or classes having no specific attribute do not have an associated table
if ($sTable == '') return;
$sClass = get_class($this);
// fields in first array, values in the second
$aFieldsToWrite = array();
$aValuesToWrite = array();
@@ -1859,6 +1890,7 @@ abstract class DBObject implements iDisplay
$value = $this->m_aCurrValues[$sAttCode];
if ($oAttDef->IsExternalKey())
{
/** @var \AttributeExternalKey $oAttDef */
$sTargetClass = $oAttDef->GetTargetClass();
if (is_array($aAuthorizedExtKeys))
{
@@ -1880,7 +1912,7 @@ abstract class DBObject implements iDisplay
}
}
if (count($aValuesToWrite) == 0) return false;
if (count($aValuesToWrite) == 0) return;
if (count($aHierarchicalKeys) > 0)
{
@@ -1973,7 +2005,7 @@ abstract class DBObject implements iDisplay
$sKey = get_class($this).'::'.$this->GetKey();
if (array_key_exists($sKey, $aUpdateReentrance))
{
return;
return false;
}
$aUpdateReentrance[$sKey] = true;
@@ -2020,6 +2052,16 @@ abstract class DBObject implements iDisplay
// Save the original values (will be reset to the new values when the object get written to the DB)
$aOriginalValues = $this->m_aOrigValues;
// Activate any existing trigger
$sClass = get_class($this);
$sClassList = implode("', '", MetaModel::EnumParentClasses($sClass, ENUM_PARENT_CLASSES_ALL));
$oSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT TriggerOnObjectUpdate AS t WHERE t.target_class IN ('$sClassList')"));
while ($oTrigger = $oSet->Fetch())
{
/** @var \Trigger $oTrigger */
$oTrigger->DoActivate($this->ToArgs('this'));
}
$bHasANewExternalKeyValue = false;
$aHierarchicalKeys = array();
$aDBChanges = array();
@@ -2179,6 +2221,7 @@ abstract class DBObject implements iDisplay
{
// Update the left & right indexes for each hierarchical key
$sTable = $sTable = MetaModel::DBGetTable(get_class($this), $sAttCode);
/** @var \AttributeHierarchicalKey $oAttDef */
$sSQL = "SELECT `".$oAttDef->GetSQLRight()."` AS `right`, `".$oAttDef->GetSQLLeft()."` AS `left` FROM `$sTable` WHERE id=".CMDBSource::Quote($this->m_iKey);
$aRes = CMDBSource::QueryToArray($sSQL);
$iMyLeft = $aRes[0]['left'];
@@ -2201,6 +2244,7 @@ abstract class DBObject implements iDisplay
}
elseif (!$oAttDef->LoadFromDB())
{
/** @var \AttributeCustomFields $oAttDef */
$oAttDef->DeleteValue($this);
}
}
@@ -2249,6 +2293,7 @@ abstract class DBObject implements iDisplay
{
foreach ($aToDelete as $iId => $aData)
{
/** @var \DBObject $oToDelete */
$oToDelete = $aData['to_delete'];
// The deletion based on a deletion plan should not be done for each oject if the deletion plan is common (Trac #457)
// because for each object we would try to update all the preceding ones... that are already deleted
@@ -2267,6 +2312,7 @@ abstract class DBObject implements iDisplay
foreach ($aToUpdate as $iId => $aData)
{
$oToUpdate = $aData['to_reset'];
/** @var \DBObject $oToUpdate */
foreach ($aData['attributes'] as $sRemoteExtKey => $aRemoteAttDef)
{
$oToUpdate->Set($sRemoteExtKey, $aData['values'][$sRemoteExtKey]);
@@ -2297,6 +2343,22 @@ abstract class DBObject implements iDisplay
return MetaModel::EnumTransitions(get_class($this), $sState);
}
/**
* Designed as an action to be called when a stop watch threshold times out
*/
public function ResetStopWatch($sAttCode)
{
$oAttDef = MetaModel::GetAttributeDef(get_class($this), $sAttCode);
if (!$oAttDef instanceof AttributeStopWatch)
{
throw new CoreException("Invalid stop watch id: '$sAttCode'");
}
$oSW = $this->Get($sAttCode);
$oSW->Reset($this, $oAttDef);
$this->Set($sAttCode, $oSW);
return true;
}
/**
* Designed as an action to be called when a stop watch threshold times out
* or from within the framework
@@ -2341,7 +2403,7 @@ abstract class DBObject implements iDisplay
// Old (pre-2.1.0 modules) action definition without any parameter
$aActionCallSpec = array($this, $actionHandler);
$sActionDesc = get_class($this).'::'.$actionHandler;
if (!is_callable($aActionCallSpec))
{
throw new CoreException("Unable to call action: ".get_class($this)."::$actionHandler");
@@ -2360,24 +2422,24 @@ abstract class DBObject implements iDisplay
switch($sParamType)
{
case 'int':
$value = (int)$aDefinition['value'];
break;
$value = (int)$aDefinition['value'];
break;
case 'float':
$value = (float)$aDefinition['value'];
break;
$value = (float)$aDefinition['value'];
break;
case 'bool':
$value = (bool)$aDefinition['value'];
break;
$value = (bool)$aDefinition['value'];
break;
case 'reference':
$value = ${$aDefinition['value']};
break;
$value = ${$aDefinition['value']};
break;
case 'string':
default:
$value = (string)$aDefinition['value'];
$value = (string)$aDefinition['value'];
}
$aParams[] = $value;
}
@@ -2413,7 +2475,7 @@ abstract class DBObject implements iDisplay
$this->Set($sAttCode, $oSW);
}
}
if (!$bDoNotWrite)
{
$this->DBWrite();
@@ -2424,12 +2486,14 @@ abstract class DBObject implements iDisplay
$oSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT TriggerOnStateLeave AS t WHERE t.target_class IN ('$sClassList') AND t.state='$sPreviousState'"));
while ($oTrigger = $oSet->Fetch())
{
/** @var \Trigger $oTrigger */
$oTrigger->DoActivate($this->ToArgs('this'));
}
$oSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT TriggerOnStateEnter AS t WHERE t.target_class IN ('$sClassList') AND t.state='$sNewState'"));
while ($oTrigger = $oSet->Fetch())
{
/** @var \Trigger $oTrigger */
$oTrigger->DoActivate($this->ToArgs('this'));
}
}
@@ -2437,22 +2501,6 @@ abstract class DBObject implements iDisplay
return $bSuccess;
}
/**
* Designed as an action to be called when a stop watch threshold times out
*/
public function ResetStopWatch($sAttCode)
{
$oAttDef = MetaModel::GetAttributeDef(get_class($this), $sAttCode);
if (!$oAttDef instanceof AttributeStopWatch)
{
throw new CoreException("Invalid stop watch id: '$sAttCode'");
}
$oSW = $this->Get($sAttCode);
$oSW->Reset($this, $oAttDef);
$this->Set($sAttCode, $oSW);
return true;
}
/**
* Lifecycle action: Recover the default value (aka when an object is being created)
*/
@@ -2495,6 +2543,7 @@ abstract class DBObject implements iDisplay
{
if ($oAttDef->IsExternalKey())
{
/** @var \AttributeExternalKey $oAttDef */
if ($oAttDef->GetTargetClass() != 'User')
{
throw new Exception("SetCurrentUser: the attribute $sAttCode must be an external key to 'User', found '".$oAttDef->GetTargetClass()."'");
@@ -2528,6 +2577,7 @@ abstract class DBObject implements iDisplay
{
if ($oAttDef->IsExternalKey())
{
/** @var \AttributeExternalKey $oAttDef */
if (!MetaModel::IsParentClass($oAttDef->GetTargetClass(), 'Person'))
{
throw new Exception("SetCurrentContact: the attribute $sAttCode must be an external key to 'Person' or any other class above 'Person', found '".$oAttDef->GetTargetClass()."'");
@@ -2718,8 +2768,18 @@ abstract class DBObject implements iDisplay
/**
* Common to the recording of link set changes (add/remove/modify)
*/
* Common to the recording of link set changes (add/remove/modify)
*
* @param $iLinkSetOwnerId
* @param \AttributeLinkedSet $oLinkSet
* @param $sChangeOpClass
* @param array $aOriginalValues
*
* @return \DBObject|null
* @throws \ArchivedObjectException
* @throws \CoreException
* @throws \CoreUnexpectedValue
*/
private function PrepareChangeOpLinkSet($iLinkSetOwnerId, $oLinkSet, $sChangeOpClass, $aOriginalValues = null)
{
if ($iLinkSetOwnerId <= 0)
@@ -2738,8 +2798,10 @@ abstract class DBObject implements iDisplay
if ($oLinkSet->IsIndirect())
{
// The "item" is on the other end (N-N links)
/** @var \AttributeLinkedSetIndirect $oLinkSet */
$sExtKeyToRemote = $oLinkSet->GetExtKeyToRemote();
$oExtKeyToRemote = MetaModel::GetAttributeDef(get_class($this), $sExtKeyToRemote);
/** @var \AttributeExternalKey $oExtKeyToRemote */
$sItemClass = $oExtKeyToRemote->GetTargetClass();
if ($aOriginalValues)
{
@@ -2785,9 +2847,9 @@ abstract class DBObject implements iDisplay
*/
private function RecordLinkSetListChange($bAdd = true)
{
$aForwardChangeTracking = MetaModel::GetTrackForwardExternalKeys(get_class($this));
foreach(MetaModel::GetTrackForwardExternalKeys(get_class($this)) as $sExtKeyAttCode => $oLinkSet)
{
/** @var \AttributeLinkedSet $oLinkSet */
if (($oLinkSet->GetTrackingLevel() & LINKSET_TRACKING_LIST) == 0) continue;
$iLinkSetOwnerId = $this->Get($sExtKeyAttCode);
@@ -2802,7 +2864,7 @@ abstract class DBObject implements iDisplay
{
$oMyChangeOp->Set("type", "removed");
}
$iId = $oMyChangeOp->DBInsertNoReload();
$oMyChangeOp->DBInsertNoReload();
}
}
}
@@ -2819,12 +2881,12 @@ abstract class DBObject implements iDisplay
protected function RecordAttChanges(array $aValues, array $aOrigValues)
{
$aForwardChangeTracking = MetaModel::GetTrackForwardExternalKeys(get_class($this));
foreach(MetaModel::GetTrackForwardExternalKeys(get_class($this)) as $sExtKeyAttCode => $oLinkSet)
{
if (array_key_exists($sExtKeyAttCode, $aValues))
{
/** @var \AttributeLinkedSet $oLinkSet */
if (($oLinkSet->GetTrackingLevel() & LINKSET_TRACKING_LIST) == 0) continue;
// Keep track of link added/removed
@@ -2856,7 +2918,7 @@ abstract class DBObject implements iDisplay
if ($oMyChangeOp)
{
$oMyChangeOp->Set("link_id", $this->GetKey());
$iId = $oMyChangeOp->DBInsertNoReload();
$oMyChangeOp->DBInsertNoReload();
}
}
}
@@ -2985,6 +3047,7 @@ abstract class DBObject implements iDisplay
foreach($aExtKeys as $sExtKeyAttCode => $oExtKeyAttDef)
{
// skip if this external key is behind an external field
/** @var \AttributeDefinition $oExtKeyAttDef */
if (!$oExtKeyAttDef->IsExternalKey(EXTKEY_ABSOLUTE)) continue;
$oSearch = new DBObjectSearch($sRemoteClass);
@@ -3006,6 +3069,13 @@ abstract class DBObject implements iDisplay
return $aDependentObjects;
}
/**
* @param \DeletionPlan $oDeletionPlan
* @param array $aVisited
* @param int $iDeleteOption
*
* @throws \CoreException
*/
private function MakeDeletionPlan(&$oDeletionPlan, $aVisited = array(), $iDeleteOption = null)
{
static $iLoopTimeLimit = null;
@@ -3016,7 +3086,7 @@ abstract class DBObject implements iDisplay
$sClass = get_class($this);
$iThisId = $this->GetKey();
$iDeleteOption = $oDeletionPlan->AddToDelete($this, $iDeleteOption);
$oDeletionPlan->AddToDelete($this, $iDeleteOption);
if (array_key_exists($sClass, $aVisited))
{
@@ -3048,13 +3118,14 @@ abstract class DBObject implements iDisplay
{
set_time_limit($iLoopTimeLimit);
/** @var \AttributeExternalKey $oAttDef */
$oAttDef = $aData['attribute'];
$iDeletePropagationOption = $oAttDef->GetDeletionPropagationOption();
/** @var \DBObjectSet $oDepSet */
$oDepSet = $aData['objects'];
$oDepSet->Rewind();
while ($oDependentObj = $oDepSet->fetch())
{
$iId = $oDependentObj->GetKey();
if ($oAttDef->IsNullAllowed())
{
// Optional external key, list to reset
@@ -3084,10 +3155,11 @@ abstract class DBObject implements iDisplay
* WILL DEPRECATED SOON
* Caching relying on an object set is not efficient since 2.0.3
* Use GetSynchroData instead
*
*
* Get all the synchro replica related to this object
* @param none
*
* @return DBObjectSet Set with two columns: R=SynchroReplica S=SynchroDataSource
* @throws \OQLException
*/
public function GetMasterReplica()
{
@@ -3098,11 +3170,15 @@ abstract class DBObject implements iDisplay
/**
* Get all the synchro data related to this object
* @param none
*
* @return array of data_source_id => array
* 'source' => $oSource,
* 'attributes' => array of $oSynchroAttribute
* 'replica' => array of $oReplica (though only one should exist, misuse of the data sync can have this consequence)
* 'source' => $oSource,
* 'attributes' => array of $oSynchroAttribute
* 'replica' => array of $oReplica (though only one should exist, misuse of the data sync can have this consequence)
* @throws \CoreException
* @throws \CoreUnexpectedValue
* @throws \MySQLException
* @throws \OQLException
*/
public function GetSynchroData()
{
@@ -3113,6 +3189,7 @@ abstract class DBObject implements iDisplay
$this->m_aSynchroData = array();
while($aData = $oReplicaSet->FetchAssoc())
{
/** @var \DBObject[] $aData */
$iSourceId = $aData['datasource']->GetKey();
if (!array_key_exists($iSourceId, $this->m_aSynchroData))
{
@@ -3120,6 +3197,7 @@ abstract class DBObject implements iDisplay
$oAttrSet = $aData['datasource']->Get('attribute_list');
while($oSyncAttr = $oAttrSet->Fetch())
{
/** @var \DBObject $oSyncAttr */
$aAttributes[$oSyncAttr->Get('attcode')] = $oSyncAttr;
}
$this->m_aSynchroData[$iSourceId] = array(
@@ -3134,7 +3212,7 @@ abstract class DBObject implements iDisplay
}
return $this->m_aSynchroData;
}
public function GetSynchroReplicaFlags($sAttCode, &$aReason)
{
$iFlags = OPT_ATT_NORMAL;
@@ -3150,10 +3228,12 @@ abstract class DBObject implements iDisplay
$oSource = $aSourceData['source'];
if (array_key_exists($sAttCode, $aSourceData['attributes']))
{
/** @var \DBObject $oSyncAttr */
$oSyncAttr = $aSourceData['attributes'][$sAttCode];
if (($oSyncAttr->Get('update') == 1) && ($oSyncAttr->Get('update_policy') == 'master_locked'))
{
$iFlags |= OPT_ATT_SLAVE;
/** @var \SynchroDataSource $oSource */
$sUrl = $oSource->GetApplicationUrl($this, $oReplica);
$aReason[] = array('name' => $oSource->GetName(), 'description' => $oSource->Get('description'), 'url_application' => $sUrl);
}
@@ -3235,11 +3315,13 @@ abstract class DBObject implements iDisplay
/**
* Register a call back that will be called when some internal event happens
*
*
* @param $iType string Any of the CALLBACK_x constants
* @param $callback callable Call specification like a function name, or array('<class>', '<method>') or array($object, '<method>')
* @param $aParameters Array Values that will be passed to the callback, after $this
*/
* @param $aParameters array Values that will be passed to the callback, after $this
*
* @throws \Exception
*/
public function RegisterCallback($iType, $callback, $aParameters = array())
{
$sCallBackName = '';
@@ -3280,7 +3362,7 @@ abstract class DBObject implements iDisplay
* See ExecAction for the syntax and features of the scripted actions
*
* @param $aActions array of statements (e.g. "set(name, Made after $source->name$)")
* @param $aSourceObjects Array of Alias => Context objects (Convention: some statements require the 'source' element
* @param $aSourceObjects array of Alias => Context objects (Convention: some statements require the 'source' element
* @throws Exception
*/
public function ExecActions($aActions, $aSourceObjects)
@@ -3329,6 +3411,14 @@ abstract class DBObject implements iDisplay
/**
* Helper to copy an attribute between two objects (in memory)
* Originally designed for ExecAction()
*
* @param \DBObject $oSourceObject
* @param $sSourceAttCode
* @param $sDestAttCode
*
* @throws \CoreException
* @throws \CoreUnexpectedValue
* @throws \MySQLException
*/
public function CopyAttribute($oSourceObject, $sSourceAttCode, $sDestAttCode)
{
@@ -3352,9 +3442,11 @@ abstract class DBObject implements iDisplay
if (is_object($oSourceAttDef) && $oSourceAttDef->IsLinkSet())
{
// The copy requires that we create a new object set (the semantic of DBObject::Set is unclear about link sets)
/** @var \AttributeLinkedSet $oSourceAttDef */
$oDestSet = DBObjectSet::FromScratch($oSourceAttDef->GetLinkedClass());
$oSourceSet = $oSourceObject->Get($sSourceAttCode);
$oSourceSet->Rewind();
/** @var \DBObject $oSourceLink */
while ($oSourceLink = $oSourceSet->Fetch())
{
// Clone the link
@@ -3397,7 +3489,7 @@ abstract class DBObject implements iDisplay
*
* @param $sVerb string Any of the verb listed above (e.g. "set")
* @param $aParams array of strings (e.g. array('name', 'copied from $source->name$')
* @param $aSourceObjects Array of Alias => Context objects (Convention: some statements require the 'source' element
* @param $aSourceObjects array of Alias => Context objects (Convention: some statements require the 'source' element
* @throws CoreException
* @throws CoreUnexpectedValue
* @throws Exception
@@ -3570,7 +3662,9 @@ abstract class DBObject implements iDisplay
{
$oLinkSet = $this->Get($sTargetListAttCode);
/** @var \AttributeLinkedSetIndirect $oListAttDef */
$oListAttDef = MetaModel::GetAttributeDef(get_class($this), $sTargetListAttCode);
/** @var \AttributeLinkedSet $oListAttDef */
$oLnk = MetaModel::NewObject($oListAttDef->GetLinkedClass());
$oLnk->Set($oListAttDef->GetExtKeyToRemote(), $iObjKey);
if (isset($sRoleAttCode))

View File

@@ -213,7 +213,7 @@ class Dict
/**
* Initialize a the entries for a given language (replaces the former Add() method)
* @param string $sLanguageCode Code identifying the language i.e. 'FR-FR', 'EN-US'
* @param hash $aEntries Hash array of dictionnary entries
* @param array $aEntries Hash array of dictionnary entries
*/
public static function SetEntries($sLanguageCode, $aEntries)
{

View File

@@ -1,5 +1,5 @@
<?php
// Copyright (C) 2010-2012 Combodo SARL
// Copyright (C) 2010-2018 Combodo SARL
//
// This file is part of iTop.
//
@@ -19,21 +19,25 @@
/**
* Persistent class Trigger and derived
* User defined triggers, that may be used in conjunction with user defined actions
* User defined triggers, that may be used in conjunction with user defined actions
*
* @copyright Copyright (C) 2010-2012 Combodo SARL
* @copyright Copyright (C) 2010-2018 Combodo SARL
* @license http://opensource.org/licenses/AGPL-3.0
*/
/**
* A user defined trigger, to customize the application
* A user defined trigger, to customize the application
* A trigger will activate an action
*
* @package iTopORM
*/
abstract class Trigger extends cmdbAbstractObject
{
/**
* @throws \CoreException
* @throws \Exception
*/
public static function Init()
{
$aParams = array
@@ -50,25 +54,32 @@ abstract class Trigger extends cmdbAbstractObject
);
MetaModel::Init_Params($aParams);
//MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeString("description", array("allowed_values"=>null, "sql"=>"description", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeLinkedSetIndirect("action_list", array("linked_class"=>"lnkTriggerAction", "ext_key_to_me"=>"trigger_id", "ext_key_to_remote"=>"action_id", "allowed_values"=>null, "count_min"=>1, "count_max"=>0, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("description", array("allowed_values" => null, "sql" => "description", "default_value" => null, "is_null_allowed" => true, "depends_on" => array())));
MetaModel::Init_AddAttribute(new AttributeLinkedSetIndirect("action_list", array("linked_class" => "lnkTriggerAction", "ext_key_to_me" => "trigger_id", "ext_key_to_remote" => "action_id", "allowed_values" => null, "count_min" => 1, "count_max" => 0, "depends_on" => array())));
// Display lists
MetaModel::Init_SetZListItems('details', array('finalclass', 'description', 'action_list')); // Attributes to be displayed for the complete details
MetaModel::Init_SetZListItems('list', array('finalclass')); // Attributes to be displayed for a list
// Search criteria
// MetaModel::Init_SetZListItems('standard_search', array('name')); // Criteria of the std search form
// MetaModel::Init_SetZListItems('advanced_search', array('name')); // Criteria of the advanced search form
// MetaModel::Init_SetZListItems('standard_search', array('name')); // Criteria of the std search form
// MetaModel::Init_SetZListItems('advanced_search', array('name')); // Criteria of the advanced search form
}
/**
* @param $aContextArgs
*
* @throws \ArchivedObjectException
* @throws \CoreException
*/
public function DoActivate($aContextArgs)
{
// Find the related actions
$oLinkedActions = $this->Get('action_list');
while ($oLink = $oLinkedActions->Fetch())
{
/** @var \DBObject $oLink */
$iActionId = $oLink->Get('action_id');
/** @var \Action $oAction */
$oAction = MetaModel::GetObject('Action', $iActionId);
if ($oAction->IsActive())
{
@@ -76,11 +87,13 @@ abstract class Trigger extends cmdbAbstractObject
}
}
}
/**
* Check whether the given object is in the scope of this trigger
* and can potentially be the subject of notifications
*
* @param DBObject $oObject The object to check
*
* @return bool
*/
public function IsInScope(DBObject $oObject)
@@ -91,8 +104,15 @@ abstract class Trigger extends cmdbAbstractObject
}
}
/**
* Class TriggerOnObject
*/
abstract class TriggerOnObject extends Trigger
{
/**
* @throws \CoreException
* @throws \Exception
*/
public static function Init()
{
$aParams = array
@@ -109,17 +129,20 @@ abstract class TriggerOnObject extends Trigger
);
MetaModel::Init_Params($aParams);
MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeClass("target_class", array("class_category"=>"bizmodel", "more_values"=>"User,UserExternal,UserInternal,UserLDAP,UserLocal", "sql"=>"target_class", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeOQL("filter", array("allowed_values"=>null, "sql"=>"filter", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeClass("target_class", array("class_category" => "bizmodel", "more_values" => "User,UserExternal,UserInternal,UserLDAP,UserLocal", "sql" => "target_class", "default_value" => null, "is_null_allowed" => false, "depends_on" => array())));
MetaModel::Init_AddAttribute(new AttributeOQL("filter", array("allowed_values" => null, "sql" => "filter", "default_value" => null, "is_null_allowed" => true, "depends_on" => array())));
// Display lists
MetaModel::Init_SetZListItems('details', array('description', 'target_class', 'filter', 'action_list')); // Attributes to be displayed for the complete details
MetaModel::Init_SetZListItems('list', array('finalclass', 'target_class', 'description')); // Attributes to be displayed for a list
// Search criteria
MetaModel::Init_SetZListItems('default_search', array('description', 'target_class')); // Default criteria of the search banner
// MetaModel::Init_SetZListItems('standard_search', array('name', 'target_class', 'description')); // Criteria of the search form
// MetaModel::Init_SetZListItems('standard_search', array('name', 'target_class', 'description')); // Criteria of the search form
}
/**
* @throws \CoreException
*/
public function DoCheckToWrite()
{
parent::DoCheckToWrite();
@@ -135,8 +158,7 @@ abstract class TriggerOnObject extends Trigger
{
$this->m_aCheckIssues[] = Dict::Format('TriggerOnObject:WrongFilterClass', $this->Get('target_class'));
}
}
catch(OqlException $e)
} catch (OqlException $e)
{
$this->m_aCheckIssues[] = Dict::Format('TriggerOnObject:WrongFilterQuery', $e->getMessage());
}
@@ -146,21 +168,33 @@ abstract class TriggerOnObject extends Trigger
/**
* Check whether the given object is in the scope of this trigger
* and can potentially be the subject of notifications
*
* @param DBObject $oObject The object to check
*
* @return bool
* @throws \CoreException
*/
public function IsInScope(DBObject $oObject)
{
$sRootClass = $this->Get('target_class');
return ($oObject instanceof $sRootClass);
}
/**
* @param $aContextArgs
*
* @throws \ArchivedObjectException
* @throws \CoreException
*/
public function DoActivate($aContextArgs)
{
$bGo = true;
if (isset($aContextArgs['this->object()']))
{
$bGo = $this->IsTargetObject($aContextArgs['this->object()']->GetKey());
/** @var \DBObject $oObject */
$oObject = $aContextArgs['this->object()'];
$bGo = $this->IsTargetObject($oObject->GetKey(), $oObject->ListChanges());
}
if ($bGo)
{
@@ -168,7 +202,18 @@ abstract class TriggerOnObject extends Trigger
}
}
public function IsTargetObject($iObjectId)
/**
* @param $iObjectId
* @param array $aChanges
*
* @return bool
* @throws \CoreException
* @throws \MissingQueryArgument
* @throws \MySQLException
* @throws \MySQLHasGoneAwayException
* @throws \OQLException
*/
public function IsTargetObject($iObjectId, $aChanges = array())
{
$sFilter = trim($this->Get('filter'));
if (strlen($sFilter) > 0)
@@ -182,14 +227,19 @@ abstract class TriggerOnObject extends Trigger
{
$bRet = true;
}
return $bRet;
}
}
/**
* To trigger notifications when a ticket is updated from the portal
*/
class TriggerOnPortalUpdate extends TriggerOnObject
{
/**
* @throws \CoreException
*/
public static function Init()
{
$aParams = array
@@ -214,8 +264,15 @@ class TriggerOnPortalUpdate extends TriggerOnObject
}
}
/**
* Class TriggerOnStateChange
*/
abstract class TriggerOnStateChange extends TriggerOnObject
{
/**
* @throws \CoreException
* @throws \Exception
*/
public static function Init()
{
$aParams = array
@@ -232,19 +289,25 @@ abstract class TriggerOnStateChange extends TriggerOnObject
);
MetaModel::Init_Params($aParams);
MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeString("state", array("allowed_values"=>null, "sql"=>"state", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("state", array("allowed_values" => null, "sql" => "state", "default_value" => null, "is_null_allowed" => false, "depends_on" => array())));
// Display lists
MetaModel::Init_SetZListItems('details', array('description', 'target_class', 'filter', 'state', 'action_list')); // Attributes to be displayed for the complete details
MetaModel::Init_SetZListItems('list', array('finalclass', 'target_class', 'state')); // Attributes to be displayed for a list
// Search criteria
MetaModel::Init_SetZListItems('standard_search', array('description', 'target_class', 'state')); // Criteria of the std search form
// MetaModel::Init_SetZListItems('advanced_search', array('name')); // Criteria of the advanced search form
// MetaModel::Init_SetZListItems('advanced_search', array('name')); // Criteria of the advanced search form
}
}
/**
* Class TriggerOnStateEnter
*/
class TriggerOnStateEnter extends TriggerOnStateChange
{
/**
* @throws \CoreException
*/
public static function Init()
{
$aParams = array
@@ -267,12 +330,18 @@ class TriggerOnStateEnter extends TriggerOnStateChange
MetaModel::Init_SetZListItems('list', array('target_class', 'state')); // Attributes to be displayed for a list
// Search criteria
MetaModel::Init_SetZListItems('standard_search', array('description', 'target_class', 'state')); // Criteria of the std search form
// MetaModel::Init_SetZListItems('advanced_search', array('name')); // Criteria of the advanced search form
// MetaModel::Init_SetZListItems('advanced_search', array('name')); // Criteria of the advanced search form
}
}
/**
* Class TriggerOnStateLeave
*/
class TriggerOnStateLeave extends TriggerOnStateChange
{
/**
* @throws \CoreException
*/
public static function Init()
{
$aParams = array
@@ -295,12 +364,18 @@ class TriggerOnStateLeave extends TriggerOnStateChange
MetaModel::Init_SetZListItems('list', array('target_class', 'state')); // Attributes to be displayed for a list
// Search criteria
MetaModel::Init_SetZListItems('standard_search', array('description', 'target_class', 'state')); // Criteria of the std search form
// MetaModel::Init_SetZListItems('advanced_search', array('')); // Criteria of the advanced search form
// MetaModel::Init_SetZListItems('advanced_search', array('')); // Criteria of the advanced search form
}
}
/**
* Class TriggerOnObjectCreate
*/
class TriggerOnObjectCreate extends TriggerOnObject
{
/**
* @throws \CoreException
*/
public static function Init()
{
$aParams = array
@@ -323,12 +398,77 @@ class TriggerOnObjectCreate extends TriggerOnObject
MetaModel::Init_SetZListItems('list', array('finalclass', 'target_class')); // Attributes to be displayed for a list
// Search criteria
MetaModel::Init_SetZListItems('standard_search', array('description', 'target_class')); // Criteria of the std search form
// MetaModel::Init_SetZListItems('advanced_search', array('name')); // Criteria of the advanced search form
// MetaModel::Init_SetZListItems('advanced_search', array('name')); // Criteria of the advanced search form
}
}
/**
* Class TriggerOnObjectCreate
*/
class TriggerOnObjectUpdate extends TriggerOnObject
{
/**
* @throws \CoreException
* @throws \Exception
*/
public static function Init()
{
$aParams = array
(
"category" => "grant_by_profile,core/cmdb,application",
"key_type" => "autoincrement",
"name_attcode" => "description",
"state_attcode" => "",
"reconc_keys" => array('description'),
"db_table" => "priv_trigger_onobjupdate",
"db_key_field" => "id",
"db_finalclass_field" => "",
"display_template" => "",
);
MetaModel::Init_Params($aParams);
MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeObjectAttCodeSet('target_attcodes', array("allowed_values" => null, "class" => "target_class", "sql" => "target_attcodes", "default_value" => null, "is_null_allowed" => true, "depends_on" => array('target_class'))));
// Display lists
MetaModel::Init_SetZListItems('details', array('description', 'target_class', 'filter', 'target_attcodes', 'action_list')); // Attributes to be displayed for the complete details
MetaModel::Init_SetZListItems('list', array('finalclass', 'target_class')); // Attributes to be displayed for a list
// Search criteria
MetaModel::Init_SetZListItems('standard_search', array('description', 'target_class')); // Criteria of the std search form
}
public function IsTargetObject($iObjectId, $aChanges = array())
{
if (!parent::IsTargetObject($iObjectId, $aChanges))
{
return false;
}
// Check the attribute
$aAttCodes = $this->Get('target_attcodes');
if (empty($aAttCodes))
{
return true;
}
foreach($aAttCodes as $sAttCode)
{
if (array_key_exists($sAttCode, $aChanges))
{
return true;
}
}
return false;
}
}
/**
* Class lnkTriggerAction
*/
class lnkTriggerAction extends cmdbAbstractObject
{
/**
* @throws \CoreException
* @throws \Exception
*/
public static function Init()
{
$aParams = array
@@ -345,11 +485,11 @@ class lnkTriggerAction extends cmdbAbstractObject
"is_link" => true,
);
MetaModel::Init_Params($aParams);
MetaModel::Init_AddAttribute(new AttributeExternalKey("action_id", array("targetclass"=>"Action", "jointype"=> '', "allowed_values"=>null, "sql"=>"action_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("action_name", array("allowed_values"=>null, "extkey_attcode"=> 'action_id', "target_attcode"=>"name")));
MetaModel::Init_AddAttribute(new AttributeExternalKey("trigger_id", array("targetclass"=>"Trigger", "jointype"=> '', "allowed_values"=>null, "sql"=>"trigger_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("trigger_name", array("allowed_values"=>null, "extkey_attcode"=> 'trigger_id', "target_attcode"=>"description")));
MetaModel::Init_AddAttribute(new AttributeInteger("order", array("allowed_values"=>null, "sql"=>"order", "default_value"=>0, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalKey("action_id", array("targetclass" => "Action", "jointype" => '', "allowed_values" => null, "sql" => "action_id", "is_null_allowed" => false, "on_target_delete" => DEL_AUTO, "depends_on" => array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("action_name", array("allowed_values" => null, "extkey_attcode" => 'action_id', "target_attcode" => "name")));
MetaModel::Init_AddAttribute(new AttributeExternalKey("trigger_id", array("targetclass" => "Trigger", "jointype" => '', "allowed_values" => null, "sql" => "trigger_id", "is_null_allowed" => false, "on_target_delete" => DEL_AUTO, "depends_on" => array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("trigger_name", array("allowed_values" => null, "extkey_attcode" => 'trigger_id', "target_attcode" => "description")));
MetaModel::Init_AddAttribute(new AttributeInteger("order", array("allowed_values" => null, "sql" => "order", "default_value" => 0, "is_null_allowed" => true, "depends_on" => array())));
// Display lists
MetaModel::Init_SetZListItems('details', array('action_id', 'trigger_id', 'order')); // Attributes to be displayed for a list
@@ -360,8 +500,15 @@ class lnkTriggerAction extends cmdbAbstractObject
}
}
/**
* Class TriggerOnThresholdReached
*/
class TriggerOnThresholdReached extends TriggerOnObject
{
/**
* @throws \CoreException
* @throws \Exception
*/
public static function Init()
{
$aParams = array
@@ -379,15 +526,16 @@ class TriggerOnThresholdReached extends TriggerOnObject
MetaModel::Init_Params($aParams);
MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeString("stop_watch_code", array("allowed_values"=>null, "sql"=>"stop_watch_code", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("threshold_index", array("allowed_values"=>null, "sql"=>"threshold_index", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("stop_watch_code", array("allowed_values" => null, "sql" => "stop_watch_code", "default_value" => null, "is_null_allowed" => false, "depends_on" => array())));
MetaModel::Init_AddAttribute(new AttributeString("threshold_index", array("allowed_values" => null, "sql" => "threshold_index", "default_value" => null, "is_null_allowed" => false, "depends_on" => array())));
// Display lists
MetaModel::Init_SetZListItems('details', array('description', 'target_class', 'stop_watch_code', 'threshold_index', 'filter', 'action_list')); // Attributes to be displayed for the complete details
MetaModel::Init_SetZListItems('list', array('target_class', 'threshold_index', 'threshold_index')); // Attributes to be displayed for a list
// Search criteria
MetaModel::Init_SetZListItems('standard_search', array('description', 'target_class')); // Criteria of the std search form
// MetaModel::Init_SetZListItems('advanced_search', array('name')); // Criteria of the advanced search form
// MetaModel::Init_SetZListItems('advanced_search', array('name')); // Criteria of the advanced search form
}
}
?>

View File

@@ -1010,7 +1010,7 @@ table .group-actions {
}
.caselog_field_entry_header {
padding: 6px;
font-size: 1em;
font-size: 0.9em;
border-bottom: 1px solid #fff;
background-color: #f2f2f2;
}

View File

@@ -1087,7 +1087,7 @@ table .group-actions .item-action-wrapper .panel-body > p:last-child{
}
.caselog_field_entry_header{
padding: 6px;
font-size: 1em;
font-size: 0.9em;
border-bottom: 1px solid $white;
background-color: #F2F2F2;
}

View File

@@ -36,7 +36,7 @@ Dict::Add('DA DA', 'Danish', 'Dansk', array(
'Class:ActionEmail/Attribute:to+' => 'Modtager af emailen',
'Class:ActionEmail/Attribute:cc' => 'Cc',
'Class:ActionEmail/Attribute:cc+' => 'Kopi sendes til',
'Class:ActionEmail/Attribute:bcc' => 'bcc',
'Class:ActionEmail/Attribute:bcc' => 'Bcc',
'Class:ActionEmail/Attribute:bcc+' => 'Blind kopi sendes til',
'Class:ActionEmail/Attribute:subject' => 'Emne',
'Class:ActionEmail/Attribute:subject+' => 'Tekst i emne feltet',

View File

@@ -574,7 +574,7 @@ Dict::Add('DA DA', 'Danish', 'Dansk', array(
'UI:AddObjectsOf_Class_LinkedWith_Class_Instance' => 'Tilføj %1$s objekter kædet til %2$s: %3$s',
'UI:AddObjectsOf_Class_LinkedWith_Class' => 'Tilføj %1$s objekter til kæden til %2$s',
'UI:ManageObjectsOf_Class_LinkedWith_Class_Instance' => 'Administrer %1$s objekter kædet til %2$s: %3$s',
'UI:AddLinkedObjectsOf_Class' => 'Tilføj %1$ss...',
'UI:AddLinkedObjectsOf_Class' => 'Tilføj %1$s objekter...',
'UI:RemoveLinkedObjectsOf_Class' => 'Fjern valgte objekter',
'UI:Message:EmptyList:UseAdd' => 'Listen er tom, brug "Tilføj..." knappen for at tilføje elementer.',
'UI:Message:EmptyList:UseSearchForm' => 'Brug søgeformularen ovenfor, til søgning efter objekters som skal tilføjes.',

View File

@@ -495,11 +495,11 @@ Dict::Add('EN US', 'English', 'English', array(
'Class:ActionEmail/Attribute:to+' => 'Destination of the email',
'Class:ActionEmail/Attribute:cc' => 'Cc',
'Class:ActionEmail/Attribute:cc+' => 'Carbon Copy',
'Class:ActionEmail/Attribute:bcc' => 'bcc',
'Class:ActionEmail/Attribute:bcc' => 'Bcc',
'Class:ActionEmail/Attribute:bcc+' => 'Blind Carbon Copy',
'Class:ActionEmail/Attribute:subject' => 'subject',
'Class:ActionEmail/Attribute:subject' => 'Subject',
'Class:ActionEmail/Attribute:subject+' => 'Title of the email',
'Class:ActionEmail/Attribute:body' => 'body',
'Class:ActionEmail/Attribute:body' => 'Body',
'Class:ActionEmail/Attribute:body+' => 'Contents of the email',
'Class:ActionEmail/Attribute:importance' => 'importance',
'Class:ActionEmail/Attribute:importance+' => 'Importance flag',
@@ -588,6 +588,17 @@ Dict::Add('EN US', 'English', 'English', array(
'Class:TriggerOnObjectCreate+' => 'Trigger on object creation of [a child class of] the given class',
));
//
// Class: TriggerOnObjectUpdate
//
Dict::Add('EN US', 'English', 'English', array(
'Class:TriggerOnObjectUpdate' => 'Trigger (on object update)',
'Class:TriggerOnObjectUpdate+' => 'Trigger on object update of [a child class of] the given class',
'Class:TriggerOnObjectUpdate/Attribute:target_attcodes' => 'Target attributes',
'Class:TriggerOnObjectUpdate/Attribute:target_attcodes+' => '',
));
//
// Class: TriggerOnThresholdReached
//

View File

@@ -751,7 +751,7 @@ Dict::Add('EN US', 'English', 'English', array(
'UI:AddObjectsOf_Class_LinkedWith_Class_Instance' => 'Add %1$s objects linked with %2$s: %3$s',
'UI:AddObjectsOf_Class_LinkedWith_Class' => 'Add %1$s objects to link with the %2$s',
'UI:ManageObjectsOf_Class_LinkedWith_Class_Instance' => 'Manage %1$s objects linked with %2$s: %3$s',
'UI:AddLinkedObjectsOf_Class' => 'Add %1$ss...',
'UI:AddLinkedObjectsOf_Class' => 'Add %1$s objects...',
'UI:RemoveLinkedObjectsOf_Class' => 'Remove selected objects',
'UI:Message:EmptyList:UseAdd' => 'The list is empty, use the "Add..." button to add elements.',
'UI:Message:EmptyList:UseSearchForm' => 'Use the search form above to search for objects to be added.',

View File

@@ -61,6 +61,10 @@ Dict::Add('FR FR', 'French', 'Français', array(
'Class:TriggerOnStateLeave+' => '',
'Class:TriggerOnObjectCreate' => 'Déclencheur sur la création d\'un objet',
'Class:TriggerOnObjectCreate+' => '',
'Class:TriggerOnObjectUpdate' => 'Déclencheur sur la modification d\'un objet',
'Class:TriggerOnObjectUpdate+' => '',
'Class:TriggerOnObjectUpdate/Attribute:target_attcodes' => 'Attributs cible',
'Class:TriggerOnObjectUpdate/Attribute:target_attcodes+' => '',
'Class:lnkTriggerAction' => 'Actions-Déclencheur',
'Class:lnkTriggerAction+' => '',
'Class:lnkTriggerAction/Attribute:action_id' => 'Action',

View File

@@ -34,11 +34,11 @@ Dict::Add('JA JP', 'Japanese', '日本語', array(
'Class:ActionEmail/Attribute:to+' => 'メールの宛先',
'Class:ActionEmail/Attribute:cc' => 'Cc',
'Class:ActionEmail/Attribute:cc+' => 'Carbon Copy',
'Class:ActionEmail/Attribute:bcc' => 'bcc',
'Class:ActionEmail/Attribute:bcc' => 'Bcc',
'Class:ActionEmail/Attribute:bcc+' => 'Blind Carbon Copy',
'Class:ActionEmail/Attribute:subject' => 'subject',
'Class:ActionEmail/Attribute:subject' => 'Subject',
'Class:ActionEmail/Attribute:subject+' => 'メールの題名',
'Class:ActionEmail/Attribute:body' => 'body',
'Class:ActionEmail/Attribute:body' => 'Body',
'Class:ActionEmail/Attribute:body+' => 'メールの本文',
'Class:ActionEmail/Attribute:importance' => '重要度',
'Class:ActionEmail/Attribute:importance+' => '重要度フラグ',

View File

@@ -485,11 +485,11 @@ Dict::Add('NL NL', 'Dutch', 'Nederlands', array(
'Class:ActionEmail/Attribute:to+' => 'Bestemming van de e-mail',
'Class:ActionEmail/Attribute:cc' => 'Cc',
'Class:ActionEmail/Attribute:cc+' => 'Carbon Copy',
'Class:ActionEmail/Attribute:bcc' => 'bcc',
'Class:ActionEmail/Attribute:bcc' => 'Bcc',
'Class:ActionEmail/Attribute:bcc+' => 'Blind Carbon Copy',
'Class:ActionEmail/Attribute:subject' => 'onderwerp',
'Class:ActionEmail/Attribute:subject' => 'Onderwerp',
'Class:ActionEmail/Attribute:subject+' => 'Titel van de e-mail',
'Class:ActionEmail/Attribute:body' => 'body',
'Class:ActionEmail/Attribute:body' => 'Body',
'Class:ActionEmail/Attribute:body+' => 'Inhoud van de e-mail',
'Class:ActionEmail/Attribute:importance' => 'Prioriteit',
'Class:ActionEmail/Attribute:importance+' => 'Prioriteitsvlag',

View File

@@ -302,9 +302,9 @@ Dict::Add('TR TR', 'Turkish', 'Türkçe', array(
'Class:ActionEmail/Attribute:to+' => 'E-posta alıcısı',
'Class:ActionEmail/Attribute:cc' => 'Kopya',
'Class:ActionEmail/Attribute:cc+' => 'Kopya',
'Class:ActionEmail/Attribute:bcc' => 'gizli kopya',
'Class:ActionEmail/Attribute:bcc' => 'Gizli kopya',
'Class:ActionEmail/Attribute:bcc+' => 'Gizli alıcı',
'Class:ActionEmail/Attribute:subject' => 'konu',
'Class:ActionEmail/Attribute:subject' => 'Konu',
'Class:ActionEmail/Attribute:subject+' => 'E-posta konusu',
'Class:ActionEmail/Attribute:body' => 'E-posta içeriği',
'Class:ActionEmail/Attribute:body+' => 'E-posta içeriği',

View File

@@ -301,7 +301,7 @@ Dict::Add('ZH CN', 'Chinese', '简体中文', array(
'Class:ActionEmail/Attribute:to+' => '邮件的目的地',
'Class:ActionEmail/Attribute:cc' => 'Cc',
'Class:ActionEmail/Attribute:cc+' => 'Carbon Copy',
'Class:ActionEmail/Attribute:bcc' => 'bcc',
'Class:ActionEmail/Attribute:bcc' => 'Bcc',
'Class:ActionEmail/Attribute:bcc+' => 'Blind Carbon Copy',
'Class:ActionEmail/Attribute:subject' => '主题',
'Class:ActionEmail/Attribute:subject+' => '邮件标题',

View File

@@ -180,17 +180,11 @@ $(function()
$('body').on('update_history.itop', function(oEvent, oData) {
// if (me.element.parents('.ui-dialog').length != 0)
// {
// //search form in modal are forbidden to update history!
// return;
// }
if ($('.ui-dialog:visible :itop-search_form_handler').length != 0)
{
//if a modal containing a search form is visible then the history update event come from it, whe do not want to update the history in this case! because search form in modal are forbidden to update history!
return;
}
if (me.element.parents('.ui-dialog').length !== 0)
{
//search form in modal are forbidden to update history!
return;
}
var sNewUrl = GetAbsoluteUrlAppRoot()+'pages/UI.php?operation=search';
sNewUrl = sNewUrl + '&filter='+oData['filter'];
@@ -1016,6 +1010,10 @@ $(function()
}
}
$.extend(oListParams, this.options.list_params);
if (me.element.parents('.ui-dialog').length !== 0)
{
oListParams.update_history = false;
}
oData.list_params = JSON.stringify(oListParams);
if (true === bAbortIfNoChange)

View File

@@ -1575,11 +1575,17 @@ EOF
if (!$bApplyStimulus)
{
$sMessage = Dict::S('UI:FailedToApplyStimuli');
$sSeverity = 'error';
$sSeverity = 'error';
$sOwnershipToken = utils::ReadPostedParam('ownership_token', null, 'raw_data');
if ($sOwnershipToken !== null)
{
// Release the concurrent lock, if any
iTopOwnershipLock::ReleaseLock(get_class($oObj), $oObj->GetKey(), $sOwnershipToken);
}
}
else if ($sIssues != '')
{
$sOwnershipToken = utils::ReadPostedParam('ownership_token', null, 'raw_data');
if ($sOwnershipToken !== null)
{