用户分组管理 - 创建分组

Examples:
```
$api->create_group('新的一个分组');
```
Result:
```
[
null,
{
group: {
id: 104,
name: "新的一个分组"
}
}
]
```

@param string $group_name [分组名字（30个字符以内）]

@return array(err, data)
- `err`, 调用失败时得到的异常
- `res`, 调用正常时得到的对象
973029
public function create_group($group_name)
    {
        $url = self::API_DOMAIN . 'cgi-bin/groups/create?access_token=' .$this->get_access_token();
        $xml = sprintf('{"group":{"name":"%s"}}', $group_name);
        $res = HttpCurl::post($url, $xml, 'json');
        // 异常处理: 获取时网络错误
        if ($res === false) {
            return Error::code('ERR_POST');
        }
        // 判断是否调用成功
        if (isset($res->group)) {
            return array(null, $res);
        } else {
            return array($res, null);
        }
    }
562124
public function getSelection($group_name, $name = 'group')
    {
        if(!array_key_exists($group_name, $this->units))
        {
            throw new ExtractorException('Ни одной выборки для группы '.$group_name.' не создано!');
        }

        if(!array_key_exists($name, $this->units[$group_name]))
        {
            throw new ExtractorException('Выборка для группы '.$group_name.' по имени '.$name.' не создана!');
        }

        return $this->units[$group_name][$name];
    }
481614
public function get_name($group = null)
	{
		// if no group is given
		if ($group === null)
		{
			// try get the the group assigned to the logged-in user
			if ( ! $login = \Auth::instance() or ! is_array($groups = $login->get_groups()))
			{
				return false;
			}
			$group = isset($groups[0][1]) ? $groups[0][1] : null;
		}

		// if it's a group id, find the corresponding object
		elseif (is_numeric($group) and isset(static::$_valid_groups[$group]))
		{
			$group = static::$_valid_groups[$group];
		}

		// if the group was found, return the name
		if ($group instanceOf Model\Auth_Group)
		{
			return $group->name;
		}
		else
		{
			// no group found, so no name either
			return null;
		}
	}
823937
public CreateGroupResponse createGroup(String name) {
        CreateGroupResponse response;
        BeanUtil.requireNonNull(name, "name is null");
        LOG.debug("创建分组.....");
        String url = BASE_API_URL + "cgi-bin/groups/create?access_token=#";
        Map<String, Object> param = new HashMap<String, Object>();
        Map<String, Object> group = new HashMap<String, Object>();
        group.put("name", name);
        param.put("group", group);
        BaseResponse r = executePost(url, JSONUtil.toJson(param));
        String resultJson = isSuccess(r.getErrcode()) ? r.getErrmsg() : r.toJsonString();
        response = JSONUtil.toBean(resultJson, CreateGroupResponse.class);
        return response;
    }
1057044
public function getSubGroupType($group_name, $ref_name = 'superior')
    {
        $types = $this->getSubs($ref_name);

        return $types->getType($group_name);
    }
1214464
function CreateGroup(
      $id = '',
      $name = '',
      $description = ''
  ) {
      if ("" != trim($name)) {
          $group_id = $id;
          if (('' == $group_id) || ('0' == $group_id)) {
              $group_id = bigdec2hex((time()-mktime(1,1,1,1,1,2000)).mt_rand(10000,99999));
          }
          if ($this->CheckGroupExists($group_id)) {
              return FALSE; // ERROR: group already exists.
          } else {
              $this->SetGroup($group_id);
              $this->SetGroupName(trim($name));
              $this->SetGroupDescription($description);
              return $this->WriteGroupData();
          }
      } else {
          return TRUE;
      }
  }
332650
static function getNodeAssignmentsForGroupName( $groupName,
                                $isFirstGroupAssignment,
                                &$defaultUserPlacement,
                                &$extraNodeAssignments,
                                $createMissingGroups,
                                $parentNodeID )
    {
        if ( !is_string( $groupName ) or $groupName === '' )
        {
            eZDebug::writeError( 'The groupName must be a non empty string. Bad groupName: ' . $groupName, __METHOD__ );
            return;
        }

        $db = eZDB::instance();
        $ini = eZINI::instance();
        $userGroupClassID = $ini->variable( "UserSettings", "UserGroupClassID" );

        $groupNameEscaped = $db->escapeString( $groupName );
        $groupQuery = "SELECT ezcontentobject_tree.node_id
                       FROM ezcontentobject, ezcontentobject_tree
                       WHERE ezcontentobject.name like '$groupNameEscaped'
                       AND ezcontentobject.id = ezcontentobject_tree.contentobject_id
                       AND ezcontentobject.contentclass_id = $userGroupClassID";
        $groupRows = $db->arrayQuery( $groupQuery );

        if ( count( $groupRows ) > 0 and $isFirstGroupAssignment )
        {
            $defaultUserPlacement = $groupRows[0]['node_id'];
            return;
        }
        else if ( count( $groupRows ) > 0 )
        {
            $extraNodeAssignments[] = $groupRows[0]['node_id'];
            return;
        }

        // Should we create user groups that are specified in LDAP, but not found in eZ Publish?
        if ( !$createMissingGroups )
        {
            return;
        }

        $newNodeIDs = self::publishNewUserGroup( array( $parentNodeID ), array( 'name' => $groupName ) );

        if ( count( $newNodeIDs ) > 0 and $isFirstGroupAssignment )
        {
            $defaultUserPlacement = $newNodeIDs[0]; // We only supplied one parent to publishNewUserGroup(), so there is only one node
        }
        else if ( count( $newNodeIDs ) > 0 )
        {
            $extraNodeAssignments[] = $newNodeIDs[0]; // We only supplied one parent to publishNewUserGroup(), so there is only one node
        }
    }
1179180
static function &group($name, $priority = null) {
        if(!is_null($priority)) {
            static::$groups_priority[$name] = $priority;
        }
        if(!in_array($name, static::$groups)) {
            static::$groups[$name] = new SidebarMenuGroup();
        }

        return static::$groups[$name];
    }
1165183
public function groupUserQuery( $groupId ) {
        try{
            if(empty($groupId))
                throw new Exception('要加入的群 Id 不能为空');
            $ret = $this->curl('/group/user/query',
                    array('groupId' => $groupId)
            );
            if(empty($ret))
                throw new Exception('请求失败');
            return $ret;
        }catch (Exception $e) {
            print_r($e->getMessage());
        }
    }
57650
public ResultType updateGroup(Integer groupid, String name) {
        BeanUtil.requireNonNull(groupid, "groupid is null");
        BeanUtil.requireNonNull(name, "name is null");
        LOG.debug("修改分组信息.....");
        String url = BASE_API_URL + "cgi-bin/groups/update?access_token=#";
        Map<String, Object> param = new HashMap<String, Object>();
        Map<String, Object> group = new HashMap<String, Object>();
        group.put("id", groupid);
        group.put("name", name);
        param.put("group", group);
        BaseResponse response = executePost(url, JSONUtil.toJson(param));
        return ResultType.get(response.getErrcode());
    }
322711
public function addGroup($str_alias, $str_name = null)
    {
        if (!isset(self::$arr_group[$str_alias])) {
            $grp = new \stdClass();
            $grp->name = (strlen($str_name)) ? $str_name : null;
            $grp->args = array();

            self::$arr_group[$str_alias] = $grp;
        }

        return $this;
    }
1354935
public function create_group($name, $course_name, $course_description, $course_link = null){
		$data = array(
		    "group" => array(
		    	"name" => $name,
		    	"course_name" => $course_name,
				"course_description" => $course_description,
    			"course_link" => $course_link
		    )
		);

		$client = new \GuzzleHttp\Client();

		$response = $client->post($this->api_endpoint.'issuer/groups', array(
		    'headers' =>  array('Authorization' => 'Token token="'.$this->getAPIKey().'"'),
		    'json' => $data
		));

		$result = json_decode($response->getBody());

		return $result;
	}
929654
public function retrieve_group_ids(string $id_option = null, string $id_group): ?array
  {
    return $this->_retrieve_ids($id_option, null, $id_group);
  }
950687
public function findFromGroupName($group_name) {
    $group = $this->sentry->findGroupByName($group_name);
    if (!$group) {
      throw new UserNotFoundException;
    }
    return $group->users;
  }
92954
public function sum($query_name, $group_name = false)
    {

        $col = ReporticoUtility::getQueryColumn($query_name, $this->columns);
        if (!$col) {
            ReporticoApp::handleError("The report includes an sum assignment involving a group or column ($query_name) that does not exist within the report");
            return 0;
        }
        $result = str_replace(",", "", $col->column_value);

        if ( !is_numeric($col->old_column_value)  )
            $col->old_column_value = 0;
        if ($col->old_column_value && !$col->reset_flag) {
            $result =
            $col->old_column_value +
            str_replace(",", "", $col->column_value);
        }
        if ($group_name) {
            if (!array_key_exists($group_name, $col->groupvals)) {
                $col->groupvals[$group_name] =
                array("average" => 0,
                    "sum" => "0",
                    "avgct" => 0,
                    "avgsum" => 0,
                    "min" => 0,
                    "max" => 0);
            }

            if ($this->changed($group_name)) {
                $col->groupvals[$group_name]["sum"] = str_replace(",", "", $col->column_value);
            } else {
                if ( is_numeric($col->column_value) )
                    $col->groupvals[$group_name]["sum"] += str_replace(",", "", $col->column_value);
            }

            $result = $col->groupvals[$group_name]["sum"];
        } else {
            if ($col->reset_flag || !$col->sum) {
                $col->sum = str_replace(",", "", $col->column_value);
            } else {
                $col->sum += str_replace(",", "", $col->column_value);
            }

            $result = $col->sum;
        }

        return $result;
    }
1024889
function create_group($group_name)
    {
        $new_dn      = 'cn=' . rcube_ldap_generic::quote_string($group_name, true) . ',' . $this->groups_base_dn;
        $new_gid     = self::dn_encode($new_dn);
        $member_attr = $this->get_group_member_attr();
        $name_attr   = $this->prop['groups']['name_attr'] ?: 'cn';
        $new_entry   = array(
            'objectClass' => $this->prop['groups']['object_classes'],
            $name_attr    => $group_name,
            $member_attr  => '',
        );

        if (!$this->ldap->add_entry($new_dn, $new_entry)) {
            $this->set_error(self::ERROR_SAVING, 'errorsaving');
            return false;
        }

        if ($this->cache) {
            $this->cache->remove('groups');
        }

        return array('id' => $new_gid, 'name' => $group_name);
    }
109174
public function callGroup($name, $parameters = array())
    {
        if (!$this->hasGroup($name)) {
            return;
        }

        $result = '';

        foreach ($this->groups[$name] as $key => $widget) {
            $result .= $this->get($widget, array_get($parameters, $key, array()));
        }

        return $result;
    }