/** * Constructor * * @param string $caption * @param string $name * @param mixed $value Pre-selected value (or array of them). * For an item with massive members, such as "Registered Users", "$value" should be used to store selected temporary users only instead of all members of that item * @param bool $include_anon Include user "anonymous"? * @param int $size Number or rows. "1" makes a drop-down-list. * @param bool $multiple Allow multiple selections? */ public function __construct($caption, $name, $include_anon = FALSE, $value = NULL, $size = 1, $multiple = FALSE, $showremovedusers = FALSE, $justremovedusers = FALSE) { $limit = 200; $select_element = new icms_form_elements_Select('', $name, $value, $size, $multiple); if ($include_anon) { $select_element->addOption(0, $GLOBALS['icmsConfig']['anonymous']); } $member_handler = icms::handler('icms_member'); $user_count = $member_handler->getUserCount(); $value = is_array($value) ? $value : (empty($value) ? array() : array($value)); if ($user_count > $limit && count($value) > 0) { $criteria = new icms_db_criteria_Compo(new icms_db_criteria_Item("uid", "(" . implode(",", $value) . ")", "IN")); } else { $criteria = new icms_db_criteria_Compo(); $criteria->setLimit($limit); } $criteria->setSort('uname'); if (!$showremovedusers) { $criteria->add(new icms_db_criteria_Item('level', '-1', '!=')); } elseif ($showremovedusers && $justremovedusers) { $criteria->add(new icms_db_criteria_Item('level', '-1')); } $criteria->setOrder('ASC'); $users = $member_handler->getUserList($criteria); $select_element->addOptionArray($users); if ($user_count <= $limit) { parent::__construct($caption, "", $name); $this->addElement($select_element); return; } icms_loadLanguageFile('core', 'findusers'); $js_addusers = "<script type=\"text/javascript\">\r\n\t\t\t\t\tfunction addusers(opts){\r\n\t\t\t\t\t\tvar num = opts.substring(0, opts.indexOf(\":\"));\r\n\t\t\t\t\t\topts = opts.substring(opts.indexOf(\":\")+1, opts.length);\r\n\t\t\t\t\t\tvar sel = xoopsGetElementById(\"" . $name . ($multiple ? "[]" : "") . "\");\r\n\t\t\t\t\t\tvar arr = new Array(num);\r\n\t\t\t\t\t\tfor (var n=0; n < num; n++) {\r\n\t\t\t\t\t\t\tvar nm = opts.substring(0, opts.indexOf(\":\"));\r\n\t\t\t\t\t\t\topts = opts.substring(opts.indexOf(\":\")+1, opts.length);\r\n\t\t\t\t\t\t\tvar val = opts.substring(0, opts.indexOf(\":\"));\r\n\t\t\t\t\t\t\topts = opts.substring(opts.indexOf(\":\")+1, opts.length);\r\n\t\t\t\t\t\t\tvar txt = opts.substring(0, nm - val.length);\r\n\t\t\t\t\t\t\topts = opts.substring(nm - val.length, opts.length);\r\n\t\t\t\t\t\t\tvar added = false;\r\n\t\t\t\t\t\t\tfor (var k = 0; k < sel.options.length; k++) {\r\n\t\t\t\t\t\t\t\tif (sel.options[k].value == val){\r\n\t\t\t\t\t\t\t\t\tadded = true;\r\n\t\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\tif (added == false) {\r\n\t\t\t\t\t\t\t\tsel.options[k] = new Option(txt, val);\r\n\t\t\t\t\t\t\t\tsel.options[k].selected = true;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\treturn true;\r\n\t\t\t\t\t}\r\n\t\t\t\t\t</script>"; $token = icms::$security->createToken(); $action_tray = new icms_form_elements_Tray("", " | "); $action_tray->addElement(new icms_form_elements_Label('', "<a href='#' onclick='var sel = xoopsGetElementById(\"" . $name . ($multiple ? "[]" : "") . "\");for (var i = sel.options.length-1; i >= 0; i--) {if (!sel.options[i].selected) {sel.options[i] = null;}}; return false;'>" . _MA_USER_REMOVE . "</a>")); $action_tray->addElement(new icms_form_elements_Label('', "<a href='#' onclick='openWithSelfMain(\"" . ICMS_URL . "/include/findusers.php?target={$name}&multiple={$multiple}&token={$token}\", \"userselect\", 800, 600, null); return false;' >" . _MA_USER_MORE . "</a>" . $js_addusers)); parent::__construct($caption, '<br /><br />', $name); $this->addElement($select_element); $this->addElement($action_tray); }
/** * Returns a {@link icms_form_Element} for editing the value of this field * * @param icms_member_user_Object $user {@link icms_member_user_Object} object to edit the value of * @param mod_profile_Profile $profile {@link mod_profile_Profile} object to edit the value of * * @return icms_form_Element */ public function getEditElement($user, $profile) { $value = in_array($this->getVar('field_name'), $this->getUserVars()) ? $user->getVar($this->getVar('field_name'), 'e') : $profile->getVar($this->getVar('field_name'), 'e'); if ($value === null) { $value = $this->getVar('field_default'); } $caption = $this->getVar('field_title'); $caption = defined($caption) ? constant($caption) : $caption; $name = $this->getVar('field_name', 'e'); $options = unserialize($this->getVar('field_options', 'n')); if ($this->getVar('field_type') != "image" && is_array($options)) { asort($options); foreach (array_keys($options) as $key) { $optval = defined($options[$key]) ? constant($options[$key]) : $options[$key]; $optkey = defined($key) ? constant($key) : $key; unset($options[$key]); $options[$optkey] = $optval; } } switch ($this->getVar('field_type')) { case "autotext": $element = new icms_form_elements_Label($caption, $value); break; case "textarea": $element = new icms_form_elements_Textarea($caption, $name, $value, 4, 30); break; case "dhtml": $element = new icms_form_elements_Dhtmltextarea($caption, $name, $value, 10, 30); break; case "select": $element = new icms_form_elements_Select($caption, $name, $value); $element->addOptionArray($options); break; case "select_multi": $element = new icms_form_elements_Select($caption, $name, $value, 5, true); $element->addOptionArray($options); break; case "radio": $element = new icms_form_elements_Radio($caption, $name, $value); $element->addOptionArray($options); break; case "checkbox": $element = new icms_form_elements_Checkbox($caption, $name, $value); $element->addOptionArray($options); break; case "yesno": $element = new icms_form_elements_Radioyn($caption, $name, $value); break; case "group": $element = new icms_form_elements_select_Group($caption, $name, true, $value); break; case "group_multi": $element = new icms_form_elements_select_Group($caption, $name, true, $value, 5, true); break; case "language": $element = new icms_form_elements_select_Lang($caption, $name, $value); break; case "date": $element = new icms_form_elements_Date($caption, $name, 15, $value); break; case "longdate": $element = new icms_form_elements_Date($caption, $name, 15, str_replace("-", "/", $value)); break; case "datetime": $element = new icms_form_elements_Datetime($caption, $name, 15, $value); break; case "timezone": $element = new icms_form_elements_select_Timezone($caption, $name, $value); $element->setExtra("style='width: 280px;'"); break; case "rank": $element = new icms_form_elements_Select($caption, $name, $value); $ranks = icms_getModuleHandler("userrank", "system")->getList(icms_buildCriteria(array("rank_special" => 1))); $element->addOption(0, "--------------"); $element->addOptionArray($ranks); break; case "theme": $element = new icms_form_elements_Select($caption, $name, $value); $element->addOption("0", _MD_PROFILE_SITEDEFAULT); $handle = opendir(ICMS_THEME_PATH . '/'); $dirlist = array(); while (false !== ($file = readdir($handle))) { if (is_dir(ICMS_THEME_PATH . '/' . $file) && !preg_match("/^[.]{1,2}\$/", $file) && strtolower($file) != 'cvs') { if (file_exists(ICMS_THEME_PATH . '/' . $file . '/theme.html') && in_array($file, $GLOBALS['icmsConfig']['theme_set_allowed'])) { $dirlist[$file] = $file; } } } closedir($handle); if (!empty($dirlist)) { asort($dirlist); $element->addOptionArray($dirlist); } break; case "image": $element = new icms_form_elements_File($caption, $name, $options['maxsize'] * 1024); if ($value != "") { $this->assignVar('field_description', ""); $element->setDescription($this->getOutputValue($user, $profile)); } break; case "openid": if ($icmsConfigAuth['auth_openid'] != 1) { break; } $element = new icms_form_elements_Text($caption, $name, 35, $this->getVar('field_maxlength'), $value); break; case "textbox": default: $element = new icms_form_elements_Text($caption, $name, 35, $this->getVar('field_maxlength'), $value); break; } if ($this->getVar('field_description') != '') { $element->setDescription($this->getVar('field_description')); } return $element; }
$opcount = count($options); for ($j = 0; $j < $opcount; $j++) { $optval = defined($options[$j]->getVar('confop_value')) ? constant($options[$j]->getVar('confop_value')) : $options[$j]->getVar('confop_value'); $optkey = defined($options[$j]->getVar('confop_name')) ? constant($options[$j]->getVar('confop_name')) : $options[$j]->getVar('confop_name'); $ele->addOption($optval, $optkey); } break; case 'select_multi' : $ele = new icms_form_elements_Select($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput(), 5, TRUE); $options = & $config_handler->getConfigOptions(new icms_db_criteria_Item('conf_id', $config[$i]->getVar('conf_id'))); $opcount = count($options); for ($j = 0; $j < $opcount; $j++) { $optval = defined($options[$j]->getVar('confop_value')) ? constant($options[$j]->getVar('confop_value')) : $options[$j]->getVar('confop_value'); $optkey = defined($options[$j]->getVar('confop_name')) ? constant($options[$j]->getVar('confop_name')) : $options[$j]->getVar('confop_name'); $ele->addOption($optval, $optkey); } break; case 'yesno' : $ele = new icms_form_elements_Radioyn($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput(), _YES, _NO); break; case 'group' : $ele = new icms_form_elements_select_Group($title, $config[$i]->getVar('conf_name'), TRUE, $config[$i]->getConfValueForOutput(), 1, FALSE); break; case 'group_multi' : $ele = new icms_form_elements_select_Group($title, $config[$i]->getVar('conf_name'), TRUE, $config[$i]->getConfValueForOutput(), 5, TRUE); break;
$umode_select = new icms_form_elements_Select(_US_CDISPLAYMODE, "umode", $umode_value); $umode_select->addOptionArray(array("nest" => _NESTED, "flat" => _FLAT, "thread" => _THREADED)); $uorder_select = new icms_form_elements_Select(_US_CSORTORDER, "uorder", $uorder_value); $uorder_select->addOptionArray(array("0" => _OLDESTFIRST, "1" => _NEWESTFIRST)); // RMV-NOTIFY icms_loadLanguageFile('core', 'notification'); include_once ICMS_ROOT_PATH . '/include/notification_constants.php'; $notify_method_select = new icms_form_elements_Select(_NOT_NOTIFYMETHOD, 'notify_method', $notify_method_value); $notify_method_select->addOptionArray(array(XOOPS_NOTIFICATION_METHOD_DISABLE => _NOT_METHOD_DISABLE, XOOPS_NOTIFICATION_METHOD_PM => _NOT_METHOD_PM, XOOPS_NOTIFICATION_METHOD_EMAIL => _NOT_METHOD_EMAIL)); $notify_mode_select = new icms_form_elements_Select(_NOT_NOTIFYMODE, 'notify_mode', $notify_mode_value); $notify_mode_select->addOptionArray(array(XOOPS_NOTIFICATION_MODE_SENDALWAYS => _NOT_MODE_SENDALWAYS, XOOPS_NOTIFICATION_MODE_SENDONCETHENDELETE => _NOT_MODE_SENDONCE, XOOPS_NOTIFICATION_MODE_SENDONCETHENWAIT => _NOT_MODE_SENDONCEPERLOGIN)); $bio_tarea = new icms_form_elements_Textarea(_US_EXTRAINFO, "bio", $bio_value); $rank_select = new icms_form_elements_Select(_AM_RANK, "rank", $rank_value); $ranklist = icms_getModuleHandler("userrank", "system")->getList(icms_buildCriteria(array('rank_special' => '1'))); if (count($ranklist) > 0) { $rank_select->addOption(0, "--------------"); $rank_select->addOptionArray($ranklist); } else { $rank_select->addOption(0, _AM_NSRID); } global $icmsConfigUser; $pwd_text = new icms_form_elements_Password(_AM_PASSWORD, "password", 10, 255, '', false, $icmsConfigUser['pass_level'] ? 'password_adv' : ''); $pwd_text2 = new icms_form_elements_Password(_AM_RETYPEPD, "pass2", 10, 255); $mailok_radio = new icms_form_elements_Radioyn(_US_MAILOK, 'user_mailok', (int) $mailok_value); $language = new icms_form_elements_select_Lang(_US_SELECT_LANG, 'language', $language_value); // Groups administration addition XOOPS 2.0.9: Mith $gperm_handler = icms::handler('icms_member_groupperm'); //If user has admin rights on groups if ($gperm_handler->checkRight("system_admin", XOOPS_SYSTEM_GROUP, icms::$user->getGroups(), 1)) { //add group selection if (in_array(XOOPS_GROUP_ADMIN, icms::$user->getGroups())) {
$title_of_form = _AM_PROFILE_PROF_EDITABLE; $perm_name = "profile_edit"; $restriction = "field_edit"; $anonymous = false; break; case "search": $title_of_form = _AM_PROFILE_PROF_SEARCH; $perm_name = "profile_search"; $restriction = ""; $anonymous = true; break; } $opform = new icms_form_Simple('', 'opform', 'permissions.php', "get"); $op_select = new icms_form_elements_Select("", 'op', $op); $op_select->setExtra('onchange="document.forms.opform.submit()"'); $op_select->addOption('edit', _AM_PROFILE_PROF_EDITABLE); $op_select->addOption('search', _AM_PROFILE_PROF_SEARCH); $opform->addElement($op_select); $opform->display(); $form = new icms_form_Groupperm($title_of_form, icms::$module->getVar('mid'), $perm_name, '', 'admin/permissions.php', $anonymous); $profile_handler = icms_getmodulehandler('profile', basename(dirname(dirname(__FILE__))), 'profile'); $fields = $profile_handler->loadFields(); if ($op == "search") { $searchable_types = array('textbox', 'select', 'radio', 'yesno', 'date', 'datetime', 'timezone', 'language'); foreach (array_keys($fields) as $i) { if (in_array($fields[$i]->getVar('field_type'), $searchable_types)) { $form->addItem($fields[$i]->getVar('fieldid'), $fields[$i]->getVar('field_title')); } } } else { foreach (array_keys($fields) as $i) {
$sig_cbox = new icms_form_elements_Checkbox('', 'attachsig', $sig_cbox_value); $sig_cbox->addOption(1, _US_SHOWSIG); $sig_tray->addElement($sig_cbox); } } $umode_select = new icms_form_elements_Select(_US_CDISPLAYMODE, 'umode', icms::$user->getVar('umode')); $umode_select->addOptionArray(array('nest' => _NESTED, 'flat' => _FLAT, 'thread' => _THREADED)); $uorder_select = new icms_form_elements_Select(_US_CSORTORDER, 'uorder', icms::$user->getVar('uorder')); $uorder_select->addOptionArray(array(XOOPS_COMMENT_OLD1ST => _OLDESTFIRST, XOOPS_COMMENT_NEW1ST => _NEWESTFIRST)); $selected_theme = new icms_form_elements_Select(_US_SELECT_THEME, 'theme_selected', icms::$user->getVar('theme')); foreach ($icmsConfig['theme_set_allowed'] as $theme) { $selected_theme->addOption($theme, $theme); } $selected_language = new icms_form_elements_Select(_US_SELECT_LANG, 'language_selected', icms::$user->getVar('language')); foreach (icms_core_Filesystem::getDirList(ICMS_ROOT_PATH . "/language/") as $language) { $selected_language->addOption($language, $language); } // TODO: add this to admin user-edit functions... icms_loadLanguageFile('core', 'notification'); include_once ICMS_INCLUDE_PATH . '/notification_constants.php'; $notify_method_select = new icms_form_elements_Select(_NOT_NOTIFYMETHOD, 'notify_method', icms::$user->getVar('notify_method')); $notify_method_select->addOptionArray(array(XOOPS_NOTIFICATION_METHOD_DISABLE => _NOT_METHOD_DISABLE, XOOPS_NOTIFICATION_METHOD_PM => _NOT_METHOD_PM, XOOPS_NOTIFICATION_METHOD_EMAIL => _NOT_METHOD_EMAIL)); $notify_mode_select = new icms_form_elements_Select(_NOT_NOTIFYMODE, 'notify_mode', icms::$user->getVar('notify_mode')); $notify_mode_select->addOptionArray(array(XOOPS_NOTIFICATION_MODE_SENDALWAYS => _NOT_MODE_SENDALWAYS, XOOPS_NOTIFICATION_MODE_SENDONCETHENDELETE => _NOT_MODE_SENDONCE, XOOPS_NOTIFICATION_MODE_SENDONCETHENWAIT => _NOT_MODE_SENDONCEPERLOGIN)); $bio_tarea = new icms_form_elements_Textarea(_US_EXTRAINFO, 'bio', icms::$user->getVar('bio', 'E')); $cookie_radio_value = empty($_COOKIE[$icmsConfig['usercookie']]) ? 0 : 1; $cookie_radio = new icms_form_elements_Radioyn(_US_USECOOKIE, 'usecookie', $cookie_radio_value, _YES, _NO); $pwd_text = new icms_form_elements_Password('', 'password', 10, 255, "", FALSE, $icmsConfigUser['pass_level'] ? 'password_adv' : ''); $pwd_text2 = new icms_form_elements_Password('', 'vpass', 10, 255); $pwd_tray = new icms_form_elements_Tray(_US_PASSWORD . '<br />' . _US_TYPEPASSTWICE); $pwd_tray->addElement($pwd_text);