forked from GNUsocial/gnu-social
NoticeListItem attentions showed double for User_group
...because they each have their own Profile now! Whiie!
This commit is contained in:
parent
e45edd6ae2
commit
09ef1fff69
@ -99,13 +99,37 @@ class Profile extends Managed_DataObject
|
||||
if ($this->_user === -1) {
|
||||
$this->_user = User::getKV('id', $this->id);
|
||||
}
|
||||
if (!($this->_user instanceof User)) {
|
||||
if (!$this->_user instanceof User) {
|
||||
throw new NoSuchUserException(array('id'=>$this->id));
|
||||
}
|
||||
|
||||
return $this->_user;
|
||||
}
|
||||
|
||||
protected $_group = -1;
|
||||
|
||||
public function getGroup()
|
||||
{
|
||||
if ($this->_group === -1) {
|
||||
$this->_group = User_group::getKV('profile_id', $this->id);
|
||||
}
|
||||
if (!$this->_group instanceof User_group) {
|
||||
throw new NoSuchGroupException(array('profile_id'=>$this->id));
|
||||
}
|
||||
|
||||
return $this->_group;
|
||||
}
|
||||
|
||||
public function isGroup()
|
||||
{
|
||||
try {
|
||||
$this->getGroup();
|
||||
return true;
|
||||
} catch (NoSuchGroupException $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function isLocal()
|
||||
{
|
||||
try {
|
||||
|
@ -62,6 +62,7 @@ class User_group extends Managed_DataObject
|
||||
'primary key' => array('id'),
|
||||
'unique keys' => array(
|
||||
'user_group_uri_key' => array('uri'),
|
||||
// when it's safe and everyone's run upgrade.php 'user_profile_id_key' => array('profile_id'),
|
||||
),
|
||||
'foreign keys' => array(
|
||||
'user_group_id_fkey' => array('profile', array('profile_id' => 'id')),
|
||||
|
67
lib/nosuchgroupexception.php
Normal file
67
lib/nosuchgroupexception.php
Normal file
@ -0,0 +1,67 @@
|
||||
<?php
|
||||
/**
|
||||
* StatusNet, the distributed open-source microblogging tool
|
||||
*
|
||||
* class for an exception when a User_group is not found by certain criteria
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENCE: This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @category Exception
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Mikael Nordfeldth <mmn@hethane.se>
|
||||
* @copyright 2013 Free Software Foundation, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
/**
|
||||
* Class for an exception when a local user is not found by certain criteria
|
||||
*
|
||||
* @category Exception
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Mikael Nordfeldth <mmn@hethane.se>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class NoSuchGroupException extends ServerException
|
||||
{
|
||||
public $data = array();
|
||||
|
||||
/**
|
||||
* constructor
|
||||
*
|
||||
* @param array $data User_group search criteria
|
||||
*/
|
||||
|
||||
public function __construct(array $data)
|
||||
{
|
||||
// filter on unique keys for User_group entries
|
||||
foreach(array('id', 'profile_id') as $key) {
|
||||
if (isset($data[$key]) && !empty($data[$key])) {
|
||||
$this->data[$key] = $data[$key];
|
||||
}
|
||||
}
|
||||
|
||||
// Here we could log the failed lookup
|
||||
|
||||
parent::__construct(_('No such user found.'));
|
||||
}
|
||||
}
|
@ -28,9 +28,7 @@
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
if (!defined('STATUSNET')) {
|
||||
exit(1);
|
||||
}
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
/**
|
||||
* Class for an exception when a local user is not found by certain criteria
|
||||
|
@ -241,15 +241,12 @@ class NoticeListItem extends Widget
|
||||
|
||||
function showAddressees()
|
||||
{
|
||||
$ga = $this->getGroupAddressees();
|
||||
$pa = $this->getProfileAddressees();
|
||||
|
||||
$a = array_merge($ga, $pa);
|
||||
|
||||
if (!empty($a)) {
|
||||
if (!empty($pa)) {
|
||||
$this->out->elementStart('span', 'addressees');
|
||||
$first = true;
|
||||
foreach ($a as $addr) {
|
||||
foreach ($pa as $addr) {
|
||||
if (!$first) {
|
||||
// TRANS: Separator in profile addressees list.
|
||||
$this->out->text(_m('SEPARATOR',', '));
|
||||
@ -265,46 +262,22 @@ class NoticeListItem extends Widget
|
||||
}
|
||||
}
|
||||
|
||||
function getGroupAddressees()
|
||||
{
|
||||
$ga = array();
|
||||
|
||||
$groups = $this->getGroups();
|
||||
|
||||
$user = common_current_user();
|
||||
|
||||
$streamNicknames = !empty($user) && $user->streamNicknames();
|
||||
|
||||
foreach ($groups as $group) {
|
||||
$ga[] = array('href' => $group->homeUrl(),
|
||||
'title' => $group->nickname,
|
||||
'class' => 'addressee group',
|
||||
'text' => ($streamNicknames) ? $group->nickname : $group->getBestName());
|
||||
}
|
||||
|
||||
return $ga;
|
||||
}
|
||||
|
||||
function getGroups()
|
||||
{
|
||||
return $this->notice->getGroups();
|
||||
}
|
||||
|
||||
function getProfileAddressees()
|
||||
{
|
||||
$pa = array();
|
||||
|
||||
$replies = $this->getReplyProfiles();
|
||||
$attentions = $this->getReplyProfiles();
|
||||
|
||||
$user = common_current_user();
|
||||
|
||||
$streamNicknames = !empty($user) && $user->streamNicknames();
|
||||
|
||||
foreach ($replies as $reply) {
|
||||
$pa[] = array('href' => $reply->profileurl,
|
||||
'title' => $reply->nickname,
|
||||
'class' => 'addressee account',
|
||||
'text' => ($streamNicknames) ? $reply->nickname : $reply->getBestName());
|
||||
foreach ($attentions as $attn) {
|
||||
$class = $attn->isGroup() ? 'group' : 'account';
|
||||
$pa[] = array('href' => $attn->profileurl,
|
||||
'title' => $attn->nickname,
|
||||
'class' => "addressee {$class}",
|
||||
'text' => ($streamNicknames) ? $attn->nickname : $attn->getBestName());
|
||||
}
|
||||
|
||||
return $pa;
|
||||
|
@ -17,7 +17,7 @@ Settings
|
||||
========
|
||||
user*: user part of the jid
|
||||
server*: server part of the jid
|
||||
resource*: resource part of the jid
|
||||
resource (gnusocial): resource part of the jid
|
||||
port (5222): port on which to connect to the server
|
||||
encryption (true): use encryption on the connection
|
||||
host (same as server): host to connect to. Usually, you won't set this.
|
||||
|
Loading…
Reference in New Issue
Block a user