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'); }
function list_sort_owners($emails, $tri_promo = true) { global $globals; // $membres' structure is the following: $sortKey => $key => $listMember $membres = array(); $seen = array(); $members = array(); $uf = new UserFilter(new UFC_Email($emails)); $it = $uf->iterUsers(); while ($u = $it->next()) { $members[$u->uid] = array('user' => $u, 'profile' => null, 'email' => $u->forlifeEmail()); $seen[] = strtolower($u->forlifeEmail()); } $pf = new ProfileFilter(new UFC_Email($emails)); $it = $pf->iterProfiles(); if ($it) { while ($p = $it->next()) { $members[$p->owner_id]['user']->setPrefetchedProfile($p); $members[$p->owner_id]['profile'] = $p; } } foreach ($emails as $email) { $email = strtolower($email); if (!in_array($email, $seen)) { $seen[] = $email; $members[$email] = array('user' => null, 'profile' => null, 'email' => $email); } } // $members is now an array of uid => {'user': User or null, 'email': $email} // $sorted_members is an array of $sortKey1 => $sortKey2 => {User, email} $sorted_members = array(); foreach ($members as $member) { if (is_null($member['user'])) { $category = 'AAAAA'; $name = $member['email']; } else { $category = $member['user']->category(); $name = $member['user']->sortName(); } if (empty($category)) { $category = "AAAAA"; } $main_sort_key = $tri_promo ? $category : strtoupper($name[0]); $alt_sort_key = $name . $member['email']; if (!array_key_exists($main_sort_key, $sorted_members)) { $sorted_members[$main_sort_key] = array(); } $sorted_members[$main_sort_key][$alt_sort_key] = $member; } uksort($sorted_members, 'strcasecmp'); foreach ($sorted_members as &$subsorted_members) { uksort($subsorted_members, 'strcasecmp'); } return $sorted_members; }
public function get() { $cond = $this->getCond(); $cond->addChild(new UFC_PartnerSharing($this->partner->id)); $pf = new ProfileFilter($cond, $this->getOrders()); $pf->restrictVisibilityForPartner($this->partner->id); $response = array(); $matches = $pf->getTotalProfileCount(); $response['matches'] = $matches; $profiles = array(); if ($matches) { // TODO : improve fetching by passing an adequate FETCH field $iter = $pf->iterProfiles(new PlLimit($this->amount), 0x0, Visibility::get(Visibility::VIEW_PRIVATE)); while ($profile = $iter->next()) { if ($profile->getPartnerSettings($this->partner->id)->exposed_uid !== 0) { $profile_data = new WSRequestEntry($this->partner, $profile); $profiles[] = $profile_data->getFields($this->fields); } } } $response['profiles'] = $profiles; return $response; }
* along with this program; if not, write to the Free Software * * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ***************************************************************************/ require_once 'connect.db.inc.php'; require_once 'plmailer.php'; ini_set('memory_limit', '128M'); // This cron sends a birthday email once a year to all users who have a profile. // It is useful technically (for 'unsubscribed users' to get at least one broken level a year) ; // and for the community management (it is very easy to unsubscribe and then difficult tu subscribe again). $pf = new ProfileFilter(new PFC_And(new UFC_Birthday('=', time()), new UFC_HasValidEmail(), new PFC_Not(new UFC_Dead()))); $limit = 0; $count_mail = 0; $texte = ""; $liste = ""; $iterator = $pf->iterProfiles(); while ($profile = $iterator->next()) { // We do not want to send more than max_send_per_min emails a minute. if ($limit > $globals->mail->max_send_per_min) { sleep(60); $limit = 0; } $limit += 1; $user = $profile->owner(); $mailer = new PlMailer('profile/birthday.mail.tpl'); // This is a social email so we want to use several info on the user to be specific. $mailer->assign('sex', $user->isFemale()); $mailer->assign('yourself', $user->display_name); $mailer->assign('groups', $user->groups()); $mailer->assign('isX', $profile->mainEducation() == 'X'); $mailer->assign('promoX', $profile->yearpromo());