本文整理汇总了PHP中User_group::groupsFromText方法的典型用法代码示例。如果您正苦于以下问题:PHP User_group::groupsFromText方法的具体用法?PHP User_group::groupsFromText怎么用?PHP User_group::groupsFromText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类User_group
的用法示例。
在下文中一共展示了User_group::groupsFromText方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle
/**
* Handle the request
*
* Make a new notice for the update, save it, and show it
*
* @return void
*/
protected function handle()
{
parent::handle();
// Workaround for PHP returning empty $_POST and $_FILES when POST
// length > post_max_size in php.ini
if (empty($_FILES) && empty($_POST) && $_SERVER['CONTENT_LENGTH'] > 0) {
// TRANS: Client error displayed when the number of bytes in a POST request exceeds a limit.
// TRANS: %s is the number of bytes of the CONTENT_LENGTH.
$msg = _m('The server was unable to handle that much POST data (%s byte) due to its current configuration.', 'The server was unable to handle that much POST data (%s bytes) due to its current configuration.', intval($_SERVER['CONTENT_LENGTH']));
$this->clientError(sprintf($msg, $_SERVER['CONTENT_LENGTH']));
}
if (empty($this->status)) {
// TRANS: Client error displayed when the parameter "status" is missing.
$this->clientError(_('Client must provide a \'status\' parameter with a value.'));
}
if (is_null($this->scoped)) {
// TRANS: Client error displayed when updating a status for a non-existing user.
$this->clientError(_('No such user.'), 404);
}
/* Do not call shortenlinks until the whole notice has been build */
// Check for commands
$inter = new CommandInterpreter();
$cmd = $inter->handle_command($this->auth_user, $this->status);
if ($cmd) {
if ($this->supported($cmd)) {
$cmd->execute(new Channel());
}
// Cmd not supported? Twitter just returns your latest status.
// And, it returns your last status whether the cmd was successful
// or not!
$this->notice = $this->auth_user->getCurrentNotice();
} else {
$reply_to = null;
if (!empty($this->in_reply_to_status_id)) {
// Check whether notice actually exists
$reply = Notice::getKV($this->in_reply_to_status_id);
if ($reply) {
$reply_to = $this->in_reply_to_status_id;
} else {
// TRANS: Client error displayed when replying to a non-existing notice.
$this->clientError(_('Parent notice not found.'), 404);
}
}
$upload = null;
try {
$upload = MediaFile::fromUpload('media', $this->scoped);
} catch (NoUploadedMediaException $e) {
// There was no uploaded media for us today.
}
if (isset($upload)) {
$this->status .= ' ' . $upload->shortUrl();
/* Do not call shortenlinks until the whole notice has been build */
}
// in Qvitter we shorten _before_ posting, so disble shortening here
$status_shortened = $this->status;
if (Notice::contentTooLong($status_shortened)) {
if ($upload instanceof MediaFile) {
$upload->delete();
}
// TRANS: Client error displayed exceeding the maximum notice length.
// TRANS: %d is the maximum lenth for a notice.
$msg = _m('Maximum notice size is %d character, including attachment URL.', 'Maximum notice size is %d characters, including attachment URL.', Notice::maxContent());
/* Use HTTP 413 error code (Request Entity Too Large)
* instead of basic 400 for better understanding
*/
$this->clientError(sprintf($msg, Notice::maxContent()), 413);
}
$content = html_entity_decode($status_shortened, ENT_NOQUOTES, 'UTF-8');
$options = array('reply_to' => $reply_to);
// -------------------------------------------------------------
// -------- Qvitter's post-to-the-right-group stuff! -----------
// -------------------------------------------------------------
// guess the groups by the content first, if we don't have group id:s as meta data
$profile = Profile::getKV('id', $this->scoped->id);
$guessed_groups = User_group::groupsFromText($content, $profile);
// if the user has specified any group id:s, correct the guesswork
if (strlen($this->post_to_groups) > 0) {
// get the groups that the user wants to post to
$group_ids = explode(':', $this->post_to_groups);
$correct_groups = array();
foreach ($group_ids as $group_id) {
$correct_groups[] = User_group::getKV('id', $group_id);
}
// correct the guesses
$corrected_group_ids = array();
foreach ($guessed_groups as $guessed_group) {
$id_to_keep = $guessed_group->id;
foreach ($correct_groups as $k => $correct_group) {
if ($correct_group->nickname == $guessed_group->nickname) {
$id_to_keep = $correct_group->id;
unset($correct_groups[$k]);
break;
}
//.........这里部分代码省略.........