PATH:
home
/
centosnipponia
/
public_html
/
ticketing.nipponia.com
/
include
<?php /********************************************************************* class.collaborator.php Ticket collaborator 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: **********************************************************************/ require_once(INCLUDE_DIR . 'class.user.php'); require_once(INCLUDE_DIR . 'class.client.php'); class Collaborator extends VerySimpleModel implements EmailContact, ITicketUser { static $meta = array( 'table' => THREAD_COLLABORATOR_TABLE, 'pk' => array('id'), 'select_related' => array('user'), 'joins' => array( 'thread' => array( 'constraint' => array('thread_id' => 'Thread.id'), ), 'user' => array( 'constraint' => array('user_id' => 'User.id'), ), ), ); const FLAG_ACTIVE = 0x0001; const FLAG_CC = 0x0002; var $active; function getId() { return $this->id; } function isActive() { return !!($this->flags & self::FLAG_ACTIVE); } function getCreateDate() { return $this->created; } function getThreadId() { return $this->thread_id; } function getTicketId() { if ($this->thread && $this->thread->object_type == ObjectModel::OBJECT_TYPE_TICKET) return $this->thread->object_id; } function getTicket() { // TODO: Change to $this->thread->ticket when Ticket goes to ORM if ($id = $this->getTicketId()) return Ticket::lookup($id); } function getUser() { return $this->user; } // EmailContact interface function getEmail() { return $this->user->getEmail(); } function getEmailAddress() { $emailaddr = (string) $this->getEmail(); if (($name=$this->getName())) $emailaddr = sprintf('"%s" <%s>', (string) $name, $emailaddr); return $emailaddr; } function getName() { return $this->user->getName(); } static function getIdByUserId($userId, $threadId) { $row = Collaborator::objects() ->filter(array('user_id'=>$userId, 'thread_id'=>$threadId)) ->values_flat('id') ->first(); return $row ? $row[0] : 0; } // VariableReplacer interface function getVar($what) { global $cfg; switch (strtolower($what)) { case 'ticket_link': $qstr = array(); if ($this->getTicket()->getAuthToken($this) && ($ticket=$this->getTicket()) && !$ticket->getThread()->getNumCollaborators()) { $qstr['auth'] = $ticket->getAuthToken($this); return sprintf('%s/view.php?%s', $cfg->getBaseUrl(), Http::build_query($qstr, false) ); } else { return sprintf('%s/tickets.php?id=%s', $cfg->getBaseUrl(), $ticket->getId() ); } } } // ITicketUser interface var $_isguest; function isOwner() { return false; } function flagGuest() { $this->_isguest = true; } function isGuest() { return $this->_isguest; } function getUserId() { return $this->user_id; } function __toString() { return Format::htmlchars($this->getEmailAddress()); } function hasFlag($flag) { return ($this->get('flags', 0) & $flag) != 0; } public function setFlag($flag, $val) { if ($val) $this->flags |= $flag; else $this->flags &= ~$flag; } public function setCc($active=true) { $this->setFlag(Collaborator::FLAG_ACTIVE, $active); $this->setFlag(Collaborator::FLAG_CC, true); $this->save(); } function isCc() { return !!($this->flags & self::FLAG_CC); } function getCollabList($collabs) { $collabList = array(); foreach ($collabs as $c) { $u = User::lookup($c); if ($u) { $email = $u->getEmail()->address; $collabList[$c] = $email; } } return $collabList; } static function create($vars=false) { $inst = new static($vars); $inst->setFlag(Collaborator::FLAG_ACTIVE, true); $inst->setFlag(Collaborator::FLAG_CC, true); $inst->created = SqlFunction::NOW(); return $inst; } function save($refetch=false) { if ($this->dirty) $this->updated = SqlFunction::NOW(); return parent::save($refetch || $this->dirty); } static function add($info, &$errors) { if (!$info || !$info['threadId'] || !$info['userId']) $errors['err'] = __('Invalid or missing information'); elseif ($c = Collaborator::lookup(array( 'thread_id' => $info['threadId'], 'user_id' => $info['userId'], ))) $errors['err'] = sprintf(__('%s is already a collaborator'), $c->getName()); if ($errors) return false; $collab = static::create(array( 'thread_id' => $info['threadId'], 'user_id' => $info['userId'], )); if ($collab->save(true)) return $collab; $errors['err'] = __('Unable to add collaborator.') .' '.__('Internal error occurred'); return false; } } ?>
[+]
..
[-] 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]