/** * Populate $objects with object that $user can see * * @param Milestone $milestone * @param array $objects * @param User $user * @return null */ function tickets_handle_on_milestone_objects(&$milestone, &$objects, &$user) { if ($user->getProjectPermission('ticket', $milestone->getProject()) >= PROJECT_PERMISSION_ACCESS) { $objects[lang('Tickets')] = Tickets::findByMilestone($milestone, STATE_VISIBLE, $user->getVisibility()); } // if }
public function actionEdit($id) { $ticket = Tickets::model()->with(array('category', 'user'))->findByPk($id); if ($ticket === NULL) { user()->setFlash(FlashConst::MESSAGE_ERROR, Yii::t('backend', 'Тикет не найден.')); $this->redirect(array('/backend/tickets/index')); } if (!$ticket->user) { user()->setFlash(FlashConst::MESSAGE_ERROR, Yii::t('backend', 'Связь с таблицей "Users" была нарушена.')); $this->redirect(array('/backend/tickets/index')); } // Убираю статус нового сообщения if ($ticket->new_message_for_admin == Tickets::STATUS_NEW_MESSAGE_ON) { $ticket->new_message_for_admin = 0; $ticket->save(FALSE, array('new_message_for_admin', 'updated_at')); } // Ответы $answersDataProvider = new CActiveDataProvider('TicketsAnswers', array('criteria' => array('condition' => 'ticket_id = :ticket_id', 'params' => array('ticket_id' => $ticket->id), 'order' => 't.created_at DESC', 'with' => 'userInfo'), 'pagination' => array('pageSize' => 10, 'pageVar' => 'page'))); $model = new TicketsAnswers(); if (isset($_POST['TicketsAnswers'])) { $model->setAttributes($_POST['TicketsAnswers']); $model->ticket_id = $id; if ($model->save()) { // change new message status $ticket->new_message_for_user = 1; $ticket->save(FALSE, array('new_message_for_user', 'updated_at')); notify()->userNoticeTicketAnswer($ticket->user->email, array('ticket' => $ticket, 'user' => $ticket->user)); user()->setFlash(FlashConst::MESSAGE_SUCCESS, Yii::t('backend', 'Ответ добавлен.')); $this->refresh(); } } $this->render('//tickets/edit', array('ticket' => $ticket, 'model' => $model, 'answersDataProvider' => $answersDataProvider)); }
/** * After validate event * @return object */ public function afterValidate() { if (count($this->ids)) { $save = array(); // The values we would like to check if they were changed // key = value from this model // value = value from the tickets model $valuesChanged = array('status' => 'ticketstatus', 'type' => 'tickettype', 'category' => 'ticketcategory', 'priority' => 'priority', 'version' => 'ticketversion', 'fixedin' => 'fixedin', 'assignedtoid' => 'assignedtoid'); // Loop the values foreach ($valuesChanged as $key => $value) { if ($this->{$key}) { $save[$value] = $this->{$key}; } } // Only update if we have any if (count($save)) { // Update all the ticket ids Tickets::model()->updateByPk($this->ids, $save); // Load one ticket model $model = Tickets::model()->findByPk(reset($this->ids)); $this->activity['projectid'] = $model->projectid; $this->activity['type'] = Activity::TYPE_TICKET; $this->activity['title'] = 'Used multi-Moderation to update <strong>{n}</strong> {title}.'; // Append project params $this->activity['params'] = array_merge($this->activity['params'], array('{n}' => count($this->ids), '{title}' => CHtml::link(Yii::t('tickets', 'Tickets'), array('/tickets')))); // Activity: New Project Activity::log($this->activity); } } return parent::afterValidate(); }
public function executeGoto(sfWebRequest $request) { $q = Doctrine_Core::getTable('Tickets')->createQuery('t')->leftJoin('t.TicketsStatus ts')->leftJoin('t.TicketsTypes tt')->leftJoin('t.Departments td')->leftJoin('t.Projects p')->leftJoin('t.Users'); $q->addWhere('projects_id=?', $request->getParameter('projects_id')); if (Users::hasAccess('view_own', 'tickets', $this->getUser(), $request->getParameter('projects_id'))) { $q->addWhere("t.departments_id in (" . implode(',', Departments::getDepartmentIdByUserId($this->getUser()->getAttribute('id'))) . ") or t.users_id='" . $this->getUser()->getAttribute('id') . "'"); } $q = Tickets::addFiltersToQuery($q, $this->getUser()->getAttribute('tickets_filter' . ((int) $request->getParameter('projects_id') > 0 ? $request->getParameter('projects_id') : ''))); $q = app::addListingOrder($q, 'tickets', $this->getUser(), (int) $request->getParameter('projects_id')); $this->menu = array(); $ids = array(); foreach ($q->fetchArray() as $v) { if (strlen($sn = app::getArrayName($v, 'TicketsStatus')) > 0) { $sn = $sn . ': '; } else { $sn = ''; } if ($request->getParameter('tickets_id') == $v['id']) { $v['name'] = '<b>' . $v['name'] . '</b>'; } $this->menu[] = array('title' => $sn . $v['name'], 'url' => 'ticketsComments/index?projects_id=' . $request->getParameter('projects_id') . '&tickets_id=' . $v['id']); $ids[] = $v['id']; } $current_key = array_search($request->getParameter('tickets_id'), $ids); $this->previous_item_id = false; $this->next_item_id = false; if (isset($ids[$current_key - 1])) { $this->previous_item_id = $ids[$current_key - 1]; } if (isset($ids[$current_key + 1])) { $this->next_item_id = $ids[$current_key + 1]; } }
public function run() { $faker = \Faker\Factory::create(); Tickets::truncate(); foreach (range(1, 100) as $index) { Tickets::insert(['title' => $faker->unique()->sentence(3), 'content' => $faker->sentence(10), 'slug' => $faker->unique()->shuffle('0123456789abc'), 'status' => $faker->boolean(50), 'user_id' => $faker->numberBetween(1, 100), 'created_at' => new DateTime(), 'updated_at' => new DateTime()]); } }
/** * Populate $portal_objects with objects which aren't private * * @param Milestone $milestone * @param array $portal_objects * @param Portal $portal * @return null */ function tickets_handle_on_portal_milestone_objects(&$milestone, &$portal_objects, &$portal) { if ($portal->getProjectPermissionValue('ticket') >= PROJECT_PERMISSION_ACCESS) { $portal_objects[lang('Tickets')] = Tickets::findByMilestone($milestone, STATE_VISIBLE, VISIBILITY_NORMAL); // used existing find method } // if }
/** * Handle on_project_object_moved event * * @param ProjectObject $object * @param Project $source * @param Project $destination * @return null */ function tickets_handle_on_project_object_moved(&$object, &$source, &$destination) { if (instance_of($object, 'Ticket')) { $object->setTicketId(Tickets::findNextTicketIdByProject($destination)); $object->save(); } // if }
/** * ServicesExpiration * List of all the services near the expiring date * @return array */ public function Last() { $ns = new Zend_Session_Namespace(); if (!empty($ns->customer)) { $data = $ns->customer; return array('records' => Tickets::Last($data['customer_id']), 'actions' => array('/tickets/edit/id/' => 'Show')); } else { return null; } }
/** * Handle on_copy_project_items event * * @param Project $from * @param Project $to * @param array $milestones_map * @param array $categories_map * @return null */ function tickets_handle_on_copy_project_items(&$from, &$to, $milestones_map, $categories_map) { $tickets = Tickets::findByProject($from, null, STATE_VISIBLE, VISIBILITY_PRIVATE); if (is_foreachable($tickets)) { foreach ($tickets as $ticket) { $ticket->copyToProject($to, array_var($milestones_map, $ticket->getMilestoneId()), array_var($categories_map, $ticket->getParentId()), array('Task', 'Attachment')); } // foreach } // if }
/** * Index action * ----------------- */ public function actionSuggestion($term) { // Find tickets that match that term $criteria = new CDbCriteria(); $criteria->addSearchCondition('t.title', $term); $criteria->limit = 10; $criteria->order = 't.title ASC'; $tickets = Tickets::model()->with(array('status', 'commentsCount'))->findAll($criteria); echo $this->renderPartial('_results', array('tickets' => $tickets), true); exit; }
/** * List of tickets * */ function index() { $this->addBreadcrumb(lang('List')); 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 $this->smarty->assign(array('categories' => Categories::findByModuleSection($this->active_project, TICKETS_MODULE, 'tickets'), 'tickets' => $tickets, 'pagination_url' => assemble_url('mobile_access_view_tickets', array('project_id' => $this->active_project->getId())), 'page_back_url' => assemble_url('mobile_access_view_project', array('project_id' => $this->active_project->getId())))); }
public function executeListing(sfWebRequest $request) { if (!isset($this->reports_id)) { $this->reports_id = false; } $q = Doctrine_Core::getTable('Tickets')->createQuery('t')->leftJoin('t.TicketsStatus ts')->leftJoin('t.TicketsTypes tt')->leftJoin('t.Departments td')->leftJoin('t.Projects p')->leftJoin('t.Users'); if ($request->hasParameter('projects_id')) { $q->addWhere('projects_id=?', $request->getParameter('projects_id')); if (Users::hasAccess('view_own', 'tickets', $this->getUser(), $request->getParameter('projects_id'))) { $q->addWhere("t.departments_id in (" . implode(',', Departments::getDepartmentIdByUserId($this->getUser()->getAttribute('id'))) . ") or t.users_id='" . $this->getUser()->getAttribute('id') . "'"); } } else { if (Users::hasAccess('view_own', 'projects', $this->getUser())) { $q->addWhere("find_in_set('" . $this->getUser()->getAttribute('id') . "',team) or p.created_by='" . $this->getUser()->getAttribute('id') . "'"); } if (Users::hasAccess('view_own', 'tickets', $this->getUser())) { $q->addWhere("t.departments_id in (" . implode(',', Departments::getDepartmentIdByUserId($this->getUser()->getAttribute('id'))) . ") or t.users_id='" . $this->getUser()->getAttribute('id') . "'"); } } if ($this->reports_id > 0) { $q = TicketsReports::addFiltersToQuery($q, $this->reports_id, $this->getUser()); } elseif ($request->hasParameter('search')) { $q = app::addSearchQuery($q, $request->getParameter('search'), 'TicketsComments', 't', $request->getParameter('search_by_extrafields')); $q = app::addListingOrder($q, 'tickets', $this->getUser()); } else { $q = Tickets::addFiltersToQuery($q, $this->getUser()->getAttribute('tickets_filter' . ((int) $request->getParameter('projects_id') > 0 ? $request->getParameter('projects_id') : ''))); $q = app::addListingOrder($q, 'tickets', $this->getUser(), (int) $request->getParameter('projects_id')); } if (sfConfig::get('app_rows_limit') > 0) { $this->pager = new sfDoctrinePager('Tickets', sfConfig::get('app_rows_limit')); $this->pager->setQuery($q); $this->pager->setPage($request->getParameter('page', 1)); $this->pager->init(); } $this->tickets_list = $q->fetchArray(); if (isset($this->is_dashboard)) { $this->url_params = 'redirect_to=dashboard'; $this->display_insert_button = true; } elseif ($this->reports_id > 0) { $this->url_params = 'redirect_to=ticketsReports' . $this->reports_id; $this->display_insert_button = true; } else { $this->url_params = 'redirect_to=ticketsList'; if ($request->hasParameter('projects_id')) { $this->url_params = 'projects_id=' . $request->getParameter('projects_id'); } $this->display_insert_button = true; } $this->tlId = rand(1111111, 9999999); }
function set_responsible_status() { $project_id = $this->request->getId('project_id'); if ($project_id) { $project = Projects::findById($project_id); } $ticket_id = $this->request->getId('ticket_id'); if ($ticket_id) { $ticket = Tickets::findByTicketId($project, $ticket_id); } $owner = Assignments::findOwnerByObject($ticket); $users = Assignments::findAssigneesByObject($ticket); $this->smarty->assign(array('project' => $project, 'ticket' => $ticket, 'users' => $users, 'owner' => $owner, 'ticket_url' => assemble_url('project_ticket', array('project_id' => $project_id, 'ticket_id' => $ticket_id)))); }
public function convertToTicket($thread_id, $msg_id, $user, $subject, $message, $department_id, $company_id) { $ticket = new Tickets(); $ticket->thread_id = $thread_id; $ticket->customer_id = $user->id; $ticket->priority = Tickets::PRIORITY_MEDIUM; $ticket->company_id = $company_id; $ticket->department_id = $department_id; $ticket->subject = $subject; $ticket->description = $message; $ticket->status = Tickets::TICKET_NEW; $ticket->requested_on = \Carbon\Carbon::now(); $ticket->save(); $ticket_attachment = new TicketAttachments(); $ticket_attachment->thread_id = $thread_id; $ticket_attachment->message_id = $msg_id; $ticket_attachment->has_attachment = Input::hasFile('attachment'); $ticket_attachment->attachment_path = Input::hasFile('attachment') ? Utils::fileUpload(Input::file('attachment'), 'attachments') : ''; $ticket_attachment->save(); $customer = User::find($ticket->customer_id); $ticketMailer = new \KodeInfo\Mailers\TicketsMailer(); $mailer_extra = Tickets::getCreatedFields(false, $ticket->id, $msg_id); $ticketMailer->created($customer->email, $customer->name, $mailer_extra); }
static function getUpdatedFields($is_fake = false, $ticket_id = 0, $msg_id = 0) { if (!$is_fake) { $ticket = Tickets::where('id', $ticket_id)->first(); $thread_message = ThreadMessages::where('id', $msg_id)->first(); $ticket_attachment = TicketAttachments::where('message_id', $msg_id)->first(); $customer = User::where('id', $ticket->customer_id)->first(); $operator = User::where('id', $ticket->operator_id)->first(); $company = Company::where('id', $ticket->company_id)->first(); $department = Department::where('id', $ticket->department_id)->first(); $receiver = Input::get('user_id') == $ticket->operator_id ? $customer : $operator; $mailer_extra = ['ticket_id' => $ticket->id, 'ticket_subject' => $ticket->subject, 'ticket_description' => $ticket->description, 'ticket_status' => $ticket->status, 'ticket_status_txt' => self::resolveStatus($ticket->status), 'ticket_priority' => $ticket->priority, 'ticket_priority_txt' => self::resolveStatus($ticket->priority), 'company_name' => $company->name, 'company_description' => $company->description, 'company_domain' => $company->domain, 'company_logo' => $company->logo, 'department_name' => $department->name, 'has_attachment' => $ticket_attachment->has_attachment, 'attachment_path' => $ticket_attachment->attachment_path, 'updated_message' => $thread_message->message, 'receiver_name' => $receiver->name, 'receiver_email' => $receiver->email]; } else { $mailer_extra = ['ticket_id' => 1, 'ticket_subject' => "How can i use contact us form", 'ticket_description' => "Hi , Sir how can i use contact us form", 'ticket_status' => 1, 'ticket_status_txt' => self::resolveStatus(1), 'ticket_priority' => 1, 'ticket_priority_txt' => self::resolveStatus(1), 'company_name' => "KODEINFO", 'company_description' => "We are a small and dedicated team of designers/developers. This is our web design and development focused blog.We focus on pushing the boundaries of standards based web technologies.", 'company_domain' => "http://www.kodeinfo.com", 'company_logo' => "http://kodeinfo.com/img/shortlogo.png", 'department_name' => "General Queries", 'has_attachment' => false, 'attachment_path' => "", 'updated_message' => "This is a updated message from customer/operator", 'receiver_name' => "Imran", 'receiver_email' => "*****@*****.**"]; } return $mailer_extra; }
public function previewPair($pair_id) { $paired = PairedTemplates::find($pair_id); $data = []; $template = $this->mailchimp->getTemplate($paired->template_id); $file_path = app_path() . "/views/emails/users/mailchimp_view.blade.php"; \File::put($file_path, $template['preview']); $send_mail = Input::get('send_mail') == "true" ? true : false; if ($paired->view == "emails.users.activate") { $user_mailer = new \KodeInfo\Mailers\UsersMailer(); $mailer_extra = User::getActivateFields(true); $data = $user_mailer->activate(Auth::user()->email, Auth::user()->name, $mailer_extra, true, $send_mail); } if ($paired->view == "emails.users.password_changed") { $user_mailer = new \KodeInfo\Mailers\UsersMailer(); $mailer_extra = User::getPasswordChangedFields(true); $data = $user_mailer->password_changed(Auth::user()->email, Auth::user()->name, $mailer_extra, true, $send_mail); } if ($paired->view == "emails.users.reset_password") { $user_mailer = new \KodeInfo\Mailers\UsersMailer(); $mailer_extra = User::getResetPasswordFields(true); $data = $user_mailer->reset_password(Auth::user()->email, Auth::user()->name, $mailer_extra, true, $send_mail); } if ($paired->view == "emails.users.welcome") { $user_mailer = new \KodeInfo\Mailers\UsersMailer(); $mailer_extra = User::getWelcomeFields(true); $data = $user_mailer->welcome(Auth::user()->email, Auth::user()->name, $mailer_extra, true, $send_mail); } if ($paired->view == "emails.tickets.ticket_created") { $user_mailer = new \KodeInfo\Mailers\TicketsMailer(); $mailer_extra = Tickets::getCreatedFields(true); $data = $user_mailer->created(Auth::user()->email, Auth::user()->name, $mailer_extra, true, $send_mail); } if ($paired->view == "emails.tickets.ticket_updated") { $user_mailer = new \KodeInfo\Mailers\TicketsMailer(); $mailer_extra = Tickets::getUpdatedFields(true); $data = $user_mailer->updated(Auth::user()->email, Auth::user()->name, $mailer_extra, true, $send_mail); } if ($send_mail) { Session::flash('success_msg', trans('msgs.mail_sent_success')); return Redirect::to('/templates/pair/all'); } else { return View::make('emails.users.mailchimp_view', $data); } }
public function executeIndex(sfWebRequest $request) { if ($request->getParameter('projects_id') > 0) { $this->forward404Unless($this->projects = Doctrine_Core::getTable('Projects')->createQuery()->addWhere('id=?', $request->getParameter('projects_id'))->fetchOne(), sprintf('Object projects does not exist (%s).', $request->getParameter('projects_id'))); $this->forward404Unless($this->tickets = Doctrine_Core::getTable('Tickets')->createQuery()->addWhere('id=?', $request->getParameter('tickets_id'))->addWhere('projects_id=?', $request->getParameter('projects_id'))->fetchOne(), sprintf('Object tasks does not exist (%s).', $request->getParameter('tickets_id'))); $this->checkProjectsAccess($this->projects); $this->checkTicketsAccess('view', $this->tickets, $this->projects); if (!$this->getUser()->hasAttribute('tickets_filter' . $request->getParameter('projects_id'))) { $this->getUser()->setAttribute('tickets_filter' . $request->getParameter('projects_id'), Tickets::getDefaultFilter($request, $this->getUser())); } } else { $this->forward404Unless($this->tickets = Doctrine_Core::getTable('Tickets')->find(array($request->getParameter('tickets_id'))), sprintf('Object tasks does not exist (%s).', $request->getParameter('id'))); $this->checkTicketsAccess('view', $this->tickets); } $this->tickets_comments = Doctrine_Core::getTable('TicketsComments')->createQuery('tc')->leftJoin('tc.Users u')->addWhere('tc.tickets_id=?', $request->getParameter('tickets_id'))->orderBy('tc.created_at desc')->fetchArray(); $this->more_actions = $this->getMoreActions($request); app::setPageTitle(t::__('Ticket') . ' | ' . ($this->tickets->getTicketsTypesId() > 0 ? $this->tickets->getTicketsTypes()->getName() . ': ' : '') . $this->tickets->getName(), $this->getResponse()); }
public function view($id = NULL) { // If no id is passed then show catalog $ticket = Tickets::factory('bannerdupes'); // Load the ticket view $view = new View('bannerdupes'); $view->action = 'view'; $view->good_id = $this->good_id; $view->bad_id = $this->bad_id; $view->comment = $this->comment; //TODO: Find a way to hook modules into the view // Load the discussion module $discussion = Ticket_Modules::factory('discussion'); $discussion->view('view', &$view); // Load the ticketphase module $phase = Ticket_Modules::factory('phaseset'); $phase->view('view', &$view); $view->render(); }
/** * Edit specific milestone * * @param void * @return null */ function edit() { $this->wireframe->print_button = false; if ($this->active_milestone->isNew()) { $this->httpError(HTTP_ERR_NOT_FOUND); } // if if (!$this->active_milestone->canEdit($this->logged_user)) { $this->httpError(HTTP_ERR_FORBIDDEN); } // if //$this->wireframe->addPageMessage(lang('<a href=":url">Click here</a> if you wish to reschedule this milestone', array('url' => $this->active_milestone->getRescheduleUrl())), 'info'); $this->wireframe->addPageMessage(lang('<a href=":url">Click here</a> if you wish to reschedule this project', array('url' => $this->active_milestone->getRescheduleUrl())), 'info'); $milestone_data = $this->request->post('milestone'); if (!is_array($milestone_data)) { $milestone_data = array('name' => $this->active_milestone->getName(), 'body' => $this->active_milestone->getBody(), 'start_on' => $this->active_milestone->getStartOn(), 'due_on' => $this->active_milestone->getDueOn(), 'priority' => $this->active_milestone->getPriority(), 'assignees' => Assignments::findAssignmentDataByObject($this->active_milestone), 'tags' => $this->active_milestone->getTags(), 'project_id' => $this->active_milestone->getProjectId(), 'visibility' => $this->active_milestone->getVisibility()); } // if //BOF:mod 20121116 $options = array(); $options[] = array('url' => 'javascript:convert_object_to_ticket(\'' . $this->active_milestone->getProjectId() . '\', \'' . $this->active_milestone->getId() . '\', \'' . $this->active_milestone->getType() . '\');', 'text' => 'Ticket'); $options[] = array('url' => 'javascript:convert_object_to_page(\'' . $this->active_milestone->getProjectId() . '\', \'' . $this->active_milestone->getId() . '\', \'' . $this->active_milestone->getType() . '\');', 'text' => 'Page'); $this->wireframe->addPageAction(lang('Convert To'), 'javascript://', $options); //EOF:mod 20121116 $this->smarty->assign('milestone_data', $milestone_data); //BOF: task 07 | AD $this->smarty->assign('is_edit_mode', '1'); //EOF: task 07 | AD if ($this->request->isSubmitted()) { if (!isset($milestone_data['assignees'])) { $milestone_data['assignees'] = array(array(), 0); } // if db_begin_work(); $old_name = $this->active_milestone->getName(); //BOF: task 07 | AD $old_project_id = $this->active_milestone->getProjectId(); //EOF: task 07 | AD $this->active_milestone->setAttributes($milestone_data); $save = $this->active_milestone->save(); if ($save && !is_error($save)) { db_commit(); //BOF: task 07 | AD //BOF: mod $this->active_milestone->register_departments(!empty($milestone_data['departments']) ? $milestone_data['departments'] : array(), implode(',', $milestone_data['departments'])); //EOF: mod //BOF:mod 20110614 $assignees_flag_data = $this->request->post('assignee'); $this->active_milestone->register_assignees_flag($assignees_flag_data); //EOF:mod 20110614 if ($old_project_id != $this->active_milestone->getProjectId()) { $link = mysql_connect(DB_HOST, DB_USER, DB_PASS); mysql_select_db(DB_NAME, $link); $query = "select id, integer_field_1 \n\t\t\t\t\t\t\tfrom healingcrystals_project_objects where \n\t\t\t\t\t\t\tmilestone_id ='" . $this->active_milestone->getId() . "' and \n\t\t\t\t\t\t\tproject_id='" . $old_project_id . "' and type='Ticket' and integer_field_1 is not null"; $result = mysql_query($query); $next_id = Tickets::findNextTicketIdByProject($this->active_milestone->getProjectId()); while ($ticket = mysql_fetch_assoc($result)) { mysql_query("update healingcrystals_project_objects \n\t\t\t\t\t\t\t\t\tset integer_field_1='" . $next_id . "' \n\t\t\t\t\t\t\t\t\twhere id='" . $ticket['id'] . "'"); $next_id++; } $query = "select updated_on, updated_by_id, updated_by_name, integer_field_1 from healingcrystals_project_objects where id='" . $this->active_milestone->getId() . "'"; $result = mysql_query($query, $link); $info = mysql_fetch_assoc($result); $query = "update healingcrystals_project_objects set \n\t\t\t\t\t\t\tproject_id ='" . $this->active_milestone->getProjectId() . "', \n\t\t\t\t\t\t\tupdated_on =" . (empty($info['updated_on']) ? "null" : "'" . $info['updated_on'] . "'") . ", \n\t\t\t\t\t\t\tupdated_by_id =" . (empty($info['updated_by_id']) ? "null" : "'" . $info['updated_by_id'] . "'") . ", \n\t\t\t\t\t\t\tupdated_by_name =" . (empty($info['updated_by_name']) ? "null" : "'" . mysql_real_escape_string($info['updated_by_name']) . "'") . ", \n\t\t\t\t\t\t\tupdated_by_email =" . (empty($info['updated_by_email']) ? "null" : "'" . $info['updated_by_email'] . "'") . " \n\t\t\t\t\t\t\twhere milestone_id ='" . $this->active_milestone->getId() . "' and project_id='" . $old_project_id . "'"; mysql_query($query); $query = "update healingcrystals_project_objects set category_id=null where id='" . $this->active_milestone->getId() . "'"; mysql_query($query); mysql_close($link); } //EOF: task 07 | AD if ($this->request->getFormat() == FORMAT_HTML) { //flash_success('Milestone ":name" has been updated', array('name' => $old_name), false, true); flash_success('Project ":name" has been updated', array('name' => $old_name), false, true); $this->redirectToUrl($this->active_milestone->getViewUrl()); } else { $this->serveData($this->active_milestone, 'milestone'); } // if } else { db_rollback(); if ($this->request->getFormat() == FORMAT_HTML) { $this->smarty->assign('errors', $save); } else { $this->serveData($save); } // if } // if } // if }
<?php include "../modelos/tickets.php"; include "../clases/Sesion.php"; include "../modelos/configuracion.php"; $configuracion = new Configuracion(); $sesion = new Sesion(); $modulo = new Tickets(); if ($sesion->sesion_iniciada() == false) { header('location:../login.php'); } $maximo_transferencia = $configuracion->maximo_transferencia; $pertenece = $sesion->getEstacion_pertenece(); if (!$pertenece) { die("<script>alert('Éste usuario no posee estación asociada!');</script>"); } $estacionInfo = $modulo->getEstacion($pertenece); $transferir = $estacionInfo[0]["transferir_id"]; $padre = $estacionInfo[0]["id_padre"]; $prioridad = $estacionInfo[0]["prioridad"]; $transf_estacion = ""; $estaciones = $modulo->getEstaciones($pertenece); foreach ($estaciones as $k => $v) { if ($transferir == $v["id"]) { $transf_estacion = $v["nombre"]; } } $estacionPertenece = $modulo->getEstacionPertenece($pertenece); ?> <!DOCTYPE html> <html>
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()); }
/** * Search issues * */ public function actionSearch() { $search = new SearchTickets(); $doSearch = false; $tickets = array(); $pages = array(); $count = null; // If we wanted to reset the form then just reset and redirect back if (isset($_POST['reset']) && $_POST['SearchTickets']) { if (isset(Yii::app()->session['searchTerms'])) { unset(Yii::app()->session['searchTerms']); } if (Yii::app()->session['didSearch']) { unset(Yii::app()->session['didSearch']); } $this->redirect(array('search')); } if (isset($_POST['SearchTickets'])) { $search->setAttributes($_POST['SearchTickets']); if ($search->validate()) { $doSearch = true; // Store it in the session so pagging will work Yii::app()->session['searchTerms'] = $_POST['SearchTickets']; Yii::app()->session['didSearch'] = true; } } elseif (isset(Yii::app()->session['didSearch']) && Yii::app()->session['didSearch'] && isset(Yii::app()->session['searchTerms']) && count(Yii::app()->session['searchTerms'])) { $search->setAttributes(Yii::app()->session['searchTerms']); if ($search->validate()) { $doSearch = true; // Store it in the session so pagging will work Yii::app()->session['searchTerms'] = Yii::app()->session['searchTerms']; Yii::app()->session['didSearch'] = true; } } // If we passed validation then search if ($doSearch) { // Initiate Criteria $criteria = new CDbCriteria(); // Build criteria if ($search->title) { $criteria->addSearchCondition('t.title', $search->title); } if ($search->keywords) { $criteria->addSearchCondition('t.keywords', $search->keywords); } // Start with the properties $props = array('status' => 'ticketstatus', 'type' => 'tickettype', 'category' => 'ticketcategory', 'priority' => 'priority', 'version' => 'ticketversion', 'fixedin' => 'fixedin'); // Loop the props and add conditions if they were submitted foreach ($props as $key => $value) { if ($search->{$key}) { $criteria->addInCondition('t.' . $value, $search->{$key}); } } // Add the reported by and assigned to condition if ($search->reportedby) { $criteria->addInCondition('t.reportedbyid', array($search->reportedby)); } if ($search->assignedtoid) { $criteria->addInCondition('t.assignedtoid', array($search->assignedtoid)); } // Initiate Pager $count = Tickets::model()->count($criteria); $pages = new CPagination($count); $pages->route = '/tickets/search'; $pages->pageSize = Yii::app()->params['ticketsPerPage']; $pages->applyLimit($criteria); // Load them $tickets = Tickets::model()->with(array('reporter', 'assigned', 'status', 'type', 'category', 'ticketpriority', 'version', 'fixed', 'ticketmilestone'))->findAll($criteria); } // Make sure we display the name and not id of the assigned to if ($search->assignedtoid && ($user = Users::model()->findByPk($search->assignedtoid))) { $search->assignedtoid = $user->username; } // Make sure we display the name and not id of the assigned to if ($search->reportedby && ($user = Users::model()->findByPk($search->reportedby))) { $search->reportedby = $user->username; } // Load the quick moderation form $moderation = new TicketsQuickModeration(); // Title $title = Yii::t('tickets', 'Search Tickets'); $this->pageTitle[] = $title; // Render $this->render('search', array('count' => $count, 'moderation' => $moderation, 'pages' => $pages, 'tickets' => $tickets, 'title' => $title, 'search' => $search, 'doSearch' => $doSearch)); }
public function all() { $customer_ids = []; if (\KodeInfo\Utilities\Utils::isDepartmentAdmin(Auth::user()->id)) { $department_admin = DepartmentAdmins::where('user_id', Auth::user()->id)->first(); $department = Department::where('id', $department_admin->department_id)->first(); $customer_ids = CompanyCustomers::where("company_id", $department->company_id)->lists('customer_id'); } elseif (\KodeInfo\Utilities\Utils::isOperator(Auth::user()->id)) { $department_admin = OperatorsDepartment::where('user_id', Auth::user()->id)->first(); $department = Department::where('id', $department_admin->department_id)->first(); $customer_ids = CompanyCustomers::where("company_id", $department->company_id)->lists('customer_id'); } else { $customer_ids = CompanyCustomers::lists('customer_id'); } if (sizeof($customer_ids) > 0) { $this->data["customers"] = User::whereIn("id", $customer_ids)->orderBy('id', 'desc')->get(); } else { $this->data["customers"] = []; } foreach ($this->data["customers"] as $customer) { $company_id = CompanyCustomers::where("customer_id", $customer->id)->pluck('company_id'); $customer->company = Company::find($company_id); $customer->all_ticket_count = Tickets::where('customer_id', $customer->id)->count(); $customer->pending_ticket_count = Tickets::where('customer_id', $customer->id)->where('status', Tickets::TICKET_PENDING)->count(); $customer->resolved_ticket_count = Tickets::where('customer_id', $customer->id)->where('status', Tickets::TICKET_RESOLVED)->count(); } return View::make('customers.all', $this->data); }
/** * Create a new widget for the dashboard */ public function widgetsAction() { $auth = Zend_Auth::getInstance(); $translator = Shineisp_Registry::getInstance()->Zend_Translate; $auth->setStorage(new Zend_Auth_Storage_Session('admin')); $id = $this->getRequest()->getParam('id', 'widget_' . rand()); $icon = $this->getRequest()->getParam('icon', 'fa fa-file'); $type = $this->getRequest()->getParam('type'); $title = $this->getRequest()->getParam('title'); $buttons = array(); if (!empty($id)) { $widget = new Shineisp_Commons_Widgets(); $widget->setId($id); // Ajax load of the widgets // Get only the new orders if ($type == "new_order_widget") { $records = Orders::Last(array(Statuses::id("tobepaid", "orders"))); $buttons = array('edit' => array('label' => $translator->translate('Edit'), 'cssicon' => 'glyphicon glyphicon-pencil', 'action' => "/admin/orders/edit/id/%d")); $widget->setBasepath('/admin/orders/')->setIdxfield($records['index'])->setButtons($buttons); // Get all the pending, processing, and paid orders to be complete } elseif ($type == 'processing_order_widget') { $statuses = array(Statuses::id("processing", "orders"), Statuses::id("pending", "orders"), Statuses::id("paid", "orders")); $buttons = array('edit' => array('label' => $translator->translate('Edit'), 'cssicon' => 'glyphicon glyphicon-pencil', 'action' => "/admin/orders/edit/id/%d")); $records = Orders::Last($statuses); $widget->setBasepath('/admin/orders/')->setIdxfield($records['index'])->setButtons($buttons); // Get all the services / order items next to the expiration date from -10 days to 30 days } elseif ($type == 'recurring_services_widget') { $records = OrdersItems::getServices(); $buttons = array('edit' => array('label' => $translator->translate('Edit'), 'cssicon' => 'glyphicon glyphicon-pencil', 'action' => "/admin/ordersitems/edit/id/%d")); $widget->setBasepath('/admin/ordersitems/')->setIdxfield($records['index'])->setButtons($buttons); // Get the last 5 tickets opened by the customers } elseif ($type == 'last_tickets_widget') { $records = Tickets::Last(null, 5); $buttons = array('edit' => array('label' => $translator->translate('Edit'), 'cssicon' => 'glyphicon glyphicon-pencil', 'action' => "/admin/tickets/edit/id/%d")); $widget->setBasepath('/admin/tickets/')->setIdxfield($records['index'])->setButtons($buttons); // get the last domain tasks to be executed } elseif ($type == 'last_domain_tasks_widget') { $records = DomainsTasks::Last(); $buttons = array('edit' => array('label' => $translator->translate('Edit'), 'cssicon' => 'glyphicon glyphicon-pencil', 'action' => "/admin/domainstasks/edit/id/%d")); $widget->setBasepath('/admin/domainstasks/')->setIdxfield($records['index'])->setButtons($buttons); // get the last ISP panel tasks to be executed } elseif ($type == 'last_panel_tasks_widget') { $records = PanelsActions::Last(); $buttons = array('edit' => array('label' => $translator->translate('Edit'), 'cssicon' => 'glyphicon glyphicon-pencil', 'action' => "/admin/panelsactions/edit/id/%d")); $widget->setBasepath('/admin/panelsactions/')->setIdxfield($records['index'])->setButtons($buttons); // get the domains next the expiration date } elseif ($type == 'expiring_domain_widget') { // Create the header table columns $records['fields'] = array('expiringdate' => array('label' => $translator->translate('Expiry Date')), 'domains' => array('label' => $translator->translate('Domain')), 'days' => array('label' => $translator->translate('Days left'))); $buttons = array('edit' => array('label' => $translator->translate('Edit'), 'cssicon' => 'glyphicon glyphicon-pencil', 'action' => "/admin/domains/edit/id/%d")); $records['data'] = Domains::getExpiringDomains(null, 107, -1, 5); $records['index'] = "domain_id"; $widget->setBasepath('/admin/domains/')->setIdxfield($records['index'])->setButtons($buttons); // get the messages/notes posted by the customers within the orders } elseif ($type == 'order_messages_widget') { $records = Messages::Last('orders'); $buttons = array('edit' => array('label' => $translator->translate('Edit'), 'cssicon' => 'glyphicon glyphicon-pencil', 'action' => "/admin/orders/edit/id/%d")); $widget->setBasepath('/admin/orders/')->setIdxfield($records['index'])->setButtons($buttons); // get the messages/notes posted by the customers within the domain } elseif ($type == 'domain_messages_widget') { $records = Messages::Last('domains'); $buttons = array('edit' => array('label' => $translator->translate('Edit'), 'cssicon' => 'glyphicon glyphicon-pencil', 'action' => "/admin/domains/edit/id/%d")); $widget->setBasepath('/admin/domains/')->setIdxfield($records['index'])->setButtons($buttons); // get the list of your best customers } elseif ($type == 'customers_parade_widget') { $buttons = array('edit' => array('label' => $translator->translate('Show'), 'cssicon' => 'glyphicon glyphicon-pencil', 'action' => "/admin/customers/edit/id/%d")); $records = Customers::Hitparade(); $widget->setBasepath('/admin/customers/')->setIdxfield($records['index'])->setButtons($buttons); // get the customer status summary } elseif ($type == 'customer_summary_widget') { $records = Customers::summary(); // get the tickets summary } elseif ($type == 'ticket_summary_widget') { $records = Tickets::summary(); // get the domains summary } elseif ($type == 'summary_domains_widget') { $records = Domains::summary(); // get the product reviews stats } elseif ($type == 'product_reviews_widget') { $records = Reviews::summary(); // get the bestseller product stats } elseif ($type == 'bestseller_widget') { $buttons = array('edit' => array('label' => $translator->translate('Show'), 'cssicon' => 'glyphicon glyphicon-pencil', 'action' => "/admin/products/edit/id/%d")); $records = Products::summary(); $widget->setBasepath('/admin/products/')->setIdxfield($records['index'])->setButtons($buttons); // get the last ISP notes } elseif ($type == 'notes_widget') { $user = $auth->getIdentity(); $records = Notes::summary($user['user_id']); $widget->setBasepath('/admin/notes/'); } else { die('No widget type has been selected: ' . $type); } // Records Builtin columns. The code get the field names as header column name if (!empty($records['fields'])) { foreach ($records['fields'] as $field => $column) { $column['alias'] = !empty($column['alias']) ? $column['alias'] : $field; $widget->setColumn($field, $column); } } if (!empty($records['data'])) { $widget->setIcon($icon)->setLabel($title)->setRecords($records['data']); die($widget->create()); } } die; }
/** * Add AC object links to commit messages * * @param string * @return string **/ private function analyzeCommitMessage($commit_message) { $pattern = '/(ticket|milestone|discussion|task)[s]*[\\s]+[#]*(\\d+)/i'; if (preg_match_all($pattern, $commit_message, $matches)) { $i = 0; $search = array(); $replace = array(); $matches_unique = array_unique($matches['0']); foreach ($matches_unique as $key => $match) { $match_data = preg_split('/[\\s,]+/', $match, null, PREG_SPLIT_NO_EMPTY); $object_class_name = $match_data['0']; $module_name = Inflector::pluralize($object_class_name); $object_id = trim($match_data['1'], '#'); $search[$i] = $match; if (class_exists($module_name) && class_exists($object_class_name)) { $object = null; switch (strtolower($module_name)) { case 'tickets': $object = Tickets::findByTicketId($this->active_project, $object_id); break; case 'discussions': $object = Discussions::findById($object_id); break; case 'milestones': $object = Milestones::findById($object_id); break; case 'tasks': $object = Tasks::findById($object_id); break; } // switch if (instance_of($object, $object_class_name)) { $replace[$i] = '<a href="' . $object->getViewUrl() . '">' . $match_data['0'] . ' ' . $match_data['1'] . '</a>'; } else { $replace[$i] = '<a href="#" class="project_object_missing" title="' . lang('Project object does not exist in this project') . '">' . $match_data['0'] . ' ' . $match_data['1'] . '</a>'; } // if instance_of $i++; } // if module loaded } // foreach return str_ireplace($search, $replace, htmlspecialchars($commit_message)); // linkify } // if preg_match return $commit_message; }
function move() { $new_parent_id = $this->request->post('new_parent_id'); $new_parent_type = $this->request->post('new_parent_type'); $new_parent_url = ''; $move_mode = false; if (!empty($new_parent_id) && !empty($new_parent_type)) { $move_mode = true; $parent_obj = $sql_part = null; switch ($new_parent_type) { case 'milestone': $parent_obj = new MileStone($new_parent_id); break; case 'ticket': $parent_obj = new Ticket($new_parent_id); break; case 'page': $parent_obj = new Page($new_parent_id); break; } if ($parent_obj) { $body = $this->active_task->getBody(); $doc = new DOMDocument(); if ($doc->loadHTML($body)) { $anc_tags = $doc->getElementsByTagName('a'); $new_parent_url = ''; foreach ($anc_tags as $anc) { if ($anc->nodeValue == 'View Task in Full') { $href = $anc->getAttribute('href'); $fragment = substr($href, strpos($href, '#')); $anc->setAttribute('href', $parent_obj->getViewUrl() . $fragment); break; } } if (!empty($fragment)) { $body_tag = $doc->getElementsByTagName('body'); $body = $doc->saveXML($body_tag->item(0)->firstChild); $comment_id = str_replace('#comment', '', $fragment); } } $link = mysql_connect(DB_HOST, DB_USER, DB_PASS); mysql_select_db(DB_NAME); $query = "update \n\t\t\t\t\t\t\thealingcrystals_project_objects \n\t\t\t\t\t\t set \n\t\t\t\t\t\t\tproject_id='" . $parent_obj->getProjectId() . "', \n\t\t\t\t\t\t\tmilestone_id='" . $parent_obj->getMilestoneId() . "', \n\t\t\t\t\t\t\tparent_id='" . $parent_obj->getId() . "', \n\t\t\t\t\t\t\tparent_type='" . $parent_obj->getType() . "', \n\t\t\t\t\t\t\tbody = '" . mysql_real_escape_string($body) . "' \n\t\t\t\t\t\t where\tid='" . $this->active_task->getId() . "'"; mysql_query($query, $link); if (!empty($comment_id)) { $comment_query = "update \n\t\t\t\t\t\t\thealingcrystals_project_objects \n\t\t\t\t\t\t set \n\t\t\t\t\t\t\tproject_id='" . $parent_obj->getProjectId() . "', \n\t\t\t\t\t\t\tmilestone_id='" . $parent_obj->getMilestoneId() . "', \n\t\t\t\t\t\t\tparent_id='" . $parent_obj->getId() . "', \n\t\t\t\t\t\t\tparent_type='" . $parent_obj->getType() . "', \n\t\t\t\t\t\t\tposition=null\n\t\t\t\t\t\t where\tid='" . $comment_id . "'"; mysql_query($comment_query, $link); } mysql_close($link); $new_parent_url = $parent_obj->getViewUrl() . '#task' . $this->active_task->getId(); $cache_id = TABLE_PREFIX . 'project_objects_id_' . $this->active_task->getId(); $cache_obj = cache_get($cache_id); if ($cache_obj) { cache_remove($cache_id); } } } else { $listing = array(); switch ($this->active_task_parent->getType()) { case 'Milestone': //$listing = Milestones::findByProject($this->active_project, $this->logged_user); $listing = Milestones::findActiveByProject_custom($this->active_project); break; case 'Ticket': $listing = Tickets::findOpenByProjectByNameSort($this->active_project, STATE_VISIBLE, $this->logged_user->getVisibility()); break; case 'Page': $categories = Categories::findByModuleSection($this->active_project, 'pages', 'pages'); $listing = Pages::findByCategories($categories, STATE_VISIBLE, $this->logged_user->getVisibility()); /*foreach($categories as $category){ $listing = array_merge($listing, Pages::findByCategory($category, STATE_VISIBLE, $this->logged_user->getVisibility())); }*/ break; } $this->smarty->assign(array('teams' => Projects::findNamesByUser($this->logged_user), 'listing' => $listing, 'task_parent_id' => $this->active_task_parent->getId())); } $this->smarty->assign('new_parent_url', $new_parent_url); $this->smarty->assign('move_mode', $move_mode); }
<label for="titre">Titre</label> <input type="text" name="titre" id="titre" value="<?php echo $ticket->getTitre()?>" placeholder="Entrez le titre" class="form-control" <?php if(!$editable): ?>disabled<?php endif; ?>> <label for="description">Description</label> <textarea name="description" id="description" placeholder="Entrez la description" class="form-control ckeditor" <?php if(!$editable): ?>disabled<?php endif; ?>><?php echo $ticket->getDescription()?></textarea> </div> <div class="form-group col-md-6"> <label>Statut</label> <div class="form-control col-md-6" disabled><?php echo $ticket->getStatut()?></div> </div> <div class="form-group col-md-12"> <label>Emetteur</label> <div class="form-control" disabled><?php echo $ticket->getUser()?></div> <label for="dateCreation">Date de création</label> <input type="text" name="dateCreation" id="dateCreation" value="<?php echo $ticket->getDateCreation()?>" disabled class="form-control"> <input type="hidden" name="idStatut" value="<?php echo $ticket->getStatut()->getId()?>"> <input type="hidden" name="idUser" value="<?php echo $ticket->getUser()->getId()?>"> </div> <div class="form-group col-md-6"> <input type="submit" value="Valider" class="btn btn-default"> <a class="btn btn-default" href="<?php echo $config["siteUrl"]?>tickets">Annuler</a> </div> <div class="form-group col-md-6"> <div class="btn-group pull-right" role="group"> <?php error_reporting(0);echo Tickets::getButtonGroup($ticket);error_reporting(-1);?> </div> </div> </div> </form> </div> </div>
/** * Find project objects in commit message, make them links and * save the relations to database * * @param string $commit_message * @param string $commit_author * @param integer $revision * @param Repository $repository * @param Project $project * @return string */ function analyze_message($commit_message, $commit_author, $revision, $repository, $project) { if (define('PURIFY_HTML') && PURIFY_HTML) { $commit_message = purify_html($commit_message); // Clean! } // if $pattern = '/((complete[d]*)[\\s]+)?(ticket|milestone|discussion|task)[s]*[\\s]+[#]*\\d+/i'; if (preg_match_all($pattern, $commit_message, $matches)) { $i = 0; $search = array(); $replace = array(); $matches_unique = array_unique($matches['0']); foreach ($matches_unique as $key => $match) { $match_data = preg_split('/[\\s,]+/', $match, null, PREG_SPLIT_NO_EMPTY); // check if the object got completed by this commit $object_completed = false; if (strpos(strtolower($match_data['0']), 'complete') !== false) { $object_completed = true; unset($match_data['0']); $match_data = array_values($match_data); } // if $object_class_name = $match_data['0']; $module_name = Inflector::pluralize($object_class_name); $object_id = trim($match_data['1'], '#'); $search[$i] = $match; if (class_exists($module_name) && class_exists($object_class_name)) { $object = null; switch (strtolower($module_name)) { case 'tickets': $object = Tickets::findByTicketId($project, $object_id); break; case 'discussions': $object = Discussions::findById($object_id); break; case 'milestones': $object = Milestones::findById($object_id); break; case 'tasks': $object = Tasks::findById($object_id); break; } // switch if (instance_of($object, $object_class_name)) { $link_already_created = CommitProjectObjects::count("object_id = '" . $object->getId() . "' AND revision = '{$revision}'") > 0; if (!$link_already_created) { $comit_project_object = new CommitProjectObject(); $comit_project_object->setProjectId($object->getProjectId()); $comit_project_object->setObjectId($object->getId()); $comit_project_object->setObjectType(ucfirst($object_class_name)); $comit_project_object->setRepositoryId($repository->getId()); $comit_project_object->setRevision($revision); db_begin_work(); $save = $comit_project_object->save(); if ($save && !is_error($save)) { db_commit(); } else { db_rollback(); } // if save } // if $replace[$i] = ($object_completed ? 'Completed ' : '') . '<a href="' . $object->getViewUrl() . '">' . $match_data['0'] . ' ' . $match_data['1'] . '</a>'; // set the object as completed if ($object_completed && !instance_of($object, 'Discussion')) { $completed_by = $repository->getMappedUser($commit_author); $object->complete($completed_by); } // if } else { $replace[$i] = ($object_completed ? 'Completed ' : '') . '<a href="#" class="project_object_missing" title="' . lang('Project object does not exist in this project') . '">' . $match_data['0'] . ' ' . $match_data['1'] . '</a>'; } // if instance_of $i++; } // if module loaded } // foreach return str_ireplace($search, $replace, htmlspecialchars($commit_message)); // linkify } // if preg_match return $commit_message; }
$tickets = new Tickets($core, $db, $user); $tickets->view($_GET['view']); } elseif (isset($_GET['delete'])) { require_once "includes/Tickets.php"; $tickets = new Tickets($core, $db, $user); $tickets->delete($_GET['delete']); $tickets->getAll(); } elseif (isset($_GET['edit'])) { require_once "includes/Tickets.php"; $tickets = new Tickets($core, $db, $user); $tickets->edit($_GET['edit']); // $tickets->getAll(); } elseif (isset($_GET['newTicket'])) { require_once "includes/Tickets.php"; $tickets = new Tickets($core, $db, $user); $tickets->newTicket(); } else { require_once "includes/Tickets.php"; $tickets = new Tickets($core, $db, $user); $tickets->getAll(); } ?> </md-content> <?php $core->checkLoad(); ?> </div> </body> </html>
/** * Save the ticket note * * @param integer $ticketid * @param array $params */ public static function saveIt($tid, $date, $note, $category = null, $status = null, $isAdmin = false, $noteid = null, $sendemail = true) { $translator = Shineisp_Registry::getInstance()->Zend_Translate; if (!is_numeric($tid)) { return false; } if (is_numeric($noteid)) { $ticketnote = self::find($noteid); } else { $ticketnote = new TicketsNotes(); } // Get and Check the ticket note $ticket = Tickets::find($tid); // update the ticket if (!empty($status) && is_numeric($status)) { $ticket->status_id = $status; } $ticket->date_updated = date('Y-m-d H:i:s'); if (is_numeric($category)) { $ticket->category_id = $category; } $ticket->save(); if ($ticket && !empty($note)) { $ticketnote->date_post = !empty($date) ? $date : $date('Y-m-d H:i:s'); $ticketnote->note = $note; $ticketnote->admin = $isAdmin; $ticketnote->ticket_id = $tid; $ticketnote->parent_id = 0; // Save the note if ($ticketnote->trySave()) { $noteid = is_numeric($noteid) ? $noteid : $ticketnote->getIncremented(); // Save the upload file $attachment = self::UploadDocument($tid, $ticket->get('customer_id')); if ($sendemail) { Tickets::send($noteid, false, $attachment); } return $ticketnote; } } return false; }