values_flat('id', 'name') as $s) { list ($id, $name) = $s; $statuses[$id] = $name; } // Build array of Agents $staff[0] = $__('ONLY Send as Ticket\'s Assigned Agent'); foreach (Staff::objects() as $s) { $staff[$s->getId()] = $s->getName(); } $global_settings = [ 'global' => new SectionBreakField( [ 'label' => $__('Global Config') ]), 'frequency' => new ChoiceField( [ 'label' => $__('Check Frequency'), 'choices' => [ '0' => $__('Every Cron'), '1' => $__('Every Hour'), '2' => $__('Every 2 Hours'), '6' => $__('Every 6 Hours'), '12' => $__('Every 12 Hours'), '24' => $__('Every 1 Day'), '36' => $__('Every 36 Hours'), '48' => $__('Every 2 Days'), '72' => $__('Every 72 Hours'), '168' => $__('Every Week'), '730' => $__('Every Month'), '8760' => $__('Every Year') ], 'default' => '2', 'hint' => $__("How often should we run?") ]), 'use_autocron' => new BooleanField( [ 'label' => $__('Use Autocron'), 'default' => 0, 'hint' => $__('If you only have auto-cron, you will want this on.') ]), 'purge-num' => new TextboxField( [ 'label' => $__('Tickets to process per run per group'), 'hint' => $__( "How many tickets should we change each time for each group? (small for auto-cron)"), 'default' => 20 ]), ]; // Configure groups to associate a status change with a canned response notification: // Get all the canned responses to use as selections: $responses = Canned::getCannedResponses(); $responses['0'] = $__('Send no Reply'); // Build an array of group configurations: $config_groups = []; foreach (range(1, self::NUMBER_OF_SETTINGS) as $i) { $gn = $this->get('group-name-' . $i); $gn = $gn ? ': ' . $gn : ''; $config_groups[] = [ 'group' . $i => new SectionBreakField( [ 'label' => $__('Group ' . $i . $gn) ]), 'group-enabled-' . $i => new BooleanField( [ 'label' => __('Enable Group'), 'hint' => __('Groups can be configured without being enabled. '), 'default' => ($i == 1) ? TRUE : FALSE // Enable first group by default. ]), 'group-name-' . $i => new TextboxField( [ 'label' => 'Groupname', 'hint' => $__('Name this group') ]), 'purge-age-' . $i => new TextboxField( [ 'default' => '999', 'label' => $__('Max Ticket age in days'), 'hint' => $__( 'Tickets with no updates in this many days will match and have their status changed.'), 'size' => 5, 'length' => 4 ]), 'close-only-answered-' . $i => new BooleanField( [ 'default' => TRUE, 'label' => $__('Only change tickets with an Agent Response'), 'hint' => '' ]), 'close-only-overdue-' . $i => new BooleanField( [ 'default' => FALSE, 'label' => $__('Only change tickets past expiry date'), 'hint' => $__('Default ignores expiry') ]), 'from-status-' . $i => new ChoiceField( [ 'label' => $__('From Status'), 'choices' => $statuses, 'default' => 1, 'hint' => $__( 'When we change the ticket, what are we changing the status from? Default is "Open"') ]), 'to-status-' . $i => new ChoiceField( [ 'label' => $__('To Status'), 'choices' => $statuses, 'default' => 3, // 3 == Open on mine. 'hint' => $__( 'When we change the ticket, what are we changing the status to? Default is "Closed"') ]), 'admin-note-' . $i => new TextareaField( [ 'label' => $__('Auto-Note'), 'hint' => $__('Create\'s an admin note just before closing.'), 'default' => 'Auto-closed for being open too long with no updates.', 'configuration' => [ 'html' => FALSE, 'size' => 40, 'length' => 256 ] ]), 'robot-account-' . $i => new ChoiceField( [ 'label' => $__('Robot Account'), 'choices' => $staff, 'default' => 0, 'hint' => $__( 'Select account for sending replies, account can be locked, still works.') ]), 'admin-reply-' . $i => new ChoiceField( [ 'label' => $__('Auto-Reply Canned Response'), 'hint' => $__( 'Select a canned response to use as a reply just before closing (can use Variables), configure in /scp/canned.php'), 'choices' => $responses ]) ]; } if (version_compare(PHP_VERSION, '5.6.0') >= 0) { // Merge all the group configurations into the global settings array and return as the config return array_merge($global_settings, ...$config_groups); } // Support pre 5.6... oi vey $settings = $global_settings; foreach ($config_groups as $group) { foreach ($group as $setting) { $settings[] = $setting; } } return $settings; } }