$SET_T = $Cont->SET['table'][(string) $T]; //$sqlAccess = $T->accessSql(); $sqlAccess = (int) Usr()->superuser; $where = "\t" . $sqlAccess . " > 0 "; if (isset($vars['find'])) { $where .= "\tAND " . $T->find($vars['find'], 1); } $ShowFs = array(); foreach ($T->Fields() as $F) { if (!$SET_T['field'][(string) $F]['show']->v) { continue; } $ShowFs[] = $F; } if (isset($vars['search']) && $vars['search']) { $h = sqlSearchHelper($vars['search'], $ShowFs); $where .= ' AND ' . $h['where']; } $perPage = 10; $num = D()->one("SELECT count(*) FROM " . $T . " WHERE " . $where); $numPages = ceil($num / $perPage); $page = isset($vars['page']) ? (int) $vars['page'] : 1; $page = min($numPages, $page); $page = max(1, $page); $sql = "SELECT *, \t\t\t\t\t\t\t\t\t\t\t" . "\t" . $sqlAccess . " as _access\t\t\t\t\t\t" . "FROM \t\t\t\t\t\t\t\t\t\t\t\t" . "\t" . $T . " \t\t\t\t\t\t\t\t\t\t\t" . "WHERE\t\t\t\t\t\t\t\t\t\t\t\t" . "\t" . $where . " \t\t\t\t\t\t\t\t\t" . (isset($h['order']) ? "ORDER BY " . $h['order'] . "\t\t\t\t\t\t\t" : '') . "LIMIT " . ($page - 1) * $perPage . ", " . $perPage . " " . ""; $res = D()->query($sql); ?> <?php if (isset($vars['find']) && is_array($vars['find'])) {
static function searchUsr($s, $opts = array()) { $d = debug_backtrace(); $d = $d[0]; trigger_error('deprecated searchUsr ' . $d['file'] . ' :' . $d['line']); $Grps = Usr()->grps(); $sh = sqlSearchHelper($s, array('id', 'lastname', 'firstname', 'email', 'city')); $sql = " SELECT \t\t\t\t\t\t\t\t" . "\tid, email, firstname, lastname\t\t" . " FROM \t\t\t\t\t\t\t\t\t" . "\tusr\t\t\t\t\t\t\t\t\t" . " WHERE " . $sh['where'] . "\t\t\t\t" . (isset($opts['grp']) ? "\tAND id IN( SELECT usr_id FROM usr_grp WHERE grp_id = " . (int) $opts['grp'] . " )" : '') . " \tAND \t\t\t\t\t\t\t\t" . "\t( \t\t\t\t\t\t\t\t\t" . "\t\tid IN( SELECT usr_id FROM usr_grp WHERE grp_id IN(" . implode(',', $Grps) . ") )\t " . "\t)\t\t\t\t\t\t\t\t\t" . " ORDER BY " . $sh['order'] . "\t\t\t\t" . ""; $res = array(); $i = 0; foreach (D()->query($sql) as $vs) { if ($i++ > 10) { break; } $File = Usr($vs['id'])->Image; $imgSrc = @$File->url() . '/w-32/h-32/img.jpg'; $res[$vs['id']]['html'] = '<img src="' . $imgSrc . '" style="float:left; display:block; margin-right:3px">' . '<b>' . $vs['firstname'] . ' ' . $vs['lastname'] . '</b><br>' . '<i>' . $vs['email'] . '</i></div>'; $res[$vs['id']]['text'] = $vs['firstname'] . ' ' . $vs['lastname']; $res[$vs['id']]['value'] = $vs['id']; } return $res; }
<?php namespace qg; $search = isset($vars['search']) ? $vars['search'] : ''; $sh = sqlSearchHelper(addslashes($search), array('lastname', 'firstname', 'company', 'email')); $res = D()->query("SELECT * \t\t\t\t\t\t" . "FROM usr \t\t\t\t\t\t" . "WHERE " . $sh['where'] . " \t\t" . (isset($_GET['grp_id']) ? " AND id IN(SELECT usr_id FROM usr_grp WHERE grp_id = " . (int) $_GET['grp_id'] . ")" : "") . "ORDER BY " . $sh['order'] . " \t\t" . "LIMIT 200\t\t\t\t\t\t"); foreach ($res as $vs) { if ($vs['superuser'] && !Usr()->superuser) { continue; } $stat = D()->row(" SELECT count(distinct sess.id) as sessions \t\t" . " FROM sess \t\t\t\t\t\t\t\t\t\t" . " WHERE usr_id = '" . $vs['id'] . "' GROUP BY usr_id"); ?> <tr> <td> <a href="<?php echo Url($Cont->Page->url())->addParam('id', $vs['id']); ?> "> <?php echo hee($vs['firstname'] . ' ' . $vs['lastname']); ?> </a> <td> <?php $is = preg_match('/@/', $vs['email']); ?> <?php echo $is ? '<a href="mailto:' . $vs['email'] . '">' : ''; ?> <?php