<commit_before><?php
/*
 * Copyright 2016 Centreon (http://www.centreon.com/)
 *
 * Centreon is a full-fledged industry-strength solution that meets 
 * the needs in IT infrastructure and application monitoring for 
 * service performance.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0  
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,*
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

class GlpiProvider extends AbstractProvider {
    protected $_glpi_connected = 0;
    protected $_glpi_session = null;
    
    const GPLI_ENTITIES_TYPE = 10;
    const GPLI_GROUPS_TYPE = 11;
    const GLPI_ITIL_CATEGORIES_TYPE = 12;
    
    const ARG_CONTENT = 1;
    const ARG_ENTITY = 2;
    const ARG_URGENCY = 3;
    const ARG_IMPACT = 4;
    const ARG_CATEGORY = 5;
    const ARG_USER = 6;
    const ARG_USER_EMAIL = 7;
    const ARG_GROUP = 8;
    const ARG_GROUP_ASSIGN = 9;
    const ARG_TITLE = 10;
    
    protected $_internal_arg_name = array(
        self::ARG_CONTENT => 'content',
        self::ARG_ENTITY => 'entity',
        self::ARG_URGENCY => 'urgency',
        self::ARG_IMPACT => 'impact',
        self::ARG_CATEGORY => 'category',
        self::ARG_USER => 'user',
        self::ARG_USER_EMAIL => 'user_email',
        self::ARG_GROUP => 'group',
        self::ARG_GROUP_ASSIGN => 'groupassign',
        self::ARG_TITLE => 'title',
    );

    function __destruct() {
        $this->logoutGlpi();
    }
    
    /**
     * Set default extra value 
     *
     * @return void
     */
    protected function _setDefaultValueExtra() {
        $this->default_data['address'] = '127.0.0.1';
        $this->default_data['path'] = '/glpi/plugins/webservices/xmlrpc.php';
        $this->default_data['https'] = 0;
        $this->default_data['timeout'] = 60;
        $this->default_data['body'] = '
{$user.alias} open ticket at {$smarty.now|date_format:"%d/%m/%y %H:%M:%S"}

{$custom_message}

{include file="file:$centreon_open_tickets_path/providers/Abstract/templates/display_selected_lists.ihtml" separator="<br/>"}

{if $host_selected|@count gt 0}
{foreach from=$host_selected item=host}
Host: {$host.name}
State: {$host.state_str}
Duration: {$host.last_hard_state_change_duration}
Output: {$host.output|substr:0:1024}

{/foreach}
{/if}

{if $service_selected|@count gt 0} 
{foreach from=$service_selected item=service}
Host: {$service.host_name}
Service: {$service.description}
State: {$service.state_str}
Duration: {$service.last_hard_state_change_duration}
Output: {$service.output|substr:0:1024}<commit_msg>+ update glpi provider separator<commit_after><?php
/*
 * Copyright 2016 Centreon (http://www.centreon.com/)
 *
 * Centreon is a full-fledged industry-strength solution that meets 
 * the needs in IT infrastructure and application monitoring for 
 * service performance.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0  
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,*
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

class GlpiProvider extends AbstractProvider {
    protected $_glpi_connected = 0;
    protected $_glpi_session = null;
    
    const GPLI_ENTITIES_TYPE = 10;
    const GPLI_GROUPS_TYPE = 11;
    const GLPI_ITIL_CATEGORIES_TYPE = 12;
    
    const ARG_CONTENT = 1;
    const ARG_ENTITY = 2;
    const ARG_URGENCY = 3;
    const ARG_IMPACT = 4;
    const ARG_CATEGORY = 5;
    const ARG_USER = 6;
    const ARG_USER_EMAIL = 7;
    const ARG_GROUP = 8;
    const ARG_GROUP_ASSIGN = 9;
    const ARG_TITLE = 10;
    
    protected $_internal_arg_name = array(
        self::ARG_CONTENT => 'content',
        self::ARG_ENTITY => 'entity',
        self::ARG_URGENCY => 'urgency',
        self::ARG_IMPACT => 'impact',
        self::ARG_CATEGORY => 'category',
        self::ARG_USER => 'user',
        self::ARG_USER_EMAIL => 'user_email',
        self::ARG_GROUP => 'group',
        self::ARG_GROUP_ASSIGN => 'groupassign',
        self::ARG_TITLE => 'title',
    );

    function __destruct() {
        $this->logoutGlpi();
    }
    
    /**
     * Set default extra value 
     *
     * @return void
     */
    protected function _setDefaultValueExtra() {
        $this->default_data['address'] = '127.0.0.1';
        $this->default_data['path'] = '/glpi/plugins/webservices/xmlrpc.php';
        $this->default_data['https'] = 0;
        $this->default_data['timeout'] = 60;
        $this->default_data['body'] = '
{$user.alias} open ticket at {$smarty.now|date_format:"%d/%m/%y %H:%M:%S"}

{$custom_message}

{include file="file:$centreon_open_tickets_path/providers/Abstract/templates/display_selected_lists.ihtml" separator=""}

{if $host_selected|@count gt 0}
{foreach from=$host_selected item=host}
Host: {$host.name}
State: {$host.state_str}
Duration: {$host.last_hard_state_change_duration}
Output: {$host.output|substr:0:1024}

{/foreach}
{/if}

{if $service_selected|@count gt 0} 
{foreach from=$service_selected item=service}
Host: {$service.host_name}
Service: {$service.description}
State: {$service.state_str}
Duration: {$service.last_hard_state_change_duration}
Output: {$service.output|substr:0:1024}
{'fraction_non_alphanumeric': 0.12495755517826825, 'fraction_numerical': 0.01595925297113752, 'mean_word_length': 3.5595975232198143, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 36, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 2}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1117559', 'n_tokens_mistral': 1972, 'n_tokens_neox': 1879, 'n_words': 481}