PHP Method User::getBulkUsersWithUIDs, codiad Code Examples

This page contains top rated real world PHP examples of method User::getBulkUsersWithUIDs from package codiad extracted from open source projects. You can rate examples to help us improve the quality of examples
Example #1
Show file File: xnetnl.php Project: Ekleog/platal
0
 public function handler_admin_nl_sync($page)
 {
     global $globals;
     $nl = $this->getNl();
     if (!$nl) {
         return PL_FORBIDDEN;
     }
     if (Env::has('add_users')) {
         S::assert_xsrf_token();
         $nl->bulkSubscribe(array_keys(Env::v('add_users')));
         $page->trigSuccess('Ajouts réalisés avec succès.');
     }
     // TODO(x2006barrois): remove raw SQL query.
     $uids = XDB::fetchColumn('SELECT  DISTINCT(g.uid)
                                 FROM  group_members AS g
                                WHERE  g.asso_id = {?} AND NOT EXISTS (SELECT  ni.*
                                                                         FROM  newsletter_ins AS ni
                                                                   INNER JOIN  newsletters    AS n  ON (ni.nlid = n.id)
                                                                        WHERE  g.uid = ni.uid AND n.group_id = g.asso_id)', $globals->asso('id'));
     $users = User::getBulkUsersWithUIDs($uids);
     usort($users, 'User::compareDirectoryName');
     $page->setTitle('Synchronisation de la newsletter');
     $page->changeTpl('newsletter/sync.tpl');
     $page->assign('users', $users);
 }
Example #2
Show file File: xnetevents.inc.php Project: Ekleog/platal
0
function get_event_participants(&$evt, $item_id, array $tri = array(), $limit = null, $offset = 0)
{
    global $globals;
    $eid = $evt['eid'];
    $money = $evt['money'] && function_exists('may_update') && may_update();
    $pay_id = $evt['paiement_id'];
    $append = $item_id ? XDB::format(' AND ep.item_id = {?}', $item_id) : '';
    $query = XDB::fetchAllAssoc('uid', 'SELECT  ep.uid, SUM(ep.paid) AS paid, SUM(ep.nb) AS nb,
                                                FIND_IN_SET(\'notify_payment\', ep.flags) AS notify_payment
                                          FROM  group_event_participants AS ep
                                         WHERE  ep.eid = {?} AND nb > 0 ' . $append . '
                                      GROUP BY  ep.uid', $eid);
    $uf = new UserFilter(new PFC_True(), $tri);
    $users = User::getBulkUsersWithUIDs($uf->filter(array_keys($query), new PlLimit($limit, $offset)));
    $tab = array();
    foreach ($users as $user) {
        $uid = $user->id();
        $tab[$uid] = $query[$uid];
        $tab[$uid]['user'] = $user;
    }
    if ($item_id) {
        return $tab;
    }
    $evt['adminpaid'] = 0;
    $evt['telepaid'] = 0;
    $evt['topay'] = 0;
    $evt['paid'] = 0;
    foreach ($tab as $uid => &$u) {
        $u['adminpaid'] = (double) $u['paid'];
        $u['montant'] = 0;
        if ($money && $pay_id) {
            $montant = XDB::fetchOneCell('SELECT  SUM(amount)
                                            FROM  payment_transactions AS t
                                           WHERE  status = "confirmed" AND ref = {?} AND uid = {?}', $pay_id, $uid);
            $u['paid'] += $montant;
        }
        $u['telepayment'] = $u['paid'] - $u['adminpaid'];
        $res_ = XDB::iterator('SELECT  ep.nb, ep.item_id, ei.montant
                                 FROM  group_event_participants AS ep
                           INNER JOIN  group_event_items AS ei ON (ei.eid = ep.eid AND ei.item_id = ep.item_id)
                                WHERE  ep.eid = {?} AND ep.uid = {?}', $eid, $uid);
        while ($i = $res_->next()) {
            $u[$i['item_id']] = $i['nb'];
            $u['montant'] += $i['montant'] * $i['nb'];
        }
        $evt['telepaid'] += $u['telepayment'];
        $evt['adminpaid'] += $u['adminpaid'];
        $evt['paid'] += $u['paid'];
        $evt['topay'] += $u['montant'];
    }
    return $tab;
}
Example #3
Show file File: marketing.php Project: Ekleog/platal
0
 function handler_relance($page)
 {
     $page->changeTpl('marketing/relance.tpl');
     if (Post::has('relancer')) {
         global $globals;
         $nbdix = $globals->core->NbIns;
         $sent = array();
         $users = User::getBulkUsersWithUIDs($_POST['relance']);
         foreach ($users as $user) {
             if ($tmp = Marketing::relance($user, $nbdix)) {
                 $sent[] = $tmp . ' a été relancé.';
             }
         }
         $page->assign('sent', $sent);
     }
     $page->assign('relance', XDB::iterator('SELECT  r.date, r.relance, r.uid
                                               FROM  register_pending AS r
                                              WHERE  hash != \'INSCRIT\'
                                           ORDER BY  date DESC'));
 }
Example #4
Show file File: userfilter.php Project: Ekleog/platal
0
 public function getUsers($limit = null)
 {
     return User::getBulkUsersWithUIDs($this->getUIDs($limit));
 }
Example #5
Show file File: old_surveys.inc.php Project: Ekleog/platal
0
 public function toCSV($sep = ',', $enc = '"', $asep = '|')
 {
     $nbq = count($this->questions);
     //require_once dirname(__FILE__) . '/../../classes/varstream.php';
     VarStream::init();
     global $csv_output;
     $csv_output = '';
     $csv = fopen('var://csv_output', 'w');
     $line = $this->isMode(self::MODE_XIDENT) ? array('id', 'Nom', 'Prenom', 'Promo') : array('id');
     $qids = array();
     for ($qid = 0; $qid < $nbq; $qid++) {
         $qids[$qid] = count($line);
         // stores the first id of a question (in case of questions with subquestions)
         array_splice($line, count($line), 0, $this->questions[$qid]->getCSVColumns());
         // the first line contains the questions
     }
     $nbf = count($line);
     $users = array();
     if ($this->isMode(self::MODE_XIDENT)) {
         // if the mode is non anonymous
         $users = User::getBulkUsersWithUIDs(XDB::fetchAllAssoc('vid', 'SELECT  v.id AS vid, v.uid
                                                                          FROM  survey_votes AS v
                                                                         WHERE  v.survey_id = {?}
                                                                      ORDER BY  vid ASC', $this->id));
     }
     $sql = 'SELECT v.id AS vid, a.question_id AS qid, a.answer AS answer
               FROM survey_votes AS v
         INNER JOIN survey_answers AS a ON a.vote_id=v.id
              WHERE v.survey_id={?}
           ORDER BY vid ASC, qid ASC, answer ASC';
     $res = XDB::iterator($sql, $this->id);
     // retrieves all answers from database
     $vid = -1;
     $vid_ = 0;
     while (($cur = $res->next()) != null) {
         if ($vid != $cur['vid']) {
             // if the vote id changes, then starts a new line
             fputcsv($csv, $line, $sep, $enc);
             // stores the former line into $csv_output
             $vid = $cur['vid'];
             $line = array_fill(0, $nbf, '');
             // creates an array full of empty string
             $line[0] = $vid_;
             // the first field is a 'clean' vote id (not the one stored in database)
             if ($this->isMode(self::MODE_XIDENT)) {
                 // if the mode is non anonymous
                 if (array_key_exists($vid, $users)) {
                     // and if the user data can be found
                     $line[1] = $users[$vid]->lastName();
                     // adds the user data (in the first fields of the line)
                     $line[2] = $users[$vid]->firstName();
                     $line[3] = $users[$vid]->promo();
                 }
             }
             $vid_++;
         }
         $ans = $this->questions[$cur['qid']]->formatAnswer($cur['answer']);
         // formats the current answer
         if (!is_null($ans)) {
             if (is_array($ans)) {
                 $fid = $qids[$cur['qid']] + $ans['id'];
                 // computes the field id
                 $a = $ans['answer'];
             } else {
                 $fid = $qids[$cur['qid']];
                 $a = $ans;
             }
             if ($line[$fid] != '') {
                 // if this field already contains something
                 $line[$fid] .= $asep;
                 // then adds a separator before adding the new answer
             }
             $line[$fid] .= $a;
             // adds the current answer to the correct field
         }
     }
     fputcsv($csv, $line, $sep, $enc);
     // stores the last line into $csv_output
     return $csv_output;
 }
Example #6
Show file File: xnetgrp.php Project: Ekleog/platal
0
 function handler_awaiting_active($page)
 {
     global $globals;
     $page->changeTpl('xnetgrp/awaiting_active.tpl');
     XDB::execute('DELETE FROM  register_pending_xnet
                         WHERE  DATE_SUB(NOW(), INTERVAL 1 MONTH) > date');
     $uids = XDB::fetchColumn('SELECT  g.uid
                                 FROM  group_members         AS g
                           INNER JOIN  accounts              AS a ON (a.uid = g.uid)
                           INNER JOIN  register_pending_xnet AS p ON (p.uid = g.uid)
                                WHERE  a.uid = g.uid AND g.asso_id = {?} AND a.type = \'xnet\' AND a.state = \'pending\'', $globals->asso('id'));
     if (Post::has('again')) {
         S::assert_xsrf_token();
         $uids_to_again = array_intersect(array_keys(Post::v('again')), $uids);
         foreach ($uids_to_again as $uid) {
             $this->again($uid);
         }
         $page->trigSuccess('Relances effectuées avec succès.');
     }
     if ($uids) {
         $registration_date = XDB::fetchAllAssoc('uid', 'SELECT  uid, date
                                                           FROM  register_pending_xnet
                                                          WHERE  uid IN {?}', $uids);
         $last_date = XDB::fetchAllAssoc('uid', 'SELECT  uid, last_date
                                                   FROM  register_pending_xnet
                                                  WHERE  uid IN {?}', $uids);
         $users = User::getBulkUsersWithUIDs($uids);
         $page->assign('users', $users);
         $page->assign('registration_date', $registration_date);
         $page->assign('last_date', $last_date);
     }
 }
Example #7
Show file File: payment.php Project: Ekleog/platal
0
 function handler_payment_csv($page, $pid = null)
 {
     if (is_null($pid)) {
         pl_redirect('payment');
     }
     if (substr($pid, -4) == '.vcf') {
         $pid = substr($pid, 0, strlen($pid) - 4);
     }
     $res = XDB::fetchAllAssoc('SELECT  uid, IF(ts_confirmed = \'0000-00-00\', 0, ts_confirmed) AS date, comment, amount
                                  FROM  payment_transactions
                                 WHERE  ref = {?}
                              ORDER BY  ts_confirmed', $pid);
     if (is_null($res)) {
         pl_redirect('payment');
     }
     $users = User::getBulkUsersWithUIDs($res, 'uid', 'user');
     $sum = 0;
     pl_cached_content_headers('text/x-csv', 'iso-8859-1', 1);
     $csv = fopen('php://output', 'w');
     fputcsv($csv, array('Date', 'Nom', utf8_decode('Prénom'), 'Sexe', 'Promotion', 'Email', 'Commentaire', 'Montant'), ';');
     foreach ($users as $item) {
         $user = $item['user'];
         $sum += $item['amount'];
         fputcsv($csv, array(format_datetime($item['date'], '%d/%m/%y'), utf8_decode($user->lastName()), utf8_decode($user->firstName()), $user->isFemale() ? 'F' : 'M', $user->promo(), $user->ForlifeEmail(), utf8_decode($item['comment']), strtr($item['amount'], '.', ',') . ' EUR'), ';');
     }
     fputcsv($csv, array(date('d/m/y'), 'Total', '', '', '', '', '', strtr($sum, '.', ',') . ' EUR'), ';');
     fclose($csv);
     exit;
 }
Example #8
Show file File: xnetevents.php Project: Ekleog/platal
0
 function handler_admin($page, $eid = null, $item_id = null)
 {
     global $globals;
     $this->load('xnetevents.inc.php');
     $evt = get_event_detail($eid, $item_id);
     if (!$evt) {
         return PL_NOT_FOUND;
     }
     $page->changeTpl('xnetevents/admin.tpl');
     if (!$evt['show_participants'] && !may_update()) {
         return PL_FORBIDDEN;
     }
     if (may_update() && Post::v('adm')) {
         S::assert_xsrf_token();
         $member = User::getSilent(Post::v('mail'));
         if (!$member) {
             $page->trigError("Membre introuvable");
         }
         // change the price paid by a participant
         if (Env::v('adm') == 'prix' && $member) {
             $amount = strtr(Env::v('montant'), ',', '.');
             XDB::execute("UPDATE group_event_participants\n                                 SET paid = paid + {?}\n                               WHERE uid = {?} AND eid = {?} AND nb > 0\n                            ORDER BY item_id ASC\n                               LIMIT 1", $amount, $member->uid, $evt['eid']);
             subscribe_lists_event($member->uid, $evt['short_name'], 1, $amount);
         }
         // change the number of personns coming with a participant
         if (Env::v('adm') == 'nbs' && $member) {
             $res = XDB::query("SELECT SUM(paid)\n                                     FROM group_event_participants\n                                    WHERE uid = {?} AND eid = {?}", $member->uid, $evt['eid']);
             $paid = $res->fetchOneCell();
             // Ensure we have an integer
             if ($paid == null) {
                 $paid = 0;
             }
             $nbs = Post::v('nb', array());
             $paid_inserted = false;
             foreach ($nbs as $id => $nb) {
                 $nb = max(intval($nb), 0);
                 if (!$paid_inserted && $nb > 0) {
                     $item_paid = $paid;
                     $paid_inserted = true;
                 } else {
                     $item_paid = 0;
                 }
                 XDB::execute('INSERT INTO  group_event_participants (eid, uid, item_id, nb, flags, paid)
                                    VALUES  ({?}, {?}, {?}, {?}, {?}, {?})
                   ON DUPLICATE KEY UPDATE  nb = VALUES(nb), flags = VALUES(flags), paid = VALUES(paid)', $evt['eid'], $member->uid, $id, $nb, '', $item_paid);
             }
             $res = XDB::query('SELECT  COUNT(uid) AS cnt, SUM(nb) AS nb
                                  FROM  group_event_participants
                                 WHERE  uid = {?} AND eid = {?}
                              GROUP BY  uid', $member->uid, $evt['eid']);
             $u = $res->fetchOneAssoc();
             if ($paid == 0 && Post::v('cancel')) {
                 XDB::execute("DELETE FROM group_event_participants\n                                        WHERE uid = {?} AND eid = {?}", $member->uid, $evt['eid']);
                 $u = 0;
                 subscribe_lists_event($member->uid, $evt['short_name'], -1, $paid);
             } else {
                 $u = $u['cnt'] ? $u['nb'] : null;
                 subscribe_lists_event($member->uid, $evt['short_name'], $u > 0 ? 1 : 0, $paid);
             }
         }
         $evt = get_event_detail($eid, $item_id);
     }
     $page->assign_by_ref('evt', $evt);
     $page->assign('tout', is_null($item_id));
     if (count($evt['moments'])) {
         $page->assign('moments', $evt['moments']);
     }
     if ($evt['paiement_id']) {
         $infos = User::getBulkUsersWithUIDs(XDB::fetchAllAssoc('SELECT  t.uid, t.amount
                                               FROM  payment_transactions AS t
                                          LEFT JOIN  group_event_participants AS ep ON(ep.uid = t.uid AND ep.eid = {?})
                                              WHERE  t.status = "confirmed" AND t.ref = {?} AND ep.uid IS NULL', $evt['eid'], $evt['paiement_id']), 'uid', 'user');
         $page->assign('oublis', count($infos));
         $page->assign('oubliinscription', $infos);
     }
     $absents = User::getBulkUsersFromDB('SELECT  p.uid
                                            FROM  group_event_participants AS p
                                       LEFT JOIN  group_event_participants AS p2 ON (p2.uid = p.uid
                                                                                            AND p2.eid = p.eid
                                                                                            AND p2.nb != 0)
                                           WHERE  p.eid = {?} AND p2.eid IS NULL
                                        GROUP BY  p.uid', $evt['eid']);
     $ofs = Env::i('offset');
     $part = get_event_participants($evt, $item_id, UserFilter::sortByName(), NB_PER_PAGE, $ofs * NB_PER_PAGE);
     $nbp = ceil($evt['user_count'] / NB_PER_PAGE);
     if ($nbp > 1) {
         $links = array();
         if ($ofs) {
             $links['précédent'] = $ofs - 1;
         }
         for ($i = 1; $i <= $nbp; $i++) {
             $links[(string) $i] = $i - 1;
         }
         if ($ofs < $nbp - 1) {
             $links['suivant'] = $ofs + 1;
         }
         $page->assign('links', $links);
     }
     $page->assign('absents', $absents);
     $page->assign('participants', $part);
 }
Example #9
Show file File: xnetlists.php Project: Ekleog/platal
0
 function handler_sync($page, $liste = null)
 {
     if (!$this->get_lists_domain()) {
         return PL_NOT_FOUND;
     }
     if (!$liste) {
         return PL_NOT_FOUND;
     }
     $page->changeTpl('xnetlists/sync.tpl');
     $mlist = $this->prepare_list($liste);
     if (Env::has('add')) {
         S::assert_xsrf_token();
         $mlist->subscribeBulk(array_keys(Env::v('add')));
     }
     list(, $members) = $mlist->getMembers();
     $mails = array_map(create_function('$arr', 'return $arr[1];'), $members);
     $subscribers = array_unique($mails);
     global $globals;
     $ann = XDB::fetchColumn('SELECT  uid
                                FROM  group_members
                               WHERE  asso_id = {?}', $globals->asso('id'));
     $users = User::getBulkUsersWithUIDs($ann);
     $not_in_list = array();
     foreach ($users as $user) {
         if (!in_array(strtolower($user->forlifeEmail()), $subscribers)) {
             $not_in_list[] = $user;
         }
     }
     $page->assign('not_in_list', $not_in_list);
 }