本文整理汇总了PHP中Group::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Group::save方法的具体用法?PHP Group::save怎么用?PHP Group::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Group
的用法示例。
在下文中一共展示了Group::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testPasswordExpiresPolicyRules
public function testPasswordExpiresPolicyRules()
{
$everyoneGroup = Group::getByName(Group::EVERYONE_GROUP_NAME);
$everyoneGroup->save();
$user = UserTestHelper::createBasicUser('Bobby');
$id = $user->id;
unset($user);
$user = User::getById($id);
$adapter = new UserGroupMembershipToViewAdapter($user);
$viewData = $adapter->getViewData();
$compareData = array($everyoneGroup->id => array('displayName' => 'Everyone', 'canRemoveFrom' => false));
$this->assertEquals($compareData, $viewData);
$a = new Group();
$a->name = 'AAA';
$this->assertTrue($a->save());
$a->users->add($user);
$this->assertTrue($a->save());
$user->forget();
$groupId = $a->id;
$a->forget();
unset($a);
$user = User::getById($id);
$adapter = new UserGroupMembershipToViewAdapter($user);
$viewData = $adapter->getViewData();
$compareData = array($everyoneGroup->id => array('displayName' => 'Everyone', 'canRemoveFrom' => false), $groupId => array('displayName' => 'AAA', 'canRemoveFrom' => true));
$this->assertEquals($compareData, $viewData);
$user->forget();
unset($user);
}
示例2: getIndex
public function getIndex()
{
$action = $_GET['action'];
if ($action == "update") {
$to = $_GET['to'];
$id = $_GET['id'];
$groupEntry = Group::find($id);
$groupEntry->name = $to;
$groupEntry->save();
} else {
if ($action == "delete") {
$id = $_GET['id'];
$groupEntry = Group::find($id);
$groupEntry->delete();
} else {
if ($action == "insert") {
$name = $_GET['name'];
$group = new Group();
$group->name = $name;
$group->save();
}
}
}
return View::make('admin');
}
示例3: editAction
/**
* Edits an existing user group
*
* @access public
* @return void
*/
public function editAction()
{
$this->title = 'Edit user group';
$form = new GroupForm();
$groupModel = new Group();
if ($this->getRequest()->isPost()) {
if ($form->isValid($this->getRequest()->getPost())) {
$groupModel->save($form->getValues());
$this->_helper->FlashMessenger(array('msg-success' => 'The group was successfully edited.'));
App_FlagFlippers_Manager::save();
$this->_redirect('/groups/');
}
} else {
$id = $this->_getParam('id');
if (!is_numeric($id)) {
$this->_helper->FlashMessenger(array('msg-success' => 'The provided group_id is invalid.'));
$this->_redirect('/groups/');
}
$row = $groupModel->findById($id);
if (empty($row)) {
$this->_helper->FlashMessenger(array('msg-success' => 'The requested group could not be found.'));
$this->_redirect('/groups/');
}
$form->populate($row->toArray());
$this->view->item = $row;
}
$this->view->form = $form;
}
示例4: save
public function save()
{
$Group = new Group($this->data->Group);
$Group->save();
$go = '>auth/Group/formObject/' . $Group->getId();
$this->renderPrompt('information', 'OK', $go);
}
示例5: addNew
/**
* @api {post} /companies/new Add new company
* @apiName Add a new company.
* @apiGroup Company
* @apiDescription Create new company.
* <p>After a new company is created, a company group will be auto generated.
* The first member enrolled (actived) into the company group will be the owner of the company group.</p>
* <p>If all the information(name, address, city, zip_code, province) provided matches the existing data,
* no new record will generate. Instead, the existing company id will return.</p>
* @apiParam {String} name company's name.
* @apiParam {String} address company's address.
* @apiParam {String} country company's country.
* @apiParam {String} province company's city.
* @apiParam {String} city company's city.
* @apiParam {String} zip_code company's zip code.
*
* @apiError 400 Input Invalid. This will happen if the param is missing or not in the valid format.
* @apiError 409 Company name already exist.
* @apiSuccessExample {json} Success-Response:
* HTTP/1.1 200 OK
* {
* "name": "New Company",
* "address": "123 Test Way",
* "country": "United States",
* "city": "Chicago",
* "zip_code": "60606",
* "province": "Illinois",
* "id": 19
* }
*/
public static function addNew()
{
$app = \Slim\Slim::getInstance();
$data = $app->request->post();
//validate input
$validata = $app->validata;
$validator = $validata::key('name', $validata::stringType()->notEmpty())->key('address', $validata::stringType()->notEmpty())->key('country', $validata::stringType()->notEmpty())->key('city', $validata::stringType()->notEmpty())->key('zip_code', $validata::stringType()->notEmpty())->key('province', $validata::stringType()->notEmpty());
if (!$validator->validate((array) $data)) {
$app->halt(400, json_encode("Input Invalid"));
}
foreach ($data as $key => $value) {
if (!in_array($key, ['name', 'address', 'country', 'city', 'province', 'zip_code'])) {
unset($data[$key]);
}
}
if (self::isExist($data['name'])) {
$app->halt(409, json_encode("Compnay name already exists"));
}
$company = Company::firstOrNew($data);
if (!$company->id) {
$company->save();
$group = new Group();
$group->company_id = $company->id;
$group->name = $company->name;
$group->access_code = self::generateRandomString(8);
$group->save();
}
return json_encode($company);
}
示例6: create
public function create()
{
if (!$this->valid_logged_in) {
redirect('users/login');
}
$this->load->library('form_validation');
if ($this->form_validation->run('groups_create') == FALSE) {
$this->load->library('table');
$data['visibility_options'] = $this->visibility_options;
// Load group creation form
$data['title'] = "Create Group";
$data['content'] = 'groups/create';
$this->load->view('master', $data);
} else {
// Create group
$name = $this->input->post('name');
$description = $this->input->post('description');
$visibility = $this->input->post('visibility');
$group = new Group();
$group->name = $name;
$group->description = $description;
$group->visibility = $visibility;
$user = new User($this->user_id);
$group->save($user);
redirect("groups/view/{$group->id}");
}
}
示例7: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
AllPermissionsOptimizationUtil::rebuild();
SecurityTestHelper::createSuperAdmin();
$everyoneGroup = Group::getByName(Group::EVERYONE_GROUP_NAME);
assert($everyoneGroup->save());
// Not Coding Standard
$group1 = new Group();
$group1->name = 'Group1';
assert($group1->save());
// Not Coding Standard
$group2 = new Group();
$group2->name = 'Group2';
assert($group2->save());
// Not Coding Standard
$group3 = new Group();
$group3->name = 'Group3';
assert($group3->save());
// Not Coding Standard
$group4 = new Group();
$group4->name = 'Group4';
assert($group4->save());
// Not Coding Standard
}
示例8: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
SecurityTestHelper::createSuperAdmin();
$super = User::getByUsername('super');
Yii::app()->user->userModel = $super;
AllPermissionsOptimizationUtil::rebuild();
//Add the nobody user to an account, but only read only.
$nobody = User::getByUsername('nobody');
$account = AccountTestHelper::createAccountByNameForOwner('superAccountReadableByNobody', Yii::app()->user->userModel);
$account->addPermissions($nobody, Permission::READ, Permission::ALLOW);
assert($account->save());
// Not Coding Standard
AllPermissionsOptimizationUtil::securableItemGivenPermissionsForUser($account, $nobody);
//Give the nobody user rights to the accounts module.
$nobody->setRight('AccountsModule', AccountsModule::RIGHT_ACCESS_ACCOUNTS);
$nobody->setRight('AccountsModule', AccountsModule::RIGHT_CREATE_ACCOUNTS);
assert($nobody->save());
// Not Coding Standard
$everyoneGroup = Group::getByName(Group::EVERYONE_GROUP_NAME);
assert($everyoneGroup->save());
// Not Coding Standard
$group1 = new Group();
$group1->name = 'Group1';
assert($group1->save());
// Not Coding Standard
}
示例9: makeAll
public function makeAll(&$demoDataHelper)
{
assert('$demoDataHelper instanceof DemoDataHelper');
$group1 = new Group();
$group1->name = 'East';
$saved = $group1->save();
assert('$saved');
$group2 = new Group();
$group2->name = 'West';
$saved = $group2->save();
assert('$saved');
$group3 = new Group();
$group3->name = 'East Channel Sales';
$group3->group = $group1;
$saved = $group3->save();
assert('$saved');
$group4 = new Group();
$group4->name = 'West Channel Sales';
$group4->group = $group2;
$saved = $group4->save();
assert('$saved');
$group5 = new Group();
$group5->name = 'East Direct Sales';
$group5->group = $group1;
$saved = $group5->save();
assert('$saved');
$group6 = new Group();
$group6->name = 'West Direct Sales';
$group6->group = $group2;
$saved = $group6->save();
assert('$saved');
$demoDataHelper->setRangeByModelName('Group', $group1->id, $group6->id);
}
示例10: testPoliciesUtilGetAllPoliciesData
public function testPoliciesUtilGetAllPoliciesData()
{
$group = new Group();
$group->name = 'viewGroup';
$saved = $group->save();
$this->assertTrue($saved);
$this->assertEquals(null, $group->getEffectivePolicy('UsersModule', UsersModule::POLICY_ENFORCE_STRONG_PASSWORDS));
$group->setPolicy('UsersModule', UsersModule::POLICY_ENFORCE_STRONG_PASSWORDS, Policy::YES);
$this->assertTrue($group->save());
$this->assertEquals(Policy::YES, $group->getEffectivePolicy('UsersModule', UsersModule::POLICY_ENFORCE_STRONG_PASSWORDS));
$this->assertEquals(Policy::YES, $group->getExplicitActualPolicy('UsersModule', UsersModule::POLICY_ENFORCE_STRONG_PASSWORDS));
$data = PoliciesUtil::getAllModulePoliciesDataByPermitable($group);
$compareData = array('UsersModule' => array('POLICY_ENFORCE_STRONG_PASSWORDS' => array('displayName' => UsersModule::POLICY_ENFORCE_STRONG_PASSWORDS, 'explicit' => Policy::YES, 'inherited' => null, 'effective' => Policy::YES), 'POLICY_MINIMUM_PASSWORD_LENGTH' => array('displayName' => UsersModule::POLICY_MINIMUM_PASSWORD_LENGTH, 'explicit' => null, 'inherited' => null, 'effective' => 5), 'POLICY_MINIMUM_USERNAME_LENGTH' => array('displayName' => UsersModule::POLICY_MINIMUM_USERNAME_LENGTH, 'explicit' => null, 'inherited' => null, 'effective' => 3), 'POLICY_PASSWORD_EXPIRES' => array('displayName' => UsersModule::POLICY_PASSWORD_EXPIRES, 'explicit' => null, 'inherited' => null, 'effective' => null), 'POLICY_PASSWORD_EXPIRY_DAYS' => array('displayName' => UsersModule::POLICY_PASSWORD_EXPIRY_DAYS, 'explicit' => null, 'inherited' => null, 'effective' => null)));
$this->assertEquals($compareData, $data);
$group->forget();
}
示例11: addGroup
public function addGroup()
{
$sectionCode = SectionCode::find(new MongoId(Input::get('section')));
if (isset($sectionCode->_id)) {
$section = Subject::find($sectionCode->subject_id)->sections()->find($sectionCode->section_id);
if (strcasecmp($section->current_code, $sectionCode->code) === 0) {
$group = new Group();
$group->name = trim(ucfirst(Input::get('name')));
$group->teamleader_id = Auth::id();
$group->section_code_id = new MongoId($sectionCode->_id);
$group->students_id = array(Auth::id());
$group->project_name = trim(strtolower(Input::get('project_name')));
$message = "";
if (Input::hasFile('avatar_file')) {
$data = Input::get('avatar_data');
$image = new CropImage(null, $data, $_FILES['avatar_file']);
$group->logo = $image->getURL();
} else {
$group->logo = null;
}
try {
$group->save();
} catch (MongoDuplicateKeyException $e) {
return Redirect::back()->withErrors(array('error' => Lang::get('register_group.duplicated')));
}
return Redirect::to(Lang::get('routes.add_group'))->with('message', Lang::get('register_group.success'));
} else {
$message = Lang::get('register_group.code_expired');
}
} else {
$message = Lang::get('register_group.code_fail');
}
return Redirect::back()->withErrors(array('error' => $message));
}
示例12: __construct
public function __construct()
{
gateKeeper();
$title = getInput("title");
$description = getInput("description");
$access_id = getInput("access_id");
$membership = getInput("membership");
$group = new Group();
$group->title = $title;
$group->description = $description;
$group->access_id = $access_id;
$group->membership = $membership;
$group->owner_guid = getLoggedInUserGuid();
$group->save();
$group->createAvatar();
$test = getEntity(array("type" => "Groupmembership", "metadata_name_value_pairs" => array(array("name" => "group", "value" => $group->guid), array("name" => "member_guid", "value" => getLoggedInUserGuid()))));
if (!$test) {
$group_membership = new Groupmembership();
$group_membership->group = $group->guid;
$group_membership->member_guid = getLoggedInUserGuid();
$group_membership->access_id = "system";
$group_membership->save();
}
new Activity(getLoggedInUserGuid(), "group:created", array(getLoggedInUser()->getURL(), getLoggedInUser()->full_name, $group->getURL(), $group->title), $group->guid);
new SystemMessage("Your group has been created.");
forward("groups");
}
示例13: actionEdit
/**
* Edits or Creates a user group
*/
public function actionEdit()
{
// Create Group Edit Form
$group = Group::model()->findByPk(Yii::app()->request->getQuery('id'));
if ($group === null) {
$group = new Group();
}
$group->scenario = 'edit';
$group->populateDefaultSpaceGuid();
$group->populateAdminGuids();
// uncomment the following code to enable ajax-based validation
if (isset($_POST['ajax']) && $_POST['ajax'] === 'admin-group-form') {
echo CActiveForm::validate($model);
Yii::app()->end();
}
if (isset($_POST['Group'])) {
$_POST = Yii::app()->input->stripClean($_POST);
$group->attributes = $_POST['Group'];
if ($group->validate()) {
$group->save();
// Redirect to admin groups overview
$this->redirect(Yii::app()->createUrl('//admin/group'));
}
}
$this->render('edit', array('group' => $group));
}
示例14: testMakeFormFromGroup
public function testMakeFormFromGroup()
{
$user = UserTestHelper::createBasicUser('Billy');
$billId = $user->id;
unset($user);
$user = User::getById($billId);
$this->assertEquals('billy', $user->username);
$user = UserTestHelper::createBasicUser('Jimmy');
$jimId = $user->id;
unset($user);
$user = User::getById($jimId);
$this->assertEquals('jimmy', $user->username);
$users = User::GetAll();
$allUsers = array();
foreach ($users as $user) {
$allUsers[$user->id] = strval($user);
}
$this->assertEquals(3, count($allUsers));
$a = new Group();
$a->name = 'JJJ';
$this->assertTrue($a->save());
$this->assertEquals(0, $a->users->count());
$this->assertEquals(0, $a->groups->count());
$form = GroupUserMembershipFormUtil::makeFormFromGroup($a);
$this->assertEquals(array(), $form->userMembershipData);
$this->assertEquals($allUsers, $form->userNonMembershipData);
}
示例15: handleCreate
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function handleCreate()
{
$rules = array('name' => 'required|alpha');
$input = array('groupname' => Input::get('groupname'));
$validator = Validator::make($input, array('groupname' => 'required'));
if ($validator->fails()) {
return Redirect::action('GroupController@index')->withErrors($validator)->withInput(Input::except('password'));
} else {
$permissions = Input::get('permissions');
$group = new Group();
$group->permissions = Input::get('permissions');
$groupname = Input::get('groupname');
$permns = $group->permissions;
foreach ($permns as $key => $value) {
if (strcmp($value, '0') == 0) {
unset($permns[$key]);
}
}
$arr2 = json_encode($permns, JSON_NUMERIC_CHECK);
$group->name = $groupname;
$group->permissions = $arr2;
$group->save();
return Redirect::action('GroupController@index')->with('success', Lang::get('groups.create_success'));
}
}