Example #1
0
function editpartner($showmenu = false, $id = 0)
{
    global $partner_handler, $xoopsUser, $xoopsConfig, $xoopsModuleConfig, $xoopsModule;
    include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
    // If there is a parameter, and the id exists, retrieve data: we're editing a partner
    if ($id != 0) {
        // Creating the partner object
        $partnerObj = new SmartpartnerPartner($id);
        if ($partnerObj->notLoaded()) {
            redirect_header("partner.php", 1, _AM_SPARTNER_NOPARTNERSELECTED);
            exit;
        }
        switch ($partnerObj->status()) {
            case _SPARTNER_STATUS_SUBMITTED:
                $breadcrumb_action1 = _AM_SPARTNER_SUBMITTED_PARTNERS;
                $breadcrumb_action2 = _AM_SPARTNER_APPROVING;
                $page_title = _AM_SPARTNER_SUBMITTED_TITLE;
                $page_info = _AM_SPARTNER_SUBMITTED_INFO;
                $button_caption = _AM_SPARTNER_APPROVE;
                $new_status = _SPARTNER_STATUS_ACTIVE;
                break;
            case _SPARTNER_STATUS_ACTIVE:
                $breadcrumb_action1 = _AM_SPARTNER_ACTIVE_PARTNERS;
                $breadcrumb_action2 = _AM_SPARTNER_EDITING;
                $page_title = _AM_SPARTNER_ACTIVE_EDITING;
                $page_info = _AM_SPARTNER_ACTIVE_EDITING_INFO;
                $button_caption = _AM_SPARTNER_MODIFY;
                $new_status = _SPARTNER_STATUS_ACTIVE;
                break;
            case _SPARTNER_STATUS_INACTIVE:
                $breadcrumb_action1 = _AM_SPARTNER_INACTIVE_PARTNERS;
                $breadcrumb_action2 = _AM_SPARTNER_EDITING;
                $page_title = _AM_SPARTNER_INACTIVE_EDITING;
                $page_info = _AM_SPARTNER_INACTIVE_EDITING_INFO;
                $button_caption = _AM_SPARTNER_MODIFY;
                $new_status = _SPARTNER_STATUS_INACTIVE;
                break;
            case _SPARTNER_STATUS_REJECTED:
                $breadcrumb_action1 = _AM_SPARTNER_REJECTED_PARTNERS;
                $breadcrumb_action2 = _AM_SPARTNER_EDITING;
                $page_title = _AM_SPARTNER_REJECTED_EDITING;
                $page_info = _AM_SPARTNER_REJECTED_EDITING_INFO;
                $button_caption = _AM_SPARTNER_MODIFY;
                $new_status = _SPARTNER_STATUS_REJECTED;
                break;
            case "default":
            default:
                break;
        }
        if ($showmenu) {
            smartpartner_adminMenu(1, $breadcrumb_action1 . " > " . $breadcrumb_action2);
        }
        echo "<br />\n";
        smartpartner_collapsableBar('bottomtable', 'bottomtableicon');
        echo "<img id='bottomtableicon' src=" . XOOPS_URL . "/modules/" . $xoopsModule->dirname() . "/images/icon/close12.gif alt='' /></a>&nbsp;" . $page_title . "</h3>";
        echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">" . $page_info . "</span>";
        echo "<div id='bottomtable'>";
    } else {
        // there's no parameter, so we're adding a partner
        $partnerObj =& $partner_handler->create();
        $breadcrumb_action1 = _AM_SPARTNER_PARTNERS;
        $breadcrumb_action2 = _AM_SPARTNER_CREATE;
        $button_caption = _AM_SPARTNER_CREATE;
        $new_status = _SPARTNER_STATUS_ACTIVE;
        if ($showmenu) {
            smartpartner_adminMenu(1, $breadcrumb_action1 . " > " . $breadcrumb_action2);
        }
        smartpartner_collapsableBar('bottomtable', 'bottomtableicon');
        echo "<img id='bottomtableicon' src=" . XOOPS_URL . "/modules/" . $xoopsModule->dirname() . "/images/icon/close12.gif alt='' /></a>&nbsp;" . _AM_SPARTNER_PARTNER_CREATING . "</h3>";
        echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">" . _AM_SPARTNER_PARTNER_CREATING_DSC . "</span>";
        echo "<div id='bottomtable'>";
    }
    // PARTNER FORM
    $sform = new XoopsThemeForm(_AM_SPARTNER_PARTNERS, "op", xoops_getenv('PHP_SELF'));
    $sform->setExtra('enctype="multipart/form-data"');
    // TITLE
    $title_text = new XoopsFormText(_AM_SPARTNER_TITLE_REQ, 'title', 50, 255, $partnerObj->title('e'));
    $sform->addElement($title_text, true);
    // LOGO
    $logo_array =& XoopsLists::getImgListAsArray(smartpartner_getImageDir());
    $logo_select = new XoopsFormSelect('', 'image', $partnerObj->image());
    $logo_select->addOption('-1', '---------------');
    $logo_select->addOptionArray($logo_array);
    $logo_select->setExtra("onchange='showImgSelected(\"image3\", \"image\", \"" . 'uploads/' . SMARTPARTNER_DIRNAME . '/images' . "\", \"\", \"" . XOOPS_URL . "\")'");
    $logo_tray = new XoopsFormElementTray(_AM_SPARTNER_LOGO, '&nbsp;');
    $logo_tray->addElement($logo_select);
    $logo_tray->addElement(new XoopsFormLabel('', "<br /><br /><img src='" . smartpartner_getImageDir('', false) . $partnerObj->image() . "' name='image3' id='image3' alt='' />"));
    $logo_tray->setDescription(_AM_SPARTNER_LOGO_DSC);
    $sform->addElement($logo_tray);
    // LOGO UPLOAD
    $max_size = 5000000;
    $file_box = new XoopsFormFile(_AM_SPARTNER_LOGO_UPLOAD, "logo_file", $max_size);
    $file_box->setExtra("size ='45'");
    $file_box->setDescription(sprintf(_AM_SPARTNER_LOGO_UPLOAD_DSC, $xoopsModuleConfig['img_max_width'], $xoopsModuleConfig['img_max_height']));
    $sform->addElement($file_box);
    // IMAGE_URL
    $image_url_text = new XoopsFormText(_CO_SPARTNER_IMAGE_URL, 'image_url', 50, 255, $partnerObj->image_url());
    $image_url_text->setDescription(_CO_SPARTNER_IMAGE_URL_DSC);
    $sform->addElement($image_url_text, false);
    // URL
    $url_text = new XoopsFormText(_AM_SPARTNER_URL, 'url', 50, 255, $partnerObj->url());
    $url_text->setDescription(_AM_SPARTNER_URL_DSC);
    $sform->addElement($url_text, false);
    // SUMMARY
    $summary_text = new XoopsFormTextArea(_AM_SPARTNER_SUMMARY_REQ, 'summary', $partnerObj->summary(0, 'e'), 7, 60);
    $summary_text->setDescription(_AM_SPARTNER_SUMMARY_DSC);
    $sform->addElement($summary_text, true);
    // DESCRIPTION
    $description_text = new XoopsFormDhtmlTextArea(_AM_SPARTNER_DESCRIPTION, 'description', $partnerObj->description(0, 'e'), 15, 60);
    $description_text->setDescription(_AM_SPARTNER_DESCRIPTION_DSC);
    $sform->addElement($description_text, false);
    // CONTACT_NAME
    $contact_name_text = new XoopsFormText(_CO_SPARTNER_CONTACT_NAME, 'contact_name', 50, 255, $partnerObj->contact_name('e'));
    $contact_name_text->setDescription(_CO_SPARTNER_CONTACT_NAME_DSC);
    $sform->addElement($contact_name_text, false);
    // CONTACT_EMAIL
    $contact_email_text = new XoopsFormText(_CO_SPARTNER_CONTACT_EMAIL, 'contact_email', 50, 255, $partnerObj->contact_email('e'));
    $contact_email_text->setDescription(_CO_SPARTNER_CONTACT_EMAIL_DSC);
    $sform->addElement($contact_email_text, false);
    // CONTACT_PHONE
    $contact_phone_text = new XoopsFormText(_CO_SPARTNER_CONTACT_PHONE, 'contact_phone', 50, 255, $partnerObj->contact_phone('e'));
    $contact_phone_text->setDescription(_CO_SPARTNER_CONTACT_PHONE_DSC);
    $sform->addElement($contact_phone_text, false);
    // ADRESS
    //$adress_text = new XoopsFormText(_CO_SPARTNER_ADRESS, 'adress', 50, 255, $partnerObj->adress('e'));
    $adress_text = new XoopsFormTextArea(_CO_SPARTNER_ADRESS, 'adress', $partnerObj->adress('e'));
    $adress_text->setDescription(_CO_SPARTNER_ADRESS_DSC);
    $sform->addElement($adress_text, false);
    // STATUS
    $options = $partnerObj->getAvailableStatus();
    $status_select = new XoopsFormSelect(_AM_SPARTNER_STATUS, 'status', $new_status);
    $status_select->addOptionArray($options);
    $status_select->setDescription(_AM_SPARTNER_STATUS_DSC);
    $sform->addElement($status_select);
    // WEIGHT
    $weight_text = new XoopsFormText(_AM_SPARTNER_WEIGHT, 'weight', 4, 4, $partnerObj->weight());
    $weight_text->setDescription(_AM_SPARTNER_WEIGHT_DSC);
    $sform->addElement($weight_text);
    // TAGS
    if (file_exists($GLOBALS['xoops']->path('/modules/tag/include/formtag.php'))) {
        include_once $GLOBALS['xoops']->path('/modules/tag/include/formtag.php');
        $tags_text = new XoopsFormTag("tags", 60, 255, $partnerObj->id(), $catid = 0);
        $sform->addElement($tags_text, false);
    }
    // DOMAINS
    if (file_exists($GLOBALS['xoops']->path('/modules/multisite/class/formselectdomains.php'))) {
        include_once $GLOBALS['xoops']->path('/modules/multisite/class/formselectdomains.php');
        $domains_text = new XoopsFormSelectDomains(_CO_SPARTNER_DOMAINS, "domains", $partnerObj->getVar('domains'), 10, true);
        $domains_text->setDescription(_CO_SPARTNER_DOMAINS_DSC);
        $sform->addElement($domains_text, false);
    }
    // Partner id
    $sform->addElement(new XoopsFormHidden('id', $partnerObj->id()));
    $button_tray = new XoopsFormElementTray('', '');
    $hidden = new XoopsFormHidden('op', 'addpartner');
    $button_tray->addElement($hidden);
    $sform->addElement(new XoopsFormHidden('original_status', $partnerObj->status()));
    if (!$id) {
        // there's no id? Then it's a new partner
        // $button_tray -> addElement( new XoopsFormButton( '', 'mod', _AM_SPARTNER_CREATE, 'submit' ) );
        $butt_create = new XoopsFormButton('', '', _AM_SPARTNER_CREATE, 'submit');
        $butt_create->setExtra('onclick="this.form.elements.op.value=\'addpartner\'"');
        $button_tray->addElement($butt_create);
        $butt_clear = new XoopsFormButton('', '', _AM_SPARTNER_CLEAR, 'reset');
        $button_tray->addElement($butt_clear);
        $butt_cancel = new XoopsFormButton('', '', _AM_SPARTNER_CANCEL, 'button');
        $butt_cancel->setExtra('onclick="history.go(-1)"');
        $button_tray->addElement($butt_cancel);
    } else {
        // else, we're editing an existing partner
        // $button_tray -> addElement( new XoopsFormButton( '', 'mod', _AM_SPARTNER_MODIFY, 'submit' ) );
        $butt_create = new XoopsFormButton('', '', $button_caption, 'submit');
        $butt_create->setExtra('onclick="this.form.elements.op.value=\'addpartner\'"');
        $button_tray->addElement($butt_create);
        $butt_cancel = new XoopsFormButton('', '', _AM_SPARTNER_CANCEL, 'button');
        $butt_cancel->setExtra('onclick="history.go(-1)"');
        $button_tray->addElement($butt_cancel);
    }
    $sform->addElement($button_tray);
    $sform->display();
    unset($hidden);
    echo "</div>";
}
Example #2
0
 $contact_phone_text->setDescription(_CO_SPARTNER_CONTACT_PHONE_DSC);
 $form->addElement($contact_phone_text, false);
 // ADRESS
 $adress_text = new XoopsFormTextArea(_CO_SPARTNER_ADRESS, 'adress', '', 4, 60);
 $adress_text->setDescription(_CO_SPARTNER_ADRESS_DSC);
 $form->addElement($adress_text, false);
 // TAGS
 if (file_exists($GLOBALS['xoops']->path('/modules/tag/include/formtag.php'))) {
     include_once $GLOBALS['xoops']->path('/modules/tag/include/formtag.php');
     $tags_text = new XoopsFormTag("tags", 60, 255, $itemid, $catid = 0);
     $form->addElement($tags_text, false);
 }
 // DOMAINS
 if (file_exists($GLOBALS['xoops']->path('/modules/multisite/class/formselectdomains.php'))) {
     include_once $GLOBALS['xoops']->path('/modules/multisite/class/formselectdomains.php');
     $domains_text = new XoopsFormSelectDomains(_CO_SPARTNER_DOMAINS, "domains", array(urlencode(XOOPS_URL)), 10, true);
     $domains_text->setDescription(_CO_SPARTNER_DOMAINS_DSC);
     $form->addElement($domains_text, false);
 }
 // NOTIFY ON PUBLISH
 if (is_object($xoopsUser) && $xoopsModuleConfig['autoapprove_submitted'] != 1) {
     $notify_checkbox = new XoopsFormCheckBox('', 'notifypub', 1);
     $notify_checkbox->addOption(1, _MD_SPARTNER_NOTIFY);
     $form->addElement($notify_checkbox);
 }
 $form->addElement(new XoopsFormCaptcha(), true);
 // BUTTONS
 $button_tray = new XoopsFormElementTray('', '');
 $hidden = new XoopsFormHidden('op', 'submitPartner');
 $button_tray->addElement($hidden);
 $butt_create = new XoopsFormButton('', '', _CO_SPARTNER_SUBMIT, 'submit');