Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CDN Features for files uploaded to system #123

Open
wants to merge 226 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
226 commits
Select commit Hold shift + click to select a range
accdb5e
Implement LDAP directory searching
Dec 13, 2013
1aaa2e3
Implement user lookup on authenticate
Dec 13, 2013
ac40364
auth-passthru: Fix Active Directory username match
Dec 18, 2013
691be0d
Add telephoneNumber lookup for Active Directory
Dec 23, 2013
5dd3134
auth-ldap: Fix incorrect usage of unconfigured dns
Jan 1, 2014
ff82153
Limit HttpAuthentication to staff's backend
protich Jan 17, 2014
bcf5839
Add plugin builder script to create PHAR files
Jan 17, 2014
e5fdaa4
Make LDAPAuthentication abtract
protich Jan 17, 2014
ee8fdf0
Allow LDAP auth to be used for clients too
Jan 17, 2014
113915c
Fixup user searches for LDAP
Jan 17, 2014
aefc10f
Merge pull request #4 from protich/feature/authentication-backends
greezybacon Jan 20, 2014
51de154
Merge pull request #5 from greezybacon/feature/plugin-builder
greezybacon Jan 21, 2014
e1f7f05
ldap: Allow specification of extremely long DNs
Jan 31, 2014
60863d7
Merge pull request #10 from greezybacon/issue/long-dns
greezybacon Jan 31, 2014
12c495a
Bump auth-ldap version
Jan 31, 2014
b155770
ldap: Ensure domain name is a FQDN
Feb 3, 2014
3700f0e
ldap: Ensure DNS is a comma-separated IP list
Feb 3, 2014
e52422f
Merge pull request #12 from greezybacon/issue/3
greezybacon Feb 19, 2014
be2000f
Bump LDAP version
Feb 19, 2014
cdf242f
ldap: Increase default domain length
Mar 3, 2014
8c4d060
storage-fs: Support reading by block size
Mar 3, 2014
a29a210
file system config page update
ntozier Feb 23, 2014
6d9ea4f
storage-fs: Bump version number
Mar 3, 2014
ccdb113
Add S3 plugin and dependencies
Jan 24, 2014
0325190
Implement blocksize for S3
Feb 3, 2014
e5afeb6
s3: Copy password on save (if not set)
Feb 4, 2014
3f6c723
ldap: Fixup path for PEAR includes
Feb 21, 2014
57b3edd
Add `hydrate` command for non-phar users
Mar 18, 2014
0af6193
No implied update of dependencies when building
Mar 20, 2014
ad344ae
Merge pull request #11 from greezybacon/feature/s3
protich Mar 21, 2014
dc4a1b0
Implement client authentication via LDAP
Mar 25, 2014
d8c507a
Implement CreateClientRequest cooperation
Mar 26, 2014
20fea98
Fixup ClientCreateRequest after searching for user
Apr 7, 2014
8ad6350
Fixup include_path setup on plugin load
Apr 7, 2014
0f48180
Add missing ldap extension to a red banner
Apr 7, 2014
1e2596b
s3: Use Content-MD5 header instead of download
Apr 7, 2014
de95ad3
Merge pull request #20 from greezybacon/feature/s3-hash-use-etag
protich Apr 14, 2014
a7e3a08
Bump version code for AWS S3 storage
Apr 18, 2014
e17c89f
oauth: Introduce external authentication with Google+
Apr 29, 2014
f60642b
ldap: Fix user name info lookup
May 4, 2014
7dc26a0
ldap: Fix auto detection of Active Directory
May 4, 2014
aa246e6
ldap: Fix user information lookup for Active Directory
May 4, 2014
63124e4
make: Don't attempt to add directories to PHARs
May 4, 2014
775528a
ldap: Allow lookup and registration to coexist
May 5, 2014
805ac21
ldap: Auto add Active Directory domain to search user
May 5, 2014
6b55697
ldap: Permit authentication by email and password
May 5, 2014
427527d
Merge pull request #26 from greezybacon/issue/25
protich May 19, 2014
3fda13b
Merge pull request #18 from greezybacon/feature/client-ldap-auth
protich May 19, 2014
1d08935
Merge pull request #24 from greezybacon/feature/google-auth
protich May 19, 2014
dcdcddf
http: Implement pass-through auth for clients
May 19, 2014
2d29f33
Merge pull request #28 from greezybacon/feature/http-client-sso
protich May 30, 2014
1ed33fa
Try anonymous bind
Chefkeks Sep 17, 2014
66f7e42
make: Add PHP compression support
Dec 31, 2014
a829df6
ldap: Fix client login under some circumstances
Mar 26, 2015
62fabc1
Allow for longer folder names in the storage-fs plugin
Mar 26, 2015
01d88cb
Add support for CAS authentication
kevinoconnor7 May 28, 2014
23cbd79
Improve include location
kevinoconnor7 May 28, 2014
75743dc
Add support for customizable CA files
kevinoconnor7 May 30, 2014
1817465
Fix small redirect bug
kevinoconnor7 Mar 29, 2015
21d5852
Merge pull request #62 from greezybacon/issue/client-auth-fails
greezybacon Apr 2, 2015
b8183c8
Merge pull request #63 from greezybacon/issue/34
greezybacon Apr 2, 2015
cca45b4
Merge pull request #49 from Chefkeks/patch-1
greezybacon Apr 2, 2015
7053e59
make: Add PHAR list support
Apr 2, 2015
f581f5f
make: Don't package test files
Apr 2, 2015
47ae22e
i18n: Translate core plugins!
Jul 30, 2014
945c886
i18n: Add translations to PHAR files
Jul 31, 2014
56d5106
i18n: Translate the other plugins
Jul 31, 2014
e6c495c
Add some initial docs concerning translations
Aug 1, 2014
58f6ac2
i18n: Fix typo in ldap configuration
Aug 11, 2014
27fdbf9
Merge pull request #44 from greezybacon/feature/translations
greezybacon Apr 2, 2015
4f7f37e
Bump version numbers
Apr 2, 2015
120be51
ldap: oops: Fix bad translation function usage
Apr 9, 2015
30a52dd
ldap, passthru: Fix login with osTicket v1.9-next (post v1.9.7)
Apr 10, 2015
9e7734f
Merge pull request #66 from greezybacon/issue/login-198
protich Apr 10, 2015
7de73af
oauth: Fix crash authenticating with `develop-next`
Apr 30, 2015
f70b28f
Add i18n support
kevinoconnor7 Jun 4, 2015
ee4377b
Merge pull request #31 from kevinoconnor7/add-auth-cas
greezybacon Jul 30, 2015
138882c
needed to download Net_LDAP2 properly - as in #38
jakkul Aug 31, 2015
59bb611
Merge pull request #80 from jakkul/patch-1
greezybacon Dec 28, 2015
bfeee61
s3: Fix upstream change to Symfony framework
Dec 28, 2015
81fb472
doc: Add blurb on building plugins
Dec 28, 2015
7c54aa9
Update make.php
Shadow00Caster Jun 21, 2016
17eed1d
Update README.md
ntozier Sep 21, 2016
e363360
modified pear.php.net to https in composer setup
tkteun Sep 22, 2016
80f96d5
Merge pull request #112 from tkteun/patch-1
protich Nov 2, 2016
04fbd9a
Merge pull request #111 from ntozier/patch-2
protich Nov 2, 2016
901520f
Audit Plugin
aydreeihn Jul 11, 2019
5328f78
Ticket Audit Pagination
aydreeihn Jul 15, 2019
3aee40d
Final Touches
aydreeihn Jul 15, 2019
9b73d86
Audit Email Export
aydreeihn Aug 13, 2019
2190191
Update Audit Exports
aydreeihn Sep 3, 2019
be0b151
ldap: PHP 7.2+ Host:Port Conflict
JediKev Sep 17, 2019
d98e5f7
Final Fixes:
aydreeihn Sep 19, 2019
0c8a6cf
issue: Password Validation
JediKev Mar 6, 2020
3d1990b
audit: Use X-Forwarded-For Address
JediKev Mar 10, 2020
0ee0c24
Merge pull request #162 from JediKev/ldap/php7.2-host-port-conflict
protich Mar 10, 2020
9a7d059
Merge pull request #168 from JediKev/issue/password-validation
protich Mar 10, 2020
78927ba
audit: New Agent DB Error
JediKev Mar 10, 2020
5c3dd17
Merge pull request #161 from aydreeihn/feature/audit-plugin
protich Mar 10, 2020
03f4c45
Issue: Include Templates
aydreeihn Mar 24, 2020
eacc457
Audit Log Fixes
aydreeihn Mar 25, 2020
1da8af7
Switching composer to stable version
yalh76 Apr 15, 2020
15f30eb
Issue: Class AuditEntry Not Found
aydreeihn Apr 23, 2020
8791d49
Merge pull request #170 from JediKev/audit/new-agent-db-error
protich Apr 27, 2020
311cf3e
Merge pull request #171 from aydreeihn/feature/audit-plugin
protich Apr 27, 2020
355648c
Merge pull request #179 from aydreeihn/issue/audit-delete
protich Apr 27, 2020
0ed99f6
Merge pull request #174 from yalh76/patch-1
protich Apr 27, 2020
8eafd08
Issue: Extra String in Link
aydreeihn Apr 30, 2020
4e33211
Merge pull request #180 from aydreeihn/feature/audit-plugin
aydreeihn Apr 30, 2020
61a32ba
Audit Issue
aydreeihn May 1, 2020
105d789
Merge pull request #181 from aydreeihn/feature/audit-plugin
aydreeihn May 6, 2020
14f4778
Merge pull request #169 from JediKev/audit/use-x-forwarded-for-address
JediKev May 6, 2020
7f5658a
auth: Add concept of a password complexity plugin
Mar 18, 2015
78ae84d
Password Policy Plugin
protich Jun 10, 2020
52f7bae
Merge pull request #183 from protich/feature/passwd-policy
protich Oct 14, 2020
7decf6b
Issue: Audit Events
aydreeihn Nov 30, 2020
d42ac0e
Merge pull request #191 from aydreeihn/issue/audit-events
aydreeihn Nov 30, 2020
fd9b326
Use Composer 1
rynomster Jan 15, 2021
e16b803
Attachments in Amazon S3: Folders
aydreeihn Feb 2, 2021
aea3128
Fix "name : Does not match the regex pattern"
mehov Feb 12, 2021
f288e45
Fix "pear-pear.php.net/Net_LDAP2 is invalid"
mehov Feb 12, 2021
2e0ae7f
issue: Host/Port Int Vals
JediKev Apr 12, 2021
af4d27e
Merge pull request #196 from mehov/patch-1
protich Apr 13, 2021
a3253cd
Merge pull request #197 from mehov/patch-2
protich Apr 13, 2021
b09a00f
Merge pull request #202 from JediKev/issue/host-port-int-vals
protich Apr 13, 2021
d7e491c
Additional S3 Folder Functionality
aydreeihn May 3, 2021
3b26e97
Authenticator Plugin
aydreeihn May 3, 2021
38a520c
Merge pull request #204 from aydreeihn/feature/auth-plugin
protich May 5, 2021
52664e2
Issue: Use Static Id
aydreeihn May 5, 2021
2452d95
Merge pull request #205 from aydreeihn/feature/auth-plugin
protich May 13, 2021
9609519
Merge pull request #195 from aydreeihn/feature/s3-folder
protich Jul 28, 2021
cea7826
Merge pull request #104 from Shadow00Caster/patch-1
protich Jul 28, 2021
f00b381
Merge pull request #193 from rynomster/patch-1
protich Jul 28, 2021
e9ba990
Issue: Undefined Method getUserId
aydreeihn Oct 29, 2021
6d55c8a
Issue: Audit Plugin Config Table Updates
aydreeihn Oct 29, 2021
8c5357a
Issue: 2FA URL Spaces
aydreeihn Oct 26, 2021
1559d11
storage-fs: mkdir Octal Numbers
JediKev Nov 2, 2021
1b0cc55
Merge pull request #216 from aydreeihn/issue/2fa-spaces
JediKev Feb 1, 2022
b2d668e
Merge pull request #217 from aydreeihn/issue/audit-getUserId
JediKev Feb 1, 2022
e5ed68a
Merge pull request #218 from JediKev/storage-fs/mkdir-octal-numbers
JediKev Feb 1, 2022
003f25e
issue: Calling Non-Static Statically
JediKev Jan 21, 2022
7a61fd1
issue: Static to Non-Static
JediKev Jan 21, 2022
f3038d9
issue: Compatible Errors
JediKev Jan 25, 2022
3eed93e
issue: Remove Pear Dependency
JediKev Jan 25, 2022
5a193fd
issue: Map Custom Dependencies
JediKev Jan 25, 2022
17fb510
issue: Composer 2
JediKev Jan 25, 2022
78bd732
issue: Latest aws-sdk-php
JediKev Jan 25, 2022
7f7d862
issue: PHP8 Hydrate
aydreeihn Jan 31, 2022
cd2d38e
issue: mapDependencies() Missing Argument
JediKev Jan 31, 2022
845bc9e
issue: auth-ldap Errors
JediKev Feb 2, 2022
fc089b9
Merge pull request #223 from JediKev/issue/php8-support
JediKev Feb 8, 2022
2e0f3d6
issue: autodiscover Static
JediKev Feb 15, 2022
8b33116
Merge pull request #224 from JediKev/issue/autodiscover-static
JediKev Feb 15, 2022
0b59afb
security: Audit Log Injection
JediKev Apr 21, 2022
047a1c3
xss: Audit Log
JediKev Apr 21, 2022
3e8a302
security: Filesystem Listing
JediKev Apr 21, 2022
a7842d4
Merge pull request #229 from JediKev/security/latest-security-patches…
JediKev May 19, 2022
faf7131
oauth2: Add OAuth2 Plugin
protich Jul 2, 2022
f5f722b
oauth: Retire the OLD OAuth Plugin
protich Jul 2, 2022
2ca1492
oauth2: Require osTicket v1.17
protich Jul 2, 2022
b6cecc1
gitignore: Ignore lib and include directories
protich Jul 2, 2022
0b507df
oauth2: Email Authorization Backend
protich Jul 6, 2022
64a7592
oauth2: Hydrate the correct libs src.
protich Jul 6, 2022
df8d4d6
auth-oauth2: Match osTicket changes for Plugin Config init.
protich Jul 12, 2022
c91489f
auth-oauth2: Add GuzzleHttp/{Psr7,Promise}
protich Jul 13, 2022
cb9dcfe
auth-oauth2: Use PasswordField for ClientSecret
protich Jul 19, 2022
c267ebc
auth-oauth2: Force Email Match
protich Jul 19, 2022
19875a2
auth-oauth2: Fix Scopes
protich Jul 22, 2022
f5e1f54
auth-oauth2: Outlook Office Scopes
protich Aug 1, 2022
7ebe42f
auth-oauth2: Change version to 0.2
protich Aug 1, 2022
276b91a
auth-oauth2: Email Address Attribute
protich Aug 4, 2022
2145f55
auth-oauth2: Email Attribute Error
protich Aug 4, 2022
a24afc5
auth-oauth2: Move Scopes Up
protich Aug 5, 2022
9346b14
auth-oauth2: Change version to 0.3
protich Aug 5, 2022
faaea9d
auth-oauth2: Remove maxlength restriction on Config fields
protich Aug 22, 2022
e5070cf
auth-oauth2: Change M$ default scope and email attr.
protich Aug 25, 2022
5f72727
auth-oauth2: Force prompt even on reauthorization.
protich Aug 25, 2022
6f17fbc
auth-oauth2: Stash Authorization Result
protich Aug 29, 2022
b3729db
auth-oauth2: Add GenericEmailOauth2Provider
protich Sep 2, 2022
06a31e0
auth-oauth2: OAuth2 Config Improvements
protich Sep 2, 2022
c8cfcf0
auth-oauth2: Change Version to 0.5
protich Sep 3, 2022
593607f
auth-oauth2: Add Default Microsoft Endpoints
protich Sep 19, 2022
cf6e72d
auth-oauth2: Change Version to 0.6
protich Sep 19, 2022
2c0fdf7
hydrate: Expanded matching for files/directories
protich Sep 27, 2022
e3195e9
Merge pull request #231 from protich/plugins/auth-oauth2
JediKev Sep 27, 2022
68b8eca
Merge pull request #237 from protich/feature/smart-hydrate
JediKev Sep 27, 2022
3fd8112
storage-s3: v1.17 Compatibility Fixes
protich Sep 30, 2022
38ed198
Merge pull request #238 from protich/aydreeihn-issue/s3-multi-inst
JediKev Sep 30, 2022
f52ce37
MS OAuth2: Don't force consent prompt
teward Oct 13, 2022
631e833
auth-oauth2: Disable Strict Email Matching on Authorization
protich Nov 2, 2022
baa0a63
Issue: Decrease S3 Plugin Size
aydreeihn Nov 3, 2022
52950db
Merge pull request #241 from teward/develop
JediKev Nov 3, 2022
adfef05
Merge pull request #250 from protich/plugins/auth-oauth2_strict-mode
JediKev Nov 3, 2022
ac2576a
Merge pull request #251 from aydreeihn/issue/aws-sdk-size-117
protich Nov 9, 2022
2271e01
Merge branch 'develop' into 1.17.x
JediKev Nov 9, 2022
1bc8cef
auth-oauth2: Resource Owner Email Mismatch
protich Nov 30, 2022
af8b399
ldap: Staff Authentication Backend ID
JediKev Dec 5, 2022
0ff1fcd
oauth2: User/Agent Destination Url
JediKev Feb 2, 2023
4cdfa35
ldap: No current() Fatal Error
JediKev Feb 2, 2023
2387c5e
Merge branch 'plugins/auth-oauth2_strict-mode' of https://github.com/…
MarcBanyard Feb 6, 2023
d467c55
auth-oauth2: Update Refresh Token
protich Feb 9, 2023
231acdd
Fixed issue for Microsoft 365 Shared Mailboxes.
MarcBanyard Feb 6, 2023
512d93d
auth-oauth2: Office 365 SMTP Resource Owner
protich Feb 13, 2023
eaaf37d
auth-oauth2: Strict Match Mode
protich Feb 13, 2023
029c4c9
auth-oauth2: Leave Resource Owner Alone!
protich Feb 15, 2023
bc61616
Merge pull request #255 from JediKev/ldap/staff-auth-bk-id
JediKev Mar 7, 2023
d5bb9a1
Merge pull request #259 from JediKev/oauth2/user-agent-dest-url
JediKev Mar 7, 2023
5b9997d
Merge pull request #260 from JediKev/ldap/no-current-fatal-error
JediKev Mar 7, 2023
d866053
Merge pull request #264 from protich/auth-oauth2/refresh_token
JediKev Mar 7, 2023
4d95ec8
Merge pull request #265 from protich/auth-oauth/resource_owner
JediKev Mar 7, 2023
033767b
issue: resolveDependencies Scripts and Extra
JediKev Mar 10, 2023
685d03a
Merge pull request #267 from JediKev/issue/resolveDependencies-script…
protich Mar 17, 2023
b120edc
oauth2: Okta Defaults
JediKev Mar 21, 2023
9b2f8b6
audit: i18n Export Issues
JediKev Mar 24, 2023
094219d
ldap: PHP 8.1 Support
JediKev Apr 12, 2023
ff814b5
ldap: No current() Fatal Error 2
JediKev Apr 12, 2023
972559f
Merge pull request #268 from JediKev/oauth2/okta-defaults
JediKev Jun 12, 2023
58aef96
Merge pull request #269 from JediKev/audit/i18n-export-issues
JediKev Jun 12, 2023
215dced
Merge pull request #271 from JediKev/ldap/php8.1-support
JediKev Jun 12, 2023
508b15e
Merge pull request #272 from JediKev/issue/ldap-bool-error
JediKev Jun 12, 2023
1f17a11
issue: Password Length
JediKev Jun 12, 2023
4b54531
Merge pull request #274 from JediKev/issue/password-length
JediKev Jun 12, 2023
d17c58a
Display account selection prompt for MS365 e-mail auth
GabrielMajeri Jul 28, 2023
50ad145
ldap: Hostname REGEX
JediKev Sep 18, 2023
8dc604f
Merge pull request #279 from JediKev/ldap/hostname-regex
protich Oct 25, 2023
2bb7717
Merge pull request #275 from GabrielMajeri/microsoft-email-auth-accou…
protich Oct 25, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,17 @@ Vagrantfile

# Staging directory used for packaging script
stage

# Ignore compiled phar files
*.phar

# Ignore hydrated libs & include dir
**/lib
**/include

# Ignore installed dependencies and composer if placed here
lib/*
!/lib/pear-pear.php.net/
composer.phar
composer.lock
composer.json
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,29 @@ Installing

Clone this repo or download the zip file and place the contents into your
`include/plugins` folder

After cloning, `hydrate` the repo by downloading the third-party library
dependencies.

php make.php hydrate

Building Plugins
================
Make any necessary additions or edits to plugins and build PHAR files with
the `make.php` command

php -dphar.readonly=0 make.php build <plugin-folder>

This will compile a PHAR file for the plugin directory. The PHAR will be
named `plugin.phar` and can be dropped into the osTicket `plugins/` folder
directly.

Translating
===========

[![Crowdin](https://d322cqt584bo4o.cloudfront.net/osticket-plugins/localized.png)](http://i18n.osticket.com/project/osticket-plugins)

Translation service is being performed via the Crowdin translation
management software. The project page for the plugins is located at

https://crowdin.com/project/osticket-plugins
165 changes: 165 additions & 0 deletions audit/audit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
<?php
require_once 'class.audit.php';
require_once(INCLUDE_DIR.'class.plugin.php');
require_once('config.php');

class AuditPlugin extends Plugin {
var $config_class = 'AuditConfig';
function bootstrap() {
AuditEntry::bootstrap();
$config = $this->getConfig();
if ($config->get('show_view_audits'))
AuditEntry::$show_view_audits = $config->get('show_view_audits');

// Ticket audit
Signal::connect('ticket.view.more', function($ticket, &$extras) {
global $thisstaff;
if (!$thisstaff || !$thisstaff->isAdmin())
return;

echo sprintf('<li><a href="#%s"', 'ajax.php/audit/ticket/' . $ticket->getId() . '/view');
echo 'onclick="javascript: $.dialog($(this).attr(\'href\').substr(1), 201); return false;"';
echo sprintf('><i class="%s"></i>', 'icon-book' ?: 'icon-cogs');
echo __('View Audit Log');
echo '</a></li>';
});

// User audit tab
Signal::connect('usertab.audit', function($user, &$extras) {
global $thisstaff;
if (!$thisstaff || !$thisstaff->isAdmin())
return;

$tabTitle = str_replace('-', ' ', __('audits'));
echo sprintf('<li> <a href="#%s">%s</a></li>', __('audits'), __(ucwords($tabTitle)));
});

// User audit body
Signal::connect('user.audit', function($user, &$extras) {
global $thisstaff;
if (!$thisstaff || !$thisstaff->isAdmin())
return;

echo '<div class="hidden tab_content" id="audits">';
include 'templates/user-audit.tmpl.php';
echo '</div>';
});

// Agent audit tab
Signal::connect('agenttab.audit', function($staff, &$extras) {
global $thisstaff;
if (!$thisstaff || !$thisstaff->isAdmin())
return;

echo '<li> <a href="#audits">Audits</a></li>';
});

// Agent audit tab body
Signal::connect('agent.audit', function($staff, &$extras) {
global $thisstaff;
if (!$thisstaff || !$thisstaff->isAdmin())
return;

echo '<div class="hidden tab_content" id="audits">';
include 'templates/agent-audit.tmpl.php';
echo '</div>';
});

// Ajax View Ticket Audit
Signal::connect('ajax.scp', function($dispatcher) {
$dispatcher->append(
url_get('^/audit/ticket/(?P<id>\d+)/view$', function($ticketId) {
global $thisstaff;

$row = Ticket::objects()->filter(array('ticket_id'=>$ticketId))->values_flat('number')->first();
if (!$row)
Http::response(404, 'No such ticket');
if (!$thisstaff || !$thisstaff->isAdmin())
Http::response(403, 'Contact your administrator');

include 'templates/ticket-audit.tmpl.php';
})
);
});

// Ajax Audit Export
Signal::connect('ajax.scp', function($dispatcher) {
$dispatcher->append(
url('^/audit/export/(?P<type>\w+)/(?P<state>\w+)|uid,(?P<uid>\d+)|sid,(?P<sid>\d+)|tid,(?P<tid>\d+)$',
function($type=NULL, $state=NULL, $uid=NULL, $sid=NULL, $tid=NULL) {
global $thisstaff;

if (!$thisstaff)
Http::response(403, 'Agent login is required');

$show = AuditEntry::$show_view_audits;
$data = array();
if ($type) {
$url = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_QUERY);
$qarray = explode('&', $url);

foreach ($qarray as $key => $value) {
list($k, $v) = explode('=', $value);
$data[$k] = $v;
}
foreach (AuditEntry::getTypes() as $abbrev => $info) {
if ($type == $abbrev)
$name = AuditEntry::getObjectName($info[0]);
}
$filename = sprintf('%s-audits-%s.csv', $name, strftime('%Y%m%d'));
$export = array('audit', $filename, '', '', 'csv', $show, $data);
} elseif ($uid) {
$userName = User::getNameById($uid);
$filename = sprintf('%s-audits-%s.csv', $userName->name, strftime('%Y%m%d'));
$export = array('user', $filename, $tableInfo, $uid, 'csv', $show, $data);
} elseif ($sid) {
$staff = Staff::lookup($sid);
$filename = sprintf('%s-audits-%s.csv', $staff->getName(), strftime('%Y%m%d'));
$export = array('staff', $filename, $tableInfo, $sid, 'csv', $show, $data);
} elseif ($tid) {
$ticket = Ticket::lookup($tid);
$filename = sprintf('%s-audits-%s.csv', $ticket->getNumber(), strftime('%Y%m%d'));
$export = array('ticket', $filename, $tableInfo, $tid, 'csv', $show, $data);
}

try {
$interval = 5;
// Create desired exporter
$exporter = new CsvExporter();
$extra = array('filename' => $filename,
'interval' => $interval);
// Register the export in the session
Exporter::register($exporter, $extra);
// Flush response / return export id and check interval
Http::flush(201, json_encode(['eid' =>
$exporter->getId(), 'interval' => $interval]));
// Phew... now we're free to do the export
session_write_close(); // Release session for other requests
ignore_user_abort(1); // Leave us alone bro!
@set_time_limit(0); // Useless when safe_mode is on
// Export to the exporter
$export[] = $exporter;
call_user_func_array(array('Export', 'audits'), $export);
$exporter->close();
// Sleep 3 times the interval to allow time for file download
sleep($interval*3);
// Email the export if it exists
$exporter->email($thisstaff);
// Delete the file.
@$exporter->delete();
exit;
} catch (Exception $ex) {
$errors['err'] = __('Unable to prepare the export');
}

include 'templates/export.tmpl.php';
})
);
});
}

function enable() {
AuditEntry::autoCreateTable();
return parent::enable();
}
}
Loading