39 public static function model($className = __CLASS__)
49 return Yii::app()->getModule(
'user')->tableProfileFields;
60 array(
'varname, title, field_type',
'required'),
61 array(
'varname',
'match',
'pattern' =>
'/^[A-Za-z_0-9]+$/u',
'message' =>
UserModule::t(
"Variable name may consist of A-z, 0-9, underscores, begin with a letter.")),
62 array(
'varname',
'unique',
'message' =>
UserModule::t(
"This field already exists.")),
63 array(
'varname, field_type',
'length',
'max' => 50),
64 array(
'field_size_min, required, position, visible',
'numerical',
'integerOnly' =>
true),
65 array(
'field_size',
'match',
'pattern' =>
'/^\s*[-+]?[0-9]*\,*\.?[0-9]+([eE][-+]?[0-9]+)?\s*$/'),
66 array(
'title, match, error_message, other_validator, default, widget',
'length',
'max' => 255),
67 array(
'range, widgetparams',
'length',
'max' => 5000),
68 array(
'id, varname, title, field_type, field_size, field_size_min, required, match, range, error_message, other_validator, default, widget, widgetparams, position, visible',
'safe',
'on' =>
'search'),
112 'condition' =>
'visible='.self::VISIBLE_ALL,
113 'order' =>
'position',
116 'condition' =>
'visible>='.self::VISIBLE_REGISTER_USER,
117 'order' =>
'position',
120 'condition' =>
'visible>='.self::VISIBLE_ONLY_OWNER,
121 'order' =>
'position',
123 'forRegistration' => array(
124 'condition' =>
'required='.self::REQUIRED_NO_SHOW_REG.
' OR required='.self::REQUIRED_YES_SHOW_REG,
125 'order' =>
'position',
128 'order' =>
'position',
140 if ($this->widget && class_exists($this->widget)) {
141 $widgetClass =
new $this->widget();
143 $arr = $this->widgetparams;
145 $newParams = $widgetClass->params;
146 $arr = (array) CJavaScript::jsonDecode($arr);
147 foreach ($arr as $p => $v) {
148 if (isset($newParams[$p])) {
152 $widgetClass->params = $newParams;
155 if (method_exists($widgetClass,
'viewAttribute')) {
156 return $widgetClass->viewAttribute($model, $this);
165 if ($this->widget && class_exists($this->widget)) {
166 $widgetClass =
new $this->widget();
168 $arr = $this->widgetparams;
170 $newParams = $widgetClass->params;
171 $arr = (array) CJavaScript::jsonDecode($arr);
172 foreach ($arr as $p => $v) {
173 if (isset($newParams[$p])) {
177 $widgetClass->params = $newParams;
180 if (method_exists($widgetClass,
'editAttribute')) {
181 return $widgetClass->editAttribute($model, $this, $params);
191 'field_type' => array(
204 self::REQUIRED_NO_SHOW_REG =>
UserModule::t(
'No, but show on registration form'),
205 self::REQUIRED_YES_SHOW_REG =>
UserModule::t(
'Yes and show on registration form'),
210 self::VISIBLE_REGISTER_USER =>
UserModule::t(
'Registered users'),
216 return isset($_items[$type][$code]) ? $_items[$type][$code] :
false;
218 return isset($_items[$type]) ? $_items[$type] :
false;
232 $criteria =
new CDbCriteria();
234 $criteria->compare(
'id', $this->
id);
235 $criteria->compare(
'varname', $this->varname,
true);
236 $criteria->compare(
'title', $this->title,
true);
237 $criteria->compare(
'field_type', $this->field_type,
true);
238 $criteria->compare(
'field_size', $this->field_size);
239 $criteria->compare(
'field_size_min', $this->field_size_min);
240 $criteria->compare(
'required', $this->required);
241 $criteria->compare(
'match', $this->match,
true);
242 $criteria->compare(
'range', $this->range,
true);
243 $criteria->compare(
'error_message', $this->error_message,
true);
244 $criteria->compare(
'other_validator', $this->other_validator,
true);
245 $criteria->compare(
'default', $this->
default,
true);
246 $criteria->compare(
'widget', $this->widget,
true);
247 $criteria->compare(
'widgetparams', $this->widgetparams,
true);
248 $criteria->compare(
'position', $this->position);
249 $criteria->compare(
'visible', $this->visible);
251 return new CActiveDataProvider(get_class($this), array(
252 'criteria' => $criteria,
253 'pagination' => array(
254 'pageSize' => Yii::app()->controller->module->fields_page_size,
257 'defaultOrder' =>
'position',