function showOrganisationAdminPage($organisations, $action = 'administer', $show_last = FALSE) { $nr = 0; $data = array(); $tabs = array(); $id = 0; $tab_id_prefix = 'organisation_page-'; $nr_orgs = $organisations->rowCount(); $current_tab = $show_last ? $nr_orgs : 1; $current_tab_content = t('You have no organisation yet.'); foreach ($organisations as $org) { $nr++; if ($nr == $current_tab) { $id = $org->org_id; $my_organisation = $org; $current_tab_content = renderOrganisation(_ORGANISATION_GROUP, $my_organisation, null, "{$tab_id_prefix}{$current_tab}", $action == 'administer'); } $tabs[] = "'{$tab_id_prefix}{$nr}'"; $data[] = array(2, $org->name, 'view', _ORGANISATION_GROUP, $org->org_id); } // check for org admin editing rights if ($action == 'administer' && vals_soc_access_check('dashboard/organisation/administer/add_or_delete')) { //To remove the add tab: comment the three lines below $nr++; $data[] = array(1, 'Add', 'add', _ORGANISATION_GROUP, null, "target={$tab_id_prefix}{$nr}&show_action=administer", true, 'adding_to_the right'); $tabs[] = "'{$tab_id_prefix}{$nr}'"; } echo sprintf('<h3>%1$s</h3>', t('Organisations you are involved in')); if ($nr) { echo renderTabs($nr, 'Org', $tab_id_prefix, _ORGANISATION_GROUP, $data, $id, TRUE, $current_tab_content, $current_tab); ?> <script type="text/javascript"> activatetabs('tab_', [<?php echo implode(',', $tabs); ?> ], '<?php echo "{$tab_id_prefix}{$current_tab}"; ?> '); </script> <?php } else { echo $current_tab_content; } }
showRoleDependentAdminPage(getRole(), $show_action, $show_last); break; case 'view': $type = altSubValue($_POST, 'type'); $id = altSubValue($_POST, 'id'); $target = altSubValue($_POST, 'target', ''); $buttons = altSubValue($_GET, 'buttons', true); if (!($id && $type && $target)) { die(t('There are missing arguments. Please inform the administrator of this mistake.')); } $organisation = Groups::getGroup($type, $id); if (!$organisation) { echo tt('The %1$s cannot be found', t_type($type)); } else { echo "<div id='msg_{$target}'></div>"; echo renderOrganisation($type, $organisation, null, $target, $buttons); } break; case 'delete': $type = altSubValue($_POST, 'type', ''); $id = altSubValue($_POST, 'id', ''); $target = altSubValue($_POST, 'target', ''); //perhaps the type can be derived from the current url (based on http-referrer system var) extract(deriveTypeAndAction(empty($type)), EXTR_OVERWRITE); if (!isValidOrganisationType($type)) { echo jsonBadResult(t('There is no such type we can delete')); } else { $result = Groups::removeGroup($type, $id); echo $result ? jsonGoodResult() : jsonBadResult('', array('target' => $target)); } break;