<commit_before><?php
// (c) Copyright 2002-2009 by authors of the Tiki Wiki/CMS/Groupware Project
// 
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id: /cvsroot/tikiwiki/tiki/tiki-user_watches.php,v 1.21.2.1 2008-03-13 21:00:48 sylvieg Exp $
$section = 'mytiki';
include_once ('tiki-setup.php');
include_once('lib/reportslib.php');

if ($prefs['feature_ajax'] == "y") {
	require_once ('lib/ajax/ajaxlib.php');
}
if (!$user) {
	$smarty->assign('msg', tra("You must log in to use this feature"));
	$smarty->assign('errortype', '402');
	$smarty->display("error.tpl");
	die;
}
if ($prefs['feature_user_watches'] != 'y') {
	$smarty->assign('msg', tra("This feature is disabled") . ": feature_user_watches");
	$smarty->display("error.tpl");
	die;
}
if ($prefs['feature_user_watches_translations']) {
	$languages = $tikilib->list_languages();
	$smarty->assign_by_ref('languages', $languages);
}
$add_options = array();
if ($prefs['feature_articles'] == 'y') {
	$add_options['article_submitted'] = tra('A user submits an article');
	$add_options['article_edited'] = tra('A user edits an article');
	$add_options['article_deleted'] = tra('A user deletes an article');
}
if ($prefs['feature_wiki'] == 'y') {
	$add_options['wiki_page_changes'] = tra('Any wiki page is changed');
}
if ($prefs['feature_user_watches_translations'] == 'y') {
	$add_options['wiki_page_in_lang_created'] = tra('A new page is created in a language');
}
if ($prefs['feature_user_watches_languages'] == 'y') {
	$add_options['category_changed_in_lang'] = tra('Category change in a language');
}

$smarty->assign('add_options', $add_options);
if (isset($_POST['langwatch'])) {
	foreach($languages as $lang) if ($_POST['langwatch'] == $lang['value']) {
		$langwatch = $lang;
		break;
	}
} else {
	$langwatch = null;
}

if ($prefs['feature_categories']) {
	include_once ('lib/categories/categlib.php');
	$categories = $categlib->list_categs();
} else {
	$categories = array();
}

if ( isset($_REQUEST['categwatch']) ) {
	$selected_categ = null;
	foreach( $categories as $categ ) {
		if ( $_REQUEST['categwatch'] == $categ['categId'] ) {
			$selected_categ = $categ;
			break;
		}
	}
}

if (isset($_REQUEST['id'])) {
	$area = 'deluserwatch';
	if ($prefs['feature_ticketlib2'] != 'y' or (isset($_POST['daconfirm']) and isset($_SESSION["ticket_$area"]))) {
		key_check($area);
		$error = $tikilib->remove_user_watch_by_id($_REQUEST['id']);
		$smarty->assign('remove_user_watch_error', !$error);
	} else {
		key_get($area);
	}
}

if (isset($_REQUEST["add"])) {
	if (isset($_REQUEST['event'])) {
		switch ($_REQUEST['event']) {
			case 'article_submitted':
				$watch_object = "*";
				$watch_type = 'article';
				$watch_label = '*';<commit_msg>[MOD]watch: avoid confirmation step if no perms<commit_after><?php
// (c) Copyright 2002-2009 by authors of the Tiki Wiki/CMS/Groupware Project
// 
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id: /cvsroot/tikiwiki/tiki/tiki-user_watches.php,v 1.21.2.1 2008-03-13 21:00:48 sylvieg Exp $
$section = 'mytiki';
include_once ('tiki-setup.php');
include_once('lib/reportslib.php');

if ($prefs['feature_ajax'] == "y") {
	require_once ('lib/ajax/ajaxlib.php');
}
if (!$user) {
	$smarty->assign('msg', tra("You must log in to use this feature"));
	$smarty->assign('errortype', '402');
	$smarty->display("error.tpl");
	die;
}
if ($prefs['feature_user_watches'] != 'y') {
	$smarty->assign('msg', tra("This feature is disabled") . ": feature_user_watches");
	$smarty->display("error.tpl");
	die;
}
if ($prefs['feature_user_watches_translations']) {
	$languages = $tikilib->list_languages();
	$smarty->assign_by_ref('languages', $languages);
}
$add_options = array();
if ($prefs['feature_articles'] == 'y') {
	$add_options['article_submitted'] = tra('A user submits an article');
	$add_options['article_edited'] = tra('A user edits an article');
	$add_options['article_deleted'] = tra('A user deletes an article');
}
if ($prefs['feature_wiki'] == 'y') {
	$add_options['wiki_page_changes'] = tra('Any wiki page is changed');
}
if ($prefs['feature_user_watches_translations'] == 'y') {
	$add_options['wiki_page_in_lang_created'] = tra('A new page is created in a language');
}
if ($prefs['feature_user_watches_languages'] == 'y') {
	$add_options['category_changed_in_lang'] = tra('Category change in a language');
}

$smarty->assign('add_options', $add_options);
if (isset($_POST['langwatch'])) {
	foreach($languages as $lang) if ($_POST['langwatch'] == $lang['value']) {
		$langwatch = $lang;
		break;
	}
} else {
	$langwatch = null;
}

if ($prefs['feature_categories']) {
	include_once ('lib/categories/categlib.php');
	$categories = $categlib->list_categs();
} else {
	$categories = array();
}

if ( isset($_REQUEST['categwatch']) ) {
	$selected_categ = null;
	foreach( $categories as $categ ) {
		if ( $_REQUEST['categwatch'] == $categ['categId'] ) {
			$selected_categ = $categ;
			break;
		}
	}
}

if (isset($_REQUEST['id'])) {
	if ($tiki_p_admin_notifications != 'y' && $user != $tikilib->get_user_notification($_REQUEST['id'])) {
		$smarty->assign('errortype', 401);
		$smarty->assign('msg', tra("Permission denied"));
		$smarty->display("error.tpl");
		die;
	}
	$area = 'deluserwatch';
	if ($prefs['feature_ticketlib2'] != 'y' or (isset($_POST['daconfirm']) and isset($_SESSION["ticket_$area"]))) {
		key_check($area);
		$error = $tikilib->remove_user_watch_by_id($_REQUEST['id']);
		$smarty->assign('remove_user_watch_error', !$error);
	} else {
		key_get($area, tra('Remove the notification email'));
	}
}

if (isset($_REQUEST["add"])) {
	if (isset($_REQUEST['event'])) {
		switch ($_REQUEST['event']) {
			case 'article_submitted':
				$watch_object = "*";
				$watch_type = 'article';
				$watch_label = '*';
{'fraction_non_alphanumeric': 0.2, 'fraction_numerical': 0.010887772194304857, 'mean_word_length': 5.7468926553672315, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3356006', 'n_tokens_mistral': 2268, 'n_tokens_neox': 2144, 'n_words': 436}