本文整理汇总了PHP中group类的典型用法代码示例。如果您正苦于以下问题:PHP group类的具体用法?PHP group怎么用?PHP group使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了group类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
public function create()
{
$model = new group();
$model->addgroup($_POST["lakeHostGroup"]);
/*** Redirect User to Group/Index ***/
header("location: index.php?rt=group/index");
}
示例2: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store(Request $request)
{
$group = new group();
$group->name = $request->input('name');
$group->body = $request->input('body');
$group->group_type = $request->input('group_type');
if ($request->get('address')) {
$group->address = $request->input('address');
if (!$group->geocode()) {
flash()->error(trans('messages.address_cannot_be_geocoded'));
} else {
flash()->info(trans('messages.ressource_geocoded_successfully'));
}
}
if ($group->isInvalid()) {
// Oops.
return redirect()->action('GroupController@create')->withErrors($group->getErrors())->withInput();
}
$group->save();
// handle cover
if ($request->hasFile('cover')) {
Storage::disk('local')->makeDirectory('groups/' . $group->id);
Image::make($request->file('cover'))->widen(800)->save(storage_path() . '/app/groups/' . $group->id . '/cover.jpg');
Image::make($request->file('cover'))->fit(300, 200)->save(storage_path() . '/app/groups/' . $group->id . '/thumbnail.jpg');
}
// make the current user a member of the group
$membership = \App\Membership::firstOrNew(['user_id' => $request->user()->id, 'group_id' => $group->id]);
$membership->notification_interval = 60 * 24;
// default to daily interval
$membership->membership = \App\Membership::MEMBER;
$membership->save();
return redirect()->action('MembershipController@settings', [$group->id]);
}
示例3: person_rm_groups
function person_rm_groups($groups)
{
foreach ($groups as $i => $groupdata) {
$group = new group($groupdata['id']);
$group->delete();
}
}
示例4: getGroup
function getGroup()
{
$groupid = $this->getGroupID();
if ($groupid != false) {
$group = new group($this->getGroupID());
if ($group->getID() != false) {
//valid group
return $group;
}
}
return false;
}
示例5: save
private static function save($group_id, $group_name)
{
if ($group_id * 1 === -1) {
$group = new group();
$group->name = $group_name;
$group->insert();
} else {
$group = new group();
$group->id = $group_id;
$group->name = $group_name;
$group->update();
}
}
示例6: search
public function search($params)
{
$query = group::find();
$dataProvider = new ActiveDataProvider(['query' => $query]);
$dataProvider->setSort(['defaultOrder' => ['parentId' => SORT_ASC, 'name' => SORT_ASC]]);
$query->andFilterWhere([group::tableName() . '.status' => '1']);
if (!($this->load($params) && $this->validate())) {
$query->joinWith(['parent']);
return $dataProvider;
}
/*$query->andFilterWhere([
'Id' => $this->Id,
'createdon' => $this->createdon,
]);//*/
$query->andFilterWhere(['like', group::tableName() . '.name', $this->name]);
//->andFilterWhere(['like', 'parentId', $this->ParentGroup])
//->andFilterWhere(['like', 'status', $this->status]);
if ($this->parentGroup != '' && strtolower($this->parentGroup) != 'root') {
$query->joinWith(['parent' => function ($q) {
$q->where('parent.name LIKE "%' . $this->parentGroup . '%" ');
}]);
} else {
if (strtolower($this->parentGroup) == 'root') {
$query->andFilterWhere([group::tableName() . '.parentId' => 0]);
}
}
return $dataProvider;
}
示例7: install
static function install()
{
$db = Database::instance();
$version = module::get_version("user");
if ($version == 0) {
$db->query("CREATE TABLE IF NOT EXISTS {users} (\n `id` int(9) NOT NULL auto_increment,\n `name` varchar(32) NOT NULL,\n `full_name` varchar(255) NOT NULL,\n `password` varchar(64) NOT NULL,\n `login_count` int(10) unsigned NOT NULL DEFAULT 0,\n `last_login` int(10) unsigned NOT NULL DEFAULT 0,\n `email` varchar(64) default NULL,\n `admin` BOOLEAN default 0,\n `guest` BOOLEAN default 0,\n `hash` char(32) default NULL,\n `url` varchar(255) default NULL,\n `locale` char(10) default NULL,\n PRIMARY KEY (`id`),\n UNIQUE KEY(`hash`),\n UNIQUE KEY(`name`))\n ENGINE=InnoDB DEFAULT CHARSET=utf8;");
$db->query("CREATE TABLE IF NOT EXISTS {groups} (\n `id` int(9) NOT NULL auto_increment,\n `name` char(64) default NULL,\n `special` BOOLEAN default 0,\n PRIMARY KEY (`id`),\n UNIQUE KEY(`name`))\n ENGINE=InnoDB DEFAULT CHARSET=utf8;");
$db->query("CREATE TABLE IF NOT EXISTS {groups_users} (\n `group_id` int(9) NOT NULL,\n `user_id` int(9) NOT NULL,\n PRIMARY KEY (`group_id`, `user_id`),\n UNIQUE KEY(`user_id`, `group_id`))\n ENGINE=InnoDB DEFAULT CHARSET=utf8;");
$everybody = group::create("Everybody");
$everybody->special = true;
$everybody->save();
$registered = group::create("Registered Users");
$registered->special = true;
$registered->save();
$guest = user::create("guest", "Guest User", "");
$guest->guest = true;
$guest->remove($registered);
$guest->save();
$admin = user::create("admin", "Gallery Administrator", "admin");
$admin->admin = true;
$admin->save();
// Let the admin own everything
$db->update("items", array("owner_id" => $admin->id), array("owner_id" => "IS NULL"));
module::set_version("user", 1);
$root = ORM::factory("item", 1);
access::allow($everybody, "view", $root);
access::allow($everybody, "view_full", $root);
access::allow($registered, "view", $root);
access::allow($registered, "view_full", $root);
}
}
示例8: show
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show(Request $request)
{
$groups = group::lists('name', 'group_id');
$locations = location::orderBy('location_id')->lists('location', 'location_id');
//$locations = array_merge($locations, array('0', 'National'));
$group_id = $request->input('group_id');
$location_id = $request->input('location_id');
if (!isset($group_id)) {
$group_id = 1;
}
if (!isset($location_id)) {
$location_id = 0;
}
/*
$rankings = \DB::table('rankings')
->join('players', 'rankings.player_id', '=', 'players.player_id')
->join('groups', 'rankings.group_id', '=', 'groups.group_id')
->join('locations', 'rankings.location_id', '=', 'locations.location_id')
->where('ranking_date', '=', $latest_date)
->where('rankings.group_id', '=', $group_id)
->where('rankings.location_id', '=', $location_id)
->distinct()
->get();
*/
$ranking = new Ranking();
$rankings = $ranking->getlatestRankings($group_id, $location_id);
return view('pages/rankings', compact('rankings', 'groups', 'locations'));
}
示例9: pg_new_edit
function pg_new_edit($pg)
{
$group = new group();
foreach ($pg as $gid => $persons) {
$group->load($gid);
if (!$group->is_head()) {
continue;
}
foreach ($persons as $pid => $decision) {
if ($decision == 0) {
continue;
}
$group->del_member_request($pid);
if ($decision == 1) {
continue;
}
$group->add_member($pid);
}
}
}
示例10: superuser
function superuser($id = "")
{
if (!$id and $id = user::id()) {
$id = user::id();
}
$userArray = user::get($id);
if (group::superuser($userArray[group])) {
return TRUE;
} else {
return FALSE;
}
}
示例11: cant_view_comments_for_unviewable_items_test
public function cant_view_comments_for_unviewable_items_test()
{
$root = ORM::factory("item", 1);
$album = album::create($root, rand(), rand(), rand());
$comment = comment::create($album, user::guest(), "text", "name", "email", "url");
user::set_active(user::guest());
// We can see the comment when permissions are granted on the album
access::allow(group::everybody(), "view", $album);
$this->assert_equal(1, ORM::factory("comment")->viewable()->where("comments.id", $comment->id)->count_all());
// We can't see the comment when permissions are denied on the album
access::deny(group::everybody(), "view", $album);
$this->assert_equal(0, ORM::factory("comment")->viewable()->where("comments.id", $comment->id)->count_all());
}
示例12: viewable_test
public function viewable_test()
{
$root = ORM::factory("item", 1);
$album = album::create($root, rand(), rand(), rand());
$item = self::_create_random_item($album);
user::set_active(user::guest());
// We can see the item when permissions are granted
access::allow(group::everybody(), "view", $album);
$this->assert_equal(1, ORM::factory("item")->viewable()->where("id", $item->id)->count_all());
// We can't see the item when permissions are denied
access::deny(group::everybody(), "view", $album);
$this->assert_equal(0, ORM::factory("item")->viewable()->where("id", $item->id)->count_all());
}
示例13: create
/**
* Create a new user.
*
* @param string $name
* @param string $full_name
* @param string $password
* @return User_Model
*/
static function create($name, $full_name, $password)
{
$user = ORM::factory("user")->where("name", $name)->find();
if ($user->loaded) {
throw new Exception("@todo USER_ALREADY_EXISTS {$name}");
}
$user->name = $name;
$user->full_name = $full_name;
$user->password = $password;
// Required groups
$user->add(group::everybody());
$user->add(group::registered_users());
$user->save();
return $user;
}
示例14: change_photo_no_csrf_fails_test
public function change_photo_no_csrf_fails_test()
{
$controller = new Photos_Controller();
$root = ORM::factory("item", 1);
$photo = photo::create($root, MODPATH . "gallery/tests/test.jpg", "test", "test", "test");
$_POST["name"] = "new name";
$_POST["title"] = "new title";
$_POST["description"] = "new description";
access::allow(group::everybody(), "edit", $root);
try {
$controller->_update($photo);
$this->assert_true(false, "This should fail");
} catch (Exception $e) {
// pass
}
}
示例15: change_album_no_csrf_fails_test
public function change_album_no_csrf_fails_test()
{
$controller = new Albums_Controller();
$root = ORM::factory("item", 1);
$this->_album = album::create($root, "test", "test", "test");
$_POST["name"] = "new name";
$_POST["title"] = "new title";
$_POST["description"] = "new description";
access::allow(group::everybody(), "edit", $root);
try {
$controller->_update($this->_album);
$this->assert_true(false, "This should fail");
} catch (Exception $e) {
// pass
}
}