break; default: //echo tt('No such type: %1$s', $type); showError(tt('No such type: %1$s', $type)); } break; case 'add': $target = altSubValue($_POST, 'target'); $type = altSubValue($_POST, 'type'); $show_action = getRequestVar('show_action', 'administer'); //altSubValue($_GET, 'show_action', 'administer'); echo '<h2>' . ($type == _STUDENT_GROUP ? t('Add a group to your list of student groups') : tt('Add your %1$s', t_type($type))) . '</h2>'; $form = drupal_get_form("vals_soc_{$type}_form", null, $target, $show_action); //TODO Should this stay? $form['#action'] = url('dashboard/administer/members'); // Process the submit button which uses ajax $form['submit'] = ajax_pre_render_element($form['submit']); // Build renderable array // $build = array( // 'form' => $form, // '#attached' => $form['submit']['#attached'], // This will attach all needed JS behaviors onto the page // ); // Print $form renderForm($form, $target); // print drupal_render($form); // print valssoc_form_get_js($form);// Print JS //print drupal_get_js(); break; case 'showmembers': if ($_POST['type'] == _STUDENT_GROUP) { echo renderUsers(_STUDENT_TYPE, '', $_POST['id'], $_POST['type']); } elseif ($_POST['type'] == _INSTITUTE_GROUP) {
function showProjectPage($show_last = FALSE, $owner_only = false) { global $base_url; //TODO check for the role of current user $role = getRole(); if (!Users::isMentor()) { //true for both mentors and organisation admins. Also, they will see their own stuff only echo t('You are not allowed to see the projects in this view.'); return; } //Get my groups $my_organisations = Groups::getGroups(_ORGANISATION_GROUP); if (!$my_organisations->rowCount()) { //There are no organisations yet for this user if ($role == _ORGADMIN_TYPE) { echo t('You have no organisation yet.') . '<br/>'; echo "<a href='" . _WEB_URL . "/dashboard/organisation/administer'>" . t('Please go to the organisation register page') . "</a>"; } else { echo t('You are not connected to any organisation yet.') . '<br/>'; echo "<a href='" . _WEB_URL . "/user/" . Users::getMyId() . "/edit'>" . t('Please edit your account to connect') . "</a>"; } } else { $show_all = !(bool) $owner_only; $owner_id = $GLOBALS['user']->uid; $orgs = array(); $orgids = array(); foreach ($my_organisations as $org) { $orgs[] = $org; $orgids[] = $org->org_id; } $projects = Project::getProjectsByUser($owner_id, $orgids, $show_all); //$my_organisations->fetchCol()); if (!$projects) { echo $owner_only ? t('You have no project yet registered') : t('There are no projects yet registered.'); echo $owner_only ? "<BR>" . '<a href="' . $base_url . '/dashboard/projects/administer" ' . 'title="Manage all my organisation\'s projects">Manage all my organisation\'s projects</a>' : ''; echo '<h2>' . t('Add a project') . '</h2>'; $tab_prefix = 'project_page-'; $target = "{$tab_prefix}1"; $form = drupal_get_form("vals_soc_project_form", '', 'project_page-1'); $form['submit'] = ajax_pre_render_element($form['submit']); $add_tab = renderForm($form, $target, true); $data = array(); $data[] = array(1, 'Add', 'add', _PROJECT_OBJ, '0', "target=admin_container", true, 'adding from the right'); echo renderTabs(1, null, 'project_page-', _PROJECT_OBJ, $data, null, TRUE, $add_tab, 1, _PROJECT_OBJ); ?> <script type="text/javascript"> transform_into_rte(); activatetabs('tab_', ['project_page-1']); </script><?php } else { echo "<a href='" . _WEB_URL . "/dashboard/projects/administer'>" . t('Show all') . "</a>"; echo " | "; echo "<a href='" . _WEB_URL . "/dashboard/projects/administer/mine'>" . t('Show only mine') . "</a>"; $org = 1; $show_org_title = $my_organisations->rowCount() > 1; $org_key = AbstractEntity::keyField(_ORGANISATION_GROUP); foreach ($orgs as $organisation) { $projects = Project::getProjectsByUser($owner_id, array($organisation->{$org_key}), $show_all); showOrganisationProjects($org, $projects, $organisation, $show_org_title, $show_last, TRUE, $owner_only); $org++; } } } }