Ejemplo n.º 1
0
function editpartner($showmenu = false, $id = 0)
{
    global $xoopsDB, $smartpartner_partner_handler, $xoopsUser, $xoopsConfig, $xoopsModuleConfig, $xoopsModule;
    if (!isset($smartpartner_partner_handler)) {
        $smartpartner_partner_handler =& smartpartner_gethandler('partner');
    }
    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(2, $breadcrumb_action1 . " > " . $breadcrumb_action2);
        }
        echo "<br />\n";
        smartpartner_collapsableBar('editpartner', 'editpartmericon', $page_title, $page_info);
    } else {
        // there's no parameter, so we're adding a partner
        $partnerObj =& $smartpartner_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(2, $breadcrumb_action1 . " > " . $breadcrumb_action2);
        }
        smartpartner_collapsableBar('addpartner', 'addpartmericon', _AM_SPARTNER_PARTNER_CREATING, _AM_SPARTNER_PARTNER_CREATING_DSC);
    }
    // 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, 'title', 50, 255, $partnerObj->title('e'));
    $sform->addElement($title_text, true);
    // Parent Category
    $mytree = new SmartTree($xoopsDB->prefix("smartpartner_categories"), "categoryid", "parentid");
    ob_start();
    $mytree->makeMySelBox("name", "weight", explode('|', $partnerObj->categoryid()), 0, 'categoryid', '', true);
    //makeMySelBox($title,$order="",$preset_id=0, $none=0, $sel_name="", $onchange="")
    $parent_cat_select = new XoopsFormLabel(_AM_SPARTNER_CATEGORY_BELONG, ob_get_contents());
    $parent_cat_select->setDescription(_AM_SPARTNER_BELONG_CATEGORY_DSC);
    $sform->addElement($parent_cat_select);
    ob_end_clean();
    // 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, 'summary', $partnerObj->summary(0, 'e'), 7, 60);
    $summary_text->setDescription(_AM_SPARTNER_SUMMARY_DSC);
    $sform->addElement($summary_text, true);
    // SHOW summary on partner page
    $showsum_radio = new XoopsFormRadioYN(_AM_SPARTNER_SHOW_SUMMARY, 'showsummary', $partnerObj->getVar('showsummary'));
    $showsum_radio->setDescription(_AM_SPARTNER_SHOW_SUMMARY_DSC);
    $sform->addElement($showsum_radio);
    // 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);
    // EMAIL_PRIV
    $email_priv_radio = new XoopsFormRadioYN(_CO_SPARTNER_CONTACT_EMAILPRIV, 'email_priv', $partnerObj->email_priv('e'));
    $email_priv_radio->setDescription(_CO_SPARTNER_CONTACT_EMAILPRIV_DSC);
    $sform->addElement($email_priv_radio);
    // 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);
    // PHONE_PRIV
    $phone_priv_radio = new XoopsFormRadioYN(_CO_SPARTNER_CONTACT_PHONEPRIV, 'phone_priv', $partnerObj->phone_priv('e'));
    $phone_priv_radio->setDescription(_CO_SPARTNER_CONTACT_PHONEPRIV_DSC);
    $sform->addElement($phone_priv_radio);
    // 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);
    // ADRESS_PRIV
    $adress_priv_radio = new XoopsFormRadioYN(_CO_SPARTNER_CONTACT_ADRESSPRIV, 'adress_priv', $partnerObj->adress_priv('e'));
    $adress_priv_radio->setDescription(_CO_SPARTNER_CONTACT_ADRESSPRIV_DSC);
    $sform->addElement($adress_priv_radio);
    // 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);
    //perms
    global $smartpermissions_handler;
    include_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectpermission.php';
    $smartpermissions_handler = new SmartobjectPermissionHandler($smartpartner_partner_handler);
    if ($partnerObj->id() != 0) {
        $grantedGroups = $smartpermissions_handler->getGrantedGroups('full_view', $partnerObj->id());
    } else {
        $grantedGroups = $xoopsModuleConfig['default_full_view'];
    }
    $full_view_select = new XoopsFormSelectGroup(_CO_SPARTNER_FULL_PERM_READ, 'full_view', true, $grantedGroups, 5, true);
    $full_view_select->setDescription(_CO_SPARTNER_FULL_PERM_READ_DSC);
    $sform->addElement($full_view_select);
    if ($partnerObj->id() != 0) {
        $partGrantedGroups = $smartpermissions_handler->getGrantedGroups('partial_view', $partnerObj->id());
    } else {
        $partGrantedGroups = $xoopsModuleConfig['default_part_view'];
    }
    $part_view_select = new XoopsFormSelectGroup(_CO_SPARTNER_PART_PERM_READ, 'partial_view', true, $partGrantedGroups, 5, true);
    $part_view_select->setDescription(_CO_SPARTNER_PART_PERM_READ_DSC);
    $sform->addElement($part_view_select);
    // 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);
    if (!$id) {
        smartpartner_close_collapsable('addpartner', 'addpartnericon');
    } else {
        smartpartner_close_collapsable('editpartner', 'editpartnericon');
    }
    if ($id != 0) {
        showfiles($partnerObj);
    }
}
Ejemplo n.º 2
0
<?php

/**
 * $Id: vpartner.php,v 1.1 2007/06/05 18:28:23 marcan Exp $
 * Module: SmartPartner
 * Author: The SmartFactory <www.smartfactory.ca>
 * Licence: GNU
 */
include "header.php";
$id = isset($_GET['id']) ? intval($_GET['id']) : 0;
$partnerObj = new SmartpartnerPartner($id);
if ($partnerObj->notLoaded()) {
    redirect_header("javascript:history.go(-1)", 1, _CO_SPARTNER_NOPARTNERSELECTED);
    exit;
}
if ($partnerObj->url()) {
    if (!isset($HTTP_COOKIE_VARS['partners'][$id])) {
        setcookie("partners[{$id}]", $id, $xoopsModuleConfig['cookietime']);
        $partnerObj->updateHits();
    }
    header("HTTP/1.1 301 Moved Permanently");
    header("Location: " . $partnerObj->url() . " ");
    exit;
    //echo "<html><head><meta http-equiv='Refresh' content='0; URL=".$partnerObj->url()."'></head><body></body></html>";
} else {
    redirect_header("index.php", 1, _XP_NOPART);
}
Ejemplo n.º 3
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>";
}
Ejemplo n.º 4
0
 /**
  * retrieve Partners from the database
  *
  * @param object $criteria {@link CriteriaElement} conditions to be met
  * @param bool $id_as_key use the partnerid as key for the array?
  * @return array array of {@link SmartpartnerPartner} objects
  */
 function &getObjects($criteria = null, $id_as_key = false)
 {
     $ret = false;
     $limit = $start = 0;
     $sql = 'SELECT * FROM ' . $this->_db->prefix($this->_dbtable);
     if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
         $whereClause = $criteria->renderWhere();
         if ($whereClause != 'WHERE ()') {
             $sql .= ' ' . $criteria->renderWhere();
             if ($criteria->getSort() != '') {
                 $sql .= ' ORDER BY ' . $criteria->getSort() . ' ' . $criteria->getOrder();
             }
             $limit = $criteria->getLimit();
             $start = $criteria->getStart();
         }
     }
     //echo "<br />" . $sql . "<br />";
     $result = $this->_db->query($sql, $limit, $start);
     if (!$result) {
         return $ret;
     }
     if (count($result) == 0) {
         return $ret;
     }
     while ($myrow = $this->_db->fetchArray($result)) {
         $partner = new SmartpartnerPartner();
         $partner->assignVars($myrow);
         if (!$id_as_key) {
             $ret[] =& $partner;
         } else {
             $ret[$myrow['id']] =& $partner;
         }
         unset($partner);
     }
     return $ret;
 }
Ejemplo n.º 5
0
 * Module: SmartPartner
 * Author: The SmartFactory <www.smartfactory.ca>
 * Licence: GNU
 */
include_once "header.php";
$xoopsOption['template_main'] = 'smartpartner_partner.html';
include_once XOOPS_ROOT_PATH . "/header.php";
include_once "footer.php";
global $xoopsUser, $xoopsConfig, $xoopsModuleConfig, $xoopsModule;
$id = isset($_GET['id']) ? intval($_GET['id']) : 0;
if ($id == 0) {
    redirect_header("javascript:history.go(-1)", 2, _MD_SPARTNER_NOPARTNERSELECTED);
    exit;
}
// Creating the Partner object for the selected FAQ
$partnerObj = new SmartpartnerPartner($id);
// If the selected partner was not found, exit
if ($partnerObj->notLoaded()) {
    redirect_header("javascript:history.go(-1)", 2, _MD_SPARTNER_NOPARTNERSELECTED);
    exit;
}
include_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectpermission.php';
$smartpermissions_handler = new SmartobjectPermissionHandler($smartpartner_partner_handler);
$grantedItems = $smartpermissions_handler->getGrantedItems('full_view');
$grantedItems = array_merge($grantedItems, $smartpermissions_handler->getGrantedItems('partial_view'));
// Chech the status
if ($partnerObj->status() != _SPARTNER_STATUS_ACTIVE || !in_array($id, $grantedItems)) {
    redirect_header("javascript:history.go(-1)", 2, _NOPERM);
    exit;
}
// Updating the counter
Ejemplo n.º 6
0
// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ //
// Project: The XOOPS Project                                                //
// ------------------------------------------------------------------------- //
include "header.php";
//error_reporting(0);
//error_reporting(0);
include_once 'header.php';
$myts =& MyTextSanitizer::getInstance();
require_once SMARTPARTNER_ROOT_PATH . 'fpdf/fpdf.inc.php';
$id = isset($_GET['id']) ? intval($_GET['id']) : 0;
if ($id == 0) {
    redirect_header("javascript:history.go(-1)", 2, _MD_SPARTNER_NOPARTNERSELECTED);
    exit;
}
// Creating the Partner object for the selected FAQ
$partnerObj = new SmartpartnerPartner($id);
// If the selected partner was not found, exit
if ($partnerObj->notLoaded()) {
    redirect_header("javascript:history.go(-1)", 2, _MD_SPARTNER_NOPARTNERSELECTED);
    exit;
}
// Chech the status
if ($partnerObj->status() != _SPARTNER_STATUS_ACTIVE) {
    redirect_header("javascript:history.go(-1)", 2, _NOPERM);
    exit;
}
$pdf_data['title'] = $partnerObj->title();
$pdf_data['subtitle'] = "subtitle...";
$pdf_data['subsubtitle'] = "subsubtitle...";
$pdf_data['date'] = "date...";
$pdf_data['filename'] = "filename...";
Ejemplo n.º 7
0
    $ret = $xoopsDB->query("SELECT a.title FROM " . $xoopsDB->prefix("smartpartner_partner") . " a WHERE a.id = '{$id}'");
    list($title) = $xoopsDB->fetchRow($ret);
    header("HTTP/1.1 301 Moved Permanently");
    header("Location: " . XOOPS_URL . "/associates/" . xoops_sef($title) . "/" . $id);
    exit;
}
$xoopsOption['template_main'] = 'smartpartner_partner.html';
include_once XOOPS_ROOT_PATH . "/header.php";
include_once "footer.php";
global $xoopsUser, $xoopsConfig, $xoopsModuleConfig, $xoopsModule;
if ($id == 0) {
    redirect_header("javascript:history.go(-1)", 2, _MD_SPARTNER_NOPARTNERSELECTED);
    exit;
}
// Creating the Partner object for the selected FAQ
$partnerObj = new SmartpartnerPartner($id);
// If the selected partner was not found, exit
if ($partnerObj->notLoaded()) {
    redirect_header("javascript:history.go(-1)", 2, _MD_SPARTNER_NOPARTNERSELECTED);
    exit;
}
// Chech the status
if ($partnerObj->status() != _SPARTNER_STATUS_ACTIVE) {
    redirect_header("javascript:history.go(-1)", 2, _NOPERM);
    exit;
}
// Updating the counter
$partnerObj->updateHits_page();
// Populating the smarty variables with informations related to the selected Partner
$partner = $partnerObj->toArray();
$xoopsTpl->assign('partner', $partner);
Ejemplo n.º 8
0
 /**
  * retrieve Partners from the database
  *
  * @param object $criteria {@link CriteriaElement} conditions to be met
  * @param bool $id_as_key use the partnerid as key for the array?
  * @return array array of {@link SmartpartnerPartner} objects
  */
 function &getObjects($criteria = null, $id_as_key = false)
 {
     $ret = array();
     $limit = $start = 0;
     $sql = 'SELECT * FROM ' . $this->table;
     if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
         $whereClause = $criteria->renderWhere();
         if ($whereClause != 'WHERE ()') {
             $sql .= ' ' . $criteria->renderWhere();
             if ($criteria->getSort() != '') {
                 $sql .= ' ORDER BY ' . $criteria->getSort() . ' ' . $criteria->getOrder();
             }
             $limit = $criteria->getLimit();
             $start = $criteria->getStart();
         }
     }
     //echo "<br />" . $sql . "<br />";exit;
     $result = $this->db->query($sql, $limit, $start);
     if (!$result) {
         return $ret;
     }
     if (count($result) == 0) {
         return $ret;
     }
     global $smartpartner_partner_cat_link_handler;
     if (!isset($smartpartner_partner_cat_link_handler)) {
         $smartpartner_partner_cat_link_handler =& smartpartner_gethandler('partner_cat_link');
     }
     while ($myrow = $this->db->fetchArray($result)) {
         $partner = new SmartpartnerPartner();
         $partner->assignVars($myrow);
         if (!$id_as_key) {
             $ret[] =& $partner;
         } else {
             $ret[$myrow['id']] =& $partner;
         }
         $partner->setVar('categoryid', $smartpartner_partner_cat_link_handler->getParentIds($partner->getVar('id')));
         unset($partner);
     }
     return $ret;
 }