Esempio n. 1
0
    function viewUser($option, $Itemid, $user_activities, $reviews, $links, $user, $clones = array(), $removed_clones = array(), $lists = array())
    {
        global $mtconf;
        $task2 = strval(JRequest::getCmd('task2', ''));
        if (array_key_exists('clone_owner', $lists)) {
            echo '<script language="javascript" type="text/javascript" src="' . $mtconf->getjconf('live_site') . $mtconf->get('relative_path_to_js_library') . '"></script>';
        }
        JHTML::_('behavior.tooltip');
        ?>
	<script language="javascript" type="text/javascript">
	<?php 
        if (array_key_exists('clone_owner', $lists)) {
            ?>
	jQuery.noConflict();
	function detectOther(ref) {
		if(ref.options[ref.selectedIndex].value == '-1') {
			jQuery('#clone_owner_username').css('display','inline');
			jQuery('#clone_owner_username')[0].focus();
		} else {
			jQuery('#clone_owner_username').css('display','none');
		}
	}
	function removeClone(){
		var owner = '';
		if(jQuery('#clone_owner').val() == '-1') {
			owner = jQuery('#clone_owner_username').val();
		} else {
			owner = jQuery('#clone_owner').val();
		}
		if(owner!='') {
			location.href = "index2.php?option=com_mtree&task=spy&task2=removecloneandalllogs&id=<?php 
            echo $user->id;
            ?>
&owner=" + owner;
		}
	}
	<?php 
        }
        ?>
	function perform_action(ref) {
		switch(ref.options[ref.selectedIndex].value) {
			case '1':
				window.open("<?php 
        echo $mtconf->getjconf('live_site') . '/index.php?option=com_mtree&task=viewowner&user_id=' . $user->id . '&Itemid=' . $Itemid;
        ?>
");
				break;
			case '2':
				location.href = "index.php?option=com_users&view=user&task=edit&cid[]=<?php 
        echo $user->id;
        ?>
";
				break;
			case '3':
				if( confirm('<?php 
        echo JText::_('Confirm remove user and all its data');
        ?>
') ) {
					location.href = "index2.php?option=com_mtree&task=spy&task2=removeuserandalllogs&id=<?php 
        echo $user->id;
        ?>
";
				}
				break;
			case '4':
				jQuery('#clone').slideDown('fast');
				break;
		}
	}

	function submitbutton(pressbutton) {
		var form = document.adminForm;
		form.task.value = 'spy';
		form.task2.value = 'removelogs';
		form.submit();
	}
	</script>
	<div id="overDiv" style="position:absolute; visibility:hidden; z-index:10000;"></div>
	<form action="index2.php" method="post" name="adminForm">
	<table class="adminheading" width="100%">
		<tr><td>
			<fieldset>
			<legend><?php 
        echo $task2 == 'viewclone' ? JText::_('Clone') : JText::_('User');
        ?>
: <?php 
        echo $user->name;
        ?>
</legend>
			<img src="images/user.png" align="left" hspace="15" />
			<table style="font-weight:normal;" width="100%">
			<tr><td width="60%" valign="top">

			<table cellpadding="3">
				<?php 
        if ($task2 == 'viewuser') {
            ?>
				<tr>
					<td align="right" valign="top"><?php 
            echo JText::_('Action');
            ?>
: </td>
					<td valign="top">
						<select id="action" class="text_area" onchange="perform_action(this)">
							<option value=''></option>
							<option value='1'><?php 
            echo JText::_('View users page in front end');
            ?>
</option>
							<option value='2'><?php 
            echo JText::_('Edit user in user manager');
            ?>
</option>
							<?php 
            if (count($links) <= 0) {
                ?>
							
							<option value='3'><?php 
                echo JText::_('Remove user including his her activities');
                ?>
</option>
							<option value='4'><?php 
                echo JText::_('Mark this user as clone');
                ?>
</option>
							<?php 
            }
            ?>
						</select>
						<?php 
            if (count($lists) > 0) {
                echo '<div id="clone" style="display:none">';
                echo '<table cellpadding="2">';
                echo '<tr><td>';
                echo 'Set the clone owner to:';
                echo '&nbsp;';
                echo $lists['clone_owner'];
                echo '&nbsp;<input type="text" id="clone_owner_username" class="text_area" style="display:none" size="20" />';
                echo '</td></tr>';
                echo '<tr><td align="left">';
                echo '<input type="button" onclick="removeClone()" value="' . sprintf(JText::_('Remove s including his her activities'), $user->username) . '" class="inputbox" />';
                echo '&nbsp; or &nbsp;<a href="#" onclick="jQuery(\'#clone\').slideUp(\'fast\');jQuery(\'#action\').val(\'\');return false;">' . JText::_('Cancel') . '</a>';
                echo '</table>';
                echo '</div>';
            }
            ?>
					</td>
				</tr>
				<?php 
        }
        ?>
				<tr>
					<td align="right"><?php 
        echo JText::_('Email');
        ?>
: </td>
					<td><a href="mailto:<?php 
        echo $user->email;
        ?>
"><?php 
        echo $user->email;
        ?>
</a></td>
				</tr>
				<tr>
					<td align="right"><?php 
        echo JText::_('Username');
        ?>
: </td>
					<td><b><?php 
        echo $user->username;
        ?>
</b></td>
				</tr>
				<?php 
        if (count($removed_clones) > 0) {
            echo '<tr>';
            echo '<td align="right">' . JText::_('Removed clones') . '(' . count($removed_clones) . '):</td>';
            echo '<td>';
            $removed_clones_output = array();
            foreach ($removed_clones as $removed_clone) {
                $removed_clones_output[] = mtfHTML::cloneuser($removed_clone->user_id, $removed_clone->username);
            }
            echo implode(', ', $removed_clones_output);
            echo '</td>';
            echo '</tr>';
        }
        ?>
			</table>

			</td>
			<td width="40%" valign="top">

			<table cellpadding="3">
				<tr>
					<td align="right"><?php 
        echo JText::_('User id');
        ?>
: </td>
					<td><b><?php 
        echo $user->id;
        ?>
</b></td>
				</tr>
				<tr>
					<td align="right"><?php 
        echo JText::_('Register');
        ?>
: </td>
					<td><b><?php 
        echo $user->registerDate;
        ?>
</b></td>
				</tr>
				<tr>
					<td align="right"><?php 
        echo JText::_('Last visit');
        ?>
: </td>
					<td><b><?php 
        echo $user->lastvisitDate;
        ?>
</b></td>
				</tr>
			</table>

			</td></tr>
			</table>
			</fieldset>
		</td></tr>
	</table>
	
	<?php 
        if (count($clones) > 0) {
            ?>
	<table class="adminlist">
	<thead>
	<tr align="left">
		<th width="15%"><?php 
            echo JText::_('Ip address');
            ?>
</th>
		<th width="85%" nowrap="nowrap"><?php 
            echo JText::_('Clones');
            ?>
</th>
	</tr>
	</thead>
	<?php 
            $ip = '';
            foreach ($clones as $clone) {
                if (empty($ip) or $ip != $clone->log_ip) {
                    $ip = $clone->log_ip;
                    $clone_count[$clone->log_ip] = 1;
                } else {
                    $clone_count[$clone->log_ip]++;
                }
                $clone_user[$clone->log_ip][] = array('username' => $clone->username, 'user_id' => $clone->user_id, 'name' => $clone->name, 'blocked' => $clone->user_blocked);
            }
            foreach ($clone_count as $ip => $count) {
                echo '<tr align="left">';
                echo '<td>' . $ip . '</td>';
                echo '<td>';
                foreach ($clone_user[$ip] as $cuser) {
                    echo mtfHTML::user($cuser['user_id'], $cuser['username'], '', $cuser['blocked']);
                    echo '&nbsp; ';
                }
                echo '</td>';
                echo '</tr>';
            }
            ?>
	</table><br />
	<?php 
        }
        ?>
			
	<?php 
        if (count($user_activities) == 0) {
            echo '<div align=\'left\'><i>' . JText::_('This user has not cast any votes yet') . '</i></div>';
        } else {
            ?>

	<table class="adminlist">
	<thead>
	<tr align="left">
		<th width="5">#</th>
		<th width="5"><input type="checkbox" name="toggle" value="" onClick="checkAll(<?php 
            echo count($user_activities);
            ?>
);" /></th>
		<th width="22%"><?php 
            echo JText::_('Activities');
            ?>
</th>
		<th width="55%" nowrap="nowrap"><?php 
            echo JText::_('Listing review');
            ?>
</th>
		<th width="10%" nowrap="nowrap"><?php 
            echo JText::_('Ip address');
            ?>
</th>
		<th width="10%" nowrap="nowrap"><?php 
            echo JText::_('Date');
            ?>
</th>
	</tr>
	</thead>
	<?php 
            $c = 0;
            $i = 0;
            foreach ($user_activities as $ua) {
                echo '<tr align="left">';
                echo '<td width="5">' . ++$c . '</td>';
                echo '<td><input type="checkbox" id="cb' . $i . '" name="cid[]" value="' . $ua->log_id . '" onclick="isChecked(this.checked);" /></td>';
                echo '<td>' . mtfHTML::userActivity($ua->log_type, $ua->value, $ua->link_id, $ua->link_name) . '</td>';
                echo '<td>' . mtfHTML::listing($ua->link_id, $ua->link_name, $ua->rev_title, $ua->rev_approved) . '</td>';
                echo '<td>' . mtfHTML::ipAddress($ua->log_ip) . '</td>';
                echo '<td align="right">' . date('j M y, H:i', strtotime($ua->log_date)) . '</td>';
                echo '</tr>';
                $i++;
            }
            ?>
	</table>

	<?php 
        }
        if (count($reviews) == 0) {
            //echo "<div align='left'><i>This user has not written any reviews yet.</i></div>";
        } else {
            ?>
	<br />
	<table class="adminlist" width="100%">
	<thead>
	<tr align="left">
		<th width="5">#</th>
		<th width="22%"><?php 
            echo JText::_('Written reviews');
            ?>
</th>
		<th width="15%" nowrap="nowrap"><?php 
            echo JText::_('Helpfuls');
            ?>
</th>
		<th width="40%" nowrap="nowrap"><?php 
            echo JText::_('Listing');
            ?>
</th>
		<th width="10%" nowrap="nowrap"><?php 
            echo JText::_('Ip address');
            ?>
</th>
		<th width="13%" nowrap="nowrap"><?php 
            echo JText::_('Date');
            ?>
</th>
	</tr>
	</thead>
	<?php 
            $c = 0;
            foreach ($reviews as $review) {
                echo '<tr align="left">';
                echo '<td width="5">' . ++$c . '</td>';
                echo '<td>' . mtfHTML::review($review->rev_id, $review->rev_title, $review->rev_text) . '</td>';
                echo '<td>' . mtfHTML::helpfuls($review->vote_helpful, $review->vote_total) . '</td>';
                echo '<td>' . '<a href="index2.php?option=' . $option . '&task=spy&task2=viewlisting&id=' . $review->link_id . '">' . $review->link_name . '</a></td>';
                if (!empty($review->log_ip)) {
                    echo '<td>' . mtfHTML::ipAddress($review->log_ip) . '</a></td>';
                } else {
                    echo '<td>-</td>';
                }
                echo '<td>' . date('j M y, H:i', strtotime($review->rev_date)) . '</td>';
                echo '</tr>';
            }
            ?>
	</table>
	<?php 
        }
        if (count($links) > 0) {
            ?>
	<br />
	<table class="adminlist" width="100%">
	<thead>
	<tr align="left">
		<th width="5">#</th>
		<th width="40%"><?php 
            echo JText::_('Owned listings');
            ?>
</th>
		<th width="20%" nowrap="nowrap"><?php 
            echo JText::_('Ratings and votes');
            ?>
</th>
		<th width="10%" nowrap="nowrap"><?php 
            echo JText::_('Reviews');
            ?>
</th>
		<th width="10%" nowrap="nowrap"><?php 
            echo JText::_('Hits');
            ?>
</th>
		<th width="10%" nowrap="nowrap"><?php 
            echo JText::_('Created');
            ?>
</th>
		<th width="10%" nowrap="nowrap"><?php 
            echo JText::_('Modified');
            ?>
</th>
	</tr>
	</thead>
	<?php 
            $c = 0;
            foreach ($links as $link) {
                echo '<tr align="left">';
                echo '<td width="5">' . ++$c . '</td>';
                echo '<td>' . mtfHTML::listing($link->link_id, $link->link_name) . '</td>';
                echo '<td>' . mtfHTML::rating($link->link_rating) . '&nbsp; ' . $link->link_votes . ' votes</td>';
                echo '<td>' . $link->reviews . '</td>';
                echo '<td>' . $link->link_hits . '</td>';
                echo '<td>' . date('j M', strtotime($link->link_created)) . '</td>';
                echo '<td>' . date('j M', strtotime($link->link_modified)) . '</td>';
                echo '</tr>';
            }
            ?>
	</table>
	<?php 
        }
        ?>

	<input type="hidden" name="option" value="<?php 
        echo $option;
        ?>
" />
	<input type="hidden" name="task" value="spy" />
	<input type="hidden" name="task2" value="viewuser" />
	<input type="hidden" name="boxchecked" value="0" />
	</form>
	<?php 
    }