/** * Show milestones index page * * @param void * @return null */ function index() { require_once SMARTY_PATH . '/plugins/modifier.datetime.php'; //BOF: task 03 | AD /* $milestones = Milestones::findActiveByProject($this->active_project, STATE_VISIBLE, $this->logged_user->getVisibility()); //EOF: task 03 | AD //BOF: task 03 | AD */ //BOF: task 04 | AD /* //EOF: task 04 | AD $milestones = Milestones::findActiveByProject($this->active_project, STATE_VISIBLE, $this->logged_user->getVisibility(), $this->order_by, $this->sort_order); //BOF: task 04 | AD */ //EOF: task 04 | AD //EOF: task 03 | AD if ($this->request->isApiCall()) { //BOF: task 04 | AD $milestones = Milestones::findActiveByProject($this->active_project, STATE_VISIBLE, $this->logged_user->getVisibility(), $this->order_by, $this->sort_order); //EOF: task 04 | AD $this->serveData($milestones, 'milestones'); } else { //BOF: task 04 | AD /* //EOF: task 04 | AD $this->smarty->assign('milestones', $milestones); //BOF: task 04 | AD */ $selected_category_id = $_GET['category_id']; $selected_category_name = 'All'; $project_id = $this->active_project->getId(); $milestones = array(); $categories_all = array(); $link = mysql_connect(DB_HOST, DB_USER, DB_PASS); mysql_select_db(DB_NAME); $query = "select id, category_name from healingcrystals_project_milestone_categories where project_id='" . $project_id . "' order by category_name"; $result = mysql_query($query); while ($category = mysql_fetch_assoc($result)) { //BOF:mod 20121108 /* //EOF:mod 20121108 $categories_all[] = array('category_id' => $category['id'], 'category_name' => $category['category_name']); //BOF:mod 20121108 */ $categories_all[] = array('id' => $category['id'], 'name' => $category['category_name'], 'url' => assemble_url('project_milestones', array('project_id' => $project_id)) . '&category_id=' . $category['id']); //EOF:mod 20121108 /*$query_1 = "select distinct a.id from healingcrystals_project_objects a inner join healingcrystals_project_object_categories b on a.id=b.object_id where a.project_id='" . $this->active_project->getId() . "' and type='Milestone' and completed_on is null and b.category_id='" . $category['id'] . "'"; //mysql_query("insert into healingcrystals_testing (query, fired_at) values ('" . mysql_real_escape_string($query_1) . "', now())"); $result_1 = mysql_query($query_1, $link); while($id = mysql_fetch_assoc($result_1)){ $ids[] = $info['id']; } $temp = Milestones::findByIds($ids, STATE_VISIBLE, $this->logged_user->getVisibility(), $this->order_by, $this->sort_order);*/ $temp = Milestones::findActiveByProject($this->active_project, STATE_VISIBLE, $this->logged_user->getVisibility(), $this->order_by, $this->sort_order, $category['id']); if (count($temp)) { $milestones[] = array('category_id' => $category['id'], 'category_name' => $category['category_name'], 'milestones_' => $temp, 'category_url' => assemble_url('project_milestones', array('project_id' => $project_id, 'category_id' => $category['id']))); if (!empty($selected_category_id) && $selected_category_id == $category['id']) { $selected_category_name = $category['category_name']; } } } //BOF:mod 20121108 $uncategorized_entries_exist = false; //EOF:mod 20121108 $temp = Milestones::findActiveByProject($this->active_project, STATE_VISIBLE, $this->logged_user->getVisibility(), $this->order_by, $this->sort_order, ''); if (count($temp)) { $milestones[] = array('category_id' => '-1', 'category_name' => 'Uncategorized Projects', 'milestones_' => $temp, 'category_url' => assemble_url('project_milestones', array('project_id' => $project_id, 'category_id' => '-1'))); if (!empty($selected_category_id) && $selected_category_id == '-1') { $selected_category_name = 'Uncategorized'; } //BOF:mod 20121108 $uncategorized_entries_exist = true; //EOF:mod 20121108 } mysql_close($link); //$this->smarty->assign('milestones', $milestones); $this->smarty->assign(array('milestones' => $milestones, 'selected_category_id' => $selected_category_id, 'selected_category_name' => $selected_category_name, 'categories_all' => $categories_all, 'categories_url' => assemble_url('project_manage_milestone_categories', array('project_id' => $project_id)), 'uncategorized_entries_exist' => $uncategorized_entries_exist)); //EOF: task 04 | AD } // if }
function move_to() { $gettype = $_GET['gettype']; $team_id = $_GET['team_id']; $project_id = $_GET['project_id']; $ticket_id = $_GET['ticket_id']; $move_to_object_id = $_GET['move_to_object_id']; if (!empty($gettype)) { $this->smarty->assign('gettype', $gettype); switch ($gettype) { case 'projects': $projects = array(); if (!empty($team_id)) { $project_obj = new Project($team_id); //$projects = Milestones::findByProject($project_obj, $this->logged_user); $projects = Milestones::findActiveByProject($project_obj, STATE_VISIBLE, VISIBILITY_NORMAL, 'name', '', '-1'); } $this->smarty->assign('projects', $projects); break; case 'tickets': $tickets = array(); if (!empty($project_id)) { $milestone_obj = new Milestone($project_id); //$tickets = Tickets::findByMilestone($milestone_obj, STATE_VISIBLE, $this->logged_user->getVisibility()); $tickets = Tickets::findOpenByMilestone($milestone_obj, STATE_VISIBLE, $this->logged_user->getVisibility()); } $this->smarty->assign('tickets', $tickets); break; case 'pages': $pages_with_milestone = array(); $pages_with_project = array(); if (!empty($team_id)) { $project_obj = new Project($team_id); //$pages_with_project = Pages::findByProjectWithoutMilestoneAssociation($project_obj, STATE_VISIBLE, $this->logged_user->getVisibility()); $pages_with_project = Pages::findUnarchivedByProjectWithoutMilestoneAssociation($project_obj, STATE_VISIBLE, $this->logged_user->getVisibility()); } elseif (!empty($project_id)) { if (!empty($project_id)) { $milestone_obj = new Milestone($project_id); $team_id = $milestone_obj->getProjectId(); //$pages_with_milestone = Pages::findByMilestone($milestone_obj, STATE_VISIBLE, $this->logged_user->getVisibility()); $pages_with_milestone = Pages::findUnarchivedByMilestone($milestone_obj, STATE_VISIBLE, $this->logged_user->getVisibility()); $project_obj = new Project($team_id); //$pages_with_project = Pages::findByProjectWithoutMilestoneAssociation($project_obj, STATE_VISIBLE, $this->logged_user->getVisibility()); $pages_with_project = Pages::findUnarchivedByProjectWithoutMilestoneAssociation($project_obj, STATE_VISIBLE, $this->logged_user->getVisibility()); } } $this->smarty->assign('pages_with_milestone', $pages_with_milestone); $this->smarty->assign('pages_with_project', $pages_with_project); break; case 'action': $move_to_object = new ProjectObject($move_to_object_id); $link = mysql_connect(DB_HOST, DB_USER, DB_PASS); mysql_select_db(DB_NAME); mysql_query("update healingcrystals_attachments set parent_id='" . $move_to_object->getId() . "', parent_type='" . $move_to_object->getType() . "' where id='" . $this->active_attachment->getId() . "'"); mysql_close($link); $type = $move_to_object->getType(); $obj = new $type($move_to_object_id); $link = 'Attachment Moved: <a href="' . $obj->getViewUrl() . '">Click to View</a>'; $this->smarty->assign('link', $link); break; } } else { $teams = Projects::findNamesByUser($this->logged_user); $this->smarty->assign('teams', $teams); } $parent = $this->active_attachment->getParent(); $this->smarty->assign('cur_project_id', $parent->getProjectId()); $this->smarty->assign('cur_attachment_id', $this->active_attachment->getId()); }
/** * List of discussions * */ function index() { $this->addBreadcrumb(lang('List')); $milestones = Milestones::findActiveByProject($this->active_project, STATE_VISIBLE, $this->logged_user->getVisibility()); $this->smarty->assign(array("milestones" => $milestones, "page_back_url" => assemble_url('mobile_access_view_project', array('project_id' => $this->active_project->getId())))); }
/** * Render select milestone control * * Params: * * - project - Project instance that need to be used * - active_only - Return only active milestones, true by default * * @param array $params * @param Smarty $smarty * @return string */ function smarty_function_select_milestone($params, &$smarty) { $project = array_var($params, 'project'); if (!instance_of($project, 'Project')) { return new InvalidParamError('project', $project, '$project value is expected to be an instance of Project class', true); } // if unset($params['project']); $active_only = false; if (isset($params['active_only'])) { $active_only = (bool) $params['active_only']; unset($params['active_only']); } // if $value = null; if (isset($params['value'])) { $value = $params['value']; unset($params['value']); } // if $optional = true; if (isset($params['optional'])) { $optional = (bool) $params['optional']; unset($params['optional']); } // if $options = array(); if ($optional) { $options[] = option_tag(lang('-- None --'), ''); $options[] = option_tag('', ''); } // if $logged_user = $smarty->get_template_vars('logged_user'); $milestones = $active_only ? Milestones::findActiveByProject($project, STATE_VISIBLE, $logged_user->getVisibility()) : Milestones::findByProject($project, $logged_user); //BOF:mod 20130126 $entries_exist = false; //EOF:mod 20130126 if (is_foreachable($milestones)) { $completed_options = array(); foreach ($milestones as $milestone) { if ($milestone->isCompleted()) { $option_attributes = $milestone->getId() == $value ? array('selected' => true) : null; $completed_options[] = option_tag($milestone->getName(), $milestone->getId(), $option_attributes); } else { //BOF:mod 20130126 $entries_exist = true; //EOF:mod 20130126 $option_attributes = $milestone->getId() == $value ? array('selected' => true) : null; $options[] = option_tag($milestone->getName(), $milestone->getId(), $option_attributes); } // if } // foreach if (is_foreachable($completed_options)) { $options[] = option_tag('', ''); $options[] = option_group_tag(lang('Completed'), $completed_options); } // if } // if //BOF:mod 20130126 if (!$entries_exist) { unset($params['class']); } //EOF:mod 20130126 return select_box($options, $params); }
/** * Show tickets index page * * @param void * @return null */ function index() { /* $selected_milestone_id = $_GET['milestone_id']; $milestones = Milestones::findByProject($this->active_project, $this->logged_user); //$milestones = Milestones::findActiveByProject($this->active_project, STATE_VISIBLE, $this->logged_user->getVisibility()); if (empty($selected_milestone_id)){ //$tickets = Tickets::findOpenByProject($this->active_project, STATE_VISIBLE, $this->logged_user->getVisibility()); $tickets = Milestones::groupByMilestone(Tickets::findOpenByProject($this->active_project, STATE_VISIBLE, $this->logged_user->getVisibility()), STATE_VISIBLE, $this->logged_user->getVisibility()); } else { $milestone = new Milestone($selected_milestone_id); $tickets_in_milestone = Tickets::findByMilestone($milestone, STATE_VISIBLE, $this->logged_user->getVisibility()); $tickets[$milestone->getId()] = array('milestone' => $milestone, 'objects' => $tickets_in_milestone); } $this->smarty->assign(array('milestones' => $milestones, 'selected_milestone_id' => $selected_milestone_id, 'can_add_ticket' => Ticket::canAdd($this->logged_user, $this->active_project), 'can_manage_categories' => $this->logged_user->isProjectLeader($this->active_project) || $this->logged_user->isProjectManager(), 'tickets' => $tickets, 'categories' => Categories::findByModuleSection($this->active_project, TICKETS_MODULE, 'tickets'), 'tickets_count' => (!empty($selected_milestone_id) ? count($tickets[$milestone->getId()]['objects']) : '-1') )); */ if ($this->request->isApiCall()) { if ($this->active_category->isLoaded()) { $this->serveData(Tickets::findOpenByCategory($this->active_category, STATE_VISIBLE, $this->logged_user->getVisibility()), 'tickets'); } else { $this->serveData(Tickets::findOpenByProject($this->active_project, STATE_VISIBLE, $this->logged_user->getVisibility()), 'tickets'); } // if } else { $tickets_url = tickets_module_url($this->active_project); $options_sort = new NamedList(); $options_sort->add('category', array('url' => $tickets_url . '&sort=category', 'text' => lang('by Category'))); $options_sort->add('star', array('url' => $tickets_url . '&sort=star', 'text' => lang('by Star'))); $options_sort->add('priority', array('url' => $tickets_url . '&sort=priority', 'text' => lang('by Priority'))); $options_sort->add('name', array('url' => $tickets_url . '&sort=name', 'text' => lang('by Name'))); $options_sort->add('owner', array('url' => $tickets_url . '&sort=owner', 'text' => lang('by Owner'))); //BOF:mod #59_266 $options_sort->add('project', array('url' => $tickets_url . '&sort=milestone', 'text' => 'by Milestone')); //EOF:mod #59_266 $this->wireframe->addPageAction(lang('Sort'), '#', $options_sort->data); $task_id = $_GET['task_id']; if (!empty($task_id)) { $link = mysql_connect(DB_HOST, DB_USER, DB_PASS); mysql_select_db(DB_NAME); $query = "select type, body from healingcrystals_project_objects where id='" . (int) $task_id . "'"; $result = mysql_query($query); $info = mysql_fetch_assoc($result); if (strtolower($info['type']) == 'task') { $body_wo_tags = strip_tags($info['body']); $query = "select max(integer_field_1) as max_count from healingcrystals_project_objects where project_id='" . $this->active_project->getId() . "'"; $result = mysql_query($query); $info = mysql_fetch_assoc($result); $integer_field_1 = $info['max_count'] + 1; $query = "update healingcrystals_project_objects set \n type='Ticket', \n module='tickets', \n parent_id='0', \n parent_type=null, \n name='" . str_replace("'", "''", $body_wo_tags) . "', \n body=null, \n updated_on=now(), \n updated_by_id='" . $this->logged_user->getId() . "', \n integer_field_1='" . $integer_field_1 . "' where id='" . (int) $task_id . "'"; mysql_query($query); $edit_url = assemble_url('project_ticket_edit', array('project_id' => $this->active_project->getId(), 'ticket_id' => $integer_field_1)); header('Location: ' . $edit_url); } mysql_close($link); } $cur_department = $_GET['department_id']; $mID = $_GET['mID']; $page = (int) $_GET['page']; $page = $page <= 0 ? 1 : $page; $limit = (int) $_GET['limit']; //$limit = $limit<=0 ? 50 : $limit; $limit = $limit <= 0 ? 1000 : $limit; $offset = ($page - 1) * $limit; $sort_by = trim(strtolower($_GET['sort'])); $sort_by = empty($sort_by) ? 'category' : $sort_by; $link = mysql_connect(DB_HOST, DB_USER, DB_PASS); mysql_select_db(DB_NAME); $tickets = array(); /*if($this->active_category->isLoaded()) { $tickets = Milestones::groupByMilestone( Tickets::findOpenByCategory($this->active_category, STATE_VISIBLE, $this->logged_user->getVisibility()), STATE_VISIBLE, $this->logged_user->getVisibility() ); } else { $tickets = Milestones::groupByMilestone( Tickets::findOpenByProject($this->active_project, STATE_VISIBLE, $this->logged_user->getVisibility()), STATE_VISIBLE, $this->logged_user->getVisibility() );*/ if (empty($cur_department)) { //BOF:mod #59_266 /* //EOF:mod #59_266 $query = "select a.id as ticket_id, b.id as milestone_id, ifnull(a.priority, '0') from healingcrystals_project_objects a left join healingcrystals_project_objects b on a.milestone_id=b.id " ; //BOF:mod #59_266 */ $query = "select distinct a.id as ticket_id, b.id as milestone_id, cast(ifnull(a.priority, '0') as signed integer) as priority ::CONTENT_PLACE_HOLDER:: from healingcrystals_project_objects a left join healingcrystals_project_objects b on a.milestone_id=b.id "; //EOF:mod #59_266 //BOF:mod 20120911 /* //EOF:mod 20120911 $query_condition = " where a.project_id='" . $this->active_project->getId() . "' and a.type='Ticket' and a.state='" . STATE_VISIBLE . "' and a.visibility='" . VISIBILITY_NORMAL . "' and a.completed_on is null " . ($this->active_category && $this->active_category->isLoaded() ? " and a.parent_id='" . $this->active_category->getId() . "' " : "") . (!empty($mID) ? " and b.id='" . $mID . "'" : ""); //BOF:mod 20120911 */ $query_condition = " where a.project_id='" . $this->active_project->getId() . "' and a.type='Ticket' and a.state='" . STATE_VISIBLE . "' and a.visibility>='" . $this->logged_user->getVisibility() . "' and a.completed_on is null " . ($this->active_category && $this->active_category->isLoaded() ? " and a.parent_id='" . $this->active_category->getId() . "' " : "") . (!empty($mID) ? " and b.id='" . $mID . "'" : ""); //EOF:mod 20120911 } else { if ($cur_department == '-1') { //BOF:mod #59_266 /* //EOF:mod #59_266 $query = "select a.id as ticket_id, b.id as milestone_id, ifnull(a.priority, '0') from healingcrystals_project_objects a left join healingcrystals_project_objects b on a.milestone_id=b.id " ; //BOF:mod #59_266 */ $query = "select distinct a.id as ticket_id, b.id as milestone_id, cast(ifnull(a.priority, '0') as signed integer) as priority ::CONTENT_PLACE_HOLDER:: from healingcrystals_project_objects a left join healingcrystals_project_objects b on a.milestone_id=b.id "; //EOF:mod #59_266 //BOF:mod 20120911 /* //EOF:mod 20120911 $query_condition = " where not exists(select * from healingcrystals_project_object_categories obj where obj.object_id=a.id) and a.project_id='" . $this->active_project->getId() . "' and a.type='Ticket' and a.state='" . STATE_VISIBLE . "' and a.visibility='" . VISIBILITY_NORMAL . "' and a.completed_on is null " . ($this->active_category && $this->active_category->isLoaded() ? " and a.parent_id='" . $this->active_category->getId() . "' " : "") . (!empty($mID) ? " and b.id='" . $mID . "'" : ""); //BOF:mod 20120911 */ $query_condition = " where not exists(select * from healingcrystals_project_object_categories obj where obj.object_id=a.id) and a.project_id='" . $this->active_project->getId() . "' and a.type='Ticket' and a.state='" . STATE_VISIBLE . "' and a.visibility>='" . $this->logged_user->getVisibility() . "' and a.completed_on is null " . ($this->active_category && $this->active_category->isLoaded() ? " and a.parent_id='" . $this->active_category->getId() . "' " : "") . (!empty($mID) ? " and b.id='" . $mID . "'" : ""); //EOF:mod 20120911 } elseif ($cur_department == '-99') { //BOF:mod #59_266 /* //EOF:mod #59_266 $query = "select a.id as ticket_id, b.id as milestone_id, ifnull(a.priority, '0') from healingcrystals_project_objects a left join healingcrystals_project_objects b on a.milestone_id=b.id left join healingcrystals_project_milestone_categories dep on a.project_id=dep.project_id left join healingcrystals_project_object_categories obj on (dep.id=obj.category_id and a.id=obj.object_id) " ; //BOF:mod #59_266 */ $query = "select distinct a.id as ticket_id, b.id as milestone_id, cast(ifnull(a.priority, '0') as signed integer) as priority ::CONTENT_PLACE_HOLDER:: from healingcrystals_project_objects a left join healingcrystals_project_objects b on a.milestone_id=b.id left join healingcrystals_project_milestone_categories dep on a.project_id=dep.project_id left join healingcrystals_project_object_categories obj on (dep.id=obj.category_id and a.id=obj.object_id) "; //EOF:mod #59_266 $query_condition = " where a.project_id='" . $this->active_project->getId() . "' and a.type='Ticket' and a.completed_on is not null " . ($this->active_category && $this->active_category->isLoaded() ? " and a.parent_id='" . $this->active_category->getId() . "' " : "") . (!empty($mID) ? " and b.id='" . $mID . "'" : ""); } else { //BOF:mod #59_266 /* //EOF:mod #59_266 $query = "select a.id as ticket_id, b.id as milestone_id, ifnull(a.priority, '0') from healingcrystals_project_objects a left join healingcrystals_project_objects b on a.milestone_id=b.id inner join healingcrystals_project_milestone_categories dep on a.project_id=dep.project_id inner join healingcrystals_project_object_categories obj on (dep.id=obj.category_id and a.id=obj.object_id) " ; //BOF:mod #59_266 */ $query = "select distinct a.id as ticket_id, b.id as milestone_id, cast(ifnull(a.priority, '0') as signed integer) as priority ::CONTENT_PLACE_HOLDER:: from healingcrystals_project_objects a left join healingcrystals_project_objects b on a.milestone_id=b.id inner join healingcrystals_project_milestone_categories dep on a.project_id=dep.project_id inner join healingcrystals_project_object_categories obj on (dep.id=obj.category_id and a.id=obj.object_id) "; //EOF:mod #59_266 //BOF:mod 20120911 /* //EOF:mod 20120911 $query_condition = " where a.project_id='" . $this->active_project->getId() . "' and dep.id='" . $cur_department . "' and a.type='Ticket' and a.state='" . STATE_VISIBLE . "' and a.visibility='" . VISIBILITY_NORMAL . "' and a.completed_on is null " . ($this->active_category && $this->active_category->isLoaded() ? " and a.parent_id='" . $this->active_category->getId() . "' " : "") . (!empty($mID) ? " and b.id='" . $mID . "'" : ""); //BOF:mod 20120911 */ $query_condition = " where a.project_id='" . $this->active_project->getId() . "' and dep.id='" . $cur_department . "' and a.type='Ticket' and a.state='" . STATE_VISIBLE . "' and a.visibility>='" . $this->logged_user->getVisibility() . "' and a.completed_on is null " . ($this->active_category && $this->active_category->isLoaded() ? " and a.parent_id='" . $this->active_category->getId() . "' " : "") . (!empty($mID) ? " and b.id='" . $mID . "'" : ""); //EOF:mod 20120911 } } //BOF:mod #59_266 /* //EOF:mod #59_266 $result = mysql_query($query . $query_condition); $total_tickets = mysql_num_rows($result); $total_pages = ceil($total_tickets / $limit); if ($sort_by=='category'){ //BOF:mod #59_266 */ if ($sort_by == 'category' || $sort_by == 'milestone') { if ($sort_by == 'category') { $query_1 = str_replace('::CONTENT_PLACE_HOLDER::', '', $query) . $query_condition; } else { $query_1 = str_replace('::CONTENT_PLACE_HOLDER::', ", (select max(created_on) from healingcrystals_project_objects c where c.type='Comment' and c.parent_id=a.id) as comment_date", $query) . $query_condition; } $result_temp = mysql_query($query_1); $total_tickets = mysql_num_rows($result_temp); $total_pages = ceil($total_tickets / $limit); if ($sort_by == 'category') { //$query_1 .= " order by isnull(b.id), b.name, a.position, priority desc limit " . $offset . ", " . $limit; $query_1 .= " order by isnull(b.id), b.name, priority desc, a.position limit " . $offset . ", " . $limit; } else { $query_1 .= " order by isnull(b.id), b.name, priority desc, comment_date desc limit " . $offset . ", " . $limit; } /* //EOF:mod #59_266 $query_1 = $query . $query_condition . " order by isnull(b.id), b.name, a.priority desc limit " . $offset . ", " . $limit; //BOF:mod #59_266 */ //EOF:mod #59_266 $result = mysql_query($query_1, $link); $cur_milestone_id = -1; while ($ticket = mysql_fetch_assoc($result)) { if ($cur_milestone_id == -1 || $cur_milestone_id != (int) $ticket['milestone_id']) { $cur_milestone_id = (int) $ticket['milestone_id']; if ($cur_milestone_id == 0) { $cur_milestone_ref = null; } else { $cur_milestone_ref = new Milestone($ticket['milestone_id']); } $tickets[] = array('milestone' => $cur_milestone_ref, 'objects' => array()); } $tickets[count($tickets) - 1]['objects'][] = new Ticket($ticket['ticket_id']); } } elseif ($sort_by == 'star' || $sort_by == 'priority' || $sort_by == 'name' || $sort_by == 'owner') { //BOF:mod #59_266 $query = str_replace('::CONTENT_PLACE_HOLDER::', '', $query); $result_temp = mysql_query($query . $query_condition); $total_tickets = mysql_num_rows($result_temp); $total_pages = ceil($total_tickets / $limit); //EOF:mod #59_266 switch ($sort_by) { case 'star': $query_1 = $query . " left join healingcrystals_starred_objects c on (a.id=c.object_id and c.user_id='" . $this->logged_user->getId() . "') left join healingcrystals_assignments d on (a.id=d.object_id and d.is_owner='1') left join healingcrystals_users e on d.user_id=e.id " . $query_condition . " order by isnull(c.object_id), 3 desc, isnull(e.first_name), e.first_name limit " . $offset . ", " . $limit; break; case 'priority': $query_1 = $query . " left join healingcrystals_assignments d on (a.id=d.object_id and d.is_owner='1') left join healingcrystals_users e on d.user_id=e.id " . $query_condition . " order by 3 desc, isnull(e.first_name), e.first_name, a.name limit " . $offset . ", " . $limit; break; case 'name': $query_1 = $query . $query_condition . " order by a.name limit " . $offset . ", " . $limit; break; case 'owner': $query_1 = $query . " left join healingcrystals_assignments d on (a.id=d.object_id and d.is_owner='1') left join healingcrystals_users e on d.user_id=e.id " . $query_condition . " order by isnull(e.first_name), e.first_name, 3 desc, a.name limit " . $offset . ", " . $limit; break; } $result = mysql_query($query_1, $link); while ($ticket = mysql_fetch_assoc($result)) { $cur_milestone_id = (int) $ticket['milestone_id']; if ($cur_milestone_id == 0) { $cur_milestone_ref = null; } else { $cur_milestone_ref = new Milestone($ticket['milestone_id']); } $tickets[] = array('milestone' => $cur_milestone_ref, 'ticket' => new Ticket($ticket['ticket_id'])); } } //} // if $all_milestones = array(); //BOF:mod 20120911 /* //EOF:mod 20120911 $query = "select id, name from healingcrystals_project_objects where project_id='" . $this->active_project->getId() . "' and type='Milestone' and state='" . STATE_VISIBLE . "' and visibility='" . VISIBILITY_NORMAL . "' and completed_on is null order by name"; //BOF:mod 20120911 */ $query = "select id, name from healingcrystals_project_objects where project_id='" . $this->active_project->getId() . "' and type='Milestone' and state='" . STATE_VISIBLE . "' and visibility>='" . $this->logged_user->getVisibility() . "' and completed_on is null order by name"; //EOF:mod 20120911 $result = mysql_query($query, $link); while ($milestone = mysql_fetch_assoc($result)) { $all_milestones[] = array('id' => $milestone['id'], 'name' => $milestone['name']); } $departments = array(); $query = "select id, category_name from healingcrystals_project_milestone_categories where project_id='" . $this->active_project->getId() . "' order by category_name"; $result = mysql_query($query); while ($department = mysql_fetch_assoc($result)) { $departments[] = array('department_id' => $department['id'], 'department_name' => $department['category_name']); } $departments[] = array('department_id' => '-1', 'department_name' => 'Uncategorized'); mysql_close($link); $this->smarty->assign(array('categories' => Categories::findByModuleSection($this->active_project, TICKETS_MODULE, 'tickets'), 'groupped_tickets' => $tickets, 'milestones' => Milestones::findActiveByProject($this->active_project, STATE_VISIBLE, $this->logged_user->getVisibility()), 'can_add_ticket' => Ticket::canAdd($this->logged_user, $this->active_project), 'can_manage_categories' => $this->logged_user->isProjectLeader($this->active_project) || $this->logged_user->isProjectManager(), 'departments_url' => assemble_url('project_manage_milestone_categories', array('project_id' => $this->active_project->getId())), 'total_tickets' => $total_tickets, 'total_pages' => $total_pages, 'current_page' => $page, 'all_milestones' => $all_milestones, 'current_milestone' => $mID, 'sort_by' => $sort_by, 'departments' => $departments, 'current_department_id' => $cur_department)); js_assign('can_manage_tickets', Ticket::canManage($this->logged_user, $this->active_project)); } // if }