Exemple #1
0
/**
 * get a list of products in datatables format
 *
 * @return array products list
 */
function Products_adminProductsListDT()
{
    $start = (int) $_REQUEST['iDisplayStart'];
    $length = (int) $_REQUEST['iDisplayLength'];
    $search = $_REQUEST['sSearch'];
    $orderbyNum = (int) $_REQUEST['iSortCol_0'];
    $orderdesc = $_REQUEST['sSortDir_0'] == 'desc' ? 'desc' : 'asc';
    $GLOBALS['product_columns'] = array();
    Core_trigger('extra-products-columns');
    global $product_columns;
    switch ($orderbyNum) {
        case 2:
            $orderby = 'name';
            break;
        case 3:
            $orderby = 'stock_number';
            break;
        case 6:
            $orderby = 'id';
            break;
        case 7:
            $orderby = 'enabled';
            break;
        case 8:
            $orderby = 'date_created';
            break;
        case 9:
            $orderby = 'date_edited';
            break;
        default:
            $orderby = 'name';
    }
    if ($orderbyNum > 9 && isset($product_columns[$orderbyNum - 10]['field_name'])) {
        $orderby = $product_columns[$orderbyNum - 10]['field_name'];
    }
    $filters = array();
    if ($search) {
        $sArr = array();
        $sArr[] = 'match(data_fields,name) against ("' . addslashes($search) . '" in boolean mode)';
        $filters[] = '(' . join(' and ', $sArr) . ')';
        #			.' or stock_number like "%'.addslashes($search).'%")';
    }
    $filter = '';
    if (count($filters)) {
        $filter = 'where ' . join(' and ', $filters);
    }
    $sql = 'select id, user_id, images_directory, name, stock_number, enabled' . ', date_created, date_edited, stockcontrol_total';
    foreach ($product_columns as $p) {
        if (isset($p['field_name'])) {
            $sql .= ', ' . $p['field_name'];
        }
    }
    $sql .= ' from products ' . $filter . ' order by ' . $orderby . ' ' . $orderdesc . ' limit ' . $start . ',' . $length;
    $rs = dbAll($sql, '', 'products');
    $result = array();
    $result['sql'] = $sql;
    $result['sEcho'] = intval($_GET['sEcho']);
    $result['iTotalRecords'] = dbOne('select count(id) as ids from products', 'ids', 'products');
    $result['iTotalDisplayRecords'] = dbOne('select count(id) as ids from products ' . $filter, 'ids', 'products');
    $arr = array();
    foreach ($rs as $r) {
        $row = array(0);
        // { has images
        $has_images = 0;
        if ($r['images_directory'] && @is_dir(USERBASE . '/f/' . $r['images_directory'])) {
            $dir = new DirectoryIterator(USERBASE . '/f/' . $r['images_directory']);
            foreach ($dir as $f) {
                if ($f->isDot()) {
                    continue;
                }
                if ($f->isFile()) {
                    $has_images++;
                }
            }
        }
        $row[] = $has_images;
        // }
        // { name
        $row[] = __FromJson($r['name']);
        // }
        // { stock_number
        $row[] = $r['stock_number'];
        // }
        // { stock_control
        $row[] = $r['stockcontrol_total'];
        // }
        // { owner
        $user = User::getInstance($r['user_id'], false, false);
        $row[] = $r['user_id'] . '|' . ($user ? $user->get('name') : 'unknown owner');
        // }
        // { id
        $row[] = $r['id'];
        // }
        // { enabled
        $row[] = $r['enabled'];
        // }
        // { created date
        $row[] = $r['date_created'];
        // }
        // { last edit
        $row[] = $r['date_edited'];
        // }
        foreach ($product_columns as $p) {
            if (isset($p['field_name'])) {
                $row[] = $r[$p['field_name']];
            } else {
                $row[] = 'TODO';
            }
        }
        $arr[] = $row;
    }
    $result['aaData'] = $arr;
    return $result;
}
Exemple #2
0
 *
 * PHP version 5.2
 *
 * @category None
 * @package  None
 * @author   Kae Verens <*****@*****.**>
 * @license  GPL 2.0
 * @link     http://kvsites.ie/
 */
if (!Core_isAdmin()) {
    Core_quit();
}
// { links: add product, import products
echo '<a href="plugin.php?_plugin=products&amp;_page=products">' . __('List all products') . '</a> | <a href="plugin.php?_plugin=products&amp;_page=products-edit">' . __('Add a Product') . '</a> | ' . '<a href="javascript:Core_screen(\'products\', \'js:Import\');">' . __('Import Products', 'core') . '</a>';
// }
if (!dbOne('select id from products_types limit 1', 'id')) {
    echo '<em>' . __('You can\'t create a product until you have created a type.') . ' <a href="javascript:Core_screen(\'products\',\'js:Types\');">' . __('Click here to create a Product Type.') . '</a></em>';
    return;
}
$rs = dbAll('select id from products limit 1');
if (!count($rs)) {
    echo '<em>' . __('No existing products.', 'core') . ' <a href="/ww.admin/plugin.php?_plugin=products&amp;_page=products-edit">' . __('Add a Product') . '</a> ' . __('or', 'core') . ' <a href="javascript:Core_screen(\'products\', \'js:Import\');">' . __('Import Products', 'core') . '</a>';
    return;
}
echo '<div id="products-wrapper"></div>' . '<select id="products-action"><option value="0"> -- </option>' . '<option value="1">' . __('Delete Selected') . '</option>' . '<option value="2">' . __('Set Disabled') . '</option>' . '<option value="3">' . __('Set Enabled') . '</option>' . '</select>';
$product_columns = array();
Core_trigger('extra-products-columns');
WW_addInlineScript('var extraProductColumns=' . json_encode($product_columns));
WW_addScript('/j/datatables-colvis-1.0.8/ColVis.min.js');
WW_addScript('products/admin/products.js');
WW_addCSS('/ww.plugins/products/admin/products.css');
Exemple #3
0
    if (file_exists(USERBASE . '/ww.cache/core/plugins.php')) {
        require_once USERBASE . '/ww.cache/core/plugins.php';
    } else {
        $ptxt = array();
        $pchecker = preg_replace('/^<\\?php/', '', file_get_contents(SCRIPTBASE . 'ww.incs/plugin-check.php'));
        foreach ($DBVARS['plugins'] as $pname) {
            if (strpos('/', $pname) !== false) {
                continue;
            }
            $ptxt[] = '$pname=\'' . $pname . '\';';
            $ptxt[] = preg_replace('/^<\\?php/', '', file_get_contents(SCRIPTBASE . 'ww.plugins/' . $pname . '/plugin.php'));
            $ptxt[] = $pchecker;
            if (isset($plugin['triggers'])) {
                foreach ($plugin['triggers'] as $name => $fn) {
                    if (!isset($PLUGIN_TRIGGERS[$name])) {
                        $PLUGIN_TRIGGERS[$name] = array();
                    }
                    $PLUGIN_TRIGGERS[$name][] = $fn;
                }
            }
        }
        @mkdir(USERBASE . '/ww.cache/core', 0777, true);
        file_put_contents(USERBASE . '/ww.cache/core/plugins.php', '<?php' . "\n" . join('', $ptxt));
        header('Location: ' . $_SERVER['REQUEST_URI']);
        Core_quit();
    }
}
// }
register_shutdown_function('Core_shutdown');
Core_trigger('initialisation-completed');
Exemple #4
0
$smarty->assign('pagename', @$PAGEDATA->alias ? $PAGEDATA->alias : $PAGEDATA->name);
if (isset($DBVARS['theme_variant']) && $DBVARS['theme_variant']) {
    if (!file_exists(THEME_DIR . '/' . THEME . '/cs/' . $DBVARS['theme_variant'] . '.css')) {
        unset($DBVARS['theme_variant']);
        Core_configRewrite();
    } else {
        $c .= '<link rel="stylesheet" href="/ww.skins/' . THEME . '/cs/' . $DBVARS['theme_variant'] . '.css" />';
    }
}
// }
// { favicon
if (file_exists(USERBASE . '/f/skin_files/favicon.png')) {
    $c .= '<link rel="shortcut icon" href="/f/skin_files/favicon.png" />';
}
// }
$smarty->assign('METADATA', $c . Core_trigger('building-metadata'));
// }
Core_headerTime('finished');
// { display the document
ob_start();
if (strpos($template, '/') === false) {
    $template = THEME_DIR . '/' . THEME . '/h/' . $template . '.html';
}
$t = $smarty->fetch($template);
session_write_close();
$t = str_replace(array('WW_SCRIPTS_GO_HERE', 'WW_CSS_GOES_HERE', '</body>'), array(WW_getScripts(), WW_getCSS(), WW_getInlineScripts() . '</body>'), $t);
if (isset($DBVARS['cdn'])) {
    $t = str_replace(array('href="/f/', 'src="/f/', 'src="/js/', 'href="/ww.skins/', 'url(/f/', 'src="/a/f=getImg/'), array('href="//' . $DBVARS['cdn'] . '/f/', 'src="//' . $DBVARS['cdn'] . '/f/', 'src="//' . $DBVARS['cdn'] . '/js/', 'href="//' . $DBVARS['cdn'] . '/ww.skins/', 'url(//' . $DBVARS['cdn'] . '/f/', 'src="//' . $DBVARS['cdn'] . '/a/f=getImg/'), $t);
}
echo $t;
Core_flushBuffer('page', 'Content-type: text/html; Charset=utf-8');
Exemple #5
0
 /**
  * get recursive details of pages to build a menu
  *
  * @param int   $parentid the parent's ID
  * @param int   $depth    current menu depth
  * @param array $options  any further options
  *
  * @return string HTML of the sub-menu
  */
 function menuBuildFg($parentid, $depth, $options)
 {
     $PARENTDATA = Page::getInstance($parentid)->initValues();
     // { menu order
     $order = 'ord,name';
     if (isset($PARENTDATA->vars['order_of_sub_pages'])) {
         switch ($PARENTDATA->vars['order_of_sub_pages']) {
             case 1:
                 // { alphabetical
                 $order = 'name';
                 if ($PARENTDATA->vars['order_of_sub_pages_dir']) {
                     $order .= ' desc';
                 }
                 break;
                 // }
             // }
             case 2:
                 // { associated_date
                 $order = 'associated_date';
                 if ($PARENTDATA->vars['order_of_sub_pages_dir']) {
                     $order .= ' desc';
                 }
                 $order .= ',name';
                 break;
                 // }
             // }
             default:
                 // { by admin order
                 $order = 'ord';
                 if ($PARENTDATA->vars['order_of_sub_pages_dir']) {
                     $order .= ' desc';
                 }
                 $order .= ',name';
                 break;
                 // }
         }
     }
     // }
     $sql = "select id,name,type from pages where parent='" . $parentid . "' and !(special&2) order by {$order}";
     $md5 = md5($sql);
     $rs = Core_cacheLoad('pages', $md5, -1);
     if ($rs === -1) {
         $rs = dbAll($sql);
         Core_cacheSave('pages', $md5, $rs);
     }
     if ($rs === false || !count($rs)) {
         return '';
     }
     $items = array();
     foreach ($rs as $r) {
         $item = '<li>';
         $page = Page::getInstance($r['id'])->initValues();
         $item .= '<a class="menu-fg menu-pid-' . $r['id'] . '" href="' . $page->getRelativeUrl() . '">' . htmlspecialchars(__FromJson($page->name)) . '</a>';
         // { override menu if a trigger causes the override
         $submenus = Core_trigger('menu-subpages-html', array($page, $depth + 1, $options));
         if ($submenus) {
             $item .= $submenus;
         } else {
             $item .= menuBuildFg($r['id'], $depth + 1, $options);
         }
         // }
         $item .= '</li>';
         $items[] = $item;
     }
     $options['columns'] = (int) $options['columns'];
     // { return top-level menu
     if (!$depth) {
         return '<ul>' . join('', $items) . '</ul>';
     }
     // }
     $s = '';
     if ($options['style_from'] == '1') {
         if ($options['background']) {
             $s .= 'background:' . $options['background'] . ';';
         }
         if ($options['opacity']) {
             $s .= 'opacity:' . $options['opacity'] . ';';
         }
         if ($s) {
             $s = ' style="' . $s . '"';
         }
     }
     // { return 1-column sub-menu
     if ($options['columns'] < 2) {
         return '<ul' . $s . '>' . join('', $items) . '</ul>';
     }
     // }
     // { return multi-column submenu
     $items_count = count($items);
     $items_per_column = ceil($items_count / $options['columns']);
     $c = '<table' . $s . '><tr><td><ul>';
     for ($i = 1; $i < $items_count + 1; ++$i) {
         $c .= $items[$i - 1];
         if ($i != $items_count && !($i % $items_per_column)) {
             $c .= '</ul></td><td><ul>';
         }
     }
     $c .= '</ul></td></tr></table>';
     return $c;
     // }
 }
Exemple #6
0
/**
 * display the default product image
 *
 * @param array  $params array of parameters passed to the Smarty function
 * @param object $smarty the current Smarty object
 *
 * @return string the HTML
 */
function Products_image($params, $smarty)
{
    global $cdnprefix;
    $params = array_merge(array('width' => 200, 'height' => 200, 'zoom' => 0, 'zoompos' => 'right'), $params);
    $imgclasses = array();
    // { zoom
    if ($params['zoom']) {
        WW_addScript('products/zoom.js');
        $imgclasses[] = 'zoom';
        $imgclasses[] = 'zoom-pos-' . $params['zoompos'];
    }
    // }
    $product = $smarty->smarty->tpl_vars['product']->value;
    $iid = $product->getDefaultImage();
    if (!$iid) {
        $iid = Core_trigger('product-images-not-found', array($product->id));
    }
    if (!$iid) {
        return Products_imageNotFound($params, $smarty);
    }
    list($link1, $link2) = @$params['nolink'] ? array('', '') : array('<a href="' . $cdnprefix . '/a/f=getImg/' . $iid . '" target="popup">', '</a>');
    $imgclasses = count($imgclasses) ? ' class="' . join(' ', $imgclasses) . '"' : '';
    return '<div class="products-image" style="width:' . $params['width'] . 'px;height:' . $params['height'] . 'px">' . $link1 . '<img' . $imgclasses . ' src="' . $cdnprefix . '/a/f=getImg/w=' . $params['width'] . '/h=' . $params['height'] . '/' . $iid . '"/>' . $link2 . '</div>';
}
Exemple #7
0
/**
 * sends an invoice if the status is right
 *
 * @param int   $id    ID of the order
 * @param array $order details of the order
 *
 * @return null
 */
function OnlineStore_sendInvoiceEmail($id, $order = false)
{
    if ($order === false) {
        $order = dbRow("SELECT * FROM online_store_orders WHERE id={$id}");
    }
    $sendAt = (int) dbOne('select val from online_store_vars where name="invoices_by_email"', 'val');
    if ($sendAt == 0 && $order['status'] != '1') {
        return;
    }
    if ($sendAt == 1) {
        // never send
        return;
    }
    if ($sendAt == 2 && $order['status'] != '2') {
        return;
    }
    if ($sendAt == 3 && $order['status'] != '4') {
        return;
    }
    $form_vals = json_decode($order['form_vals']);
    $items = json_decode($order['items']);
    $short_domain = str_replace('www.', '', $_SERVER['HTTP_HOST']);
    // { work out from/to
    $page = Page::getInstanceByType('online-store');
    $page->initValues();
    $from = 'noreply@' . $short_domain;
    $bcc = '';
    if ($page && isset($page->vars['online_stores_admin_email']) && $page->vars['online_stores_admin_email']) {
        $from = $page->vars['online_stores_admin_email'];
        $bcc = $page->vars['online_stores_admin_email'];
    }
    if (isset($form_vals->billing_email)) {
        $form_vals->Billing_Email = $form_vals->billing_email;
    }
    if (!isset($form_vals->Billing_Email) || !$form_vals->Billing_Email) {
        $form_vals->Billing_Email = $form_vals->Email;
    }
    $headers = '';
    if ($bcc) {
        $sendToAdmin = (int) dbOne('select val from online_store_vars where name="invoices_by_email_admin"', 'val');
        if (!$sendToAdmin) {
            $headers .= 'BCC: ' . $bcc . "\r\n";
        }
    }
    // }
    Core_trigger('send-invoice', array($order));
    // { send invoice
    if ($form_vals->Billing_Email != '*****@*****.**') {
        Core_mail($form_vals->Billing_Email, '[' . $short_domain . '] invoice #' . $id, $order['invoice'], $from, '_body', $headers);
    }
    // }
    // { handle item-specific stuff (vouchers, stock control)
    foreach ($items as $item_index => $item) {
        if (!$item->id) {
            continue;
        }
        $p = Product::getInstance($item->id);
        $pt = ProductType::getInstance($p->vals['product_type_id']);
        if ($pt->is_voucher) {
            $html = $pt->voucher_template;
            // { common replaces
            $html = str_replace('{{$_name}}', $p->name, $html);
            $html = str_replace('{{$description}}', $p->vals['description'], $html);
            $html = str_replace('{{$_recipient}}', $form_vals->Billing_Email, $html);
            $html = str_replace('{{$_amount}}', $p->vals['os_voucher_value'], $html);
            // }
            if (strpos($html, '{{PRODUCTS_QRCODE}}') !== false) {
                // qr code
                $url = 'http://' . $_SERVER['HTTP_HOST'] . '/a/p=online-store/f=checkQrCode/' . 'oid=' . $order['id'] . '/pid=' . $item_index . '/md5=' . md5($order['invoice']);
                $html = str_replace('{{PRODUCTS_QRCODE}}', '<img src="http://' . $_SERVER['HTTP_HOST'] . '/a/p=online-store/f=getQrCode/b64=' . urlencode(base64_encode($url)) . '"/>', $html);
            }
            Core_mail($form_vals->Billing_Email, '[' . $short_domain . '] voucher', $html, $from, '_body', $headers);
        }
        // { stock control
        if (isset($p->vals['online-store'])) {
            $valsOS = $p->vals['online-store'];
            $stock_amount = (int) @$valsOS['_stock_amt'] - $item->amt;
            $valsOS['_stock_amt'] = $stock_amount;
            $sold_amount = (int) @$valsOS['_sold_amt'] + $item->amt;
            $valsOS['_sold_amt'] = $sold_amount;
            dbQuery('update products set' . ' online_store_fields="' . addslashes(json_encode($valsOS)) . '"' . ', os_amount_in_stock=' . $stock_amount . ', os_amount_sold=' . $sold_amount . ', date_edited=now()' . ' where id=' . $item->id);
        }
        // }
    }
    Core_cacheClear('products');
    // }
}
Exemple #8
0
function Menu_getChildren($parentid, $currentpage = 0, $isadmin = 0, $topParent = 0)
{
    global $_languages;
    $md5 = md5($parentid . '|' . $currentpage . '|' . $isadmin . '|' . $topParent . '|' . join(',', $_languages) . '|' . @$_SESSION['language']);
    $pageParentFound = 0;
    // { first, check to see if this is a menu that should be handled by a plugin
    if (preg_match('/[a-z]/', $parentid)) {
        $bits = explode('_', $parentid);
        return $GLOBALS['PLUGINS'][$bits[0]]['triggers']['menu-subpages'](null, $bits[1]);
    }
    // }
    if ($parentid) {
        $PARENTDATA = Page::getInstance($parentid);
        $PARENTDATA->initValues();
    } else {
        $PARENTDATA = (object) array('id' => '0', 'order_of_sub_pages' => 'ord', 'order_of_sub_pages_dir' => 'asc');
    }
    $filter = $isadmin ? '' : '&& !(special&2)';
    // { override menu if a trigger causes the override
    $trigger = Core_trigger('menu-subpages', $PARENTDATA);
    if ($trigger) {
        return $trigger;
    }
    // }
    // { menu order
    $order = 'ord,name';
    if (isset($PARENTDATA->vars['order_of_sub_pages'])) {
        switch ($PARENTDATA->vars['order_of_sub_pages']) {
            case 1:
                // { alphabetical
                $order = 'name';
                if ($PARENTDATA->vars['order_of_sub_pages_dir']) {
                    $order .= ' desc';
                }
                break;
                // }
            // }
            case 2:
                // { associated_date
                $order = 'associated_date';
                if ($PARENTDATA->vars['order_of_sub_pages_dir']) {
                    $order .= ' desc';
                }
                $order .= ',name';
                break;
                // }
            // }
            default:
                // { by admin order
                $order = 'ord';
                if ($PARENTDATA->vars['order_of_sub_pages_dir']) {
                    $order .= ' desc';
                }
                $order .= ',name';
                // }
        }
    }
    // }
    $sql = 'select id as subid,id,name,alias,type,(select count(id) from pages where ' . "parent=subid {$filter}) as numchildren from pages where parent='" . $parentid . "' {$filter} order by {$order}";
    $rs = Core_cacheLoad('pages', md5($sql), -1);
    if ($rs == -1) {
        $rs = dbAll($sql);
        Core_cacheSave('pages', md5($sql), $rs);
    }
    $menuitems = array();
    $i = 0;
    foreach ($rs as $k => $r) {
        $PAGEDATA = Page::getInstance($r['id']);
        if (isset($PAGEDATA->banned) && $PAGEDATA->banned) {
            continue;
        }
        $c = array();
        $c[] = $parentid == $topParent ? 'menuItemTop' : 'menuItem';
        if (!$i++) {
            $c[] = 'first';
        }
        $c[] = 'c' . $i;
        // { see if the menu item has sub-pages according to a trigger
        $trigger = is_array(Core_trigger('menu-subpages', $PAGEDATA));
        if ($trigger) {
            $r['numchildren'] = 1;
            $rs[$k]['numchildren'] = 1;
        }
        // }
        if ($r['numchildren']) {
            $c[] = 'ajaxmenu_hasChildren dropdown';
        }
        if ($r['id'] == $currentpage) {
            $c[] = 'ajaxmenu_currentPage';
            $c[] = 'current-page';
            $pageParentFound = 1;
        } else {
            if ($r['numchildren'] && !$pageParentFound && Menu_containsPage($currentpage, $r['id'])) {
                $c[] = 'ajaxmenu_containsCurrentPage';
                $pageParentFound = 1;
            }
        }
        $rs[$k]['classes'] = join(' ', $c);
        $rs[$k]['link'] = $PAGEDATA->getRelativeURL();
        $rs[$k]['name'] = __FromJson($PAGEDATA->name);
        $rs[$k]['parent'] = $parentid;
        $menuitems[] = $rs[$k];
    }
    return $menuitems;
}
Exemple #9
0
<?php

/**
 * admin footer
 *
 * PHP version 5.2
 *
 * @category None
 * @package  None
 * @author   Kae Verens <*****@*****.**>
 * @license  GPL 2.0
 * @link     http://kvsites.ie/
 */
echo '</div></div>' . WW_getScripts() . WW_getCSS() . Core_trigger('admin-scripts') . '<!-- end of admin --></body></html>';
Exemple #10
0
    // show authorised payments (for retrieval)
    $c .= '<li><a href="#online-store-authorised">' . __('Authorised Payments') . '</a></li>';
}
$c .= '</ul>';
// { orders
$c .= '<div id="online-store-orders">';
if (!isset($_SESSION['online-store'])) {
    $_SESSION['online-store'] = array();
}
if (!isset($_SESSION['online-store']['status'])) {
    $_SESSION['online-store']['status'] = 1;
}
if (isset($_REQUEST['online-store-status'])) {
    $_SESSION['online-store']['status'] = $_REQUEST['online-store-status'];
}
$c .= Core_trigger('online-store-list-orders');
$c .= '<p>' . __('This list shows orders with the status: ') . '<select id="online-store-status">';
$statii = array('0' => __('Unpaid'), '4' => __('Authorised'), '1' => __('Paid'), '5' => __('Prepared'), '2' => __('Dispatched'), '3' => __('Cancelled'), 'all' => __('Show All Orders'));
foreach ($statii as $k => $v) {
    $c .= '<option value="' . $k . '"';
    if ($k == $_SESSION['online-store']['status']) {
        $c .= ' selected="selected"';
    }
    $c .= '>' . htmlspecialchars($v) . '</option>';
}
$c .= '</select></p>';
// { filter for SQL
if ($_SESSION['online-store']['status'] == 1) {
    $filter = 'status=1 or authorised=1';
} else {
    if ($_SESSION['online-store']['status'] == 'all') {
Exemple #11
0
        echo '<label>' . __('Amount in stock') . ': ' . '<input class="small" name="stockcontrol_total" value="' . (int) @$pdata['stockcontrol_total'] . '"/></label>';
        // }
        // { stock control for products which have user-selectable options
        if (count($options)) {
            $detail = @$pdata['stockcontrol_details'];
            if (!$detail) {
                $detail = '[]';
            }
            echo '<table id="stockcontrol-complex"></table><script>' . 'window.stockcontrol_detail=' . $detail . ';window.stockcontrol_options=["' . join('", "', $options) . '"];</script><a href="#" id="' . 'stockcontrol-addrow">add row</a>' . '<p>' . __('To remove rows, set their options to "-- Choose --" and save the' . ' product.') . '</p>';
        }
        // }
        echo '</div>';
    }
}
// }
Core_trigger('products-show-edit-form-tabs', array($pdata, $product_type));
// { categories
echo '<h2>' . __('Categories') . '</h2><div id="categories"><p>' . __('At least one category must be chosen.') . '</p>';
// { add selected categories to the list
$rs = ProductsCategoriesProducts::getByProductId($id);
echo '<ul id="categories-wrapper">';
foreach ($rs as $r) {
    $cat = ProductCategory::getInstance($r);
    if (!$cat) {
        continue;
    }
    echo '<li><input type="checkbox" name="product_categories[' . $cat->vals['id'] . ']" checked="checked"/>' . $cat->getBreadcrumbs() . '</li>';
}
echo '</ul><button id="category-add">Add Category</button>';
// }
$cid = (int) @$pdata['default_category'];
Exemple #12
0
/**
 * send registration token
 *
 * @return array status
 */
function Core_sendRegistrationToken()
{
    $email = @$_REQUEST['email'];
    if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
        return array('error' => 'invalid email address');
    }
    $sql = 'select id from user_accounts where email="' . addslashes($email) . '"';
    if (dbOne($sql, 'id')) {
        return array('error' => 'already registered');
    }
    if (!isset($_SESSION['privacy'])) {
        $_SESSION['privacy'] = array();
    }
    Core_trigger('user-registration-token-sent');
    $_SESSION['privacy']['registration'] = array('token' => rand(10000, 99999), 'custom' => array(), 'email' => $email);
    if (@$_REQUEST['custom'] && is_array($_REQUEST['custom'])) {
        $_SESSION['privacy']['registration']['custom'] = $_REQUEST['custom'];
    }
    $emaildomain = str_replace('www.', '', $_SERVER['HTTP_HOST']);
    $from = Core_siteVar('useraccounts_registrationtokenemail_from');
    Core_mail($email, Core_siteVar('useraccounts_registrationtokenemail_subject'), str_replace('%token%', $_SESSION['privacy']['registration']['token'], Core_siteVar('useraccounts_registrationtokenemail_message')), $from);
    return array('ok' => 1);
}
Exemple #13
0
function OnlineStore_adminInvoiceNumberUpdate()
{
    $id = (int) $_REQUEST['id'];
    $num = (int) $_REQUEST['num'];
    dbQuery('update online_store_orders set invoice_num=' . $num . ' where id=' . $id);
    $order = dbRow('select id,invoice_num,meta from online_store_orders where id=' . $id);
    $meta = json_decode($order['meta'], true);
    $order['meta'] = $meta;
    Core_trigger('online-store-order-invoice-num-changed', array($order));
    return true;
}
Exemple #14
0
/**
 * display a user's profile
 *
 * @return string HTML of the profile
 */
function Privacy_profileGet()
{
    $uid = addslashes($_SESSION['userdata']['id']);
    $user = dbRow('select * from user_accounts where id=' . $uid);
    $html = Core_trigger('privacy_overload', array($user));
    if ($html) {
        return $html;
    }
    $contact = json_decode($user['contact'], true);
    $phone = !isset($contact['phone']) || $contact['phone'] == '' ? '<a href="javascript:edit_user_dialog(' . $user['id'] . ');">' . __('Add', 'core') . '</a>' : htmlspecialchars($contact['phone']);
    // get array of groups the user is a member of
    $groups = array();
    $sql = 'select groups_id from users_groups where user_accounts_id=' . $uid;
    $group_ids = dbAll($sql, '', 'users_groups');
    $extras = dbOne('select * from user_accounts where id=' . $uid . ' limit 1', 'extras');
    $extras = json_decode($extras, true);
    $remainingCredits = isset($extras['free-credits']) ? $extras['free-credits'] : 0;
    $remainingPaidCredits = isset($extras['paid_credits']) ? $extras['paid_credits'] : 0;
    if (!array_key_exists('free-credits', $extras)) {
        // the user has not been initialised
        $remainingCredits = dbOne('SELECT * FROM `site_vars` WHERE `name`="max-free-credits"', 'value');
        $extras['free-credits'] = $remainingCredits;
        dbQuery("update user_accounts set extras='" . json_encode($extras) . "' where id=" . $uid);
    }
    foreach ($group_ids as $key => $id) {
        array_push($groups, dbOne('select name from groups where id=' . $id['groups_id'], 'name'));
    }
    $groups = implode(',', $groups);
    $html = '<a class="logout" href="/?logout=1" style="float:right">' . __('Logout') . '</a><h2>' . htmlspecialchars($user['name']) . '</h2>' . '<div id="tabs"><ul>' . '<li><a href="#details">' . __('User Details', 'core') . '</a></li>' . '<li><a href="#address">' . __('Address', 'core') . '</a></li>' . '</ul>' . '<div id="details"><p style="float:right">' . '<a href="javascript:edit_user_dialog(' . $user['id'] . ');"' . ' id="edit-user-info">' . __('Edit Details', 'core') . '</a>' . ' <a href="javascript:change_password_dialog(' . $user['id'] . ');"' . ' id="user-change-password" style="diplay:inline">' . __('Change Password', 'core') . '</a></p>' . '<table id="user-info" style="border:1px solid #ccc;margin:10px">' . '<tr><th>' . __('Email', 'core') . '</th><td>' . htmlspecialchars($user['email']) . '</td></tr>' . '<tr><th>' . __('Phone', 'core') . '</th><td>' . $phone . '</td></tr>' . '<tr><th>' . __('Avatar', 'core') . '</th><td><span id="avatar-wrapper"' . ' data-uid="' . $uid . '"></span></td></tr>';
    // { credits
    $page = $GLOBALS['PAGEDATA'];
    if (isset($page->vars['userlogin_can_purchase_credits']) && $page->vars['userlogin_can_purchase_credits']) {
        $html .= '<tr class="remaining-credits"><th>' . __('RemainingCredits', 'core') . '</th>' . '<td>' . $remainingCredits . '</td></tr>' . '<tr class="paid-credits"><th>' . __('PaidCredits', 'core') . '</th>' . '<td>' . $remainingPaidCredits . '&nbsp;' . '<button id="buy-credits">Buy Credits</button></td></tr>';
    }
    // }
    $html .= '</table></div>' . '<div id="address"><a id="new-address" href="javascript:add_address();"' . ' style="float:right">[+]' . __('Add Address') . '</a>' . '<div id="address-container"><table>';
    if ($addresses = json_decode(@$user['address'], true)) {
        foreach ($addresses as $name => $address) {
            $select = @$address['default'] == 'yes' ? ' checked="checked"' : '';
            $html .= ' <tr> <td> <input type="radio"' . $select . ' name="default-address" value="' . $name . '"/> </td> <td>' . str_replace(' ', '-', $name) . '</td> <td> <a href="javascript:edit_addr' . 'ess(\'' . $name . '\');" class="edit-addr" name="' . $name . '">' . __('edit') . '.</a> <a href="javascript:;" ' . 'class="delete-addr" name="' . $name . '">' . __('[x]') . '</a> </td> </tr> ';
        }
    } else {
        $html .= '<i>' . __('No address(es) saved yet', 'core') . '</i>';
    }
    $html .= '</table></div><br style="clear:both"/></div>
	</div>';
    WW_addScript('privacy/js.js');
    WW_addScript('privacy/frontend/change_password.js');
    $html .= Core_trigger('privacy_user_profile', array($user));
    return $html;
}