123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- <?php
- /**
- * Implements hook_permission().
- */
- function materio_user_permission() {
- return array(
- 'view own user profile' => array(
- 'title' => t('view own user profile'),
- 'description' => t('view own user profile'),
- ),
- );
- }
- /**
- * Implements hook_menu_alter().
- */
- function materio_user_menu_alter(&$items) {
- $items['user/%user']['access callback'] = 'user_access';
- $items['user/%user']['access arguments'] = array('view own user profile');
- }
- /**
- * Implements hook_block_info().
- */
- function materio_user_block_info() {
- $blocks['user_register'] = array(
- 'info' => t('Register block'),
- 'cache' => DRUPAL_NO_CACHE
- );
- $blocks['old_database_link'] = array(
- 'info' => t('Old data base link'),
- 'cache' => DRUPAL_NO_CACHE
- );
- return $blocks;
- }
- /**
- * Implements hook_block_view().
- */
- function materio_user_block_view($delta = '') {
- global $user, $language;
- $block = array();
- switch ($delta) {
- case 'user_register':
- if(isset($user->roles[1])){
- $block['subject'] = t('Create your materiO\' account');//drupal_is_front_page() ? t('Your projects will born from here') : t('Create your materiO\' account');
- $block['content'] = drupal_render(drupal_get_form('user_register_form'));
- }
- break;
- case 'old_database_link':
- if( (isset($user->roles[6]) || isset($user->roles[8])) && $user->created < strtotime('01-12-2012') ){
- // dsm($user, 'user');
- $block['subject'] = '';
-
- $path = 'http://base.materio.com';
-
- if($language->language == 'fr')
- $path .= '/index_fr.html';
- $block['content'] = l(t('Old database'), $path);
- }
-
- break;
- }
- return $block;
- }
- /**
- * Implements hook_form_alter().
- */
- function materio_user_form_alter(&$form, &$form_state, $form_id) {
- // dsm($form_id);
- if($form_id == "user_register_form" ){
- // dsm($form);
- $form['account']['pass']['#type'] = 'password';
- $form['account']['pass']['#title'] = t('Password');
-
- $form['actions']['#type'] = "container";
- $form['actions']['submit']['#value'] = t('Join');
- $form['termsofservices'] = array(
- '#type' => 'checkbox',
- '#title' => t('I accept') .' '. l('the materiO terms of services', 'node/11183'),
- '#required' => true,
- );
- $form['#submit'][] = "materio_user_user_register_form_submit";
- }
- }
- function materio_user_user_register_form_submit($form, &$form_state){
- // dsm($form, 'form');
- // dsm($form_state, 'form_state');
- // dsm($_REQUEST, '$_REQUEST');
- // dsm($_GET, '$_GET');
- unset($_REQUEST['destination'], $_REQUEST['edit']['destination']);
- $form_state['redirect'] = array(
- 'node/11187',
- array(
- 'fragment' => $_GET['q'] == 'node/11187' ? 'content-bottom' : '', // if we register from the membership page, then go directly to the form
- )
- );
-
- // $frontlink = l('continue with basic', '<front>');
- // // drupal_get_messages('status');
- // drupal_set_message(t('Welcome, you just join materiO\'! now you can choose the membership that\'s right for you, or !link', array('!link'=>$frontlink)));
- }
- /**
- * Implements hook_help().
- */
- function materio_user_help($path, $arg) {
- // dsm($path, 'path');
- // dsm($arg, 'arg');
- switch ($path) {
- case 'node/%':
- if($arg[1] == 11187 ){
- global $user;
- // dsm($user, 'user');
-
- if(isset($user->roles[1])){ // anonyme
- $message = t('Please create an account and join materio, then we\'ll provide you the membership form.');
- $content = '<p>' . $message . '</p>';
- return $content;
- }else if(isset($user->roles[2])){ // authentificated user (not utilisateur)
- $content = '<h2>' . t('Welcome, you just joined materiO\' !') . '</h2>';
- $frontlink = l('continue with basic', '<front>');
- $message = t('Now you can choose the membership that\'s right for you, or !link', array('!link'=>$frontlink));
- $content .= '<p>' . $message . '</p>';
- return $content;
- }
- }
- }
- }
|