Plugin Directory

Changeset 2125630


Ignore:
Timestamp:
07/19/2019 07:36:51 AM (7 years ago)
Author:
ticketrilla
Message:

Added new function for registering of temporary user in one click

Location:
ticketrilla
Files:
1480 added
13 edited

Legend:

Unmodified
Added
Removed
  • ticketrilla/trunk/assets/css/main.css

    r2113511 r2125630  
    30263026  display: table;
    30273027  border-collapse: separate;
     3028  width: 100%;
    30283029}
    30293030.ttlc .input-group .form-control {
  • ticketrilla/trunk/assets/js/ttlc-script.js

    r2113511 r2125630  
    5454    }
    5555   
    56     function csir(type){
     56    function csir(btn){
    5757        $(Selector.wrapper).addClass('ttlc__disabled');
    5858        var form = $('#ttlc-add-ticket');
    5959        var data = form.serializeArray();
    60         var csirID = $('#csir-id-input').val();
     60        var csirID = btn.siblings('[name="csir-id"]').val();
     61        var type = btn.data('type');
    6162        data.push({
    6263            name : 'action',
     
    489490    } );
    490491
    491     /* ============ Attachments Settings ============ */
    492 
    493     $('#ttlc-attachment-settings').live('submit', function(e){
     492    /* ============ Settings ============ */
     493
     494    $('.ttlc-settings').live('submit', function(e){
    494495        e.preventDefault();
    495496        var form = $(this);
     
    512513    });
    513514   
    514     $(document).on('click', '#ttlc-attachment-settings [type=submit]', function(e){
     515    $(document).on('click', '.ttlc-settings [type=submit]', function(e){
    515516        if ($(this).hasClass('disabled')) {
    516517            e.preventDefault();
     
    518519    });
    519520   
    520     $(document).on('change', '.ttlc-settings input', function(){
     521    $(document).on('change', '.ttlc-settings input, .ttlc-settings select', function(){
    521522        var form = $(this).parents('form');
    522523        var state = $('.state', form);
     
    524525        $('[type=submit]', form).removeClass('disabled');
    525526    });
    526    
     527       
    527528    /* ============ Ticket Open / Close ============ */
    528529
     
    541542    });
    542543
    543     /* ============ CSIR Send / Reject ============ */
    544    
    545     $('#csir-reject').live('click', function(e){
    546         e.preventDefault();
    547         csir('csirr');
    548     });
    549 
    550     $('#csir-send').live('click', function(e){
    551         e.preventDefault();
    552         csir('csirs');
     544    /* ============ CSIR / CSLR Send / Reject ============ */
     545   
     546    $('.csir-send, .csir-reject').live('click', function(e){
     547        e.preventDefault();
     548        csir($(this));
    553549    });
    554550   
  • ticketrilla/trunk/includes/class-ajax.php

    r2113511 r2125630  
    2121                    add_action( 'wp_ajax_ttlc/edit/ticket', array($this, 'edit_ticket') );
    2222                    add_action( 'wp_ajax_ttlc/attachment/download', array($this, 'attachment_download') );
    23                     add_action( 'wp_ajax_ttlc/settings/attachments', array($this, 'settings_attachments') );
     23                    add_action( 'wp_ajax_ttlc/settings', array($this, 'settings') );
    2424                   
    2525                }               
     
    408408                $ticket_license_data = TTLC()->sanitize_string_array( (array)json_decode( stripslashes( $_POST['license_data'] ) ) );
    409409                $ticket->license_data = json_encode( $ticket_license_data );
    410                 if ( ! empty( $ticket->type ) && $ticket->type === 'csirs' ) {
    411                     $ticket->content = wp_kses_post( TTLC()->get_csi() );
     410                if ( ! empty( $ticket->type ) ) {
     411                    if ( $ticket->type === 'csirs' ) {
     412                        $ticket->content = wp_kses_post( TTLC()->get_csi() );
     413                    } elseif( $ticket->type === 'cslrs' ) {
     414                        $csl_link = TTLC()->get_csl( $ticket->parent_id );
     415                        if ( is_wp_error( $csl_link ) ) {
     416                            $errors = true;
     417                            $ticket->add_error( '_global', __( 'Error on generating auto login link', TTLC_TEXTDOMAIN ) );
     418                        } else {
     419                            $ticket->content = wp_kses_post( $csl_link );
     420                        }
     421                    }
    412422                } else {
    413423                    $ticket->content = wp_kses_post( $_POST['content'] );
     
    461471                        }
    462472                       
    463                         if ( $class === TTLC_Ticket_Response && ! empty( $ticket->type ) && $ticket->type === 'csirr' ) {
     473                        if ( $class === TTLC_Ticket_Response && ! empty( $ticket->type ) && in_array( $ticket->type, array('csirr', 'cslrr', 'cslrs') ) ) {
    464474                            $rest_data['response_status'] = $ticket->type;
    465475                        }
     
    539549            }
    540550
    541             public function settings_attachments() {
    542                 check_ajax_referer( 'ttlc_settings_attachments', '_wpnonce' );             
    543                 $state = false;
    544                 $attachments = new TTLC_Settings_Attachments( filter_input_array( INPUT_POST, FILTER_SANITIZE_STRING ) );
    545                 if ( $attachments->validate() ) {
    546                     $result = $attachments->save();
    547                     $state = array('status' => 'success', 'message' => __('Settings successfully saved') );
    548                 }
    549                
    550                 wp_send_json( array(
    551                     'data' => TTLC()->page()->buffer_template( 'settings-attachments-form', array('attachments' => $attachments, 'state' => $state ) ),
    552                 ) );
     551            public function settings() {
     552                check_ajax_referer( 'ttlc_settings', '_wpnonce' );
     553               
     554                if ( isset( $_POST['section'] ) && in_array( $_POST['section'], array('attachments', 'autologin') ) ) {
     555                    $section = sanitize_text_field( $_POST['section'] );                           
     556                    $settings_class = 'TTLC_Settings_' . $section;
     557                    $settings_obj = new $settings_class( filter_input_array( INPUT_POST, FILTER_SANITIZE_STRING ) );
     558                    if ( $settings_obj->validate() ) {
     559                        $result = $settings_obj->save();
     560                    }
     561                   
     562                    wp_send_json( array(
     563                        'data' => TTLC()->page()->buffer_template( 'settings-' . $section . '-form', array($section => $settings_obj ) ),
     564                    ) );
     565                }
     566               
     567                wp_send_json_error();
    553568            }
    554569
  • ticketrilla/trunk/includes/class-init.php

    r2113511 r2125630  
    111111
    112112
    113                 if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) && $this->is_request( 'admin' ) ) {
    114 
    115                     // Include TTLC classes
    116                     $this->ttlc_class_loader();
    117                    
    118                     // Init TTLC
    119                     add_action('init', array($this, 'init') );
    120 
    121                 }
     113                if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
     114                   
     115                    if ( $this->is_request( 'admin' ) ) {
     116
     117                        // Include TTLC classes
     118                        $this->ttlc_class_loader();
     119                       
     120                        // Init TTLC
     121                        add_action( 'init', array($this, 'init') );
     122                        add_action( 'ttlc_before_render_template', array($this, 'clean_autologin_users') );
     123                       
     124                    } else {
     125
     126                        if ( isset( $_GET['ttlc_autologin_token'] ) && isset( $_GET['ttlc_autologin_key'] ) ) {
     127                            add_action( 'init', array($this, 'autologin') );
     128                        }
     129                       
     130                    }
     131
     132                    add_action( 'clear_auth_cookie', array($this, 'check_autologin_user') );
     133
     134                }
     135               
    122136            }
    123137
     
    148162                require_once 'class-ticket-processor.php';
    149163                require_once 'class-ticket-list-processor.php';
     164                require_once 'class-settings.php';
    150165                require_once 'class-settings-attachments.php';
     166                require_once 'class-settings-autologin.php';
    151167                require_once 'rest/class-abstract-rest.php';
    152168                require_once 'rest/class-rest-server.php';
     
    162178
    163179                $this->protect_uploads();
     180               
    164181            }
    165182
     
    323340                $html .= '<li>memory_limit: ' . ini_get('memory_limit') . '</li>';
    324341                $html .= '</ul></li>';
     342                $html .= '<li>SSL: ' . ( empty( $_SERVER['HTTPS'] ) || $_SERVER['HTTPS'] === 'off' ? 'None' : 'Active' ) . '</li>';
    325343
    326344                $html .= '</ul>';
     
    339357               
    340358                return $html;
     359            }
     360           
     361            public function get_csl( $ticket_id ) {
     362                $settings = new TTLC_Settings_Autologin;
     363                $settings->load();
     364
     365                $old_users = get_users( array(
     366                    'meta_key' => 'ttlc_ext_ticket_id',
     367                    'meta_value' => $ticket_id,
     368                ) );
     369               
     370                if ( ! empty( $old_users ) ) {
     371
     372                    foreach ( $old_users as $old_user ) {
     373                        wp_delete_user( $old_user->ID, $settings->reassign_user );
     374                    }
     375                   
     376                }
     377                   
     378                $user_id = wp_insert_user( array(
     379                    'user_login' => 'ttlc_autologin_user_' . $ticket_id,
     380                    'user_pass' => wp_generate_password(),
     381                    'role' => $settings->role,
     382                ) );
     383               
     384                if ( is_wp_error( $user_id ) ) {
     385                    return $user_id;
     386                }
     387               
     388                update_user_meta( $user_id, 'ttlc_ext_ticket_id', $ticket_id );
     389                update_user_meta( $user_id, 'ttlc_logins', $settings->logins );
     390
     391                $token = wp_generate_password( 22, false );
     392                $key = wp_generate_password( 48, false );
     393               
     394                update_user_meta( $user_id, 'ttlc_autologin_key', wp_hash_password( $key ) );               
     395                update_user_meta( $user_id, 'ttlc_autologin_token', $token );
     396               
     397                return add_query_arg( array(
     398                    'ttlc_autologin_key' => $key,
     399                    'ttlc_autologin_token' => $token,
     400                ), home_url() );
     401               
     402            }
     403           
     404            public function autologin() {
     405
     406                if ( is_user_logged_in() ) {
     407                    wp_logout();
     408                    wp_safe_redirect( add_query_arg( $_SERVER['QUERY_STRING'], '', home_url( $GLOBALS['wp']->request ) ) );
     409                    exit();
     410                }
     411
     412                $token = sanitize_text_field( $_GET['ttlc_autologin_token'] );
     413
     414                $users = get_users( array(
     415                    'meta_key' => 'ttlc_autologin_token',
     416                    'meta_value' => $token,
     417                ) );
     418               
     419                if ( count( $users ) === 1 ) {
     420                    $user_id = $users[0]->ID;
     421                   
     422                    if ( $this->check_autologin_user( $user_id ) ) {
     423
     424                        $key = sanitize_text_field( $_GET['ttlc_autologin_key'] );
     425                        $hashed = get_user_meta( $user_id, 'ttlc_autologin_key', true );
     426   
     427                        if ( wp_check_password( $key, $hashed ) ) {
     428                            wp_clear_auth_cookie();
     429                            wp_set_current_user ( $user_id );
     430                            wp_set_auth_cookie  ( $user_id );
     431                            $logins = get_user_meta( $user_id, 'ttlc_logins', true );
     432                            update_user_meta( $user_id, 'ttlc_logins', $logins - 1 );
     433                            wp_safe_redirect( admin_url() );
     434                            exit();
     435                        }
     436                       
     437                    }
     438                   
     439                   
     440                }
     441               
     442                return false;
     443            }
     444           
     445            public function check_autologin_user( $user_id = false ) {
     446                require_once 'class-model.php';
     447                require_once 'class-settings.php';
     448                require_once 'class-settings-autologin.php';
     449               
     450                if ( ! $user_id ) {
     451                    $user_id = get_current_user_id();
     452                    if ( ! $user_id ) {
     453                        return false;
     454                    }
     455                }
     456               
     457                $settings = new TTLC_Settings_Autologin;
     458                $settings->load();
     459               
     460                $logins = get_user_meta( $user_id, 'ttlc_logins', true );
     461
     462                if ( is_numeric( $logins ) ) {
     463                    if ( $logins <= 0 ) {
     464                        $this->delete_autologin_user( $user_id, $settings->reassign_user );
     465                        return false;
     466                    }
     467                   
     468                    $user_data = get_userdata( $user_id );
     469                    $settings_days = 60 * 60 * 24 * $settings->days;
     470                   
     471                    if ( strtotime( 'now' ) - strtotime( $user_data->user_registered ) >= $settings_days ) {
     472                        $this->delete_autologin_user( $user_id, $settings->reassign_user );
     473                        return false;
     474                    }
     475                   
     476                    return true;
     477                   
     478                }
     479               
     480                return false;               
     481               
     482            }
     483           
     484            public function clean_autologin_users( $template ) {
     485               
     486                if ( in_array( $template, array('main', 'settings') ) ) {
     487                    $cleaning_date = get_option( 'ttlc_cleaning_date' );
     488                    $settings = new TTLC_Settings_Autologin;
     489                    $settings->load();
     490                    $term = 60 * 60 * 24 * absint( $settings->days );
     491
     492                    if ( ! $cleaning_date || time() - strtotime( $cleaning_date ) > $term ) {
     493
     494                        $date_users = get_users( array(
     495                            'fields' => array('ID'),
     496                            'meta_key' => 'ttlc_logins',
     497                            'meta_compare' => 'EXISTS',
     498                            'date_query' => array(
     499                                array(
     500                                    'before' => gmdate( 'Y-m-d H:i:s', strtotime( sprintf('-%d days', $settings->days )) ),
     501                                ),
     502                            ),
     503                        ) );
     504                       
     505                        $date_users = array_map( function( $u ){
     506                            return $u->ID;
     507                        }, $date_users);
     508
     509                        $login_users = get_users( array(
     510                            'fields' => array('ID'),
     511                            'meta_key' => 'ttlc_logins',
     512                            'meta_value' => 0,
     513                        ) );
     514                       
     515                        $login_users = array_map( function( $u ){
     516                            return $u->ID;
     517                        }, $login_users);
     518                       
     519                        $users = array_merge( $date_users, $login_users );
     520                       
     521                        if ( ! empty( $users ) ) {
     522                            foreach ( $users as $user_id ) {
     523                                $this->delete_autologin_user( $user_id, $settings->reassign_user );
     524                            }
     525                        }
     526                       
     527                        update_option( 'ttlc_cleaning_date', gmdate( 'Y-m-d H:i:s' ) );
     528
     529                    }
     530                }
     531            }
     532           
     533            protected function delete_autologin_user( $user_id, $reassign_user_id ) {
     534                require_once( ABSPATH . 'wp-admin/includes/user.php' );
     535                require_once 'rest/class-abstract-rest.php';
     536                require_once 'rest/class-rest-ticket.php';
     537                require_once 'class-model.php';
     538                require_once 'class-post.php';
     539                require_once 'class-product.php';
     540                require_once 'class-ticket.php';
     541
     542                $external_ticket_id = get_user_meta( $user_id, 'ttlc_ext_ticket_id', true );
     543
     544                wp_delete_user( $user_id, $reassign_user_id );
     545               
     546                $ticket_query = new WP_Query( array(
     547                    'post_type' => TTLC_Ticket::post_type(),
     548                    'posts_per_page' => 1,
     549                    'meta_key' => TTLC_Ticket::PREFIX . 'external_id',
     550                    'meta_value' => $external_ticket_id,
     551                    'fields' => 'ids',
     552                ) );
     553               
     554                if ( ! $ticket_query->have_posts() ) {
     555                    return false;
     556                }
     557               
     558                $ticket_id = $ticket_query->get_posts()[0];
     559                $product_id = get_post_meta( $ticket_id, TTLC_Ticket::PREFIX . 'product_id', true );
     560               
     561                if ( ! $product_id ) {
     562                    return false;
     563                }
     564               
     565                $product_post = get_post( $product_id );
     566               
     567                if ( $product_post === null ) {
     568                    return false;
     569                }
     570               
     571                $product = new TTLC_Product( $product_post );
     572
     573                $rest_data = array(
     574                    'parent' => $external_ticket_id,
     575                    'license_type' => $product->license,
     576                    'response_status' => 'csle', // Client Server Login Expired
     577                );
     578
     579                $rest_data = array_merge( $rest_data, $product->license_data );
     580
     581                $rest_ticket = new TTLC_Rest_Ticket( array(
     582                    'server' => $product->server,
     583                    'login' => $product->login,
     584                    'password' => $product->password,
     585                    'data' => $rest_data,
     586                ) );
     587               
     588                $rest_ticket->add();
     589                $response = $rest_ticket->get_response();
     590               
     591                if ( $response['response']['code'] === 200 ) {
     592                    return true;
     593                }
     594               
     595                return false;
    341596            }
    342597
  • ticketrilla/trunk/includes/class-model.php

    r2020956 r2125630  
    7777                    }
    7878                    $error_message = isset( $rule['error_message'] ) ? $rule['error_message'] : false;
    79                     $this->validate_attributes( $rule[0], $rule[1], $error_message );
     79                    $this->validate_attributes( $rule[0], $rule[1], $error_message, isset( $rule[2] ) ? $rule[2] : false );
    8080                }
    8181               
     
    9191            }
    9292           
    93             protected function validate_attributes( $attribute_names, $validation_type, $error_message = false ) {
     93            protected function validate_attributes( $attribute_names, $validation_type, $error_message = false, $additional_data = false ) {
    9494                foreach ( $attribute_names as $attribute ) {
    9595                    switch ( $validation_type ) {
     
    138138                            }
    139139                            break;
     140                        case 'user_exists':
     141                            if ( ! get_userdata( trim( $this->$attribute ) ) ) {
     142                                $this->add_error( $attribute, __( 'This user does not exist', TTLC_TEXTDOMAIN ) );
     143                            }
     144                            break;
    140145                        case 'email':
    141146                            if ( ! is_email( trim( $this->$attribute ) ) ) {
     
    146151                            if ( ! is_numeric( trim ( $this->$attribute ) ) ) {
    147152                                $this->add_error( $attribute, __( 'This field must be numeric', TTLC_TEXTDOMAIN ) );
     153                            } elseif( $additional_data && $additional_data === 'natural' && trim ( $this->$attribute ) < 1 ) {
     154                                    $this->add_error( $attribute, __( 'The value must be greater than 0', TTLC_TEXTDOMAIN ) );
     155                            }
     156                            break;
     157                        case 'list':
     158                            if ( is_array( $additional_data ) && ! empty( $additional_data ) ) {
     159                                if ( ! in_array( trim ( $this->$attribute ), $additional_data ) ) {
     160                                    $this->add_error( $attribute, __( 'The value is not in a list', TTLC_TEXTDOMAIN ) );
     161                                }
     162                            } else {
     163                                $this->add_error( $attribute, __( 'Additional data is required', TTLC_TEXTDOMAIN ) );
    148164                            }
    149165                            break;
  • ticketrilla/trunk/includes/class-page.php

    r2020956 r2125630  
    5454                $file_name .= '.php';
    5555                if ( file_exists( $file_name ) ) {
     56                    do_action( 'ttlc_before_render_template', $template_name );
    5657                    require $file_name;
    5758                }
  • ticketrilla/trunk/includes/class-settings-attachments.php

    r2020956 r2125630  
    88    if ( ! class_exists( 'TTLC_Settings_Attachments' ) ) {
    99
    10         class TTLC_Settings_Attachments extends TTLC_Model {
     10        class TTLC_Settings_Attachments extends TTLC_Settings {
     11           
     12            protected $_suffix = 'attachments';
    1113
    12             public $size;
    13             public $time;
    14             public $autoload;
     14            public $size = 5;
     15            public $time = 30;
     16            public $autoload = false;
    1517           
    1618            public function attributes() {
     
    2628                    array(
    2729                        array('size', 'time'),
    28                         'number'
     30                        'number',
     31                        'natural',
    2932                    ),
    3033                );
    3134            }
    3235           
    33             public function save() {
    34                 $result = true;
    35                 $not_saved = array();
    36                 foreach( $this->attributes() as $attribute => $label ) {
    37                     $update = update_option( 'ttlc_attachments_' . $attribute , $this->$attribute );
    38                     if ( ! $update ) {
    39                         $not_saved[] = $label;
    40                         $result = false;
    41                     }
    42                 }
    43 
    44                 return $result ? true : new WP_Error('ttlc_attachments_settings', sprintf( __('%s: options values have not changed', TTLC_TEXTDOMAIN ), implode( ', ', $not_saved ) ) );
    45             }
    4636        }
    4737   
  • ticketrilla/trunk/includes/class-ticket.php

    r2113511 r2125630  
    8383                    'csirr' => __( '%s has rejected the server information request.', TTLC_TEXTDOMAIN),
    8484                    'csirs' => __( '%s has sent the server information.', TTLC_TEXTDOMAIN),
     85                    'cslr' => __( '%s has requested your server login.', TTLC_TEXTDOMAIN),
     86                    'cslrc' => __( '%s has requested your server login.', TTLC_TEXTDOMAIN),
     87                    'cslrr' => __( '%s has rejected the server login request.', TTLC_TEXTDOMAIN),
     88                    'cslrs' => __( '%s has sent the server login link.', TTLC_TEXTDOMAIN),
     89                    'csle' => __( '%s Client server login link has expired.', TTLC_TEXTDOMAIN),
    8590                );
    8691
  • ticketrilla/trunk/readme.txt

    r2113511 r2125630  
    6060== Changelog ==
    6161
     62= 1.0.4 =
     63* Added new function for registering of temporary user in one click
    6264= 1.0.3 =
    6365* Added new function for sending server information in one click
  • ticketrilla/trunk/templates/settings-attachments-form.php

    r2031126 r2125630  
    99    $attachments = $data['attachments'];
    1010    $labels = $attachments->attributes();
    11     $state = isset( $data['state'] ) && is_array( $data['state'] ) ? $data['state'] : false;
    1211
    1312?>
    1413                            <form id="ttlc-attachment-settings" class="ttlc__settings-inner ttlc-settings">
    15                                 <input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce( 'ttlc_settings_attachments' ); ?>">
    16                                 <input type="hidden" name="action" value="ttlc/settings/attachments">
     14                                <input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce( 'ttlc_settings' ); ?>">
     15                                <input type="hidden" name="action" value="ttlc/settings">
     16                                <input type="hidden" name="section" value="attachments">
    1717                                <div class="ttlc__settings-inner-header">
    1818                                    <h4><?php esc_html_e( 'Attachments', TTLC_TEXTDOMAIN ); ?></h4>
     
    2424                                                <label><?php echo esc_html( $labels['size'] ); ?></label>
    2525                                                <div class="input-group"><span class="input-group-addon"><?php esc_html_e( 'MB', TTLC_TEXTDOMAIN ); ?></span>
    26                                                     <input name="size" id="ttlc__attachment-max-size" type="number" value="<?php echo esc_attr( $attachments->size ); ?>" class="form-control">
     26                                                    <input name="size" id="ttlc__attachment-max-size" type="number" min="1" value="<?php echo esc_attr( $attachments->size ); ?>" class="form-control">
    2727                                                </div><span class="help-block"><?php esc_html_e( 'Maximum attachments size', TTLC_TEXTDOMAIN ); ?></span>
    2828                                            </div>
     
    3131                                            <div class="form-group">
    3232                                                <label><?php echo esc_html( $labels['time'] ); ?></label>
    33                                                 <div class="input-group"><span class="input-group-addon"><?php esc_html_e( 'sec', TTLC_TEXTDOMAIN ); ?></span>
    34                                                     <input name="time" id="ttlc__attachment-max-time" type="number" value="<?php echo esc_attr( $attachments->time ); ?>" class="form-control">
     33                                                <div class="input-group"><span class="input-group-addon"><?php esc_html_e( 'sec.', TTLC_TEXTDOMAIN ); ?></span>
     34                                                    <input name="time" id="ttlc__attachment-max-time" type="number" min="1" value="<?php echo esc_attr( $attachments->time ); ?>" class="form-control">
    3535                                                </div><span class="help-block"><?php esc_html_e( 'Maximum attachments loading time', TTLC_TEXTDOMAIN ); ?></span>
    3636                                            </div>
     
    4646                                    </div>
    4747                                </div>
    48                                 <div class="ttlc__settings-inner-footer">
    49                                 <?php
    50                                     if ($attachments->has_errors() ) {
    51                                         echo '<span class="text-danger state">';
    52                                         foreach( $attachments->get_errors() as $attr_key => $errors ) {
    53                                             foreach ( $errors as $error ) {
    54                                                 echo esc_html( $labels[$attr_key] . ': ' . $error ) . '<br>';
    55                                             }
    56                                         }
    57                                         echo '</span>';
    58                                     } elseif( is_array( $state ) ) {
    59                                         echo '<span class="text-' . esc_attr( $state['status'] ) . ' state">' . esc_html( $state['message'] ) . '</span>';
    60                                     } else {
    61                                         echo '<span class="text-warning state"></span>';
    62                                     }
    63                                 ?>
    64                                     <button type="submit" class="btn btn-dark disabled"><?php esc_html_e( 'Save', TTLC_TEXTDOMAIN ); ?></a>
    65                                 </div>
     48                                <?php $this->render_template( 'settings-section-footer', array('model' => $attachments ) ); ?>
    6649                            </form>
  • ticketrilla/trunk/templates/settings.php

    r2045742 r2125630  
    2020                    <div class="row">
    2121                        <div class="col-md-12">
     22                        <?php
     23                            $attachments = new TTLC_Settings_Attachments;
     24                            $attachments->load();                           
     25                            $this->render_template( 'settings-attachments-form', array('attachments' => $attachments) );
     26                        ?>
     27                        </div>
     28                    </div>
     29                    <div class="row">
     30                        <div class="col-md-12">
    2231                        <?php
    23                             $attachments = new TTLC_Settings_Attachments;
    24                             $attachments->size = get_option('ttlc_attachments_size', 5);
    25                             $attachments->time = get_option('ttlc_attachments_time', 30);
    26                             $attachments->autoload = get_option('ttlc_attachments_autoload', false);
    27                             $this->render_template( 'settings-attachments-form', array('attachments' => $attachments) );
     32                            $autologin = new TTLC_Settings_Autologin;
     33                            $autologin->load();
     34                            $this->render_template( 'settings-autologin-form', array('autologin' => $autologin) );
    2835                        ?>
    2936                        </div>
  • ticketrilla/trunk/templates/ticket.php

    r2113511 r2125630  
    208208                                                } elseif( array_key_exists( $response->type, $responses_statuses ) ) {
    209209                                                    echo sprintf( $responses_statuses[$response->type], esc_html( $response->author ) . $sup );
     210                                                } else {
     211                                                    echo sprintf( __( '%s Unknown response type. Please, try to update the plugin.', TTLC_TEXTDOMAIN ), esc_html( $response->author ) . $sup );
    210212                                                }
    211213                                                echo '</h4></div>';
    212                                                 if( in_array( $response->type, array('csir', 'csirc') ) ) {
    213                                                     $disabled = $response->type === 'csirc' || $ticket_processor->fallback ? ' disabled' : '';
    214                                                     $csi_preview = TTLC()->get_csi();
     214                                                if( in_array( $response->type, array('csir', 'csirc', 'cslr', 'cslrc') ) ) {
     215                                                    $disabled = in_array( $response->type, array('csirc', 'cslrc') ) || $ticket_processor->fallback ? ' disabled' : '';
     216                                                    $csir_data = in_array( $response->type, array('csir', 'cslr') ) ? $response->type : '';
     217                                                    $csirs_data = $csir_data ? ' data-type="' . $csir_data . 's"' : '';
     218                                                    $csirr_data = $csir_data ? ' data-type="' . $csir_data . 'r"' : '';
     219
    215220                                                    echo '<div class="ttlc__tickets-responses-csir">';
    216                                                     echo '<button id="csir-send" class="btn btn-info"' . $disabled . '>' . esc_html__( 'Send', TTLC_TEXTDOMAIN ) . '</button>';
    217                                                     echo ' <button id="csir-reject" class="btn btn-danger"' . $disabled . '>' . esc_html__( 'Reject', TTLC_TEXTDOMAIN ) . '</button>';
    218                                                     echo '<input type="hidden" name="csir-id" id="csir-id-input" value="' . esc_attr( $response->external_id ) . '">';
     221                                                    echo '<button class="csir-send btn btn-info"' . $disabled . $csirs_data . '>' . esc_html__( 'Send', TTLC_TEXTDOMAIN ) . '</button>';
     222                                                    echo ' <button class="csir-reject btn btn-danger"' . $disabled . $csirr_data . '>' . esc_html__( 'Reject', TTLC_TEXTDOMAIN ) . '</button>';
     223                                                    echo '<input type="hidden" name="csir-id" value="' . esc_attr( $response->external_id ) . '">';
    219224                                                    if ( $response->type === 'csir' && ! $ticket_processor->fallback ) {
     225                                                        $csi_preview = TTLC()->get_csi();
    220226                                                        echo '<div class="ttlc__label-info"><i class="fa fa-question-circle-o" aria-hidden="true"></i><div class="ttlc__label-info-hidden"><div class="ttlc__label-info-csi-preview">' . apply_filters( 'the_content', $csi_preview ) . '</div></div></div>';
    221227                                                    }
  • ticketrilla/trunk/ticketrilla-client.php

    r2113511 r2125630  
    66Author: Daniil Babkin
    77Author URI: https://ticketrilla.com
    8 Version: 1.0.3
     8Version: 1.0.4
    99Description: Client's plugin for support of WP products
    1010License: GPLv2 or later
Note: See TracChangeset for help on using the changeset viewer.