function renderOrganisation($type, $organisation = '', $organisation_owner = '', $target = '', $show_buttons = true) { if (!$organisation) { $organisation = Groups::getGroup($type, '', $organisation_owner); } $key_name = Groups::keyField($type); $id = $organisation->{$key_name}; if ($organisation) { $s = ''; if ($show_buttons && user_access('vals admin register')) { $pPath = request_path(); $edit_action = "onclick='ajaxCall(\"administration\", \"edit\", {type: \"{$type}\", id: {$id}, path: \"{$pPath}\", target: \"{$target}\"}, " . ($type == _STUDENT_GROUP ? "\"{$target}\");'" : "\"formResult\", \"html\", \"{$target}\");'"); $s .= "<div class='totheright'>"; $s .= "\t<input type='button' value='" . t('edit') . "' {$edit_action}/>"; // has the org signup period ended if so user cant add/delete entries, only edit if (vals_soc_access_check("dashboard/{$type}/administer/add_or_delete")) { $delete_action = "onclick='if(confirm(\"" . tt('Are you sure you want to delete this %1$s?', t_type($type)) . "\")){ajaxCall(\"administration\", \"delete\", {type: \"{$type}\", id: {$id}, path: \"{$pPath}\", target: \"{$target}\"}, \"refreshTabs\", \"json\", [\"{$type}\", \"{$target}\", \"administration\"]);}'"; $s .= "\t<input type='button' value='" . t('delete') . "' {$delete_action}/>"; } $s .= "</div>"; //$sub_type_user = ''; } $s .= formatMemberRecordNice($organisation, $type, $target); if ($type == _STUDENT_GROUP) { $s .= "<h2>" . t('Members') . "</h2>"; $students = Users::getStudents($id); $s .= renderStudents('', $students); } return $s; } else { return tt('You have no %1$s registered yet', $type); } }
<?php require_once '../classes/db/Groups.php'; require_once '../classes/Helper.php'; Helper::checkAuthorisation(); if ($_GET) { $groups = new Groups(); switch ($_GET['type']) { case 'id': Helper::checkGetParameter('id'); $group = $groups->getGroup($_GET['id']); echo json_encode($group); break; case 'driver': Helper::checkGetParameter('driver_id'); $response = ['list' => $groups->getGroups($_GET['driver_id'])]; echo json_encode($response); break; case 'all': $response = ['list' => $groups->getAllGroups()]; echo json_encode($response); break; } }
<div class="col-sm-3 col-md-2 sidebar panel" style="margin-bottom:0px;"> <ul class="nav nav-sidebar"> <li><a href="/Views/User/dashboard.php">Overview <span class="sr-only">(current)</span></a></li> <li><a href="/Views/User/profile.php">Profile</a></li> <li><a href="/Views/Friends/manager.php">Friends</a></li> <li class="active"><a href="/Views/Groups/manager.php">Groups</a></li> <li><a href="/Views/Events/manager.php">Events</a></li> </ul> <ul class="nav nav-sidebar"> <li><a href="/Views/Business/manager.php">Buisness</a></li> </ul> </div> <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main"> <?php $results = $groups->getGroup(); // Edit only for admin $adminCheck = $groups->isAdmin(); echo "<script>console.log('isAdmin: " . $adminCheck . "');</script>"; if ($adminCheck) { echo '<div class="row">'; echo '<div class="col-md-12"><a class="btn btn-info btn-raised" style="float: right;" data-toggle="modal" data-dismiss="modal" data-target="#EditG">Edit Group</a></div>'; echo '</div>'; } ?> <div class="row placeholders panel panel-primary" style="margin-top:15px;"> <!-- <div class="" style="margin-bottom:20px;"></div> --> <div class="panel-body"> <div class="col-xs-6 col-sm-3 placeholder" style="margin:40px 0px; border-right: solid 2px gainsboro;"> <?php
// if(isset($_POST['path'])){ // $form['#action'] = url($_POST['path']); // } //unset($_POST); renderForm($form, $target); } break; case 'edit': $type = altSubValue($_POST, 'type', ''); $id = altSubValue($_POST, 'id', ''); $target = altSubValue($_POST, 'target', ''); if (!isValidOrganisationType($type)) { //for convenience we have made a project an organisationtype as well //TODO: make this better echo tt('There is no such type to edit : %1$s', $type); } else { $obj = Groups::getGroup($type, $id); // See http://drupal.stackexchange.com/questions/98592/ajax-processed-not-added-on-a-form-inside-a-custom-callback-my-module-deliver // for additions below $originalPath = false; if (isset($_POST['path'])) { $originalPath = $_POST['path']; } unset($_POST); $form = drupal_get_form("vals_soc_{$type}_form", $obj, $target); if ($originalPath) { $form['#action'] = url($originalPath); } // Process the submit button which uses ajax //$form['submit'] = ajax_pre_render_element($form['submit']); // Build renderable array // $build = array(