/**
  * Returns sql where statement based on active user filters
  * @param string $extra sql
  * @param array named params (recommended prefix ex)
  * @return array sql string and $params
  */
 function get_sql_filter($extra = '', array $params = null)
 {
     list($filter, $params) = parent::get_sql_filter($extra, $params);
     // remove empty " AND " conditions at start, middle and end of filter
     $search = array('/^(?: AND )+/', '/(<= AND )(?: AND )+/', '/(?: AND )+$/');
     $filter = preg_replace($search, '', $filter);
     return array($filter, $params);
 }
Example #2
0
                    redirect($returnurl);
                } else {
                    if ($unlock and confirm_sesskey()) {
                        require_capability('moodle/user:update', $sitecontext);
                        if ($user = $DB->get_record('user', array('id' => $unlock, 'mnethostid' => $CFG->mnet_localhost_id, 'deleted' => 0))) {
                            login_unlock_account($user);
                        }
                        redirect($returnurl);
                    }
                }
            }
        }
    }
}
// create the user filter form
$ufiltering = new user_filtering();
echo $OUTPUT->header();
// Carry on with the user listing
$context = context_system::instance();
$extracolumns = get_extra_user_fields($context);
$columns = array_merge(array('firstname', 'lastname'), $extracolumns, array('city', 'country', 'lastaccess'));
foreach ($columns as $column) {
    $string[$column] = get_user_field_name($column);
    if ($sort != $column) {
        $columnicon = "";
        if ($column == "lastaccess") {
            $columndir = "DESC";
        } else {
            $columndir = "ASC";
        }
    } else {
Example #3
0
                     redirect($returnurl);
                 } else {
                     if ($unlock and confirm_sesskey()) {
                         require_capability('moodle/user:update', $sitecontext);
                         if ($user = $DB->get_record('user', array('id' => $unlock, 'mnethostid' => $CFG->mnet_localhost_id, 'deleted' => 0))) {
                             login_unlock_account($user);
                         }
                         redirect($returnurl);
                     }
                 }
             }
         }
     }
 }
 // create the user filter form
 $ufiltering = new user_filtering();
 $context = context_system::instance();
 //$extracolumns = get_extra_user_fields($context);
 $columns = array_merge(array('firstname', 'lastname', 'email'), array('city', 'country', 'lastaccess'));
 foreach ($columns as $column) {
     $string[$column] = get_user_field_name($column);
     if ($sort != $column) {
         $columnicon = "";
         if ($column == "lastaccess") {
             $columndir = "DESC";
         } else {
             $columndir = "ASC";
         }
     } else {
         $columndir = $dir == "ASC" ? "DESC" : "ASC";
         if ($column == "lastaccess") {
Example #4
0
 /**
  * Returns sql where statement based on active user filters.  Overridden to provide proper
  * 'show inactive' default condition.
  *
  * @param string $extra sql
  * @return string
  */
 function get_sql_filter($extra = '')
 {
     global $SESSION;
     $newextra = '';
     // Include default SQL if inactive filter has not been included in list
     if (empty($SESSION->user_filtering) || !isset($SESSION->user_filtering['inactive']) || !$SESSION->user_filtering['inactive']) {
         $newextra = ($extra ? $extra . ' AND ' : '') . 'inactive=0';
     }
     return parent::get_sql_filter($newextra);
 }
Example #5
0
 if (!empty($interestedusers)) {
     print_heading(get_string('similarusers', 'block_tao_team_groups'));
     foreach ($interestedusers as $u) {
         // not efficient but want to ensure getting all user fields. consider changing.
         $useri = get_record('user', 'id', $u->id);
         echo "<a href='{$CFG->wwwroot}/user/view.php?id={$groupid}&course={$courseid}'>" . fullname($useri) . "</a>\n                      <a href='{$CFG->wwwroot}/blocks/tao_team_groups/managegroup.php?id={$courseid}&groupid={$groupid}&action=inviteuser&userid={$u->id}'>" . get_string('invitethisuser', 'block_tao_team_groups') . "</a><br/>";
     }
 }
 print_heading(get_string('searchforusers', 'block_tao_team_groups'));
 if ($CFG->groupmax > $i + $invitecount) {
     //check if max number of group members has not been exceeded and print invite link.
     echo "<p>" . get_string('searchforusersdesc', 'block_tao_team_groups') . "</p>";
     //print search form
     $site = get_site();
     // create the user filter form
     $ufiltering = new user_filtering(array('realname' => 0, 'lastname' => 1, 'firstname' => 1, 'email' => 0, 'city' => 1, 'country' => 1, 'profile' => 1, 'mnethostid' => 1), null, array('id' => $courseid, 'groupid' => $groupid, 'perpage' => $perpage, 'page' => $page, 'sort' => $sort, 'dir' => $dir));
     $extrasql = $ufiltering->get_sql_filter();
     if (!empty($extrasql)) {
         //don't bother to do any of the following unless a filter is already set!
         //exclude users already in a group inside this course.
         $extrasql .= "AND id NOT IN (SELECT userid \n                                  FROM {$CFG->prefix}groups_members gm, {$CFG->prefix}groups g \n                                  WHERE g.courseid={$courseid} AND g.id=gm.groupid) ";
         //exclude users already invited.
         $extrasql .= "AND id NOT IN (SELECT userid\n                                  FROM {$CFG->prefix}group_invites\n                                  WHERE courseid={$courseid} AND groupid={$groupid} ) ";
         $columns = array("firstname", "lastname", "city", "country", "lastaccess");
         foreach ($columns as $column) {
             $string[$column] = get_string("{$column}");
             if ($sort != $column) {
                 $columnicon = "";
                 if ($column == "lastaccess") {
                     $columndir = "DESC";
                 } else {