PATH:
home
/
centosnipponia
/
public_html
/
ticketing.nipponia.com
/
include
<?php /********************************************************************* class.lock.php Ticket lock handle. Peter Rotich <peter@osticket.com> Copyright (c) 2006-2013 osTicket http://www.osticket.com Released under the GNU General Public License WITHOUT ANY WARRANTY. See LICENSE.TXT for details. vim: expandtab sw=4 ts=4 sts=4: **********************************************************************/ /* * Mainly used as a helper... */ class Lock extends VerySimpleModel { static $meta = array( 'table' => LOCK_TABLE, 'pk' => array('lock_id'), 'joins' => array( 'ticket' => array( 'reverse' => 'Ticket.lock', 'list' => false, ), 'task' => array( 'reverse' => 'Task.lock', 'list' => false, ), 'staff' => array( 'constraint' => array('staff_id' => 'Staff.staff_id'), ), ), ); const MODE_DISABLED = 0; const MODE_ON_VIEW = 1; const MODE_ON_ACTIVITY = 2; function getId() { return $this->lock_id; } function getStaffId() { return $this->staff_id; } function getStaffName() { return $this->staff->getName(); } function getStaff() { return $this->staff; } function getCreateTime() { return $this->created; } function getExpireTime() { return strtotime($this->expire); } //Get remaiming time before the lock expires function getTime() { return max(0, $this->getExpireTime() - Misc::dbtime()); } //Should we be doing realtime check here? (Ans: not really....expiretime is local & based on loadtime) function isExpired() { return (Misc::dbtime() > $this->getExpireTime()); } function getCode() { return $this->code; } //Renew existing lock. function renew($lockTime=0) { global $cfg; if(!$lockTime || !is_numeric($lockTime)) //XXX: test to make it works. $lockTime = $cfg->getLockTime(); $this->expire = SqlExpression::plus( SqlFunction::NOW(), SqlInterval::MINUTE($lockTime) ); return $this->save(true); } //release aka delete a lock. function release() { return $this->delete(); } /* ----------------------- Static functions ---------------------------*/ static function lookup($id, $object=false) { if ($object instanceof Ticket) return parent::lookup(array('lock_id' => $id, 'ticket__ticket_id' => $object->getId())); elseif ($object instanceof Task) return parent::lookup(array('lock_id' => $id, 'task__id' => $object->getId())); else return parent::lookup($id); } //Create a ticket lock...this function assumes the caller checked for access & validity of ticket & staff x-ship. static function acquire($staffId, $lockTime) { if (!$staffId or !$lockTime) return null; // Create the new lock. $lock = new static(array( 'created' => SqlFunction::NOW(), 'staff_id' => $staffId, 'expire' => SqlExpression::plus( SqlFunction::NOW(), SqlInterval::MINUTE($lockTime) ), 'code' => Misc::randCode(10) )); if ($lock->save(true)) return $lock; } // Simply remove ALL locks a user (staff) holds on a ticket(s). static function removeStaffLocks($staffId, $object=false) { $locks = static::objects()->filter(array( 'staff_id' => $staffId, )); if ($object instanceof Ticket) $locks->filter(array('ticket__ticket_id' => $object->getId())); elseif ($object instanceof Task) $locks->filter(array('task__id' => $object->getId())); return $locks->delete(); } static function cleanup() { return static::objects()->filter(array( 'expire__lt' => SqlFunction::NOW() ))->delete(); } } ?>
[+]
..
[-] class.model.php
[edit]
[-] ajax.i18n.php
[edit]
[-] class.json.php
[edit]
[-] class.mime.php
[edit]
[-] class.orm.php
[edit]
[-] class.dept.php
[edit]
[-] ajax.filter.php
[edit]
[-] api.tickets.php
[edit]
[-] ajax.note.php
[edit]
[-] class.2fa.php
[edit]
[-] class.setup.php
[edit]
[-] ajax.orgs.php
[edit]
[-] class.format.php
[edit]
[-] class.message.php
[edit]
[-] class.xml.php
[edit]
[-] class.priority.php
[edit]
[-] class.app.php
[edit]
[-] index.php
[edit]
[-] ajax.forms.php
[edit]
[-] ajax.config.php
[edit]
[-] ajax.tickets.php
[edit]
[-] ajax.content.php
[edit]
[-] class.file.php
[edit]
[-] ajax.email.php
[edit]
[-] class.cli.php
[edit]
[-] class.company.php
[edit]
[-] class.mailer.php
[edit]
[-] class.list.php
[edit]
[-] class.canned.php
[edit]
[-] class.client.php
[edit]
[+]
upgrader
[-] class.csrf.php
[edit]
[-] ost-sampleconfig.php
[edit]
[-] class.http.php
[edit]
[-] ajax.staff.php
[edit]
[-] class.search.php
[edit]
[-] JSON.php
[edit]
[-] class.avatar.php.bak
[edit]
[-] class.error.php
[edit]
[-] class.mail.php
[edit]
[-] class.sla.php
[edit]
[-] class.draft.php
[edit]
[-] class.dispatcher.php
[edit]
[-] class.note.php
[edit]
[-] class.mailparse.php
[edit]
[-] class.filter_action.php
[edit]
[-] class.queue.php
[edit]
[-] class.i18n.php
[edit]
[-] class.osticket.php
[edit]
[-] ajax.users.php
[edit]
[-] class.staff.php
[edit]
[+]
fpdf
[-] class.crypto.php
[edit]
[+]
laminas-mail
[-] class.misc.php
[edit]
[-] class.auth.php
[edit]
[-] html2text.php
[edit]
[-] class.translation.php
[edit]
[-] class.util.php
[edit]
[-] class.schedule.php
[edit]
[-] class.banlist.php
[edit]
[-] class.config.php
[edit]
[-] ajax.upgrader.php
[edit]
[+]
mpdf
[-] class.email.php
[edit]
[-] ajax.admin.php
[edit]
[+]
config
[-] ajax.thread.php
[edit]
[-] class.user.php
[edit]
[-] class.passwd.php
[edit]
[-] class.import.php
[edit]
[+]
client
[-] ajax.tips.php
[edit]
[-] tnef_decoder.php
[edit]
[-] class.oauth2.php
[edit]
[-] class.plugin.php
[edit]
[-] class.timezone.php
[edit]
[-] class.ticket.php
[edit]
[-] class.nav.php
[edit]
[-] class.category.php
[edit]
[-] class.charset.php
[edit]
[+]
cli
[-] class.cron.php
[edit]
[-] class.captcha.php
[edit]
[-] class.dynamic_forms.php
[edit]
[-] class.faq.php
[edit]
[+]
plugins
[-] class.pdf.php
[edit]
[-] ajax.schedule.php
[edit]
[-] class.usersession.php
[edit]
[-] class.topic.php
[edit]
[-] class.base32.php
[edit]
[-] htmLawed.php
[edit]
[-] ajax.sequence.php
[edit]
[+]
i18n
[-] class.signal.php
[edit]
[-] class.mailfetch.php
[edit]
[-] UniversalClassLoader.php
[edit]
[-] class.sequence.php
[edit]
[-] class.businesshours.php
[edit]
[-] class.role.php
[edit]
[+]
pear
[-] class.yaml.php
[edit]
[-] Spyc.php
[edit]
[-] mysqli.php
[edit]
[-] class.thread_actions.php
[edit]
[-] class.export.php
[edit]
[-] ajax.plugins.php
[edit]
[-] class.collaborator.php
[edit]
[-] class.ostsession.php
[edit]
[+]
staff
[-] class.attachment.php
[edit]
[-] class.template.php
[edit]
[-] class.filter.php
[edit]
[-] class.controller.php
[edit]
[-] class.team.php
[edit]
[-] class.session.php
[edit]
[-] class.avatar.php
[edit]
[-] ajax.kbase.php
[edit]
[-] class.variable.php
[edit]
[-] class.validator.php
[edit]
[-] ajax.tasks.php
[edit]
[-] class.upgrader.php
[edit]
[-] class.page.php
[edit]
[-] ajax.export.php
[edit]
[-] ajax.search.php
[edit]
[-] PasswordHash.php
[edit]
[-] class.report.php
[edit]
[-] class.forms.php
[edit]
[-] class.task.php
[edit]
[-] class.migrater.php
[edit]
[-] class.lock.php
[edit]
[-] class.organization.php
[edit]
[-] class.pagenate.php
[edit]
[-] api.cron.php
[edit]
[-] class.api.php
[edit]
[-] class.thread.php
[edit]
[-] class.knowledgebase.php
[edit]
[-] .MANIFEST
[edit]
[-] class.log.php
[edit]
[-] ajax.draft.php
[edit]
[-] class.ajax.php
[edit]
[-] ost-config.php
[edit]
[-] txets.php
[edit]
[-] .htaccess.disabled
[edit]