本文整理汇总了PHP中Group::destroy方法的典型用法代码示例。如果您正苦于以下问题:PHP Group::destroy方法的具体用法?PHP Group::destroy怎么用?PHP Group::destroy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Group
的用法示例。
在下文中一共展示了Group::destroy方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: destroy
public static function destroy($id)
{
self::check_logged_in();
$group = new Group(array('id' => $id));
$group->destroy();
Redirect::to('/group', array('message' => 'Ryhmä poistettu'));
}
示例2: destroy
/**
* Remove the specified group from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
if (!Sentry::getUser()) {
return Redirect::route('sessions.create');
}
Group::destroy($id);
return Redirect::route('groups.index');
}
示例3: run
public function run($request)
{
// get all groups from LDAP, but only get the attributes we need.
// this is useful to avoid holding onto too much data in memory
// especially in the case where getGroups() would return a lot of groups
$ldapGroups = $this->ldapService->getGroups(false, array('objectguid', 'samaccountname', 'dn', 'name', 'description'), 'objectguid');
$start = time();
$count = 0;
foreach ($ldapGroups as $data) {
$group = Group::get()->filter('GUID', $data['objectguid'])->limit(1)->first();
if (!($group && $group->exists())) {
// create the initial Group with some internal fields
$group = new Group();
$group->GUID = $data['objectguid'];
$this->log(sprintf('Creating new Group (ID: %s, GUID: %s, sAMAccountName: %s)', $group->ID, $data['objectguid'], $data['samaccountname']));
} else {
$this->log(sprintf('Updating existing Group "%s" (ID: %s, GUID: %s, sAMAccountName: %s)', $group->getTitle(), $group->ID, $data['objectguid'], $data['samaccountname']));
}
// Synchronise specific guaranteed fields.
$group->Code = $data['samaccountname'];
if (!empty($data['name'])) {
$group->Title = $data['name'];
} else {
$group->Title = $data['samaccountname'];
}
if (!empty($data['description'])) {
$group->Description = $data['description'];
}
$group->DN = $data['dn'];
$group->LastSynced = (string) SS_Datetime::now();
$group->IsImportedFromLDAP = true;
$group->write();
// Mappings on this group are automatically maintained to contain just the group's DN.
// First, scan through existing mappings and remove ones that are not matching (in case the group moved).
$hasCorrectMapping = false;
foreach ($group->LDAPGroupMappings() as $mapping) {
if ($mapping->DN === $data['dn']) {
// This is the correct mapping we want to retain.
$hasCorrectMapping = true;
} else {
$this->log(sprintf('Deleting invalid mapping %s on %s.', $mapping->DN, $group->getTitle()));
$mapping->delete();
}
}
// Second, if the main mapping was not found, add it in.
if (!$hasCorrectMapping) {
$this->log(sprintf('Setting up missing group mapping from %s to %s', $group->getTitle(), $data['dn']));
$mapping = new LDAPGroupMapping();
$mapping->DN = $data['dn'];
$mapping->write();
$group->LDAPGroupMappings()->add($mapping);
}
// cleanup object from memory
$group->destroy();
$count++;
}
// remove Group records that were previously imported, but no longer exist in the directory
// NOTE: DB::query() here is used for performance and so we don't run out of memory
if ($this->config()->destructive) {
foreach (DB::query('SELECT "ID", "GUID" FROM "Group" WHERE "IsImportedFromLDAP" = 1') as $record) {
if (!isset($ldapGroups[$record['GUID']])) {
$group = Group::get()->byId($record['ID']);
// Cascade into mappings, just to clean up behind ourselves.
foreach ($group->LDAPGroupMappings() as $mapping) {
$mapping->delete();
}
$group->delete();
$this->log(sprintf('Removing Group "%s" (GUID: %s) that no longer exists in LDAP.', $group->Title, $group->GUID));
// cleanup object from memory
$group->destroy();
}
}
}
$end = time() - $start;
$this->log(sprintf('Done. Processed %s records. Duration: %s seconds', $count, round($end, 0)));
}
示例4: destroy
/**
* Remove the specified group from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
Group::destroy($id);
return Redirect::route('groups.index');
}
示例5: Group
<?php
include_once "chain_record_define.php";
/* $obj has same named properties with group table columns. */
$obj = new Group();
$obj->destroy(array("dbs" => array("testdb1", "testdb2")));
/* Create model object with hash array. */
$m = $obj->create(array("title" => "ChainRecord Introduction.", "memo" => "This is sample code."));
/* save model object (insert) */
/*
try{
$m->save(array(
"dbs" => array("testdb1","testdb2")
)
);
}catch(Exception $e){
echo "save failed.\n";
}
*/
示例6: catch
} catch (Exception $e) {
// Do nothing
}
try {
$group->remove_reader($user);
} catch (Exception $e) {
// Do nothing
}
// If user was removed, then say so and quit.
if (!$group->is_admin($user) && !$group->is_reader($user)) {
Helpers::respond_json(new Attempt('success', "{$user->get_name()} removed from {$group->get_name()}."));
die;
}
try {
// If user is still admin, destroy group
$group->destroy($user);
$attempt = new Attempt('success', 'Group ' . $group->get_name() . ' removed permanently by ' . $user->get_name() . ".");
} catch (Exception $e) {
Helpers::respond_json(new Attempt('error', $e->getMessage()));
die;
}
// END of remove_group
} else {
if ($action == "am_admin") {
try {
$group_name = Helpers::require_variable('group', 'a group name');
$user_name = Helpers::require_variable('user', 'a user to validate');
$group = new Group(array("name" => $group_name));
$user = new User(array("name" => $user_name, "admin" => true));
$group->read();
$user->read();
示例7: destroyAction
function destroyAction()
{
$group = new Group($this->args[1]);
if ($group->destroy()) {
$this->flash('Group removed successfully.');
redirect_to(ADMIN_URL . '/groups');
} else {
$this->flash('There was an error deleting the group.');
redirect_to(ADMIN_URL . '/groups/show/' . $group->id);
}
}
示例8: tearDown
protected function tearDown()
{
$grp = new Group();
$grp->destroy(array("dbs" => array("testdb1", "testdb2")));
}
示例9: tearDown
protected function tearDown()
{
$grp = new Group();
$grp->destroy();
}
示例10: Group
<?php
include_once "chain_record_define.php";
/* $obj has same named properties with group table columns. */
$obj = new Group();
$t1 = "destroy target record title";
/* delete groups table records */
$obj->destroy(array("cond" => array("title = ?", $t1)));
/* SQL: DELETE FROM groups WHERE title = ? */
/* parameter $t1 bind to '?' by database api */
示例11: destroy
public static function destroy($id)
{
parent::check_logged_in();
Group::destroy($id);
Redirect::to('/group', array('message' => 'Group has been removed.'));
}