public function testValidField()
 {
     $validDef = array('name' => 'status', 'vname' => 'LBL_STATUS', 'type' => 'enum', 'len' => '25', 'options' => 'meeting_status_dom', 'comment' => 'Meeting status (ex: Planned, Held, Not held)');
     $invalidDef = array('name' => 'direction', 'vname' => 'LBL_DIRECTION', 'type' => 'enum', 'len' => '25', 'options' => 'call_direction_dom', 'comment' => 'Indicates whether call is inbound or outbound', 'source' => 'non-db', 'importable' => 'false', 'massupdate' => false, 'reportable' => false);
     $this->assertTrue(AbstractMetaDataParser::validField($validDef));
     $this->assertFalse(AbstractMetaDataParser::validField($invalidDef));
     //Test the studio override property
     $invalidDef['studio'] = 'visible';
     $validDef['studio'] = false;
     $this->assertFalse(AbstractMetaDataParser::validField($validDef));
     $this->assertTrue(AbstractMetaDataParser::validField($invalidDef));
     $invalidDef['studio'] = array('editview' => 'visible');
     $this->assertTrue(AbstractMetaDataParser::validField($invalidDef, 'editview'));
     $this->assertFalse(AbstractMetaDataParser::validField($invalidDef, 'detailview'));
 }
 function __construct($subpanelName, $moduleName)
 {
     $GLOBALS['log']->debug(get_class($this) . "->__construct({$subpanelName} , {$moduleName})");
     $this->_subpanelName = $subpanelName;
     $this->_moduleName = $moduleName;
     $module = BeanFactory::getBean($moduleName);
     // BEGIN ASSERTIONS
     if (empty($module)) {
         sugar_die(get_class($this) . ": Modulename {$moduleName} is not a Deployed Module");
     }
     // END ASSERTIONS
     $this->historyPathname = 'custom/history/modules/' . $moduleName . '/subpanels/' . $subpanelName . '/' . self::HISTORYFILENAME;
     $this->_history = new History($this->historyPathname);
     require_once 'include/SubPanel/SubPanelDefinitions.php';
     // retrieve the definitions for all the available subpanels for this module from the subpanel
     $spd = new SubPanelDefinitions($module);
     // Get the lists of fields already in the subpanel and those that can be added in
     // Get the fields lists from an aSubPanel object describing this subpanel from the SubPanelDefinitions object
     $this->_viewdefs = array();
     $this->_fielddefs = array();
     $this->_language = '';
     if (!empty($spd->layout_defs)) {
         if (array_key_exists(strtolower($subpanelName), $spd->layout_defs['subpanel_setup'])) {
             //First load the original defs from the module folder
             $originalSubpanel = $spd->load_subpanel($subpanelName, false, true);
             $this->_fullFielddefs = $originalSubpanel ? $originalSubpanel->get_list_fields() : array();
             $this->_mergeFielddefs($this->_fielddefs, $this->_fullFielddefs);
             $this->_aSubPanelObject = $spd->load_subpanel($subpanelName);
             // now check if there is a restored subpanel in the history area - if there is, then go ahead and use it
             if (file_exists($this->historyPathname)) {
                 // load in the subpanelDefOverride from the history file
                 $GLOBALS['log']->debug(get_class($this) . ": loading from history");
                 require $this->historyPathname;
                 $this->_viewdefs = $layout_defs;
             } else {
                 $this->_viewdefs = $this->_aSubPanelObject->get_list_fields();
             }
             // don't attempt to access the template_instance property if our subpanel represents a collection, as it won't be there - the sub-sub-panels get this value instead
             if (!$this->_aSubPanelObject->isCollection()) {
                 $this->_language = $this->_aSubPanelObject->template_instance->module_dir;
             }
             // Retrieve a copy of the bean for the parent module of this subpanel - so we can find additional fields for the layout
             $subPanelParentModuleName = $this->_aSubPanelObject->get_module_name();
             $beanListLower = array_change_key_case($GLOBALS['beanList']);
             if (!empty($subPanelParentModuleName) && isset($beanListLower[strtolower($subPanelParentModuleName)])) {
                 $subPanelParentModule = get_module_info($subPanelParentModuleName);
                 // Run through the preliminary list, keeping only those fields that are valid to include in a layout
                 foreach ($subPanelParentModule->field_defs as $key => $def) {
                     $key = strtolower($key);
                     if (AbstractMetaDataParser::validField($def)) {
                         if (!isset($def['label'])) {
                             $def['label'] = $def['name'];
                         }
                         $this->_fielddefs[$key] = $def;
                     }
                 }
             }
             $this->_mergeFielddefs($this->_fielddefs, $this->_viewdefs);
         }
     }
 }
Exemple #3
0
 /**
  * Relate to email1 should be true
  * @group 39729
  */
 public function testEmail1FieldOnTrue()
 {
     $this->assertTrue(AbstractMetaDataParser::validField($this->def, $this->_view));
 }
Exemple #4
0
 public function testHideMeetingDisplayedURL()
 {
     $validDef = $this->meeting->field_defs['displayed_url'];
     $this->assertFalse(AbstractMetaDataParser::validField($validDef, 'wirelesseditview'));
     $this->assertFalse(AbstractMetaDataParser::validField($validDef, 'wirelessdetailview'));
 }
 function getAvailableFields()
 {
     // Obtain the full list of valid fields in this module
     $availableFields = array();
     foreach ($this->_fielddefs as $key => $def) {
         if (AbstractMetaDataParser::validField($def) || isset($this->_originalViewDef[$key])) {
             $availableFields[$key] = array('name' => $key, 'label' => $def['label']);
             // layouts use 'label' not 'vname' for the label entry
         }
     }
     // Available fields are those that are in the Model and the original layout definition, but not already shown in the View
     // So, because the formats of the two are different we brute force loop through View and unset the fields we find in a copy of Model
     if (!empty($this->_viewdefs)) {
         foreach ($this->_viewdefs['panels'] as $panel) {
             foreach ($panel as $row) {
                 foreach ($row as $field) {
                     unset($availableFields[$field]);
                 }
             }
         }
     }
     return $availableFields;
 }
 /**
  * Determines if a field exists on the bean
  * @param $field
  * @return bool
  */
 public function isValidField($field)
 {
     $field = strtolower($field);
     $defs = $this->getFieldDefs();
     if (empty($defs)) {
         // no idea where it came from, let it pass.no reason to remove fields that may be necessary
         return true;
     }
     if (empty($defs[$field])) {
         return false;
     }
     $viewname = $this->views[$this->client . $this->viewtype] == MB_SIDECARLISTVIEW ? MB_LISTVIEW : $this->views[$this->client . $this->viewtype];
     $parser = ParserFactory::getParser($viewname, $this->module);
     if ($parser && method_exists($parser, 'isValidField')) {
         return $parser->isValidField($field, $defs[$field]);
     } else {
         return AbstractMetaDataParser::validField($defs[$field], $this->viewtype, $this->client);
     }
 }