1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206:
<?php
class ExtendedField
{
const READ_PROFILE_AUTHORIZATION = 1;
const READ_EDIT_AND_ADD_AUTHORIZATION = 2;
private $id;
private $name;
private $position;
private $field_name;
private $field_type;
private $description;
private $possible_values;
private $default_value;
private $required;
private $display;
private $regex;
private $freeze;
private $authorization;
private $is_not_installer = false;
public function set_id($id)
{
$this->id = $id;
}
public function get_id()
{
return !empty($this->id) ? $this->id : 0;
}
public function set_name($name)
{
$this->name = $name;
}
public function get_name()
{
return !empty($this->name) ? $this->name : '';
}
public function set_position($position)
{
$this->position = $position;
}
public function get_position()
{
if (empty($this->position))
{
$request = PersistenceContext::get_querier()->get_column_value(DB_TABLE_MEMBER_EXTENDED_FIELDS_LIST, 'MAX(position) + 1', '');
$this->position = !empty($request) ? $request : 1;
}
return $this->position;
}
public function set_field_name($field_name)
{
$this->field_name = $field_name;
}
public function get_field_name()
{
if (empty($this->field_name) && !empty($this->name))
{
$this->field_name = $this->rewrite_field_name($this->name);
}
return !empty($this->field_name) ? $this->field_name : '';
}
public function set_description($description)
{
$this->description = $description;
}
public function get_description()
{
return !empty($this->description) ? $this->description : '';
}
public function set_field_type($field_type)
{
$this->field_type = $field_type;
}
public function get_field_type()
{
return $this->field_type;
}
public function set_possible_values($possible_values)
{
$this->possible_values = $possible_values;
}
public function get_possible_values()
{
return !empty($this->possible_values) ? $this->possible_values : '';
}
public function set_default_value($default_value)
{
$this->default_value = $default_value;
}
public function get_default_value()
{
return !empty($this->default_value) ? $this->default_value : '';
}
public function set_is_required($required)
{
$this->required = $required;
}
public function get_required()
{
return !empty($this->required) ? $this->required : false;
}
public function set_display($values)
{
$this->display = $values;
}
public function get_display()
{
return !empty($this->display) ? $this->display : false;
}
public function set_regex($regex)
{
$this->regex = $regex;
}
public function get_regex()
{
return !empty($this->regex) ? $this->regex : 0;
}
public function set_is_freeze($freeze)
{
$this->freeze = $freeze;
}
public function get_is_freeze()
{
return !empty($this->freeze) ? $this->freeze : false;
}
public function set_authorization($authorization)
{
$this->authorization = $authorization;
}
public function get_authorization()
{
return !empty($this->authorization) ? $this->authorization : array('r1' => 3, 'r0' => 3, 'r-1' => 2);
}
public function set_is_not_installer($is_not_installer)
{
$this->is_not_installer = $is_not_installer;
}
public function get_is_not_installer()
{
return $this->is_not_installer;
}
public function get_instance()
{
$field_type = $this->get_field_type();
if (!empty($field_type))
{
$class = (string)$field_type;
return new $class();
}
}
public static function rewrite_field_name($field_name)
{
$field = TextHelper::strtolower($field_name);
$field = Url::encode_rewrite($field);
$field = str_replace('-', '_', $field);
return 'f_' . $field;
}
}
?>