/** * Adds restriction (a binding between the display and item type) * * @param int $pn_type_id the type * @param array $pa_settings Array of options for the restriction. (No options are currently implemented). * @return bool True on success, false on error, null if no screen is loaded * */ public function addTypeRestriction($pn_type_id, $va_settings = null) { if (!($vn_display_id = $this->getPrimaryKey())) { return null; } // display must be loaded if (!is_array($va_settings)) { $va_settings = array(); } if (!($t_instance = $this->_DATAMODEL->getInstanceByTableNum($this->get('table_num')))) { return false; } $va_type_list = $t_instance->getTypeList(); if (!isset($va_type_list[$pn_type_id])) { return false; } $t_restriction = new ca_bundle_display_type_restrictions(); if ($this->inTransaction()) { $t_restriction->setTransaction($this->getTransaction()); } $t_restriction->setMode(ACCESS_WRITE); $t_restriction->set('table_num', $this->get('table_num')); $t_restriction->set('type_id', $pn_type_id); $t_restriction->set('display_id', $this->getPrimaryKey()); foreach ($va_settings as $vs_setting => $vs_setting_value) { $t_restriction->setSetting($vs_setting, $vs_setting_value); } $t_restriction->insert(); if ($t_restriction->numErrors()) { $this->errors = $t_restriction->errors(); return false; } return true; }