1
0
Fork 0
mirror of https://github.com/Oreolek/ifhub.club.git synced 2024-06-16 23:00:51 +03:00

Дефолтные значения в дополнительных полях для типов - число, дробь, строка, чекбокс

This commit is contained in:
Mzhelskiy Maxim 2014-10-27 18:55:56 +07:00
parent 0d7f14d353
commit 1757f80333
9 changed files with 89 additions and 9 deletions

View file

@ -33,6 +33,13 @@ class ModuleProperty_EntityValueTypeCheckbox extends ModuleProperty_EntityValueT
return (bool)$this->getValueObject()->getValueInt();
}
public function getValueForForm()
{
$oValue = $this->getValueObject();
$oProperty = $oValue->getProperty();
return $oValue->_isNew() ? $oProperty->getParam('default') : $oValue->getValueInt();
}
public function validate()
{
return $this->validateStandart('boolean');
@ -44,4 +51,23 @@ class ModuleProperty_EntityValueTypeCheckbox extends ModuleProperty_EntityValueT
$oValue = $this->getValueObject();
$oValue->setValueInt($mValue ? 1 : 0);
}
public function prepareParamsRaw($aParamsRaw)
{
$aParams = array();
$aParams['default'] = isset($aParamsRaw['default']) ? true : false;
if (isset($aParamsRaw['default_value'])) {
$aParams['default_value'] = htmlspecialchars($aParamsRaw['default_value']);
}
return $aParams;
}
public function getParamsDefault()
{
return array(
'default_value' => 1,
);
}
}

View file

@ -33,6 +33,13 @@ class ModuleProperty_EntityValueTypeFloat extends ModuleProperty_EntityValueType
return $this->getValueObject()->getValueFloat();
}
public function getValueForForm()
{
$oValue = $this->getValueObject();
$oProperty = $oValue->getProperty();
return $oValue->_isNew() ? $oProperty->getParam('default') : $oValue->getValueFloat();
}
public function validate()
{
return $this->validateStandart('number', array('integerOnly' => false));
@ -58,4 +65,15 @@ class ModuleProperty_EntityValueTypeFloat extends ModuleProperty_EntityValueType
}
return $aRules;
}
public function prepareParamsRaw($aParamsRaw)
{
$aParams = array();
if (isset($aParamsRaw['default'])) {
$aParams['default'] = htmlspecialchars($aParamsRaw['default']);
}
return $aParams;
}
}

View file

@ -33,6 +33,13 @@ class ModuleProperty_EntityValueTypeInt extends ModuleProperty_EntityValueType
return $this->getValueObject()->getValueInt();
}
public function getValueForForm()
{
$oValue = $this->getValueObject();
$oProperty = $oValue->getProperty();
return $oValue->_isNew() ? $oProperty->getParam('default') : $oValue->getValueInt();
}
public function validate()
{
return $this->validateStandart('number', array('integerOnly' => true));
@ -58,4 +65,15 @@ class ModuleProperty_EntityValueTypeInt extends ModuleProperty_EntityValueType
}
return $aRules;
}
public function prepareParamsRaw($aParamsRaw)
{
$aParams = array();
if (isset($aParamsRaw['default'])) {
$aParams['default'] = htmlspecialchars($aParamsRaw['default']);
}
return $aParams;
}
}

View file

@ -33,6 +33,13 @@ class ModuleProperty_EntityValueTypeVarchar extends ModuleProperty_EntityValueTy
return $this->getValueObject()->getValueVarchar();
}
public function getValueForForm()
{
$oValue = $this->getValueObject();
$oProperty = $oValue->getProperty();
return $oValue->_isNew() ? $oProperty->getParam('default') : $oValue->getValueVarchar();
}
public function validate()
{
return $this->validateStandart('string');
@ -58,4 +65,15 @@ class ModuleProperty_EntityValueTypeVarchar extends ModuleProperty_EntityValueTy
}
return $aRules;
}
public function prepareParamsRaw($aParamsRaw)
{
$aParams = array();
if (isset($aParamsRaw['default'])) {
$aParams['default'] = htmlspecialchars($aParamsRaw['default']);
}
return $aParams;
}
}

View file

@ -317,7 +317,7 @@ class ModuleRbac extends ModuleORM
}
/**
* Загружает в кеш разрешения
* Загружает в кеш разрешения
*/
protected function LoadPermissions()
{
@ -403,9 +403,9 @@ class ModuleRbac extends ModuleORM
return false;
}
if (!($oRoleUser = $this->Rbac_GetRoleUserByFilter(array(
'role_id' => $oRole->getId(),
'user_id' => $iUserId
)))
'role_id' => $oRole->getId(),
'user_id' => $iUserId
)))
) {
/**
* Добавляем

View file

@ -1,6 +1,6 @@
{include "components/field/field.checkbox.tpl"
name = "property[{$property->getId()}]"
value = 1
checked = $property->getValue()->getValueInt()
value = $property->getParam( 'default_value' )
checked = $property->getValue()->getValueForForm()
note = $property->getDescription()
label = $property->getTitle()}

View file

@ -1,6 +1,6 @@
{include "components/field/field.text.tpl"
name = "property[{$property->getId()}]"
value = $property->getValue()->getValueFloat()
value = $property->getValue()->getValueForForm()
classes = 'width-150'
note = $property->getDescription()
label = $property->getTitle()}

View file

@ -1,6 +1,6 @@
{include "components/field/field.text.tpl"
name = "property[{$property->getId()}]"
value = $property->getValue()->getValueInt()
value = $property->getValue()->getValueForForm()
classes = 'width-150'
note = $property->getDescription()
label = $property->getTitle()}

View file

@ -1,5 +1,5 @@
{include "components/field/field.text.tpl"
name = "property[{$property->getId()}]"
value = $property->getValue()->getValueVarchar()
value = $property->getValue()->getValueForForm()
note = $property->getDescription()
label = $property->getTitle()}