public function action_person_record_status($obj)
 {
     if (!$obj instanceof iHRIS_PageView) {
         return;
     }
     $person = $obj->getPerson();
     if (!$person instanceof iHRIS_Person) {
         return false;
     }
     $obj->addChildForms('person_record_status');
     $template = $obj->getTemplate();
     $recordStatusObjs = $person->getChildren('person_record_status');
     if (count($recordStatusObjs) == 1) {
         return true;
     } else {
         if (count($recordStatusObjs) > 1) {
             I2CE::raiseError("Too many record status forms  for " . $person->getId());
             return false;
         } else {
             if ($obj->hasPermission("task(person_can_edit_child_form_person_record_status)")) {
                 $template->appendFileById("view_person_record_status_link.html", 'span', 'record_status_links');
             }
         }
     }
     return true;
 }
 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;
 }
 protected function loadObjects()
 {
     $factory = I2CE_FormFactory::instance();
     if ($this->isPost()) {
         $dataset = $factory->createContainer('dataset');
         if (!$dataset instanceof iHRIS_DataSet) {
             I2CE::raiseError("Could not create Data Set form");
             return;
         }
         $dataset->load($this->post);
         //$surname_ignore = $person->getField('surname_ignore');
         //$ignore_path = array('forms','person',$person->getID(),'ignore','surname');
         //            if ($surname_ignore instanceof I2CE_FormField && $this->post_exists($ignore_path)) {
         //                $surname_ignore->setFromPost($this->post($ignore_path));
         //            }
     } else {
         if ($this->get_exists('id')) {
             $id = $this->get('id');
             if (strpos($id, '|') === false) {
                 I2CE::raiseError("Depcreated use of id variable");
                 $id = 'dataset|' . $id;
             }
         } else {
             $id = 'dataset|0';
         }
         $dataset = $factory->createContainer($id);
         if (!$dataset instanceof iHRIS_DataSet) {
             I2CE::raiseError("Could not create valid Data Set form from id:{$id}");
             return;
         }
         $dataset->populate();
         $dataset->load($this->request());
     }
     $this->setObject($dataset);
 }
 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;
 }
 /**
  * Process a result row.
  * @param array $row
  * @param int $row_num The current row number when processing results.  If there was a result limit, it starts the count from the beginning of the
  * result offset.  Othwerwise, it starts counting form zero.
  * @param DOMNode $contentNode. Default to null. A node to append the result onto
  */
 protected function processResultRow($row, $row_num, $contentNode = null)
 {
     parent::processResultRow($row, $row_num, $contentNode);
     $per_page = (int) $this->defaultOptions['limit_per_page'];
     if ($per_page < 1) {
         //check it is not bad, if so make it something reasonable -- in fact make it the default per page in I2CE_CustomReport_Display
         $per_page = 100;
     }
     $page = (int) $this->defaultOptions['limit_page'];
     //$page = (int) $this->page->request('limit_page');
     if ($page < 1) {
         $page = 1;
     }
     $appendCount = $row_num - ($page - 1) * $per_page;
     $cellNode = $this->template->appendFileByName("customReports_table_data_cell.html", "td", "report_row", $appendCount, null, true);
     if (!$cellNode instanceof DOMNode) {
         I2CE::raiseError("Could not add data cell to table");
         return false;
     }
     $field_args = array();
     foreach ($this->page->getActionFields() as $field) {
         $field_args[] = $row->{$field};
     }
     $actionNode = $this->page->getActionNode($field_args);
     $this->template->appendNode($actionNode, $cellNode);
     return true;
 }
 /**
  * Update config for given values
  * @param array $vals.  An array of values (presumably from $_POST) to update magic data from
  * @returns  true on sucess
  */
 public function processValues($vals)
 {
     //add a new field name,formfield,header
     foreach (array('name', 'formfield', 'header') as $key) {
         if (!array_key_exists($key, $vals) || !is_scalar(${$key} = $vals[$key]) || !${$key}) {
             I2CE::raiseError("Missing {$key} when creating a new field");
             return false;
         }
     }
     if (!I2CE_MagicDataNode::checkKey($name) || in_array($name, $this->getFieldNames(true))) {
         I2CE::raiseError("Could not create a new field named  {$name}");
         return false;
     }
     $formfields = I2CE::getConfig()->getKeys("/modules/forms/FORMFIELD");
     if (!in_array($formfield, $formfields)) {
         I2CE::raiseError("Invalid form field");
         return false;
     }
     $this->storage->{$name} = array('formfield' => $formfield);
     if (!($swissField = $this->getChild($name)) instanceof I2CE_Swiss_FormField) {
         I2CE::raiseError("Could not get field controler");
         return false;
     }
     if (!($swissHeaders = $swissField->getChild('headers', true)) instanceof I2CE_Swiss_FormField_Headers) {
         I2CE::raiseError("Could not get headers controler");
         return false;
     }
     $swissHeaders->processValues(array('val' => array('default' => $header)));
     return true;
 }
 public function displayValues($contentNode, $transient_options, $action)
 {
     $mainNode = $this->template->appendFileByNode('view_relationship_forms.html', 'div', $contentNode);
     if (!$mainNode instanceof DOMNode) {
         I2CE::raiseError("Unable to add reported form list template");
         return false;
     }
     $listNode = $this->template->getElementById('report_forms_list', $mainNode);
     if (!$listNode instanceof DOMElement) {
         I2CE::raiseError("Don't knwo where to add forms");
         return false;
     }
     $swissRelationshipForms = $this->getSwissFormsInRelationship();
     foreach ($swissRelationshipForms as $form => $swissRelationshipForm) {
         if ($swissRelationshipForm instanceof I2CE_Swiss_FormRelationship_Join) {
             $swissForm = $this->getChild($form, true);
         } else {
             $swissForm = $this->getChild('primary_form', true);
         }
         if (!$swissForm instanceof I2CE_Swiss_CustomReports_Report_ReportingForm) {
             continue;
         }
         $formNode = $this->template->appendFileByNode('customReports_report_forms_each.html', 'li', $listNode);
         if (!$formNode instanceof DOMNode) {
             continue;
         }
         $this->template->setDisplayDataImmediate('name', $form, $formNode);
         $swissForm->addAjaxLink('form_link', 'form_contents', 'form_ajax', $formNode, $action, $transient_options);
     }
     return true;
 }
 public function displayValues($content_node, $transient_options, $action)
 {
     if (!($mainNode = $this->template->appendFileByNode('swiss_xmlrelationship_formfields.html', 'div', $content_node)) instanceof DOMNode) {
         return false;
     }
     $listNode = $this->template->getElementById('forms_list', $mainNode);
     if (!$listNode instanceof DOMElement) {
         I2CE::raiseError("Don't know where to add forms");
         return false;
     }
     foreach ($this->getFormNames() as $formname) {
         if (!($swissChild = $this->getChild($formname, true)) instanceof I2CE_Swiss) {
             continue;
         }
         $formNode = $this->template->appendFileByNode('swiss_xmlrelationship_formfields_each.html', 'li', $listNode);
         if (!$formNode instanceof DOMNode) {
             continue;
         }
         $name = $formname;
         if ($formname == 'primary_form' && ($relObj = $this->getRelationship()) instanceof I2CE_FormRelationship) {
             $name = $relObj->getForm('primary_form') . ' (primary_form)';
         }
         $this->template->setDisplayDataImmediate('name', $name, $formNode);
         $swissChild->addAjaxLink('form_link', 'form_contents', 'form_ajax', $formNode, $action, $transient_options);
     }
     return true;
 }
 public function action()
 {
     parent::action();
     $init_options = array('root_path' => '/modules/forms/storage_options/CSD/remote_services', 'root_path_create' => true, 'root_url' => 'remote_directory_selector', 'root_type' => 'ServiceDirectorySelector');
     try {
         $swiss_factory = new I2CE_SwissMagicFactory($this, $init_options);
     } catch (Exception $e) {
         I2CE::raiseError("Could not create swissmagic for selectable" . $e->getMessage());
         return false;
     }
     try {
         $swiss_factory->setRootSwiss();
     } catch (Exception $e) {
         I2CE::raiseError("Could not create root swissmagic for selectable" . $e->getMessage());
         return false;
     }
     $swiss_path = $this->request_remainder;
     $action = array_shift($swiss_path);
     if ($action == 'update' && $this->isPost()) {
         if ($swiss_factory->updateValues($this->post())) {
             $this->userMessage("Updated Remote Directories");
         } else {
             $this->userMessage("Unable To Update Remote Directories");
         }
         $this->setRedirect('home');
     }
     $action = 'edit';
     return $swiss_factory->displayValues($this->template->getElementById('siteContent'), $swiss_path, $action);
 }
 protected function ensureFieldsFromForm()
 {
     if ($this->ensured) {
         return;
     }
     $swissForm = $this->getAncestorByClass('I2CE_Swiss_CustomReports_Report_ReportingForm');
     if (!$swissForm instanceof I2CE_Swiss_CustomReports_Report_ReportingForm) {
         I2CE::raiseError("Could not get reported form");
         return;
     }
     $formRel = $this->getSwissRelationshipForm($swissForm->storage->getName());
     if (!$formRel instanceof I2CE_Swiss) {
         I2CE::raiseError("Could not get relationship form for " . $swissForm->storage->getName());
         return;
     }
     $formName = $formRel->getField("form");
     if (!$formName) {
         I2CE::raiseError("Could not get relationship form name for " . $swissForm->storage->getName());
         return;
     }
     $factory = I2CE_FormFactory::instance();
     $fields = $factory->getFieldNames($formName, array('in_db' => true));
     $fields[] = 'last_modified';
     $fields[] = 'created';
     foreach ($fields as $field) {
         $this->getChild($field, true);
     }
     $this->getChild('id', true);
     $this->ensured = true;
 }
 /**
  * Create the report display and add it to the page.
  * @param string $query The query string to pass to the action for applying limits.
  * @return boolean
  */
 protected function actionReport($query = '')
 {
     try {
         $this->display = new I2CE_CustomReport_Display_DefaultAction($this, $this->args['report_view']);
     } catch (Exception $e) {
         I2CE::raiseError("Could not get for " . $this->args['report_view'] . "\n" . $e);
         return false;
     }
     $this->template->addHeaderLink($this->args['action_script']);
     $this->template->addHeaderLink("CustomReports.css");
     $this->template->addHeaderLink("CustomReports_iehacks.css", array('ie6' => true));
     $this->template->setDisplayData("limit_description", false);
     $contentNode = $this->template->getElementById("siteContent");
     if (!$contentNode instanceof DOMNode || !$this->display->display($contentNode)) {
         I2CE::raiseError("Couldn't display report.  Either no content node or an error occurred displaying the report.");
         return false;
     }
     $reportLimitsNode = $this->template->getElementById('report_limits');
     if (!$reportLimitsNode instanceof DOMNode) {
         I2CE::raiseError("Unable to find report_limits node.");
     } else {
         $applyNode = $this->template->appendFileByNode("customReports_display_limit_apply_Default.html", "tr", $reportLimitsNode);
         $form = $this->template->query(".//*[@id='limit_form']", $contentNode);
         if ($form->length == 1) {
             $form = $form->item(0)->setAttribute('action', $this->page() . "?{$query}");
         }
     }
     return true;
 }
 protected function displayMeta($mainNode, $transient_options, $action)
 {
     foreach (self::$bool_keys as $k => $default) {
         if ($this->hasField($k)) {
             $val = $this->getField($k) ? 1 : 0;
         } else {
             $val = $default;
         }
         $this->template->selectOptionsImmediate($k, array($val), $mainNode);
     }
     $this->renameInputs(array_keys(self::$bool_keys), $mainNode);
     if (!($sortNode = $this->template->getElementByName('key_sort', 0, $mainNode)) instanceof DOMNode) {
         I2CE::raiseError("Don't know where to add key sorts");
         return false;
     }
     $sort = $this->getField('key_sort');
     if (!in_array($sort, self::$allowed_sorts)) {
         $sort = 'SORT_NATURAL_CASE';
         //the default
     }
     foreach (self::$allowed_sorts as $s) {
         $attrs = array('value' => $s);
         if ($sort == $s) {
             $attrs['selected'] = 'selected';
         }
         $sortNode->appendChild($this->template->createElement('option', $attrs, $s));
     }
     $this->renameInputs(array('key_sort'), $mainNode);
     return true;
 }
 protected function ensureFunctions()
 {
     if ($this->ensured) {
         return true;
     }
     $swissRel = $this->getSwissRelationship();
     if (!$swissRel instanceof I2CE_Swiss_FormRelationship) {
         I2CE::raiseError("Could not get Relationship");
         return false;
     }
     $relFunctions = $swissRel->getSwissFunctions();
     if (!$relFunctions instanceof I2CE_Swiss_FormRelationship_ReportingFunctions) {
         return false;
     }
     $rels = array($relFunctions);
     while (count($rels) > 0) {
         $relFunctions = array_pop($rels);
         foreach ($relFunctions as $func => $swissRelFunction) {
             $this->getChild($func, true);
             if (($t_relFunctions = $swissRelFunction->getChild('reporting_functions')) instanceof I2CE_Swiss_FormRelationship_ReportingFunctions) {
                 $rels[] = $t_relFunctions;
             }
         }
     }
     $this->ensured = 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;
 }
 /**
  * Wrapper function to fenerates a UUID via the pecl uuid module.
  * More {@link http://pwet.fr/man/linux/fonctions_bibliotheques/ossp/uuid doucmentation} on ossp uuid.
  *
  * <br/>
  * Version 1 UUIDs are guaranteed to be unique through combinations of hardware addresses, time stamps and random seeds. There is a reference in the UUID to the hardware (MAC) address of the first network interface card (NIC) on the host which generated the UUID this reference is intended to ensure the UUID will be unique in space as the MAC address of every network card is assigned by a single global authority (IEEE) and is guaranteed to be unique. The next component in a UUID is a timestamp which, as clock always (should) move forward, will be unique in time. Just in case some part of the above goes wrong (the hardware address cannot be determined or the clock moved steps backward), there is a random clock sequence component placed into the UUID as a catch-all for uniqueness.
  * <br/>
  * Version 3 and version 5 UUIDs are guaranteed to be inherently globally unique if the combination of namespace and name used to generate them is unique.  It is  not supported at the moment
  * <br/>
  * Version 4 UUIDs are not guaranteed to be globally unique, because they are generated out of locally gathered pseudo-random numbers only. Nevertheless there is still a high likelihood of uniqueness over space and time and that they are computationally difficult to guess. 
  *                                                                                                *
  * http://manpages.ubuntu.com/manpages/dapper/man3/uuid.3ossp.html
  * V1 -- Time an node
  * V4 -- random data
  * 
  * @param string $version.  Defaults to 1
  * @retruns mixed string or false on failure
  */
 public static function generateUUID($version = 4)
 {
     switch ($version) {
         case 3:
             I2CE::raiseError("Version 3 not supported");
             return false;
             break;
         case 5:
             I2CE::raiseError("Version 5 not supported");
             return false;
             break;
         case 4:
             $version = UUID_TYPE_RANDOM;
             break;
         default:
         case 1:
             $version = UUID_TYPE_DEFAULT;
             break;
     }
     // if (  0 != uuid_make ( self::$uuidobject, $version ) > 0 ) { //i think it returns a non-zero on failure
     //     return false;
     // }
     // uuid_export ( self::$uuidobject, UUID_FMT_STR, &$uuidstring );
     return trim(uuid_create($version));
 }
 /**
  * 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;
 }
 /**
  * Create and load data for the objects used for this form.
  * 
  * Create the list object and if this is a form submission load
  * the data from the form data.
  */
 protected function loadObjects()
 {
     $factory = I2CE_FormFactory::instance();
     if ($this->isPost()) {
         $person = $factory->createContainer('person');
         if (!$person instanceof iHRIS_Person) {
             I2CE::raiseError("Could not create person form");
             return;
         }
         $person->load($this->post);
         $surname_ignore = $person->getField('surname_ignore');
         $ignore_path = array('forms', 'person', $person->getID(), 'ignore', 'surname');
         if ($surname_ignore instanceof I2CE_FormField && $this->post_exists($ignore_path)) {
             $surname_ignore->setFromPost($this->post($ignore_path));
         }
     } else {
         if ($this->get_exists('id')) {
             $id = $this->get('id');
             if (strpos($id, '|') === false) {
                 I2CE::raiseError("Depcreated use of id variable");
                 $id = 'person|' . $id;
             }
         } else {
             $id = 'person|0';
         }
         $person = $factory->createContainer($id);
         if (!$person instanceof iHRIS_Person) {
             I2CE::raiseError("Could not create valid person form from id:{$id}");
             return;
         }
         $person->populate();
         $person->load($this->request());
     }
     $this->setObject($person, I2CE_PageForm::EDIT_PRIMARY, null, true);
 }
 protected function action()
 {
     if (!parent::action()) {
         return false;
     }
     I2CE::raiseError("aremaC <- sthgiL");
     if (!is_scalar($search_form = array_shift($this->request_remainder)) || !($search_obj = I2CE_FormFactory::instance()->createContainer($search_form)) instanceof CSD_SearchMatches || (!($matches = $search_obj->getField('matches'))) instanceof I2CE_FormField_ASSOC_MAP_RESULTS) {
         return false;
     }
     I2CE::raiseError(print_r($this->request(), true));
     if (($maxField = $search_obj->getField('max')) instanceof I2CE_FormField_INT) {
         if ($maxField->getValue() > 200) {
             $maxField->setValue(200);
         }
     }
     $search_obj->load($this->post, false, false);
     I2CE::raiseError($search_obj->getXMLRepresentation(false));
     $search_obj->setID("1");
     //so it will populate
     $search_obj->populate(true);
     if (count($results = $matches->getValue()) > 200) {
         return false;
         I2CE::raiseError("Too many results");
     }
     $this->data['length'] = count($results);
     $this->data['data'] = $results;
     I2CE::raiseError("REQ=" . print_r($this->request(), true));
     $this->data = array($this->data);
     I2CE::raiseError(print_r($this->data, true));
     return true;
 }
 /**
  * Create and load data for the objects used for this form.
  * 
  * Create the list object and if this is a form submission load
  * the data from the form data.
  */
 protected function loadObjects()
 {
     $factory = I2CE_FormFactory::instance();
     if ($this->isPost()) {
         $trainingprovider = $factory->createContainer('trainingprovider');
         if (!$trainingprovider instanceof iHRIS_TrainingProvider) {
             I2CE::raiseError("Could not create trainingprovider form");
             return;
         }
         $trainingprovider->load($this->post);
         $name_ignore = $trainingprovider->getField('name_ignore');
         $ignore_path = array('forms', 'trainingprovider', $trainingprovider->getID(), 'ignore', 'name');
         if ($name_ignore instanceof I2CE_FormField && $this->post_exists($ignore_path)) {
             $name_ignore->setFromPost($this->post($ignore_path));
         }
     } else {
         if ($this->get_exists('id')) {
             $id = $this->get('id');
             if (strpos($id, '|') === false) {
                 I2CE::raiseError("Depcreated use of id variable");
                 $id = 'trainingprovider|' . $id;
             }
         } else {
             $id = 'trainingprovider|0';
         }
         $trainingprovider = $factory->createContainer($id);
         if (!$trainingprovider instanceof iHRIS_TrainingProvider) {
             I2CE::raiseError("Could not create valid trainingprovider form from id:{$id}");
             return;
         }
         $trainingprovider->populate();
     }
     $this->setObject($trainingprovider);
 }
 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($this->getContainerTemplate(), 'div', $content_node)) instanceof DOMNode || !($containerNode = $this->template->getElementByName('forms', 0, $mainNode))) {
         I2CE::raiseError("Could not load " . $this->getContainerTemplate());
         return false;
     }
     if (($formsNode = $this->template->getElementByName('form', 0, $mainNode)) instanceof DOMNode) {
         $forms = array_diff($this->getAllowedForms(), $this->storage->getKeys());
         foreach ($forms as $form) {
             $formsNode->appendChild($this->template->createElement('option', array('value' => $form), $form));
         }
     }
     $this->renameInputs(array('form'), $mainNode);
     foreach ($this->storage->getKeys() as $name) {
         $containerNode->appendChild($liNode = $this->template->createElement('li'));
         if (!($childNode = $this->template->appendFileByNode($this->getFormTemplate(), 'div', $liNode)) instanceof DOMNode || !($swissChild = $this->getChild($name)) instanceof I2CE_Swiss) {
             continue;
         }
         $this->template->setDisplayDataImmediate('name', $name, $childNode);
         $swissChild->addAjaxLink('form_link', $this->getAjaxContainer(), 'form_ajax', $childNode, $action, $transient_options);
         $delete_link = $swissChild->getURLRoot('delete_class') . $swissChild->path;
         $this->template->setDisplayDataImmediate('delete_link', $delete_link, $childNode);
     }
     return true;
 }
 public function display($supress_output = false)
 {
     if (!array_key_exists('HTTP_HOST', $_SERVER)) {
         exit("No command line usage for this page");
     }
     if (!$this->get_exists('delay_index')) {
         I2CE::raiseError("Invalid tree data request:  'request' is missing");
         return false;
     }
     $delay_index = $this->get('delay_index');
     if (!array_key_exists('tree_data', $_SESSION) || !is_array($_SESSION['tree_data']) || !array_key_exists($delay_index, $_SESSION['tree_data'])) {
         return false;
     }
     $data = $_SESSION['tree_data'][$delay_index];
     unset($_SESSION['tree_data'][$delay_index]);
     if (!is_array($data)) {
         return false;
     }
     $template = new I2CE_Template();
     $template->loadRootText("<span id='root'>");
     $root = $template->getElementById('root');
     $doc = $template->getDoc();
     I2CE_Module_TreeSelect::createTreeData($template, $root, $data);
     $tdoc = new DOMDocument();
     $tdoc->appendChild($tdoc->importNode($root, true));
     echo $tdoc->saveHTML();
     die;
 }
 public function processValues($vals)
 {
     I2CE::raiseError(print_r($vals, true));
     I2CE::raiseError(print_r($_FILES, true));
     if (!parent::processValues($vals)) {
         return false;
     }
     if (array_key_exists('get_all_fields', $vals) && is_scalar($vals['get_all_fields'])) {
         $this->setField('get_all_fields', $vals['get_all_fields'] ? 1 : 0);
     }
     if (array_key_exists('use_cache', $vals) && is_scalar($vals['use_cache'])) {
         $this->setField('use_cache', $vals['use_cache'] ? 1 : 0);
     }
     if (array_key_exists('use_display_fields', $vals) && is_scalar($vals['use_display_fields'])) {
         $this->setField('use_display_fields', $vals['use_display_fields'] ? 1 : 0);
     }
     if (array_key_exists('do_upload', $vals) && $vals['do_upload'] && array_key_exists('__files_upload', $vals) && ($tmpfile = $vals['__files_upload']) && array_key_exists($tmpfile, $_FILES) && is_array($_FILES[$tmpfile]) && array_key_exists('tmp_name', $_FILES[$tmpfile]) && ($file = $_FILES[$tmpfile]['tmp_name']) && ($contents = file_get_contents($file)) && ($transformNode = $this->storage->traverse("transform", true, false)) instanceof I2CE_MagicDataNode) {
         $transformNode->setAttribute('binary', 1);
         $transformNode->setAttribute('encoding', 'base64');
         if (array_key_exists('type', $_FILES[$tmpfile])) {
             $transformNode->setAttribute('mime-type', $_FILES[$tmpfile]['type']);
         }
         $transformNode->setValue(base64_encode($contents));
     } else {
         if (array_key_exists('do_select', $vals) && $vals['do_select'] && array_key_exists('select', $vals) && is_scalar($vals['select']) && is_array($options = $this->getXSLTS()) && in_array($vals['select'], $options) && ($transformNode = $this->storage->traverse("transform", true, false)) instanceof I2CE_MagicDataNode) {
             $transformNode->setAttribute('binary', 0);
             $transformNode->setValue('@' . $vals['select']);
         } else {
             if (array_key_exists('do_erase', $vals) && $vals['do_erase'] && ($transformNode = $this->storage->traverse("transform", false, false)) instanceof I2CE_MagicDataNode) {
                 $transformNode->erase();
             }
         }
     }
     return true;
 }
 public function displayValues($contentNode, $transient_options, $action)
 {
     $mainNode = $this->template->appendFileByNode('customReports_reportView_merge_' . $action . '.html', 'div', $contentNode);
     if (!$mainNode instanceof DOMNode) {
         I2CE::raiseError("Could not load report views template");
         return false;
     }
     if ($this->isEnabled()) {
         $this->template->setDisplayDataImmediate('enabled', 1, $mainNode);
     } else {
         $this->template->setDisplayDataImmediate('enabled', 0, $mainNode);
     }
     if ($this->showBlanks()) {
         $this->template->setDisplayDataImmediate('show_blanks', 1, $mainNode);
     } else {
         $this->template->setDisplayDataImmediate('show_blanks', 0, $mainNode);
     }
     $this->template->setDisplayDataImmediate('merge_report_name', $this->getDisplayName(), $mainNode);
     $header_node = $this->template->getElementById('merge_header', $mainNode);
     if ($header_node instanceof DOMNode) {
         $this->template->setDisplayData('linked_report', $this->getLinkedReport(), $header_node);
     }
     $inputs = array('enabled', 'show_blanks', 'merge_exists');
     if ($action == 'edit') {
         $this->renameInputs($inputs, $mainNode);
     }
     return $this->displayFields($mainNode, $transient_options, $action);
 }
 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;
 }
 /**
  *  Caluclulate the length of a string
  * @param string $string  the string we wish to calculate the length of
  * @param bool use_font_size default false -- 
  * @returns float/int the length of the string
  */
 public function getStringWidth($string, $use_font_size = false)
 {
     if ($this->direction != -1) {
         return $this->font_metrics[$this->direction]->getStringWidth($string, $use_font_size);
     } else {
         I2CE::raiseError("No font direction specified", E_USER_ERROR);
     }
 }
 /**
  * Update config for given values
  * @param array $vals.  An array of values (presumably from $_POST) to update magic data from
  * @returns  true on sucess
  */
 public function processValues($vals)
 {
     I2CE::raiseError("Received:" . print_r($vals, true));
     if (array_key_exists('style', $vals)) {
         $this->setField('style', $vals['style']);
     }
     return true;
 }
 /**
  * Run the upgrade for this module.  
  * @param string $old_vers
  * @param string $new_vers
  * @return boolean
  */
 public function upgrade($old_vers, $new_vers)
 {
     if (I2CE_Validate::checkVersion($old_vers, '<', '3.2.5')) {
         I2CE::raiseError("Disabling training module.");
         I2CE_ModuleFactory::instance()->disable(array("manage-training-simple-competency", "manage-training-institution", "manage-training-course", "training-simple-competency", "training-institution", "training-course"));
     }
     return parent::upgrade($old_vers, $new_vers);
 }
 /**
  * method to intialize temporary upload table
  * @returns boolean
  */
 protected function createTempUploadTable()
 {
     if (!I2CE_Util::runSQLScript('initialize_temp_upload.sql')) {
         I2CE::raiseError("Could not initialize tempoary upload table");
         return false;
     }
     return true;
 }
 /**
  * Set the user for this module.
  * This is for any command line access that needs to override the user.
  * @param I2CE_User $user
  */
 public function setUser($user)
 {
     if ($user instanceof I2CE_User) {
         $this->user = $user;
     } else {
         I2CE::raiseError("Invalid user object passed to setUser");
     }
 }