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++; } } } }