Example #1
0
 /**
  * Add an invitation for the given invitee, from the given inviter.
  * @param string $feature The feature to invite to.
  * @param object $invitee The user to be invited.
  * @param object $inviter The inviting user, or null for $wgUser.
  * @return integer One of the INVITE_RESULT constants.
  */
 public static function inviteUser($feature, $invitee, $inviter = null)
 {
     global $wgUser, $wgInvitationTypes;
     if ($inviter === null) {
         $inviter = $wgUser;
     }
     if (($res = Invitations::checkInviteOperation($feature, $invitee, $inviter)) != INVITE_RESULT_OK) {
         return $res;
     }
     // We /should/ be OK to go.
     $dbw = wfGetDB(DB_MASTER);
     $dbw->update('invite_count', array('ic_count=ic_count-1'), array('ic_user' => $inviter->getId(), 'ic_type' => $feature), __METHOD__);
     $dbw->insert('invitation', array('inv_invitee' => $invitee->getId(), 'inv_inviter' => $inviter->getId(), 'inv_type' => $feature), __METHOD__);
     // Log it.
     $log = new LogPage('invite');
     $log->addEntry('invite', $invitee->getUserPage(), '', array($feature));
     Invitations::insertCountRow($feature, $invitee);
 }