Link de invitación único?

Events happening in the community are now at Drupal community events on www.drupal.org.
ssoulless's picture

Aclaración de versión: Drupal 7
Hola estoy desarrollando una comunidad masiva, y uno de los factores claves son las invitaciones....

Estoy tratando de implementar un sistema que me permita generar un link único para cada usuario el cual ellos pueden compartir, y todo aquel que se registre a través de ese link contará como referido de quién le compartió el link, y así hacer un ranking de los usuarios que mas referidos tengan.

Estoy trabajando con el módulo Invite, estoy haciendo un submódulo que se integra con Invite que hace exactamente lo que necesito, y he llegado a esto

El link que debería tener el siguiente formato

http://#misitioweb.com/invite/code/#inviter_id

Donde inviter_id es el id del usuario que comparte el link...

este es el script principal (invite_link.module.php)

<?php

/
* @file
* link de invitacion core, llamado de funciones
*/

/

* Nombres de las seciones.
*/
define('INVITE_LINK_SESSION', 'invite_link_user');

/
* Implementando hook_menu().
*/
function invite_link_menu() {
  $items['invite/code/%'] = array(
    'page callback' => 'invite_link_page',
    'access callback' => TRUE,
    'page arguments' => array(2),
    'type' => MENU_CALLBACK,
  );

  $items['user/%user/invites/link'] = array(
    'title' => 'Link',
    'page callback' => 'invite_link_user_overview',
    'access callback' => 'invite_user_access',
    'access arguments' => array('send invitations', 1),
    'type' => MENU_LOCAL_TASK,
    'weight' => 15,
  );

  return $items;
}

/

* Implementando hook_user().
*/
function invite_link_user($op, &$edit, &$account, $category = NULL) {
  switch ($op) {
    case 'insert':
      if (isset($_SESSION[INVITE_LINK_SESSION])) {
        $code = invite_generate_code();

        $invite = _invite_substitutions(array(
          'inviter' => $_SESSION[INVITE_LINK_SESSION],
          'email' => $account->mail,
          'reg_code'  => $code,
          'code'  => $code,
        ));
        invite_save($invite);
        invite_process($invite, $account);

        unset($_SESSION[INVITE_LINK_SESSION]);
        $_SESSION[INVITE_SESSION] = $code;
      }
      break;

    case 'delete':
      invite_delete($account->uid);
      break;
  }
}

/
* Retorna el link de cada usuario en la pestaña link del módulo invite
*/
function invite_link_user_overview() {
  global $user;

  $links = array();
  $links[] = url('invite/code/' . $user->uid, array('absolute' => TRUE));
  $links[] = url('invite/code/' . $user->name, array('absolute' => TRUE));

  return theme_item_list($links, t('Your links (can be used independently):'));
}

/

* Provee la lógica de la página para saber de quién es el invitado
*/
function invite_link_page($user_info) {
  if (is_numeric($user_info)) {
    $user_info = array('uid' => $user_info);
  }
  else {
    $user_info = array('name' => $user_info);
  }

  $user = user_load($user_info);
  if (!$user) {
    drupal_not_found();
  }

  $_SESSION[INVITE_LINK_SESSION] = $user;
  drupal_goto(variable_get('invite_registration_path', 'user/register'));
}

Básicamente hice una especie de submódulo que se integra con el invite para que genere el link de invitación único para cada usuario, pero el condenado no funciona T_T AYUDENME =(

Si existe otra alternativa mas facil porfavor díganmela que no me quiero matar mas la cabeza con esto....

ADJUNTO EL MÓDULO PARA QUE LO PRUEBEN Y ME AYUDEN A ARREGLARLO.

ESTO LE PUEDE SERVIR A ALGUIEN MÁS, PROMETO QUE LO SUBIRÉ A LA COMUNIDAD DE DRUPAL PARA QUE ALGUIEN MAS LO DESCARGUE.

Gracias de antemano

AttachmentSize
invite_link-7.x-1.x-dev.tar_.gz10 KB

Comments

Invitation module

yujipolo's picture

¿Has probado con Invitation? https://drupal.org/project/

Restricts registration to users who have an invite code (for running a private beta).

The users do not have the invite code can request it by enter email.
The user submit the request form will get a reference URL to invite friends.
Once the user invited 10 friends to submit request, s/he will get the invite code.
The active users has a given number (5) of invite code.
Each invite code only can be used once.
Views provided for admin to see all invite request, invite code status. 

Latin America

Group categories

Latin America

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week