aboutsummaryrefslogtreecommitdiff
path: root/views/default/output/confirmlink.php
blob: 0843083f0d727a9cbe2c4f04b90ad0efe3449b6a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php

	/**
	 * Elgg confirmation link
	 * A link that displays a confirmation dialog before it executes
	 * 
	 * @package Elgg
	 * @subpackage Core
	 * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
	 * @author Curverider Ltd
	 * @copyright Curverider Ltd 2008-2009
	 * @link http://elgg.org/
	 * 
	 * @uses $vars['text'] The text of the link
	 * @uses $vars['href'] The address
	 * @uses $vars['confirm'] The dialog text
	 * 
	 */

	$confirm = $vars['confirm'];
	if (!$confirm)
		$confirm = elgg_echo('question:areyousure');
		
	$link = $vars['href'];
	
	if ($vars['is_action'])
	{
		$ts = time();
		$token = generate_action_token($ts);
    	
    	$sep = "?";
		if (strpos($link, '?')>0) $sep = "&";
		$link = "$link{$sep}__elgg_token=$token&__elgg_ts=$ts";
	}
?>
<a href="<?php echo $link; ?>" onclick="return confirm('<?php echo addslashes($confirm); ?>');"><?php echo htmlentities($vars['text'], ENT_QUOTES, 'UTF-8'); ?></a>