} break; case 'view': $type = _PROJECT_OBJ; $id = altSubValue($_POST, 'id'); $target = altSubValue($_POST, 'target', ''); $inline = getRequestVar('inline', FALSE); if (!($id && $type && $target)) { die(t('There are missing arguments. Please inform the administrator of this mistake.')); } $project = Project::getProjectById($id, TRUE); if (!$project) { echo t('The project cannot be found'); } else { echo "<div id='msg_{$target}'></div>"; echo renderProject($project, $target, $inline); } break; case 'add': $target = altSubValue($_POST, 'target'); $type = altSubValue($_POST, 'type'); $org = altSubValue($_GET, 'org'); echo '<h2>' . t('Add new project') . '</h2>'; echo "<div id='msg_{$target}'></div>"; $form = drupal_get_form("vals_soc_project_form", '', $target, $org); renderForm($form, $target); break; case 'save': $type = altSubValue($_POST, 'type', ''); $id = altSubValue($_POST, 'id', ''); $draft = altSubValue($_POST, 'draft', false);
function showOrganisationProjects($org_nr, $projects, $organisation, $show_org_title = TRUE, $show_last = FALSE, $inline = FALSE, $owner_only = FALSE) { $org_id = $organisation->org_id; $nr = 1; $tab_id_prefix = "project_page{$org_nr}-"; $data = array(); $activating_tabs = array(); $nr_projects = count($projects); $current_tab = $show_last && $show_last == $org_id ? $nr_projects + 1 : 1; $current_tab_id = "{$tab_id_prefix}{$current_tab}"; //data is like: [translate, label, action, type, id, extra GET arguments, render with rich text area, render tab to the right] $data[] = array(1, 'All', 'list', _PROJECT_OBJ, null, "org={$org_id}&inline=" . ($inline ? 1 : 0) . "&mine=" . ($owner_only ? 1 : 0)); $activating_tabs[] = "'{$tab_id_prefix}{$nr}'"; $nr++; if ($show_org_title) { echo '<h3>' . tt('Projects in your organisation ') . sprintf('<i>%1$s</i>', $organisation->name) . '</h3>'; } foreach ($projects as $project) { if ($nr == $current_tab) { //$id = $project->pid; $my_project = $project; } $activating_tabs[] = "'{$tab_id_prefix}{$nr}'"; $data[] = array(0, $project->title, 'view', _PROJECT_OBJ, $project->pid); $nr++; } $data[] = array(1, 'Add', 'add', _PROJECT_OBJ, 0, "target={$tab_id_prefix}{$nr}&org={$org_id}", TRUE, 'right'); $activating_tabs[] = "'{$tab_id_prefix}{$nr}'"; //If no target is sent along, the project views are shown inline $current_tab_content = 1 == $current_tab ? renderProjects('', $projects, $current_tab_id, $inline, FALSE, FALSE) : renderProject($my_project, $current_tab_id, false); echo renderTabs($nr, 'Project', $tab_id_prefix, _PROJECT_OBJ, $data, 0, TRUE, $current_tab_content, $current_tab, _PROJECT_OBJ); ?> <script type="text/javascript"> activatetabs('tab_', [<?php echo implode(', ', $activating_tabs); ?> ], '<?php echo $current_tab_id; ?> '); </script> <?php }