/** * Render select Mailbox type control * * @param array $params * @param Smarty $smarty * @return string */ function smarty_function_select_incoming_mail_object_type($params, &$smarty) { $mailbox_object_types = array(); if (module_loaded('discussions')) { $mailbox_object_types[] = INCOMING_MAIL_OBJECT_TYPE_DISCUSSION; } // if if (module_loaded('tickets')) { $mailbox_object_types[] = INCOMING_MAIL_OBJECT_TYPE_TICKET; } // if if (!array_var($params, 'skip_comment', true)) { $mailbox_object_types[] = INCOMING_MAIL_OBJECT_TYPE_COMMENT; } // if $value = null; if (isset($params['value'])) { $value = $params['value']; unset($params['value']); } // if $options = array(); foreach ($mailbox_object_types as $mailbox_object_type) { $option_attributes = $mailbox_object_type == $value ? array('selected' => true) : null; $options[] = option_tag(Inflector::humanize($mailbox_object_type), $mailbox_object_type, $option_attributes); } // foreach return select_box($options, $params); }
/** * Show a object properties * * Parameters: * * - object - Object of which properties are shown * - show_completed_status - To display object completed status * - show_milestone - To display object milestone * - show_tags - To display object tags * - show_body - To display object description * - show_category - To display object category * - show_file_details - To display file details, if object is file * - show_name - To display object name * - show_priority - To display object priority * - show_milestone_day_info - To display milestone due on info * - show_assignees - To show assignees * - only_show_body - To display only body * * @param array $params * @param Smarty $smarty * @return string */ function smarty_function_mobile_access_object_properties($params, &$smarty) { $object = array_var($params, 'object'); if (!instance_of($object, 'ProjectObject')) { return new InvalidParamError('object', $object, '$object is expected to be an instance of ProjectObject class', true); } // if $smarty->assign(array('_mobile_access_object_properties_object' => $object, '_mobile_access_object_properties_show_completed_status' => (bool) array_var($params, 'show_completed_status', false), '_mobile_access_object_properties_show_milestone' => (bool) array_var($params, 'show_milestone', false), '_mobile_access_object_properties_show_tags' => (bool) array_var($params, 'show_tags', false), '_mobile_access_object_properties_show_body' => (bool) array_var($params, 'show_body', false), '_mobile_access_object_properties_show_category' => (bool) array_var($params, 'show_category', false), '_mobile_access_object_properties_show_file_details' => (bool) array_var($params, 'show_file_details', false), '_mobile_access_object_properties_show_name' => (bool) array_var($params, 'show_name', false), '_mobile_access_object_properties_show_assignees' => (bool) array_var($params, 'show_assignees', false), '_mobile_access_object_properties_show_priority' => (bool) array_var($params, 'show_priority', false), '_mobile_access_object_properties_show_milestone_day_info' => (bool) array_var($params, 'show_milestone_day_info', false), '_mobile_access_object_properties_show_total_time' => (bool) array_var($params, 'show_total_time', false), '_mobile_access_object_properties_only_show_body' => (bool) array_var($params, 'only_show_body', false))); if (module_loaded(TIMETRACKING_MODULE)) { $smarty->assign(array('_mobile_access_object_properties_total_time' => float_format(TimeRecords::sumObjectTime($object), 2))); } return $smarty->fetch(get_template_path('_object_properties', null, MOBILE_ACCESS_MODULE)); }
/** * Construct auth controller * * @param Request $request * @return AuthController */ function __construct($request) { parent::__construct($request); // if user is using mobile device, redirect it to mobile access login page if (module_loaded('mobile_access') && is_mobile_device(USER_AGENT)) { if ($request->matched_route != 'logout') { $this->redirectTo('mobile_access_login'); } else { $this->redirectTo('mobile_access_logout'); } // if } // if $this->setLayout('application'); }
/** * Index page action * */ function index() { if (!module_loaded('tickets')) { $this->redirectTo('public_submit_unavailable'); } // if $ticket_data = $this->request->post('ticket'); $this->smarty->assign(array('captcha_url' => ROOT_URL . '/captcha.php?id=' . md5(time()), "ticket_data" => $ticket_data)); if ($this->request->isSubmitted()) { $errors = new ValidationErrors(); if ($this->captcha_enabled) { //$captcha_value = array_var($_SESSION, CAPTCHA_SESSION_ID); if (!Captcha::Validate($ticket_data['captcha'])) { $errors->addError(lang('Code you entered is not valid'), 'captcha'); $this->smarty->assign('errors', $errors); } // if } // if if (!$errors->hasErrors()) { $submitter = new AnonymousUser($ticket_data['created_by_name'], $ticket_data['created_by_email']); db_begin_work(); $ticket = new Ticket(); attach_from_files($ticket, $submitter); $ticket->setAttributes($ticket_data); $ticket->setProjectId($this->active_project->getId()); $ticket->setVisibility(VISIBILITY_NORMAL); $ticket->setState(STATE_VISIBLE); $ticket->setCreatedBy($submitter); $save = $ticket->save(); if (!$save || is_error($save)) { unset($ticket_data['captcha']); db_rollback(); $this->smarty->assign(array('ticket_data' => $ticket_data, 'errors' => $save)); } else { Subscriptions::subscribeUsers(array($this->active_project->getLeaderId()), $ticket); db_commit(); $ticket->ready(); $this->redirectTo('public_submit_success'); } // if } // if } // if }
/** * Render object time widget * * @param array $params * @param Smarty $smarty * @return string */ function smarty_function_object_time($params, &$smarty) { if (!module_loaded('timetracking')) { return ''; } // if $object = array_var($params, 'object'); if (!instance_of($object, 'ProjectObject')) { return new InvalidParamError('$object', $object, '$object is expected to be a valid instance of ProjectObject class'); } // if $show_time = ''; $additional_class = ''; if (array_var($params, 'show_time', true)) { $object_time = TimeRecords::sumObjectTime($object); if ($object->can_have_tasks) { $tasks_time = TimeRecords::sumTasksTime($object); } else { $tasks_time = 0; } // if $additional_class = 'with_text'; $total_time = $object_time + $tasks_time; if ($object_time == 0 && $tasks_time == 0) { $show_time = '<span class="time_widget_text">' . lang('No time tracked') . '</span> '; } elseif ($tasks_time == 0) { $show_time = '<span class="time_widget_text">' . lang(':total hours logged', array('total' => float_format($total_time, 2))) . '</span> '; } else { $show_time = '<span class="time_widget_text">' . lang(':total hours logged - :object_time for the ticket and :tasks_time for tasks', array('type' => $object->getVerboseType(true), 'total' => float_format($total_time, 2), 'object_time' => float_format($object_time, 2), 'tasks_time' => float_format($tasks_time, 2))) . '</span> '; } // if } // if $wrapper_id = 'object_time_widget_' . $object->getId(); $image_url = $object->getHasTime() ? get_image_url('clock-small.gif') : get_image_url('gray-clock-small.gif'); return '<span id="' . $wrapper_id . '" class="time_popup_widget ' . $additional_class . '">' . $show_time . '<a href="' . $object->getTimeUrl() . '" title="' . lang('Time') . '"><img src="' . $image_url . '" alt="" /></a></span><script type="text/javascript">App.TimePopup.init("' . $wrapper_id . '")</script>'; }
/** * Edit translation file in chosen language * * @param void * @return void */ function edit_translation_file() { if ($this->active_language->isNew()) { $this->httpError(HTTP_ERR_NOT_FOUND); } // if $translation_id = $this->request->get('filename'); if (!$translation_id) { $this->httpError(HTTP_ERR_NOT_FOUND); } // if $dictionary_filename = Languages::getDictionaryPath($translation_id); if (!is_file($dictionary_filename)) { flash_error('Dictionary does not exists'); $this->redirectToUrl($this->active_language->getViewUrl()); } // if $dictionary = Languages::getDictionary($translation_id); $translation_file = Languages::getTranslationPath($this->active_language, $translation_id); if (!is_file($translation_file)) { flash_error('Translation file does not exists. You need to create it first.'); $this->redirectToUrl($this->active_language->getViewUrl()); } // if $translation_data = Languages::getTranslation($this->active_language, $translation_id); $prepared_form_data = $this->request->post('form_data'); if (!is_array($prepared_form_data)) { $prepared_form_data = array(); foreach ($dictionary as $dictionary_id => $dictionary_value) { $prepared_form_data[$dictionary_id] = array("dictionary_value" => $dictionary_value, "translated_value" => array_var($translation_data, $dictionary_value)); } // foreach $this->smarty->assign(array("prepared_form_data" => $prepared_form_data)); } // if $this->smarty->assign(array("translation_file" => $translation_id, "form_url" => $this->active_language->getEditTranslationFileUrl($translation_id))); if ($this->request->isSubmitted()) { if (is_foreachable($prepared_form_data)) { $new_prepared_data = array(); $translation_data = array(); foreach ($prepared_form_data as $prepared_form_data_key => $prepared_form_data_value) { $translation_data[array_var($dictionary, $prepared_form_data_key)] = $prepared_form_data_value; $new_prepared_data[$prepared_form_data_key] = array("dictionary_value" => array_var($dictionary, $prepared_form_data_key), "translated_value" => $prepared_form_data_value); } // foreach } // if file_put_contents($translation_file, '<?php return ' . var_export($translation_data, true) . ' ?>'); cache_remove_by_pattern('lang_cache_for_*'); if (module_loaded('incoming_mail')) { // set config option for translation if (array_key_exists(EMAIL_SPLITTER, $translation_data)) { $config_option = ConfigOptions::getValue('email_splitter_translations'); $config_option[$this->active_language->getLocale()] = $translation_data[EMAIL_SPLITTER]; ConfigOptions::setValue('email_splitter_translations', $config_option); } // if } // if $this->smarty->assign(array("prepared_form_data" => $new_prepared_data)); } // if }
/** * Constructor * * @param Request $request * @return MobileAccessController extends ApplicationController */ function __construct($request) { parent::__construct($request); $this->disableCategories(); $project_id = $this->request->get('project_id'); if ($project_id) { $this->active_project = Projects::findById($project_id); } // if if (!instance_of($this->active_project, 'Project')) { $this->httpError(HTTP_ERR_NOT_FOUND); } // if if (!$this->logged_user->isProjectMember($this->active_project)) { $this->httpError(HTTP_ERR_FORBIDDEN); } // if if ($this->active_project->getType() == PROJECT_TYPE_SYSTEM) { $this->httpError(HTTP_ERR_NOT_FOUND); } // if $this->project_sections = array(); $this->project_sections[] = array("name" => "overview", "full_name" => lang("Overview"), "url" => assemble_url('mobile_access_view_project', array('project_id' => $this->active_project->getId()))); if (module_loaded('discussions') && $this->logged_user->getProjectPermission('discussion', $this->active_project)) { $this->project_sections[] = array("name" => "discussions", "full_name" => lang("Discussions"), "url" => assemble_url('mobile_access_view_discussions', array('project_id' => $this->active_project->getId()))); } if (module_loaded('milestones') && $this->logged_user->getProjectPermission('milestone', $this->active_project)) { $this->project_sections[] = array("name" => "milestones", "full_name" => lang("Milestones"), "url" => assemble_url('mobile_access_view_milestones', array('project_id' => $this->active_project->getId()))); } if (module_loaded('files') && $this->logged_user->getProjectPermission('file', $this->active_project)) { $this->project_sections[] = array("name" => "files", "full_name" => lang("Files"), "url" => assemble_url('mobile_access_view_files', array('project_id' => $this->active_project->getId()))); } if (module_loaded('checklists') && $this->logged_user->getProjectPermission('checklist', $this->active_project)) { $this->project_sections[] = array("name" => "checklists", "full_name" => lang("Checklists"), "url" => assemble_url('mobile_access_view_checklists', array('project_id' => $this->active_project->getId()))); } if (module_loaded('pages') && $this->logged_user->getProjectPermission('page', $this->active_project)) { $this->project_sections[] = array("name" => "pages", "full_name" => lang("Pages"), "url" => assemble_url('mobile_access_view_pages', array('project_id' => $this->active_project->getId()))); } if (module_loaded('tickets') && $this->logged_user->getProjectPermission('ticket', $this->active_project)) { $this->project_sections[] = array("name" => "tickets", "full_name" => lang("Tickets"), "url" => assemble_url('mobile_access_view_tickets', array('project_id' => $this->active_project->getId()))); } if (module_loaded('timetracking') && $this->logged_user->getProjectPermission('timerecord', $this->active_project)) { $this->project_sections[] = array("name" => "timetracking", "full_name" => lang("Time"), "url" => assemble_url('mobile_access_view_timerecords', array('project_id' => $this->active_project->getId()))); } if (module_loaded('source') && $this->logged_user->getProjectPermission('repository', $this->active_project)) { $this->project_sections[] = array("name" => "source", "full_name" => lang("Repositories"), "url" => assemble_url('mobile_access_view_repositories', array('project_id' => $this->active_project->getId()))); } //if($this->active_project->isLoaded() && $this->enable_categories) { $this->addBreadcrumb(lang('Project'), assemble_url('mobile_access_view_project', array("project_id" => $this->active_project->getId()))); $this->smarty->assign(array("page_title" => $this->active_project->getName(), "active_project" => $this->active_project, "project_sections" => $this->project_sections, "page_breadcrumbs" => $this->breadcrumbs, "active_project_section" => 'overview', "active_category" => $this->active_category)); }
/** * Export tickets * * @param void * @return null */ function export() { $object_visibility = array_var($_GET, 'visibility', VISIBILITY_NORMAL); $exportable_modules = explode(',', array_var($_GET, 'modules', null)); if (!is_foreachable($exportable_modules)) { $exportable_modules = null; } // if require_once PROJECT_EXPORTER_MODULE_PATH . '/models/ProjectExporterOutputBuilder.class.php'; $output_builder = new ProjectExporterOutputBuilder($this->active_project, $this->smarty, $this->active_module, $exportable_modules); if (!$output_builder->createOutputFolder()) { $this->serveData($output_builder->execution_log, 'execution_log', null, FORMAT_JSON); } // if $output_builder->createAttachmentsFolder(); $module_categories = Categories::findByModuleSection($this->active_project, $this->active_module, $this->active_module); $module_objects = Tickets::findByProject($this->active_project, null, STATE_VISIBLE, $object_visibility); $output_builder->setFileTemplate($this->active_module, $this->controller_name, 'index'); $output_builder->smarty->assign('categories', $module_categories); $output_builder->smarty->assign('objects', $module_objects); $output_builder->outputToFile('index'); // export tickets by categories if (is_foreachable($module_categories)) { foreach ($module_categories as $module_category) { if (instance_of($module_category, 'Category')) { $output_builder->smarty->assign(array('current_category' => $module_category, 'objects' => Tickets::findByProject($this->active_project, $module_category, STATE_VISIBLE, $object_visibility))); $output_builder->outputToFile('category_' . $module_category->getId()); } // if } // foreach } // if // export tickets if (is_foreachable($module_objects)) { $output_builder->setFileTemplate($this->active_module, $this->controller_name, 'object'); foreach ($module_objects as $module_object) { if (instance_of($module_object, 'Ticket')) { $output_builder->outputAttachments($module_object->getAttachments()); $comments = $module_object->getComments($object_visibility); $output_builder->outputObjectsAttachments($comments); if (module_loaded('timetracking')) { $timerecords = TimeRecords::findByParent($module_object, null, STATE_VISIBLE, $object_visibility); $total_time = TimeRecords::calculateTime($timerecords); } else { $timerecords = null; $total_time = 0; } // if $output_builder->smarty->assign(array('timerecords' => $timerecords, 'total_time' => $total_time, 'object' => $module_object, 'comments' => $comments)); $output_builder->outputToFile('ticket_' . $module_object->getId()); } // if } // foreach } // if $this->serveData($output_builder->execution_log, 'execution_log', null, FORMAT_JSON); }