Esempio n. 1
0
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');
}
Esempio n. 2
0
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;
}
Esempio n. 3
0
 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;
 }
Esempio n. 4
0
 function handler_marketing($page)
 {
     $page->changeTpl('marketing/index.tpl');
     $page->setTitle('Marketing');
     $alive = array('all' => new ProfileFilter(new PFC_Not(new UFC_Dead())), 'women' => new ProfileFilter(new PFC_And(new UFC_Sex(User::GENDER_FEMALE), new PFC_Not(new UFC_Dead()))), 'x' => new ProfileFilter(new PFC_And(new PFC_Not(new UFC_Dead()), new UFC_AccountType('x'))), '72' => new ProfileFilter(new PFC_And(new UFC_Promo('>=', UserFilter::GRADE_ING, 1972), new PFC_Not(new UFC_Dead()))), 'master' => new ProfileFilter(new PFC_And(new PFC_Not(new UFC_Dead()), new UFC_AccountType('master'))), 'phd' => new ProfileFilter(new PFC_And(new PFC_Not(new UFC_Dead()), new UFC_AccountType('phd'))));
     $registered = array('all' => new ProfileFilter(new PFC_And(new UFC_Registered(true), new PFC_Not(new UFC_Dead()))), 'women' => new ProfileFilter(new PFC_And(new UFC_Registered(true), new UFC_Sex(User::GENDER_FEMALE), new PFC_Not(new UFC_Dead()))), 'x' => new ProfileFilter(new PFC_And(new UFC_Registered(true), new PFC_Not(new UFC_Dead()), new UFC_AccountType('x'))), '72' => new ProfileFilter(new PFC_And(new UFC_Registered(true), new UFC_Promo('>=', UserFilter::GRADE_ING, 1972), new PFC_Not(new UFC_Dead()))), 'master' => new ProfileFilter(new PFC_And(new UFC_Registered(true), new PFC_Not(new UFC_Dead()), new UFC_AccountType('master'))), 'phd' => new ProfileFilter(new PFC_And(new UFC_Registered(true), new PFC_Not(new UFC_Dead()), new UFC_AccountType('phd'))));
     $statistics = array('all' => array('description' => "Étudiants et anciens de l'X"), 'women' => array('description' => "Étudiantes et anciennes de l'X"), 'x' => array('description' => 'X'), '72' => array('description' => 'X vivants depuis la promo 1972'), 'master' => array('description' => "Masters de l'X"), 'phd' => array('description' => "Docteurs de l'X"));
     foreach ($statistics as $key => &$data) {
         $data['alive'] = $alive[$key]->getTotalCount();
         $data['registered'] = $registered[$key]->getTotalCount();
         $data['rate'] = round($data['registered'] / $data['alive'] * 100, 2);
     }
     $registeredWeek = new ProfileFilter(new PFC_And(new UFC_Registered(true, '>=', strtotime('1 week ago')), new PFC_Not(new UFC_Dead())));
     $registrationPending = XDB::fetchOneCell('SELECT  COUNT(*)
                                                 FROM  register_pending');
     $registrations = array('week' => $registeredWeek->getTotalCount(), 'pending' => $registrationPending);
     $ok = XDB::fetchOneCell('SELECT  COUNT(*)
                                FROM  register_mstats
                               WHERE  success != \'0000-00-00\'');
     $okWeek = XDB::fetchOneCell('SELECT  COUNT(*)
                                    FROM  register_mstats
                                   WHERE  success >= {?}', strtotime('1 week ago'));
     $res = XDB::fetchAllAssoc('SELECT  type, COUNT(*) as count
                                  FROM  register_marketing
                              GROUP BY  type');
     $no = array();
     foreach ($res as $value) {
         $no[$value['type']] = $value['count'];
     }
     $no['week'] = XDB::fetchOneCell('SELECT  COUNT(*)
                                        FROM  register_marketing
                                       WHERE  last >= {?}', strtotime('1 week ago'));
     $marketings = array('ok' => $ok, 'okWeek' => $okWeek, 'noPerso' => isset($no['user']) ? $no['user'] : 0, 'noXorg' => isset($no['staff']) ? $no['staff'] : 0, 'noAX' => isset($no['ax']) ? $no['ax'] : 0, 'noWeek' => $no['week']);
     $page->assign('statistics', $statistics);
     $page->assign('registrations', $registrations);
     $page->assign('marketings', $marketings);
 }
Esempio n. 5
0
 function handler_csv(PlPage $page, PlUser $user)
 {
     $page->changeTpl('carnet/mescontacts.outlook.tpl', NO_SKIN);
     $pf = new ProfileFilter(new UFC_Contact($user));
     require_once 'carnet/outlook.inc.php';
     Outlook::output_profiles($pf->getProfiles(), 'fr');
 }
Esempio n. 6
0
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
 *  GNU General Public License for more details.                           *
 *                                                                         *
 *  You should have received a copy of the GNU General Public License      *
 *  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.