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


PHP UserGroup::save方法代码示例

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


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

示例1: 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

示例2: addAction

 public function addAction()
 {
     $ans = [];
     try {
         if (!$this->request->isPost()) {
             throw new Exception('请用正确的方式访问我们的API', 99);
         }
         $validation = new Phalcon\Validation();
         $validation->add('name', new PresenceOf(['message' => 'name is needed']));
         $validation->add('name', new StringLength(['max' => 30, 'messageMaximum' => 'The name is too long.']));
         $messages = $validation->validate($_POST);
         foreach ($messages as $message) {
             throw new Exception($message, 102);
         }
         //获取Post中的内容,然后将name存入到数据库中
         $name = $this->request->getPost('name');
         $userGroup = new UserGroup();
         $userGroup->name = $name;
         $success = $userGroup->save();
         if ($success) {
             $ans['id'] = $userGroup->id;
         } else {
             foreach ($userGroup->getMessages() as $message) {
                 throw new Exception($message, 100);
             }
         }
     } catch (Exception $e) {
         $ans['id'] = -1;
         Utils::makeError($e, $ans);
     } finally {
         echo json_encode($ans);
     }
 }
开发者ID:hyfjjjj,项目名称:HHA-Web,代码行数:33,代码来源:UserGroupController.php

示例3: save_data

/**
 * Save imported class data to database
 *
 * @param $classes
 *
 * @return int
 */
function save_data($classes)
{
    $count = 0;
    $usergroup = new UserGroup();
    foreach ($classes as $index => $class) {
        $usersToAdd = isset($class['users']) ? $class['users'] : null;
        unset($class['users']);
        $id = $usergroup->save($class);
        if ($id) {
            if (!empty($usersToAdd)) {
                $usersToAddList = explode(',', $usersToAdd);
                $userIdList = array();
                foreach ($usersToAddList as $username) {
                    $userInfo = api_get_user_info_from_username($username);
                    $userIdList[] = $userInfo['user_id'];
                }
                if (!empty($userIdList)) {
                    $usergroup->subscribe_users_to_usergroup($id, $userIdList, false);
                }
            }
            $count++;
        }
    }
    return $count;
}
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:32,代码来源:usergroup_import.php

示例4: testCreateNewGroup

 public function testCreateNewGroup()
 {
     // Create new UserGroup model
     $model = new UserGroup();
     $model->name = 'Admin';
     $model->description = 'Test Group';
     $model->gperm_access_admin_panel = 1;
     $model->pperm_browse_crash_reports = 1;
     $model->pperm_browse_bugs = 1;
     $model->pperm_browse_debug_info = 1;
     $model->pperm_manage_crash_reports = 1;
     $model->pperm_manage_bugs = 1;
     $model->pperm_manage_debug_info = 1;
     $model->default_sidebar_tab = 'Digest';
     $model->default_bug_status_filter = 'open';
     // Validate model - assume failure (group name already exist)
     $this->assertFalse($model->validate());
     // Correct name
     $model->name = 'NewGroup';
     // Validate model - assume success
     $this->assertTrue($model->validate());
     // Apply changes to database - assume success
     $this->assertTrue($model->save());
     // Ensure group's status is Active
     $this->assertTrue($model->status == UserGroup::STATUS_ACTIVE);
     // Check the new group is not standard
     $this->assertFalse($model->isStandard());
     // Check the new group can be updated
     $this->assertTrue($model->canUpdate());
     // Delete new group - should succeed
     $this->assertTrue($model->delete());
 }
开发者ID:xyzz,项目名称:CrashFix,代码行数:32,代码来源:UserGroupTest.php

示例5: groups

 public function groups($nickname = null)
 {
     $user = $this->load_user($nickname);
     $this->assign("user", $user);
     if ($this->post && isset($_POST['group_id'])) {
         $group = Group::find_by_iD($_POST['group_id']);
         if ($group) {
             $userGroup = new UserGroup();
             $userGroup->group_id = $group->id;
             $userGroup->user_id = $user->id;
             if ($userGroup->save()) {
                 Site::Flash('notice', 'The user has been added to the group');
                 Redirect("admin/users/" . $user->permalink() . '/groups');
             }
         }
     }
     $userGroups = array();
     foreach ($user->groups() as $ug) {
         $userGroups[] = $ug->id;
     }
     $allGroups = Group::find_all();
     $groups = array();
     foreach ($allGroups as $group) {
         if (in_array($group->id, $userGroups)) {
             continue;
         }
         $groups[$group->id] = $group->name;
     }
     $this->assign('groups', $groups);
     $this->title = "{$user->nickname} :: Groups";
     $this->render("user/groups.tpl");
 }
开发者ID:ItsHaden,项目名称:epicLanBootstrap,代码行数:32,代码来源:user.controller.php

示例6: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     if ($this->user_role == 'top_admin') {
         $model = new UserGroup();
         // Uncomment the following line if AJAX validation is needed
         // $this->performAjaxValidation($model);
         $criteria = new CDbCriteria();
         $criteria->condition = 'status=:status';
         $criteria->params = array(':status' => 1);
         $criteria->order = 'sort_order';
         $menu_list = UserMenu::model()->findAll($criteria);
         if (isset($_POST['UserGroup'])) {
             $sep = "";
             $user_menu = "";
             if (isset($_POST['user_menu'])) {
                 // echo "<pre>".print_r($_POST['user_menu'])."</pre>";
                 $count_menu = count($_POST['user_menu']);
                 $menu_list = array();
                 $menu_list = $_POST['user_menu'];
                 foreach ($menu_list as $key => $value) {
                     $user_menu .= $sep . $value;
                     $sep = ",";
                 }
             }
             $_POST['UserGroup']['user_menu'] = $user_menu;
             $model->attributes = $_POST['UserGroup'];
             if ($model->save()) {
                 $this->redirect(array('index'));
             }
         }
         $this->render('create', array('model' => $model, 'menu_list' => $menu_list));
     } else {
         $this->redirect(array('site/index'));
     }
 }
开发者ID:ultr4h4ck,项目名称:project_gspa,代码行数:39,代码来源:UserGroupController.php

示例7: group_store

 public function group_store()
 {
     $data = Input::all();
     $group = new UserGroup();
     $group->fill($data);
     $group->save();
     return Redirect::route('perm.group.list');
 }
开发者ID:sammy8806,项目名称:gsi_laravel,代码行数:8,代码来源:PermissionAdminController.php

示例8: addUserGroupSubmit

function addUserGroupSubmit($p)
{
    $grp = new UserGroup();
    $grp->setName($p['name']);
    $grp->setInfo($p['info']);
    $grp->setLevel($p['level']);
    $grp->save();
    redir('a/usergroups');
}
开发者ID:martinlindhe,项目名称:core_dev,代码行数:9,代码来源:usergroups.php

示例9: saveUserGroupSubmit

function saveUserGroupSubmit($p)
{
    $grp = new UserGroup($p['g_id']);
    $grp->setName($p['name']);
    $grp->setInfo($p['info']);
    $grp->setLevel($p['level']);
    $grp->save();
    return true;
}
开发者ID:martinlindhe,项目名称:core_dev,代码行数:9,代码来源:usergroup.php

示例10: addToGroups

 /**
  * add user to groups
  *
  * @param array $group_name
  */
 public function addToGroups($group_name)
 {
     $group_ids = Group::findGroupIdByNames($group_name);
     foreach ($group_ids as $group_id) {
         $user_group = new UserGroup();
         $user_group->user_id = $this->getId();
         $user_group->group_id = $group_id;
         $user_group->save();
     }
 }
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:15,代码来源:User.class.php

示例11: _mainModelAfterSave

 /**
  * We're going to create a UserGroup when a new Model record is created
  *
  * @param Model $Model
  * @param boolean $created
  */
 private function _mainModelAfterSave(Model $Model, $created)
 {
     if ($created) {
         $UserGroup = new UserGroup();
         // create a UserGroup for this Course
         $data = $UserGroup->create(array('title' => $Model->data[$Model->alias][$Model->displayField], 'model' => $Model->alias, 'foreign_key' => $Model->id, 'owner_id' => $Model->userId));
         $UserGroup->save($data);
         // make the current Auth.User a member, and the moderator, for this group
         $UserGroup->UsersUserGroup->add(array('UsersUserGroup' => array('user_id' => $Model->userId, 'user_group_id' => $UserGroup->id, 'is_moderator' => 1, 'is_approved' => 1)));
     }
 }
开发者ID:ayaou,项目名称:Zuha,代码行数:17,代码来源:UserGroupableBehavior.php

示例12: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new UserGroup();
     if (isset($_POST['UserGroup'])) {
         $model->attributes = $_POST['UserGroup'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:xyzz,项目名称:CrashFix,代码行数:15,代码来源:UserGroupController.php

示例13: save_data

/**
 * Save imported class data to database
 */
function save_data($classes)
{
    $number_of_added_classes = 0;
    $usergroup = new UserGroup();
    foreach ($classes as $index => $class) {
        $id = $usergroup->save($class);
        if ($id) {
            $number_of_added_classes++;
        }
    }
    return $number_of_added_classes;
}
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:15,代码来源:usergroup_import.php

示例14: run

 public function run()
 {
     $model = new UserGroup();
     if (isset($_POST['UserGroup'])) {
         $model->attributes = $_POST['UserGroup'];
         $model->acl = isset($_POST['acls']) ? $_POST['acls'] : array();
         if ($model->save()) {
             $this->controller->message('success', Yii::t('admin', 'Add Success'), $this->controller->createUrl('index'));
         }
     }
     $this->controller->render('create', array('model' => $model, 'acls' => $this->controller->acl()));
 }
开发者ID:jerrylsxu,项目名称:yiifcms,代码行数:12,代码来源:CreateAction.php

示例15: UserGroupSave

 /**
  * 保存用户到用户组
  */
 static function UserGroupSave($user_id, $group)
 {
     \Yii::app()->db->createCommand()->update('users', array('yourself' => $_POST['self'] ? 1 : 0), 'id=:id', array('id' => $user_id));
     if ($group) {
         UserGroup::model()->deleteAllByAttributes(array('user_id' => $user_id));
         foreach ($group as $group_id) {
             $model = new UserGroup();
             $model->group_id = $group_id;
             $model->user_id = $user_id;
             $model->save();
         }
     }
 }
开发者ID:hiproz,项目名称:mincms,代码行数:16,代码来源:UserGroup.php


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