0

Id like to show total number of users elsewhere on my site, and dont know which part of the following code calls that.

I want to have 'some text[number of users here], and counting!'

I need to strip out only the minimum code to display the total number within another php page. please help, I have no idea of php.

<?php if (!defined('APPLICATION')) exit();
 
class UserListModule extends Gdn_Module {
   
   public function __construct(&$Sender = '') {
      parent::__construct($Sender);
   }
   
   public function GetData() {
   	 $SQL = Gdn::SQL();
     $Session = Gdn::Session();
     $Random = Gdn::Config('UserList.Random');
     $Limit = Gdn::Config('UserList.Limit');
     $NoPhoto = Gdn::Config('UserList.NoPhoto');
     
     $Select='u.UserID, u.Name, u.Photo';
     $From='User u';
     $Where=array('u.Deleted'=>0,'r.RoleID>'=>7);
     
     if($Random && $NoPhoto) {
        	$Order='RAND()';
     } else if((!$NoPhoto) && ($Random)) {
        	$Where['u.Photo >']=0;
	       	$Order='RAND()';
     } else if(!$NoPhoto) {
        	$Where['u.Photo >']=0;
        	$Order='u.UserID';
     } else {
        	$Order='u.UserID';
     }
     
     $this->Users = $SQL
    	    ->Select($Select)
        	->From($From)
        	->Join('UserRole r','u.UserID = r.UserID')
        	->Where($Where)
        	->Get();
     
     $this->All_Users = $SQL
    	    ->Select('u.UserID')
        	->From('User u')
        	->Join('UserRole r', 'u.UserID = r.UserID')
        	->Where(array('u.Deleted'=>0,'r.RoleID>'=>7))
        	->Get();

   }

   public function AssetTarget() {
      return 'Panel';
   }

   public function ToString() {
      $String = '';
      $Session = Gdn::Session();
	  $permissions=$Session->User->Permissions;
	  $admin=preg_match('/Garden.Settings.Manage/',$permissions);
	  
      ob_start();
      $Limit = Gdn::Config('UserList.Limit');
      $Photo = Gdn::Config('UserList.Photo');
      $Title = Gdn::Config('UserList.Title');
      $ShowNumUsers = Gdn::Config('UserList.ShowNumUsers');
      
      if(empty($Title)) {
      	$Title="Members";
      }
      
      if($Photo) {
      ?>
      <style type="text/css">
#UserList ul.PanelInfo li {
	border: 0!important;
	float: left;
	width: 25%;
	padding: 5px 0 0 0;
}
#UserList img {
	height: 48px;
	width: 48px;
}
#UserList ul.PanelInfo li {
	text-align: center!important;
}
</style>
<?php } ?>
<style type="text/css">
#UserList ul.PanelInfo li a {
	float: none;
}
#UserList ul.PanelInfo li {
	text-align: left;
}
</style>
      <div id="UserList" class="Box">
         <h4><?php echo $Title;
         if($ShowNumUsers) echo " (".$this->All_Users->NumRows().")"; ?></h4>
         <ul class="PanelInfo">
            <?php
			if($this->Users->NumRows() > 0) { 
               foreach($this->Users->Result() as $User) {
                  ?>
                  <li>
                     <?php
                     if($Photo) {
	                     if(!empty($User->Photo)) {
		                    echo "<a href=\"".Url('/profile/'.$User->Name)."\"><img src=\"".Url('uploads/'.ChangeBasename($User->Photo, 'n%s'))."\" alt=\"".$User->Name."\" title=\"".$User->Name."\" /></a><br />";
	    	             } else {
	        	         	echo "<a href=\"".Url('/profile/'.$User->Name)."\"><img src=\"".Url('plugins/UserList/user.png')."\" alt=\"".$User->Name."\" title=\"".$User->Name."\" /></a><br />";
	            	     }
	            	 } else {
	            	 	echo UserAnchor($User);
	            	 }
                     ?>
                  </li>
                  <?php
                  }
               } else {
	               if($admin) {
	               	 echo "<p>No users to display. Try <a href=\"".Url('plugin/userlist')."\">changing your settings</a>.</p>";
	               } else {
	                 echo "<p>No users to display.</p>";
	               }
               }
            ?>
         </ul>
         <div style="clear:both;"></div>
      </div>
      <?php
      $String = ob_get_contents();
      @ob_end_clean();
      return $String;
   }
}
3
Contributors
13
Replies
14
Views
6 Years
Discussion Span
Last Post by Inny
0

You're using a class to get db info.

This is the format for sql query:

$this->Users = $SQL
    	    ->Select($Select)
        	->From($From)
        	->Join('UserRole r','u.UserID = r.UserID')
        	->Where($Where)
        	->Get();

From what I can see, you pass key info so that the parent class builds an SQL statement and returns a resultset.

$this->Users->NumRows()

Will give you the number of rows returned by the query. As it's there already, you could use this. I don't know if this will give you all the users though - just specific types due to the where and join clauses. Or you could use a different query altogether:

$Select = "count(*) c";
$From = "User"
$this->UserNo = $SQL
    	    ->Select($Select)
        	->From($From)
        	->Get();

echo $UserNo->c
0

Thankyou Friend, but Im totally clueless with php, Ive never written any!

How do I write that so it outputs correctly (just the number) in following code where Ive added *I need it here* please ?

I tried to insert that as is, and got error.

<?php echo '<?xml version="1.0" encoding="utf-8"?>'; 
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-ca">
<link rel="shortcut icon" href="http://www.camosreptiles.com.au/forum/themes/camo/design/favicon.png" type="image/x-icon" />
<script type="text/javascript">
if(document.location.protocol=='http:'){
 var Tynt=Tynt||[];Tynt.push('dLsjCWJcGr4lVVadbi-bpO');Tynt.i={"ap":"Read more:"};
 (function(){var s=document.createElement('script');s.async="async";s.type="text/javascript";s.src='http://tcr.tynt.com/ti.js';var h=document.getElementsByTagName('script')[0];h.parentNode.insertBefore(s,h);})();
}
</script>
<div id="fb-root"></div>
<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) {return;}
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

      

<head>
   <?php $this->RenderAsset('Head'); ?>
</head>
<body id="<?php echo $BodyIdentifier; ?>" class="<?php echo $this->CssClass; ?>">
   <div id="Frame">
      <div id="Head">
         <div class="Menu">

            <a class="Title" href="<?php echo Url('/'); ?>"><span><?php echo Gdn_Theme::Logo(); ?></span></a><span style="position:absolute;top:10px;"><link href="https://chatserver.comm100.com/css/comm100_livechatbutton.css" rel="stylesheet" type="text/css"/><div align="center" id="comm100_ChatButton"><div id="comm100_warp"><center><div id="comm100_dvhelp"><a class="comm100_ahelp_css" href="http://www.comm100.com/livechat/" onclick="comm100_Chat();return false;" target="_blank" title="Live Chat Software for Website"><img id="comm100_ButtonImage" src="https://chatserver.comm100.com/BBS.aspx?siteId=87351&amp;planId=1471&amp;partnerId=-1" style="border:0px" alt="Live Chat Software for Website" /></a><script src="https://chatserver.comm100.com/js/LiveChat.js?siteId=87351&amp;planId=1471&amp;partnerId=-1" type="text/javascript"></script><div id="comm100_track"><a href="http://www.comm100.com/livechat/" target="_blank"><b>Live Chat</b></a> by <a style="color:#009999;cursor:pointer;" onclick="javascript:document.getElementById('comm100_dvbox').style.display='';">Comm100</a></div></div><div id="comm100_dvbox" class="comm100_dvbox_css" style="display:none;" onmouseover="this.style.display=''" onmouseout="this.style.display='none'"><div class="comm100_dvcontent_css"><p class="comm100_ptitle_css"><b><a href="http://www.comm100.com/" target="_blank" class="comm100_atitle_css" >Comm100</a> Products:</b></p><ul class="comm100_ulbox_css"><li style="display:none;" class="comm100_onelinone">&nbsp;</li><li><a href="http://www.comm100.com/" target="_blank">Customer Service Software</a></li><li><a href="http://www.comm100.com/livechat/" target="_blank" >Live Chat Software</a></li><li><a href="http://www.comm100.com/emailmarketingnewsletter/" target="_blank">Email Marketing Software</a></li><li><a href="http://www.comm100.com/livechat/" target="_blank">Live Help</a></li><li><a href="http://www.comm100.com/emailmarketingnewsletter/" target="_blank">Email Marketing</a></li><li><a href="http://www.comm100.com/livechat/" target="_blank">Live Support</a></li></ul></div></div></center></div></div></span><center><div class="fb-like" data-href="http://www.camosreptiles.com.au/forum/index.php?p=/" data-send="false" data-layout="button_count" data-width="55" data-show-faces="false"></div></center><span style="position:absolute;top:10px;right:10px"><a href="http://www.camosreptiles.com.au/shop.php"target='_blank'><img src="http://www.camosreptiles.com.au/herpfulthingsc.gif"/></a><br>
&nbsp;<b><a href="/index.php">WEBSITE HOME</a>&nbsp;&nbsp;~&nbsp;&nbsp;<a href="/classifieds/">CLASSIFIEDS</a></b></span>



*I need it here please*



            <?php
			      $Session = Gdn::Session();
					if ($this->Menu) {
						$this->Menu->AddLink('Dashboard', T('Dashboard'), '/dashboard/settings', array('Garden.Settings.Manage'));
						// $this->Menu->AddLink('Dashboard', T('Users'), '/user/browse', array('Garden.Users.Add', 'Garden.Users.Edit', 'Garden.Users.Delete'));
						$this->Menu->AddLink('Activity', T('Activity'), '/activity');
						if ($Session->IsValid()) {
							$Name = $Session->User->Name;
							$CountNotifications = $Session->User->CountNotifications;
							if (is_numeric($CountNotifications) && $CountNotifications > 0)
								$Name .= ' <span class="Alert">'.$CountNotifications.'</span>';

                     if (urlencode($Session->User->Name) == $Session->User->Name)
                        $ProfileSlug = $Session->User->Name;
                     else
                        $ProfileSlug = $Session->UserID.'/'.urlencode($Session->User->Name);
							$this->Menu->AddLink('User', $Name, '/profile/'.$ProfileSlug, array('Garden.SignIn.Allow'), array('class' => 'UserNotifications'));
							$this->Menu->AddLink('SignOut', T('Sign Out'), SignOutUrl(), FALSE, array('class' => 'NonTab SignOut'));
						} else {
							$Attribs = array();
							if (SignInPopup() && strpos(Gdn::Request()->Url(), 'entry') === FALSE)
								$Attribs['class'] = 'SignInPopup';
								
							$this->Menu->AddLink('Entry', T('Sign In'), SignInUrl(Url('')), FALSE, array('class' => 'NonTab'), $Attribs);
						}
						echo $this->Menu->ToString();
					}
				?>
            <div class="Search"><?php
					$Form = Gdn::Factory('Form');
					$Form->InputPrefix = '';
					echo 
						$Form->Open(array('action' => Url('/search'), 'method' => 'get')),
						$Form->TextBox('Search'),
						$Form->Button('Go', array('Name' => '')),
						$Form->Close();
				?></div>
         </div>
      </div>
      <div id="Body">
         <div id="Content"><?php $this->RenderAsset('Content'); ?>




<center><script>
var linkwithin_site_id = 911777;
</script>
<script src="http://www.linkwithin.com/widget.js"></script>
<div class="linkwithin_div"></center>
<br>
<br>
<style type="text/css">
	/* The box container div with id 258791 */
	div#rssincl-box-258791 {
		width: 500px; /* sets the width of your RSSbox */
		overflow-x: auto; /* sets a scrollbar if the content is larger than 350px */
	}
 
	/* All elements inside the box container */
	div#rssincl-box-258791 *{
		font-family: Arial, Helvetica, sans-serif; /* sets the font family for all elements within the RSSbox */
		text-align:left; /* sets text-align to left for all elements*/
		margin:0; /* sets margin to zero for all elements*/
		padding:0; /* sets padding to zero for all elements*/
		line-height:110%; /* sets the line-height a bit greater than normal*/
		clear:both; /* no floating in general */
	}
 
	/* The div around the title */
	div#rssincl-box-258791 div.rssincl-head {
		padding:10px; /* sets the padding to 10px*/
                /* set the url to a gradient background image */
		background-image:url('http://www.camosreptiles.com.au/scales.jpg');
		background-repeat:repeat;
                         background-attachment:fixed;
 
		background-color: transparent; 
	}
 
	/* The <p> which contains the title of the box, and the <a> tag wrapped around the title (if used) */
	div#rssincl-box-258791 div.rssincl-head p.rssincl-title,
	div#rssincl-box-258791 div.rssincl-head p.rssincl-title a {
		font-size: 18px; /* sets the font size of the title to 18px*/
		font-weight:bold; /* and bold of course */
		color: transparent; /* colors the title white */
		text-decoration:none; /* no underline */
	}
 
	/* The div around the content elements / news items */
	div#rssincl-box-258791 div.rssincl-content {}
 
	/* The div around each news item */
	div#rssincl-box-258791 div.rssincl-content div.rssincl-entry {
		padding:10px; /* padding to 10px again */
                /* url to gradient background-image */
		background-image:url('http://www.camosreptiles.com.au/scales.jpg');
		background-repeat:repeat-repeat;
                background-attachment:fixed;
		background-color: #F8F8F8; /* background-color when image is not shown */
		border-bottom:0px; /* set grey border bottom */
		border-left:0px; /* set grey border left */
		border-right:0px; /* set grey border right */
	}
 
	/* The <p> tag containing the news item title */
	div#rssincl-box-258791 div.rssincl-content div.rssincl-entry p.rssincl-itemtitle {
		padding:5px; /* padding of title to 5px*/
		padding-left:25px; /* left padding to 25px because of background image (arrow) */
                /* set the url to a background image  */
		background-image:url('http://www.rssinclude.com/assets/web/images/tutorial/rssinclude_arrow.gif');
		background-repeat:no-repeat; /* don't repeat it */
		background-position:0px 0px; /* positioning of background image*/
		margin-bottom:0px; /* margin below the item title*/
	}
 
	/* The <a> tag wrapped around the news item title */
	div#rssincl-box-258791 div.rssincl-content div.rssincl-entry p.rssincl-itemtitle a {
		font-size: 18px; /* font size to 14px */
		font-weight:bold; /* bold */
		text-decoration:underline; /* lets it look like a link */
		color: #000000;	 /* dark grey */
	}
 
	/* Set a color for rolling over the item title*/
	div#rssincl-box-258791 div.rssincl-content div.rssincl-entry p.rssincl-itemtitle a:hover{
		color:#CC0101; /* change font color to red on rollover */
	}
 
	/* The <p> tag containing the item description, and all elements inside this tag */
	div#rssincl-box-258791 div.rssincl-content div.rssincl-entry p.rssincl-itemdesc,
	div#rssincl-box-258791 div.rssincl-content div.rssincl-entry p.rssincl-itemdesc *{
		font-size: 18px; /* general font size 12px */
                font-weight:bold;
		color: #000000; /* dark grey */
	}
 
	/* The <p> tag containing the item date, and all elements inside this tag */
	div#rssincl-box-258791 div.rssincl-content div.rssincl-entry p.rssincl-itemdate,
	div#rssincl-box-258791 div.rssincl-content div.rssincl-entry p.rssincl-itemdate *{
		font-size: 18px; /* set date smaller than normal text */
                font-weight:bold;
		color: #000000; /* dark grey again */
	}
 
	div#rssincl-box-258791 div.rssincl-content div.rssincl-entry p.rssincl-itemdate {
		margin-bottom:6px; /* a bit of space below the date*/
	}
 
	/* If there are images inside the description, you can style them as well */
	div#rssincl-box-258791 div.rssincl-content div.rssincl-entry div.rssincl-itemdesc img {
		border:0px; /* no border for images inside description tag */
	}
 
	/* There is a clearer div which you can set to "clear:both"... */
	div#rssincl-box-258791 div.rssincl-content div.rssincl-entry div.rssincl-clear {
		clear:both; /* important when using "float" for item elements */
	}
</style>

<center><img src="http://www.camosreptiles.com.au/smallsnake.gif"/></center>
<center><script type="text/javascript" src="http://output26.rssinclude.com/output?type=js&amp;id=258791&amp;hash=d4e66a7275669685968b5edc4c8a96e4"></script></center>







</div>
         <div id="Panel"><?php $this->RenderAsset('Panel'); ?></div>
      </div>
      <div id="Foot">
			<?php
				$this->RenderAsset('Foot');
				echo Wrap(Anchor(T('Powered by Vanilla'), C('Garden.VanillaUrl')), 'div');
			?>
		Copyright &copy 2011 Camosreptiles All Rights Reserved. ABN: 14937547569.</div>
   </div>
	<?php $this->FireEvent('AfterBody'); ?>



</body>
</html>
0

could this code be modified to just show total users?

<?PHP
$file = "users.ini";
$ip = $_SERVER['REMOTE_ADDR'];
$time = time();
$content = @file_get_contents($file);
$new_content = $ip." = ".$time;
$content .= $new_content."\r\n";
@file_put_contents($file,$content);

$users = @parse_ini_file($file);
$count = 0;
foreach($users as $ip=>$time){
	if($time >= time() - 300){ // past 3 minutes
		$count++;
	}
}
echo $count;
?>
0

I have no idea how your OOP works. Your classes aren't posted. I take it this isn't your code. If you have no idea of php and you're trying to deal with OOP code, you're going to struggle a bit.

It seems as though you've got this code wholesale from somebody - have you tried their support system (forum, discussion threads, etc)?

As for the last code snippet, lord knows what this is doing. Is it logging unique users or is it just logging activity?

0

Last snippet is just logging activity, yes I got it elsewhere, waiting on support from Author.

What can I post you to help you with my quest?

whats OOP ?

0

Id like to show total number of users elsewhere on my site, and dont know which part of the following code calls that.

I want to have 'some text[number of users here], and counting!'

I need to strip out only the minimum code to display the total number within another php page. please help, I have no idea of php.

<?php if (!defined('APPLICATION')) exit();
 
class UserListModule extends Gdn_Module {
   
   public function __construct(&$Sender = '') {
      parent::__construct($Sender);
   }
   
   public function GetData() {
   	 $SQL = Gdn::SQL();
     $Session = Gdn::Session();
     $Random = Gdn::Config('UserList.Random');
     $Limit = Gdn::Config('UserList.Limit');
     $NoPhoto = Gdn::Config('UserList.NoPhoto');
     
     $Select='u.UserID, u.Name, u.Photo';
     $From='User u';
     $Where=array('u.Deleted'=>0,'r.RoleID>'=>7);
     
     if($Random && $NoPhoto) {
        	$Order='RAND()';
     } else if((!$NoPhoto) && ($Random)) {
        	$Where['u.Photo >']=0;
	       	$Order='RAND()';
     } else if(!$NoPhoto) {
        	$Where['u.Photo >']=0;
        	$Order='u.UserID';
     } else {
        	$Order='u.UserID';
     }
     
     $this->Users = $SQL
    	    ->Select($Select)
        	->From($From)
        	->Join('UserRole r','u.UserID = r.UserID')
        	->Where($Where)
        	->Get();
     
     $this->All_Users = $SQL
    	    ->Select('u.UserID')
        	->From('User u')
        	->Join('UserRole r', 'u.UserID = r.UserID')
        	->Where(array('u.Deleted'=>0,'r.RoleID>'=>7))
        	->Get();

   }

   public function AssetTarget() {
      return 'Panel';
   }

   public function ToString() {
      $String = '';
      $Session = Gdn::Session();
	  $permissions=$Session->User->Permissions;
	  $admin=preg_match('/Garden.Settings.Manage/',$permissions);
	  
      ob_start();
      $Limit = Gdn::Config('UserList.Limit');
      $Photo = Gdn::Config('UserList.Photo');
      $Title = Gdn::Config('UserList.Title');
      $ShowNumUsers = Gdn::Config('UserList.ShowNumUsers');
      
      if(empty($Title)) {
      	$Title="Members";
      }
      
      if($Photo) {
      ?>
      <style type="text/css">
#UserList ul.PanelInfo li {
	border: 0!important;
	float: left;
	width: 25%;
	padding: 5px 0 0 0;
}
#UserList img {
	height: 48px;
	width: 48px;
}
#UserList ul.PanelInfo li {
	text-align: center!important;
}
</style>
<?php } ?>
<style type="text/css">
#UserList ul.PanelInfo li a {
	float: none;
}
#UserList ul.PanelInfo li {
	text-align: left;
}
</style>
      <div id="UserList" class="Box">
         <h4><?php echo $Title;
         if($ShowNumUsers) echo " (".$this->All_Users->NumRows().")"; ?></h4>
         <ul class="PanelInfo">
            <?php
			if($this->Users->NumRows() > 0) { 
               foreach($this->Users->Result() as $User) {
                  ?>
                  <li>
                     <?php
                     if($Photo) {
	                     if(!empty($User->Photo)) {
		                    echo "<a href=\"".Url('/profile/'.$User->Name)."\"><img src=\"".Url('uploads/'.ChangeBasename($User->Photo, 'n%s'))."\" alt=\"".$User->Name."\" title=\"".$User->Name."\" /></a><br />";
	    	             } else {
	        	         	echo "<a href=\"".Url('/profile/'.$User->Name)."\"><img src=\"".Url('plugins/UserList/user.png')."\" alt=\"".$User->Name."\" title=\"".$User->Name."\" /></a><br />";
	            	     }
	            	 } else {
	            	 	echo UserAnchor($User);
	            	 }
                     ?>
                  </li>
                  <?php
                  }
               } else {
	               if($admin) {
	               	 echo "<p>No users to display. Try <a href=\"".Url('plugin/userlist')."\">changing your settings</a>.</p>";
	               } else {
	                 echo "<p>No users to display.</p>";
	               }
               }
            ?>
         </ul>
         <div style="clear:both;"></div>
      </div>
      <?php
      $String = ob_get_contents();
      @ob_end_clean();
      return $String;
   }
}

Thankyou Friend, but Im totally clueless with php, Ive never written any!

:)

0

Last snippet is just logging activity, yes I got it elsewhere, waiting on support from Author.

What can I post you to help you with my quest?

whats OOP ?

How long have you been waiting for support? May be you are being a little impatient?

0

A few weeks now. Im sure its not that hard IF you understand php, alas, I dont!
I do know I cant do this client side with javascript since its calling data from mysql.
Is there any code or info I can supply that will help YOU understand how my software works?
Im working off a plugin that shows a list of users,(first code posted this thread)

Edited by Inny: attach plugin files

Attachments
<?php if (!defined('APPLICATION')) exit();
 
class UserListModule extends Gdn_Module {
   
   public function __construct(&$Sender = '') {
      parent::__construct($Sender);
   }
   
   public function GetData() {
   	 $SQL = Gdn::SQL();
     $Session = Gdn::Session();
     $Random = Gdn::Config('UserList.Random');
     $Limit = Gdn::Config('UserList.Limit');
     $NoPhoto = Gdn::Config('UserList.NoPhoto');
     
     $Select='u.UserID, u.Name, u.Photo';
     $From='User u';
     $Where=array('u.Deleted'=>0,'r.RoleID>'=>7);
     
     if($Random && $NoPhoto) {
        	$Order='RAND()';
     } else if((!$NoPhoto) && ($Random)) {
        	$Where['u.Photo >']=0;
	       	$Order='RAND()';
     } else if(!$NoPhoto) {
        	$Where['u.Photo >']=0;
        	$Order='u.UserID';
     } else {
        	$Order='u.UserID';
     }
     
     $this->Users = $SQL
    	    ->Select($Select)
        	->From($From)
        	->Join('UserRole r','u.UserID = r.UserID')
        	->Where($Where)
        	->Get();
     
     $this->All_Users = $SQL
    	    ->Select('u.UserID')
        	->From('User u')
        	->Join('UserRole r', 'u.UserID = r.UserID')
        	->Where(array('u.Deleted'=>0,'r.RoleID>'=>7))
        	->Get();

   }

   public function AssetTarget() {
      return 'Panel';
   }

   public function ToString() {
      $String = '';
      $Session = Gdn::Session();
	  $permissions=$Session->User->Permissions;
	  $admin=preg_match('/Garden.Settings.Manage/',$permissions);
	  
      ob_start();
      $Limit = Gdn::Config('UserList.Limit');
      $Photo = Gdn::Config('UserList.Photo');
      $Title = Gdn::Config('UserList.Title');
      $ShowNumUsers = Gdn::Config('UserList.ShowNumUsers');
      
      if(empty($Title)) {
      	$Title="Members";
      }
      
      if($Photo) {
      ?>
      <style type="text/css">
#UserList ul.PanelInfo li {
	border: 0!important;
	float: left;
	width: 25%;
	padding: 5px 0 0 0;
}
#UserList img {
	height: 48px;
	width: 48px;
}
#UserList ul.PanelInfo li {
	text-align: center!important;
}
</style>
<?php } ?>
<style type="text/css">
#UserList ul.PanelInfo li a {
	float: none;
}
#UserList ul.PanelInfo li {
	text-align: left;
}
</style>
      <div id="UserList" class="Box">
         <h4><?php echo $Title;
         if($ShowNumUsers) echo " (".$this->All_Users->NumRows().")"; ?></h4>
         <ul class="PanelInfo">
            <?php
			if($this->Users->NumRows() > 0) { 
               foreach($this->Users->Result() as $User) {
                  ?>
                  <li>
                     <?php
                     if($Photo) {
	                     if(!empty($User->Photo)) {
		                    echo "<a href=\"".Url('/profile/'.$User->Name)."\"><img src=\"".Url('uploads/'.ChangeBasename($User->Photo, 'n%s'))."\" alt=\"".$User->Name."\" title=\"".$User->Name."\" /></a><br />";
	    	             } else {
	        	         	echo "<a href=\"".Url('/profile/'.$User->Name)."\"><img src=\"".Url('plugins/UserList/user.png')."\" alt=\"".$User->Name."\" title=\"".$User->Name."\" /></a><br />";
	            	     }
	            	 } else {
	            	 	echo UserAnchor($User);
	            	 }
                     ?>
                  </li>
                  <?php
                  }
               } else {
	               if($admin) {
	               	 echo "<p>No users to display. Try <a href=\"".Url('plugin/userlist')."\">changing your settings</a>.</p>";
	               } else {
	                 echo "<p>No users to display.</p>";
	               }
               }
            ?>
         </ul>
         <div style="clear:both;"></div>
      </div>
      <?php
      $String = ob_get_contents();
      @ob_end_clean();
      return $String;
   }
}
<?php if (!defined('APPLICATION')) exit();
$PluginInfo['UserList'] = array(
   'Name' => 'User List',
   'Description' => "Lists users registered to the forum in the side panel.",
   'Version' => '0.5',
   'Author' => "Ellie Roepken",
   'AuthorEmail' => 'ellie@roepken.net',
   'AuthorUrl' => 'http://ellie.roepken.net',
   'RegisterPermissions' => FALSE,
   'SettingsPermission' => FALSE
);

class UserListPlugin implements Gdn_IPlugin {
   
   public function PluginController_UserList_Create(&$Sender) {
      $Sender->AddSideMenu('plugin/userlist');
      $Sender->Form = new Gdn_Form();
      $Validation = new Gdn_Validation();
      $ConfigurationModel = new Gdn_ConfigurationModel($Validation);
      $ConfigurationModel->SetField(array('UserList.Limit', 'UserList.Hide', 'UserList.Random', 'UserList.Photo', 'UserList.NoPhoto', 'UserList.Title', 'UserList.ShowNumUsers'));
      $Sender->Form->SetModel($ConfigurationModel);
            
      if ($Sender->Form->AuthenticatedPostBack() === FALSE) {
         $Sender->Form->SetData($ConfigurationModel->Data);
      } else {
         $Data = $Sender->Form->FormValues();
         $ConfigurationModel->Validation->ApplyRule('UserList.Limit', array('Required', 'Integer'));
         if ($Sender->Form->Save() !== FALSE)
            $Sender->StatusMessage = Gdn::Translate("Your settings have been saved.");
      }
      
      $Sender->View = dirname(__FILE__).DS.'views'.DS.'userlist.php';
      $Sender->Render();

   }
   
   public function Base_Render_Before(&$Sender) {
      $Controller = $Sender->ControllerName;
      $Session = Gdn::Session();     
      $Hide=Gdn::Config('UserList.Hide', TRUE);

	  if($Hide && !$Session->IsValid())	return;
      if(!in_array($Sender->ControllerName, array('categoriescontroller', 'discussioncontroller', 'discussionscontroller'))) return;
   
      if ($Controller !== "plugin") {
         include_once(PATH_PLUGINS.DS.'UserList'.DS.'class.userlistmodule.php');
         $UserListModule = new UserListModule($Sender);
         $UserListModule->GetData();
         $Sender->AddModule($UserListModule);
         $Session = Gdn::Session();
         $Limit = Gdn::Config('UserList.Limit', 6);
         if (!is_numeric($Limit))
            $Limit = 6;
            
         $Sender->AddDefinition('UserListLimit', $Limit);
      }
   }

   public function Base_GetAppSettingsMenuItems_Handler(&$Sender) {
      $Menu = $Sender->EventArguments['SideMenu'];
      $Menu->AddLink('Add-ons', 'User List', 'plugin/userlist', 'Garden.Settings.Manage');
   }

   public function Setup() { 
      // No setup required.
   }
}
<?php if (!defined('APPLICATION')) exit();
echo $this->Form->Open();
echo $this->Form->Errors();
?>
<h1><?php echo Gdn::Translate("User List Module"); ?></h1>
      <table class="AltRows">  
         <tbody>
         	  <tr>
               	  <th><?php echo T('Limit'); ?></th><th><?php echo $this->Form->TextBox('UserList.Limit', 'Limit'); ?></th>
              </tr>
              <tr>
               	  <th><?php echo T('Module Title'); ?></th><th><?php echo $this->Form->TextBox('UserList.Title', 'Title'); ?></th>
              </tr>
         	  <tr>
                  <th colspan="2"><?php
                     echo $this->Form->Checkbox('UserList.Random', "Randomize");
                  ?></th>
               </tr>
               <tr>
                  <th colspan="2"><?php
                     echo $this->Form->Checkbox('UserList.Hide', "Hide from guests");
                  ?></th>
               </tr>
               <tr>
                  <th colspan="2"><?php
                     echo $this->Form->Checkbox('UserList.ShowNumUsers', "Show total number of users next to title");
                  ?></th>
               </tr>
         </tbody>
      </table>
      <table class="AltRows">  
         <tbody>
         	  <tr>
                  <th>
                  	<?php echo T('Photo Mode'); ?>
                  </th>
               </tr>
         	   <tr>
                  <th><?php
                     echo $this->Form->Checkbox('UserList.Photo', "Show Photo");
                  ?></th>
               </tr>
               <tr>
                  <th><?php
                     echo $this->Form->Checkbox('UserList.NoPhoto', "Show users that don't have a photo");
                  ?></th>
               </tr>
         </tbody>
      </table>

<?php echo $this->Form->Close('Save');
0

A few weeks now. Im sure its not that hard IF you understand php, alas, I dont!
I do know I cant do this client side with javascript since its calling data from mysql.
Is there any code or info I can supply that will help YOU understand how my software works?
Im working off a plugin that shows a list of users,(first code posted this thread)

I don't think I can help with the script as it is complex and I'm not ready to poke around. Simplest thing I would suggest is you post your schema and someone writes script to pull total users. The downside of this is you are adding security weakpoint!

0

Yes its a plugin to show a list of users
see files attached last page

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.