当前位置: 首页>>代码示例>>PHP>>正文


PHP group::create方法代码示例

本文整理汇总了PHP中group::create方法的典型用法代码示例。如果您正苦于以下问题:PHP group::create方法的具体用法?PHP group::create怎么用?PHP group::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在group的用法示例。


在下文中一共展示了group::create方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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);
     }
 }
开发者ID:xafr,项目名称:gallery3,代码行数:31,代码来源:user_installer.php

示例2: install

 static function install()
 {
     $db = Database::instance();
     $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               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               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               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();
     $current_provider = module::get_var("gallery", "identity_provider");
     if (empty($current_provider)) {
         // If there is no provider defined then we are doing an initial install
         // so we need to set the provider and make the administrator own everything
         // If the installer is called and there is an identity provider, then we
         // are switching identity providers and and the event handlers will do the
         // right things
         module::set_var("gallery", "identity_provider", "user");
         // Let the admin own everything
         $db->query("update {items} set owner_id = {$admin->id}");
     }
     $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);
     module::set_var("user", "mininum_password_length", 5);
     module::set_version("user", 2);
 }
开发者ID:ChrisRut,项目名称:gallery3,代码行数:38,代码来源:user_installer.php

示例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 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;
 }
开发者ID:hiwilson,项目名称:gallery3,代码行数:43,代码来源:g2_import.php

示例4: 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);
     }
 }
开发者ID:HelixiR,项目名称:gallery3,代码行数:39,代码来源:g2_import.php

示例5: i_can_edit_test

 public function i_can_edit_test()
 {
     // Create a new user that belongs to no groups
     $user = user::create("access_test", "Access Test", "");
     foreach ($user->groups as $group) {
         $user->remove($group);
     }
     $user->save();
     user::set_active($user);
     // This user can't edit anything
     $root = ORM::factory("item", 1);
     $this->assert_false(access::can("edit", $root));
     // Now add them to a group that has edit permission
     $group = group::create("access_test");
     $group->add($user);
     $group->save();
     access::allow($group, "edit", $root);
     $user = ORM::factory("user", $user->id);
     // reload() does not flush related columns
     user::set_active($user);
     // And verify that the user can edit.
     $this->assert_true(access::can("edit", $root));
 }
开发者ID:krgeek,项目名称:gallery3,代码行数:23,代码来源:Access_Helper_Test.php

示例6: add_group

 public function add_group()
 {
     access::verify_csrf();
     $form = $this->_get_group_add_form_admin();
     $valid = $form->validate();
     if ($valid) {
         $new_name = $form->add_group->inputs["name"]->value;
         $group = group::lookup_by_name($new_name);
         if (!empty($group)) {
             $form->add_group->inputs["name"]->add_error("in_use", 1);
             $valid = false;
         }
     }
     if ($valid) {
         $group = group::create($new_name);
         $group->save();
         message::success(t("Created group %group_name", array("group_name" => $group->name)));
         print json_encode(array("result" => "success"));
     } else {
         print json_encode(array("result" => "error", "form" => $form->__toString()));
     }
 }
开发者ID:ChrisRut,项目名称:gallery3,代码行数:22,代码来源:admin_users.php

示例7: create_group

 /**
  * @see IdentityProvider_Driver::create_group.
  */
 public function create_group($name)
 {
     return group::create($name);
 }
开发者ID:ChrisRut,项目名称:gallery3,代码行数:7,代码来源:Gallery.php

示例8: add_group

 public function add_group()
 {
     access::verify_csrf();
     $form = group::get_add_form_admin();
     $valid = $form->validate();
     if ($valid) {
         $new_name = $form->add_group->inputs["name"]->value;
         $group = ORM::factory("group")->where("name", $new_name)->find();
         if ($group->loaded) {
             $form->add_group->inputs["name"]->add_error("in_use", 1);
             $valid = false;
         }
     }
     if ($valid) {
         $group = group::create($new_name);
         $group->save();
         message::success(t("Created group %group_name", array("group_name" => p::clean($group->name))));
         print json_encode(array("result" => "success"));
     } else {
         print json_encode(array("result" => "error", "form" => $form->__toString()));
     }
 }
开发者ID:hiwilson,项目名称:gallery3,代码行数:22,代码来源:admin_users.php

示例9: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     group::create($request->all());
     return redirect('admin/groups')->with('success', Lang::get('message.success.create'));
 }
开发者ID:zangee3,项目名称:avs,代码行数:10,代码来源:GroupsController.php

示例10: group

<?php

/*
 * This file is part of Infoschool - a web based school intranet.
 * Copyright (C) 2004 Maikel Linke
 */
include 'var.php';
$output->secure();
$groupname = '';
if (isset($_POST['name'])) {
    $groupname = $_POST['name'];
}
$group = new group();
$group->create($groupname);
redirect('group.php');
开发者ID:BackupTheBerlios,项目名称:infoschool-svn,代码行数:15,代码来源:group_new.php


注:本文中的group::create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。