/** * Return the generated form output. * @param array $args List of parameter values passed through to the form depending on how the form has been configured. * This array always contains a value for language. * @param object $node The Drupal node object. * @param array $response When this form is reloading after saving a submission, contains the response from the service call. * Note this does not apply when redirecting (in this case the details of the saved object are in the $_GET data). * @return Form HTML. */ public static function get_form($args, $node, $response = null) { if (!hostsite_get_user_field('indicia_user_id')) { return 'Please ensure that you\'ve filled in your surname on your user profile before creating or editing groups.'; } self::createBreadcrumb($args); iform_load_helpers(array('report_helper')); report_helper::$website_id = $args['website_id']; $auth = report_helper::get_read_write_auth($args['website_id'], $args['password']); if (empty($_GET['group_id'])) { return 'This form should be called with a group_id parameter'; } $group = self::loadExistingGroup($_GET['group_id'], $auth, $args); hostsite_set_page_title(lang::get('Administer {1}', $group['title'])); report_helper::$javascript .= "indiciaData.website_id={$args['website_id']};\n"; report_helper::$javascript .= "indiciaData.group_id={$group['id']};\n"; report_helper::$javascript .= 'indiciaData.ajaxFormPostUrl="' . iform_ajaxproxy_url(null, 'groups_user') . "\";\n"; if (!empty($args['admin_role_name'])) { $adminRoleOnScreenName = $args['admin_role_name']; } else { $adminRoleOnScreenName = 'administrator'; } if (!empty($args['member_role_name'])) { $memberRoleOnScreenName = $args['member_role_name']; } else { $memberRoleOnScreenName = 'member'; } //Setup actions column $actions = array(array('caption' => 'Approve member', 'javascript' => 'approveMember({groups_user_id});', 'visibility_field' => 'pending')); if ($adminRoleOnScreenName === 'administrator') { $caption = 'Set user to be an ' . $adminRoleOnScreenName; } else { $caption = 'Set user to be a ' . $adminRoleOnScreenName; } //Only allow toggle of user's role if page is configured to allow this. if (isset($args['allow_role_toggle']) && $args['allow_role_toggle'] == true) { $actions[] = array('caption' => $caption, 'javascript' => 'toggleRole({groups_user_id},\'{name}\',\'administrator\');', 'visibility_field' => 'member'); $actions[] = array('caption' => 'Set user to be a ' . $memberRoleOnScreenName, 'javascript' => 'toggleRole({groups_user_id},\'{name}\',\'member\');', 'visibility_field' => 'administrator'); } //Only allow removal of users if page is configured to allow this. if (isset($args['allow_remove']) && $args['allow_remove'] == true) { $actions[] = array('caption' => 'Remove from group', 'javascript' => 'removeMember({groups_user_id},\'{name}\');'); } $r = report_helper::report_grid(array('dataSource' => 'library/groups/group_members', 'readAuth' => $auth['read'], 'extraParams' => array('group_id' => $group['id']), 'columns' => array(array('display' => lang::get('Actions'), 'actions' => $actions)))); return $r; }