/**
 * Edition des paramètres du bloc
 *
 * @param array $options [0] = Nombre maximum de listes à voir, [1] = Type de listes (0 = les 2, 1 = liste cadeaux, 2 = produits recommandés)
 * @return array
 */
function b_oledrion_category_lists_edit($options)
{
    include XOOPS_ROOT_PATH . '/modules/oledrion/include/common.php';
    $form = '';
    $form .= "<table border='0'>";
    $form .= '<tr><td>' . _MB_OLEDRION_LISTS_COUNT . "</td><td><input type='text' name='options[]' id='options' value='" . intval($options[0]) . "' /></td></tr>";
    $listTypes = oledrion_lists::getTypesArray();
    $listTypeSelect = oledrion_utils::htmlSelect('options[]', $listTypes, intval($options[1]), false);
    $form .= '<tr><td>' . _MB_OLEDRION_LISTS_TYPE . "</td><td>" . $listTypeSelect . "</td></tr>";
    $form .= '</table>';
    return $form;
}
 /**
  * Retourne la liste des produits appartenants à une liste
  *
  * @param oledrion_lists $list
  * @return array
  */
 function getProductsFromList(oledrion_lists $list)
 {
     return $this->getObjects(new criteria('productlist_list_id', $list->getVar('list_id'), '='));
 }
Exemple #3
0
function listForm($op, $product_id = 0)
{
    global $handlers, $baseurl;
    if ($op == 'edit') {
        $title = _OLEDRION_EDIT_LIST;
        $label_submit = _AM_OLEDRION_MODIFY;
        $list_id = isset($_GET['list_id']) ? intval($_GET['list_id']) : 0;
        if (empty($list_id)) {
            oledrion_utils::redirect(_AM_OLEDRION_ERROR_21, $baseurl, 5);
        }
        $item = null;
        $item = $handlers->h_oledrion_lists->get($list_id);
        if (!is_object($item)) {
            oledrion_utils::redirect(_AM_OLEDRION_NOT_FOUND, $baseurl, 5);
        }
        // Vérification, est-ce que l'utilisateur courant est bien le propriétaire de cette liste ?
        if (!$handlers->h_oledrion_lists->isThisMyList($list_id)) {
            oledrion_utils::redirect(_OLEDRION_ERROR25, $baseurl, 8);
        }
        $edit = true;
        $label_submit = _AM_OLEDRION_MODIFY;
    } else {
        $title = _OLEDRION_ADD_LIST;
        $label_submit = _AM_OLEDRION_ADD;
        $item = $handlers->h_oledrion_lists->create(true);
        $edit = false;
    }
    $sform = new XoopsThemeForm($title, 'frmList', $baseurl);
    $sform->addElement(new XoopsFormHidden('op', 'save'));
    $sform->addElement(new XoopsFormHidden('list_id', $item->getVar('list_id')));
    $sform->addElement(new XoopsFormText(_AM_OLEDRION_TITLE, 'list_title', 50, 255, $item->getVar('list_title', 'e')), true);
    //$sform->addElement(new XoopsFormText(_OLEDRION_LIST_PASSWORD, 'list_password', 50, 50, $item->getVar('list_password','e')), false);
    $selectTypes = oledrion_lists::getTypesArray();
    $selectType = new XoopsFormSelect(_OLEDRION_LIST_TYPE, 'list_type', $item->getVar('list_type', 'e'));
    $selectType->addOptionArray($selectTypes);
    $sform->addElement($selectType, true);
    $sform->addElement(new XoopsFormTextArea(_OLEDRION_DESCRIPTION, 'list_description', $item->getVar('list_description', 'e'), 7, 60), false);
    $listProducts = array();
    if ($edit) {
        $listProducts = $handlers->h_oledrion_lists->getListProducts($item);
        if (count($listProducts) > 0) {
            $productsTray = new XoopsFormElementTray(_OLEDRION_PROD_IN_THIS_LIST, '<br />');
            $productsTray->addElement(new XoopsFormLabel(_OLEDRION_CHECK_PRODUCTS), false);
            foreach ($listProducts as $product) {
                $caption = "<a target='_blank' href='" . $product->getLink() . "'>" . $product->getVar('product_title') . '</a>';
                $checkbox = new XoopsFormCheckBox($caption, 'productsList[]');
                $checkbox->addOption($product->getVar('product_id'), _DELETE);
                $productsTray->addElement($checkbox);
                unset($caption, $checkbox);
            }
            $sform->addElement($productsTray, false);
        }
    }
    if ($product_id > 0) {
        $product = null;
        $product = $handlers->h_oledrion_products->get($product_id);
        if (is_object($product) && $product->isProductVisible()) {
            $content = "<a target='_blank' href='" . $product->getLink() . "'>" . $product->getVar('product_title') . '</a>';
            $sform->addElement(new XoopsFormLabel(_OLEDRION_PRODUCT_DO_ADD, $content));
            $sform->addElement(new XoopsFormHidden('product_id', $product_id));
        }
    }
    $button_tray = new XoopsFormElementTray('', '');
    $submit_btn = new XoopsFormButton('', 'post', $label_submit, 'submit');
    $button_tray->addElement($submit_btn);
    $sform->addElement($button_tray);
    $sform = oledrion_utils::formMarkRequiredFields($sform);
    return $sform;
}
Exemple #4
0
 /**
  * Décrémente le nombre de produits dans une liste
  *
  * @param  oledrion_lists $list
  * @return boolean
  */
 public function decrementListProductsCount(oledrion_lists $list, $value = 1)
 {
     $value = intval($value);
     $res = true;
     $sql = 'UPDATE ' . $this->table . ' SET list_productscount = list_productscount - $value WHERE list_id = ' . $list->getVar('list_id');
     $res = $this->db->queryF($sql);
     $this->forceCacheClean();
     return $res;
 }