t('Origo@ETH badge & text'), ); return $blocks; case 'configure': return array(); case 'save': return; case 'view': default: switch ($delta) { case 0: default: $block['content'] = origo_eth_block_content(); break; } return $block; } } /** * Function to render the content of Origo @ ETH's block * @return unknown_type */ function origo_eth_block_content() { $output = ''; $eth_link = 'http://origo.ethz.ch'; $img = $base_path . drupal_get_path('theme', 'oxymoron') .'/origo_button_1.png'; $output .= l('Hosted on ', $eth_link, array('absolute' => TRUE)) .'
'; $output .= 'Hosted on Origo
'; $output .= l('a project by ETH Zürich', $eth_link) .'
'; $output .= '©'. l(' 2006 - 2010', $eth_link) .'
'; $output .= l('Terms of Use', 'global/terms_of_use') .'
'; return $output; } /** * Implementation of hook_form_id_alter(). */ function origo_eth_form_origo_home_create_project_form_alter(&$form, &$form_state) { // Advertising title for Git Repos $form['rcs_type']['#options'][ORIGO_REPO_GIT] = t('Git') .' ('. t('only available on ') . l('oriact.com', 'http://www.oriact.com') . ')'; $form['rcs_type']['#post_render'] = array('origo_eth_process_repo_type'); // Advertising title for Private Projects $form['type']['#options'][ORIGO_PRIVATE_PROJECT] = t('Private Project') .' ('. t('only available on ') . l('oriact.com', 'http://www.oriact.com') . ')'; $form['type']['#post_render'] = array('origo_eth_process_project_type'); } /** * Implementation of hook_form_id_alter(). * This is the form shown to an administrator upon creating a project (or fulfilling a project request). */ function origo_eth_form_origo_admin_create_project_form_alter(&$form, &$form_state) { // Advertising title for Git Repos $form['rcs_type']['#options'][ORIGO_REPO_GIT] = t('Git') .' ('. t('only available on ') . l('oriact.com', 'http://www.oriact.com') . ')'; $form['rcs_type']['#post_render'] = array('origo_eth_process_repo_type'); // Advertising title for Private Projects $form['type']['#options'][ORIGO_PRIVATE_PROJECT] = t('Private Project') .' ('. t('only available on ') . l('oriact.com', 'http://www.oriact.com') . ')'; $form['type']['#post_render'] = array('origo_eth_process_project_type'); } /** * Implementation of hook_form_id_alter(). * Alter Origo's form for changing a project. */ function origo_eth_form_origo_admin_change_project_type_form_alter(&$form, &$form_state) { $project_id = $form_state['storage']['project_id']; if (isset($project_id) && $project_id > 0) { // Add option to change RCS type $form['options']['rcs_type']['#options'][ORIGO_REPO_GIT] = t('Git') .' ('. t('only available on ') . l('oriact.com', 'http://www.oriact.com') . ')'; $form['options']['rcs_type']['#post_render'] = array('origo_eth_process_repo_type'); // Add option for private projects $form['options']['type']['#options'][ORIGO_PRIVATE_PROJECT] = t('Private Project') .' ('. t('only available on ') . l('oriact.com', 'http://www.oriact.com') . ')'; $form['options']['type']['#post_render'] = array('origo_eth_process_project_type'); } } function origo_eth_form_origo_home_project_user_add_form_alter(&$form, &$form_state) { $form['type']['#options'][ORIGO_ACCESS_GROUP_CLIENT] = t('Client') .' ('. t('only available on ') . l('oriact.com', 'http://www.oriact.com') . ')'; $form['type']['#post_render'] = array('origo_eth_process_user_type'); } /** * Helper function to disable the "GIT" radio button. * * @param string $content The already rendered HTML code. * @param array $element The form element as defined for Drupal. */ function origo_eth_process_repo_type($content, $element) { return disable_radio_button($content, ORIGO_REPO_GIT); } /** * Helper function to disable the "Private Project" radio button. * * @param string $content The already rendered HTML code. * @param array $element The form element as defined for Drupal. */ function origo_eth_process_project_type($content, $element) { return disable_radio_button($content, ORIGO_PRIVATE_PROJECT); } /** * Helper function to disable the "Client" user role. * * @param string $content The already rendered HTML code. * @param array $element The form element as defined for Drupal. */ function origo_eth_process_user_type($content, $element) { return disable_radio_button($content, ORIGO_ACCESS_GROUP_CLIENT); } /** * Helper function for disabling a generic radio button. * * @param string $content The already rendered HTML code. * @param array $element The form element as defined for Drupal. */ function disable_radio_button($content, $needle) { // Drupal 6 doesn't allow to disable a single radio-button, thus we have to do this after rendering. $needle = 'value="'. $needle .'"'; return str_replace($needle, $needle . ' disabled=true ', $content); } /** * Implementation of custom hook origo_home_repository_links(). */ function origo_eth_origo_home_repository_links(&$repositories) { $repositories['Git'] = array ( 'description' => 'Git repositories for Origo are only available on '. l('oriact.com', 'http://www.oriact.com'), ); return $repositories; }