当前位置: 首页>>代码示例>>PHP>>正文


PHP UserGroup::getNewInstance方法代码示例

本文整理汇总了PHP中UserGroup::getNewInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP UserGroup::getNewInstance方法的具体用法?PHP UserGroup::getNewInstance怎么用?PHP UserGroup::getNewInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UserGroup的用法示例。


在下文中一共展示了UserGroup::getNewInstance方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setUp

 public function setUp()
 {
     ActiveRecordModel::getApplication()->clearCachedVars();
     ActiveRecordModel::beginTransaction();
     if (empty($this->autoincrements)) {
         foreach ($this->getUsedSchemas() as $table) {
             $res = $this->db->executeQuery("SHOW TABLE STATUS LIKE '{$table}'");
             $res->next();
             $this->autoincrements[$table] = (int) $res->getInt("Auto_increment");
         }
     }
     if ($this instanceof BackendControllerTestCase) {
         ClassLoader::import('application.model.user.SessionUser');
         ClassLoader::import('application.model.user.UserGroup');
         // set up user
         $group = UserGroup::getNewInstance('Unit tester');
         $group->save();
         $group->setAllRoles();
         $group->save();
         $user = User::getNewInstance('unittest@test.com', null, $group);
         $user->save();
         SessionUser::setUser($user);
     }
     if ($this instanceof ControllerTestCase) {
         $this->request = self::getApplication()->getRequest();
     }
 }
开发者ID:saiber,项目名称:livecart,代码行数:27,代码来源:UnitTest.php

示例2: setUp

 public function setUp()
 {
     parent::setUp();
     $this->role = Role::getNewInstance('__testrole__');
     $this->role->save();
     $this->userGroup = UserGroup::getNewInstance('Any random group name');
     $this->userGroup->save();
 }
开发者ID:saiber,项目名称:livecart,代码行数:8,代码来源:AccessControlAssociationTest.php

示例3: create

 /**
  * @role create
  */
 public function create()
 {
     $userGroup = UserGroup::getNewInstance($this->translate('_new_user_group'));
     $userGroup->save();
     return new JSONResponse($userGroup->toArray(), 'success', $this->translate('_new_user_group_successfully_created'));
 }
开发者ID:saiber,项目名称:livecart,代码行数:9,代码来源:UserGroupController.php

示例4: setAdmin

 public function setAdmin()
 {
     if (!$this->buildAdminValidator()->isValid()) {
         return new ActionRedirectResponse('install', 'admin');
     }
     ClassLoader::import('application.model.user.UserGroup');
     ClassLoader::import('application.model.user.User');
     ClassLoader::import('application.model.user.SessionUser');
     ActiveRecordModel::beginTransaction();
     // create user group for administrators
     $group = UserGroup::getNewInstance('Administrators');
     $group->setAllRoles();
     $group->save();
     // create administrator account
     $user = User::getNewInstance($this->request->get('email'), null, $group);
     $user->loadRequestData($this->request);
     $user->setPassword($this->request->get('password'));
     $user->isEnabled->set(true);
     $user->save();
     ActiveRecordModel::commit();
     // log in
     SessionUser::setUser($user);
     // set store email
     $this->config->set('MAIN_EMAIL', $this->request->get('email'));
     $this->config->set('NOTIFICATION_EMAIL', $this->request->get('email'));
     $this->config->set('NEWSLETTER_EMAIL', $this->request->get('email'));
     $this->config->save();
     return new ActionRedirectResponse('install', 'config');
 }
开发者ID:GregerA,项目名称:livecart,代码行数:29,代码来源:InstallController.php

示例5: getNextUserGroup

 public function getNextUserGroup()
 {
     try {
         if (!($data = $this->loadRecord('SELECT * FROM ' . $this->getTablePrefix() . 'customers_groups'))) {
             return null;
         }
     } catch (Exception $e) {
         return null;
     }
     $name = null;
     foreach (array('customers_group_name', 'customer_group_name') as $key) {
         if (!empty($data[$key])) {
             return UserGroup::getNewInstance($data[$key]);
         }
     }
     return null;
 }
开发者ID:saiber,项目名称:livecart,代码行数:17,代码来源:OsCommerceImport.php

示例6: testHasConcreteAccess

 public function testHasConcreteAccess()
 {
     $group = UserGroup::getNewInstance('testing1337', 'testing1337');
     $group->save();
     $role = Role::getNewInstance('testing1337.update');
     $role->save();
     $group->applyRole($role);
     $group->save();
     $this->assertFalse($group->hasAccess('testing1337'));
     $this->assertTrue($group->hasAccess('testing1337.update'));
     $this->assertFalse($group->hasAccess('testing1337.create'));
 }
开发者ID:saiber,项目名称:livecart,代码行数:12,代码来源:UserGroupTest.php

示例7: setUp

 public function setUp()
 {
     parent::setUp();
     $this->group = UserGroup::getNewInstance('test', 'test');
     $this->group->save();
 }
开发者ID:saiber,项目名称:livecart,代码行数:6,代码来源:UserTest.php

示例8: testQuantityPrices

 public function testQuantityPrices()
 {
     $product = $this->products[0];
     $this->order->addProduct($product, 5);
     $price = $product->getPricingHandler()->getPriceByCurrencyCode('USD');
     $this->assertIsA($price, 'ProductPrice');
     $price->setPriceRule(5, null, 15);
     $this->assertEquals($this->order->getTotal(true), 75);
     $price->removePriceRule(5, null);
     $this->assertEquals($this->order->getTotal(true), 500);
     $price->setPriceRule(4, null, 15);
     $this->assertEquals($this->order->getTotal(true), 75);
     $price->removePriceRule(4, null);
     $price->setPriceRule(6, null, 15);
     $this->assertEquals($this->order->getTotal(true), 500);
     $price->setPriceRule(9, null, 15);
     $this->assertEquals($this->order->getTotal(true), 500);
     // user group pricing
     $group = UserGroup::getNewInstance('test');
     $group->save();
     $price->setPriceRule(4, null, 15);
     $price->setPriceRule(4, $group, 10);
     $this->assertEquals($this->order->getTotal(true), 75);
     $user = $this->order->user->get();
     $user->userGroup->set($group);
     $user->save();
     $this->assertEquals($this->order->getTotal(true), 50);
     $price->removePriceRule(4, null);
     $price->removePriceRule(4, $group);
     $price->setPriceRule(4, null, 15);
     $price->setPriceRule(6, $group, 10);
     $this->assertEquals($this->order->getTotal(true), 75);
     $price->setPriceRule(5, $group, 10);
     $this->assertEquals($this->order->getTotal(true), 50);
     $price->setPriceRule(2, $group, 7);
     $price->setPriceRule(3, $group, 8);
     $price->setPriceRule(4, $group, 9);
     $price->setPriceRule(6, $group, 11);
     $this->assertEquals($this->order->getTotal(true), 50);
 }
开发者ID:saiber,项目名称:livecart,代码行数:40,代码来源:OrderTest.php


注:本文中的UserGroup::getNewInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。