21 defined(
'XOOPS_ROOT_PATH') or die("XOOPS root path not defined");
29 function __construct()
59 function setVar($key, $value, $not_gpc =
false)
61 if ($key ==
'field_options' && is_array($value)) {
62 foreach (array_keys($value) as $idx ) {
63 $value[$idx] = base64_encode($value[$idx]);
66 parent::setVar($key, $value, $not_gpc);
69 function getVar($key, $format =
's')
71 $value = parent::getVar($key, $format);
72 if ($key ==
'field_options' && !empty($value)) {
73 foreach (array_keys($value) as $idx) {
74 $value[$idx] = base64_decode($value[$idx]);
90 $value = in_array($this->getVar(
'field_name'), $this->getUserVars() ) ?
$user->getVar($this->getVar(
'field_name'),
'e') :
$profile->getVar($this->getVar(
'field_name'),
'e');
92 $caption = $this->getVar(
'field_title');
93 $caption = defined($caption) ? constant($caption) : $caption;
94 $name = $this->getVar(
'field_name',
'e');
95 $options = $this->getVar(
'field_options');
99 foreach (array_keys(
$options) as $key) {
101 $optkey = defined($key) ? constant($key) : $key;
106 include_once
$GLOBALS[
'xoops']->path(
'class/xoopsformloader.php');
107 switch ($this->getVar(
'field_type') ) {
115 $element =
new XoopsFormText($caption, $name, 35, $this->getVar(
'field_maxlength'), $value);
129 if (!in_array(
'', array_keys(
$options))) {
130 $element->addOption(
'',
_NONE);
133 $eltmsg = str_replace(
'"',
'\"', stripslashes($eltmsg));
134 $element->customValidationCode[] =
"\nvar hasSelected = false; var selectBox = myform.{$name};" .
135 "for (i = 0; i < selectBox.options.length; i++ ) { if ( selectBox.options[i].selected == true && selectBox.options[i].value != '' ) { hasSelected = true; break; } }" .
136 "if ( !hasSelected ) { window.alert(\"{$eltmsg}\"); selectBox.focus(); return false; }";
181 $element =
new XoopsFormDatetime($caption, $name, 15, $value);
185 $element =
new XoopsFormSelectList($caption, $name, $value, 1,
$options[0]);
190 $element->setExtra(
"style='width: 280px;'");
196 include_once
$GLOBALS[
'xoops']->path(
'class/xoopslists.php');
197 $ranks = XoopsLists::getUserRankList();
198 $element->addOption(0,
"--------------");
199 $element->addOptionArray($ranks);
208 if (is_dir(
XOOPS_THEME_PATH .
'/' .
$file) && !preg_match(
"/^[.]{1,2}$/", $file) && strtolower($file) !=
'cvs' ) {
209 if (file_exists(
XOOPS_THEME_PATH .
"/" . $file .
"/theme.html") && in_array($file,
$GLOBALS[
'xoopsConfig'][
'theme_set_allowed'])) {
221 if ($this->getVar(
'field_description') !=
"") {
222 $element->setDescription($this->getVar(
'field_description') );
237 if (file_exists(
$file =
$GLOBALS[
'xoops']->path(
'modules/profile/language/' .
$GLOBALS[
'xoopsConfig'][
'language'] .
'/modinfo.php'))) {
240 include_once
$GLOBALS[
'xoops']->path(
'modules/profile/language/english/modinfo.php');
243 $value = in_array($this->getVar(
'field_name'), $this->getUserVars() ) ?
$user->getVar($this->getVar(
'field_name') ) :
$profile->getVar($this->getVar(
'field_name'));
245 switch ($this->getVar(
'field_type') ) {
248 if ( $this->getVar(
'field_name') ==
'url' && $value !=
'') {
249 return '<a href="' .
formatURL($value) .
'" rel="external">' . $value .
'</a>';
264 $options = $this->getVar(
'field_options');
275 $options = $this->getVar(
'field_options');
278 foreach (array_keys(
$options) as $key) {
279 if (in_array($key, $value)) {
298 foreach (array_keys(
$options) as $key) {
299 if (in_array($key, $value)) {
309 return str_replace(
"-",
"/", $value);
316 if (!empty($value)) {
324 $value =
$user->getVar($this->getVar(
'field_name'),
'n');
325 $value = str_replace(
"{X_UID}",
$user->getVar(
"uid"), $value);
326 $value = str_replace(
"{X_URL}", XOOPS_URL, $value );
327 $value = str_replace(
"{X_UNAME}",
$user->getVar(
"uname"), $value);
332 $userrank =
$user->rank();
333 $user_rankimage =
"";
334 if (isset($userrank[
'image']) && $userrank[
'image'] !=
"") {
335 $user_rankimage =
'<img src="'.XOOPS_UPLOAD_URL .
'/' . $userrank[
'image'] .
'" alt="' . $userrank[
'title'] .
'" /><br />';
337 return $user_rankimage.$userrank[
'title'];
345 include_once
$GLOBALS[
'xoops']->path(
'class/xoopslists.php');
346 $timezones = XoopsLists::getTimeZoneList();
347 $value = empty($value) ?
"0" : strval($value);
348 return $timezones[str_replace(
'.0',
'', $value)];
360 function getValueForSave($value)
362 switch ($this->getVar(
'field_type')) {
381 return (array) $value;
385 return strtotime($value);
391 if (!empty($value)) {
392 return strtotime($value[
'date']) + intval($value[
'time']);
404 function getUserVars()
424 parent::__construct(
$db,
'profile_field',
"profilefield",
"field_id",
'field_title');
437 if (!empty($force_update) || count(
$fields) == 0) {
438 $this->table_link = $this->db->prefix(
'profile_category');
440 $criteria->setSort(
'l.cat_weight ASC, o.field_weight');
442 foreach (array_keys($field_objs) as
$i ) {
443 $fields[$field_objs[
$i]->getVar(
'field_name')] = $field_objs[
$i];
460 $obj->setVar(
'field_name', str_replace(
' ',
'_', $obj->getVar(
'field_name')));
463 switch ($obj->getVar(
'field_type') ) {
467 $obj->setVar(
'field_maxlength', 10);
476 $obj->setVar(
'field_maxlength', 1);
509 if ($obj->getVar(
'field_valuetype') ==
"") {
513 if ((!in_array($obj->getVar(
'field_name'), $this->
getUserVars())) && (isset(
$_REQUEST[
'field_required']))) {
519 $changetype =
"CHANGE `" . $obj->getVar(
'field_name',
'n') .
"`";
521 $maxlengthstring = $obj->getVar(
'field_maxlength') > 0 ?
"(" . $obj->getVar(
'field_maxlength') .
")" :
"";
524 switch ($obj->getVar(
'field_valuetype')) {
528 $type =
"mediumtext";
538 if (!$maxlengthstring) {
540 $maxlengthstring =
"(255)";
541 $obj->setVar(
'field_maxlength', 255);
550 $type =
"decimal(14,6)";
554 $type =
"float(15,9)";
561 $maxlengthstring =
"";
566 $maxlengthstring =
"";
571 $changetype .
" `" . $obj->cleanVars[
'field_name'] .
"` " .
$type . $maxlengthstring .
' NULL';
572 if (!$this->db->query(
$sql)) {
579 if (!parent::insert($obj, $force)) {
582 return $obj->getVar(
'field_id');
593 function delete(&$obj, $force =
false)
597 $sql =
"ALTER TABLE " .
$profile_handler->table .
" DROP `" . $obj->getVar(
'field_name',
'n') .
"`";
598 if ($this->db->query(
$sql)) {
600 if (!parent::delete($obj, $force)) {
604 if ($obj->getVar(
'field_show') || $obj->getVar(
'field_edit')) {
607 if (is_object($profile_module)) {
612 return $groupperm_handler->deleteAll(
$criteria);
626 return array(
'uid',
'uname',
'name',
'email',
'url',
'user_avatar',
'user_regdate',
'user_icq',
'user_from',
627 'user_sig',
'user_viewemail',
'actkey',
'user_aim',
'user_yim',
'user_msnm',
'pass',
'posts',
628 'attachsig',
'rank',
'level',
'theme',
'timezone_offset',
'last_login',
'umode',
'uorder',
629 'notify_method',
'notify_mode',
'user_occ',
'bio',
'user_intrest',
'user_mailok');