<th style="border-right: medium none;" class="Column05"><?php 
print t("Delete");
?>
</th>
  </tr>
<?php 
$page = $_GET["page"];
//print "page : ".$page."<br/>";
$items_per_page = 15;
$page_total = ceil(count($list_invited) / $items_per_page);
for ($i = 0; $i < $items_per_page; $i++) {
    $value = $list_invited[$items_per_page * $page + $i];
    if ($value) {
        $list_item = array();
        if ($value->joined != 0) {
            $invitee = CUserManager::instance()->User($value->invitee);
            $list_item["name"] = $value->email;
            $list_item["status"] = 1;
            $list_item["remind"] = "-";
            $list_item["delete"] = "-";
        } else {
            $list_item["name"] = $value->email;
            $list_item["status"] = 0;
            $img = '<img alt="" src="sites/all/themes/poker/images/icon_buttonred.gif"/>';
            $list_item["remind"] = "<a href='javascript:void(0);' onclick=\"javascript:os_poker_submit(this, 'invite-action-remind-form-{$i}');\">{$img}</a>";
            $list_item["delete"] = "<a href='javascript:void(0);' onclick=\"javascript:os_poker_submit(this, 'invite-action-delete-form-{$i}');\">{$img}</a>";
        }
        $list_item["date"] = date("d.m.y", $value->created);
        ?>
		<tr>	
			<td class=<?php 
Пример #2
0
 public static function GiveItem($item_id, $targets, $debug = FALSE)
 {
     require_once drupal_get_path('module', 'os_poker') . "/scheduler.class.php";
     require_once drupal_get_path('module', 'os_poker') . "/user.class.php";
     $user = CUserManager::instance()->CurrentUser();
     try {
         if (!is_array($targets) || count($targets) == 0) {
             throw new Exception(t('Bad parameter: !cause', array('!cause' => is_array($targets) ? t('$target is empty') : t('$targer is not an array'))));
         }
         $rawTargets = CUserManager::instance()->UserList($targets);
         $targets = array_filter($rawTargets, "_os_poker_user_accepts_gifts");
         $ntargets = count($targets);
         if ($ntargets == 0) {
             throw new Exception(t('No one of targets accepts gifts'));
         }
         $item = new CItem($item_id);
         //check if the item really exists
         /*
          ** User must pay !
          */
         $nchips = $user->Chips();
         $price = $item->price * $ntargets;
         if (bccomp($nchips, $price) < 0) {
             throw new Exception(t('User doesn\'t have enough money (!uc vs !cn needed).', array('!uc' => $nchips, '!cn' => $price)));
         }
         $sql = "INSERT INTO `{poker_operation}`\n\t\t\t\t   (`id_item`, `uid`, `source_uid`, `tstamp`)\n\t\t\t\t   VALUES ";
         foreach ($targets as $target) {
             $fields[] = "(%d, %d, %d, %s)";
             $values[] = $item->id_item;
             $values[] = $target->uid;
             $values[] = $user->uid;
             $values[] = "NOW()";
         }
         $sql .= implode(", ", $fields);
         $res = db_query($sql, $values);
         if ($res == FALSE) {
             throw new Exception(t('DB error : !message', array("!message" => db_error())));
         }
         /*
          ** Expiry
          */
         $operation_id = db_last_insert_id("{poker_operation}", "id_operation");
         $ttl = $item->ttl;
         if ($operation_id && !empty($ttl)) {
             //$operation_id -= (count($targets) - 1);
             foreach ($targets as $target) {
                 $gift = array('item' => $item->name, 'receiver' => $target->uid, 'sender' => $user->uid);
                 if ($target->ActiveItem() <= 0) {
                     $target->ActivateItem($operation_id, $gift);
                 } else {
                     //Send gift notification, even if the item is not activated
                     foreach ($target->Tables() as $table) {
                         foreach (CPoker::UsersAtTable($table->serial) as $notified_uid) {
                             CScheduler::instance()->RegisterTask(new CGiftNotificationMessage(), $notified_uid, array('live'), "-1 day", $gift);
                         }
                     }
                 }
                 CScheduler::instance()->RegisterTask(new CItemExpiry(), $target->uid, 'live', $ttl, array("id_operation" => $operation_id));
                 ++$operation_id;
                 $args["symbol"] = $item->picture;
                 $args["text"] = t("You just receive a !gift from !user", array("!gift" => substr($item->name, 0, 30), "!user" => $user->profile_nickname));
                 if (_os_poker_user_accepts_gifts($user)) {
                     $args["links"] = l(t("Send a gift in return"), "poker/shop/shop/1/buddy/" . $user->uid);
                 }
                 CMessageSpool::instance()->SendMessage($target->uid, $args);
             }
         }
         /*
          ** User must pay !
          */
         $user->SubChips($price);
         $user->Save();
     } catch (Exception $e) {
         if ($debug == TRUE) {
             throw $e;
         }
         return FALSE;
     }
     return TRUE;
 }
Пример #3
0
 public function ProcessLiveEvents()
 {
     static $sql = "SELECT *, (moment <= NOW()) AS active FROM {poker_scheduler} WHERE uid IN (SELECT uid FROM {polling_users}) AND uid IN (SELECT uid FROM {poker_user_ext} WHERE dirty_flags) AND (`moment` <= NOW() OR `visible` = 1) AND (`trigger` like '%\"live\"%' OR (`trigger` like '%\"inbox\"%' AND NOT is_read)) ORDER BY moment ASC";
     //Gather all pending live events and unread ibox messages tasks
     $results = db_query($sql);
     $tasks = array();
     while ($task = db_fetch_object($results)) {
         $triggers = json_decode($task->trigger);
         if (is_array($triggers)) {
             $task->trigger = $triggers;
             foreach ($triggers as $trigger) {
                 $tasks[$task->uid][$trigger][$task->id_task] = $task;
             }
         }
     }
     //Process all tasks for each user
     foreach ($tasks as $uid => $user_tasks) {
         $this->ClearNewTask($uid);
         $user = CUserManager::instance()->User($uid, TRUE);
         //Trigger 'live' and 'inbox'
         $this->TriggerHelper('live', $user, $user_tasks);
         $this->TriggerHelper('inbox', $user, $user_tasks);
         //Check for unread inbox messages
         $mboxsize = count($user_tasks['inbox']);
         if ($mboxsize) {
             //Add messages if there is unread messages
             CMessageSpool::instance()->PushMsg($user, array("type" => "os_poker_messagebox", "body" => array("inbox" => $mboxsize, "picture" => $base_path . drupal_get_path('module', 'os_poker') . "/images/mailbox.png")));
         }
     }
 }
Пример #4
0
 public static function CheckRewards($action, $source, $targets)
 {
     $player = CUserManager::instance()->User($source);
     if ($player) {
         $rew = $player->Rewards();
         switch ($action) {
             case "invite":
                 $invites = $player->Invites();
                 if (count($invites["accepted"]) >= 50) {
                     CPoker::GiveReward("reward63", $player, $rew);
                 }
                 if (count($invites["accepted"]) >= 25) {
                     CPoker::GiveReward("reward52", $player, $rew);
                 }
                 if (count($invites["accepted"]) >= 5) {
                     CPoker::GiveReward("reward37", $player, $rew);
                 }
                 if (count($invites["accepted"]) >= 2) {
                     CPoker::GiveReward("reward17", $player, $rew);
                 }
                 break;
             case "buddy":
                 $buddies = $player->Buddies(FALSE, TRUE);
                 if (count($buddies) >= 100) {
                     CPoker::GiveReward("reward62", $player, $rew);
                 }
                 if (count($buddies) >= 50) {
                     CPoker::GiveReward("reward51", $player, $rew);
                 }
                 if (count($buddies) >= 10) {
                     CPoker::GiveReward("reward36", $player, $rew);
                 }
                 if (count($buddies) >= 5) {
                     CPoker::GiveReward("reward16", $player, $rew);
                 }
                 break;
             case "sit":
                 $buddies = $player->Buddies();
                 CPoker::GiveReward("reward1", $player, $rew);
                 if ($rew["reward18"]["value"] == 0) {
                     foreach ($buddies as $buddy) {
                         if (in_array($buddy, $targets)) {
                             CPoker::GiveReward("reward18", $player, $rew);
                         }
                     }
                 }
                 break;
             case "chips":
                 $chips = $player->Chips();
                 if (bccomp($chips, "1000000") >= 0 || bccomp($targets['chips'], "1000000") >= 0) {
                     CPoker::GiveReward("reward40", $player, $rew);
                 }
                 break;
             default:
                 break;
         }
         /* global check at each CheckRewards for Strike! */
         $all_rewards = CPoker::GetRewards();
         if ($player->GetNumRewards() == count($all_rewards) - 1) {
             CPoker::GiveReward("reward57", $player, $rew);
         }
     }
 }
Пример #5
0
 public function Run($context_user, $arguments)
 {
     list($tourney_serial, $tourney_name, $table_serial) = $arguments;
     //force reload of current user to ensure chips count is updated.
     $context_user = CUserManager::instance()->User($context_user->uid, true);
     $msg = array('type' => 'os_poker_tourney_start', 'body' => array('tourney_id' => $tourney_serial, 'tourney_name' => $tourney_name, 'table_id' => $table_serial));
     parent::Run($context_user, $msg);
 }
Пример #6
0
function os_poker_shop_page($tab, $category = NULL, $target_type = NULL, $target_id = NULL, $subtarget_id = NULL)
{
    $content = "";
    if ($tab == NULL || $tab == "shop") {
        require_once drupal_get_path('module', 'os_poker') . "/user.class.php";
        require_once drupal_get_path('module', 'os_poker') . "/shop.class.php";
        require_once drupal_get_path('module', 'os_poker') . "/poker.class.php";
        $subtarget = NULL;
        $buddies = NULL;
        $cats = CShop::ListCategories();
        if ($target_type == NULL) {
            $target_type = "self";
        }
        if ($category == NULL) {
            $vcats = array_keys($cats);
            if (count($vcats) > 0) {
                $category = $vcats[0];
            }
        }
        $prods = CShop::ListItems($category);
        if (isset($_GET["list"]) && $_GET["list"] == "items" && !empty($_GET["ajax"])) {
            return print theme('os_poker_item_list', $prods);
        }
        $current_user = CUserManager::instance()->CurrentUser();
        $buddies = array_filter($current_user->Buddies(TRUE), "_os_poker_user_accepts_gifts");
        switch ($target_type) {
            case "table":
                $target = array_filter(CPoker::UsersAtTable($target_id, TRUE), "_os_poker_user_accepts_gifts");
                if ($subtarget_id) {
                    $subtarget = CUserManager::instance()->User($subtarget_id);
                }
                $merge = array_merge(array(), $target, $buddies);
                $special = array();
                foreach ($merge as $u) {
                    $special[$u->uid] = $u->uid;
                }
                $special = array_unique(array_keys($special));
                break;
            case "buddy":
                $target = $buddies;
                $subtarget = CUserManager::instance()->User($target_id);
                break;
            case "self":
                $target = $buddies;
                $subtarget = $current_user;
                break;
        }
        if (!empty($_POST["shop_action"]) && !empty($_POST["shop_item"])) {
            $action = $_POST["shop_action"];
            $success = TRUE;
            switch ($action) {
                case "subtarget":
                    if ($subtarget->uid == $current_user->uid) {
                        $success = CShop::BuyItem($_POST["shop_item"], empty($_POST["shop_item_activate"]) ? FALSE : !!$_POST["shop_item_activate"]);
                        watchdog('os_poker', ' buy: ' . $success);
                    } else {
                        $success = CShop::GiveItem($_POST["shop_item"], array($subtarget));
                        watchdog('os_poker', ' giveItem: ' . $success);
                    }
                    break;
                case "target":
                    $success = CShop::GiveItem($_POST["shop_item"], $target);
                    watchdog('os_poker', ' target: ' . $success);
                    break;
                case "special":
                    $success = CShop::GiveItem($_POST["shop_item"], $special);
                    watchdog('os_poker', ' spezial: ' . $success);
                    break;
            }
            if ($success == FALSE) {
                $error = theme('poker_error_message', "<h1>" . t("Sorry !") . "</h1>" . t("You don't have enough Chips."));
            } else {
                if ($target_type == 'table') {
                    watchdog('os_poker', ' goto');
                    drupal_goto('poker/closebox');
                }
            }
        }
        $params = array("categories" => $cats, "current_category" => $category, "items" => $prods, "current_user" => $current_user, "target_type" => $target_type, "target" => $target, "subtarget" => $subtarget, "target_id" => $target_id, "subtarget_id" => $subtarget_id, "buddies" => $buddies, "special" => $special, "error" => $error);
        $content = theme('os_poker_shop', $params);
    } else {
        if ($tab == "get_chips") {
            $content = theme('os_poker_shop_get_chips', drupal_get_form('chips_paypal_form'), $params);
        }
    }
    return theme('os_poker_shop_tabs', $tab, $content);
}
Пример #7
0
 public function SendInstantMessage($args, $targetUid = NULL)
 {
     $current_user = CUserManager::instance()->CurrentUser();
     if ($current_user && $current_user->uid != 0 || $targetUid) {
         if (isset($args["text"])) {
             if ($targetUid == NULL) {
                 $targetUid = $current_user->uid;
             }
             CScheduler::instance()->RegisterTask(new CMessage(), $targetUid, array('live'), "-1 day", array('type' => 'os_poker_imsg', 'body' => array('text' => $args['text'], 'title' => isset($args['title']) ? $args['title'] : t('Notification'))));
         }
     }
 }
Пример #8
0
function os_poker_online_users($return_hash = FALSE, $refresh = FALSE)
{
    static $user_hash;
    if (!$refresh && is_array($user_hash)) {
        return $return_hash ? $user_hash : count($user_hash);
    }
    // FROM modules/user.module, user_block (3)
    // Count users active within the defined period.
    $interval = time() - variable_get('user_block_seconds_online', 900);
    // Perform database queries to gather online user lists.  We use s.timestamp
    // rather than u.access because it is much faster.
    $anonymous_count = sess_count($interval);
    $authenticated_users = db_query('SELECT DISTINCT u.uid, u.name, s.timestamp FROM {users} u INNER JOIN {sessions} s ON u.uid = s.uid WHERE s.timestamp >= %d AND s.uid > 0 ORDER BY s.timestamp DESC', $interval);
    $authenticated_count = 0;
    $items = array();
    $user_hash = array();
    while ($account = db_fetch_object($authenticated_users)) {
        $user_hash[$account->uid] = 'drupal';
        $authenticated_count++;
    }
    // We also check the users playing at table, since the drupal time out and jpoker timeout are different
    $players = CPoker::PlayingUsers();
    foreach ($players as $player_uid) {
        if (!isset($user_hash[$player_uid])) {
            $user_hash[$player_uid] = 'table';
            $authenticated_count++;
        }
    }
    // If the current user just logged in, he may not have a session entry. Check manually
    $current_user = CUserManager::instance()->CurrentUser();
    if (!empty($current_user->uid) && !isset($user_hash[$current_user->uid])) {
        $user_has[$current_user->uid] = 'self';
        $authenticated_count++;
    }
    if ($return_hash) {
        return $user_hash;
    }
    return $authenticated_count;
}
Пример #9
0
function _os_poker_process_message_unsafe()
{
    static $poker_server_events = array('NONE', 'HAND', 'TOURNEY', 'BUY_IN', 'REFILL', 'PRIZE', 'REGISTER', 'UNREGISTER', 'LEAVE', 'SEAT', 'TOURNEY_START');
    $current_user = CUserManager::instance()->CurrentUser();
    $resp = array("errorMsg" => NULL, "error" => FALSE, "messages" => array());
    $message_type = trim(isset($_GET["type"]) ? trim($_GET["type"]) : "noop");
    if ($message_type == "os_poker_reward") {
        /* Reward message is a special message which comes without a current user context 
        		   args[0] = reward number
        		   args[1] = player serial
        		   args[2] = time_stamp
        		*/
        $all_rewards = CPoker::GetRewards();
        $params = json_decode($_GET['args'], TRUE);
        CPoker::ShowReward("reward" . $params[0], $params[1], $all_rewards);
        $resp["messages"][] = array("type" => "noop", "body" => NULL);
    }
    if ($current_user && $current_user->uid != 0) {
        switch ($message_type) {
            case "os_poker_sit_down":
                CPoker::CheckRewards("sit", $current_user->uid, json_decode($_GET["players"], TRUE));
                $resp["messages"][] = array("type" => "noop", "body" => NULL);
                break;
            case "os_poker_daily_gift":
                if ($current_user->DailyGift()) {
                    $resp["messages"][] = array('type' => 'os_poker_gift_sent', 'body' => array('text' => t('You have sent !amount free chips to !count buddies', array('!count' => count($current_user->Buddies()), '!amount' => 100))));
                } else {
                    $resp["messages"][] = array("type" => "noop", "body" => NULL);
                }
                break;
            case "os_poker_load_messagebox":
                CScheduler::instance()->Trigger("inbox");
                $mbox = CScheduler::instance()->GetUnreadTasks("inbox");
                $mboxsize = count($mbox);
                if ($_GET["msgcount"] != $mboxsize) {
                    $resp["messages"][] = array("type" => "os_poker_messagebox", "body" => array("inbox" => $mboxsize, "picture" => $base_path . drupal_get_path('module', 'os_poker') . "/images/mailbox.png"));
                } else {
                    $resp["messages"][] = array("type" => "noop", "body" => NULL);
                }
                break;
            case "os_poker_challenge_user":
                //TODO: limit challenge to 1 per sender/receiver
                if (isset($_GET["challengetarget"])) {
                    $target_user = CUserManager::instance()->User($_GET["challengetarget"]);
                    if ($target_user && $target_user->uid != 0 && $current_user->uid != $target_user->uid) {
                        //Wait for symbol, text, link
                        $args["symbol"] = 'chips';
                        $args["text"] = t("You just receive a headsup challenge from !user", array("!user" => $current_user->profile_nickname));
                        $args["links"] = "<a class='noreplace' href='javascript:void(0);' onclick='javascript:parent.os_poker_start_challenge(" . $current_user->uid . ", " . $target_user->uid . ");'>" . t("Accept") . "</a>/<a href='javascript:void(0);' >" . t("Refuse") . "</a>";
                        CMessageSpool::instance()->SendMessage($target_user->uid, $args);
                        $notification = array('text' => t("You just challenged !user", array("!user" => $target_user->profile_nickname ? $target_user->profile_nickname : variable_get('anonymous', t('Anonymous')))), 'title' => t('Challenge'));
                        CMessageSpool::instance()->SendInstantMessage($notification);
                        $resp["messages"][] = array("type" => "os_poker_notify", "body" => $notification);
                    }
                }
                break;
            case "os_poker_activate_item":
                if (isset($_GET["id_item"]) && is_numeric($_GET["id_item"])) {
                    $current_user->ActivateItem($_GET["id_item"]);
                } else {
                    trigger_error(t('Invalid item ID: %item_id', array('%item_id' => isset($_GET["id_item"]) ? $_GET["id_item"] : 'undefined')), E_USER_ERROR);
                }
                break;
            case "os_poker_invite_user":
                if (isset($_GET["target"])) {
                    $target_user = CUserManager::instance()->User($_GET["target"]);
                    if ($target_user && $target_user->uid != 0 && $current_user->uid != $target_user->uid) {
                        $tables = $current_user->Tables();
                        if (count($tables) > 0) {
                            $args["symbol"] = 'chips';
                            $args["text"] = t("!user is playing at table !table come and join", array("!user" => $current_user->profile_nickname, "!table" => $tables[0]->name));
                            //TODO : Check $_GET["online"] to send mail
                            CMessageSpool::instance()->SendMessage($target_user->uid, $args);
                            $notification = array('text' => t("You just invited !user to play", array("!user" => $target_user->profile_nickname ? $target_user->profile_nickname : variable_get('anonymous', t('Anonymous')))), 'title' => t('Invitation'));
                            CMessageSpool::instance()->SendInstantMessage($notification);
                            $resp["messages"][] = array("type" => "os_poker_notify", "body" => $notification);
                        }
                    }
                }
                break;
            case 'os_poker_trigger_error':
                trigger_error("Message triggered error.", E_USER_ERROR);
                break;
            case 'os_poker_trigger_exception':
                throw new Exception('Message triggered exception.');
                break;
            default:
                $resp["messages"][] = array("type" => "noop", "body" => NULL);
                break;
        }
    }
    if (in_array(drupal_strtoupper($message_type), $poker_server_events)) {
        if (preg_match('/\\[([^,]+),([^,]+),([^,]+)\\]/', $_GET['args'], $args)) {
            array_shift($args);
        }
        //Event setn from the poker server
        //TODO Authenticate the request... how ?
        switch ($message_type) {
            case 'BUY_IN':
                list($uid, $game_id, $amount) = $args;
                if (user_load($uid)) {
                    CScheduler::instance()->RegisterTask(new CUpdateUserChipsCount(), $uid, array('live'));
                    $resp["messages"][] = array("type" => "debug", "body" => t('Recevied BUY_IN for user !uid', array('!uid' => $uid)));
                } else {
                    trigger_error(t('Invalid user ID: %uid', array('%uid' => $uid)), E_USER_ERROR);
                }
                break;
            case 'TOURNEY_START':
                list($tourney_serial, $dummy1, $dummy2) = $args;
                $tourney_users = CPoker::TourneyRegisteredUsers($tourney_serial);
                foreach ($tourney_users as $tourney_user) {
                    if (user_load($tourney_user->user_serial)) {
                        CScheduler::instance()->RegisterTask(new CTourneyNotificationMessage(), $tourney_user->user_serial, array('live'), "-1 day", array($tourney_serial, $tourney_user->description_short, $tourney_user->table_serial));
                        $resp["messages"][] = array("type" => "debug", "body" => t('Recevied tourney start notification for user !uid', array('!uid' => $tourney_user->user_serial)));
                    }
                }
                break;
            case 'HAND':
            case 'TOURNEY':
            case 'REFILL':
            case 'PRIZE':
            case 'REGISTER':
            case 'UNREGISTER':
            case 'LEAVE':
            case 'SEAT':
            case 'NONE':
                $resp["messages"][] = array("type" => "noop", "body" => NULL);
                break;
        }
    } else {
        if (!$resp["messages"]) {
            $resp["messages"][] = array("type" => "noop", "body" => NULL);
        }
    }
    _os_poker_process_message_set_header();
    print json_encode($resp);
}
Пример #10
0
function os_poker_buddies_invite_form($form_state)
{
    $form = array();
    for ($i = 0; $i < 5; $i++) {
        $nb = $i + 1;
        $form["name_" . $nb] = array('#type' => 'textfield', '#title' => $i == 0 ? t("Name") : "", '#prefix' => '<div class="clear"></div><div class="num" ' . ($i == 0 ? "style='margin-top: 14px'" : "") . ' >' . $nb . '</div>');
        $form["mail_" . $nb] = array('#type' => 'textfield', '#title' => $i == 0 ? t("E-Mail") : "", '#attributes' => array("class" => "invite_target_mail", "number" => $nb));
    }
    $form["message"] = array('#type' => 'textarea', '#title' => "Message", '#resizable' => FALSE, '#default_value' => isset($form_state['values']['message']) ? $form_state['values']['message'] : t('I just forked out 5.000 chips for you, so we can play together on !site_name ;-). Just click on the link in this e-mail and register!', array('!site_name' => variable_get('site_name', 'Drupal'))));
    $form["email"] = array('#type' => 'hidden', '#default_value' => '');
    $form['submit'] = array('#type' => 'submit', '#value' => t('Send invite'), '#attributes' => array("style" => "display:none;"));
    $form['f_submit'] = array('#type' => 'markup', '#value' => '<div class="clear"></div><div class="TeaseMore"><div onclick="javascript:os_poker_submit(this, \'os-poker-buddies-invite-form\');" ' . " class='poker_submit big'" . " ><div class='pre'>&nbsp;</div><div class='label'>" . t("Send") . "</div></div></div>");
    $cuser = CUserManager::instance()->CurrentUser();
    //invite stuff :
    $remaining_invites = invite_get_remaining_invites($cuser->DrupalUser());
    if ($remaining_invites == 0) {
        // Deny access when NOT resending an invite.
        drupal_set_message(t("Sorry, you've reached the maximum number of invitations."), 'error');
        drupal_goto(referer_uri());
    }
    $form['resent'] = array('#type' => 'value', '#value' => 0);
    $form['reg_code'] = array('#type' => 'value', '#value' => NULL);
    if ($remaining_invites != INVITE_UNLIMITED) {
        $form['remaining_invites'] = array('#type' => 'value', '#value' => $remaining_invites);
    }
    // Sender e-mail address.
    if ($user->uid && variable_get('invite_use_users_email', 0)) {
        $from = $user->mail;
    } else {
        $from = variable_get('site_mail', ini_get('sendmail_from'));
    }
    // Personalize displayed e-mail address.
    // @see http://drupal.org/project/pmail
    if (module_exists('pmail')) {
        $from = personalize_email($from);
    }
    $form['from'] = array('#type' => 'hidden', '#value' => check_plain($from));
    $allow_multiple = user_access('send mass invitations');
    if (!$allow_multiple) {
        drupal_set_message(t("'send mass invitations' permission must be set !"), 'error');
    }
    //user_relationship stuff :
    $new_user = drupal_anonymous_user();
    module_load_include('inc', 'user_relationships_ui', 'user_relationships_ui.forms');
    $form += user_relationships_ui_request_form($cuser->uid, $new_user->uid, $form);
    $form['rtid']['#weight'] = 0;
    $form['#redirect'] = array("poker/buddies/invitedlist");
    return $form;
}