本文整理匯總了PHP中Group::write方法的典型用法代碼示例。如果您正苦於以下問題:PHP Group::write方法的具體用法?PHP Group::write怎麽用?PHP Group::write使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Group
的用法示例。
在下文中一共展示了Group::write方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: updatedetails
/**
* Update the details for the organisation
*/
function updatedetails($data, $form, $request)
{
if ($this->group) {
$this->saveInto($this->group);
$this->group->write();
$form->sessionMessage(_t('EcommerceCorporateAccount.DETAILSHAVEBEENUPDATED', 'Your details have been updated.'), 'good');
Director::redirectBack();
} else {
$form->sessionMessage(_t('EcommerceCorporateAccount.DETAILSCOULDNOTBEUPATED', 'Your details have not been updated.'), 'bad');
Director::redirectBack();
}
}
開發者ID:helpfulrobot,項目名稱:sunnysideup-ecommerce-corporate-account,代碼行數:15,代碼來源:CorporateAccountOrganisationForm.php
示例2: Group
static function add_members_to_customer_group()
{
$gp = DataObject::get_one("Group", "\"Title\" = '" . self::get_group_name() . "'");
if (!$gp) {
$gp = new Group();
$gp->Title = self::get_group_name();
$gp->Sort = 999998;
$gp->write();
}
$allCombos = DB::query("Select \"ID\", \"MemberID\", \"GroupID\" FROM \"Group_Members\" WHERE \"Group_Members\".\"GroupID\" = " . $gp->ID . ";");
//make an array of all combos
$alreadyAdded = array();
$alreadyAdded[-1] = -1;
if ($allCombos) {
foreach ($allCombos as $combo) {
$alreadyAdded[$combo["MemberID"]] = $combo["MemberID"];
}
}
$extraWhere = $unlistedMembers = DataObject::get("Member", $where = "\"Member\".\"ID\" NOT IN (" . implode(",", $alreadyAdded) . ")", $sort = null, $join = "INNER JOIN \"Order\" ON \"Order\".\"MemberID\" = \"Member\".\"ID\"");
//add combos
if ($unlistedMembers) {
$existingMembers = $gp->Members();
foreach ($unlistedMembers as $member) {
$existingMembers->add($member);
}
}
}
示例3: requireDefaultRecords
public function requireDefaultRecords()
{
parent::requireDefaultRecords();
// Add default author group if no other group exists
$frontend_group = Group::get()->filter("Code", "users-frontend");
if (!$frontend_group->exists()) {
$frontend_group = new Group();
$frontend_group->Code = 'users-frontend';
$frontend_group->Title = "Frontend Users";
$frontend_group->Sort = 1;
$frontend_group->write();
Permission::grant($frontend_group->ID, 'USERS_MANAGE_ACCOUNT');
DB::alteration_message('Front end users group created', 'created');
}
// Add a verified users group (only used if we turn on
// verification)
$verify_group = Group::get()->filter("Code", "users-verified");
if (!$verify_group->exists()) {
$verify_group = new Group();
$verify_group->Code = 'users-verified';
$verify_group->Title = "Verified Users";
$verify_group->Sort = 1;
$verify_group->write();
Permission::grant($verify_group->ID, 'USERS_VERIFIED');
DB::alteration_message('Verified users group created', 'created');
}
}
示例4: processRecord
public function processRecord($record, $columnMap, &$results, $preview = false)
{
$objID = parent::processRecord($record, $columnMap, $results, $preview);
$_cache_groupByCode = array();
// Add to predefined groups
$member = DataObject::get_by_id($this->objectClass, $objID);
foreach ($this->groups as $group) {
// TODO This isnt the most memory effective way to add members to a group
$member->Groups()->add($group);
}
// Add to groups defined in CSV
if (isset($record['Groups']) && $record['Groups']) {
$groupCodes = explode(',', $record['Groups']);
foreach ($groupCodes as $groupCode) {
$groupCode = Convert::raw2url($groupCode);
if (!isset($_cache_groupByCode[$groupCode])) {
$group = Group::get()->filter('Code', $groupCode)->first();
if (!$group) {
$group = new Group();
$group->Code = $groupCode;
$group->Title = $groupCode;
$group->write();
}
$member->Groups()->add($group);
$_cache_groupByCode[$groupCode] = $group;
}
}
}
$member->destroy();
unset($member);
return $objID;
}
示例5: strtolower
static function get_main_group()
{
$group = DataObject::get_one('Group', "Code = '" . strtolower(self::$main_group) . "'");
if (!$group) {
$group = new Group(array('Title' => self::$main_group));
$group->write();
}
return $group;
}
示例6: doUp
function doUp()
{
global $database;
$members = array(1368, 270, 9202);
// EdgarMagana, JonProulx, ShillaSaebi
$group = new Group();
$group->setTitle('User Committee');
$group->setDescription('User Committee');
$group->setSlug('user-committee');
$group->write();
$group->Members()->setByIDList($members);
}
示例7: testAlternateTreeTitle
function testAlternateTreeTitle()
{
$group = new Group();
$group->Title = 'The A Team';
$group->AccessAllSubsites = true;
$this->assertEquals($group->getTreeTitle(), 'The A Team <i>(global group)</i>');
$group->AccessAllSubsites = false;
$group->write();
$group->Subsites()->add($this->objFromFixture('Subsite', 'domaintest1'));
$group->Subsites()->add($this->objFromFixture('Subsite', 'domaintest2'));
$this->assertEquals($group->getTreeTitle(), 'The A Team <i>(Test 1, Test 2)</i>');
}
示例8: requireDefaultRecords
/**
* Add a specific group in order to enable users/groups managemet
*/
public function requireDefaultRecords()
{
$group = DataObject::get('Group', "Code = 'users-manager'");
if (!$group->count()) {
$usersManagerGroup = new Group();
$usersManagerGroup->Code = 'users-manager';
$usersManagerGroup->Title = _t('Group.DefaultGroupTitleUsersManager', 'Users Manager');
$usersManagerGroup->Sort = 0;
$usersManagerGroup->write();
Permission::grant($usersManagerGroup->ID, 'CMS_ACCESS_SecurityAdmin');
}
}
示例9: requireDefaultRecords
function requireDefaultRecords()
{
if (!Group::get()->filter(array("Code" => "team-member"))->First()) {
$group = new Group();
$group->Title = "Team Member";
$group->Code = "team-member";
$group->Sort = 2;
$group->write();
$group->flushCache();
DB::alteration_message('Team Member Group created', 'created');
}
parent::requireDefaultRecords();
}
示例10: requireDefaultRecords
public function requireDefaultRecords()
{
parent::requireDefaultRecords();
// Add default author group if no other group exists
$curr_group = Group::get()->filter("Code", "customers");
if (!$curr_group->exists()) {
$group = new Group();
$group->Code = 'customers';
$group->Title = "Customers";
$group->Sort = 1;
$group->write();
DB::alteration_message('Customers group created', 'created');
}
}
示例11: requireDefaultRecords
function requireDefaultRecords()
{
parent::requireDefaultRecords();
//Create a new group for customers
$allGroups = DataObject::get('Group');
$existingCustomerGroup = $allGroups->find('Title', 'Customers');
if (!$existingCustomerGroup) {
$customerGroup = new Group();
$customerGroup->Title = 'Customers';
$customerGroup->setCode($customerGroup->Title);
$customerGroup->write();
Permission::grant($customerGroup->ID, 'VIEW_ORDER');
}
}
示例12: testOverwriteExistingImport
function testOverwriteExistingImport()
{
$existinggroup = new Group();
$existinggroup->Title = 'Old Group Title';
$existinggroup->Code = 'newgroup1';
$existinggroup->write();
$loader = new GroupCsvBulkLoader();
$results = $loader->load('sapphire/tests/security/GroupCsvBulkLoaderTest.csv');
$created = $results->Created()->toArray();
$this->assertEquals(count($created), 1);
$this->assertEquals($created[0]->Code, 'newchildgroup1');
$updated = $results->Updated()->toArray();
$this->assertEquals(count($updated), 1);
$this->assertEquals($updated[0]->Code, 'newgroup1');
$this->assertEquals($updated[0]->Title, 'New Group 1');
}
示例13: testOverwriteExistingImport
public function testOverwriteExistingImport()
{
$existinggroup = new Group();
$existinggroup->Title = 'Old Group Title';
$existinggroup->Code = 'newgroup1';
$existinggroup->write();
$loader = new GroupCsvBulkLoader();
$results = $loader->load($this->getCurrentRelativePath() . '/GroupCsvBulkLoaderTest.csv');
$created = $results->Created()->toArray();
$this->assertEquals(count($created), 1);
$this->assertEquals($created[0]->Code, 'newchildgroup1');
$updated = $results->Updated()->toArray();
$this->assertEquals(count($updated), 1);
$this->assertEquals($updated[0]->Code, 'newgroup1');
$this->assertEquals($updated[0]->Title, 'New Group 1');
}
示例14: onAfterWrite
public function onAfterWrite()
{
parent::onAfterWrite();
// TODO: should test if this is needed or not
if (!$this->owner->ID) {
return;
}
// Apply the subsite title to config
$siteconfig = $this->getSiteConfig();
if ($siteconfig) {
if ($siteconfig->Title == _t('Subsite.SiteConfigTitle', 'Your Site Name') && $this->owner->Title) {
$siteconfig->Title = $this->owner->Title;
$siteconfig->write();
}
}
// Make sure we have groups for this subsite
$groupName = $this->getAdministratorGroupName();
$group = self::getGroupByName($groupName);
if ($groupName && !$group) {
$group = new Group();
$group->Title = $groupName;
$group->AccessAllSubsites = false;
$group->write();
$group->Subsites()->add($this->owner);
// Apply default permissions to this group
$codes = array_unique(array_keys(Permission::get_codes(false)));
$default_permissions = Config::inst()->get('SubsiteExtension', 'admin_default_permissions');
foreach ($default_permissions as $p) {
if (in_array($p, $codes)) {
$po = new Permission(array('Code' => $p));
$po->write();
$group->Permissions()->add($po);
}
}
$group->write();
}
$membersGroupName = $this->getMembersGroupName();
$membersGroup = self::getGroupByName($membersGroupName);
if ($membersGroupName && !$membersGroup) {
$membersGroup = new Group();
$membersGroup->Title = $membersGroupName;
$membersGroup->AccessAllSubsites = true;
$membersGroup->write();
$membersGroup->Subsites()->add($this->owner);
$membersGroup->write();
}
}
示例15: up
function up()
{
echo "Starting Migration Proc ...<BR>";
//check if migration already had ran ...
$migration = DataObject::get_one("Migration", "Name='{$this->title}'");
if (!$migration) {
$g = new Group();
$g->setTitle('Community Members');
$g->setDescription('Community Members');
$g->setSlug(IFoundationMember::CommunityMemberGroupSlug);
$g->write();
$migration = new Migration();
$migration->Name = $this->title;
$migration->Description = $this->description;
$migration->Write();
}
echo "Ending Migration Proc ...<BR>";
}