define('GROUP', $id); if (!group_user_access($id)) { $SESSION->add_error_msg(get_string('canteditdontown', 'group')); redirect('/group/mygroups.php'); } $group_data = group_get_groups_for_editing(array($id)); if (count($group_data) != 1) { throw new GroupNotFoundException(get_string('groupnotfound', 'group', $id)); } $group_data = $group_data[0]; // Fix dates to unix timestamps instead of formatted timestamps. $group_data->editwindowstart = isset($group_data->editwindowstart) ? strtotime($group_data->editwindowstart) : null; $group_data->editwindowend = isset($group_data->editwindowend) ? strtotime($group_data->editwindowend) : null; } else { define('TITLE', get_string('creategroup', 'group')); if (!group_can_create_groups()) { throw new AccessDeniedException(get_string('accessdenied', 'error')); } $group_data = (object) array('id' => null, 'name' => null, 'description' => null, 'grouptype' => 'standard', 'open' => 1, 'controlled' => 0, 'category' => 0, 'public' => 0, 'usersautoadded' => 0, 'viewnotify' => GROUP_ROLES_ALL, 'submittableto' => 0, 'allowarchives' => 0, 'editroles' => 'all', 'hidden' => 0, 'hidemembers' => 0, 'hidemembersfrommembers' => 0, 'groupparticipationreports' => 0, 'invitefriends' => 0, 'suggestfriends' => 0, 'urlid' => null, 'editwindowstart' => null, 'editwindowend' => null, 'sendnow' => 0, 'feedbacknotify' => GROUP_ROLES_ALL); } $form = array('name' => 'editgroup', 'plugintype' => 'core', 'pluginname' => 'groups', 'elements' => array('name' => array('type' => 'text', 'title' => get_string('groupname', 'group'), 'rules' => array('required' => true, 'maxlength' => 128), 'defaultvalue' => $group_data->name), 'description' => array('type' => 'wysiwyg', 'title' => get_string('groupdescription', 'group'), 'rules' => array('maxlength' => 65536), 'rows' => 10, 'cols' => 55, 'defaultvalue' => $group_data->description), 'urlid' => array('type' => 'text', 'title' => get_string('groupurl', 'group'), 'prehtml' => '<span class="description">' . get_config('wwwroot') . get_config('cleanurlgroupdefault') . '/</span> ', 'description' => get_string('groupurldescription', 'group') . ' ' . get_string('cleanurlallowedcharacters'), 'rules' => array('maxlength' => 30, 'regex' => get_config('cleanurlvalidate')), 'defaultvalue' => $group_data->urlid, 'ignore' => !$id || !get_config('cleanurls')), 'settings' => array('type' => 'fieldset', 'collapsible' => true, 'collapsed' => false, 'class' => 'sectioned last', 'legend' => get_string('settings'), 'elements' => array()), 'submit' => array('type' => 'submitcancel', 'class' => 'btn-primary', 'value' => array(get_string('savegroup', 'group'), get_string('cancel')), 'goto' => get_config('wwwroot') . 'group/mygroups.php'))); $elements = array(); $elements['membership'] = array('type' => 'html', 'value' => '<h4>' . get_string('Membership', 'group') . '</h4>'); $cancreatecontrolled = $USER->get('admin') || $USER->get('staff') || $USER->is_institutional_admin() || $USER->is_institutional_staff(); $elements['open'] = array('type' => 'switchbox', 'title' => get_string('Open', 'group'), 'description' => get_string('opendescription', 'group'), 'defaultvalue' => $group_data->open, 'disabled' => !$cancreatecontrolled && $group_data->controlled); if ($cancreatecontrolled || $group_data->controlled) { $elements['controlled'] = array('type' => 'switchbox', 'title' => get_string('Controlled', 'group'), 'description' => get_string('controlleddescription', 'group'), 'defaultvalue' => $group_data->controlled, 'disabled' => !$cancreatecontrolled); } else { $form['elements']['controlled'] = array('type' => 'hidden', 'value' => $group_data->controlled); } $elements['request'] = array('type' => 'switchbox', 'title' => get_string('request', 'group'), 'description' => get_string('requestdescription', 'group'), 'defaultvalue' => !$group_data->open && $group_data->request, 'disabled' => $group_data->open);
$filter = param_alpha('filter', 'all'); $offset = param_integer('offset', 'all'); $groupcategory = param_variable('groupcategory', 0); $groupsperpage = 20; $offset = (int) ($offset / $groupsperpage) * $groupsperpage; $results = group_get_associated_groups($USER->get('id'), $filter, $groupsperpage, $offset, $groupcategory); $elements = array(); $elements['options'] = array('type' => 'select', 'options' => array('all' => get_string('allmygroups', 'group'), 'admin' => get_string('groupsiown', 'group'), 'member' => get_string('groupsimin', 'group'), 'invite' => get_string('groupsiminvitedto', 'group'), 'request' => get_string('groupsiwanttojoin', 'group')), 'defaultvalue' => $filter); if (get_config('allowgroupcategories') && ($groupcategories = get_records_menu('group_category', '', '', 'displayorder', 'id,title'))) { $options[0] = get_string('allcategories', 'group'); $options[-1] = get_string('categoryunassigned', 'group'); $options += $groupcategories; $elements['groupcategory'] = array('type' => 'select', 'options' => $options, 'defaultvalue' => $groupcategory, 'help' => true); } $elements['submit'] = array('type' => 'submit', 'value' => get_string('filter')); $form = pieform(array('name' => 'filter', 'method' => 'post', 'renderer' => 'oneline', 'elements' => $elements)); $pagination = build_pagination(array('url' => get_config('wwwroot') . 'group/mygroups.php?filter=' . $filter, 'count' => $results['count'], 'limit' => $groupsperpage, 'offset' => $offset, 'resultcounttextsingular' => get_string('group', 'group'), 'resultcounttextplural' => get_string('groups', 'group'))); group_prepare_usergroups_for_display($results['groups'], 'mygroups'); $smarty = smarty(); $smarty->assign('groups', $results['groups']); $smarty->assign('cancreate', group_can_create_groups()); $smarty->assign('form', $form); $smarty->assign('filter', $filter); $smarty->assign('pagination', $pagination['html']); $smarty->assign('searchingforgroups', array('<a href="' . get_config('wwwroot') . 'group/find.php">', '</a>')); $smarty->assign('PAGEHEADING', TITLE); $smarty->display('group/mygroups.tpl'); function filter_submit(Pieform $form, $values) { redirect('/group/mygroups.php?filter=' . $values['options'] . (!empty($values['groupcategory']) ? '&groupcategory=' . intval($values['groupcategory']) : '')); }