include_once $class_path . "user_html.inc.php";
$site = new Site(array(on_debug => $_COOKIE["debug"] ? 1 : 0, on_admin_keel => 1));
if (!$site->user->allowed_adminpage()) {
    exit;
}
######### get adminpage name
$adminpage_names = get_adminpage_name(array("script_name" => $site->script_name));
$parent_pagename = $adminpage_names['parent_pagename'];
$pagename = $adminpage_names['pagename'];
global $read_allowed_groups;
global $all_levels;
global $selected_parents;
global $column_count;
###########
# PERMISSIONS CHECK - get read-allowed group ID-s for current user
$read_allowed_groups = get_allowed_groups();
#echo printr($read_allowed_groups);
$top_group = get_topparent_group(array("site" => $site));
########### find user_id & group_id & role_id (what was selected in selectbox)
if ($site->fdat['selected_group']) {
    list($type, $sel_id) = split(":", $site->fdat['selected_group']);
    $site->fdat['user_id'] = $type == 'user_id' ? $sel_id : '';
    $site->fdat['group_id'] = $type == 'group_id' ? $sel_id : '';
    $site->fdat['role_id'] = $type == 'role_id' ? $sel_id : '';
    if ($type == 'user_id') {
        $site->fdat['group_id'] = get_my_group(array("who" => $site->fdat['selected_group']));
    }
} else {
    $site->fdat['selected_group'] = 'group_id:' . $site->fdat['group_id'];
}
#echo $site->fdat['selected_group']. " gr:".$site->fdat['group_id'];
示例#2
0
    print_error('move_notselected', 'forumng');
}
$discussion = mod_forumng_discussion::get_from_id($d, $cloneid);
// Get target forum.
$targetforum = mod_forumng::get_from_cmid($target, mod_forumng::CLONE_DIRECT);
// If it is a clone, find the original.
$targetforum = $targetforum->get_real_forum();
$targetcmid = $targetforum->get_course_module_id();
// Check permission for move.
$aag = permission_to_move($discussion, $targetforum);
// Work out target group for move.
$targetgroup = get_target_group($discussion, $targetforum, $aag);
$groupmode = $targetforum->get_group_mode();
$options = array();
if ($groupmode && !$targetgroup) {
    $options = get_allowed_groups($targetforum, $aag);
    // If there's only one then we'll use it.
    if (count($options) == 1) {
        reset($options);
        $targetgroup = key($options);
    } else {
        if (count($options) == 0) {
            print_error('move_nogroups', 'forumng');
        }
    }
}
if (!$targetgroup && $groupmode > 0) {
    // User needs to choose one from form.
    $targetgroup = get_target_group_from_user($targetforum, $cloneid, $d, $pageparams, $discussion, $options);
}
// Perform move.
 public function definition()
 {
     global $CFG, $USER;
     $mform = $this->_form;
     $pageparams = $this->_customdata['params'];
     $target = $this->_customdata['params']['target'];
     $forumngid = $this->_customdata['params']['id'];
     $cloneid = $this->_customdata['params']['clone'];
     $multigroups = $this->_customdata['params']['multigroups'];
     $targetgroupmode = $this->_customdata['params']['targetgroupmode'];
     $targetforum = $this->_customdata['targetforum'];
     $pageparams = $this->_customdata['params'];
     foreach ($pageparams as $param => $value) {
         $mform->addElement('hidden', $param, $value);
         $mform->setType($param, PARAM_INT);
     }
     $selectedids = array();
     foreach ($pageparams as $field => $value) {
         $matches = array();
         if (!is_array($value) && (string) $value !== '0' && preg_match('~^selectd([0-9]+)$~', $field, $matches)) {
             $selectedids[] = $matches[1];
         }
     }
     // Get list of allowed groups.
     $options = array();
     // Check to see whether target forum uses group mode.
     if ($targetgroupmode) {
         $options = get_allowed_groups($targetforum, false);
     }
     // Informational paragraph.
     $mform->addElement('static', '', '', get_string('move_discussions_group_info', 'forumngfeature_move', $targetforum->get_name()));
     // Get group from user.
     $mform->addElement('select', 'chosengroup', get_string('group'), $options);
     reset($options);
     $mform->setDefault('group', key($options));
     $this->add_action_buttons(true, get_string('movediscussions', 'forumngfeature_move'));
 }
function print_users_table(){

	global $site;
	global $class_path;
	
	global $group; # selected 1 group info
	global $user; # selected 1 user info

	$args = func_get_arg(0);

	include_once($class_path."adminpage.inc.php");
	include_once($class_path."custom.inc.php");

	###########
	# PERMISSIONS CHECK - get read-allowed group ID-s for current user
	$read_allowed_groups = get_allowed_groups();
	#echo printr($read_allowed_groups);

?>


<?
############################
# CONTENT TABLE
?>
	<TABLE class="scms_content_area" width="100%" height="100%" border=0 cellspacing=0 cellpadding=0>
	<TR>
		<!-- Left column -->
		<TD class="scms_left">
			<TABLE border=0 width="100%" height="100%" cellspacing=0 cellpadding=0>
			<!-- Search -->
			<TR>
				<TD id="search">
					<?
					#################
					# SEARCH BOX
					print_search_box(array(
						"hide_end_form_tag" => $args['show_checkboxes']	// if we need to show checkboxes, don't print end form tag
					));
					?>				
				</TD>
			</TR>
			<!-- //Search -->
			<TR>
				<TD valign=top>
					<div id=navigation class="scms_left_div">
					<TABLE width="100%" border="0" cellpadding="0" cellspacing="0">
					<?
						/*
						 * Get favorites 
						*/
						$favorites = $site->user->get_favorites(array(
							fetch_user_favorits => 1,
							fetch_group_favorits => 1,
						));
						if(count($favorites)>0) {
					?>
						<!-- Favorites -->
						<tr>
							<td class="scms_groupheader">
								<IMG SRC="<?=$site->CONF['wwwroot'].$site->CONF['styles_path']?>/gfx/icons/16x16/actions/bookmark.png" WIDTH="16" HEIGHT="16" BORDER="0" ALT="" align=absmiddle>&nbsp;&nbsp;<?=$site->sys_sona(array(sona => "Favorites", tyyp=>"admin"))?>
							</td>
						</tr>
						<TR>
							<TD>
								<table border=0>
								<?
									/*
									* Display favorites
									*/

									foreach($favorites as $favorite_data) {
								?>
									<tr>
										<td style="padding-right:4px;padding-left:16px"><img src="<?=$site->CONF['wwwroot'].$site->CONF[styles_path]?>/gfx/icons/16x16/users/<?= (strlen($favorite_data['group_id'])>0?'group':($favorite_data['is_superuser']?'superuser':'******')) ?>.png" width="16" height="16"></td>
										<td><a href="javascript:<?= strlen($favorite_data['group_id'])>0?"select_group('".$favorite_data['group_id']."')":"document.getElementById('selectform_user_id').value='".$favorite_data['user_id']."';document.getElementById('selectform_group_id').value='".$favorite_data['user_group_id']."';document.forms['selectform'].submit();"; ?>"><?= strlen($favorite_data['group_id'])>0?$favorite_data['name']:$favorite_data['firstname'].' '.$favorite_data['lastname'] ?></a></td>
									</tr>
								<?
									} //foreach
								?>
								</table>
							</TD>
						</TR>
						<!-- //Favorites -->
						<?
							} //if favorites
						?>
						<!-- Menu tree -->
						<TR>
							<TD>
								<?
								#################
								# GROUPS TREE: 2 views - tree & search result list

								#### GROUP WHERE
								if($site->user->is_superuser) { 
									$group_where_str = " 1=1 "; 
								}
								else { 
									# $group_where_str = $site->db->prepare(" FIND_IN_SET(group_id,?) ", join(",",$read_allowed_groups));
									$group_where_str = " group_id IN('".join("','", $read_allowed_groups)."') ";

								}

								###### GET tree html
								$tree_html = get_grouptree_html(array(
									 "where_str" => $group_where_str,
									 "expand_all"  => $args['expand_all'],
									 "show_checkboxes" => $args['show_checkboxes']
								));
								###### PRINT tree html
								if ($args['show_checkboxes']){
									echo "</form>";
								}
								?>
								
								<?echo $tree_html; ?>          
								
								<?
								# / GROUPS TREE
								#################
								?>
							</TD>
						</TR>
						<!-- //Menu tree -->
					</TABLE>
					</div>
				</TD>
			</TR>
			</TABLE>
		<!-- // Left column -->
		</TD>
	<?
	# / LEFT COLUMN
	##################
?>

<?

# if not browse window
if($args['is_browse']) { $site->fdat['view']='overview_false'; }

############################
# MIDDLE LIST

	#################
	# USERS WHERE

	$where_sql[] = $group_where_str;

	# group filter
	if($site->fdat['group_id'] && !$site->fdat['flt_role']) {
		# 1. if search criteria is defined, then search from all current open subtree
		if($site->fdat['search'] && $site->fdat['user_search'] && $site->fdat['search_subtree']) {
			########## a) user search AND group search BOTH	=>  use group search result
			if($site->fdat['group_search']) {
#				$where_sql[] = $site->db->prepare("FIND_IN_SET(group_id,?)",join(',',$group_search_result));
			}
			########## b) user search AND NOT group search => don't use group filter at all
			else {
				/*
				# variant 2 => use group menu
				$menu->get_full_subtree(array("parent_id" => $site->fdat['group_id']));
				# $menu->full_subtree is variable from group tree and is all ID-s of group children
				$tree_with_children = $menu->full_subtree;
				#echo printr($tree_with_children);
				$where_sql[] = $site->db->prepare("FIND_IN_SET(group_id,?)",join(',',$tree_with_children));
				*/
			}
		}
		# 2. if no search criteria, then show only users belonging to current group
		else {
			$where_sql[] = $site->db->prepare("group_id=?",$site->fdat['group_id']);
		}
	}
	# user search filter, search from fixed fields ()
	if($site->fdat['search'] && $site->fdat['user_search']) {
		$where_sql[] = $site->db->prepare("(username LIKE ? OR firstname LIKE ? OR lastname LIKE ? OR email LIKE ?)",
			$site->fdat['search'].'%',
			$site->fdat['search'].'%',
			$site->fdat['search'].'%',
			$site->fdat['search'].'%'
		);
	}
	# user role filter, search from user_roles
	if($site->fdat['flt_role']) {
		$where_sql[] = $site->db->prepare("(user_roles.role_id = ?)",
			$site->fdat['flt_role']
		);
		### extra JOIN needed
		$join = " LEFT JOIN user_roles ON user_roles.user_id = users.user_id ";
	}

	$where = is_array($where_sql) ? " WHERE ".join(" AND ",$where_sql) : '';

	### if search is used then set page to null
	if(!isset($site->fdat['page']) && ($site->fdat['search'] || $site->fdat['flt_role']) ) { $site->fdat['page'] = 0;}

	# / USERS WHERE
	#################

?>
<!-- Middle column -->
<TD class="scms_middle<?=($site->fdat['view']=='overview_true' ? "" : "_dialogwindow")?>" >

	<TABLE style="width: 98%" height="100%" border="0" cellspacing="0" cellpadding="0">
		<!-- Table title -->
		<TR height=25>
		<TD>

			<?######### grey title header ########?>

				<table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr class="scms_pane_header"> 
                     <td>			
					  <IMG SRC="<?=$site->CONF['wwwroot'].$site->CONF['styles_path']?>/gfx/icons/16x16/users/user.png" WIDTH="16" HEIGHT="16" BORDER="0" ALT="" align=absmiddle> <?=$site->sys_sona(array(sona => "users", tyyp=>"admin"));?>
					 </td>
					 <td align="right">
					 </td>
					 <td style="width:120px">
						<!-- Paging -->
						<?
						#################
						# pagenumbers table
						$sql = "SELECT COUNT(*) FROM users ".$join.$where;
						$sth = new SQL($sql);
						$total_count = $sth->fetchsingle();
						
						$pagenumbers = print_pagenumbers(array(
							"total_count" => $total_count,
							"rows_count" => 20,
						));
						# / pagenumbers 
						#################
						?>			
						<!-- //Paging -->
					 </td>
                    </tr>
                 </table>
			<?######### / grey title header ########?>


		</TD>
	</TR>
	<!-- // Table title -->

		 
 <?
	#################
	# table column names
	?>
	<!-- Table heading -->
	<TR height=25>
	<TD class="scms_tableheader">

	<?
	####### get assoc.array of visible fieldnames and translations
	$visible_fields = get_visible_fields(array(
		"prefpage_name" => ($args['is_browse'] ?'select_group':'user_management_fields'),
		"sst_name" => 'custom,kasutaja',
	));
#printr($visible_fields);
	####### print column headers table
	print_column_headers(array(
		"visible_fields" => $visible_fields,
		"page_prefs_url" => '&name='.($args['is_browse'] ?'select_group':'user_management_fields').'&sst_name=custom,kasutaja'
	));
	##### td width: calculate percents
	$td_width = intval((100/sizeof(array_keys($visible_fields)))).'%';

	?>
	</TD>
	</TR>
	<!-- //Table heading -->

	<?
	# / COLUMN NAMES
	#################
	?>
		<!-- Table data -->
		<TR>
			<TD valign=top>
					<!-- Scrollable area -->
					<div id=listing class="scms_middle_div">
						<table width="100%" border="0" cellspacing="0" cellpadding="0" class="scms_table">
<?
	#################
	# users list

	########### ORDER
	$order = " ORDER BY ".$site->fdat['sortby']." ".$site->fdat['sort'];

	########### SQL

 	$sql = $site->db->prepare("SELECT users.* FROM users ");
	$sql .= $join;
	$sql .= $where;
	$sql .= $order;
	$sql .= $pagenumbers['limit_sql'];

#print $sql;
	$sth = new SQL($sql);
	$listusers = array();
	while($tmp = $sth->fetch()){
		$listusers[] = $tmp;
	}
		#################
		# loop over users
		$i = 0;
		foreach($listusers as $listuser){
			$next_id = 	$listusers[$i+1]['user_id'];
			$prev_id = 	$listusers[$i-1]['user_id'];
			
			
#			$href = "?group_id=".$listuser[group_id]."&user_id=".$listuser[user_id];
#			$href .= "&page=".$site->fdat['page'];
$href = "javascript:document.getElementById('selectform_user_id').value='".$listuser[user_id]."';document.getElementById('selectform_group_id').value='".$listuser[group_id]."';document.getElementById('selectform_user_next_id').value='".$next_id."';document.getElementById('selectform_user_prev_id').value='".$prev_id."';document.forms['selectform'].submit();";

			# user is spueruser
			if($listuser['is_predefined']) {$icongif = "superuser.png"; }
			# ordinary user, not Everybody group member 
			else { $icongif = "user.png"; }
		?>
          <tr id="<?=$listuser[user_id]?>" <?=($site->fdat['user_id'] == $listuser[user_id] ? ' class="scms_activerow"' : '')?>>
			<?##### icon ######?>
			<td width="20"><img src="<?=$site->CONF['wwwroot'].$site->CONF['styles_path']?>/gfx/icons/16x16/users/<?=$icongif?>" width="16" height="16"></td>

			<?# loop over visible fields
			foreach(array_keys($visible_fields) as $key=>$field){ 
				if($field=='fullname'){ $listuser[$field] = $listuser['firstname'].' '.$listuser['lastname']; }

				?>
				<td width="<?=$td_width?>" ondblclick="javascript:void(openpopup('<?=$site->CONF['wwwroot'].$site->CONF['adm_path']?>/edit_user.php?user_id=<?=$listuser[user_id]?>&tab=user&op=edit','user','366','450'))"><a href="<?=$href?>"><?=($listuser[$field] ? $listuser[$field] : '&nbsp;')?></a></td>
			<? } # foreach ?>
			<?##### delete ######?>
<!--			<td width="16" align="right">&nbsp;</td>-->
		
			</tr>
		<?
			$i++;
		}
		# / loop over users
		#################
		?>
					  </table>
					</div>
					<!-- //Scrollable area -->
                </TD>
              </TR>
			<!-- //Table data -->

            </TABLE>
		</TD>
<?
# / MIDDLE LIST
############################
?>



		</TD>
  </TR>
		<?
		###################
		# select buttons
		if($args['is_browse']){
		?>
        <tr align="right" height=30> 
          <td valign="top" colspan="2" style="padding-top: 10px; padding-right:10px" > 

<? if ($args['show_checkboxes']){ ?>
			<input type="button" value="<?=$site->sys_sona(array(sona => "vali", tyyp=>"admin")) ?>" onclick="javascript:selectform.op2.value='selectclose'; send_box_values();" style="width: 60px">
<? } else { ?>
            <input type="button" value="<?=$site->sys_sona(array(sona => "vali", tyyp=>"admin")) ?>" onclick="javascript:selectform.op2.value='selectclose';selectform.submit();" style="width: 60px">
<? } ?>
			<input type="button" value="<?=$site->sys_sona(array(sona => "close", tyyp=>"editor")) ?>" onclick="javascript:window.close();" style="width: 60px"> 
          </td>
        </tr>
		<?}?>
</TABLE>

<?
}