Пример #1
0
function do_edit_save($aid, $params)
{
    $pid = cf\api\admin\doAction($aid, $params);
    if (array_key_exists('id', $params)) {
        $pid = $params['id'];
    }
    //update categories
    $pos = cf\query2arrays('SELECT group_id,sort_order FROM cf_products_in_groups WHERE product_id=:id', array('id' => $pid), false, 'group_id');
    cf\execQuery('DELETE FROM cf_products_in_groups WHERE product_id=:id', array('id' => $pid));
    $categories = cf\param::exist('category') ? cf\param::get('category') : array();
    $q = cf\createQuery('INSERT INTO cf_products_in_groups (group_id,product_id,sort_order) VALUES(:groupId,:productId,:sortOrder)', array('productId' => $pid));
    foreach ($categories as $catId) {
        $q->setParam('groupId', $catId);
        $q->setParam('sortOrder', array_key_exists($catId, $pos) ? $pos[$catId]['sort_order'] : 500);
        $q->execute();
    }
    //update attributes
    if (cf\param::exist('attributes')) {
        $attrValues = cf\param::get('attributes');
        $attributes = new cf\ProductAttributes($pid, true);
        foreach ($attributes as $attr) {
            if (array_key_exists($attr->id(), $attrValues)) {
                $attr->setValue($attrValues[$attr->id()]);
            }
        }
        $product = new cf\Product($pid);
        $product->setAttributes($attributes);
    }
}
Пример #2
0
function do_edit_save($aid, $params)
{
    $uid = false;
    if (array_key_exists('id', $params)) {
        $uid = $params['id'];
        $pass = trim($params['password']);
        unset($params['password']);
        cf\api\admin\doAction($aid, $params);
        if ($pass) {
            cf\User::setPassword($uid, $pass);
        }
    } else {
        $uid = cf\User::register($params['login'], $params['password'], $params['name'], $params['email'], $params['descr']);
    }
    if (cf\param::exist('roles')) {
        $roles = array_keys(cf\param::get('roles'));
        cf\execQuery('DELETE FROM cf_user_roles WHERE user_id=:uid', array('uid' => $uid));
        $q = cf\createQuery('INSERT INTO cf_user_roles (user_id,role_id) VALUES(:userId,:roleId)');
        $q->setParam('userId', $uid);
        foreach ($roles as $rid) {
            $q->setParam('roleId', $rid);
            $q->execute();
        }
    }
}
Пример #3
0
function do_edit_save($aid, $params)
{
    $pid = cf\api\admin\doAction($aid, $params);
    if (array_key_exists('id', $params)) {
        $pid = $params['id'];
    }
    global $fk;
    if (!$fk) {
        //it's not an option
        //update categories
        $pos = cf\query2arrays('SELECT page_id,sort_order FROM cf_products_in_category WHERE product_id=:id', array('id' => $pid), false, 'page_id');
        cf\execQuery('DELETE FROM cf_products_in_category WHERE product_id=:id', array('id' => $pid));
        $categories = cf\param::exist('category') ? cf\param::get('category') : array();
        $q = cf\createQuery('INSERT INTO cf_products_in_category (page_id,product_id,sort_order) VALUES(:categoryId,:productId,:sortOrder)', array('productId' => $pid));
        foreach ($categories as $catId) {
            $q->setParam('categoryId', $catId);
            $q->setParam('sortOrder', array_key_exists($catId, $pos) ? $pos[$catId]['sort_order'] : 500);
            $q->execute();
        }
    }
    //update attributes
    if (cf\param::exist('attributes')) {
        cf\execQuery("DELETE FROM cf_product_attributes WHERE product_id=:id", array('id' => $pid));
        $q = cf\createQuery("INSERT INTO cf_product_attributes (product_id, attribute_id, attribute_value) VALUES (:pid,:aid,:val)");
        $attrValues = cf\param::get('attributes');
        foreach ($attrValues as $id => $val) {
            $q->setParam('pid', $pid);
            $q->setParam('aid', $id);
            $q->setParam('val', $val);
            $q->execute();
        }
    }
}
Пример #4
0
function do_edit_save($aid, $params)
{
    $channelId = cf\api\admin\doAction($aid, $params);
    if (array_key_exists('id', $params)) {
        $channelId = $params['id'];
    }
    //update categories
    cf\execQuery('DELETE FROM cf_rss_channel_to_category WHERE channel_id=:id', array('id' => $channelId));
    $cats = cf\param::exist('cat') ? cf\param::get('cat') : array();
    $q = cf\createQuery('INSERT INTO cf_rss_channel_to_category (category_id,channel_id) VALUES(:catId,:channelId)', array('channelId' => $channelId));
    foreach ($cats as $catId) {
        $q->setParam('catId', $catId);
        $q->execute();
    }
}
Пример #5
0
function do_edit_save($aid, $params)
{
    $iId = cf\api\admin\doAction($aid, $params);
    if (array_key_exists('id', $params)) {
        $iId = $params['id'];
    }
    //update albums
    $pos = cf\query2arrays('SELECT album_id,sort_order FROM cf_gallery_image_in_album WHERE image_id=:id', array('id' => $iId), false, 'album_id');
    cf\execQuery('DELETE FROM cf_gallery_image_in_album WHERE image_id=:id', array('id' => $iId));
    $albums = cf\param::exist('album') ? cf\param::get('album') : array();
    $q = cf\createQuery('INSERT INTO cf_gallery_image_in_album (album_id,image_id,sort_order) VALUES(:albumId,:imageId,:sortOrder)', array('imageId' => $iId));
    foreach ($albums as $albumId) {
        $q->setParam('albumId', $albumId);
        $q->setParam('sortOrder', array_key_exists($albumId, $pos) ? $pos[$albumId]['sort_order'] : 500);
        $q->execute();
    }
}
Пример #6
0
<?php

try {
    require_once 'core.php';
    require_once cf\Config::path . 'api/admin.php';
    $view = cf\api\admin\getView(cf\param::get('vid'));
    $aid = cf\param::get('aid');
    $k = cf\param::exist('k') ? cf\param::get('k') : array();
    if (cf\param::exist('do')) {
        $params = array_merge(cf\param::get('p'), $k);
        $do = cf\param::get('do');
        $fileURLs = cf\param::get('URL', array());
        foreach ($fileURLs as $fnm => $url) {
            if ($url) {
                $_FILES[$fnm] = array('name' => $url, 'type' => 'url');
            }
        }
        if (function_exists('do_edit_save')) {
            do_edit_save($aid, $params);
        } else {
            cf\api\admin\doAction($aid, $params);
        }
        if ('save' == $do) {
            forward(cf\param::get('referer'));
        }
    }
    $action = cf\api\admin\getAction($aid, $k);
    $smarty->assign('k', json_encode($k));
    $smarty->assign('view', $view);
    $smarty->assign('action', $action);
    $smarty->assign('referer', cf\param::get('referer'));
Пример #7
0
<?php

require_once 'core.php';
require_once cf\Config::path . 'api/admin.php';
$view = cf\api\admin\getView(cf\param::get('vid'));
$smarty->assign('view', $view);
$smarty->assign('fk', cf\param::exist('fk') ? cf\param::asInt('fk') : false);
$name = $view['name'];
if (cf\param::exist('tid') && cf\param::exist('fk')) {
    $name = cf\api\admin\getNameByKey(cf\param::get('tid'), cf\param::get('fk'));
}
show('list', $name);
Пример #8
0
    return $args;
}
try {
    list($module, $method) = explode('.', cf\param::get('method'));
    require_once \cf\Config::path . "api/{$module}.php";
    $method = "cf\\api\\{$module}\\{$method}";
    if (!function_exists($method)) {
        throw new Exception("Invalid method - {$method}");
    }
    $returnHTML = false;
    $res = call_user_func_array($method, params2MethodArgs($method, cf\param::toArray()));
    if (cf\param::exist('return')) {
        $retVarName = cf\param::get('return');
        ${$retVarName} = $res;
    }
    if (cf\param::exist('forward')) {
        $url = cf\param::get('forward');
        if ('referer' == $url) {
            $url = $_SERVER['HTTP_REFERER'];
        } else {
            eval('$url="' . $url . '";');
        }
        forward($url);
    }
    if (!$returnHTML) {
        header('Content-Type: application/json');
        $res = json_encode($res);
    }
    echo $res;
} catch (Exception $e) {
    header("HTTP/1.0 500 Error occured");
Пример #9
0
define('NO_AUTH', 1);
require_once 'core.php';
$err = '';
$user = cf\User::getLoggedIn();
if (cf\param::exist('logout')) {
    if ($user) {
        $user->logout();
    }
} elseif ($user) {
    forward(cf\param::exist('referer') ? cf\param::asString('referer') : 'index.php');
} elseif (cf\param::exist('log')) {
    $log = cf\param::asString('log');
    $pwd = cf\param::asString('pwd');
    try {
        if ($log && $pwd && cf\User::login($log, $pwd, cf\param::exist('remember'))) {
            forward(cf\param::exist('referer') ? cf\param::asString('referer') : 'index.php');
        }
    } catch (Exception $e) {
        switch ($e->getCode()) {
            case cf\User::ERR_INVALID_USER:
                $err = 'Неправильное имя пользователя';
                break;
            case cf\User::ERR_PASSWORD_INCORRECT:
                $err = 'Неправильный пароль';
                break;
        }
    }
}
$smarty->assign('errMsg', $err);
$smarty->display('login.tpl');