function tickets_dashboard_content($context) { $tickets = ProjectTickets::getOpenTicketsByUser(logged_user()); $context->assign('ticketsheader', lang('open tickets')); $context->assign('tickets', $tickets); $context->includeTemplate(get_template_path('dashboard', 'tickets')); }
/** * Return ticket object * * @param void * @return ProjectTicket */ function getTicket() { if (is_null($this->ticket)) { $this->ticket = ProjectTickets::findById($this->getTicketId()); } return $this->ticket; }
/** * Returns a total count of all tickets. * * @access public * @param void * @return string */ function getTotalTicketCount() { if (!plugin_active('tickets')) { return 0; } return ProjectTickets::count('`milestone_id` = ' . DB::escape($this->getId())); }
/** * This function will return paginated result. Result is an array where first element is * array of returned object and second populated pagination object that can be used for * obtaining and rendering pagination data using various helpers. * * Items and pagination array vars are indexed with 0 for items and 1 for pagination * because you can't use associative indexing with list() construct * * @access public * @param array $arguments Query argumens (@see find()) Limit and offset are ignored! * @param integer $items_per_page Number of items per page * @param integer $current_page Current page number * @return array */ function paginate($arguments = null, $items_per_page = 10, $current_page = 1) { if (isset($this) && instance_of($this, 'ProjectTickets')) { return parent::paginate($arguments, $items_per_page, $current_page); } else { return ProjectTickets::instance()->paginate($arguments, $items_per_page, $current_page); } // if }
/** * Unsubscribe from message * * @param void * @return null */ function unsubscribe() { $ticket = ProjectTickets::findById(get_id()); if (!$ticket instanceof ProjectTicket) { flash_error(lang('ticket dnx')); $this->redirectTo('tickets'); } // if if (!$ticket->canView(logged_user())) { flash_error(lang('no access permissions')); $this->redirectTo('tickets'); } // if if ($ticket->unsubscribeUser(logged_user())) { flash_success(lang('success unsubscribe to ticket')); } else { flash_error(lang('error unsubscribe to ticket')); } // if $this->redirectToUrl($ticket->getViewUrl()); }
/** * Return array of task that are assigned to specific user or his company * * @param User $user * @return array */ function getUsersTickets(User $user) { if (!plugin_active('tickets')) return null; $conditions = DB::prepareString('`project_id` = ? AND ((`assigned_to_user_id` = ? AND `assigned_to_company_id` = ?) OR (`assigned_to_user_id` = ? AND `assigned_to_company_id` = ?) OR (`assigned_to_user_id` = ? AND `assigned_to_company_id` = ?) OR `created_by_id`= ?) AND `closed_on` = ?', array($this->getId(), $user->getId(), $user->getCompanyId(), 0, $user->getCompanyId(), 0, 0, $user->getId(), EMPTY_DATETIME)); if(!$user->isMemberOfOwnerCompany()) { $conditions .= DB::prepareString(' AND `is_private` = ?', array(0)); } // if return ProjectTickets::findAll(array( 'conditions' => $conditions, 'order' => '`created_on`' )); // findAll } // getUsersTickets
/** * Call back function for ticket link * * @param mixed $matches * @return */ function replace_ticket_link_callback($matches) { if (count($matches) < 2) { return null; } // if if (!logged_user()->isMemberOfOwnerCompany()) { $object = ProjectTickets::findOne(array('conditions' => array('`id` = ? AND `project_id` = ? AND `is_private` = 0 ', $matches[1], active_project()->getId()))); } else { $object = ProjectTickets::findOne(array('conditions' => array('`id` = ? AND `project_id` = ?', $matches[1], active_project()->getId()))); } // if if (!$object instanceof ProjectTicket) { return '<del>' . lang('invalid reference') . '</del>'; } else { return '<a href="' . $object->getViewUrl() . '">' . $object->getTitle() . '</a>'; } // if }
<?php $canEdit = $ticket->canEdit(logged_user()); // Set page title and set crumbs to index $title = $canEdit ? 'edit ticket' : 'view ticket'; set_page_title(lang($title)); project_tabbed_navigation(PROJECT_TAB_TICKETS); $crumbs = array(array(lang('tickets'), get_url('tickets'))); if ($ticket->isClosed()) { $crumbs[] = array(lang('closed tickets'), ProjectTickets::getIndexUrl(true)); } $crumbs[] = array(lang($title)); project_crumbs($crumbs); add_stylesheet_to_page('project/tickets.css'); add_stylesheet_to_page('application_logs.css'); if ($ticket->isPrivate()) { ?> <div class="private" title="<?php echo lang('private ticket'); ?> "><span><?php echo lang('private ticket'); ?> </span></div> <?php } // if ?> <h2><?php echo lang('ticket #', $ticket->getId()); ?>
/** * Shows weekly schedule in a calendar view * * @param void * @return null */ function weekly_schedule() { $this->addHelper('textile'); // Gets desired view 'detail', 'list' or 'calendar' // $view_type is from URL, Cookie or set to default: 'calendar' $view_type = array_var($_GET, 'view', Cookie::getValue('weeklyScheduleViewType', 'calendar')); $expiration = Cookie::getValue('remember' . TOKEN_COOKIE_NAME) ? REMEMBER_LOGIN_LIFETIME : null; Cookie::setValue('weeklyScheduleViewType', $view_type, $expiration); $monthYear = array_var($_GET, 'month'); if (!isset($monthYear) || trim($monthYear) == '' || preg_match('/^(\\d{4})(\\d{2})$/', $monthYear, $matches) == 0) { $year = gmdate('Y'); $month = gmdate('m'); } else { list(, $year, $month) = $matches; } // TODO make first day of week configurable $from_date = DateTimeValueLib::makeFromString('monday' . (date('w') == 1 ? '' : ' last week')); $to_date = $from_date->advance(60 * 60 * 24 * 7 * 3, false); // +3 weeks $upcoming_milestones = ProjectMilestones::getActiveMilestonesInPeriodByUser(logged_user(), $from_date, $to_date); $upcoming_tickets = array(); if (plugin_active('tickets')) { $upcoming_tickets = ProjectTickets::getOpenTicketsInPeriodByUser(logged_user(), $from_date, $to_date); } $active_projects = array(); $projects_index = array(); $counter = 1; if (is_array($upcoming_milestones)) { foreach ($upcoming_milestones as $milestone) { if (!isset($projects_index[$milestone->getProjectId()])) { $projects_index[$milestone->getProjectId()] = $counter; $active_projects[] = $milestone->getProject(); $counter++; } // if } // foreach } // if if (is_array($upcoming_tickets)) { foreach ($upcoming_tickets as $ticket) { if (!isset($projects_index[$ticket->getProjectId()])) { $projects_index[$ticket->getProjectId()] = $counter; $active_projects[] = $ticket->getProject(); $counter++; } // if } // foreach } // if tpl_assign('from_date', $from_date); tpl_assign('to_date', $to_date); tpl_assign('view_type', $view_type); tpl_assign('upcoming_tickets', $upcoming_tickets); tpl_assign('late_tickets', array()); // logged_user()->getLateTickets()); tpl_assign('upcoming_milestones', $upcoming_milestones); tpl_assign('late_milestones', array()); // logged_user()->getLateMilestones()); tpl_assign('projects', $active_projects); tpl_assign('projects_index', $projects_index); }
/** * Download tickets as attachment * * @access public * @param void * @return null */ function download() { $this->canGoOn(); $download_type = isset($_REQUEST['content_type']) ? $_REQUEST['content_type'] : 'text/csv'; $download = ProjectTickets::getDownload(active_project(), $download_type); download_contents($download['content'], $download['type'], $download['name'], strlen($download['content'])); die; }
/** * Return manager instance * * @access protected * @param void * @return ProjectTickets */ function manager() { if (!$this->manager instanceof ProjectTickets) { $this->manager = ProjectTickets::instance(); } return $this->manager; }
<div class="blockContent"> <ul> <li><a href="<?php echo ProjectTickets::getIndexUrl(); ?> " <?php if (isset($closed) && !$closed) { echo 'class="selected"'; } ?> ><?php echo lang('open tickets'); ?> </a></li> <li><a href="<?php echo ProjectTickets::getIndexUrl(true); ?> " <?php if (isset($closed) && $closed) { echo 'class="selected"'; } ?> ><?php echo lang('closed tickets'); ?> </a></li> <li><a href="<?php echo get_url('tickets', 'categories'); ?> " <?php if (!isset($closed)) {
/** * Return array of task that are assigned to specific user or his company * * @param User $user * @param array $options * @param boolean $include_company * @return array */ function getUsersTickets(User $user, $options = null, $include_company = false) { if (!plugin_active('tickets')) { return null; } if ($include_company) { $conditions = DB::prepareString('`project_id` = ? AND ((`assigned_to_user_id` = ? AND `assigned_to_company_id` = ?) OR (`assigned_to_user_id` = ? AND `assigned_to_company_id` = ?) OR (`assigned_to_user_id` = ? AND `assigned_to_company_id` = ?) OR `created_by_id`= ?) AND `closed_on` = ?', array($this->getId(), $user->getId(), $user->getCompanyId(), 0, $user->getCompanyId(), 0, 0, $user->getId(), EMPTY_DATETIME)); } else { $conditions = DB::prepareString('`project_id` = ? AND `assigned_to_user_id` = ? AND `closed_on` = ?', array($this->getId(), $user->getId(), EMPTY_DATETIME)); } // if if (!$user->isMemberOfOwnerCompany()) { $conditions .= DB::prepareString(' AND `is_private` = ?', array(0)); } // if $options['conditions'] = $conditions; if (!isset($options['order'])) { $options['order'] = '`created_on`'; } return ProjectTickets::findAll($options); // findAll }