function generate_wats4u_extract() { $pf = new ProfileFilter(new PFC_True()); // For debug: replace with iterProfiles(new PlLimit(100)); $profiles = $pf->iterProfiles(); $alive_profiles = PlIteratorUtils::filter($profiles, '_filter_profile'); return PlIteratorUtils::map($alive_profiles, '_map_profile'); }
public function __construct(PlUser $owner) { $notifs = Watch::getEvents($owner); $infos = array(); foreach ($notifs as $n) { foreach ($n['users'] as $user) { $op = $n['operation']; $date = $op->getDate($user); @($datetext = new Date($date)); @($datetext = $datetext->format('%e %B %Y')); $profile = $user->profile(); $infos[] = array('operation' => $op, 'title' => '[' . $op->getTitle(1) . '] - ' . $user->fullName() . ' le ' . $datetext, 'author' => $user->fullName(), 'publication' => $op->publicationDate($user), 'date' => strtotime($date), 'id' => $op->flag . '-' . $user->id() . '-' . strtotime($date), 'data' => $op->getData($user), 'hruid' => $user->login(), 'dead' => $user->deathdate, 'profile' => $user->profile()->hrid(), 'link' => Platal::globals()->baseurl . '/profile/' . $profile->hrid(), 'user' => $user, 'contact' => $owner->isContact($profile)); } } $this->it = PlIteratorUtils::fromArray($infos); }
protected function fetch(PlUser $user) { global $globals; $events = XDB::iterator('SELECT e.id, e.titre AS title, e.texte, e.creation_date AS publication, e.post_id, p.attachmime IS NOT NULL AS photo, FIND_IN_SET(\'wiki\', e.flags) AS wiki, e.uid, e.promo_min, e.promo_max FROM announces AS e LEFT JOIN announce_photos AS p ON (p.eid = e.id) WHERE FIND_IN_SET("valide", e.flags) AND expiration >= NOW()'); $data = array(); while ($e = self::nextEvent($events, $user)) { $author = User::getWithUID($e['uid']); $promo = $author->promo(); $e['author'] = $author->fullName() . ($promo ? ' (' . $promo . ')' : ''); $e['link'] = $globals->baseurl . '/events#newsid' . $e['id']; $data[] = $e; } return PlIteratorUtils::fromArray($data, 1, true); }
protected function fetch(User $user) { global $globals; $nf = new NewsFilter(new PFC_And(new NFC_Current(), new NFC_Target($user->targetCastes())), new NFO_Begin(true)); $all_news = $nf->get(); $all_news->select(NewsSelect::news()); $data = array(); foreach ($all_news as $item) { $e = array(); $e['id'] = $item->id(); $e['title'] = '[' . $item->target()->group()->label() . '] ' . $item->title(); $e['news'] = $item; $e['publication'] = $item->begin()->format(); $auth = $item->origin() != false ? '[' . $item->origin()->label() . '] ' : ''; $e['author'] = $auth . $item->writer()->displayName(); $e['link'] = $globals->baseurl . '/news'; $data[] = $e; } return PlIteratorUtils::fromArray($data, 1, true); }
protected function fetch(User $user) { global $globals; $activities = new ActivityInstanceFilter(new PFC_Or(new PFC_And(new AIFC_END(new FrankizDateTime(), AIFC_End::AFTER), new AIFC_User($user, 'restricted')), new PFC_And(new AIFC_END(new FrankizDateTime(), AIFC_End::AFTER), new AIFC_User($user, 'everybody')))); $activities = $activities->get(); $activities->select(ActivityInstanceSelect::base()); $data = array(); foreach ($activities as $item) { $e = array(); $e['id'] = $item->id(); $e['title'] = '[' . $item->target_group()->label() . '] ' . $item->title(); $e['activity'] = $item; $e['publication'] = $item->begin()->format(); $auth = $item->origin() != false ? '[' . $item->origin() . '] ' : ''; $e['author'] = $auth . $item->writer()->displayName(); $e['link'] = $globals->baseurl . '/activity'; $data[] = $e; } return PlIteratorUtils::fromArray($data, 1, true); }
/** Return an iterator over the validation concerning the given type * and the given user. * * @param type The type of the validations to fetch, null mean "any type" * @param applyTo A User or a Profile object the validation applies to. */ public static function iterate($type = null, $applyTo = null) { function toValidation($elt) { list($result, $stamp) = $elt; $result = Validate::unserialize($result); $result->stamp = $stamp; return $result; } $where = array(); if ($type) { $where[] = XDB::format('type = {?}', $type); } if ($applyTo) { if ($applyTo instanceof User) { $where[] = XDB::format('uid = {?}', $applyTo->id()); } else { if ($applyTo instanceof Profile) { $where[] = XDB::format('pid = {?}', $applyTo->id()); } } } if (!empty($where)) { $where = 'WHERE ' . implode('AND', $where); } else { $where = ''; } $it = XDB::iterRow('SELECT data, DATE_FORMAT(stamp, "%Y%m%d%H%i%s") FROM requests ' . $where . ' ORDER BY stamp'); return PlIteratorUtils::map($it, 'toValidation'); }
protected function fetch() { return PlIteratorUtils::fromArray($this->profile_list); }
function handler_ical(PlPage $page, PlUser $user) { require_once 'ical.inc.php'; $page->changeTpl('carnet/calendar.tpl', NO_SKIN); $page->register_function('display_ical', 'display_ical'); $filter = new UserFilter(new UFC_Contact($user)); $profiles = $filter->iterProfiles(); $page->assign('events', PlIteratorUtils::map($profiles, array($this, 'buildBirthRef'))); pl_cached_content_headers('text/calendar', 1); }
protected static function loadMainFieldsFromUIDs(array $uids, $respect_order = true) { if (empty($uids)) { return PlIteratorUtils::emptyIterator(); } global $globals; $joins = ''; $fields = array(); if ($globals->asso('id')) { $joins .= XDB::format("LEFT JOIN group_members AS gpm ON (gpm.uid = a.uid AND gpm.asso_id = {?})\n", $globals->asso('id')); $fields[] = 'gpm.perms AS group_perms'; $fields[] = 'gpm.comm AS group_comm'; $fields[] = 'gpm.position AS group_position'; } if (count($fields) > 0) { $fields = ', ' . implode(', ', $fields); } else { $fields = ''; } if ($respect_order) { $order = 'ORDER BY ' . XDB::formatCustomOrder('a.uid', $uids); } else { $order = ''; } $uids = array_map(array('XDB', 'escape'), $uids); return XDB::iterator('SELECT a.uid, a.hruid, a.registration_date, h.uid IS NOT NULL AS homonym, a.firstname, a.lastname, IF(ef.email IS NULL, NULL, CONCAT(ef.email, \'@\', mf.name)) AS forlife, IF(ef.email IS NULL, NULL, CONCAT(ef.email, \'@\', df.name)) AS forlife_alternate, IF(eb.email IS NULL, NULL, CONCAT(eb.email, \'@\', mb.name)) AS bestalias, (er.redirect IS NULL AND a.state = \'active\' AND FIND_IN_SET(\'mail\', at.perms)) AS lost, a.email, a.full_name, a.directory_name, a.display_name, a.sort_name, a.sex = \'female\' AS gender, IF(a.state = \'active\', CONCAT(at.perms, \',\', IF(a.user_perms IS NULL, \'\', a.user_perms)), \'\') AS perms, a.user_perms, a.email_format, a.is_admin, a.state, a.type, at.description AS type_description, a.skin, FIND_IN_SET(\'watch\', a.flags) AS watch, a.comment, a.weak_password IS NOT NULL AS weak_access, g.g_account_name IS NOT NULL AS googleapps, a.token IS NOT NULL AS token_access, a.token, a.last_version, s.start AS lastlogin, s.host, fp.last_seen AS banana_last ' . $fields . ' FROM accounts AS a INNER JOIN account_types AS at ON (at.type = a.type) LEFT JOIN email_source_account AS ef ON (ef.uid = a.uid AND ef.type = \'forlife\') LEFT JOIN email_virtual_domains AS mf ON (ef.domain = mf.id) LEFT JOIN email_virtual_domains AS df ON (df.aliasing = mf.id AND df.name LIKE CONCAT(\'%\', {?}) AND df.name NOT LIKE \'alumni.%\') LEFT JOIN email_source_account AS eb ON (eb.uid = a.uid AND FIND_IN_SET(\'bestalias\',eb.flags)) LEFT JOIN email_virtual_domains AS mb ON (a.best_domain = mb.id) LEFT JOIN email_redirect_account AS er ON (er.uid = a.uid AND er.flags = \'active\' AND er.broken_level < 3 AND er.type != \'imap\' AND er.type != \'homonym\') LEFT JOIN homonyms_list AS h ON (h.uid = a.uid) LEFT JOIN gapps_accounts AS g ON (a.uid = g.l_userid AND g.g_status = \'active\') LEFT JOIN log_last_sessions AS ls ON (ls.uid = a.uid) LEFT JOIN log_sessions AS s ON (s.id = ls.id) LEFT JOIN forum_profiles AS fp ON (fp.uid = a.uid) ' . $joins . ' WHERE a.uid IN (' . implode(', ', $uids) . ') GROUP BY a.uid ' . $order, $globals->mail->domain2, $globals->mail->domain2); }
public function __construct(PlIterator $it, array $pids, $fields = 0x0, $visibility = null) { require_once 'profilefields.inc.php'; if ($visibility === null) { $visibility = Visibility::defaultForRead(); } $this->fields = $fields; $this->visibility = $visibility; $subits = array(); $callbacks = array(); $subits[0] = $it; $callbacks[0] = PlIteratorUtils::arrayValueCallback('pid'); $cb = PlIteratorUtils::objectPropertyCallback('pid'); $fields = $fields & self::FETCH_ALL; for ($field = 1; $field < $fields; $field *= 2) { if ($fields & $field) { $callbacks[$field] = $cb; $subits[$field] = new ProfileFieldIterator($field, $pids, $visibility); } } $this->iterator = PlIteratorUtils::parallelIterator($subits, $callbacks, 0); }
public function getOptionsIter($subid = null) { return PlIteratorUtils::fromArray(self::expandArray($this->getOptions($subid)), 1, true); }
public static function fetchData(array $pids, Visibility $visibility) { $data = XDB::iterator('SELECT ppss.pid, ppss.exposed_uid, ppss.sharing_level, ppss.allow_email, ppss.partner_id, ppse.shortname AS partner_shortname, ppse.name AS partner_name, ppse.url AS partner_url FROM profile_partnersharing_settings AS ppss LEFT JOIN profile_partnersharing_enum AS ppse ON (ppss.partner_id = ppse.id) WHERE ppss.pid IN {?} ORDER BY ' . XDB::formatCustomOrder('ppss.pid', $pids), $pids); return PlIteratorUtils::subIterator($data, PlIteratorUtils::arrayValueCallback('pid')); }