/** * Perform the main actions of the page. * @global array Get the home page from the global configuration */ protected function action() { parent::action(); if ($this->user->logged_in()) { $this->setRedirect('home'); return; } $access = I2CE::getUserAccess(); $has_email = $access instanceof I2CE_UserAccess_Mechanism && $access->canChangePassword() && I2CE_User::hasDetail('email'); $this->template->setBodyId("loginPage"); $this->template->setDisplayDataImmediate('has_email', $has_email); if (!$this->isPost() || !$has_email) { return; } if ($this->post('submit') == "Reset") { if (I2CE_Validate::checkString($this->post('username')) && I2CE_User::userExists($this->post('username'), true)) { $user = new I2CE_User($this->post('username'), true, false, true); $email = $user->email; $valid_email = I2CE_Validate::checkEmail($email); $pass = trim(I2CE_User::generatePassword()); if ($user->getRole() != 'guest' && $valid_email && $pass && $user->setPassword($pass)) { if ($this->mailPassword($email, $this->post('username'), $pass)) { $this->template->addTextNode("error_message", "Your password has been reset and mailed to you."); } else { $this->template->addTextNode("error_message", "Your password has been reset, but could not mailed to you. Please contact your system administrator"); } } else { $this->template->addTextNode("error_message", "Your password could not be reset. Please contact your system administrator to change your password."); } } else { $this->template->addTextNode("error_message", "Your username could not be found in the database. Please contact your System Administrator."); } } elseif ($this->post('submit') == "View") { $usernames = I2CE_User::findUsersByInfo(false, array('email' => $this->post('email'))); if (is_array($usernames) && count($usernames) == 1) { reset($usernames); $this->template->addText('<p id="error_message">Your username is: <b>' . current($usernames) . '</b><br />Enter it below to reset your password or return to the login page to login.</p>', 'p'); } else { $this->template->addTextNode("error_message", "That email address was not found in the system. Please contact your System Administrator."); } } else { $this->template->addTextNode("error_message", "Please click one of the submit buttons or only enter one text field."); } }
protected function getXMLMetaData($headers) { $user = new I2CE_User(); $sender_role = $user->getRole(); $sender_username = $user->username(); $sender_name = $user->firstname . ' ' . $user->lastname; $sender_email = $user->email; $data_elements = ''; $report = addslashes($this->view); $name = $report; $this->config->setIfIsSet($name, 'display_name'); $desc = $name . ' report'; $this->config->setIfIsSet($desc, 'description'); $when = date("c"); array_shift($headers); //get rid of the # header foreach ($headers as $key => $header) { $data_elements .= " <elemDesc id='{$key}'>\n <name>{$header}</name>\n </elemDesc>\n"; } return "<ihrisReport id='{$report}'> \n <reportDetails>\n <name>{$name}</name>\n <description>{$desc}</description>\n <whenGenerated>{$when}</whenGenerated>\n <sender>\n <user>{$sender_username}</user>\n <name>{$sender_name}</name>\n <role>{$sender_role}</role>\n <email>{$sender_email}</email> \n </sender>\n <dataElements>\n{$data_elements} </dataElements>\n </reportDetails>\n <reportData>\n"; return $out; }
protected function get_XLS_2004_XML_MetaData($headers) { $user = new I2CE_User(); $sender_role = $user->getRole(); $sender_username = $user->username(); $sender_name = $user->firstname . ' ' . $user->lastname; $sender_email = $user->email; $report = addslashes($this->view); $name = $report; $this->config->setIfIsSet($name, 'display_name'); $desc = ''; $this->config->setIfIsSet($desc, 'description'); $desc = $report . ':' . $desc; $when = date("c"); //array_shift($headers); //get rid of the # header $col_desc = str_repeat('<Column ss:AutoFitWidth="1"/>', count($headers)); $header_title = ' <Row ss:Height="14">'; foreach ($headers as $key => $header) { $header_title .= "<Cell ss:StyleID='s17'><Data ss:Type='String'>{$header}</Data></Cell>"; } $header_title .= ' </Row>' . "\n"; //$sender_role //$sender_email $user_title = "{$sender_username} {$sender_name}"; $meta_title = '<Row ss:Height="14">'; ///do something with $sener_name, $sender_email, $sender_role, $sender_username, $when, $name, $desc $meta_title .= "<Cell ss:StyleID='s17'><Data ss:Type='String'>{$sender_name}</Data></Cell>"; $meta_title .= "<Cell ss:StyleID='s17'><Data ss:Type='String'>{$sender_email}</Data></Cell>"; $meta_title .= "<Cell ss:StyleID='s17'><Data ss:Type='String'>{$sender_username}</Data></Cell>"; $meta_title .= "<Cell ss:StyleID='s17'><Data ss:Type='String'>{$sender_role}</Data></Cell>"; $meta_title .= "<Cell ss:StyleID='s17'><Data ss:Type='String'>{$sender_when}</Data></Cell>"; $meta_title .= "</Row>\n"; $meta_title = '<Row ss:Height="14">'; ///do something with $sener_name, $sender_email, $sender_role, $sender_username, $when, $name, $desc $meta_title .= "<Cell ss:StyleID='s22'><Data ss:Type='String'>{$name}</Data></Cell>"; $meta_title .= "<Cell ss:StyleID='s22'><Data ss:Type='String'>{$desc}</Data></Cell>"; $meta_title .= "<Cell ss:StyleID='s22'><Data ss:Type='String'>{$when}</Data></Cell>"; $meta_title .= "</Row>\n"; $preamble = "<?xml version='1.0'?>\n<Workbook xmlns='urn:schemas-microsoft-com:office:spreadsheet'\n xmlns:o='urn:schemas-microsoft-com:office:office'\n xmlns:x='urn:schemas-microsoft-com:office:excel'\n xmlns:ss='urn:schemas-microsoft-com:office:spreadsheet'\n xmlns:html='http://www.w3.org/TR/REC-html40'>\n <DocumentProperties xmlns='urn:schemas-microsoft-com:office:office'>\n <Author>{$user_title}</Author>\n <LastAuthor>{$user_title}</LastAuthor>\n <Created>{$when}</Created>\n <LastSaved>2015-02-05T17:30:02Z</LastSaved>\n <Company>I2CE + iHRIS</Company>\n <Version>14.0</Version>\n </DocumentProperties>\n <OfficeDocumentSettings xmlns='urn:schemas-microsoft-com:office:office'>\n <AllowPNG/>\n </OfficeDocumentSettings>\n <ExcelWorkbook xmlns='urn:schemas-microsoft-com:office:excel'>\n <WindowHeight>9740</WindowHeight>\n <WindowWidth>23840</WindowWidth>\n <WindowTopX>480</WindowTopX>\n <WindowTopY>40</WindowTopY>\n <TabRatio>600</TabRatio>\n <CreateBackup/>\n <ProtectStructure>False</ProtectStructure>\n <ProtectWindows>False</ProtectWindows>\n </ExcelWorkbook>\n <Styles>\n <Style ss:ID='Default' ss:Name='Normal'>\n <Alignment ss:Vertical='Bottom'/>\n <Borders/>\n <Font ss:FontName='MS Sans Serif'/>\n <Interior/>\n <NumberFormat/>\n <Protection/>\n </Style>\n <Style ss:ID='s17'>\n <Alignment ss:Horizontal='Center' ss:Vertical='Center'/>\n <Borders>\n <Border ss:Position='Bottom' ss:LineStyle='Continuous' ss:Weight='1'/>\n <Border ss:Position='Left' ss:LineStyle='Continuous' ss:Weight='1'/>\n <Border ss:Position='Right' ss:LineStyle='Continuous' ss:Weight='1'/>\n <Border ss:Position='Top' ss:LineStyle='Continuous' ss:Weight='1'/>\n </Borders>\n <Font ss:FontName='Calibri' ss:Size='11' ss:Color='#000000' ss:Bold='1'/>\n <Interior ss:Color='#C0C0C0' ss:Pattern='Solid'/>\n <Protection/>\n </Style>\n <Style ss:ID='s19'>\n <Alignment ss:Vertical='Center' ss:WrapText='1'/>\n <Borders>\n <Border ss:Position='Bottom' ss:LineStyle='Continuous' ss:Weight='1'\n ss:Color='#C0C0C0'/>\n <Border ss:Position='Left' ss:LineStyle='Continuous' ss:Weight='1'\n ss:Color='#C0C0C0'/>\n <Border ss:Position='Right' ss:LineStyle='Continuous' ss:Weight='1'\n ss:Color='#C0C0C0'/>\n <Border ss:Position='Top' ss:LineStyle='Continuous' ss:Weight='1'\n ss:Color='#C0C0C0'/>\n </Borders>\n <Font ss:FontName='Calibri' ss:Size='11' ss:Color='#000000'/>\n <Interior/>\n <Protection/>\n </Style>\n <Style ss:ID='s20'>\n <Alignment ss:Horizontal='Right' ss:Vertical='Center' ss:WrapText='1'/>\n <Borders>\n <Border ss:Position='Bottom' ss:LineStyle='Continuous' ss:Weight='1'\n ss:Color='#C0C0C0'/>\n <Border ss:Position='Left' ss:LineStyle='Continuous' ss:Weight='1'\n ss:Color='#C0C0C0'/>\n <Border ss:Position='Right' ss:LineStyle='Continuous' ss:Weight='1'\n ss:Color='#C0C0C0'/>\n <Border ss:Position='Top' ss:LineStyle='Continuous' ss:Weight='1'\n ss:Color='#C0C0C0'/>\n </Borders>\n <Font ss:FontName='Calibri' ss:Size='11' ss:Color='#000000'/>\n <Interior/>\n <Protection/>\n </Style>\n <Style ss:ID='s22'>\n <Alignment ss:Horizontal='Right' ss:Vertical='Center' ss:WrapText='1'/>\n <Borders>\n <Border ss:Position='Bottom' ss:LineStyle='Continuous' ss:Weight='1'\n ss:Color='#C0C0C0'/>\n <Border ss:Position='Left' ss:LineStyle='Continuous' ss:Weight='1'\n ss:Color='#C0C0C0'/>\n <Border ss:Position='Right' ss:LineStyle='Continuous' ss:Weight='1'\n ss:Color='#C0C0C0'/>\n <Border ss:Position='Top' ss:LineStyle='Continuous' ss:Weight='1'\n ss:Color='#C0C0C0'/>\n </Borders>\n <Font ss:FontName='Calibri' ss:Size='11' ss:Color='#000000'/>\n <Interior/>\n <NumberFormat ss:Format='dd\\-mmm\\-yy'/>\n <Protection/>\n </Style>\n </Styles>\n <Worksheet ss:Name='{$name}'>\n <Table ss:ExpandedColumnCount='48' ss:ExpandedRowCount='11527' x:FullColumns='1' x:FullRows='1' ss:DefaultColumnWidth='61'>\n"; return $preamble . $cold_desc . $meta_title . $header_title; }
/** * Create the links on the dashboard page that will used to load the reports through ajax. * @param string $options An array to set options especially to display the default report_view configurations * @return boolean */ public function displayReportLinks() { $user = new I2CE_User(); $loggedin_role = $user->getRole(); //for each of the views we display it directly to the dashboard page //get reports for the current user //I2CE::raiseMessage('opts ' . print_r($this->args,true)); if (!array_key_exists('dashes', $this->args)) { $this->template->addFile("dashboard_missing.html"); return; } if (array_key_exists('default_settings', $this->args)) { $defaults = $this->args['default_settings']; } $opt_settings = array('height' => 250, 'width' => 350, 'title' => '', 'label_size' => 10); foreach ($opt_settings as $key => $val) { if (!array_key_exists($key, $defaults)) { $defaults[$key] = $val; } } $dash = null; if (count($this->request_remainder) > 0) { $dash = array_shift($this->request_remainder); } else { $dash = $loggedin_role; } if (!array_key_exists($dash, $this->args['dashes'])) { $dash = 'default'; if (!array_key_exists($dash, $this->args['dashes'])) { I2CE::raiseError("No default dashboard configured."); $this->template->addFile('dashboard_missing.html'); } } $dash_details = $this->args['dashes'][$dash]; $permissions = array(); if (array_key_exists('tasks', $dash_details)) { $permissions[] = 'task(' . implode(',', $dash_details['tasks']) . ')'; } if (array_key_exists('roles', $dash_details)) { $permissions[] = 'role(' . implode(',', $dash_details['roles']) . ')'; } if (count($permissions) > 0 && !$this->hasPermission(implode('|', $permissions))) { $this->template->addFile("dashboard_denied.html"); return; } if (array_key_exists('settings', $dash_details)) { foreach ($opt_settings as $key => $val) { if (array_key_exists($key, $dash_details['settings'])) { $defaults[$key] = $dash_details['settings'][$key]; } } } $this->template->setDisplayDataImmediate('dashboard_title', $defaults['title']); if (!array_key_exists('order', $dash_details) || !is_array($dash_details['order']) || count($dash_details['order']) == 0) { $this->template->addFile("dashboard_misconfigured.html"); return; } $reportViews = $dash_details['order']; ksort($reportViews); $views = array(); if (array_key_exists('report_views', $dash_details)) { $views = $dash_details['report_views']; } $reportListNode = $this->template->getElementById("dashboard_report_list"); foreach ($reportViews as $report_view) { $view_settings = $defaults; if (array_key_exists($report_view, $views)) { if (array_key_exists('enabled', $views[$report_view]) && !$views[$report_view]['enabled']) { // Skip if not enabled. continue; } foreach ($opt_settings as $key => $val) { if (array_key_exists($key, $views[$report_view]) && $views[$report_view][$key]) { $view_settings[$key] = $views[$report_view][$key]; } } } $reportViewConfigs = I2CE::getConfig()->getAsArray("/modules/CustomReports/reportViews/{$report_view}"); $div = $this->template->createElement('div', array('id' => "report_view_{$report_view}", 'class' => "dashboard_report")); $reportListNode->appendChild($div); $page = new I2CE_Page_ShowReport(array(), array($report_view), array('no_controls' => 1, 'flash_height' => $view_settings['height'], 'flash_width' => $view_settings['width'], 'results_id' => $report_view, 'height' => $view_settings['height'], 'width' => $view_settings['width'], 'label_size' => $view_settings['label_size'])); $page->template = $this->template; $displayObj = $page->getDisplay($report_view); //$displays = $page->getDesiredDisplays( $report_view ); //$displayObj = $page->instantiateDisplay( $displays[0], $report_view ); $displayObj->display($div); $header = $this->template->getElementByName("report_view_display_name", 0, $div); if ($header instanceof DOMElement) { $link = $this->template->createElement('a', array("href" => "CustomReports/show/{$report_view}"), $header->nodeValue); $header->replaceChild($link, $header->firstChild); } //$url = "CustomReports/show/$report_view?no_controls=1&results_id=$report_view&flash_height=" . $view_settings['height'] . "&flash_width=" . $view_settings['width'] . "&height=" . $view_settings['height'] . "&width=" . $view_settings['width']; //$this->addAjaxLoad( "report_view_$report_view",$url,'report','CustomReports_PieChart,visualization_wrapper' ); } return true; }
/** * Populate a drop down of users that can be edited by the current user given his/her access level. * @param string $selectId * @global array */ public function listUsersToEdit($selectId, $username = null) { $add_last = array(); if ($username == null) { $usernames = I2CE_User::findUsersByInfo(false, array(), false); //we all users except the interal admin user regardless or role or details. } else { $userAccess = I2CE::getUserAccess(); if (!$userAccess instanceof I2CE_UserAccess_Mechansim) { return false; } if (!in_array('creator', $userAccess->getAllowedDetails())) { return false; } $usernames = I2CE_User::findUsersByInfo(false, array('creator' => $username)); } if (!is_array($usernames)) { return false; } foreach ($usernames as $username) { $user = new I2CE_User($username, true, false, false); if (!$user instanceof I2CE_User) { continue; } $role = $user->getRole(); if ($role) { $role = I2CE_User_Form::getRoleNameFromShortName($role); } $disp = trim($user->displayName()); if (!$disp) { $disp = "({$username})"; } if ($role == "") { $add_last[$username] = 'No Access - ' . $disp; } else { $this->template->addOption($selectId, $username, $role . ' - ' . $disp); } } foreach ($add_last as $username => $dispname) { $this->template->addOption($selectId, $username, $dispname); } }