protected function loadPrimary()
 {
     $formFactory = I2CE_FormFactory::instance();
     if ($this->get_exists('id')) {
         if (!($this->primObj = $formFactory->createContainer($this->get('id'))) instanceof I2CE_Form || $this->formRelationship->getPrimaryForm() != $this->primObj->getName()) {
             I2CE::raiseError("invalid form id :" . print_r($this->request(), true) . "\ndoes not match " . $this->formRelationship->getPrimaryForm());
             return false;
         }
         $this->primObj->populate();
     }
     return true;
 }
 protected function setHeaderVars($segment)
 {
     $rel_base = '/modules/CustomReports/relationships';
     if (array_key_exists('relationship_base', $this->args) && is_scalar($this->args['relationship_base'])) {
         $rel_base = $this->args['relationship_base'];
     }
     $use_cache = I2CE_ModuleFactory::instance()->isEnabled('CachedForms');
     if (array_key_exists('use_cache', $this->args)) {
         $use_cache = $this->args['use_cache'];
     }
     if ($use_cache) {
         $cache_callback = array('I2CE_CachedForm', 'getCachedTableName');
     } else {
         $cache_callback = null;
     }
     try {
         if (!array_key_exists('header_relationship', $this->args) || !is_string($this->args['header_relationship']) || strlen($this->args['header_relationship']) == 0 || !($formRelationship = new I2CE_FormRelationship($this->args['header_relationship'], $rel_base, $cache_callback)) instanceof I2CE_FormRelationship || $formRelationship->getPrimaryForm() != $this->primObj->getName()) {
             return;
         }
         $fields = $this->getFields();
         $data = $formRelationship->getFormData($this->primObj->getName(), $this->primObj->getId(), $fields, array(), true);
         $row = 0;
         foreach ($data as $formfields) {
             if (!$this->setData($segment, $row, $formfields, $formRelationship)) {
                 I2CE::raiseError("Error setting data for row: {$row}");
                 return false;
             }
             break;
             //only do one row
         }
     } catch (Exception $e) {
     }
 }
 public function hasPermission_userSatisfies($node, $args)
 {
     if (count($args) != 3) {
         I2CE::raiseError("Two few arguments for permision satosfoes() method");
         return null;
     }
     if (!I2CE_MagicDataNode::checkKey($relationship = array_shift($args))) {
         I2CE::raiseError("No valid relationship specified");
         return null;
     }
     try {
         $relationshipObj = new I2CE_FormRelationship($relationship);
     } catch (Exception $e) {
         I2CE::raiseError("Relationship {$relationship} is not valid");
         return null;
     }
     if ($relationshipObj->getPrimaryForm() != 'person') {
         I2CE::raiseError("Relationship does not have user as its primary form");
         return null;
     }
     array_unshift($args, new I2CE_User());
     return call_user_func_array(array($relationshipObj, 'formSatisfiesRelationship'), $args);
 }