Example #1
0
 public function SaveAction()
 {
     $actions = $this->params['action'];
     $subactions = $this->params['subaction'];
     $controllerRez = array();
     if (is_array($subactions)) {
         foreach ($subactions as $controllerName => $controllerData) {
             foreach ($controllerData as $actionName => $actionData) {
                 foreach ($actionData as $subactionName => $tmp) {
                     $controllerRez[$controllerName][$actionName][] = $subactionName;
                 }
             }
         }
     }
     if (is_array($actions)) {
         foreach ($actions as $controllerName => $controllerData) {
             foreach ($controllerData as $actionName => $tmp) {
                 if (!isset($controllerRez[$controllerName][$actionName])) {
                     $controllerRez[$controllerName][$actionName] = array();
                 }
             }
         }
     }
     $this->setModel("User_types");
     $rights = serialize($controllerRez);
     $this->model->load($this->params['userType']);
     $this->model->set("rights", $rights);
     $this->model->update();
     $router = getManager('CRouter');
     $router->redirect($router->createUrl("Rights", "Index", array("userType" => $this->params['userType'])));
 }
Example #2
0
 public function checkAccess($controllerName, $actionName, $subactionName = '')
 {
     //$user = getManager('CUser');
     $user = getManager('user');
     $userRights = unserialize($user->getRights());
     if (isset($userRights[$controllerName])) {
         if (isset($userRights[$controllerName][$actionName])) {
             if (!strlen($subactionName) || in_array($subactionName, $userRights[$controllerName][$actionName])) {
                 return true;
             } else {
                 return false;
             }
         } else {
             // TODO:: hardcoded admin controller name
             if ($controllerName == 'AdminController') {
                 //$router = getManager('CRouter');
                 $router = getManager('router');
                 $router->redirect($router->createUrl('Admin', 'LoginForm'));
             }
             $flashMessage = getManager('CFlashMessage');
             $flashMessage->setMessage("Доступ запрещен (Екшн " . $actionName . ")", FLASH_MSG_TYPES::$error);
             return false;
         }
     } else {
         // TODO:: hardcoded admin controller name
         if ($controllerName == 'AdminController') {
             //$router = getManager('CRouter');
             $router = getManager('router');
             $router->redirect($router->createUrl('Admin', 'LoginForm'));
         }
         $flashMessage = getManager('CFlashMessage');
         $flashMessage->setMessage("Доступ запрещен (Контроллер " . $controllerName . ")", FLASH_MSG_TYPES::$error);
         return false;
     }
 }
Example #3
0
 public function displayAll()
 {
     $msgTypes = get_class_vars('FLASH_MSG_TYPES');
     $session = getManager('CSession');
     foreach ($msgTypes as $type) {
         if (!is_array($type)) {
             $msg = $session->read("FLASH_MSG_" . $type);
             if ($msg) {
                 $this->renderMsg($msg, $type);
             }
             $session->clear("FLASH_MSG_" . $type);
         }
     }
 }
Example #4
0
/**
 * Print all objects in a class
 */
function print_os($class)
{
    $m = getManager();
    if (!($os = $m->getAll($class))) {
        echo "no object in class {$class}\n";
        return;
    }
    $i = 0;
    foreach ($os as $o) {
        echo $o;
        echo "\n";
        if ($i++ > 5) {
            break;
        }
    }
}
Example #5
0
 public function SaveAction()
 {
     echo "TestController/SaveAction<br/><br/>";
     $data = $this->params;
     $form = new CFormData();
     $form->setFields($this->formFields);
     $form->setData($data);
     $router = getManager('CRouter');
     if ($form->validate()) {
         $this->model->setData($data);
         if (isset($this->params['id'])) {
             $this->model->id = $this->params['id'];
             $this->model->update();
             echo '</pre>';
             echo 'Запись обновлена. <a href="' . $router->createUrl('Test') . '">На главную</a></pre>';
         } else {
             $this->model->insert();
             echo '</pre>';
             echo 'Запись вставлена. <a href="' . $router->createUrl('Test') . '">На главную</a></pre>';
         }
     } else {
         if (isset($this->params['id'])) {
             $form->setTitle('Редактирование элемента');
             $form->setHidden(array('id' => $this->params['id']));
         } else {
             $form->setTitle('Добавление элемента');
         }
         $form->setAction($router->createUrl('Test', 'Save'));
         $form->setSubmitText('Сохранить');
         $form->setCancelText('Назад');
         $form->setCancelUrl($router->createUrl('Test'));
         $form->initForm();
         $this->view->content = $form->renderForm();
         $this->view->display();
     }
     echo '</pre>';
 }
Example #6
0
<?php

/**
 * $Id: update.php 1043 2007-03-06 12:58:53Z nauhygon $
 * 
 * Copyright(c) 2005 by Oak Nauhygon. All rights reserved.
 * 
 * @author Oak Nauhygon <*****@*****.**>
 * @version $Revision: 1043 $ $Date: 2007-03-06 07:58:53 -0500 (Tue, 06 Mar 2007) $
 * @package ezpdo_bench
 * @subpackage ezpdo_bench.books
 */
include_once dirname(__FILE__) . '/common.php';
// get the persistence manager
$m = getManager();
if (!($authors = $m->find("from Author where name = ?", $author_name))) {
    echo "Cannot find author [" . $author_name . "]\n";
    exit;
}
// go through each author
foreach ($authors as $author) {
    // change
    $name0 = $author->name;
    $author->name = $name0 . " (updated)";
    $author->commit();
    // change back
    $author->name = $name0;
    $author->commit();
}
echo "Author [{$author_name}] is updated. Use `php find.php` to check.\n";
showPerfInfo();
Example #7
0
 /**
  * @return Test2Manager
  */
 public static function getTest2Manager()
 {
     return getManager('Test2');
 }
Example #8
0
<?php

// initialize
include_once '../../../common/init.php';
if (!isLoggedInAdmin()) {
    redirect('');
} else {
    // include needed database functions
    include_once $BASE_PATH . 'database/auth.php';
    $id = $_GET['id'];
    // fetch data
    $manager = getManager($id);
    // send data to smarty
    $smarty->assign('manager', $manager);
    // display smarty template
    $smarty->display('manager/managers/view_manager.tpl');
}
Example #9
0
                    <td class="uemail">
                       <?php 
    echo $do['email'];
    ?>
                    </td>
                    <td class="upassword">
                        <?php 
    echo $do['password'];
    ?>
                    </td>
                    <td class="umanager" mid="<?php 
    echo $do['manager_id'];
    ?>
">
                        <?php 
    echo getManager($do['manager_id']);
    ?>
                    </td>
                    <td>
                        <?php 
    echo date("d.m.Y H:i", strtotime(getLastLoginDate($do["id"])));
    ?>
                    </td>
                    <td align="right">
                        <?php 
    $query = mysql_query("SELECT SUM(cart.quantity * cart.price) AS incart FROM cart LEFT JOIN orders ON cart.order_id = orders.id LEFT JOIN products ON cart.product_id = products.id LEFT JOIN categories ON products.category_id = categories.id WHERE orders.status = 0 AND user_id = '" . $do["id"] . "' AND !categories.expected");
    $res = mysql_fetch_array($query);
    echo number_format($res['incart'] + 0, 2, '.', ' ');
    ?>
 MDL
                    </td>
 function SaveBranchAction()
 {
     //var_dump($this -> branch_name, $this -> branch_access, $this -> branch_parent, $this -> branch_catalog);
     $session = getManager('CSession');
     $user = unserialize($session->read('user'));
     $user_id = 0;
     if (isset($user['id']) && (int) $user['id'] > 0) {
         $user_id = (int) $user['id'];
     }
     $this->setModel("BlogsModel");
     $this->model->resetSql();
     $this->model->where('user_id = ' . $user_id);
     $this->model->setData($this->model->getOne());
     // Set blog id for rightly check Branch Access
     $this->blog_id = (int) $this->model->get('id');
     $branch_id = (int) $this->branch_id;
     $this->checkBranchAccess($branch_id, $user_id);
     $this->setModel("BlogTree");
     $this->model->load($branch_id);
     $branch_data = $this->model->getData();
     // Set data to tree model
     $this->setModel("BlogTree");
     $this->model->resetSql();
     $this->model->set('id', isset($branch_data['id']) ? (int) $branch_data['id'] : null);
     $this->model->set('blog_id', $this->blog_id);
     $this->model->set('name', $this->branch_name);
     $this->model->set('access', (int) $this->branch_access);
     $this->model->set('blogs_catalog_id', (int) $this->branch_catalog);
     $this->model->set('blog_banner_id', 0);
     // TODO::0
     //$this -> model -> set('key', '');
     if (!count($branch_data)) {
         $this->model->set('key', '');
     } else {
     }
     $this->model->set('level', 0);
     $branch_id = (int) $this->model->save();
     $router = getManager('CRouter');
     $router->redirect($router->createUrl('Blog', 'EditBranch', array('id' => $branch_id)));
 }
Example #11
0
<?php

// initialize
include_once '../../../common/init.php';
if (!isLoggedInAdmin()) {
    redirect('');
} else {
    // include needed database functions
    include_once $BASE_PATH . 'database/auth.php';
    // fetch data
    $manager = getManager($_GET['id']);
    // send data to smarty
    $smarty->assign('manager', $manager);
    // display smarty template
    $smarty->display('manager/auth/form_edit.tpl');
}
Example #12
0
 private function getActionName($params)
 {
     if (isset($params[1]) && strlen(trim($params[1]))) {
         $actionName = ucwords($params[1]);
         $meth = get_class_methods($this->controllerName);
         if (in_array($actionName . 'Action', $meth)) {
             return ucwords($actionName) . 'Action';
         } else {
             $flashMessage = getManager('CFlashMessage');
             $session = getManager('CSession');
             $flashMessage->setMessage("Действие не существует", FLASH_MSG_TYPES::$error);
             $lastPath = $session->read('LAST_PATH');
             if ($lastPath) {
                 $this->redirect($lastPath);
             } else {
                 return DEFAULT_ACTION . 'Action';
             }
             return DEFAULT_ACTION . 'Action';
         }
     } else {
         return DEFAULT_ACTION . 'Action';
     }
 }
    global $managerList;
    $limit_start = $counter;
    $limit_stop = $counter + 20;
    $conn = db_connect();
    $conn->set_charset("utf8");
    // 指定数据库字符编码
    $result = $conn->query("select manager.id, manager.name, manager.avatar, company.name as company, manager.comments_number, manager.score from decoration_manager as manager, decoration_company as company WHERE manager.company = company.id LIMIT {$limit_start}, {$limit_stop} ");
    if (!$result) {
        throw new Exception('Search user score failed.');
    }
    $num_result = $result->num_rows;
    $managerList['total'] = $num_result;
    //数据库查询出来的字段全部是字符串,另外json定义跟数据库定义可能不一致,所以需要做相应地转换
    for ($i = 0; $i < $num_result; $i++) {
        $row_db = $result->fetch_assoc();
        $converted_row = array();
        //保存转换后的单条记录
        $converted_row['id'] = intval(stripslashes($row_db['id']));
        $converted_row['name'] = stripslashes($row_db['name']);
        $converted_row['avatar'] = stripslashes($row_db['avatar']);
        $converted_row['company'] = stripslashes($row_db['company']);
        $converted_row['comments'] = intval(stripslashes($row_db['comments_number']));
        $converted_row['score'] = intval(stripslashes($row_db['score']));
        $managerList["row"][$i] = $converted_row;
    }
    $result->free();
    $conn->close();
    return json_encode($managerList);
}
$jsonStr = getManager($param_counter);
print "{$jsonStr}";
Example #14
0
 function DeleteAction()
 {
     die(__METHOD__);
     $router = getManager('CRouter');
     $router->redirect($router->createUrl('AdminParameter', 'EditGroup', array('id' => $this->controller_id)));
 }