本文整理汇总了PHP中Hubzero\User\Group::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Group::getInstance方法的具体用法?PHP Group::getInstance怎么用?PHP Group::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Hubzero\User\Group
的用法示例。
在下文中一共展示了Group::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: up
/**
* Up
**/
public function up()
{
// select all groups with duplicate cname's
$query = "SELECT gidNumber, cn, description\n\t\t\t\t FROM `#__xgroups` WHERE cn IN (\n\t\t\t\t\t SELECT cn FROM `#__xgroups` GROUP BY cn HAVING COUNT(*) > 1\n\t\t\t\t ) ORDER BY gidNumber;";
$this->db->setQuery($query);
$duplicateGroups = $this->db->loadObjectList();
// var to hold original groups
$original = array();
// loop through each group
foreach ($duplicateGroups as $duplicateGroup) {
// make sure to keep the original group
if (!in_array($duplicateGroup->cn, $original)) {
$original[] = $duplicateGroup->cn;
continue;
}
// delete group
// also deletes membership related stuff
$hzGroup = \Hubzero\User\Group::getInstance($duplicateGroup->gidNumber);
$hzGroup->delete();
}
// // Add unique index to cn column
if ($this->db->tableExists('#__xgroups')) {
if (!$this->db->tableHasKey('#__xgroups', 'idx_cn')) {
$query = "ALTER TABLE `#__xgroups` ADD UNIQUE INDEX `idx_cn` (`cn`);";
$this->db->setQuery($query);
$this->db->query();
}
}
}
示例2: up
/**
* Up
**/
public function up()
{
// include com_wishlist files
require_once PATH_CORE . DS . 'components' . DS . 'com_wishlist' . DS . 'models' . DS . 'wishlist.php';
// Load some objects
$wishlist = new \Components\Wishlist\Tables\Wishlist($this->db);
$wish = new \Components\Wishlist\Tables\Wish($this->db);
// Get records
$lists = $wishlist->getRecords(array('category' => 'group'));
// vars to hold counts
$deletedLists = 0;
$deletedWishes = 0;
// check to make sure each group wishlist has a valid group
foreach ($lists as $list) {
// load group
$group = \Hubzero\User\Group::getInstance($list->referenceid);
// if group doesnt exist we need to remove the list and wishes
if (!$group || !is_object($group)) {
// Get wishes
$wishes = $wish->get_wishes($list->id, array('filterby' => 'all', 'sortby' => ''), 1);
// delete each wish
foreach ($wishes as $item) {
$wish->load($item->id);
$wish->delete();
$deletedWishes++;
}
// delete wishlist
$wishlist->load($list->id);
$wishlist->delete();
$deletedLists++;
}
}
}
示例3: __construct
/**
* Constructor - sets output mechanism and arguments for use by command
*
* @param \Hubzero\Console\Output $output The ouput renderer
* @param \Hubzero\Console\Arguments $arguments The command arguments
* @return void
**/
public function __construct(Output $output, Arguments $arguments)
{
parent::__construct($output, $arguments);
// Do we have a group arg?
if ($cname = $this->arguments->getOpt('group')) {
$group = \Hubzero\User\Group::getInstance($cname);
} else {
// Get the current directory
$currentDirectory = getcwd();
// Remove web root
$currentDirectory = str_replace(PATH_APP, '', $currentDirectory);
// Get group upload directory
$groupsConfig = \Component::params('com_groups');
$groupsDirectory = trim($groupsConfig->get('uploadpath', '/site/groups'), DS);
// Are we within the groups upload path
if (strpos($currentDirectory, $groupsDirectory)) {
$gid = str_replace($groupsDirectory, '', $currentDirectory);
$gid = trim($gid, DS);
// Get group instance
$group = \Hubzero\User\Group::getInstance($gid);
}
}
// Make sure we have a group & its super!
if (isset($group) && $group && $group->isSuperGroup()) {
$this->group = $group;
} else {
$this->output->error('Error: Provided group is not valid');
}
}
示例4: execute
/**
* Override Execute Method
*
* @return void
*/
public function execute()
{
//get the cname, active tab, and action for plugins
$this->cn = Request::getVar('cn', '');
$this->active = Request::getVar('active', '');
$this->action = Request::getVar('action', '');
// Check if they're logged in
if (User::isGuest()) {
$this->loginTask(Lang::txt('COM_GROUPS_ERROR_MUST_BE_LOGGED_IN'));
return;
}
//check to make sure we have cname
if (!$this->cn) {
$this->_errorHandler(400, Lang::txt('COM_GROUPS_ERROR_NO_ID'));
}
// Load the group page
$this->group = Group::getInstance($this->cn);
// Ensure we found the group info
if (!$this->group || !$this->group->get('gidNumber')) {
$this->_errorHandler(404, Lang::txt('COM_GROUPS_ERROR_NOT_FOUND'));
}
// Check authorization
if ($this->_authorize() != 'manager' && !$this->_authorizedForTask('group.pages')) {
$this->_errorHandler(403, Lang::txt('COM_GROUPS_ERROR_NOT_AUTH'));
}
//continue with parent execute method
parent::execute();
}
示例5: __construct
/**
* Constructor
*
* @param integer $referenceid Scope ID (group, course, etc.)
* @return void
*/
public function __construct($referenceid = 0)
{
$this->set('referenceid', $referenceid)->set('category', 'group')->set('option', $this->_segments['option']);
$this->_item = \Hubzero\User\Group::getInstance($referenceid);
if (!$this->_item) {
$this->_item = new \Hubzero\User\Group();
}
$this->_segments['cn'] = $this->_item->get('cn');
$this->_segments['active'] = 'wishlist';
}
示例6: __construct
/**
* Constructor
*
* @param integer $scope_id Scope ID (group, course, etc.)
* @return void
*/
public function __construct($scope_id)
{
$group = \Hubzero\User\Group::getInstance($scope_id);
if (!$group) {
$group = new \Hubzero\User\Group();
$group->set('cn', '_unknown_');
}
$this->_segments['cn'] = $group->get('cn');
$this->_segments['active'] = 'forum';
$this->_segments['scope'] = '';
$this->_name = $group->get('cn');
}
示例7: loadLanguage
/**
* Loads the plugin language file
*
* @param string $extension The extension for which a language file should be loaded
* @param string $basePath The basepath to use
* @return boolean True, if the file has successfully loaded.
*/
public function loadLanguage($extension = '', $basePath = PATH_APP)
{
if (empty($extension)) {
$extension = 'plg_' . $this->_type . '_' . $this->_name;
}
$group = \Hubzero\User\Group::getInstance(Request::getCmd('cn'));
if ($group && $group->isSuperGroup()) {
$basePath = PATH_APP . DS . 'site' . DS . 'groups' . DS . $group->get('gidNumber');
}
$lang = \App::get('language');
return $lang->load(strtolower($extension), $basePath, null, false, true) || $lang->load(strtolower($extension), PATH_APP . DS . 'plugins' . DS . $this->_type . DS . $this->_name, null, false, true) || $lang->load(strtolower($extension), PATH_APP . DS . 'plugins' . DS . $this->_type . DS . $this->_name, null, false, true) || $lang->load(strtolower($extension), PATH_CORE . DS . 'plugins' . DS . $this->_type . DS . $this->_name, null, false, true);
}
示例8: execute
/**
* Override Execute Method
*
* @return void
*/
public function execute()
{
// Incoming
$this->gid = Request::getVar('gid', '');
// Ensure we have a group ID
if (!$this->gid) {
App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=manage', false), Lang::txt('COM_GROUPS_MISSING_ID'), 'error');
return;
}
$this->group = Group::getInstance($this->gid);
parent::execute();
}
示例9: listTask
/**
* Display members of a group
*
* @apiMethod GET
* @apiUri /groups/{id}/members/list
* @apiParameter {
* "name": "id",
* "description": "Group identifier",
* "type": "integer",
* "required": true,
* "default": 0
* }
* @apiParameter {
* "name": "list",
* "description": "Comma-separated list of member status",
* "type": "string",
* "required": false,
* "default": "",
* "allowedValues": "members, managers, invitees, applicants"
* }
* @apiParameter {
* "name": "start",
* "description": "Number of where to start returning results.",
* "type": "integer",
* "required": false,
* "default": 0
* }
* @return void
*/
public function listTask()
{
$id = Request::getInt('id', 0);
$group = \Hubzero\User\Group::getInstance($id);
if (!$group) {
throw new Exception(Lang::txt('COM_GROUPS_ERROR_MISSING_RECORD'), 404);
}
// get all group members, managers, etc
$members = $group->get('members');
$managers = $group->get('managers');
$invitees = $group->get('invitees');
$applicants = $group->get('applicants');
// get what the user wants back
$list = Request::getVar('list', 'members, managers, invitees, applicants');
// split by comma
if (is_string($list)) {
$list = explode(',', $list);
$list = array_map('trim', $list);
$list = array_map('strtolower', $list);
}
// var to hold return
$response = array();
// add members
if (in_array('members', $list)) {
foreach ($members as $k => $member) {
$members[$k] = array('uidNumber' => $member);
}
$response['members'] = $members;
}
// add managers
if (in_array('managers', $list)) {
foreach ($managers as $k => $manager) {
$managers[$k] = array('uidNumber' => $manager);
}
$response['managers'] = $managers;
}
// add invitees
if (in_array('invitees', $list)) {
foreach ($invitees as $k => $invitee) {
$invitees[$k] = array('uidNumber' => $invitee);
}
$response['invitees'] = $invitees;
}
// add managers
if (in_array('applicants', $list)) {
foreach ($applicants as $k => $applicant) {
$applicants[$k] = array('uidNumber' => $applicant);
}
$response['applicants'] = $applicants;
}
$this->send($response);
}
示例10: execute
/**
* Override Execute Method
*
* @return void
*/
public function execute()
{
$id = Request::getInt('gidNumber');
// Load the group page
$this->group = Group::getInstance($id);
// Ensure we found the group info
if (!$this->group || !$this->group->get('gidNumber')) {
App::abort(404, Lang::txt('COM_GROUPS_ERROR_NOT_FOUND'));
}
//build path to the group folder
$this->path = PATH_APP . DS . trim($this->config->get('uploadpath', '/site/groups'), DS) . DS . $this->group->get('gidNumber');
//continue with parent execute method
parent::execute();
}
示例11: __construct
/**
* Constructor
*
* @param integer $scope_id Scope ID (group, course, etc.)
* @return void
*/
public function __construct($scope_id = 0)
{
$this->set('scope_id', $scope_id);
$group = \Hubzero\User\Group::getInstance($scope_id);
if (!$group || !$group->get('cn')) {
$group = new \Hubzero\User\Group();
$group->set('gidNumber', $scope_id);
$group->set('cn', $scope_id);
$group->set('description', Lang::txt('(unknown)'));
}
$this->_group = $group;
$this->_segments['cn'] = $group->get('cn');
$this->_segments['active'] = 'collections';
$this->set('option', $this->_segments['option']);
}
示例12: onUserAfterDelete
/**
* Method is called after user data is deleted from the database
*
* @param array $user holds the user data
* @param bool $succes true if user was succesfully stored in the database
* @param string $msg message
*/
public function onUserAfterDelete($user, $succes, $msg)
{
// Check params for group name
$groupAlias = $this->params->get('group', false);
if ($groupAlias) {
// Get the group
$group = \Hubzero\User\Group::getInstance($groupAlias);
if (is_object($group)) {
// Remove the user from the group
$group->remove('members', array($user['id']));
// Update the groups
$group->update();
}
}
}
示例13: __construct
/**
* Constructor
*
* @param integer $scope_id Scope ID (group, course, etc.)
* @return void
*/
public function __construct($scope_id = 0)
{
$this->set('scope_id', $scope_id);
$this->_item = UserGroup::getInstance($scope_id);
if (!$this->_item instanceof UserGroup) {
$this->_item = new UserGroup();
}
$this->_segments['cn'] = $this->_item->get('cn');
$this->_segments['active'] = 'blog';
$groupParams = Component::params('com_groups');
$uploadpath = $groupParams->get('uploadpath', '/site/groups');
$uploadpath = trim($uploadpath, DS) . DS . $this->get('scope_id') . DS . 'uploads' . DS . 'blog';
$this->set('path', $uploadpath);
$this->set('scope', $this->_segments['cn'] . '/blog');
$this->set('option', $this->_segments['option']);
}
示例14: onSearch
/**
* Build search query and add it to the $results
*
* @param object $request \Components\Search\Models\Basic\Request
* @param object &$results \Components\Search\Models\Basic\Result\Set
* @param object $authz \Components\Search\Models\Basic\Authorization
* @return void
*/
public static function onSearch($request, &$results, $authz)
{
$terms = $request->get_term_ar();
$weight = 'match(e.title, e.content) against(\'' . join(' ', $terms['stemmed']) . '\')';
$addtl_where = array();
foreach ($terms['mandatory'] as $mand) {
$addtl_where[] = "(e.title LIKE '%{$mand}%' OR e.content LIKE '%{$mand}%')";
}
foreach ($terms['forbidden'] as $forb) {
$addtl_where[] = "(e.title NOT LIKE '%{$forb}%' AND e.content NOT LIKE '%{$forb}%')";
}
// Commenting out Access check as it was never used and column was removed from table
// during events refactoring
//
// @author Chris Smoak
// @date 4/20/2014
//
// $addtl_where[] = '(e.access IN (' . implode(',', User::getAuthorisedViewLevels()) . '))';
$rows = new \Components\Search\Models\Basic\Result\Sql("SELECT\n\t\t\t\te.title,\n\t\t\t\te.content AS description,\n\t\t\t\te.scope,\n\t\t\t\te.scope_id,\n\t\t\t\tconcat('index.php?option=com_events&task=details&id=', e.id) AS link,\n\t\t\t\t{$weight} AS weight,\n\t\t\t\tpublish_up AS date,\n\t\t\t\t'Events' AS section\n\t\t\tFROM `#__events` e\n\t\t\tWHERE\n\t\t\t\tstate = 1 AND\n\t\t\t\tapproved AND {$weight} > 0" . ($addtl_where ? ' AND ' . join(' AND ', $addtl_where) : '') . " ORDER BY {$weight} DESC");
foreach ($rows->to_associative() as $row) {
if (!$row) {
continue;
}
// check group perms
if ($row->scope == 'group') {
// load group
$group = \Hubzero\User\Group::getInstance($row->scope_id);
// make sure we found one
if (!$group) {
continue;
}
// get group calendar access
$access = \Hubzero\User\Group\Helper::getPluginAccess($group, 'calendar');
// is calendar off
// is calendar for registered users & not logged in
// is calendar for members only and we are not a member
if ($access == 'nobody' || $access == 'registered' && User::isGuest() || $access == 'members' && !in_array(User::get('id'), $group->get('members'))) {
continue;
}
}
$row->set_description(preg_replace('/(\\[+.*?\\]+|\\{+.*?\\}+|[=*])/', '', $row->get_description()));
$results->add($row);
}
}
示例15: onResourcesSub
/**
* Return data on a resource sub view (this will be some form of HTML)
*
* @param object $resource Current resource
* @param string $option Name of the component
* @param integer $miniview View style
* @return array
*/
public function onResourcesSub($resource, $option, $miniview = 0)
{
$arr = array('area' => $this->_name, 'html' => '', 'metadata' => '');
if (!$resource->group_owner || substr($resource->group_owner, 0, strlen('app-')) == 'app-') {
return $arr;
}
$group = \Hubzero\User\Group::getInstance($resource->group_owner);
if (!$group || !$group->get('gidNumber')) {
return $arr;
}
// Pass the view some info
$view = $this->view('default', 'display')->set('option', $option)->set('resource', $resource)->set('params', $this->params)->set('group', $group);
if ($miniview) {
$view->setLayout('mini');
}
// Return the output
$arr['html'] = $view->setErrors($this->getErrors())->loadTemplate();
return $arr;
}