public function displayValues($content_node, $transient_options, $action)
 {
     if (!($mainNode = $this->template->appendFileByNode('swiss_form_meta.html', 'div', $content_node)) instanceof DOMNode) {
         I2CE::raiseError("no template ");
         return false;
     }
     $inputs = array('description');
     $forms = I2CE::getConfig()->getKeys("/modules/forms/forms");
     $selected = $this->getSelectedForms();
     if (!is_array($selected)) {
         //in case it wan't ever set
         $selected = array();
     }
     if (($formsNode = $this->template->getElementByName('child_forms', 0, $mainNode)) instanceof DOMNode) {
         foreach ($forms as $form) {
             $input = 'child_forms[' . $form . ']';
             $inputs[] = $input;
             $attr = array('value' => 1, 'name' => $input, 'type' => 'checkbox');
             if (in_array($form, $selected)) {
                 $attr['checked'] = 'checked';
             }
             $formsNode->appendChild($formNode = $this->template->createElement('span', array('style' => 'display:inline-block;width:33%; min-width:33%')));
             $formNode->appendChild($this->template->createElement('input', $attr));
             $formNode->appendChild($this->template->createTextNode($form));
         }
     }
     $this->template->setDisplayDataImmediate('description', $this->getField('description'), $mainNode);
     $this->renameInputs($inputs, $mainNode);
     if (($swissChild = $this->getChild('child_form_data', true)) instanceof I2CE_Swiss && ($childNode = $this->template->getElementById('child_form_data', $mainNode)) instanceof DOMNode) {
         $swissChild->addAjaxLink('child_form_data_link', 'display_container', 'child_form_data_ajax', $childNode, $action, $transient_options);
     }
     return true;
 }
    /**
     * Add javascript logout to the page if a timeout is set for the site.
     * @param I2CE_Page $page
     */
    public function javascriptTimeout($page)
    {
        if (!$page->getUser()->logged_in()) {
            return;
        }
        $timeout = 0;
        I2CE::getConfig()->setIfIsSet($timeout, "/config/site/user_timeout");
        I2CE::getConfig()->setIfIsSet($timeout, "/user_prefs/timeout/user_timeout");
        if ($timeout && is_numeric($timeout) && $timeout > 0) {
            $timeout = $timeout * 1000;
            $message = "You have been logged out due to inactivity.";
            I2CE::getConfig()->setIfIsSet($message, "/config/site/user_timeout_message");
            I2CE::getConfig()->setIfIsSet($message, "/user_prefs/timeout/user_timeout_message");
            $logout = $page->getAccessedBaseURL() . "logout?message=" . urlencode($message);
            $js = <<<EOJS
var auto_logout_timeout_id = 0;
window.addEvent('domready', function() { 
        autoLogoutResetTimeout(); 
        document.addEvent('keypress', function(event) { autoLogoutResetTimeout(); } );
        document.addEvent('mousemove', function(event) { autoLogoutResetTimeout(); } );
        } );
function autoLogoutResetTimeout() {
    if ( auto_logout_timeout_id > 0 ) {
        clearTimeout( auto_logout_timeout_id );
    }
    auto_logout_timeout_id = setTimeout( function() { window.location = "{$logout}"; }, {$timeout} );
}
EOJS;
            $template = $page->getTemplate();
            $template->addHeaderLink("mootools-core.js");
            $template->addHeaderText($js, "script", true);
        }
    }
Esempio n. 3
0
 public function displayValues($content_node, $transient_options, $action)
 {
     if (!($mainNode = $this->template->appendFileByNode('swiss_form.html', 'div', $content_node)) instanceof DOMNode) {
         I2CE::raiseError("no template form_class_builder_menu.html");
         return false;
     }
     if (($classNode = $this->template->getElementByName('class', 0, $mainNode)) instanceof DOMNode) {
         $selected = $this->getField('class');
         foreach (I2CE::getConfig()->getKeys("/modules/forms/formClasses") as $class) {
             $attrs = array('value' => $class);
             if ($selected == $class) {
                 $attrs['selected'] = $selected;
             }
             $classNode->appendChild($this->template->createElement('option', $attrs, $class));
         }
     }
     $this->template->setDisplayDataImmediate('display', $this->getField('display'), $mainNode);
     $storage = $this->getField('storage');
     if (!$storage) {
         $storage = 'entry';
     }
     $this->template->setDisplayDataImmediate('storage', $storage, $mainNode);
     $this->renameInputs(array('display', 'class'), $mainNode);
     if (($metaChild = $this->getChild('meta', true)) instanceof I2CE_Swiss && ($metaNode = $this->template->getElementById('meta', $mainNode)) instanceof DOMNode) {
         $metaChild->addAjaxLink('meta_link', 'container', 'meta_ajax', $metaNode, $action, $transient_options);
     }
     if (($storage_optionsChild = $this->getChild('storage_options', true)) instanceof I2CE_Swiss && ($storage_optionsNode = $this->template->getElementById('storage_options', $mainNode)) instanceof DOMNode) {
         $storage_optionsChild->addAjaxLink('storage_options_link', 'container', 'storage_options_ajax', $storage_optionsNode, $action, $transient_options);
     }
     return true;
 }
 /**
  * Upgrade this module if necessary
  * @param string $old_vers
  * @param string $new_vers
  * @return boolean
  */
 public function upgrade($old_vers, $new_vers)
 {
     /*
      * In 3.2.3 we moved some lists from entry to magicdata storage so we need to get the
      * old data from entry and save them to the new form storage.
      */
     if (I2CE_Validate::checkVersion($old_vers, '<', '3.2.3')) {
         $user = new I2CE_User(1, false, false, false);
         $class_config = I2CE::getConfig()->modules->forms->formClasses;
         $migrate_path = "/I2CE/formsData/migrate_data/3.2.3";
         if (!I2CE_FormStorage::migrateField("training_course_competency_evaluation", array("competency_evaluation" => "competency_evaluation", "competency" => "competency"), $migrate_path, $user)) {
             return false;
         }
         if (!I2CE_FormStorage::migrateField("training_course", array("competency" => "competency"), $migrate_path, $user)) {
             return false;
         }
         // If everything migrated correctly, then remove the unused fields.
         unset($class_config->iHRIS_Training_Course_Competency_Evaluation->fields->competency_type);
     }
     if (I2CE_Validate::checkVersion($old_vers, '<', '3.2.6')) {
         $evals = array('not_evaluated' => 'Not Evaluated');
         if (!I2CE_Module_Lists::remapFields('competency_evaluation', $evals, 'training_course_competency_evaluation')) {
             return false;
         }
     }
     if (I2CE_Validate::checkVersion($old_vers, '<', '3.2.7')) {
         //             if (!I2CE_Module_Lists::deleteMappedValues('training_course_evaluation', $evals)) {
         //                 return false;
         //             }
     }
     return parent::upgrade($old_vers, $new_vers);
 }
Esempio n. 5
0
 /**
  * Loads in the file containing mime types and extensions
  */
 protected static function loadMimeTypes()
 {
     self::$extToMimeTypes = array();
     $mime_file = null;
     if (I2CE::getConfig()->setIfIsSet($mime_file, "/modules/MimeTypes/mime_types")) {
         $mime_file = I2CE::getFileSearch()->search('MIME', $mime_file);
     }
     if (empty($mime_file)) {
         I2CE::raiseError('Unable to find mime.types file.', E_USER_WARNING);
         return;
     }
     $a = file($mime_file);
     if (empty($a)) {
         I2CE::raiseError('mime.types file is empty.', E_USER_WARNING);
         return;
     }
     foreach ($a as $l) {
         $l = trim($l);
         if (strlen($l) < 1 || $l[0] == '#') {
             //skip comments
             continue;
         }
         $pieces = preg_split("/\\s+/", $l, -1, PREG_SPLIT_NO_EMPTY);
         if (empty($pieces)) {
             //a blank line
             continue;
         }
         $mime = strtolower(array_shift($pieces));
         foreach ($pieces as $ext) {
             self::$extToMimeTypes[strtolower($ext)] = $mime;
         }
     }
 }
 /**
  * Upgrades the modules
  * @param string $old_vers
  * @param string $new_vers
  * @returns boolean
  */
 public function upgrade($old_vers, $new_vers)
 {
     if (I2CE_Validate::checkVersion($old_vers, '<', '3.2.12')) {
         I2CE::raiseError("Changing contact child forms of training_institution to training_institution_contact");
         if (!iHRIS_Module_Contact::changeContactForm('training_institution', 'contact_type|facility', 'training_institution_contact', true)) {
             I2CE::raiseError("Could not upgrade training instituion contacts");
             return false;
         }
     }
     if (I2CE_Validate::checkVersion($old_vers, '=', '3.2.12')) {
         //the changeContactForm did not remvoe the contact form before
         if (!iHRIS_Module_Contact::removeContactForm('training_institution')) {
             return false;
         }
     }
     if (I2CE_Validate::checkVersion($old_vers, '<', '3.2.19')) {
         I2CE::raiseError("Changing contact child forms of training_funder to training_funder_contact");
         if (!iHRIS_Module_Contact::changeContactForm('training_funder', 'contact_type|facility', 'training_funder_contact', true)) {
             I2CE::raiseError("Could not upgrade training funder contacts");
             return false;
         }
     }
     if (I2CE_Validate::checkVersion($old_vers, '<', '3.2.20')) {
         $user = new I2CE_User(1, false, false, false);
         $class_config = I2CE::getConfig()->modules->forms->formClasses;
         $migrate_path = "/I2CE/formsData/migrate_data/3.2.3";
         if (!I2CE_FormStorage::migrateField("training_institution", array("location" => array("county" => "county", "district" => "district", "country" => "country")), $migrate_path, $user)) {
             return false;
         }
         if (!I2CE_FormStorage::migrateField("training_funder", array("location" => array("county" => "county", "district" => "district", "country" => "country")), $migrate_path, $user)) {
             return false;
         }
     }
     return true;
 }
Esempio n. 7
0
 protected static function initMailer()
 {
     $backend = "mail";
     I2CE::getConfig()->setIfIsSet($backend, "/modules/Mailer/mail_server_backend");
     I2CE::getConfig()->setIfIsSet(self::$params, "/modules/Mailer/mail_server_params", true);
     I2CE::getConfig()->setIfIsSet(self::$headers, "/modules/Mailer/mail_message_headers", true);
     if (class_exists('Mail', false)) {
         self::$method = 'pear';
         $allowed_backends = array("mail", "smtp", "sendmail");
     } else {
         I2CE::raiseError("No Mail class : try 'sudo apt-get install pear-mail'");
         self::$method = 'localhost';
         $allowed_backends = array("localhost");
     }
     if (!in_array($backend, $allowed_backends)) {
         I2CE::raiseError("Mailing backend {$backend} is not in list: " . implode(" ", $allowed_backends));
         self::$method = false;
         return false;
     }
     if (self::$method == 'pear') {
         if (array_key_exists('auth', self::$params) && self::$params['auth'] == 1) {
             self::$params['auth'] = true;
         }
         try {
             self::$pear_mailer =& Mail::factory($backend, self::$params);
         } catch (Exception $e) {
             I2CE::raiseError("Could not create pear mailer:\n" . $e->getMessage());
             self::$method = false;
             return false;
         }
     }
 }
 public function processDOMEditable($node, $template, $form_node)
 {
     $default = $this->getValue();
     $ele_name = $this->getHTMLName();
     if (!$default instanceof I2CE_Date) {
         $default = I2CE_Date::now();
     }
     if ($this->use_date_picker) {
         $date = $default->dbFormat();
         $attrs = array("class" => "datepicker_ymd", "name" => $ele_name, "type" => "text", "value" => $date);
         foreach (array('onclick', 'onchange') as $attr) {
             if ($node->hasAttribute($attr)) {
                 $attrs[$attr] = $node->getAttribute($attr);
                 $node->removeAttribute($attr);
             }
         }
         $element = $template->createElement("input", $attrs);
         $this->setElement($element);
         $node->appendChild($element);
         $args = array('format' => 'F j, Y', 'inputOutputFormat' => 'Y-m-d', 'allowEmpty' => true, 'startView' => 'decades');
         $add_args = I2CE::getConfig()->getAsArray("/modules/DatePicker/options");
         if (is_array($add_args)) {
             $args = array_merge($args, $add_args);
         }
         $template->addDatePicker('datepicker_ymd', $args);
     } else {
         I2CE_Date::addMonthDayElement($template, $ele_name, $default, $this->hasInvalid(), $node);
         I2CE_Date::addYearElement($template, $ele_name, $default, $this->hasInvalid(), $node, $this->getYearRange(), false, true);
     }
 }
 /**
  * Add any necessary defaults to the given map details.
  * This is currently just a default view and any layers
  * defined in the _order, but not in the layers data.
  * @param array &$maps The maps data
  */
 public function addMapDefaults(&$maps)
 {
     $config = I2CE::getConfig()->modules->OpenLayers;
     if ($config->is_parent('default')) {
         $defaults = array('_height', '_width');
         foreach ($defaults as $default) {
             if (!array_key_exists($default, $maps) && $config->default->is_scalar($default)) {
                 $maps[$default] = $config->default->{$default};
             }
         }
         foreach ($maps as $map_name => &$map) {
             if ($map_name[0] == '_') {
                 continue;
             }
             if ($config->is_parent("default/layers")) {
                 if (array_key_exists('layers', $map) && is_array($map['layers']) && array_key_exists('_order', $map['layers']) && is_array($map['layers']['_order'])) {
                     foreach ($map['layers']['_order'] as $layer => $order) {
                         if (!array_key_exists($layer, $map['layers']) && $config->is_parent("default/layers/{$layer}")) {
                             $map['layers'][$layer] = $config->default->layers->{$layer}->getAsArray();
                         }
                     }
                 }
             }
             if ($config->is_parent("default/view")) {
                 if (array_key_exists('view', $map)) {
                     $map['view'] = array_merge($config->default->view->getAsArray(), $map['view']);
                 } else {
                     $map['view'] = $config->default->view->getAsArray();
                 }
             }
         }
     }
 }
 protected function ensureLimits()
 {
     if ($this->ensured) {
         return;
     }
     if ($this->storage->is_scalar()) {
         return false;
     }
     if (!$this->parent instanceof I2CE_Swiss_CustomReports_Report_ReportingForm_Field) {
         return false;
     }
     $factory = I2CE_FormFactory::instance();
     $formName = $this->parent->getForm();
     $formObj = $factory->createForm($formName);
     if (!$formObj instanceof I2CE_Form) {
         I2CE::raiseError("Could not instantiate the form {$formName}  at " . $this->configPath);
         return false;
     }
     $field = $this->parent->getName();
     $allowed_limits = $formObj->getLimitStyles($field);
     $excludes = I2CE::getConfig()->getAsArray("/modules/CustomReports/limit_excludes/displayed");
     foreach ($allowed_limits as $limit => $data) {
         if (in_array($limit, $excludes)) {
             continue;
         }
         $swissLimit = $this->getChild($limit, true);
         if (is_array($data) && count($data) == 1 && in_array('value', $data)) {
             $swissLimit->setAllowPivot(true);
         } else {
             $swissLimit->setAllowPivot(false);
         }
     }
     $this->ensured = true;
 }
 public function displayValues($content_node, $transient_options, $action)
 {
     if (!($mainNode = $this->template->appendFileByNode('swiss_formfield_headers.html', 'div', $content_node)) instanceof DOMNode || !($headersNode = $this->template->getElementByName('headers_body', 0, $mainNode)) instanceof DOMNode) {
         I2CE::raiseError("Could not load headers template");
         return false;
     }
     $headers = $this->storage->getAsArray();
     $inputs = array('new_key', 'new_val', 'do_new');
     $delete = 'Delete Header';
     I2CE::getConfig()->setIfIsSet($delete, "/modules/form-builder/messages/delete_header");
     foreach ($headers as $key => $val) {
         if (!is_scalar($val) && !$val === null) {
             continue;
         }
         $headersNode->appendChild($trNode = $this->template->createElement('tr'));
         $trNode->appendChild($keyNode = $this->template->createElement('td'));
         $trNode->appendChild($valNode = $this->template->createElement('td'));
         $keyNode->appendChild($labelNode = $this->template->createElement('h3'));
         $labelNode->appendChild($this->template->createTextNode($key));
         $input = 'val[' . $key . ']';
         $inputs[] = $input;
         $valNode->appendChild($this->template->createElement('input', array('value' => $val, 'name' => $input)));
         $valNode->appendChild($this->template->createElement('br'));
         $input = 'delete[' . $key . ']';
         $inputs[] = $input;
         $keyNode->appendChild($this->template->createElement('input', array('type' => 'checkbox', 'value' => 1, 'name' => $input)));
         $keyNode->appendChild($this->template->createTextNode($delete));
     }
     if (($newNode = $this->template->getElementByName('new_key', 0, $mainNode)) instanceof DOMNode) {
         $this->template->setClassValue($newNode, 'validate_data', array('notinlist' => array_keys($headers)), '%');
     }
     $this->renameInputs($inputs, $mainNode);
     return true;
 }
Esempio n. 12
0
 protected function displayMeta($mainNode, $transient_options, $action)
 {
     if (($styleNode = $this->template->getElementByName('style', 0, $mainNode)) instanceof DOMNode) {
         $styles = I2CE::getConfig()->getKeys("/I2CE/template/page_styles");
         $selected_style = $this->getField('style');
         foreach ($styles as $style) {
             $attrs = array('value' => $style);
             if ($style == $selected_style && $selected_style != '' || $style == 'shell' && $selected_style == '') {
                 $attrs['selected'] = 'selected';
             }
             $styleNode->appendChild($this->template->createElement('option', $attrs, $style));
         }
         $this->renameInputs('style', $mainNode);
     }
     if (($descNode = $this->template->getElementByName('description', 0, $mainNode)) instanceof DOMNode) {
         $this->template->setDisplayData("page", $this->name, $descNode);
         $this->template->setDisplayData("class", $this->getField('class'), $descNode);
     }
     if (($linkNode = $this->template->getElementByName('link_name', 0, $mainNode)) instanceof DOMNode) {
         $page = $this->getName();
         $url = I2CE_Page::getAccessedBaseURL() . '/' . $page;
         $c = 0;
         $formids = $this->getSampleIDs();
         foreach ($formids as $formid) {
             $this->template->setDisplayDataImmediate("link_title_" . $c, "{$page} {$c}", $linkNode);
             $this->template->setDisplayDataImmediate("page_edit_link_" . $c, "{$url}?id={$formid}", $linkNode);
             $c++;
         }
         return true;
     }
 }
 /**
  * Upgrade this module if necessary
  * @param string $old_vers
  * @param string $new_vers
  * @return boolean
  */
 public function upgrade($old_vers, $new_vers)
 {
     /*
      * In 3.2.3 we moved some lists from entry to magicdata storage so we need to get the
      * old data from entry and save them to the new form storage.
      */
     if (I2CE_Validate::checkVersion($old_vers, '<', '3.2.3')) {
         $user = new I2CE_User(1, false, false, false);
         $class_config = I2CE::getConfig()->modules->forms->formClasses;
         $migrate_path = "/I2CE/formsData/migrate_data/3.2.3";
         if (!I2CE_FormStorage::migrateForm("facility_type", "entry", $user, $migrate_path, false, array("type"))) {
             return false;
         }
         if (I2CE_FormStorage::migrateForm("facility", "entry", $user, $migrate_path, false, array("type"), array("facility_type" => "facility_type", "location" => array("county" => "county", "district" => "district", "country" => "country")))) {
             unset($class_config->iHRIS_Facility->fields->country);
             unset($class_config->iHRIS_Facility->fields->district);
             unset($class_config->iHRIS_Facility->fields->county);
             unset($class_config->iHRIS_Facility->fields->type);
         } else {
             return false;
         }
     } elseif (I2CE_Validate::checkVersion($old_vers, '<', '3.2.4')) {
         $user = new I2CE_User(1, false, false, false);
         $class_config = I2CE::getConfig()->modules->forms->formClasses;
         $migrate_path = "/I2CE/formsData/migrate_data/3.2.3";
         if (!I2CE_FormStorage::migrateForm("facility", "entry", $user, $migrate_path, false, array("type"))) {
             return false;
         }
         unset($class_config->iHRIS_Facility->fields->type);
     }
     return parent::upgrade($old_vers, $new_vers);
 }
 public function displayArgs($mainNode, $transient_options, $action)
 {
     // Display the action link's form field
     $this->template->setDisplayDataImmediate('formfield', $this->getField('formfield'), $mainNode);
     // Display the action link's link location
     $this->template->setDisplayDataImmediate('linkloc', $this->getField('href'), $mainNode);
     // Display the action link's link text field
     $this->template->setDisplayDataImmediate('linktext', $this->getField('text'), $mainNode);
     // Rename the inputs to include swiss instance path
     $inputs = array('linkloc', 'formfield', 'linktext');
     if (($taskNode = $this->template->getElementByName('task', 0, $mainNode)) instanceof DOMNode) {
         $tasks = I2CE::getConfig()->getAsArray("/I2CE/tasks/task_description");
         $selected_task = $this->getField('task');
         foreach ($tasks as $task => $desc) {
             $attrs = array('value' => $task, 'title' => $desc);
             if ($task == $selected_task) {
                 $attrs['selected'] = 'selected';
             }
             $taskNode->appendChild($this->template->createElement('option', $attrs, $task));
         }
         $inputs[] = 'task';
     }
     $this->renameInputs($inputs, $mainNode);
     return true;
 }
 public function displayArgs($mainNode, $transient_options, $action)
 {
     if (!parent::displayArgs($mainNode, $transient_options, $action)) {
         return false;
     }
     if (($relNode = $this->template->getElementByName('relationship', 0, $mainNode)) instanceof DOMNode) {
         $relationships = I2CE::getConfig()->getKeys("/modules/CustomReports/relationships");
         $selected_rel = $this->getField('relationship');
         foreach ($relationships as $relationship) {
             $attrs = array('value' => $relationship);
             if ($relationship == $selected_rel) {
                 $attrs['selected'] = 'selected';
             }
             $title = false;
             if (I2CE::getConfig()->setIfIsSet($title, "/modules/CustomReports/relationships/{$relationship}/display_name")) {
                 $attrs['title'] = $title;
             }
             $relNode->appendChild($this->template->createElement('option', $attrs, $relationship));
         }
         if ($selected_rel) {
             $this->template->setDisplayDataImmediate('has_relationship', 1, $mainNode);
             $this->template->setDisplayDataImmediate('relationship_link', "CustomReports/edit/relationships/" . $selected_rel, $mainNode);
         } else {
             $this->template->setDisplayDataImmediate('has_relationship', 0, $mainNode);
         }
     }
     $this->renameInputs(array('relationship'), $mainNode);
     return true;
 }
 public function displayValues($content_node, $transient_options, $action)
 {
     if (!($mainNode = $this->template->appendFileByNode('swiss_mapped_limits_form.html', 'div', $content_node)) instanceof DOMNode || !($limitsNode = $this->template->getElementByName('limits', 0, $mainNode))) {
         I2CE::raiseError("Could not load swiss_mapped_limits.html");
         return false;
     }
     $existing = $this->storage->getKeys();
     if (($selectNode = $this->template->getElementByName('new', 0, $mainNode)) instanceof DOMNode) {
         foreach (I2CE::getConfig()->getKeys("/modules/forms/forms") as $key) {
             if (in_array($key, $existing)) {
                 continue;
             }
             $selectNode->appendChild($this->template->createElement('option', array('value' => $key), $key));
         }
     }
     $this->renameInputs(array('new'), $mainNode);
     foreach ($existing as $name) {
         $limitsNode->appendChild($liNode = $this->template->createElement('li'));
         if (!($limitNode = $this->template->appendFileByNode('swiss_mapped_limits_each.html', 'div', $liNode)) instanceof DOMNode || !($swissLimit = $this->getChild($name)) instanceof I2CE_Swiss) {
             continue;
         }
         $this->template->setDisplayDataImmediate('name', $name, $limitNode);
         $swissLimit->addAjaxLink('limit_link', 'relationship_where_container', 'limit_ajax', $limitNode, $action, $transient_options);
         $delete_link = $swissLimit->getURLRoot('delete_class') . $swissLimit->path;
         $this->template->setDisplayDataImmediate('delete_link', $delete_link, $limitNode);
     }
     return true;
 }
 protected function addNewLocaleMenu($contentNode, $transient_options)
 {
     $locales = I2CE_Locales::validateLocales($this->getChildNames());
     $def_locales = array();
     //the locales packaged with iHRIS by default
     I2CE::getConfig()->setIfIsSet($def_locales, "/locales/default-available", true);
     $def_locale_list = array();
     foreach ($def_locales as $locale => $locale_lang) {
         if (in_array($locale_lang, $locales)) {
             continue;
         }
         $disp = I2CE_Module_LocaleSelector::getLocaleName($locale_lang);
         if ($disp != $locale_lang) {
             $disp .= ' (' . $locale_lang . ')';
         }
         $def_locale_list[$locale_lang] = $disp;
     }
     if (count($def_locale_list) > 0) {
         $this->template->setDisplayDataImmediate('has_def_locale', 1, $contentNode);
         $this->template->setDisplayDataImmediate('def_locale', $def_locale_list, $contentNode);
         $this->addAjaxOptionMenu('add_def_locale', 'locales_container', $contentNode);
     } else {
         $this->template->setDisplayDataImmediate('has_def_locale', 0, $localeNode);
     }
     if (!($localeNode = $this->template->getElementById('new_locale', $contentNode)) instanceof DOMNode) {
         return false;
     }
     $this->template->setClassValue($localeNode, 'validate_data', array('notinlist' => array_unique(array_merge($def_locales, $locales))), '%');
     return $this->addAjaxOptionMenu('add_locale', 'locales_container', $contentNode);
 }
 public static function getAvailableCourses()
 {
     $status = I2CE_FormStorage::listFields('training_course_status', 'name');
     foreach ($status as $i => &$s) {
         if (!array_key_exists('name', $s)) {
             unset($status[$i]);
             continue;
         }
         $s = $s['name'];
     }
     $t_filters = array();
     I2CE::getConfig()->setIfIsSet($t_filters, '/modules/training-course/filters/availableCourses', true);
     //this should be moved to magic data form storage!
     $filters = array();
     foreach ($t_filters as $val) {
         if (($key = array_search($val, $status)) !== false) {
             $filters[] = $key;
         }
     }
     $where = array();
     if (count($filters) > 0) {
         $where = array('operator' => 'FIELD_LIMIT', 'field' => 'training_course_status', 'style' => 'in', 'data' => array('value' => $filters));
     }
     $courses = I2CE_FormStorage::listFields('training_course', 'name', false, $where);
     foreach ($courses as $i => &$c) {
         if (!array_key_exists('name', $c)) {
             unset($courses[$i]);
             continue;
         }
         $c = $c['name'];
     }
     return $courses;
 }
 protected function getRootStorage()
 {
     if ($this->root_path) {
         return I2CE::getConfig()->traverse($this->root_path, $this->root_path_create, false);
     } else {
         return I2CE::getConfig();
     }
 }
 public static function getCSDArgs($csd_cache)
 {
     $args = array('relationship' => $csd_cache, 'transform' => '@' . $csd_cache . '.xsl', 'get_all_fields' => 1);
     if (!I2CE_MagicDataNode::checkKey($csd_cache) || !is_array($t_args = I2CE::getConfig()->getAsArray("/modules/csd_cache/" . $csd_cache . '/args'))) {
         $t_args = array();
     }
     I2CE_Util::merge_recursive($args, $t_args);
     return $args;
 }
Esempio n. 21
0
 /**
  * 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());
         }
     }
 }
Esempio n. 22
0
 /**
  * Return a list of the cron types available.
  * For use with an ENUM field type.
  * @return array
  */
 public function listTypes()
 {
     $types = array();
     foreach (I2CE::getConfig()->modules->admin->cron->types as $key => $data) {
         if ($data instanceof I2CE_MagicDataNode) {
             $types[$key] = $data->display_name;
         }
     }
     return $types;
 }
Esempio n. 23
0
 public function action()
 {
     parent::action();
     if ($this->request_exists('message') && $this->request('message')) {
         $this->template->userMessage($this->request('message'));
     }
     $i2ce_config = I2CE::getConfig()->I2CE;
     $this->user->logout();
     session_destroy();
     $this->redirect('login');
 }
Esempio n. 24
0
 protected function mailPassword($email, $username, $password)
 {
     $i2ce_config = I2CE::getConfig()->I2CE;
     $msg = "The password for your account in " . $i2ce_config->template->prefix_title . " has been reset.\n\nUsername: "******"\nPassword: "******"\n";
     if (!I2CE_Mailer::mail($email, array('Subject' => "New " . $i2ce_config->template->prefix_title . " Password"), $msg)) {
         I2CE::raiseError("Could not mail reset password to {$username}");
         return false;
     }
     $this->userMessage("Your password has been reset and is being mailed to you now.");
     return true;
 }
 /**
  * Display the report
  * @param DOMNode $contentNode The DOM node we wish to display into
  * @param boolean $processResults Defaults to true meaning we run through the results
  * @param mixed $controls.  If null (default), we display all the report controsl.  If string or an array of string, we only display the indicated controls
  * @returns boolean. true on sucess
  */
 public function display($contentNode, $processResults = true, $controls = null)
 {
     $parent_return = parent::display($contentNode, false, $controls);
     $i2ce_config = I2CE::getConfig();
     $this->template->addHeaderLink('https://www.google.com/jsapi', array('type' => "text/javascript", 'ext' => 'js'), false);
     $this->template->addHeaderText("        google.load('visualization', '1.0', {'packages':['corechart']});\n", 'script', 'visualization_wrapper');
     $this->template->addHeaderLink('QueryWrapper.js');
     $save_req = "flash_data&" . file_get_contents("php://input") . "&" . $_SERVER['QUERY_STRING'];
     $req_key = md5($save_req);
     $_SESSION['req_query'][$req_key] = $save_req;
     $vis_class = $this->defaultOptions['styles'][$this->defaultOptions['style']]['visualization_class'];
     $options = array('height' => 350, 'width' => 590);
     if (array_key_exists('global_options', $this->defaultOptions) && is_array($this->defaultOptions['global_options'])) {
         foreach ($this->defaultOptions['global_options'] as $key => $val) {
             if (is_numeric($val)) {
                 $options[$key] = $val + 0;
             } elseif (is_array($val)) {
                 // Make sure arrays stay as JSON arrays
                 ksort($val);
                 $options[$key] = $val;
             } else {
                 $options[$key] = $val;
             }
         }
     }
     if (array_key_exists('visualization_options', $this->defaultOptions['styles'][$this->defaultOptions['style']]) && is_array($this->defaultOptions['styles'][$this->defaultOptions['style']]['visualization_options'])) {
         foreach ($this->defaultOptions['styles'][$this->defaultOptions['style']]['visualization_options'] as $opt => $val) {
             if (is_numeric($val)) {
                 $options[$opt] = $val + 0;
             } else {
                 $options[$opt] = $val;
             }
         }
     }
     if (array_key_exists('height', $this->defaultOptions)) {
         $options['height'] = $this->defaultOptions['height'] + 0;
     }
     if (array_key_exists('width', $this->defaultOptions)) {
         $options['width'] = $this->defaultOptions['width'] + 0;
     }
     $report_results = 'report_results';
     if (array_key_exists('results_id', $this->defaultOptions)) {
         $report_results = 'report_results_' . $this->defaultOptions['results_id'];
         $this->template->setAttribute('id', $report_results, 'report_results', null, $contentNode);
     }
     $this->template->setAttribute('onclick', "queryWrapper_{$report_results}.resize( 0, 0, true );", 'vis_button_smaller', null, $contentNode);
     $this->template->setAttribute('onclick', "queryWrapper_{$report_results}.resize();", 'vis_button_bigger', null, $contentNode);
     $dataSourceURL = "index.php/CustomReports/show/{$this->view}/Datasource?req_query={$req_key}";
     //$js = "        google.load('visualization', '1.0', {'packages':['corechart']});\n"
     $js = "        google.setOnLoadCallback(drawChart_{$report_results});\n" . "        var dataSourceURL_{$report_results} = '{$dataSourceURL}';\n" . "        var query_{$report_results};\n" . "        var queryWrapper_{$report_results};\n" . "        function drawChart_{$report_results}() {\n" . "          var container = document.getElementById('{$report_results}');\n" . "          var chart = new google.visualization.{$vis_class}(container);\n" . "          query_{$report_results} && query_{$report_results}.abort();\n" . "          query_{$report_results} = new google.visualization.Query(dataSourceURL_{$report_results});\n" . "          queryWrapper_{$report_results} = new QueryWrapper( query_{$report_results}, chart, " . json_encode($options) . ", container );\n" . "          queryWrapper_{$report_results}.sendAndDraw();\n" . "        }\n";
     $this->template->addHeaderText($js, 'script', 'visualization_wrapper');
     //add this to a new script node.
     return $parent_return;
 }
Esempio n. 26
0
 public function invisibleClass($class_name)
 {
     $classConfig = I2CE::getConfig()->traverse("/modules/forms/formClasses/{$class_name}", false, false);
     if (!$classConfig instanceof I2CE_MagicDataNode) {
         return null;
     }
     if (!$classConfig->is_scalar('extends') || !$classConfig->extends) {
         I2CE::raiseError("Checking for invisible class {$class_name} -- no extension");
         return null;
     }
     return 'class ' . $class_name . ' extends ' . $classConfig->extends . ' {}';
 }
Esempio n. 27
0
 /**
  * Upgrade this module if necessary
  * @param string $old_vers
  * @param string $new_vers
  * @return boolean
  */
 public function upgrade($old_vers, $new_vers)
 {
     /*
      * In 3.2.3 we moved some lists from entry to magicdata storage so we need to get the
      * old data from entry and save them to the new form storage.
      */
     if (I2CE_Validate::checkVersion($old_vers, '<', '3.2.3')) {
         $class_config = I2CE::getConfig()->modules->forms->formClasses;
         unset($class_config->iHRIS_ContinuingEducationCourse->fields->type);
     }
     return parent::upgrade($old_vers, $new_vers);
 }
 protected function processUpload()
 {
     if (!($mdn = I2CE::getConfig()->traverse(self::$md_path, true, false)) instanceof I2CE_MagicDataNode || $mdn->is_parent() || !array_key_exists('dhisexport', $_FILES) || !(array_key_exists('error', $_FILES['dhisexport']) && count($_FILES['dhisexport']['error']) > 0) || $_FILES["dhisexport"]["size"] == 0 || !array_key_exists('tmp_name', $_FILES['dhisexport']) || !is_readable($file = $_FILES["dhisexport"]["tmp_name"])) {
         I2CE::raiseError("Could not access save DHIS export to " . self::$md_path);
         return false;
     }
     $mdn->setAttribute('binary', 1);
     I2CE::raiseError("Setting dhis export at " . $mdn->getPath());
     $mdn->setValue(file_get_contents($file));
     $this->launchBackgroundPage("CachedForms/dropAndCacheForce", array('--post=profile=dhis_metadata'));
     return true;
 }
 protected function setConfig()
 {
     if (count($this->request_remainder) > 0 && $this->request_remainder[0] == '__NONE') {
         $this->config_path = '__NONE';
         $this->config = null;
     } else {
         $this->config = I2CE::getConfig()->traverse('/modules/CustomReports', true);
         if (!$this->config instanceof I2CE_MagicDataNode) {
             $this->config = null;
         }
     }
 }
 public function displayValues($content_node, $transient_options, $action)
 {
     if (!($mainNode = $this->template->appendFileByNode('swiss_svs_lists.html', 'div', $content_node)) instanceof DOMNode || !($listNode = $this->template->getElementByName('lists', 0, $mainNode)) instanceof DOMNode) {
         return false;
     }
     $publish_text = 'Publish a new version';
     $retrieve_text = 'Retrieve the most recent version';
     $edit_text = 'Edit %s configuration';
     $other_text = 'Other Versions:';
     $based_on_form_text = 'Based on the list %s';
     I2CE::getConfig()->setIfIsSet($publish_text, "/modules/SVS/messages/publish");
     I2CE::getConfig()->setIfIsSet($retrieve_text, "/modules/SVS/messages/retrieve");
     I2CE::getConfig()->setIfIsSet($edit_text, "/modules/SVS/messages/edit");
     I2CE::getConfig()->setIfIsSet($other_text, "/modules/SVS/messages/other");
     I2CE::getConfig()->setIfIsSet($based_on_form_text, "/modules/SVS/messages/basd_on_form_style");
     foreach ($this->storage->getKeys() as $oid) {
         if (!($swissChild = $this->getChild($oid)) instanceof I2CE_Swiss_SVS) {
             continue;
         }
         $form = $swissChild->getField('list');
         $id = 'list_' . $oid;
         $listNode->appendChild($liNode = $this->template->createElement('li'));
         $liNode->appendChild($spanNode = $this->template->createElement('span', array('id' => $id)));
         $spanNode->appendChild($aNode = $this->template->createElement('a', array('id' => $id . '_link')));
         $aNode->appendChild($this->template->createElement('h3', array(), sprintf($edit_text, $oid)));
         if ($form) {
             $spanNode->appendChild($pNode = $this->template->createElement('p', array(), sprintf($based_on_form_text, $form)));
         }
         $spanNode->appendChild($divNode = $this->template->createElement('div', array('id' => $id . '_ajax', 'class' => 'indented')));
         $spanNode->appendChild($linkDivNode = $this->template->createElement('div', array('class' => 'indented')));
         $publish = I2CE_Page::getAccessedBaseURL() . '/SVS/publish?id=' . $oid;
         $retrieve = I2CE_Page::getAccessedBaseURL() . '/SVS/RetrieveValueSet?id=' . $oid;
         $linkDivNode->appendChild($this->template->createElement('a', array('href' => $publish), $publish_text));
         $linkDivNode->appendChild($this->template->createElement('br'));
         $versions = iHRIS_SVS::getVersions($oid);
         if (count($versions) > 0) {
             $linkDivNode->appendChild($this->template->createElement('a', array('href' => $retrieve), $retrieve_text));
             $linkDivNode->appendChild($this->template->createElement('br'));
             $linkDivNode->appendChild($this->template->createTextNode($other_text));
             sort($versions);
             foreach ($versions as $i => $version) {
                 if ($i != 0) {
                     $linkDivNode->appendChild($this->template->createTextNode(','));
                 }
                 $linkDivNode->appendChild($this->template->createElement('a', array('href' => $retrieve . '&version=' . $version), " {$version} "));
             }
         }
         $linkDivNode->appendChild($this->template->createElement('pre', array(), $retrieve));
         $swissChild->addAjaxLink($id . '_link', 'contents', $id . '_ajax', $spanNode, $action, $transient_options);
     }
     return true;
 }