return $this->watch_last;
}
+
+ // Contacts
+ private $contacts = null;
+ public function isContact(PlUser &$user)
+ {
+ if ($this->contacts) {
+ $this->contacts = XDB::fetchAllAssoc('contact', 'SELECT *
+ FROM contacts
+ WHERE uid = {?}',
+ $this->id());
+ }
+ return isset($this->contacts[$user->id()]);
+ }
+
// Return permission flags for a given permission level.
public static function makePerms($perms, $is_admin)
{
abstract public function getOrder();
abstract public function getDate(PlUser &$user);
+ public function publicationDate(PlUser &$user)
+ {
+ return $this->getDate($user);
+ }
+
public function seen(PlUser &$user, $last)
{
return strtotime($this->getDate($user)) > $last;
}
+
+ public function getData(PlUser &$user)
+ {
+ return null;
+ }
}
class WatchProfileUpdate extends WatchOperation
return $user->profile()->deathdate;
}
+ public function publicationDate(PlUser &$user)
+ {
+ return $user->profile()->deathdate_rec;
+ }
+
public function seen(PlUser &$user, $last)
{
return strtotime($user->profile()->deathdate_rec) > $last;
return $user->profile()->next_birthday;
}
+ public function publicationDate(PlUser &$user)
+ {
+ return date('Y-m-d', strtotime($user->profile()->next_birthday) - self::WATCH_LIMIT);
+ }
+
public function seen(PlUser &$user, $last)
{
$birthday = strtotime($user->profile()->next_birthday);
private $notifs;
private $it;
- public function __construct(Notifs& $notifs)
+ public function __construct(PlUser &$owner)
{
- $this->notifs =& $notifs;
- $this->it = PlIteratorUtils::fromArray($notifs->_data, 3);
+ $notifs = Watch::getEvents($owner);
+ $infos = array();
+ foreach ($notifs as $n) {
+ foreach ($n['users'] as $user) {
+ $op = $n['operation'];
+ $date = $op->getDate($user);
+ $infos[] = array('operation' => $op,
+ 'title' => '[' . $op->getTitle(1) . '] - ' . $user->fullName(),
+ 'author' => $user->fullName(),
+ 'publication' => strtotime($op->publicationDate($user)),
+ 'date' => strtotime($date),
+ 'id' => $op->flag . strtotime($date),
+ 'data' => $op->getData($user),
+ 'hruid' => $user->login(),
+ 'dead' => $user->deathdate,
+ 'profile' => $user->profile()->hrid(),
+ 'user' => $user,
+ 'contact' => $owner->isContact($user));
+ }
+ }
+ $this->it = PlIteratorUtils::fromArray($infos);
}
public function next()
{
$data = $this->it->next();
- if (is_null($data)) {
- return null;
- }
- $cid = $data['keys'][0];
- $x = $data['value'];
-
- global $globals;
- @require_once 'Date.php';
- @$date = new Date($x['date']);
- @$date = $date->format('%e %B %Y');
- $author = $x['prenom'] . ' ' . $x['nom'] . ' (X' . $x['promo'] . ')';
- return array_merge($x,
- array('author' => $author,
- 'publication' => $x['known'],
- 'id' => 'carnet' . $x['known'] . $cid . $x['bestalias'],
- 'link' => $globals->baseurl . '/profile/private/'
- . $x['bestalias'],
- 'title' => '[' . $this->notifs->_cats[$cid]['short'] . '] '
- . $author . ' - le ' . $date));
+ return $data['value'];
}
public function total()
protected function fetch(PlUser &$user)
{
- return new CarnetFeedIterator(new Notifs($user->id(), false));
+ return new CarnetFeedIterator($user);
}
}
{* *}
{**************************************************************************}
-{if $article->data}{$article->prenom} {$article->nom} a mis à jours les données suivantes :<br />{$article->data}<br />{/if}
-{if !$article->contact and !$article->dcd}
-<a href="{#globals.baseurl#}/carnet/contacts?action=ajouter&user={$article->bestalias}&token={$rss_hash}">
+{if $article->data}{profile user=$article->user promo=false link=false} a mis à jours les données suivantes :<br />{$article->data}<br />{/if}
+{if !$article->contact and !$article->dead}
+<a href="{#globals.baseurl#}/carnet/contacts?action=ajouter&user={$article->hruid}&token={$rss_hash}">
{icon name=add title="Ajouter" full=true} Ajouter à mes contacts
</a><br />
{/if}
-{if !$article->dcd}
-<a href="{#globals.baseurl#}/vcard/{$article->bestalias}.vcf">
+{if !$article->dead}
+<a href="{#globals.baseurl#}/vcard/{$article->profile}.vcf">
{icon name=vcard title="Carte de visite" full=true} Télécharger la carte de visite électronique
</a>
{/if}