Пример #1
0
 /**
  * Processes the template and assigns common variables automatically.
  * 
  * @access	private
  */
 function processTemplate()
 {
     global $HTTP_SERVER_VARS;
     // determine the correct CSS file to use
     if (ereg('MSIE ([0-9].[0-9]{1,2})', @$HTTP_SERVER_VARS["HTTP_USER_AGENT"], $log_version)) {
         $user_agent = 'ie';
     } else {
         $user_agent = 'other';
     }
     $this->assign("user_agent", $user_agent);
     // create the list of projects
     $usr_id = Auth::getUserID();
     if ($usr_id != '') {
         $prj_id = Auth::getCurrentProject();
         if (!empty($prj_id)) {
             $role_id = User::getRoleByUser($usr_id, $prj_id);
             $this->assign("current_project", $prj_id);
             $this->assign("current_project_name", Auth::getCurrentProjectName());
             $has_customer_integration = Customer::hasCustomerIntegration($prj_id);
             $this->assign("has_customer_integration", $has_customer_integration);
             if ($has_customer_integration) {
                 $this->assign("customer_backend_name", Customer::getBackendImplementationName($prj_id));
             }
             if ($role_id == User::getRoleID('administrator') || $role_id == User::getRoleID('manager')) {
                 $this->assign("show_admin_link", true);
             }
             if ($role_id > 0) {
                 $this->assign("current_role", (int) $role_id);
                 $this->assign("current_role_name", User::getRole($role_id));
             }
         }
         $info = User::getNameEmail($usr_id);
         $this->assign("active_projects", Project::getAssocList($usr_id));
         $this->assign("current_full_name", $info["usr_full_name"]);
         $this->assign("current_email", $info["usr_email"]);
         $this->assign("current_user_id", $usr_id);
         $this->assign("is_current_user_clocked_in", User::isClockedIn($usr_id));
         $this->assign("roles", User::getAssocRoleIDs());
     }
     $this->assign("app_setup", Setup::load());
     $this->assign("app_setup_path", APP_SETUP_PATH);
     $this->assign("app_setup_file", APP_SETUP_FILE);
     $this->assign("application_version", APP_VERSION);
     $this->assign("application_title", APP_NAME);
     $this->assign("app_base_url", APP_BASE_URL);
     $this->assign("rel_url", APP_RELATIVE_URL);
     $this->assign("lang", APP_CURRENT_LANG);
     $this->assign("SID", SID);
     // now for the browser detection stuff
     Net_UserAgent_Detect::detect();
     $this->assign("browser", Net_UserAgent_Detect::_getStaticProperty('browser'));
     $this->assign("os", Net_UserAgent_Detect::_getStaticProperty('os'));
     // this is only used by the textarea resize script
     $js_script_name = str_replace('/', '_', str_replace('.php', '', $HTTP_SERVER_VARS['PHP_SELF']));
     $this->assign("js_script_name", $js_script_name);
     $this->assign("total_queries", $GLOBALS['TOTAL_QUERIES']);
     $this->assign(array("cell_color" => APP_CELL_COLOR, "light_color" => APP_LIGHT_COLOR, "middle_color" => APP_MIDDLE_COLOR, "dark_color" => APP_DARK_COLOR, "cycle" => APP_CYCLE_COLORS, "internal_color" => APP_INTERNAL_COLOR));
 }
Пример #2
0
 /**
  * Processes the template and assign common variables automatically.
  * @return $this
  */
 private function processTemplate()
 {
     $core = array('rel_url' => APP_RELATIVE_URL, 'base_url' => APP_BASE_URL, 'app_title' => APP_NAME, 'app_version' => APP_VERSION, 'app_setup' => Setup::load(), 'messages' => Misc::getMessages(), 'roles' => User::getAssocRoleIDs(), 'auth_backend' => APP_AUTH_BACKEND, 'current_url' => $_SERVER['PHP_SELF']);
     // If VCS version is present "Eventum 2.3.3-148-g78b3368", link ref to github
     $vcsVersion = self::getVcsVersion();
     if ($vcsVersion) {
         $link = "https://github.com/eventum/eventum/commit/{$vcsVersion}";
         $core['application_version_link'] = $link;
         // append VCS version if not yet there
         if (!preg_match('/-g[0-9a-f]+$/', APP_VERSION)) {
             $core['app_version'] = "v{$core['app_version']}-g{$vcsVersion}";
         }
     }
     $usr_id = Auth::getUserID();
     if ($usr_id) {
         $core['user'] = User::getDetails($usr_id);
         $prj_id = Auth::getCurrentProject();
         $setup = Setup::load();
         if (!empty($prj_id)) {
             $role_id = User::getRoleByUser($usr_id, $prj_id);
             $has_crm = CRM::hasCustomerIntegration($prj_id);
             $core = $core + array('project_id' => $prj_id, 'project_name' => Auth::getCurrentProjectName(), 'has_crm' => $has_crm, 'current_role' => $role_id, 'current_role_name' => User::getRole($role_id), 'feature_access' => Access::getFeatureAccessArray($usr_id));
             if ($has_crm) {
                 $crm = CRM::getInstance($prj_id);
                 $core['crm_template_path'] = $crm->getTemplatePath();
                 if ($role_id == User::getRoleID('Customer')) {
                     try {
                         $contact = $crm->getContact($core['user']['usr_customer_contact_id']);
                         $core['allowed_customers'] = $contact->getCustomers();
                         $core['current_customer'] = $crm->getCustomer(Auth::getCurrentCustomerID(false));
                     } catch (CRMException $e) {
                     }
                 }
             }
         }
         $info = User::getDetails($usr_id);
         $raw_projects = Project::getAssocList(Auth::getUserID(), false, true);
         $active_projects = array();
         foreach ($raw_projects as $prj_id => $prj_info) {
             if ($prj_info['status'] == 'archived') {
                 $prj_info['prj_title'] .= ' ' . ev_gettext('(archived)');
             }
             $active_projects[$prj_id] = $prj_info['prj_title'];
         }
         $core = $core + array('active_projects' => $active_projects, 'current_full_name' => $info['usr_full_name'], 'current_email' => $info['usr_email'], 'current_user_id' => $usr_id, 'current_user_datetime' => Date_Helper::getISO8601date('now', '', true), 'is_current_user_clocked_in' => User::isCLockedIn($usr_id), 'is_anon_user' => Auth::isAnonUser(), 'is_current_user_partner' => !empty($info['usr_par_code']), 'roles' => User::getAssocRoleIDs(), 'current_user_prefs' => Prefs::get(Auth::getUserID()));
         $this->assign('current_full_name', $core['user']['usr_full_name']);
         $this->assign('current_email', $core['user']['usr_email']);
         $this->assign('current_user_id', $usr_id);
         $this->assign('handle_clock_in', $setup['handle_clock_in'] == 'enabled');
         $this->assign('is_current_user_clocked_in', User::isClockedIn($usr_id));
         $this->assign('roles', User::getAssocRoleIDs());
     }
     $this->assign('core', $core);
     return $this;
 }