public function manipulateWrangler($wrangler, $module, $page, $request, $pageRoot, $pageRemainder) { $user = new I2CE_User(); $user->logout(); if (array_key_exists('autologout', $_GET) && array_key_exists('HTTP_REFERER', $_SERVER) && $_SERVER['HTTP_REFERER']) { $_SESSION['referal'] = $_SERVER['HTTP_REFERER']; } return array('module' => $module, 'page' => 'login', 'request' => $request, 'pageRoot' => $pageRoot, 'pageRemainder' => $pageRemainder); }
public function welcomeNamedUser($node, $template, $named_welcome_str, $unamed_welcome_str = '') { if (!$template instanceof I2CE_Template && !$node instanceof DOMNode) { return; } $user = new I2CE_User(); if ($named_welcome_str && $user->logged_in() && ($name = $user->displayName())) { $text = sprintf($named_welcome_str, $name); } else { $text = $unamed_welcome_str; } $t_node = $template->createTextNode($text); $node->appendChild($t_node); }
/** * 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."); } }
/** * Save a form object into magicdata * @param I2CE_Form $form * @param I2CE_User $user * @param boolean $transact */ public function save($form, $user, $transact) { $form_id = $form->getId(); if (!$form_id) { $form_id = $this->getNextAvailableId($form->getName()); } if (!$form_id) { return false; } $form->setId($form_id); $form_config = $this->getFormConfig($form, true); if (!$form_config instanceof I2CE_MagicDataNode) { return false; } $form_config->last_modified = I2CE_Date::now(I2CE_Date::DATE_TIME)->dbFormat(); $form_config->who = $user->getId(); $parent = $form->getParent(); if ($parent != "") { /* Does this need to be here? the parent node may be new and doesn't exist... if ($form_config->is_parent('parent')) { return false; } */ $form_config->parent = $parent; } return parent::save($form, $user, $transact); }
protected function updateContactTypes() { $db = MDB2::singleton(); $factory = I2CE_FormFactory::instance(); if ($db->supports('transactions')) { $db->beginTransaction(); } $contactFormId = I2CE_Form::getFormId("contact"); if ($contactFormId == 0) { I2CE::raiseError("Unable to get contact form id"); if ($db->in_transaction) { $db->rollback(); } return false; } $adminUser = I2CE_User::findUser('role', 'admin', false); if (!$adminUser instanceof I2CE_User) { I2CE::raiseError("Cannot find an administrative user"); if ($db->in_transaction) { $db->rollback(); } return false; } $changes = array(4 => 5, 3 => 4); // TYPE_OTHER = 3 => TYPE_OTHER = 4 // TYPE_FACILITY = 4 => TYPE_FACILITY = 5 $qry = $db->prepare('SELECT id from record where form = ?', array('integer'), MDB2_PREPARE_RESULT); if (I2CE::pearError($qry, "Error preping select records")) { if ($db->in_transaction) { $db->rollback(); } return false; } $results = $qry->execute($contactFormId); if (I2CE::pearError($results, "Error getting records")) { if ($db->in_transaction) { $db->rollback(); } return false; } while ($row = $results->fetchRow()) { $contact = $factory->createContainer('contact' . '|' . $row->id); if (!$contact instanceof iHRIS_Contact) { I2CE::raiseError("Unable to create contact with id " . $row->id); if ($db->in_transaction) { $db->rollback(); } return false; } $contact->populate(); foreach ($changes as $old => $new) { if ($contact->contact_type == $old) { I2CE::raiseError("Changing contact type {$old} to {$new} for record " . $row->id); $contact->contact_type = $new; if (!$contact->save($adminUser)) { I2CE::raiseError("Unable to save record " . $row->id); if ($db->in_transaction) { $db->rollback(); } return false; } $contact->cleanup(); continue 2; } } $contact->cleanup(); } if ($db->in_transaction) { return $db->commit() == MDB2_OK; } else { return true; } }
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; }
/** * Main display method for web interface * @param boolean $supress_output defaults to false. set to true to supress the output of a webpage */ protected function displayWeb($supress_output = false) { $i2ce_config = I2CE::getConfig()->I2CE; if (!$this->initPage()) { $pages = $i2ce_config->page; if (isset($pages->login) && !$this->user->logged_in()) { $this->setRedirect('login'); //defined in module Login } else { $this->setRedirect('noaccess'); //defined in I2CE } $this->redirect($this->redirect); return; } $error = false; $permission = 'role(' . implode(",", $this->access) . ')'; if (array_key_exists('tasks', $this->args) && is_array($this->args['tasks']) && count($this->args['tasks']) > 0) { $permission .= ' | task(' . implode(',', $this->args['tasks']) . ')'; } if ($this->hasPermission($permission)) { I2CE_ModuleFactory::callHooks('pre_page_action', $this); if (!$supress_output) { I2CE_ModuleFactory::callHooks('pre_displayed_page_action', $this); } if ($this->loadHTMLTemplates() === false) { $error = true; } else { if ($this->setActiveMenu() === false) { $error = true; } else { if ($this->action() === false) { $error = true; } else { I2CE_ModuleFactory::callHooks('post_page_action', $this); } } } } else { if ($this->user->logged_in()) { $this->userMessage("You do not have access to the page `{$this->page}`", 'notice'); } if ($this->redirect == "") { //if there is a login page available, use it. Otherwise, go to the no access page. $pages = $i2ce_config->page; if (isset($pages->login) && !$this->user->logged_in()) { $this->setRedirect('login'); //defined in module Login } else { $this->setRedirect('noaccess'); //defined in I2CE } } } if ($this->redirect != "") { $this->redirect($this->redirect); return; } if ($error) { $this->userMessage("There was an unexpected error in processing the requested page", "notice", false); I2CE_ModuleFactory::callHooks('pre_page_display_error', $this); } $this->_display($supress_output); }
/** * Display the recent changes list for the given form. * @return boolean */ protected function actionRecent() { $form = array_shift($this->request_remainder); $form_config = I2CE::getConfig()->traverse("/modules/forms/forms"); if (!$form_config->is_parent($form) || !I2CE::getConfig()->is_parent("/modules/RecentForm/forms/{$form}")) { return $this->actionMenu(); } $page_size = 25; $days = "today"; $user = false; if (count($this->request_remainder) > 0) { $days = array_shift($this->request_remainder); } $user_list = false; if (count($this->request_remainder) > 0) { $user_list = array_shift($this->request_remainder); $user = explode(',', $user_list); foreach ($user as $key => $uid) { if ($uid == "me") { $uobj = new I2CE_User(); $user[$key] = $uobj->getId(); } } $user = array_filter($user, "is_numeric"); if (count($user) == 0) { $user = false; } elseif (count($user) == 1) { $user = array_pop($user); } } switch ($days) { case "yesterday": $mod_time = mktime(0, 0, 0, date("n"), date("j") - 1); break; case "week": $mod_time = mktime(0, 0, 0, date("n"), date("j") - 7); break; default: $mod_time = mktime(0, 0, 0); break; } $form_name = $form; $form_config->setIfIsSet($form_name, "{$form}/display"); $user_link = ""; if ($user_list) { $user_link = "/" . $user_list; } $this->template->setDisplayDataImmediate("display_form_name", ": " . $form_name); $header = $this->template->appendFileById("recent_display.html", "div", "recent_forms"); $this->template->setDisplayDataImmediate("recent_name", $form_name, $header); $this->template->setDisplayDataImmediate("recent_date", date("d M Y", $mod_time), $header); $this->template->setDisplayDataImmediate("recent_today_link", array("href" => "recent/{$form}/today" . $user_link), $header); $this->template->setDisplayDataImmediate("recent_yesterday_link", array("href" => "recent/{$form}/yesterday" . $user_link), $header); $this->template->setDisplayDataImmediate("recent_week_link", array("href" => "recent/{$form}/week" . $user_link), $header); $this->template->setDisplayDataImmediate("recent_me_link", array("href" => "recent/{$form}/{$days}/me"), $header); $this->template->setDisplayDataImmediate("recent_all_link", array("href" => "recent/{$form}/{$days}"), $header); $recent_form_config = I2CE::getConfig()->traverse("/modules/RecentForm/forms/{$form}", true); $fields = $recent_form_config->fields->getAsArray(); ksort($fields); if (!is_array($fields)) { $fields = array(); } $display = implode(" ", array_fill(0, count($fields), "%s")); $recent_form_config->setIfIsSet($display, "display"); $link = "recent"; $recent_form_config->setIfIsSet($link, "link"); $parent = false; $recent_form_config->setIfIsSet($parent, "parent"); if ($parent) { $parent = true; } $order = $fields; array_unshift($order, "-last_modified"); if ($this->request_exists("page")) { $limit_start = ((int) $this->request("page") - 1) * $page_size; } else { $limit_start = 0; } $results = I2CE_FormStorage::listDisplayFields($form, $fields, $parent, array(), $order, array($limit_start, $page_size), $mod_time, false, $user); $num_found = I2CE_FormStorage::getLastListCount($form); $this->template->setDisplayDataImmediate("recent_found", $num_found, $header); foreach ($results as $id => $data) { $record = $this->template->appendFileById("recent_display_form.html", "li", "recent_list"); if ($parent) { $this->template->setDisplayDataImmediate("form_link", array("href" => $link . $data['parent']), $record); } else { $this->template->setDisplayDataImmediate("form_link", array("href" => $link . $form . "|" . $id), $record); } $extra_display = I2CE_ModuleFactory::callHooks("recent_form_{$form}_display", $data); array_unshift($extra_display, vsprintf($display, $data)); $this->template->setDisplayDataImmediate("record_display", implode(' ', $extra_display), $record); } if ($this->module == "I2CE") { $url = $this->page . "/" . $form . "/" . $days; } else { $url = $this->module . "/" . $this->page . "/" . $form . "/" . $days; } $total_pages = max(1, ceil($num_found / $page_size)); if ($total_pages > 1) { $page_num = (int) $this->request('page'); $page_num = min(max(1, $page_num), $total_pages); $this->makeJumper("recent", $page_num, $total_pages, $url, array()); } }
public function manipulateWrangler($wrangler, $module, $page, $request, $pageRoot, $pageRemainder) { $user = new I2CE_User(); $user->logout(); return array('module' => $module, 'page' => 'login', 'request' => $request, 'pageRoot' => $pageRoot, 'pageRemainder' => $pageRemainder); }
/** * 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; }
/** * Save the objects to the database. * * Save the default object being edited and return to the view page. */ protected function save() { if ($this->creatingNewUser()) { if (!$this->hasPermission('task(users_can_edit)')) { return false; } if (!$this->userObj instanceof I2CE_User_Form || !($username = $this->userObj->username)) { return false; } $accessMech = I2CE::getUserAccess(); if ($accessMech->userExists($username, false)) { I2CE::raiseError("Trying to recreate existing user : " . $username); return false; } if (I2CE_User::hasDetail('creator')) { $this->userObj->creator = $this->user->username; } } return parent::save(); }
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; }
/** * Add an alert to the given user. * @param string $username * @param string $alert_type * @param string $message * @return boolean */ public function sendUserAlert($username, $alert_type, $message, $link = null, $link_text = null) { if (!I2CE_User::userExists($username, false)) { I2CE::raiseError("Invalid user: {$username} passed to sendUserAlert"); return false; } $ff = I2CE_FormFactory::instance(); $user_alert = $ff->createContainer("user_alert"); $user_alert->getField('alert_type')->setFromDB($alert_type); $user_alert->message = $message; if ($link && $link_text) { $user_alert->link = $link; $user_alert->link_text = $link_text; } $user_alert->setParent("user|" . $username); $save_user = new I2CE_User('0', false, true, false); $user_alert->validate(); if ($user_alert->hasInvalid()) { I2CE::raiseError("Invalid data passed to sendUserAlert"); return false; } if ($user_alert->save($save_user)) { return true; } I2CE::raiseError("Failed to save new user alert"); return false; }
/** * 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); } }
protected function updatePersonFormFields() { ini_set('max_execution_time', 6000); ini_set('memory_limit', "64M"); $db = MDB2::singleton(); $factory = I2CE_FormFactory::instance(); if ($db->supports('transactions')) { $db->beginTransaction(); } $personFormId = I2CE_Form::getFormId("person", true); if ($personFormId == 0) { I2CE::raiseError("Unable to get person form id. Assuming that no person forms have ever been created."); if ($db->in_transaction) { $db->rollback(); } return true; } $adminUser = I2CE_User::findUser('role', 'admin', false); if (!$adminUser instanceof I2CE_User) { I2CE::raiseError("Cannot find an administrative user"); if ($db->in_transaction) { $db->rollback(); } return false; } $details = array(); $changes = array('country' => 'residence_country', 'district' => 'residence_district', 'county' => 'county_district'); foreach (array_keys($changes) as $location) { die("deprecated badness in managemodule"); $details[$location] = I2CE_FormField::getFormFieldIdAndType("person", $location); if ($details[$location] === null) { I2CE::raiseError("Unable to get details for person:{$location}. Assuming that is has never beens used so skipping."); if ($db->in_transaction) { $db->rollback(); } unset($changes[$location]); continue; } $details[$location]['qry'] = $db->prepare("SELECT " . $details[$location]['type'] . "_value as val FROM last_entry where record = ? and form_field = ? LIMIT 1", array("integer", "integer"), MDB2_PREPARE_RESULT); if (I2CE::pearError($details[$location]['qry'], "Error preping statement:")) { if ($db->in_transaction) { $db->rollback(); } return false; } } $qry = $db->prepare('SELECT id from record where form = ?', array('integer'), MDB2_PREPARE_RESULT); if (I2CE::pearError($qry, "Error preping select records")) { if ($db->in_transaction) { $db->rollback(); } return false; } $results = $qry->execute($personFormId); if (I2CE::pearError($results, "Error getting records")) { if ($db->in_transaction) { $db->rollback(); } return false; } while ($row = $results->fetchRow()) { $person = $factory->createContainer('person' . '|' . $row->id); if (!$person instanceof iHRIS_Person) { I2CE::raiseError("Unable to create person with id " . $row->id); if ($db->in_transaction) { $db->rollback(); } return false; } $person->populate(); foreach ($changes as $old => $new) { $t_results = $details[$old]['qry']->execute(array($row->id, $details[$old]['id'])); if (I2CE::pearError($t_results, "Error selecting data for {$old} for id " . $row->id)) { if ($db->in_transaction) { $db->rollback(); } return false; } $t_row = $t_results->fetchRow(); if (!$t_row) { continue; //we did not get anything } if (I2CE::pearError($t_row, "Error getting data for {$old} for id " . $row->id)) { if ($db->in_transaction) { $db->rollback(); } return false; } $person->{$new} = $t_row->val; } if (!$person->save($adminUser)) { I2CE::raiseError("Unable to save record " . $row->id); if ($db->in_transaction) { $db->rollback(); } return false; } $person->cleanup(); } if ($db->in_transaction) { return $db->commit() == MDB2_OK; } else { return true; } }
/** * Checks to make sure all the required fields are valid. * * Checks to make sure the username is unique in the system and that the password matches the confirmed password. * @global array */ public function validate() { parent::validate(); if ($this->id == '0') { if (I2CE_User::userExists($this->username, false)) { $this->setInvalidMessage('username', 'unique'); } } if (strlen($this->password) > 0 && $this->password != $this->confirm) { $this->setInvalidMessage('password', 'mismatch'); } if ($this->id == '0' && $this->password == "" && !$this->generate_password) { $this->setInvalidMessage('password', 'required'); } $saving_user = new I2CE_User('0', true, true, false); if ($saving_user->role != 'admin') { // Allow anyone to set the self service role $role_field = $this->getField('role'); $role_val = $role_field->getDBValue(); $role_val = str_replace('role|', '', $role_val); if ($saving_user->role != $role_val) { $default_ss = ''; I2CE::getConfig()->setIfIsSet($default_ss, "/modules/SelfService/default_user_role"); if ($role_val != $default_ss) { $where = array('operator' => 'AND', 'operand' => array(array('operator' => 'FIELD_LIMIT', 'field' => 'assignable', 'style' => 'yes'), array('operator' => 'FIELD_LIMIT', 'field' => 'trickle_up', 'style' => 'equals', 'data' => array('value' => $saving_user->role)), array('operator' => 'FIELD_LIMIT', 'field' => 'id', 'style' => 'equals', 'data' => array('value' => $role_val)))); $results = I2CE_FormStorage::search('role', false, $where); if (count($results) == 0) { $this->setInvalidMessage('role', 'notallowed'); } } } } }
/** * Perform the main actions of the page. * @global array */ protected function action() { $i2ce_config = I2CE::getConfig()->I2CE; parent::action(); $fields = array("Name" => false, "Company" => false, "Title" => false, "Industry" => false, "Address" => false, "City" => false, "State" => false, "Postal_Code" => false, "Country" => false, "Telephone" => false, "Fax" => false, "Email" => false, "Comments" => false, "referer" => false); $valid = true; $err_msg = ""; if ($this->isPost()) { $message = ""; foreach ($fields as $name => $required) { if ($required && !I2CE_Validate::checkString($this->post($name))) { $valid = false; $err_msg .= "<li>{$name} is blank.</li>\n"; } $message .= $name . ": " . $this->post($name) . "\n"; } $message .= "Username : "******"\n"; $message .= "User Role : " . $this->user->getRole() . "\n"; if ($valid) { $this->template->addFile("feedback_thanks.html"); $this->template->setDisplayData("return_link", 'home'); I2CE_Mailer::mail($i2ce_config->feedback->to, array('Subject' => $i2ce_config->feedback->subject, 'From' => $this->post('Email')), $message); return; } } $this->template->addFile("feedback_form.html"); if (array_key_exists('contact_address', $this->args) && $this->args['contact_address']) { if (($formNode = $this->template->getElementById('feedback_form')) instanceof DOMElement) { $formNode->setAttribute('action', 'mailto:' . $this->args['contact_address'] . '?Subject=iHRIS Feedback'); $formNode->setAttribute('enctype', 'text/plain'); } } if (!$valid && $err_msg != "") { $this->template->addText('<div id="error">There were some problems with your information:<ul>' . $err_msg . '</ul></div>'); } if ($this->isPost()) { foreach ($fields as $name => $required) { if ($name == "Comments") { $this->template->addText('<textarea name="Comments" rows="10" cols="45" id="Comments">' . $this->post($name) . '</textarea>', "textarea", $name); } else { $this->template->setAttribute("value", $this->post($name), $name, "."); } } } else { $this->template->setAttribute("value", $_SERVER['HTTP_REFERER'], "referer", "."); if (!array_key_exists('auto_populate', $this->args) || $this->args['auto_populate']) { //defaults to true foreach (array('email' => 'Email', 'phone' => 'Phone', 'fax' => 'Fax') as $detail => $data) { if (I2CE_User::hasDetail($detail)) { $this->template->setDisplayDataImmediate($data, $this->user->{$detail}); } } $this->template->setDisplayDataImmediate('Name', $this->user->displayName()); } } }
/** * Perform the main actions of the page. * @global array Get the home page from the global configuration */ protected function action() { if ($this->request_exists('message') && $this->request('message')) { $this->template->userMessage($this->request('message'), 'default', false); } $i2ce_config = I2CE::getConfig()->I2CE; parent::action(); $this->template->setBodyId("loginPage"); if ($this->isPost()) { if ($this->post('submit') == "Login as Guest") { $this->post['username'] = $i2ce_config->guest->account; $this->post['password'] = $i2ce_config->guest->password; } $message = $this->user->login($this->post('username'), $this->post('password')); if (is_string($message)) { $this->template->setDisplayDataImmediate('error_message', $message); } else { if ($message === true) { //the user was logged in if (I2CE_Locales::getPreferredLocale() != I2CE_Locales::getBrowserPreferredLocale()) { $this->user->setPreferredLocale(I2CE_Locales::getPreferredLocale()); } } } } if ($this->user->logged_in()) { if (array_key_exists('referal', $_SESSION) && $_SESSION['referal']) { $site_url = $this->getAccessedBaseURL(); $referal = $_SESSION['referal']; unset($_SESSION['referal']); if ($site_url . $this->page == $referal) { //there is an off chance that we are redirect from the login page. this can happen if we initialize the site by accessing the login page $referal = $this->getHome(); } if (preg_match('/login/', $referal) || preg_match('/logout/', $referal)) { $referal = $this->getHome(); } } else { $referal = $this->getHome(); } if ($this->user->username != 'i2ce_admin' && I2CE_User::userHasDefaultPassword($this->user->username)) { $this->userMessage("Please you must change your default password before you continue using the system!", "notice"); $this->setRedirect('password'); } else { $this->setRedirect($referal); } return true; } if ($default_password = I2CE_User::userHasPassword('administrator', 'administrator')) { $username = $this->template->query('//input[@name="username"]'); if ($username->length == 1) { $username->item(0)->setAttribute('value', 'administrator'); } $password = $this->template->query('//input[@name="password"]'); if ($password->length == 1) { $password->item(0)->setAttribute('value', 'administrator'); } } else { if (($autologinuser = I2CE_User::getAutoLoginUser()) !== false) { $username = $this->template->query('//input[@name="username"]'); if ($username->length == 1) { $username->item(0)->setAttribute('value', $autologinuser); } } } $this->template->addHeaderLink("welcomeText.css"); if ($this->user->logged_in() && $this->user->username == 'administrator' && $default_password) { $this->userMessage("Your password is currently set to the default password, administrator. Please change this by clicking on the \"Change Password\" link below.", "notice"); $this->userMessage("If you have not already done so, please create a new user with a non-administrative role for everyday use.", "notice"); } }
protected function createAdminUser() { if (I2CE::getUserAccessProtocol() !== 'DEFAULT') { return true; } $admins = I2CE_User::findUsersByInfo('admin'); if (is_array($admins) && count($admins) > 0) { I2CE::raiseError("Admin users already found"); return true; // an admin already exists. } if (I2CE_User::userExists('administrator', false)) { //do nothing. somebody has been messing around here. return true; //hopefully whoever allowed this to happen } $admin = new I2CE_User('administrator', false, false, false); $admin->email = '*****@*****.**'; $admin->creator = 'administrator'; $admin->firstname = 'Site'; $admin->lastname = 'Administrator'; $admin->username = '******'; $admin->role = 'admin'; I2CE::raiseError("Creating user 'administrator' with administrative privlages"); return $admin->save('administrator'); }
/** * Checks to make sure all the required fields are valid. * * Checks to make sure the username is unique in the system and that the password matches the confirmed password. * @global array */ public function validate() { parent::validate(); if ($this->id == '0') { if (I2CE_User::userExists($this->username, false)) { $this->setInvalidMessage('username', 'unique'); } } if (strlen($this->password) > 0 && $this->password != $this->confirm) { $this->setInvalidMessage('password', 'mismatch'); } if ($this->id == '0' && $this->password == "" && !$this->generate_password) { $this->setInvalidMessage('password', 'required'); } }