Example #1
0
/**
 * Invites a user (or a future user) to a stream .
 * @param {array} $_REQUEST
 * @param {string} $_REQUEST.publisherId The id of the stream publisher
 * @param {string} $_REQUEST.streamName The name of the stream the user will be invited to
 *  @param {string} [$_REQUEST.userId] user id or an array of user ids
 *  @param {string} [$_REQUEST.fb_uid] fb user id or array of fb user ids
 *  @param {string} [$_REQUEST.label]  label or an array of labels, or tab-delimited string
 *  @param {string} [$_REQUEST.identifier] identifier or an array of identifiers
 *  @param {string|array} [$_REQUEST.addLabel] label or an array of labels for adding publisher's contacts
 *  @param {string|array} [$_REQUEST.addMyLabel] label or an array of labels for adding logged-in user's contacts
 *  @param {string} [$_REQUEST.readLevel] the read level to grant those who are invited
 *  @param {string} [$_REQUEST.writeLevel] the write level to grant those who are invited
 *  @param {string} [$_REQUEST.adminLevel] the admin level to grant those who are invited
 *	@param {string} [$_REQUEST.displayName] optionally override the name to display in the invitation for the inviting user
 * @see Users::addLink()
 */
function Streams_invite_post()
{
    $publisherId = Streams::requestedPublisherId(true);
    $streamName = Streams::requestedName(true);
    Streams::$cache['invited'] = Streams::invite($publisherId, $streamName, $_REQUEST, $_REQUEST);
}
Example #2
0
 /**
  * Invites a user (or a future user) to this stream
  * @method invite
  * @static
  * @param {array} $who Array that can contain the following keys:
  * @param {string|array} [$who.userId] user id or an array of user ids
  * @param {string|array} [$who.fb_uid]  fb user id or array of fb user ids
  * @param {string|array} [$who.label]  label or an array of labels, or tab-delimited string
  * @param {string|array} [$who.identifier]  identifier or an array of identifiers, or tab-delimited string
  * @param {integer} [$who.newFutureUsers] the number of new Users_User objects to create via Users::futureUser in order to invite them to this stream. This typically is used in conjunction with passing the "html" option to this function.
  * @param {array} [$options=array()]
  *  @param {string|array} [$options.label] label or an array of labels for adding publisher's contacts
  *  @param {string|array} [$options.myLabel] label or an array of labels for adding logged-in user's contacts
  *  @param {integer} [$options.readLevel] => the read level to grant those who are invited
  *  @param {integer} [$options.writeLevel] => the write level to grant those who are invited
  *  @param {integer} [$options.adminLevel] => the admin level to grant those who are invited
  *	@param {string} [$options.displayName] => the display name to use to represent the inviting user
  *  @param {string} [$options.appUrl] => Can be used to override the URL to which the invited user will be redirected and receive "Q.Streams.token" in the querystring.
  *	@param {array} [$options.html] => an array of ($template, $batchName) such as ("MyApp/foo.handlebars", "foo") for generating html snippets which can then be viewed from and printed via the action Streams/invitations?batchName=$batchName
  * @see Users::addLink()
  * @return {array} returns array with keys "success", "invited", "statuses", "identifierTypes", "alreadyParticipating"
  */
 function invite($who, $options = array())
 {
     return Streams::invite($this->publisherId, $this->name, $who, $options);
 }
Example #3
0
#Read primary arguments
$LOCAL_DIR = $FROM_APP ? APP_DIR : $argv[1];
#Check paths
if (!file_exists($Q_filename = Q_DIR . DIRECTORY_SEPARATOR . 'scripts' . DIRECTORY_SEPARATOR . 'Q.inc.php')) {
    #Q Platform
    die("[ERROR] {$Q_filename} not found" . PHP_EOL);
}
if (!is_dir($LOCAL_DIR)) {
    #App dir
    die("[ERROR] {$LOCAL_DIR} doesn't exist or is not a directory" . PHP_EOL);
}
#Define APP_DIR
if (!defined('APP_DIR')) {
    define('APP_DIR', $LOCAL_DIR);
}
#Include Q
try {
    include $Q_filename;
} catch (Exception $e) {
    die('[ERROR] ' . $e->getMessage() . PHP_EOL . $e->getTraceAsString() . PHP_EOL);
}
$app = Q_Config::expect('Q', 'app');
$identifier = $FROM_APP ? $argv[1] : $argv[2];
$communityId = Q::ifset($argv, $FROM_APP ? 2 : 3, Users::communityId());
$labels = array_slice($argv, $FROM_APP ? 3 : 4);
$addLabel = empty($labels) ? "{$app}/admins" : $labels;
$asUserId = $app;
$skipAccess = true;
$appUrl = Q_Uri::url('Communities/onboarding');
Streams::invite($communityId, 'Streams/community/main', compact('identifier'), compact('addLabel', 'asUserId', 'skipAccess', 'appUrl'));
echo "Successfully invited {$identifier}\n";