/** * Fonction permettant d'effectuer le comptage sur le dashboard */ public function dashboard() { $admin = new Model_Admin(); $dashboardCountNews = $admin->countNews(); $dashboardCountArticles = $admin->countArticles(); $dashboardCountUsers = $admin->countUsers(); /*$dashboardCountComments = $admin->countComments();*/ require_once $_SERVER['DOCUMENT_ROOT'] . "/ecommerce/views/admin/home.php"; }
public function action_product() { $sushi = new Model_Admin(); $result = $sushi->read_product(); $category = $sushi->get_category(); $category = $category->as_array(); $result = $result->as_array(); $content = View::factory('/admin/product'); $content->product = $result; $content->category = $category; $this->template->scripts = array('jquery-1.11.3.min', 'bootstrap.min', 'admin4'); $this->template->content = $content; }
/** * 增加城市 */ public function addAction() { if ($this->_request->isPost()) { //修改密码验证 $aCookie = Util_Cookie::get(Yaf_G::getConf('authkey', 'cookie')); $iAdminID = $aCookie['iAdminID']; $aUser = Model_Admin::getDetail($iAdminID); $pwd = $this->getParam('pwd'); if (!isset($pwd) || $pwd == '') { return $this->showMsg('修改密码不可以为空', false); } if ($aUser['sEditPassword'] != md5($pwd)) { return $this->showMsg('修改密码不正确', false); } $aCity = $this->_checkData('add'); if (empty($aCity)) { return null; } if (Model_City::getCityByName($aCity['sCityName'])) { return $this->showMsg('城市已经存在!', false); } if (Model_City::addData($aCity) > 0) { return $this->showMsg('城市增加成功!', true); } else { return $this->showMsg('城市增加失败!', false); } } }
if ($this->bCheckLogin) { // 当前用户 $aCookie = Util_Cookie::get(Yaf_G::getConf('authkey', 'cookie')); if (empty($aCookie)) { return $this->redirect('/admin/login'); } $this->aCurrUser = $aCookie; // 当前城市 $this->iCurrCityID = Util_Cookie::get('city'); if (empty($this->iCurrCityID)) { $this->iCurrCityID = $this->aCurrUser['iCityID']; } $this->aCurrCity = Model_City::getDetail($this->iCurrCityID); } $this->assign('sStaticRoot', 'http://' . Yaf_G::getConf('static', 'domain')); } /** * 执行Action后的操作 * * @see Yaf_Controller::actionAfter() */ public function actionAfter() { if ($this->autoRender() == true) { if (!empty($this->aCurrUser)) { $this->assign('aCurrUser', $this->aCurrUser);
/** * 编辑权限点 * * @return boolean */ public function editAction() { if ($this->isPost()) { //修改密码验证 $aCookie = Util_Cookie::get(Yaf_G::getConf('authkey', 'cookie')); $iAdminID = $aCookie['iAdminID']; $aUser = Model_Admin::getDetail($iAdminID); $pwd = $this->getParam('pwd'); if (!isset($pwd) || $pwd == '') { return $this->showMsg('修改密码不可以为空', false); } if ($aUser['sEditPassword'] != md5($pwd)) { return $this->showMsg('修改密码不正确', false); } $aPermission = $this->_checkData(); if (empty($aPermission)) { return null; } $aPermission['iPermissionID'] = intval($this->getParam('iPermissionID')); if (1 == Model_Permission::updData($aPermission)) { return $this->showMsg('权限点信息更新成功!', true); } else { return $this->showMsg('权限点信息更新失败!', false); } } else { $iPermissionID = intval($this->getParam('id')); $aPermission = Model_Permission::getDetail($iPermissionID); $this->assign('aPermission', $aPermission); $this->assign('aMenuTree', Model_Menu::getMenus()); } }
/** * 代理修改 */ public function editAction() { if ($this->_request->isPost()) { //修改密码验证 $aCookie = Util_Cookie::get(Yaf_G::getConf('authkey', 'cookie')); $iAdminID = $aCookie['iAdminID']; $aUser = Model_Admin::getDetail($iAdminID); $pwd = $this->getParam('pwd'); if (!isset($pwd) || $pwd == '') { return $this->showMsg('修改密码不可以为空', false); } if ($aUser['sEditPassword'] != md5($pwd)) { return $this->showMsg('修改密码不正确', false); } $aProxy = $this->_checkData('update'); if (empty($aProxy)) { return null; } $aProxy['iProxyID'] = intval($this->getParam('iProxyID')); $aOldProxy = Model_CrawlProxy::getDetail($aProxy['iProxyID']); if (!$aOldProxy) { return $this->showMsg('代理信息更新失败!', false); } if (1 == Model_CrawlProxy::updData($aProxy)) { return $this->showMsg('代理信息更新成功!', true); } else { return $this->showMsg('代理信息更新失败!', false); } } else { $iProxyID = intval($this->getParam('id')); $aProxy = Model_CrawlProxy::getDetail($iProxyID); $this->assign('aProxy', $aProxy); } }
/** * 编辑角色 * @return NULL|boolean */ public function editAction() { if ($this->isPost()) { //修改密码验证 $aCookie = Util_Cookie::get(Yaf_G::getConf('authkey', 'cookie')); $iAdminID = $aCookie['iAdminID']; $aUser = Model_Admin::getDetail($iAdminID); $pwd = $this->getParam('pwd'); if (!isset($pwd) || $pwd == '') { return $this->showMsg('修改密码不可以为空', false); } if ($aUser['sEditPassword'] != md5($pwd)) { return $this->showMsg('修改密码不正确', false); } $aRole = $this->_checkData('update'); if (empty($aRole)) { return null; } $aRole['iRoleID'] = intval($this->getParam('iRoleID')); if (1 == Model_Role::updData($aRole)) { return $this->showMsg('角色信息更新成功!', true); } else { return $this->showMsg('角色信息更新失败!', false); } } else { $iRoleID = intval($this->getParam('id')); $aRole = Model_Role::getDetail($iRoleID); $aRole['aPermission'] = explode(',', $aRole['sPermission']); $aRole['aModule'] = explode(',', $aRole['sModule']); $this->assign('aRole', $aRole); $this->assign('aPermissionList', Model_Permission::getAllPermissions()); $this->assign('aMenuList', Model_Menu::getMenus()); } }
public function deleteData($id = null) { parent::deleteUploads($this, $id); DB::delete('articles')->where('id', '=', $id)->execute(); DB::delete('articles_bags')->where('id_article', '=', $id)->execute(); DB::delete('articles_categories')->where('id_article', '=', $id)->execute(); DB::delete('articles_types')->where('id_article', '=', $id)->execute(); }
public function getActionButtons() { $buttons = parent::getActionButtons(); if (isset($buttons['Удалить'])) { unset($buttons['Удалить']); } return $buttons; }
public function getGalleryImages() { try { $model = new Model_Admin_SecondaryItems(); return Model_Admin::getSharedModelUploads($model, $this->id, 'Галерея'); } catch (Exception $e) { return []; } }
public function action_edit() { $request = $this->request->current(); $id = (int) Request::current()->param('id'); $helper_orm = ORM_Helper::factory('admin'); $orm = $helper_orm->orm(); if (!$this->acl->is_allowed($this->user, $orm, 'edit')) { throw new HTTP_Exception_404(); } else { $this->left_menu_user_add(); } if ((bool) $id) { $orm->and_where('id', '=', $id)->find(); if (!$orm->loaded() or in_array($orm->username, $this->_exclude_admins)) { throw new HTTP_Exception_404(); } $this->title = __('Edit admin'); } else { $this->title = __('Add admin'); } if (empty($this->back_url)) { $this->back_url = Route::url('admin', array('controller' => 'admins')); } if ($this->is_cancel) { $request->redirect($this->back_url); } $errors = array(); $submit = Request::$current->post('submit'); if ($submit) { try { if ((bool) $id) { $orm->updater_id = $this->user->id; $orm->updated = date('Y-m-d H:i:s'); } else { $orm->creator_id = $this->user->id; } $values = $request->post(); if (!empty($values['password'])) { $ex_validation = Model_Admin::get_password_validation($values); } else { $ex_validation = NULL; unset($values['password']); } $helper_orm->save($values, $ex_validation); } catch (ORM_Validation_Exception $e) { $errors = $this->errors_extract($e); } } // If add action then $submit = NULL if (!empty($errors) or $submit != 'save_and_exit') { $sites = ORM::factory('site')->find_all()->as_array('id', 'name'); $this->template->set_filename('admins/edit')->set('errors', $errors)->set('helper_orm', $helper_orm)->set('roles', $this->acl_roles())->set('sites', $sites); } else { $request->redirect($this->back_url); } }
public function action_create() { //POST送信なら if (Input::method() == 'POST') { //バリデーションの初期化 $val = Model_Admin::validate('create'); $val->add_field('password', 'パスワード', 'required|max_length[100]'); //バリデーションOKなら if ($val->run()) { //POSTデータを受け取る $username = Input::post('username'); $email = Input::post('email'); $password = Input::post('password'); $group = Input::post('group'); //重複確認 $username_count = Model_Admin::count(array('where' => array(array('username' => $username)))); $email_count = Model_Admin::count(array('where' => array(array('email' => $email)))); //ユーザー名が重複していたら if ($username_count > 0) { Session::set_flash('error', 'ユーザー名が重複しています'); Response::redirect('admin/create'); } else { //Eメールアドレスが重複していたら if ($email_count > 0) { Session::set_flash('error', 'Eメールアドレスが重複しています'); Response::redirect('admin/create'); } //Authのインスタンス化 $auth = Auth::instance(); //もしユーザー登録されたら if ($auth->create_user($username, $password, $email, $group)) { //登録成功のメッセージ Session::set_flash('success', '<span class="btn btn-primary span8">新規ユーザーの『' . $username . '』を追加しました</span><br>'); //indexページへ移動 Response::redirect('admin/index'); } else { //データが保存されなかったら Session::set_flash('error', '登録されませんでした'); } } } //バリデーションNGなら Session::set_flash('error', $val->show_errors()); } //POST送信でなければ //テーマのインスタンス化 $this->theme = \Theme::forge(); //テーマにテンプレートのセット $this->theme->set_template('admin/template'); //テーマのテンプレートにタイトルをセット $this->theme->get_template()->set('title', 'ameken.com'); //テーマのテンプレートにビューとページデータをセット $this->theme->get_template()->set('content', $this->theme->view('admin/create')); return $this->theme; }
public function testChangeAdminPassword() { $password = '******'; $emMock = $this->getMockBuilder('\\Box_EventManager')->getMock(); $emMock->expects($this->atLeastOnce())->method('fire')->will($this->returnValue(true)); $dbMock = $this->getMockBuilder('\\Box_Database')->getMock(); $dbMock->expects($this->atLeastOnce())->method('store')->will($this->returnValue(true)); $passwordMock = $this->getMockBuilder('\\Box_Password')->getMock(); $passwordMock->expects($this->atLeastOnce())->method('hashIt')->with($password); $di = new \Box_Di(); $di['logger'] = new \Box_Log(); $di['events_manager'] = $emMock; $di['db'] = $dbMock; $di['password'] = $passwordMock; $model = new \Model_Admin(); $model->loadBean(new \RedBeanPHP\OODBBean()); $service = new Service(); $service->setDi($di); $result = $service->changeAdminPassword($model, $password); $this->assertTrue($result); }
public function testGet() { $service = new \Box\Mod\Profile\Service(); $model = new \Model_Admin(); $model->loadBean(new \RedBeanPHP\OODBBean()); $model->id = 1; $model->role = 'admin'; $model->admin_group_id = 1; $model->email = '*****@*****.**'; $model->name = 'Admin'; $model->signature = 'Sincerely'; $model->status = 'active'; $model->created_at = '2014-01-01'; $model->updated_at = '2014-01-01'; $adminApi = new \Box\Mod\Profile\Api\Admin(); $adminApi->setIdentity($model); $adminApi->setService($service); $result = $adminApi->get(); $expected = array('id' => $model->id, 'role' => $model->role, 'admin_group_id' => $model->admin_group_id, 'email' => $model->email, 'name' => $model->name, 'signature' => $model->signature, 'status' => $model->status, 'api_token' => null, 'created_at' => $model->created_at, 'updated_at' => $model->updated_at); $this->assertEquals($expected, $result); }
public function testArticle_get() { $adminApi = new \Box\Mod\Kb\Api\Admin(); $data = array('id' => rand(1, 100)); $db = $this->getMockBuilder('Box_Database')->getMock(); $db->expects($this->atLeastOnce())->method('findOne')->will($this->returnValue(new \Model_KbArticle())); $admin = new \Model_Admin(); $admin->loadBean(new \RedBeanPHP\OODBBean()); $admin->id = 5; $di = new \Box_Di(); $di['loggedin_admin'] = $admin; $di['db'] = $db; $validatorMock = $this->getMockBuilder('\\Box_Validate')->disableOriginalConstructor()->getMock(); $validatorMock->expects($this->atLeastOnce())->method('checkRequiredParamsForArray')->will($this->returnValue(null)); $di['validator'] = $validatorMock; $adminApi->setDi($di); $kbService = $this->getMockBuilder('Box\\Mod\\Kb\\Service')->setMethods(array('toApiArray'))->getMock(); $kbService->expects($this->atLeastOnce())->method('toApiArray')->will($this->returnValue(array())); $adminApi->setService($kbService); $result = $adminApi->article_get($data); $this->assertInternalType('array', $result); }
public function editAction() { $this->view->title = "Редактирование страницы"; $this->view->headTitle($this->view->title, 'PREPEND'); $id = $this->getRequest()->getParam('id'); $mdlPages = new Model_Admin($id); $parametr = $mdlPages->getPageItem($id); $formEdit = new Form_PageEdit(); $formEdit->addDecorator('HtmlTag', array('tag' => 'img', 'class' => 'myElement', 'id' => $parametr['image'], 'alt' => 'no-image', 'src' => DS . 'img' . DS . 'upload' . DS . $parametr['image'])); if ($this->_request->isPost()) { if ($formEdit->isValid($this->_request->getParams())) { $params = $formEdit->getValues(); $flag = $params['delete']; if ($flag) { $params['image'] = ''; } $mdlPages->fill($params); $mdlPages->save(); $this->_helper->redirector('index'); } } $formEdit->populate($mdlPages->populateForm()); $this->view->form = $formEdit; }
public function authAdmin() { if (isset($_SESSION['admlog']) && isset($_SESSION['admpass'])) { $email = $_SESSION['admlog']; $pass = $_SESSION['admpass']; $chek_admin = Model_Admin::getByField(__CLASS__, $this->table, "email", $email); if (!password_verify($pass, $chek_admin->password)) { app::redirect("/admin/auth"); exit; } return true; } else { app::redirect('/admin/auth'); exit; } }
{ $aUser = Model_Admin::getDetail($iAdminID); if ($aUser['sRoleID'] === '-1') { return -1; } $aRoleList = Model_Role::getPKIDList($aUser['sRoleID']); $aModuleID = array(); foreach ($aRoleList as $aRole) { if (!empty($aRole['sModule'])) { $aModuleID = array_merge($aModuleID, explode(',', $aRole['sModule'])); } } return array_flip($aModuleID); } /** * 取得用户所有访问权限 * * @param array $aUser * @return array */ public static function getUserPermissions($iAdminID)
/** * 更换城市 */ public function changeAction() { // 当前用户 $aCookie = Util_Cookie::get(Yaf_G::getConf('authkey', 'cookie')); if (empty($aCookie)) { return $this->redirect('/admin/login'); } $this->aCurrUser = $aCookie; $iCityID = $this->getParam('id'); $aCity = Model_City::getDetail($iCityID); if (empty($aCity) || $aCity['iBackendShow'] == 0 || $aCity['iStatus'] == 0) { return $this->showMsg('城市不存在或未开放!', false); } $aUser = Model_Admin::getDetail($this->aCurrUser['iAdminID']); $aCityID = explode(',', $aUser['sCityID']); if ($aUser['sCityID'] != '-1' && !in_array($iCityID, $aCityID)) { return $this->showMsg('您没有访问该城市的权限,请联系管理员!', false); } Util_Cookie::set('city', $iCityID); return $this->showMsg('城市切换成功!', true); }
/** * 编辑菜单 */ public function editAction() { if ($this->isPost()) { //修改密码验证 $aCookie = Util_Cookie::get(Yaf_G::getConf('authkey', 'cookie')); $iAdminID = $aCookie['iAdminID']; $aUser = Model_Admin::getDetail($iAdminID); $pwd = $this->getParam('pwd'); if (!isset($pwd) || $pwd == '') { return $this->showMsg('修改密码不可以为空', false); } if ($aUser['sEditPassword'] != md5($pwd)) { return $this->showMsg('修改密码不正确', false); } $aMenu = $this->_checkData('update'); if (empty($aMenu)) { return null; } $aMenu['iMenuID'] = intval($this->getParam('iMenuID')); $aOldMenu = Model_Menu::getDetail($aMenu['iMenuID']); if (empty($aOldMenu)) { return $this->showMsg('菜单不存在!', false); } //更新排序,加在最后面 if ($aOldMenu['iParentID'] != $aMenu['iParentID']) { $aMenu['iOrder'] = Model_Menu::getNextOrder($aMenu['iParentID']); } if (1 == Model_Menu::updData($aMenu)) { return $this->showMsg('菜单信息更新成功!', true); } else { return $this->showMsg('菜单信息更新失败!', false); } } else { $iMenuID = intval($this->getParam('id')); $aMenu = Model_Menu::getDetail($iMenuID); $aTree = Model_Menu::getMenus(); $this->assign('aTree', $aTree); $this->assign('aMenu', $aMenu); } }
/** * 基础配置修改 */ public function editAction() { if ($this->_request->isPost()) { //修改密码验证 $aCookie = Util_Cookie::get(Yaf_G::getConf('authkey', 'cookie')); $iAdminID = $aCookie['iAdminID']; $aUser = Model_Admin::getDetail($iAdminID); $pwd = $this->getParam('pwd'); if (!isset($pwd) || $pwd == '') { return $this->showMsg('修改密码不可以为空', false); } if ($aUser['sEditPassword'] != md5($pwd)) { return $this->showMsg('修改密码不正确', false); } $aDomain = $this->_checkData('update'); if (empty($aDomain)) { return null; } $aDomain['iAutoID'] = intval($this->getParam('iAutoID')); $aOldDomain = Model_Domain::getDetail($aDomain['iAutoID']); if (empty($aOldDomain)) { return $this->showMsg('基础配置不存在!', false); } if ($aOldDomain['sName'] != $aDomain['sName']) { if (Model_Domain::getRow(array('where' => array('sName' => $aDomain['sName'], 'iType' => $aDomain['iType'], 'iStatus' => 1)))) { return $this->showMsg('基础配置已经存在!', false); } } if (1 == Model_Domain::updData($aDomain)) { return $this->showMsg('基础配置信息更新成功!', true); } else { return $this->showMsg('基础配置信息更新失败!', false); } } else { $iAutoID = intval($this->getParam('id')); $aDomain = Model_Domain::getDetail($iAutoID); $this->assign('aDomain', $aDomain); } $this->assign('iType', Model_Domain::$iType); }
/** * 敏感词修改 */ public function editAction() { if ($this->_request->isPost()) { //修改密码验证 $aCookie = Util_Cookie::get(Yaf_G::getConf('authkey', 'cookie')); $iAdminID = $aCookie['iAdminID']; $aUser = Model_Admin::getDetail($iAdminID); $pwd = $this->getParam('pwd'); if (!isset($pwd) || $pwd == '') { return $this->showMsg('修改密码不可以为空', false); } if ($aUser['sEditPassword'] != md5($pwd)) { return $this->showMsg('修改密码不正确', false); } $aBadword = $this->_checkData('update'); if (empty($aBadword)) { return null; } $aBadword['iAutoID'] = intval($this->getParam('iAutoID')); $aOldBadword = Model_Badword::getDetail($aBadword['iAutoID']); if (empty($aOldBadword)) { return $this->showMsg('敏感词不存在!', false); } if ($aOldBadword['sWord'] != $aBadword['sWord']) { if (Model_Badword::getBadwordByWord($aBadword['sWord'])) { return $this->showMsg('敏感词已经存在!', false); } } if (1 == Model_Badword::updData($aBadword)) { return $this->showMsg('敏感词信息更新成功!', true); } else { return $this->showMsg('敏感词信息更新失败!', false); } } else { $iBadwordID = intval($this->getParam('id')); $aBadword = Model_Badword::getDetail($iBadwordID); $this->assign('aBadword', $aBadword); } }
public function getActionButtons() { $buttons = parent::getActionButtons(); $ref = urlencode(AdminHREF::getFullCurrentHREF()); $changePass = function ($row) use($ref) { $href = AdminHREF::getDefaultAdminRouteUri('dataEdit', 'UsersPasswords', $row['id']) . '/?ref=' . $ref; $text = '<i class="fa fa-lock gc"></i>'; return '<a title="Сменить пароль" href="' . $href . '">' . $text . '</a>'; }; $changeRoles = function ($row) use($ref) { $href = AdminHREF::getDefaultAdminRouteUri('dataEdit', 'UsersRoles', $row['id']) . '/?ref=' . $ref; $text = '<i class="fa fa-user-secret gc"></i>'; return '<a title="Роли пользователя" href="' . $href . '">' . $text . '</a>'; }; $loginUser = function ($row) use($ref) { $href = AdminHREF::getDefaultAdminRouteUri('loginuser', 'users', $row['id']); $text = '<i class="fa fa-sign-in gc"></i>'; return '<a title="Войти от имени пользователя" href="' . $href . '">' . $text . '</a>'; }; $buttons['Роли пользователя'] = $changeRoles; $buttons['Сменить пароль'] = $changePass; $buttons['Войти'] = $loginUser; return $buttons; }
public function getheader() { return parent::getheader(); }
/** * 财务修改 */ public function editAction() { if ($this->_request->isPost()) { //修改密码验证 $aCookie = Util_Cookie::get(Yaf_G::getConf('authkey', 'cookie')); $iAdminID = $aCookie['iAdminID']; $aUser = Model_Admin::getDetail($iAdminID); $pwd = $this->getParam('pwd'); if (!isset($pwd) || $pwd == '') { return $this->showMsg('修改密码不可以为空', false); } if ($aUser['sEditPassword'] != md5($pwd)) { return $this->showMsg('修改密码不正确', false); } $aFinance = $this->_checkData('update'); if (empty($aFinance)) { return null; } $aFinance['iAutoID'] = intval($this->getParam('iAutoID')); $aOldFinance = Model_Finance::getDetail($aFinance['iAutoID']); if (empty($aOldFinance)) { return $this->showMsg('财务不存在!', false); } if (1 == Model_Finance::updData($aFinance)) { if ($aOldFinance['iPayStatus'] == 0 && $aFinance['iPayStatus'] == 1) { // 邮件通知 $sTitle = Model_Kv::getValue('finance_forget_email_title'); $sContent = Model_Kv::getValue('finance_forget_email_content'); $aUser = Model_Finance::getDetail($aFinance['iAutoID']); $time = date('Y-m-d H:i:s', $aUser['iUpdateTime']); $email = Model_User::getDetail($aUser['iUserID']); // 短信通知 // $iTempID = Util_Common::getConf(1, 'aSmsTempID'); Util_Mail::send($email['sEmail'], $sTitle, $sContent, array($email['sEmail'], $time, $aUser['iPayMoney'])); // Util_Sms::sendTemplateSms($email['sMobile'], array( // $aUser['sMediaName'] // ), $iTempID); } return $this->showMsg('财务更新成功!', true); } else { return $this->showMsg('财务更新失败!', false); } } else { $iFinanceID = intval($this->getParam('id')); $aFinance = Model_Finance::getDetail($iFinanceID); $aUser = Model_User::getDetail($aFinance['iUserID']); $this->assign('aUser', $aUser); $this->assign('aFinance', $aFinance); } }
public function testrenewal_invoiceOrderNotFound() { $validatorMock = $this->getMockBuilder('\\Box_Validate')->getMock(); $validatorMock->expects($this->atLeastOnce())->method('checkRequiredParamsForArray'); $dbMock = $this->getMockBuilder('\\Box_Database')->getMock(); $clientOrder = new \Model_ClientOrder(); $clientOrder->loadBean(new \RedBeanPHP\OODBBean()); $clientOrder->price = 10; $dbMock->expects($this->atLeastOnce())->method('findOne')->will($this->returnValue(null)); $di = new \Box_Di(); $di['validator'] = $validatorMock; $di['db'] = $dbMock; $this->api->setDi($di); $identity = new \Model_Admin(); $identity->loadBean(new \RedBeanPHP\OODBBean()); $this->api->setIdentity($identity); $data['order_id'] = 1; $this->setExpectedException('\\Box_Exception', 'Order not found'); $this->api->renewal_invoice($data); }
<form action='<?php echo AdminHREF::getFullHost() . AdminHREF::getPath(); ?> '> <?php $pagination = ''; $content = AdminHTML::renderNoneFound(); $data = $model->getData(); $uniqueValues = []; if (!empty($data)) { $dataFirstKey = array_keys($data)[0]; $dataKeys = array_keys($data[$dataFirstKey]); foreach ($dataKeys as $dataKey) { $uniqueValues[$dataKey] = Model_Admin::getDistinctSubArrayKeyValues($data, $dataKey); } Model_Admin::filterData($data, $model); $countData = count($data); $perPage = intval(Admin::getConfig('itemsPerPage')); $pages = ceil($countData / $perPage); $page = AdminHREF::getPage(); if ($page > $pages) { $page = $pages; } $content = View::factory('Admin/Data/List', ['data' => array_slice($data, ($page - 1) * $perPage, $perPage), 'uniqueValues' => $uniqueValues, 'model' => $model]); $pagination = View::factory('Admin/Data/Pagination', ['pages' => $pages, 'page' => $page, 'countData' => $countData, 'perPage' => $perPage]); } ?> <?php echo $pagination, $content, $pagination; ?>
public function deleteData($id = null) { parent::deleteUploads($this, $id); DB::delete('news')->where('id', '=', $id)->execute(); }
public function testOnAfterAdminOrderUncancel_LogException() { $params = array('id' => rand(1, 100)); $eventMock = $this->getMockBuilder('\\Box_Event')->disableOriginalConstructor()->getMock(); $eventMock->expects($this->atLeastOnce())->method('getParameters')->will($this->returnValue($params)); $order = new \Model_ClientOrder(); $order->loadBean(new \RedBeanPHP\OODBBean()); $dbMock = $this->getMockBuilder('\\Box_Database')->disableOriginalConstructor()->getMock(); $dbMock->expects($this->atLeastOnce())->method('getExistingModelById')->will($this->returnValue($order)); $emailServiceMock = $this->getMockBuilder('\\Box\\Mod\\Email\\Service')->setMethods(array('sendTemplate'))->getMock(); $emailServiceMock->expects($this->atLeastOnce())->method('sendTemplate')->willThrowException(new \Exception('PHPUnit controlled exception')); $orderArr = array('id' => rand(1, 100), 'client' => array('id' => rand(1, 100)), 'service_type' => 'domain'); $serviceMock = $this->getMockBuilder('\\Box\\Mod\\Order\\Service')->setMethods(array('getOrderServiceData', 'toApiArray'))->disableOriginalConstructor()->getMock(); $serviceMock->expects($this->atLeastOnce())->method('getOrderServiceData')->will($this->returnValue(array())); $serviceMock->expects($this->atLeastOnce())->method('toApiArray')->will($this->returnValue($orderArr)); $admin = new \Model_Admin(); $admin->loadBean(new \RedbeanPHP\OODBBean()); $di = new \Box_Di(); $di['db'] = $dbMock; $di['loggedin_admin'] = $admin; $di['mod_service'] = $di->protect(function ($serviceName) use($emailServiceMock, $serviceMock) { if ($serviceName == 'email') { return $emailServiceMock; } if ($serviceName == 'order') { return $serviceMock; } }); $serviceMock->setDi($di); $eventMock->expects($this->atLeastOnce())->method('getDi')->will($this->returnValue($di)); $serviceMock->onAfterAdminOrderUncancel($eventMock); }
public function testNoteCreate() { $randId = rand(1, 100); $supportPrCategoryModel = new \Model_SupportPrCategory(); $supportPrCategoryModel->loadBean(new \RedBeanPHP\OODBBean()); $dbMock = $this->getMockBuilder('\\Box_Database')->disableOriginalConstructor()->getMock(); $dbMock->expects($this->atLeastOnce())->method('dispense')->will($this->returnValue($supportPrCategoryModel)); $dbMock->expects($this->atLeastOnce())->method('store')->will($this->returnValue($randId)); $di = new \Box_Di(); $di['db'] = $dbMock; $di['logger'] = $this->getMockBuilder('Box_Log')->getMock(); $this->service->setDi($di); $data = array('name' => 'Name', 'email' => '*****@*****.**', 'can_reopen' => 1, 'close_after' => rand(1, 100), 'signature' => 'Signature'); $admin = new \Model_Admin(); $admin->loadBean(new \RedBeanPHP\OODBBean()); $ticket = new \Model_SupportTicket(); $ticket->loadBean(new \RedBeanPHP\OODBBean()); $result = $this->service->noteCreate($ticket, $admin, 'Note'); $this->assertInternalType('integer', $result); $this->assertEquals($result, $randId); }