本文整理汇总了PHP中group::lookup_by_name方法的典型用法代码示例。如果您正苦于以下问题:PHP group::lookup_by_name方法的具体用法?PHP group::lookup_by_name怎么用?PHP group::lookup_by_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类group
的用法示例。
在下文中一共展示了group::lookup_by_name方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: import_group
/**
* Import a single group.
*/
static function import_group(&$queue)
{
$g2_group_id = array_shift($queue);
if (self::map($g2_group_id)) {
return t("Group with id: %id already imported, skipping", array("id" => $g2_group_id));
}
try {
$g2_group = g2(GalleryCoreApi::loadEntitiesById($g2_group_id));
} catch (Exception $e) {
return t("Failed to import Gallery 2 group with id: %id\n%exception", array("id" => $g2_group_id, "exception" => $e->__toString()));
}
switch ($g2_group->getGroupType()) {
case GROUP_NORMAL:
try {
$group = group::create($g2_group->getGroupName());
} catch (Exception $e) {
// @todo For now we assume this is a "duplicate group" exception
$group = group::lookup_by_name($g2_group->getGroupname());
}
$message = t("Group '%name' was imported", array("name" => $g2_group->getGroupname()));
break;
case GROUP_ALL_USERS:
$group = group::registered_users();
$message = t("Group 'Registered' was converted to '%name'", array("name" => $group->name));
break;
case GROUP_SITE_ADMINS:
$message = t("Group 'Admin' does not exist in Gallery 3, skipping");
break;
// This is not a group in G3
// This is not a group in G3
case GROUP_EVERYBODY:
$group = group::everybody();
$message = t("Group 'Everybody' was converted to '%name'", array("name" => $group->name));
break;
}
if (isset($group)) {
self::set_map($g2_group->getId(), $group->id);
}
return $message;
}
示例2: edit_group
public function edit_group($id)
{
access::verify_csrf();
$group = group::lookup($id);
if (empty($group)) {
kohana::show_404();
}
$form = $this->_get_group_edit_form_admin($group);
$valid = $form->validate();
if ($valid) {
$new_name = $form->edit_group->inputs["name"]->value;
$group = group::lookup_by_name($name);
if ($group->loaded) {
$form->edit_group->inputs["name"]->add_error("in_use", 1);
$valid = false;
}
}
if ($valid) {
$group->name = $form->edit_group->inputs["name"]->value;
$group->save();
message::success(t("Changed group %group_name", array("group_name" => $group->name)));
print json_encode(array("result" => "success"));
} else {
message::error(t("Failed to change group %group_name", array("group_name" => $group->name)));
print json_encode(array("result" => "error", "form" => $form->__toString()));
}
}
示例3: import_group
/**
* Import a single group.
*/
static function import_group(&$queue)
{
$g2_group_id = array_shift($queue);
if (self::map($g2_group_id)) {
return;
}
try {
$g2_group = g2(GalleryCoreApi::loadEntitiesById($g2_group_id));
} catch (Exception $e) {
g2_import::log(t("Failed to import Gallery 2 group with id: %id", array("id" => $g2_group_id)));
return;
}
switch ($g2_group->getGroupType()) {
case GROUP_NORMAL:
try {
$group = group::create($g2_group->getGroupName());
} catch (Exception $e) {
// @todo For now we assume this is a "duplicate group" exception
$group = group::lookup_by_name($g2_group->getGroupname());
}
break;
case GROUP_ALL_USERS:
$group = group::registered_users();
break;
case GROUP_SITE_ADMINS:
break;
// This is not a group in G3
// This is not a group in G3
case GROUP_EVERYBODY:
$group = group::everybody();
break;
}
if (isset($group)) {
self::set_map($g2_group->getId(), $group->id);
}
}
示例4: lookup_group_by_name
/**
* @see IdentityProvider_Driver::lookup_group_by_name.
*/
public function lookup_group_by_name($name)
{
return group::lookup_by_name($name);
}