<?php
if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );

/**
*
* @package simpleMembership
* @copyright Andrey Kvasnevskiy-OrdaSoft(akbet@mail.ru); Anton Getman(ljanton@mail.ru);
* Homepage: http://www.ordasoft.com
* @version: 1.2 FREE
*
**/




require_once ($mosConfig_absolute_path."/libraries/joomla/factory.php");
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
/**
*
* @package simplemembership
*
**/
// ensure this file is being included by a parent file
$bid = mosGetParam($_POST, 'bid', array (0));
require_once ($mosConfig_absolute_path."/administrator/components/com_simplemembership/admin.simplemembership.class.others.php");
function catOrderDownIcon( $i, $n, $index, $task='orderdown', $alt='Move Down' ) {
	if ($i < $n-1 ) {
		return '<a href="#reorder" onclick="return listItemTask(\'cb'.$index.'\',\''.$task.'\')" title="'.$alt.'">
			<img src="images/downarrow.png" width="12" height="12" border="0" alt="'.$alt.'" />
		</a>';
	} else {
		return '&nbsp;';
	}
}
function catOrderUpIcon( $i,$index, $task='orderup', $alt='Move Up' ) {
	if ($i > 0 ) {
		return '<a href="#reorder" onclick="return listItemTask(\'cb'.$index.'\',\''.$task.'\')" title="'.$alt.'">
			<img src="images/uparrow.png" width="12" height="12" border="0" alt="'.$alt.'" />
		</a>';
	} else {
		return '&nbsp;';
	}
}

class HTML_Categories
{
	function show($rows)
	{
		global $my,$mainframe,$mosConfig_live_site ;
		$section = "group";
		$section_name = "simplemembershipLibrary";
		//$mainframe->addCustomHeadTag('<link rel="stylesheet" href="'.$mosConfig_live_site.'/administrator/components/com_simplemembership/includes/simplemembership.css" type="text/css" />');
		$doc =JFactory::getDocument();
$doc->addStyleSheet( $mosConfig_live_site.'/administrator/components/com_simplemembership/includes/simplemembership.css' );

    ?>
<form action="index.php" method="post" name="adminForm">
<table cellpadding="4" cellspacing="0" border="0" width="100%">
	<tr>
		<td width="30%"> </td>
		<td width="70%" class="simplemembership_manager_caption" valign='bottom'><?php echo _SIMPLEMEMBERSHIP_CATEGORIES_MANAGER; ?>
		</td>
	</tr>
</table>
<table class="adminlist">
	<tr>
		<th width="20"><input type="checkbox" name="toggle" value=""
			onClick="checkAll(<?php echo count($rows);?>);" /></th>
		<th align="center" class="title" width="20%"><?php echo ADMIN_GROUP_NAME;?></th>
		<th align="center" width="15%" ><?php echo ADMIN_GROUP_ACLGROUPNAME;?></th>
		<th align="center" width="10%"><?php echo ADMIN_GROUP_INTERVAL;?></th>
		<th align="center" ><?php echo ADMIN_GROUP_NOTES;?></th>
		<th align="center" width="40px" ><?php echo ADMIN_GROUP_PUBLISH;?></th>
	</tr>
	<?php
	$k = 0;
	$i = 0;
	foreach ($rows as $row) {
		?>
	<tr class="<?php echo "row$k";?>">
		<td width="20"><?php $mosHTML= new mosHTML(); echo $mosHTML->idBox($i, $row->id, false,'bid');?></td>
		<td align="center"><a href="#edit"
			onClick="return listItemTask('cb<?php echo $i;?>','edit');"><?php echo $row->name;?>
			</a></td>
		<td align="center"><?php echo $row->acl_group;?></td>
		<td align="center"><?php echo $row->days_last;?></td>
		<td align="center"><?php echo $row->notes;?></td>
		<td align="center"><?php
		$task = $row->published ? 'unpublish' : 'publish';
		$alt = $row->published ? 'Publish' : 'Unpublish';
		$img = $row->published ?  'tick.png' : 'publish_x.png';
		?>
		<a href="javascript: void(0);"
			onClick="return listItemTask('cb<?php echo $i;?>','<?php echo $task;?>')">
		<img src="templates/bluestork/images/admin/<?php echo $img;?>" width="12" height="12" border="0"
			alt="<?php echo $alt;?>" /> </a>
		</td>
		<?php
		$k = 1 - $k;
		?>
	</tr>
	<?php
	$k = 1 - $k;
	$i++;
}
?>
</table>
<input type="hidden" name="option" value="com_simplemembership" /> 
<input type="hidden" name="section" value="group" /> 
<input type="hidden"	name="task" value="" /> 
<input type="hidden" name="chosen" value="" />
<input type="hidden" name="act" value="" /> 
<input type="hidden"	name="boxchecked" value="0" />
<!--input type="hidden" name="type" value="<?php echo $type;?>" /--></form>
<?php
}

/**
 * Writes the edit form for new and existing categories
 *
 * @param mosCategory $ The category object
 * @param string $
 * @param array $
 */

function edit( $section, &$lists, $redirect, $row)
{
	global $my, $mosConfig_live_site,$mainframe;
	//$mainframe->addCustomHeadTag('<script type = "text/JavaScript" src ="'. $mosConfig_live_site.'/administrator/components/com_simplemembership/includes/functions.js"></script>');
//	$mainframe->addCustomHeadTag('<link rel="stylesheet" href="'.$mosConfig_live_site.'/administrator/components/com_simplemembership/includes/simplemembership.css" type="text/css" />');
			$doc =JFactory::getDocument();
$doc->addStyleSheet( $mosConfig_live_site.'/administrator/components/com_simplemembership/includes/simplemembership.css' );
$doc->addScript( $mosConfig_live_site.'/administrator/components/com_simplemembership/includes/functions.css' );

  global $mosConfig_live_site,$option;
	?>
<script language="javascript" type="text/javascript">
		function submitbutton(pressbutton, section) {
			var form = document.adminForm;
			if (pressbutton == 'cancel') {
				submitform( pressbutton );
				return;
			}

			if ( form.name.value == "" ) {
				alert('<?php echo _DML_CAT_MUST_SELECT_NAME;?>');
			} else {
				<?php getEditorContents('editor1', 'description') ;?>
				submitform(pressbutton);
			}
		}
		</script>
<form action="index.php" method="post" name="adminForm">
<table>
	<tr>
		<th class="simplemembership_manager_caption" align="left"><?php 
			if( is_object($row))echo $row->id ? _SIMPLEMEMBERSHIP_HEADER_EDIT : _SIMPLEMEMBERSHIP_HEADER_ADD;?>
			<?php echo _SIMPLEMEMBERSHIP_CATEGORY;?> <?php if( is_object($row))echo $row->name;?></th>
	</tr>
</table>
<table class="adminform" width="60%">
	<tr>
		<th colspan="2"><?php echo _SIMPLEMEMBERSHIP_CATEGORIES__DETAILS;?></th>
	</tr>
	<tr>
		<td width="350px"><?php echo SIMPLEMEMBERSHIP_GROUP_EDIT_TITLE;?>:</td>
		<td align="left"><input class="text_area" type="text" name="title"
						  value="<?php if( is_object($row))echo $row->name; ?>" size="50" /></td>
	</tr>
	<tr>
		<td width="350px"><?php echo SIMPLEMEMBERSHIP_GROUP_EDIT_ACLSELECT;?>:</td>
		<td align="left"><?php echo $lists['acl_group_select']; ?></td>
	</tr>
	<tr>
		<td colspan="2"><?php echo SIMPLEMEMBERSHIP_GROUP_EDIT_NOTES;?>:</td>
	</tr>
	<tr>
		<td colspan="2"><?php if(is_object($row))editorArea('editor1', $row->notes , 'notes', '500', '200', '50', '5');
		else
		editorArea('editor1', '' , 'notes', '500', '200', '50', '5');
    
?></td>
			</tr>
		</table>
<input type="hidden" name="option" value="com_simplemembership" />
<input type="hidden" name="section" value="group" /> 
<input type="hidden"	name="task" value="" /> 
<!--input type="hidden" name="oldtitle"	value="<?php echo $row->title ;?>" /-->
 <input type="hidden" name="id"	value="<?php echo $row->id;?>" > 
 <input type="hidden" name="sectionid"	value="com_simplemembership" /> 
 <input type="hidden" name="redirect"	value="<?php echo $redirect;?>" /></form>
				<?php
}
}


class HTML_simplemembership
{

function add_acl_group_form($option,$lists)
{
	global $user_configuration,$my, $mosConfig_live_site,$mainframe;
//	$mainframe->addCustomHeadTag('<script type = "text/JavaScript" src ="'.$mosConfig_live_site.'/administrator/components/com_simplemembership/includes/functions.js"></script>');
		$doc =JFactory::getDocument();
//$doc->addStyleSheet( $mosConfig_live_site.'/administrator/components/com_simplemembership/includes/simplemembership.css' );
$doc->addScript( $mosConfig_live_site.'/administrator/components/com_simplemembership/includes/functions.css' );

	?>
				<script language="javascript" type="text/javascript">
				 function trim(string){
					return string.replace(/(^\s+)|(\s+$)/g, "");
				 }
				 function submitbutton(pressbutton) {
					submitform( pressbutton );
				}
				</script>
<form action="index.php?option=<?php echo $option; ?>" method="post" name="adminForm" id="adminForm"	enctype="multipart/form-data">
<table cellpadding="4" cellspacing="1" border="0" width="100%"	class="adminform">
	<tr>
		<td valign="top" align="left"><strong><?php echo _SIMPLEMEMBERSHIP_PARENT_GROUP;?>:</strong>
		</td>
		<td align="left"><?php echo $lists['acl_group_select'];?></td>
	</tr>
	<tr>
		<td valign="top" align="left"><strong><?php echo _SIMPLEMEMBERSHIP_ADMIN_ACLNAME;?>:</strong>
		</td>
		<td align="left"><input class="inputbox" type="text" name="acl_name"	size="80" value="" /></td>
	</tr>
</table>
<input type="hidden" name="option" value="<?php echo $option;?>" />
<input type="hidden" name="task" value="" /></form>
	<?php
}

function del_acl_group_form($option,$lists)
{
	global $user_configuration,$my, $mosConfig_live_site,$mainframe;
	//$mainframe->addCustomHeadTag('<script type = "text/JavaScript" src ="'.$mosConfig_live_site.'/administrator/components/com_simplemembership/includes/functions.js"></script>');
	$doc =JFactory::getDocument();
$doc->addScript( $mosConfig_live_site.'/administrator/components/com_simplemembership/includes/functions.css' );

  
  ?>
				<script language="javascript" type="text/javascript">
				 function trim(string){
					return string.replace(/(^\s+)|(\s+$)/g, "");
				 }
				 function submitbutton(pressbutton) {
					submitform( pressbutton );
				}
				</script>
<form action="index.php?option=<?php echo $option; ?>&task=del_acl_group" method="post" name="adminForm" id="adminForm"	enctype="multipart/form-data">
<table cellpadding="4" cellspacing="1" border="0" width="100%"	class="adminform">
	<tr>
		<td valign="top" align="left"><strong><?php echo _SIMPLEMEMBERSHIP_TODELETE_GROUP;?>:</strong>
		</td>
		<td align="left"><?php echo $lists['custom_groups'];?></td>
	</tr>
	
</table>
<input type="hidden" name="boxchecked" value="1" />
<input type="hidden" name="option" value="<?php echo $option;?>" />
<input type="hidden" name="task" value="del_acl_group" /></form>
	<?php
}

function showUsers($option, $rows_simplemembership, & $publist, & $search, & $pageNav, $olist, $enablelist )
{
	global $my, $mosConfig_live_site,$mainframe,$session;
	//$mainframe->addCustomHeadTag('<link rel="stylesheet" href="'.$mosConfig_live_site.'/administrator/components/com_simplemembership/includes/simplemembership.css" type="text/css" />');
	// for 1.6
global $doc;
$doc =JFactory::getDocument();
JHTML::_("behavior.mootools");
$doc->addStyleSheet( $mosConfig_live_site.'/administrator/components/com_simplemembership/includes/simplemembership.css' );

  ?>
<form action="index.php" method="post" id="adminForm" name="adminForm">
    
    
 <script type="text/javascript">

function sync_user(params_for_sync) {
      var url_for_sync= '<?php echo $mosConfig_live_site ?>/administrator/components/com_simplemembership/sync_ajax.php';
      var data_for_url=new String();
//       for (var key in params_for_sync){
//         data_for_url+='params_for_sync['+key+']='+params_for_sync[key]+'&';
//       }//a lot unnessecury elemnts, they are methods and fucntion, that's becouse we need hadnmade data
//       alert(data_for_url);
     data_for_url+='params_for_sync[task]='+params_for_sync['task']+'&';
     data_for_url+='params_for_sync[ia]='+params_for_sync['ia']+'&';
     data_for_url+='params_for_sync[ia_d]='+params_for_sync['ia_d']+'&';
     data_for_url+='params_for_sync[count_adv_users]='+params_for_sync['count_adv_users']+'&';
     data_for_url+='params_for_sync[ij]='+params_for_sync['ij']+'&';
     data_for_url+='params_for_sync[count_joom_users]='+params_for_sync['count_joom_users']+'&';
     data_for_url+='params_for_sync[ie]='+params_for_sync['ie']+'&';
     data_for_url+='params_for_sync[ie_d]='+params_for_sync['ie_d']+'&';
     data_for_url+='params_for_sync[count_exp_users]='+params_for_sync['count_exp_users']+'&';
     data_for_url+='params_for_sync[status]='+params_for_sync['status'];
      ajaxxx = new Request.JSON({
        //update: $('log'),
        url:url_for_sync,
        method: 'post',
        data: data_for_url,
        update:update_divs(params_for_sync),
        onSuccess: function(response) {
          if(response){
            var data_query = response;//JSON.decode(response,true);//eval('(' + response + ')');
            //console.log('hello',data_query);
            if(!data_query) alert('ERROR!!!'+response);
            if(data_query['status']=='sync_user_ok') {
              data_query['task']='expire';
              sync_user(data_query);
            }
            else if(data_query['status']=='exp_user_ok') {
              $('sync_button').disabled = false;
              $('loader_user').setStyle('display', 'none');
              alert('Users were synchronized, and now the page will be reloaded');
              window.location.reload();
            }
            else if(data_query['status']=='0'){
              sync_user(data_query);
            }
          }
          else alert('ERROR');
        },
        onFailure: function(text){
          alert('ERROR'+text);
        },
        onError:function(text){
          alert('ERROR'+text);
        }
      }).send();
}
function update_divs(params_for_sync){
          var proccess_msg;
          var proccess_ia=make_percent(params_for_sync['ia'],params_for_sync['count_adv_users']);
          var proccess_ij=make_percent(params_for_sync['ij'],params_for_sync['count_joom_users']);
          var proccess_ie=make_percent(params_for_sync['ie'],params_for_sync['count_exp_users']);
          proccess_msg='COMPLETED:</br> Memebership users: '+proccess_ia+'% </br> JOOMLA user: '+proccess_ij+'% </br> Expired users: '+proccess_ie+'%';
          $('loader_user').setStyle('display', 'block');
          $('status_user').innerHTML='<b style="color:red">Please wait DO NOT BROWSE</b></br>'+proccess_msg;
          $('sync_button').disabled = true;
}
function make_percent(i_users,count_users){
  var return_percent;
  if(count_users <= 100){
    if(i_users >0){
      return_percent=100;
    }
    else return_percent=0;
  }
  else {
    return_percent=(i_users*100*100)/count_users;
  }
  if(return_percent >100) return_percent=100;
  return Math.floor(return_percent);
}
function start_sync(){
    var params_for_sync=new Array();
    params_for_sync['task']='sync';
    params_for_sync['ia']='0';
    params_for_sync['ia_d']='0';
    params_for_sync['count_adv_users']='0';
    params_for_sync['ij']='0';
    params_for_sync['count_joom_users']='0';
    params_for_sync['ie']='0';
    params_for_sync['ie_d']='0';
    params_for_sync['count_exp_users']='0';
    params_for_sync['status']='0';
    sync_user(params_for_sync);
}

</script> 


<table cellpadding="4" cellspacing="0" border="0" width="100%">
  <tr>
    <td width="30%" align="center"></td>
    <td width="40%" class="simplemembership_manager_caption" valign='bottom' align="left"><?php echo _SIMPLEMEMBERSHIP_ADMIN_USERS ?></td>
    <td width="30%" valign='bottom' align="right">
    <div id="status_user" style="font-size:17px;"></div>
    <div id="loader_user" style="display:none;"><img src="<?php echo $mosConfig_live_site;?>/administrator/components/com_simplemembership/images/loader-line.gif"></div>
    <input type="button" value="Sync users" id="sync_button" onclick="start_sync();">
    </td>
  </tr>
</table>
<table cellpadding="4" cellspacing="0" border="0" width="100%"
	class="adminlist">
	<tr>
		<td><?php echo _SIMPLEMEMBERSHIP_SHOW_SEARCH;?></td>
		<td><input type="text" name="search" value="<?php echo $search;?>"
			class="inputbox" onChange="document.adminForm.submit();" /></td>
		<td><?php echo $publist;?></td>
		<td><?php echo $olist;?></td>
		<td><?php echo $enablelist;?></td>
	</tr>
</table><table cellpadding="4" cellspacing="0" border="0" width="100%"
	class="adminlist">
	<tr>
		<th width="20"><input type="checkbox" name="toggle" value=""
			onClick="checkAll(<?php echo count( $rows_simplemembership ); ?>);" /></th>
		<th align="center" class="title" nowrap="nowrap"><?php echo _SIMPLEMEMBERSHIP_LABEL_USERNAME;?></th>
		<th align="center" class="title" nowrap="nowrap"><?php echo _SIMPLEMEMBERSHIP_LABEL_USEREMAIL;?></th>
		<th align="center" class="title" nowrap="nowrap"><?php echo _SIMPLEMEMBERSHIP_LABEL_SIMPLEMEMBERSHIPGROUP;?></th>
		<th align="center" class="title" nowrap="nowrap"><?php echo _SIMPLEMEMBERSHIP_LABEL_USERSTATUS;?></th>
		<th align="center" class="title" nowrap="nowrap"><?php echo _SIMPLEMEMBERSHIP_LABEL_USERGROUP;?></th>
		<th align="center" class="title" nowrap="nowrap"><?php echo _SIMPLEMEMBERSHIP_LABEL_USERENABLED;?></th>
		<th align="center" class="title" nowrap="nowrap"><?php echo _SIMPLEMEMBERSHIP_LABEL_USERWANTED_STATUS;?></th>
		<th align="center" class="title" nowrap="nowrap"><?php echo _SIMPLEMEMBERSHIP_LABEL_USERAPPROVED;?></th>
		<th align="center" class="title" nowrap="nowrap"><?php echo _SIMPLEMEMBERSHIP_LABEL_USERLASTAPPROVED;?></th>
	</tr>
	<?php	for ($i = 0, $n = count($rows_simplemembership); $i < $n; $i ++) {
		$row = $rows_simplemembership[$i];
		?>
	<tr class="row<?php echo $i % 2; ?>">
		<td width="20" align="left"><?php
	$mosHTML= new mosHTML(); echo $mosHTML->idBox( $i, $row->id, false, 'bid' );
?>
</td>
		<td align="left"><a href="#" onClick="return listItemTask('cb<?php echo $i;?>','edit_user')" ><?php echo $row->name; ?></a></td>
		<td align="center"><?php echo $row->email; ?></td>
		<td align="center">
		<?php
		if($row->group_name == '')
		echo 'Joomla';
		else
		echo $row->group_name; ?>
		</td>
		<td align="center" style="">
		<?php
		if(strstr($row->user_type, '::')){
		$status = '';
    $err_code='';}
		else
		{
			$status = $row->user_type;
			$err_code = '';
		}
		$err_msg = '';
		if($err_code!='')
		{
			$style = 'style="color: #ff0033;"';
			$err_msg = HTML_simplemembership::getErrMsg($err_code);
		}
		if($status=='')
		{
			$status = 'Valid';
			$style = 'style="color: #33ff33;"';
		}
		echo @"<span $style>". $status ."<br />" .$err_msg .'</span>';
		?>
		</td>
		<td align="center"><?php foreach($row->gid as $groups){ echo $groups."</br>";} /*echo $row->joom_usertype; */?></td>
		<?php
		$task = $row->block ? 'unpublish' : 'publish';
		$alt = $row->block ? 'Unpublish' : 'Publish';
		$img = $row->block ? 'publish_x.png': 'tick.png';
		?>
		<td width="5%" align="center"><a href="javascript: void(0);"
			onClick="return listItemTask('cb<?php echo $i;?>','<?php echo $task;?>')">
		<img src="templates/bluestork/images/admin/<?php echo $img;?>" width="12" height="12" border="0"
			alt="<?php echo $alt;?>" /> </a></td>
		<td align="center"><?php foreach($row->joom_usertypew as $want_group){ echo $want_group."</br>"; }/*echo $row->joom_usertypew;*/ ?></td>
		<?php

    $task = $row->approved ? 'unapprove' : 'approve';
		$alt = $row->approved ? 'Unapprove' : 'Approve';
		$img = $row->approved ? 'publish_x.png': 'tick.png';
		?>
		<td width="5%" align="center"><a href="javascript: void(0);"
			onClick="return listItemTask('cb<?php echo $i;?>','<?php echo $task;?>')">
		<img src="templates/bluestork/images/admin/<?php echo $img;?>" width="12" height="12" border="0"
			alt="<?php echo $alt;?>" /> </a></td>
		<td align="center">
		<?php
		$date_temp = $row->last_approved;
		if($date_temp == '' || $date_temp == '0000-00-00')
		echo 'never';
		else 
		echo $date_temp; ?></td>
	</tr>
	<?php } ?>
	<tr>
		<td colspan="13"><?php echo $pageNav->getListFooter();?></td>
	</tr>
</table>
<input type="hidden" name="option" value="<?php echo $option;?>" />
<input type="hidden" name="task" value="" />
<input type="hidden"	name="boxchecked" value="0" />
	</form>
	<?php
}


/**
 * Writes the edit form for new and existing records
 *
 */
function editUser($option, & $row, & $olist, $bid, $msg, $user_profile_form)
{
	global $user_configuration,$my, $mosConfig_live_site,$mainframe;
	//$mainframe->addCustomHeadTag('<script type = "text/JavaScript" src ="'.$mosConfig_live_site.'/administrator/components/com_simplemembership/includes/functions.js"></script>');
		$doc =JFactory::getDocument();
$doc->addScript( $mosConfig_live_site.'/administrator/components/com_simplemembership/includes/functions.css' );
       JHTML::_('behavior.formvalidation');
  
  ?>

				<script language="javascript" type="text/javascript">
				 function trim(string){
					return string.replace(/(^\s+)|(\s+$)/g, "");
				 }
				 function submitbutton(pressbutton) {
					submitform( pressbutton );
				}
				</script>

<form action="index.php" method="post" name="adminForm" id="adminForm"
	enctype="multipart/form-data" class="form-validate" enctype="multipart/form-data">





    <fieldset class="adminform">
      <legend>
        Account Details
      </legend>
        <ul class="adminformlist">
          <li>
            <label id="name-lbl" class="hasTip required" for="name">
              Name:
          <span class="star">&nbsp;*</span> 
            </label>
              <input name="name" id="name" size="40" value="<?php echo $row->name;?>" class="inputbox required" maxlength="50" type="text"> 
            </li>
         
         
          <li>
            <label id="username-lbl" for="username" class="hasTip required">
              Username:
              <span class="star">&nbsp;*</span>
            </label>
            <input id="username" name="username" size="40" value="<?php echo $row->username;?>" class="inputbox required validate-username" maxlength="25" type="text">
          </li>
         
         
          <li>
            <label id="emailmsg" for="email" class="hasTip required">
              E-mail:
                    <span class="star">&nbsp;*</span>
            </label>
            <input id="email" name="email" size="40" value="<?php echo $row->email;?>" class="inputbox required validate-email" maxlength="100" type="text">
          </li>
         
         
          <li>
            <label id="mmg" for="gid">
              MemberGroup:
            </label>
            <?php echo $olist;
            ?>
          </li>
          <li>
            <label id="pwmsg" for="password" class="hasTip <?php if($bid==0) echo"required";?>">
              Password:
                      <?php if($bid==0)  echo '<span class="star">&nbsp;*</span>';?>
            </label>
              <input class="inputbox required validate-password" id="password" name="password" size="40" value="" type="password">
            </li>
          <li>
            <label id="pw2msg" for="password2" class="hasTip <?php if($bid==0) echo"required";?>">
              Verify Password:
                              <?php if($bid==0)  echo '<span class="star">&nbsp;*</span>';?>
            </label>
            <input class="inputbox required validate-passverify" id="password2" name="password2" size="40" value="" type="password">
          </li>
        </ul>
      </fieldset>
        <?php 
          foreach($user_profile_form->getFieldsets() as $fieldset){
    if($fieldset->name =='user_details') continue;
    $fields=$user_profile_form->getFieldset($fieldset->name);
    if(count($fields)){//print profile fields?>
      <fieldset class="adminform">
      <?php if(isset($fieldset->label)){?>
        <legend>
        <?php echo JText::_($fieldset->label);?>
        </legend>
        <ul class="adminformlist">
      <?php }
      foreach($fields as $field){
        if($field->hidden) {
         $field->input;
        }
        else{
        ?>
          <li>
            <?php
            echo $field->label; ?>
            <?php echo $field->input;
            if($field->name=='profile[file]'){
              if($user_profile_form->getValue('file','profile','') !==''){?>
                <input type="button" value="DELETE" onclick="document.getElementById('profile_photo').style.display='none'; document.getElementById('file_path').value='';"/>
                <div id='profile_photo' style="display:block;max-width:500px;">
                <img src="<?php echo $mosConfig_live_site.$user_profile_form->getValue('file','profile','')?>" style="max-width:500px;">
                </div>
              <?php
              }
            }
            ?>
          </li>
        <?php
        }
      }?>
      </ul>
    </fieldset>
    <?php }
  }
 ?>


<input type="hidden" id="file_path" name="file_path" value="<?php echo $user_profile_form->getValue('file','profile','');?>" />
<input type="hidden" name="id" value="<?php echo $row->id; ?>" />
<input type="hidden" name="bid" value="<?php echo $bid; ?>" />
<input type="hidden" name="option" value="<?php echo $option;?>" />
<input type="hidden" name="boxchecked" value="0" />
<input type="hidden"	name="task" value="" />
	</form>
	<?php
}

function showConfiguration_frontend($lists, $option)
{
	global $my, $mosConfig_live_site,$mainframe,$act, $task;
	//$mainframe->addCustomHeadTag('<script type = "text/JavaScript" src ="'.$mosConfig_live_site.'/administrator/components/com_simplemembership/includes/functions.js"></script>');
//	$mainframe->addCustomHeadTag('<link rel="stylesheet" href="'.$mosConfig_live_site.'/administrator/components/com_simplemembership/includes/simplemembership.css" type="text/css" />');
		$doc =JFactory::getDocument();
$doc->addStyleSheet( $mosConfig_live_site.'/administrator/components/com_simplemembership/includes/simplemembership.css' );
$doc->addScript( $mosConfig_live_site.'/administrator/components/com_simplemembership/includes/functions.css' );

  ?>
<div
	id="overDiv"
	style="position: absolute; visibility: hidden; z-index: 10000;"></div>

<script
	type="text/javascript" language="Javascript"
	src="<?php echo $mosConfig_live_site;?>/includes/js/overlib_mini.js"></script>
<table cellpadding="4" cellspacing="0" border="0" width="100%">
	<tr>
		<td width="30%"> </td>

		<td width="70%" class="simplemembership_manager_caption" valign='bottom'><?php echo _SIMPLEMEMBERSHIP_ADMIN_CONFIG_FRONTEND ?>
		</td>
	</tr>
</table>
<form action="index.php" method="post" name="adminForm" id="adminForm">
<table class="adminform">
	<tr>
		<td width="185"><?php echo _SIMPLEMEMBERSHIP_ADMIN_CONFIG_ADDUSER_EMAIL_SEND; ?>:</td>
		<td width="20"><?php echo mosToolTip( _SIMPLEMEMBERSHIP_ADMIN_CONFIG_ADDUSER_EMAIL_SEND_TT_BODY, _SIMPLEMEMBERSHIP_ADMIN_CONFIG_ADDUSER_EMAIL_SEND_TT_HEAD); ?></td>
		<td><?php echo $lists['acl_group_set_email']['show']; ?></td>
		<td colspan="3" ></td>
	</tr>
	<tr>
		<td colspan="6">
		<hr />
		</td>
	</tr>
	<tr>
		<td width="185"><?php echo _SIMPLEMEMBERSHIP_ADMIN_CONFIG_USERS_WHO_CAN_SEE_THE_OTHER_PROFILES;?>:</td>
		<td width="20"><?php echo mosToolTip( _SIMPLEMEMBERSHIP_ADMIN_CONFIG_USERS_WHO_CAN_SEE_THE_OTHER_PROFILES_TT_BODY, _SIMPLEMEMBERSHIP_ADMIN_CONFIG_USERS_WHO_CAN_SEE_THE_OTHER_PROFILES_TT_HEAD ); ?></td>
		<td><?php echo $lists['other_profiles']; ?></td>
	</tr>
		<tr>
		<td colspan="6">
		<hr />
		</td>
	</tr>	<tr>
		<td colspan="6" align="left">
		<?php echo _SIMPLEMEMBERSHIP_ADMIN_CONFIG_PREREGISTERMSG; ?>:
		</td>
	</tr>
	<tr>
	<td colspan="6"><?php editorArea( 'editor1',  $lists['preregister'] , 'preregister', 500, 250, '70', '10' ) ; ?></td>
	</tr>
	<tr>
		<td colspan="6">
		<hr />
		</td>
	</tr>
	<tr>
		<td colspan="6" align="left">
		<?php echo _SIMPLEMEMBERSHIP_ADMIN_CONFIG_ACTIVATION; ?>:
		</td>
	</tr>
	<tr>
	<td colspan="6"><?php editorArea( 'editor2',  $lists['activationmsg'] , 'activationmsg', 500, 250, '70', '10' ) ; ?></td>
	</tr>
	<!--***************   begin add send mail for admin   *****************-->
</table>
<input type="hidden" name="option" value="<?php echo $option; ?>" />
<input type="hidden" name="task" value="config_save_frontend" /></form>
		<?php
}

function showConfiguration_backend($lists, $option) {
	global $mosConfig_live_site, $act, $task,$mainframe;
	//	$mainframe->addCustomHeadTag('<link rel="stylesheet" href="'.$mosConfig_live_site.'/administrator/components/com_simplemembership/includes/simplemembership.css" type="text/css" />');
			$doc =JFactory::getDocument();
$doc->addStyleSheet( $mosConfig_live_site.'/administrator/components/com_simplemembership/includes/simplemembership.css' );

	?>
		<div id="overDiv"
		style="position: absolute; visibility: hidden; z-index: 10000;"></div>
		<script
			type="text/javascript" language="Javascript"
			src="<?php echo $mosConfig_live_site;?>/includes/js/overlib_mini.js"></script>
		<table cellpadding="4" cellspacing="0" border="0" width="100%">
			<tr>
				<td width="30%"> </td>
				<td width="70%" class="simplemembership_manager_caption" valign='bottom'><?php echo _SIMPLEMEMBERSHIP_ADMIN_CONFIG_BACKEND ?>
				</td>
			</tr>
		</table>
		<form action="index.php" method="post" name="adminForm" id="adminForm">
			<table class="adminform">
				<tr>
					<td width="185"><?php echo _SIMPLEMEMBERSHIP_ADMIN_CONFIG_ADDUSER_EMAIL;
					?>:</td>
					<td width="20"><?php echo mosToolTip( _SIMPLEMEMBERSHIP_ADMIN_CONFIG_ADDUSER_EMAIL_TT_BODY, _SIMPLEMEMBERSHIP_ADMIN_CONFIG_ADDUSER_EMAIL_TT_HEAD ); ?></td>
					<td><?php echo $lists['useradd_notification_email']; ?></td>
				</tr>
				<tr>
		<td colspan="6">
		<hr />
		</td>
	</tr>
	<tr>
		<td width="185"><?php echo _SIMPLEMEMBERSHIP_ADMIN_CONFIG_DEFAULT_GROUP;?>:</td>
		<td width="20"><?php echo mosToolTip( _SIMPLEMEMBERSHIP_ADMIN_CONFIG_DEFAULT_GROUP_TT_BODY, _SIMPLEMEMBERSHIP_ADMIN_CONFIG_DEFAULT_GROUP_TT_HEAD ); ?></td>
		<td><?php echo $lists['default_group']; ?></td>
	</tr>
		<tr>
		<td colspan="6">
		<hr />
		</td>
	</tr>
	<tr>
		<td colspan="6" align="left">
		<?php echo _SIMPLEMEMBERSHIP_ADMIN_CONFIG_ADMINACCCREATENOTIFY; ?>:
		</td>
	</tr>
	<tr>
	<td colspan="6"><?php editorArea( 'editor1',  $lists['admin_created_msg'] , 'admin_created_msg', 500, 250, '70', '10' ) ; ?></td>
	</tr>
	<tr>
		<td colspan="6">
		<hr />
		</td>
	</tr>
	<tr>
		<td colspan="6" align="left">
		<?php echo _SIMPLEMEMBERSHIP_ADMIN_CONFIG_USERACCCREATENOTIFY; ?>:
		</td>
	</tr>
	<tr>
	<td colspan="6"><?php editorArea( 'editor2',  $lists['user_created_msg'] , 'user_created_msg', 500, 250, '70', '10' ) ; ?></td>
	</tr>
	<tr>
		<td colspan="6">
		<hr />
		</td>
	</tr>
	<tr>
		<td colspan="6" align="left">
		<?php echo _SIMPLEMEMBERSHIP_ADMIN_CONFIG_USERACCENABLENOTIFY; ?>:
		</td>
	</tr>
	<tr>
	<td colspan="6"><?php editorArea( 'editor3',  $lists['user_enabled_msg'] , 'user_enabled_msg', 500, 250, '70', '10' ) ; ?></td>
	</tr>
	<tr>
		<td colspan="6">
		<hr />
		</td>
	</tr>
	<tr>
		<td colspan="6" align="left">
		<?php echo _SIMPLEMEMBERSHIP_ADMIN_CONFIG_USERACCAPPROVENOTIFY; ?>:
		</td>
	</tr>
	<tr>
	<td colspan="6"><?php editorArea( 'editor4',  $lists['user_approve_msg'] , 'user_approve_msg', 500, 250, '70', '10' ) ; ?></td>
	</tr>
	<tr>
		<td colspan="6">
		<hr />
		</td>
	</tr>
	<tr>
		<td colspan="6" align="left">
		<?php echo _SIMPLEMEMBERSHIP_ADMIN_CONFIG_USERACCDISAPPROVENOTIFY; ?>:
		</td>
	</tr>
	<tr>
	<td colspan="6"><?php editorArea( 'editor4',  $lists['user_disapprove_msg'] , 'user_disapprove_msg', 500, 250, '70', '10' ) ; ?></td>
	</tr>
			</table>
			<input type="hidden" name="option" value="<?php echo $option; ?>" /> <input
			type="hidden" name="task" value="config_save_backend" /></form>
		<?php
}
function about() {
	global $mosConfig_live_site,$mainframe;
	$tabs = new mosTabs(0);
	//$mainframe->addCustomHeadTag('<link rel="stylesheet" href="'.$mosConfig_live_site.'/administrator/components/com_simplemembership/includes/simplemembership.css" type="text/css" />');
		$doc =JFactory::getDocument();
$doc->addStyleSheet( $mosConfig_live_site.'/administrator/components/com_simplemembership/includes/simplemembership.css' );

	?>
<div
	id="overDiv"
	style="position: absolute; visibility: hidden; z-index: 10000;"></div>
<script type="text/javascript" language="Javascript" src="<?php echo $mosConfig_live_site;?>/includes/js/overlib_mini.js"></script>
<table cellpadding="4" cellspacing="0" border="0" width="100%">
	<tr>
		<td width="30%"> </td>
		<td width="70%" class="simplemembership_manager_caption" valign='bottom'><?php echo _SIMPLEMEMBERSHIP_ADMIN_ABOUT ?>
		</td>
	</tr>
</table>
<form	action="index.php" method="post" name="adminForm" id="adminForm"><?php
	$tabs->startPane("aboutPane");
	$tabs->startTab(_SIMPLEMEMBERSHIP_ADMIN_ABOUT_ABOUT, "display-page");
	?>
<table class="adminform">
	<tr>
		<td width="80%">
		<h3><?PHP echo _SIMPLEMEMBERSHIP__HTML_ABOUT; ?></h3>
		<?PHP echo _SIMPLEMEMBERSHIP__HTML_ABOUT_INTRO; ?></td>
		<td width="20%"><img src="../components/com_simplemembership/images/simplemembership.jpg" align="right"	alt="simplemembership" /></td>
	</tr>
</table>
		<?php
		$tabs->endTab();
		//******************************   tab--2 about   **************************************
		$tabs->startTab(_SIMPLEMEMBERSHIP_ADMIN_ABOUT_RELEASENOTE, "display-page");
		include_once("./components/com_simplemembership/doc/releasenote.php");
		$tabs->endTab();
		//******************************   tab--3 about--changelog.txt   ***********************
		$tabs->startTab(_SIMPLEMEMBERSHIP_ADMIN_ABOUT_CHANGELOG, "display-page");
		include_once("./components/com_simplemembership/doc/changelog.html");
		$tabs->endTab();
    //******************************   tab--4 about--help   ***********************
    $tabs->startTab(_SIMPLEMEMBERSHIP_ADMIN_ABOUT_HELP, "display-page");
    include_once("./components/com_simplemembership/doc/help.html");
    $tabs->endTab();
    $tabs->endPane();
		?>
</form>
		<?php
}

function getErrMsg($err_code)
{
	switch($err_code)
	{
		case 'dug':
			$str = 'Unappropriated joomla group for this simplemembership group';
			break;
		case 'texp':
			$str = 'Time expired';
			break;
		default:
			$str = '';
			break;
	}
	return $str;
}
}
?>
