Ejemplo n.º 1
0
 /**
  * @param null $obj
  */
 public function __construct($object = null)
 {
     $this->object = $object;
     $this->config = $object->config;
     $xoops = Xoops::getInstance();
     parent::__construct('', 'xcaptchaform', $xoops->getEnv('PHP_SELF'), 'post', true, 'horizontal');
     $activate = new Xoops\Form\Radio(_AM_XCAPTCHA_ACTIVATE, 'disabled', $this->config['disabled']);
     $activate->addOption(1, _AM_XCAPTCHA_ENABLE);
     $activate->addOption(0, _AM_XCAPTCHA_DISABLE);
     $this->addElement($activate, false);
     $plugin_List = new Xoops\Form\Select(_AM_XCAPTCHA_PLUGINS, 'mode', $this->config['mode']);
     $plugin_List->addOptionArray($this->object->plugin_List);
     $this->addElement($plugin_List, false);
     $this->addElement(new Xoops\Form\Text(_AM_XCAPTCHA_NAME, 'name', 50, 50, $this->config['name']), true);
     $skipmember = new Xoops\Form\Radio(_AM_XCAPTCHA_SKIPMEMBER, 'skipmember', $this->config['skipmember']);
     $skipmember->addOption(1, _AM_XCAPTCHA_ENABLE);
     $skipmember->addOption(0, _AM_XCAPTCHA_DISABLE);
     $this->addElement($skipmember, false);
     $this->addElement(new Xoops\Form\Text(_AM_XCAPTCHA_MAXATTEMPTS, 'maxattempts', 2, 2, $this->config['maxattempts']), true);
     $this->addElement(new Xoops\Form\Hidden('type', 'config'));
     $buttonTray = new Xoops\Form\ElementTray('', '');
     $buttonTray->addElement(new Xoops\Form\Hidden('op', 'save'));
     $buttonTray->addElement(new Xoops\Form\Button('', 'submit', XoopsLocale::A_SUBMIT, 'submit'));
     $buttonTray->addElement(new Xoops\Form\Button('', 'reset', XoopsLocale::A_RESET, 'reset'));
     $buttonCancelSend = new Xoops\Form\Button('', 'cancel', XoopsLocale::A_CANCEL, 'button');
     $buttonCancelSend->setExtra("onclick='javascript:history.go(-1);'");
     $buttonTray->addElement($buttonCancelSend);
     $this->addElement($buttonTray);
 }
Ejemplo n.º 2
0
         } else {
             if ($send2 == 1) {
                 $form->addElement(new Xoops\Form\Label(_PM_TO, XoopsUser::getUnameFromId($to_userid, false)));
                 $form->addElement(new Xoops\Form\Hidden('to_userid', $to_userid));
             } else {
                 $form->addElement(new Xoops\Form\SelectUser(_PM_TO, 'to_userid'));
             }
             $subject = "";
             $message = "";
         }
     }
     $form->addElement(new Xoops\Form\Text(_PM_SUBJECTC, 'subject', 4, 100, $subject), true);
     $icons = new Xoops\Form\Radio(XoopsLocale::MESSAGE_ICON, 'msg_image', '', true);
     $subject_icons = XoopsLists::getSubjectsList();
     foreach (array_keys($subject_icons) as $i) {
         $icons->addOption($i, "<img src='" . $xoops->url("images/subject/") . $i . "' alt='" . $i . "' />");
     }
     $form->addElement($icons, false);
     $form->addElement(new Xoops\Form\DhtmlTextArea(_PM_MESSAGEC, 'message', $message, 8, 37), true);
     $form->addElement(new Xoops\Form\RadioYesNo(_PM_SAVEINOUTBOX, 'savecopy', 0));
     $form->addElement(new Xoops\Form\Hidden('op', 'submit'));
     $buttons = new Xoops\Form\ElementTray('');
     $buttons->addElement(new Xoops\Form\Button('', 'submit', XoopsLocale::A_SUBMIT, 'submit'));
     $buttons->addElement(new Xoops\Form\Button('', 'reset', _PM_CLEAR, 'reset'));
     $cancel_send = new Xoops\Form\Button('', 'cancel', _PM_CANCELSEND, 'button');
     $cancel_send->setExtra("onclick='javascript:window.close();'");
     $buttons->addElement($cancel_send);
     $form->addElement($buttons);
     $tpl->assign('form', $form->render());
     $tpl->display("module:pm/pm_pmlite.tpl");
 }
Ejemplo n.º 3
0
/**
 * Get {@link Xoops\Form\ThemeForm} for editing a user
 *
 * @param XoopsUser $user
 * @param ProfileProfile|null $profile
 * @param bool $action
 * @return Xoops\Form\ThemeForm
 */
function profile_getUserForm(XoopsUser $user, ProfileProfile $profile = null, $action = false)
{
    $xoops = Xoops::getInstance();
    if ($action === false) {
        $action = $_SERVER['REQUEST_URI'];
    }
    $title = $user->isNew() ? _PROFILE_AM_ADDUSER : XoopsLocale::EDIT_PROFILE;
    $form = new Xoops\Form\ThemeForm($title, 'userinfo', $action, 'post', true);
    /* @var $profile_handler ProfileProfileHandler */
    $profile_handler = \Xoops::getModuleHelper('profile')->getHandler('profile');
    // Dynamic fields
    if (!$profile) {
        $profile = $profile_handler->getProfile($user->getVar('uid'));
    }
    // Get fields
    $fields = $profile_handler->loadFields();
    // Get ids of fields that can be edited
    $gperm_handler = $xoops->getHandlerGroupPermission();
    $editable_fields = $gperm_handler->getItemIds('profile_edit', $xoops->user->getGroups(), $xoops->module->getVar('mid'));
    if ($user->isNew() || $xoops->user->isAdmin()) {
        $elements[0][] = array('element' => new Xoops\Form\Text(XoopsLocale::USERNAME, 'uname', 3, $xoops->user->isAdmin() ? 60 : $xoops->getConfig('maxuname'), $user->getVar('uname', 'e')), 'required' => 1);
        $email_text = new Xoops\Form\Text('', 'email', 4, 60, $user->getVar('email'));
    } else {
        $elements[0][] = array('element' => new Xoops\Form\Label(XoopsLocale::USERNAME, $user->getVar('uname')), 'required' => 0);
        $email_text = new Xoops\Form\Label('', $user->getVar('email'));
    }
    $email_tray = new Xoops\Form\ElementTray(XoopsLocale::EMAIL, '<br />');
    $email_tray->addElement($email_text, $user->isNew() || $xoops->user->isAdmin() ? 1 : 0);
    $weights[0][] = 0;
    $elements[0][] = array('element' => $email_tray, 'required' => 0);
    $weights[0][] = 0;
    if ($xoops->user->isAdmin() && $user->getVar('uid') != $xoops->user->getVar('uid')) {
        //If the user is an admin and is editing someone else
        $pwd_text = new Xoops\Form\Password('', 'password', 3, 32);
        $pwd_text2 = new Xoops\Form\Password('', 'vpass', 3, 32);
        $pwd_tray = new Xoops\Form\ElementTray(XoopsLocale::PASSWORD . '<br />' . XoopsLocale::TYPE_NEW_PASSWORD_TWICE_TO_CHANGE_IT);
        $pwd_tray->addElement($pwd_text);
        $pwd_tray->addElement($pwd_text2);
        $elements[0][] = array('element' => $pwd_tray, 'required' => 0);
        //cannot set an element tray required
        $weights[0][] = 0;
        $level_radio = new Xoops\Form\Radio(_PROFILE_MA_USERLEVEL, 'level', $user->getVar('level'));
        $level_radio->addOption(1, _PROFILE_MA_ACTIVE);
        $level_radio->addOption(0, _PROFILE_MA_INACTIVE);
        //$level_radio->addOption(-1, _PROFILE_MA_DISABLED);
        $elements[0][] = array('element' => $level_radio, 'required' => 0);
        $weights[0][] = 0;
    }
    $elements[0][] = array('element' => new Xoops\Form\Hidden('uid', $user->getVar('uid')), 'required' => 0);
    $weights[0][] = 0;
    $elements[0][] = array('element' => new Xoops\Form\Hidden('op', 'save'), 'required' => 0);
    $weights[0][] = 0;
    $cat_handler = \Xoops::getModuleHelper('profile')->getHandler('category');
    $categories = array();
    $all_categories = $cat_handler->getObjects(null, true, false);
    $count_fields = count($fields);
    /* @var ProfileField $field */
    foreach ($fields as $field) {
        if (in_array($field->getVar('field_id'), $editable_fields)) {
            // Set default value for user fields if available
            if ($user->isNew()) {
                $default = $field->getVar('field_default');
                if ($default !== '' && $default !== null) {
                    $user->setVar($field->getVar('field_name'), $default);
                }
            }
            if ($profile->getVar($field->getVar('field_name'), 'n') === null) {
                $default = $field->getVar('field_default', 'n');
                $profile->setVar($field->getVar('field_name'), $default);
            }
            $fieldinfo['element'] = $field->getEditElement($user, $profile);
            $fieldinfo['required'] = $field->getVar('field_required');
            $key = @$all_categories[$field->getVar('cat_id')]['cat_weight'] * $count_fields + $field->getVar('cat_id');
            $elements[$key][] = $fieldinfo;
            $weights[$key][] = $field->getVar('field_weight');
            $categories[$key] = @$all_categories[$field->getVar('cat_id')];
        }
    }
    if ($xoops->isUser() && $xoops->user->isAdmin()) {
        $xoops->loadLanguage('admin', 'profile');
        $gperm_handler = $xoops->getHandlerGroupPermission();
        //If user has admin rights on groups
        include_once $xoops->path('modules/system/constants.php');
        if ($gperm_handler->checkRight('system_admin', XOOPS_SYSTEM_GROUP, $xoops->user->getGroups(), 1)) {
            //add group selection
            $group_select = new Xoops\Form\SelectGroup(XoopsLocale::USER_GROUPS, 'groups', false, $user->getGroups(), 5, true);
            $elements[0][] = array('element' => $group_select, 'required' => 0);
            //set as latest;
            $weights[0][] = $count_fields + 1;
        }
    }
    ksort($elements);
    foreach (array_keys($elements) as $k) {
        array_multisort($weights[$k], SORT_ASC, array_keys($elements[$k]), SORT_ASC, $elements[$k]);
        $title = isset($categories[$k]) ? $categories[$k]['cat_title'] : _PROFILE_MA_DEFAULT;
        $desc = isset($categories[$k]) ? $categories[$k]['cat_description'] : "";
        //$form->addElement(new Xoops\Form\Label("<div class='break'>{$title}</div>", $desc), false);
        $desc = $desc != '' ? ' - ' . $desc : '';
        $form->insertBreak($title . $desc);
        foreach (array_keys($elements[$k]) as $i) {
            $form->addElement($elements[$k][$i]['element'], $elements[$k][$i]['required']);
        }
    }
    $form->addElement(new Xoops\Form\Hidden('uid', $user->getVar('uid')));
    $form->addElement(new Xoops\Form\Button('', 'submit', XoopsLocale::SAVE_CHANGES, 'submit'));
    return $form;
}
Ejemplo n.º 4
0
$tab1->addElement($password, true);
$description = new Xoops\Form\TextArea('Description', 'description', '', 5, 6, 'Your description');
$description->setDescription('Put the description');
$tab1->addElement($description, true);
$description_2 = new Xoops\Form\DhtmlTextArea('Description_2', 'description_2', '', 6, 7);
$description_2->setDescription('Put the description_2');
$tab1->addElement($description_2, true);
$tab2->addElement(new Xoops\Form\RadioYesNo('Yes or No', 'yesorno', 0), false);
$radio_inline = new Xoops\Form\Radio('Radio Inline', 'radio_inline', 1, true);
$radio_inline->addOption(1, 'Radio Inline 1');
$radio_inline->addOption(2, 'Radio Inline 2');
$radio_inline->addOption(3, 'Radio Inline 3');
$radio_inline->setDescription('Description Radio Inline');
$tab2->addElement($radio_inline, false);
$radio = new Xoops\Form\Radio('Radio', 'radio', 2, false);
$radio->addOption(1, 'Radio 1');
$radio->addOption(2, 'Radio 2');
$radio->addOption(3, 'Radio 3');
$radio->setDescription('Description Radio');
$tab2->addElement($radio, false);
$checkbox_inline = new Xoops\Form\Checkbox('Checkbox Inline', 'checkbox_inline', 1, true);
$checkbox_inline->addOption(1, 'Checkbox Inline 1');
$checkbox_inline->addOption(2, 'Checkbox Inline 2');
$checkbox_inline->addOption(3, 'Checkbox Inline 3');
$checkbox_inline->setDescription('Description Checkbox Inline');
$tab3->addElement($checkbox_inline, true);
$checkbox = new Xoops\Form\Checkbox('Checkbox', 'checkbox', 2, false);
$checkbox->addOption(1, 'Checkbox 1');
$checkbox->addOption(2, 'Checkbox 2');
$checkbox->addOption(3, 'Checkbox 3');
$checkbox->setDescription('Description Checkbox');
Ejemplo n.º 5
0
                 unset($element);
                 break;
             case "language":
                 $element = new Xoops\Form\SelectLanguage($fields[$i]->getVar('field_title'), $fields[$i]->getVar('field_name'), null, 6);
                 $searchform->addElement($element);
                 unset($element);
                 break;
         }
     }
     asort($sortby_arr);
     $sortby_arr = array_merge(array("" => XoopsLocale::NONE, "uname" => XoopsLocale::USERNAME, "email" => XoopsLocale::EMAIL), $sortby_arr);
     $sortby_select = new Xoops\Form\Select(_PROFILE_MA_SORTBY, 'sortby');
     $sortby_select->addOptionArray($sortby_arr);
     $searchform->addElement($sortby_select);
     $order_select = new Xoops\Form\Radio(_PROFILE_MA_ORDER, 'order', 0);
     $order_select->addOption(0, XoopsLocale::ASCENDING_ORDER);
     $order_select->addOption(1, XoopsLocale::DESCENDING_ORDER);
     $searchform->addElement($order_select);
     $limit_text = new Xoops\Form\Text(_PROFILE_MA_PERPAGE, 'limit', 15, 10, $limit_default);
     $searchform->addElement($limit_text);
     $searchform->addElement(new Xoops\Form\Hidden('op', 'results'));
     $searchform->addElement(new Xoops\Form\Button('', 'submit', XoopsLocale::A_SUBMIT, 'submit'));
     $searchform->assign($xoops->tpl());
     $xoops->tpl()->assign('page_title', _PROFILE_MA_SEARCH);
     //added count user
     $member_handler = $xoops->getHandlerMember();
     $acttotal = $member_handler->getUserCount(new Criteria('level', 0, '>'));
     $total = sprintf(_PROFILE_MA_ACTUS, "<span style='color:#ff0000;'>{$acttotal}</span>");
     $xoops->tpl()->assign('total_users', $total);
     break;
 case "results":
Ejemplo n.º 6
0
 /**
  * @param CommentsComment $obj
  */
 public function __construct(CommentsComment $obj)
 {
     $xoops = Xoops::getInstance();
     $helper = Comments::getInstance();
     $module = $xoops->getModuleById($obj->getVar('modid'));
     if (!is_object($module)) {
         $xoops->redirect(\XoopsBaseConfig::get('url'), 1, XoopsLocale::E_NO_ACCESS_PERMISSION);
     }
     $dirname = $module->getVar('dirname');
     // create form
     if ($xoops->isAdminSide) {
         $url = $helper->url("admin/comment_post.php");
     } else {
         $url = $helper->url("comment_post.php");
     }
     parent::__construct(_MD_COMMENTS_POSTCOMMENT, "commentform", $url, "post", true);
     switch ($xoops->getModuleConfig('com_rule', $dirname)) {
         case COMMENTS_APPROVEALL:
             $rule_text = _MD_COMMENTS_COMAPPROVEALL;
             break;
         case COMMENTS_APPROVEUSER:
             $rule_text = _MD_COMMENTS_COMAPPROVEUSER;
             break;
         case COMMENTS_APPROVEADMIN:
         default:
             $rule_text = _MD_COMMENTS_COMAPPROVEADMIN;
             break;
     }
     $this->addElement(new Xoops\Form\Label(_MD_COMMENTS_COMRULES, $rule_text));
     $this->addElement(new Xoops\Form\Text(_MD_COMMENTS_TITLE, 'com_title', 50, 255, $obj->getVar('title', 'e')), true);
     $icons_radio = new Xoops\Form\Radio(XoopsLocale::MESSAGE_ICON, 'com_icon', $obj->getVar('icon', 'e'));
     $subject_icons = XoopsLists::getSubjectsList();
     foreach ($subject_icons as $iconfile) {
         $icons_radio->addOption($iconfile, '<img src="' . \XoopsBaseConfig::get('url') . '/images/subject/' . $iconfile . '" alt="" />');
     }
     $this->addElement($icons_radio);
     // editor
     $editor = $helper->getConfig('com_editor');
     if (class_exists('Xoops\\Form\\Editor')) {
         $configs = array('name' => 'com_text', 'value' => $obj->getVar('text', 'e'), 'rows' => 25, 'cols' => 90, 'width' => '100%', 'height' => '400px', 'editor' => $editor);
         $this->addElement(new Xoops\Form\Editor(_MD_COMMENTS_MESSAGE, 'com_text', $configs, false, $onfailure = 'textarea'));
     } else {
         $this->addElement(new Xoops\Form\DhtmlTextArea(_MD_COMMENTS_MESSAGE, 'com_text', $obj->getVar('text', 'e'), 10, 50), true);
     }
     $option_tray = new Xoops\Form\ElementTray(XoopsLocale::OPTIONS, '<br />');
     $button_tray = new Xoops\Form\ElementTray('', '&nbsp;');
     if ($xoops->isUser()) {
         if ($xoops->getModuleConfig('com_anonpost', $dirname)) {
             $noname = $obj->getVar('noname', 'e') ? 1 : 0;
             $noname_checkbox = new Xoops\Form\Checkbox('', 'com_noname', $noname);
             $noname_checkbox->addOption(1, XoopsLocale::POST_ANONYMOUSLY);
             $option_tray->addElement($noname_checkbox);
         }
         if (false != $xoops->user->isAdmin($obj->getVar('modid'))) {
             // show status change box when editing (comment id is not empty)
             if ($obj->getVar('id', 'e')) {
                 $status_select = new Xoops\Form\Select(_MD_COMMENTS_STATUS, 'com_status', $obj->getVar('status', 'e'));
                 $status_select->addOptionArray(array(COMMENTS_PENDING => _MD_COMMENTS_PENDING, COMMENTS_ACTIVE => _MD_COMMENTS_ACTIVE, COMMENTS_HIDDEN => _MD_COMMENTS_HIDDEN));
                 $this->addElement($status_select);
                 $button_tray->addElement(new Xoops\Form\Button('', 'com_dodelete', XoopsLocale::A_DELETE, 'submit'));
             }
             if (isset($editor) && in_array($editor, array('textarea', 'dhtmltextarea'))) {
                 $html_checkbox = new Xoops\Form\Checkbox('', 'com_dohtml', $obj->getVar('dohtml', 'e'));
                 $html_checkbox->addOption(1, _MD_COMMENTS_DOHTML);
                 $option_tray->addElement($html_checkbox);
             }
         }
     }
     if (isset($editor) && in_array($editor, array('textarea', 'dhtmltextarea'))) {
         //Yeah, what?
     }
     $smiley_checkbox = new Xoops\Form\Checkbox('', 'com_dosmiley', $obj->getVar('domsiley', 'e'));
     $smiley_checkbox->addOption(1, _MD_COMMENTS_DOSMILEY);
     $option_tray->addElement($smiley_checkbox);
     $xcode_checkbox = new Xoops\Form\Checkbox('', 'com_doxcode', $obj->getVar('doxcode', 'e'));
     $xcode_checkbox->addOption(1, _MD_COMMENTS_DOXCODE);
     $option_tray->addElement($xcode_checkbox);
     if (isset($editor) && in_array($editor, array('textarea', 'dhtmltextarea'))) {
         $br_checkbox = new Xoops\Form\Checkbox('', 'com_dobr', $obj->getVar('dobr', 'e'));
         $br_checkbox->addOption(1, _MD_COMMENTS_DOAUTOWRAP);
         $option_tray->addElement($br_checkbox);
     } else {
         $this->addElement(new Xoops\Form\Hidden('com_dohtml', 1));
         $this->addElement(new Xoops\Form\Hidden('com_dobr', 0));
     }
     $this->addElement($option_tray);
     if (!$xoops->isUser()) {
         $this->addElement(new Xoops\Form\Captcha());
     }
     $this->addElement(new Xoops\Form\Hidden('com_modid', $obj->getVar('modid', 'e')));
     $this->addElement(new Xoops\Form\Hidden('com_pid', $obj->getVar('pid', 'e')));
     $this->addElement(new Xoops\Form\Hidden('com_rootid', $obj->getVar('rootid', 'e')));
     $this->addElement(new Xoops\Form\Hidden('com_id', $obj->getVar('id', 'e')));
     $this->addElement(new Xoops\Form\Hidden('com_itemid', $obj->getVar('itemid', 'e')));
     $this->addElement(new Xoops\Form\Hidden('com_order', Request::getInt('com_order', $helper->getUserConfig('com_order'))));
     $this->addElement(new Xoops\Form\Hidden('com_mode', Request::getString('com_mode', $helper->getUserConfig('com_mode'))));
     // add module specific extra params
     if (!$xoops->isAdminSide) {
         /* @var $plugin CommentsPluginInterface */
         $plugin = \Xoops\Module\Plugin::getPlugin($dirname, 'comments');
         if (is_array($extraParams = $plugin->extraParams())) {
             $myts = MyTextSanitizer::getInstance();
             foreach ($extraParams as $extra_param) {
                 // This routine is included from forms accessed via both GET and POST
                 if (isset($_POST[$extra_param])) {
                     $hidden_value = $myts->stripSlashesGPC($_POST[$extra_param]);
                 } else {
                     if (isset($_GET[$extra_param])) {
                         $hidden_value = $myts->stripSlashesGPC($_GET[$extra_param]);
                     } else {
                         $hidden_value = '';
                     }
                 }
                 $this->addElement(new Xoops\Form\Hidden($extra_param, $hidden_value));
             }
         }
     }
     $button_tray->addElement(new Xoops\Form\Button('', 'com_dopreview', XoopsLocale::A_PREVIEW, 'submit'));
     $button_tray->addElement(new Xoops\Form\Button('', 'com_dopost', _MD_COMMENTS_POSTCOMMENT, 'submit'));
     $this->addElement($button_tray);
     return $this;
 }