/** * Add bread crumb * * Parameters: * * - url - crumb URL, optional * - not_lang - use raw value, optional * * @param array $params * @param string $content * @param Smarty $smarty * @param boolean $repeat * @return string */ function smarty_block_add_bread_crumb($params, $content, &$smarty, &$repeat) { static $instance; $url = array_var($params, 'url'); $not_lang = (bool) array_var($params, 'not_lang'); $text = $not_lang ? $content : lang($content); if (trim($text) == '') { return new InvalidParamError('text', $text, "Bread crumb text is required in add_bread_crumb helper"); } // if if ($instance === null) { $instance =& Wireframe::instance(); } // if $instance->addBreadCrumb($text, $url); return ''; }
/** * Constructor * * @param Request $request * @return ApplicationController */ function __construct($request) { parent::__construct($request); // Set detault layout for application pages $this->setLayout(array('module' => SYSTEM_MODULE, 'layout' => 'wireframe')); // Get Smarty instance... We need it $this->smarty =& Smarty::instance(); // Load and init owner company $this->owner_company = get_owner_company(); if (instance_of($this->owner_company, 'Company')) { cache_set('owner_company', $this->owner_company); } else { $this->httpError(HTTP_ERR_NOT_FOUND, 'Owner company is not defined'); } // if $this->application =& application(); $this->authentication =& Authentication::instance(); $this->logged_user =& $this->authentication->provider->getUser(); $this->wireframe =& Wireframe::instance(); $this->wireframe->page_company = $this->owner_company; $this->theme_name = instance_of($this->logged_user, 'User') ? UserConfigOptions::getValue('theme', $this->logged_user) : ConfigOptions::getValue('theme'); $this->smarty->assign(array('root_url' => ROOT_URL, 'assets_url' => ASSETS_URL)); // Maintenance mode if (ConfigOptions::getValue('maintenance_enabled')) { if (instance_of($this->logged_user, 'User') && $this->logged_user->isAdministrator()) { $this->wireframe->addPageMessage(lang('System is in maintenance mode and can be used by administrators only. <a href=":url">Click here</a> to turn off maintenance mode', array('url' => assemble_url('admin_settings_maintenance'))), 'warning'); } else { $additional_error_info = ConfigOptions::getValue('maintenance_message'); if ($additional_error_info) { $additional_error_info .= "\n\n"; } // if $additional_error_info .= lang('When system is in maintenance mode, administrators can log in and access the system') . ": " . assemble_url('login'); $this->smarty->assign('additional_error_info', $additional_error_info); if ($this->restrict_access_in_maintenance_mode) { $this->httpError(503); } // if } // if } // if // Check permissions if ($this->login_required && !instance_of($this->logged_user, 'User')) { // If async don't redirect to loging, just server proper HTTP code if ($this->request->isAsyncCall()) { $this->httpError(HTTP_ERR_UNAUTHORIZED, null, true, true); // Not async? Redirect to login with extracted route data... } else { $params = array(); if ($request->matched_route != 'login') { $params['re_route'] = $request->matched_route; foreach ($this->request->url_params as $k => $v) { if ($k == 'module' || $k == 'controller' || $k == 'action') { continue; } // if $params["re_{$k}"] = $v; } // foreach } // if $this->redirectTo($this->login_route, $params); } // if } // if if (instance_of($this->logged_user, 'User') && !$this->logged_user->getSystemPermission('system_access')) { $this->authentication->provider->logUserOut(); $this->httpError(HTTP_ERR_FORBIDDEN); } // if $loaded_modules = $this->application->getModules(); $assets_query_string = 'v=' . $this->application->version . '&modules='; foreach ($loaded_modules as $loaded_module) { $assets_query_string .= $loaded_module->getName() . ','; } // foreach $this->smarty->assign(array('api_status' => API_STATUS, 'application' => $this->application, 'owner_company' => $this->owner_company, 'authentication' => $this->authentication, 'logged_user' => $this->logged_user, 'request' => $this->request, 'theme_name' => $this->theme_name, 'request_time' => $this->request_time, 'loaded_modules' => $this->application->getModules(), 'captcha_url' => ROOT_URL . '/captcha.php?id=' . md5(time()), 'assets_query_string' => $assets_query_string, 'js_disabled_url' => assemble_url('js_disabled'))); $this->smarty->assign_by_ref('wireframe', $this->wireframe); js_assign(array('homepage_url' => ROOT_URL, 'assets_url' => ASSETS_URL, 'indicator_url' => get_image_url('indicator.gif'), 'big_indicator_url' => get_image_url('indicator_big.gif'), 'ok_indicator_url' => get_image_url('ok_indicator.gif'), 'warning_indicator_url' => get_image_url('warning_indicator.gif'), 'error_indicator_url' => get_image_url('error_indicator.gif'), 'pending_indicator_url' => get_image_url('pending_indicator.gif'), 'url_base' => URL_BASE, 'keep_alive_interval' => KEEP_ALIVE_INTERVAL, 'refresh_session_url' => assemble_url('refresh_session'), 'jump_to_project_url' => assemble_url('jump_to_project_widget'), 'quick_add_url' => assemble_url('quick_add'), 'path_info_through_query_string' => PATH_INFO_THROUGH_QUERY_STRING, 'image_picker_url' => assemble_url('image_picker'), 'copyright_removed' => LICENSE_COPYRIGHT_REMOVED, 'custom_tabs_manager' => assemble_url('custom_tabs_manager'), 'add_milestone_url' => assemble_url('project_milestones_add', array('project_id' => '--PROJECT_ID--')), 'add_checklist_url' => assemble_url('project_checklists_add', array('project_id' => '--PROJECT_ID--')), 'add_discussion_url' => assemble_url('project_discussions_add', array('project_id' => '--PROJECT_ID--')), 'add_file_url' => assemble_url('project_files_upload', array('project_id' => '--PROJECT_ID--')), 'add_page_url' => assemble_url('project_pages_add', array('project_id' => '--PROJECT_ID--')), 'add_ticket_url' => assemble_url('project_tickets_add', array('project_id' => '--PROJECT_ID--')), 'add_timerecord_url' => assemble_url('project_time_add', array('project_id' => '--PROJECT_ID--')), 'attachment_rename_url' => assemble_url('attachment_rename', array('project_id' => '--PROJECT_ID--', 'attachment_id' => '--ATTACHMENT_ID--')), 'attachment_copy_to_url' => assemble_url('attachment_copy_to', array('project_id' => '--PROJECT_ID--', 'attachment_id' => '--ATTACHMENT_ID--')), 'attachment_move_to_url' => assemble_url('attachment_move_to', array('project_id' => '--PROJECT_ID--', 'attachment_id' => '--ATTACHMENT_ID--')), 'image_uploader_url' => assemble_url('image_uploader'), 'render_comments_url' => assemble_url('render_comments'), 'move_task_url' => assemble_url('project_task_move', array('project_id' => '--PROJECT_ID--', 'task_id' => '--TASK_ID--')), 'get_collection_url' => assemble_url('collection'), 'quick_task_reminder_url' => assemble_url('project_task_quickreminder', array('project_id' => '--PROJECT_ID--', 'task_id' => '--TASK_ID--')), 'convert_to_ticket_url' => assemble_url('project_object_convert_to_ticket', array('project_id' => '--PROJECT_ID--', 'object_id' => '--OBJECT_ID--')), 'convert_to_milestone_url' => assemble_url('project_object_convert_to_milestone', array('project_id' => '--PROJECT_ID--', 'object_id' => '--OBJECT_ID--')), 'convert_to_page_url' => assemble_url('project_object_convert_to_page', array('project_id' => '--PROJECT_ID--', 'object_id' => '--OBJECT_ID--')), 'snooze_task_url' => assemble_url('project_task_snooze', array('project_id' => '--PROJECT_ID--', 'task_id' => '--TASK_ID--')))); if ($this->logged_user) { $link = mysql_connect(DB_HOST, DB_USER, DB_PASS); mysql_select_db(DB_NAME); if (!empty($_SESSION['pg_ttl'])) { mysql_query("update healingcrystals_user_visited_pages set title='" . mysql_real_escape_string($_SESSION['pg_ttl']) . "' where user_id='" . $this->logged_user->getId() . "' and access_time='" . date('Y-m-d H:i:s', $_SESSION['temp_time']) . "'"); } $current_url = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://') . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; $pos = strpos($_SERVER['QUERY_STRING'], '%2F'); if ($pos !== false) { $max_pages_count_per_user = 50; //require_once SMARTY_PATH . '/plugins/function.page_title.php'; //$current_page_title = smarty_function_page_title(array('default' => 'Projects')); //$current_page_title = PageConstruction::getPageTitle(); $_SESSION['temp_time'] = time(); mysql_query("insert into healingcrystals_user_visited_pages (user_id, page_url, title, access_time) values ('" . $this->logged_user->getId() . "', '" . $current_url . "', '', '" . date('Y-m-d H:i:s', $_SESSION['temp_time']) . "')"); //mysql_query("insert into healingcrystals_user_visited_pages (user_id, page_url, title, access_time) values ('" . $this->logged_user->getId() . "', '" . $current_url . "', '', now())"); $query = "select count(*) as count from healingcrystals_user_visited_pages where user_id='" . $this->logged_user->getId() . "'"; $result = mysql_query($query); $info = mysql_fetch_assoc($result); $current_count = $info['count']; if ($current_count > $max_pages_count_per_user) { $querries = array(); $query = "select * from healingcrystals_user_visited_pages where user_id='" . $this->logged_user->getId() . "' order by access_time limit 0, " . ($current_count - $max_pages_count_per_user); $result = mysql_query($query); while ($info = mysql_fetch_assoc($result)) { $querries[] = "delete from healingcrystals_user_visited_pages where user_id='" . $this->logged_user->getId() . "' and page_url='" . $info['page_url'] . "' and access_time='" . $info['access_time'] . "'"; } } foreach ($querries as $query) { mysql_query($query); } } $_SESSION['pg_ttl'] = ''; mysql_close($link); } }
/** * Set page properties with following object * * Parameters: * * - object - Application object instance * * @param array $params * @param Smarty $smarty * @return null */ function smarty_function_page_object($params, &$smarty) { static $private_roles = false; $object = array_var($params, 'object'); if (!instance_of($object, 'ApplicationObject')) { return new InvalidParamError('object', $object, '$object is expected to be an instance of ApplicationObject class', true); } // if require_once SMARTY_DIR . '/plugins/modifier.datetime.php'; $wireframe =& Wireframe::instance(); $logged_user =& get_logged_user(); $construction =& PageConstruction::instance(); if ($construction->page_title == '') { $construction->setPageTitle($object->getName()); } // if if (instance_of($object, 'ProjectObject') && $wireframe->details == '') { $in = $object->getParent(); $created_on = $object->getCreatedOn(); $created_by = $object->getCreatedBy(); if (instance_of($created_by, 'User') && instance_of($in, 'ApplicationObject') && instance_of($created_on, 'DateValue')) { //BOF:mod 20120913 /* //EOF:mod 20120913 $wireframe->details = lang('By <a href=":by_url">:by_name</a> in <a href=":in_url">:in_name</a> on <span>:on</span>', array( //BOF:mod 20120913 */ $wireframe->details = lang('Created on <span>:on</span>', array('by_url' => $created_by->getViewUrl(), 'by_name' => $created_by->getDisplayName(), 'in_url' => $in->getViewUrl(), 'in_name' => $in->getName(), 'on' => smarty_modifier_datetime($created_on))); } elseif (instance_of($created_by, 'User') && instance_of($created_on, 'DateValue')) { //BOF:mod 20120913 /* //EOF:mod 20120913 $wireframe->details = lang('By <a href=":by_url">:by_name</a> on <span>:on</span>', array( //BOF:mod 20120913 */ $wireframe->details = lang('Created on <span>:on</span>', array('by_url' => $created_by->getViewUrl(), 'by_name' => $created_by->getDisplayName(), 'on' => smarty_modifier_datetime($created_on))); } elseif (instance_of($created_by, 'User')) { //BOF:mod 20120913 /* //EOF:mod 20120913 $wireframe->details = lang('By <a href=":by_url">:by_name</a>', array( //BOF:mod 20120913 */ $wireframe->details = lang('Created on <span>:on</span>', array('by_url' => $created_by->getViewUrl(), 'by_name' => $created_by->getDisplayName(), 'on' => smarty_modifier_datetime($created_on))); } elseif (instance_of($created_by, 'AnonymousUser') && instance_of($created_on, 'DateValue')) { //BOF:mod 20120913 /* //EOF:mod 20120913 $wireframe->details = lang('By <a href=":by_url">:by_name</a> on <span>:on</span>', array( //BOF:mod 20120913 */ $wireframe->details = lang('Created on <span>:on</span>', array('by_url' => 'mailto:' . $created_by->getEmail(), 'by_name' => $created_by->getName(), 'on' => smarty_modifier_datetime($created_on))); } elseif (instance_of($created_by, 'AnonymousUser')) { //BOF:mod 20120913 /* //EOF:mod 20120913 $wireframe->details = lang('By <a href=":by_url">:by_name</a>', array( //BOF:mod 20120913 */ $wireframe->details = lang('Created on <span>:on</span>', array('by_url' => 'mailto:' . $created_by->getEmail(), 'by_name' => $created_by->getName(), 'on' => smarty_modifier_datetime($created_on))); } // if } // if $smarty->assign('page_object', $object); // Need to do a case sensitive + case insensitive search to have PHP4 covered $class_methods = get_class_methods($object); if (in_array('getOptions', $class_methods) || in_array('getoptions', $class_methods)) { $options = $object->getOptions($logged_user); if (instance_of($options, 'NamedList') && $options->count()) { $wireframe->addPageAction(lang('Options'), '#', $options->data, array('id' => 'project_object_options'), 1000); } // if if (instance_of($object, 'ProjectObject')) { if ($object->getState() > STATE_DELETED) { if ($object->getVisibility() <= VISIBILITY_PRIVATE) { //Ticket ID #362 - modify Private button (SA) 14March2012 BOF $users_table = TABLE_PREFIX . 'users'; $assignments_table = TABLE_PREFIX . 'assignments'; $subscription_table = TABLE_PREFIX . 'subscriptions'; // $rows = db_execute_all("SELECT $assignments_table.is_owner AS is_assignment_owner, $users_table.id AS user_id, $users_table.company_id, $users_table.first_name, $users_table.last_name, $users_table.email FROM $users_table, $assignments_table WHERE $users_table.id = $assignments_table.user_id AND $assignments_table.object_id = ? ORDER BY $assignments_table.is_owner DESC", $object->getId()); $rows = db_execute_all("SELECT {$assignments_table}.is_owner AS is_assignment_owner, {$users_table}.id AS user_id, {$users_table}.company_id, {$users_table}.first_name, {$users_table}.last_name, {$users_table}.email FROM {$users_table}, {$assignments_table} WHERE {$users_table}.id = {$assignments_table}.user_id AND {$assignments_table}.object_id = " . $object->getId() . " UNION SELECT '0' AS is_assignment_owner, {$users_table}.id AS user_id, {$users_table}.company_id, {$users_table}.first_name, {$users_table}.last_name, {$users_table}.email FROM {$users_table}, {$subscription_table} WHERE {$users_table}.id = {$subscription_table}.user_id AND {$subscription_table}.parent_id = " . $object->getId()); if (is_foreachable($rows)) { $owner = null; $other_assignees = array(); $users_dropdown_for_tickets = ''; foreach ($rows as $row) { if (empty($row['first_name']) && empty($row['last_name'])) { $user_link = clean($row['email']); } else { $user_link = clean($row['first_name'] . ' ' . $row['last_name']); } // if if ($row['is_assignment_owner']) { $owner = $user_link; } else { $other_assignees[] = $user_link; } if ($owner) { if (instance_of($object, 'Ticket')) { if (count($other_assignees) > 0) { $users = $owner; if (!empty($users)) { $users .= ', '; } $users .= implode(', ', $other_assignees); } else { $users = $owner; } // if } else { if (count($other_assignees) > 0) { $users = $owner . ' ' . lang('is responsible', null, true, $language) . '. ' . lang('Other assignees', null, true, $language) . ': ' . implode(', ', $other_assignees) . '.'; } else { $users = $owner . ' ' . lang('is responsible', null, true, $language) . '.'; } // if } } elseif (count($other_assignees) > 0) { $users = implode(', ', $other_assignees); } } } $wireframe->addPageMessage(lang('<b>Private</b> - This Ticket has been marked as "Private" and is Visible by these Users: :users', array('users' => $users)), PAGE_MESSAGE_PRIVATE); //Ticket ID #362 - modify Private button (SA) 14March2012 EOF } // if } else { $wireframe->addPageMessage(lang('<b>Trashed</b> - this :type is located in trash.', array('type' => $object->getVerboseType(true))), PAGE_MESSAGE_TRASHED); } // if } // if } // if return ''; }
/** * Prepare portal project section breadcrumb when this object is accessed * directly and not through module controller * * @param Portal $portal * @param Wireframe $wireframe * @return null */ function preparePortalProjectSectionBreadcrumb($portal, &$wireframe) { $wireframe->addBreadCrumb(lang('Tickets'), assemble_url('portal_tickets', array('portal_name' => $portal->getSlug()))); }
/** * Set page details for current page * * @param array $params * @param string $content * @param Smarty $smarty * @param boolean $repeat * @return string */ function smarty_block_details($params, $content, &$smarty, &$repeat) { $wireframe =& Wireframe::instance(); $wireframe->details = $content; return ''; }
/** * Prepare project section breadcrumb when this object is accessed directly * and not through module controller * * @param Wireframe $wireframe * @return null */ function prepareProjectSectionBreadcrumb(&$wireframe) { $wireframe->addBreadCrumb(lang('Milestones'), assemble_url('project_milestones', array('project_id' => $this->getProjectId()))); }