Commit 5e58ca16 authored by Francesco Iannuzzelli's avatar Francesco Iannuzzelli

Remove keyword by user

parent 490025b3
......@@ -98,6 +98,15 @@ class Ontology
}
}
public function KeywordRemove($id, $id_type, $id_keyword) {
$res = array();
$db =& Db::globaldb();
$db->begin();
$db->lock( "keywords_use" );
$res[] = $db->query( "DELETE FROM keywords_use WHERE id=$id AND id_type=$id_type AND id_keyword=$id_keyword" );
Db::finish( $res, $db);
}
public function InsertKeywordsArray($keywords,$id_item,$id_type)
{
if(count($keywords)>0)
......
<?php
/********************************************************************
PhPeace - Portal Management System
Copyright notice
(C) 2003-2019 Francesco Iannuzzelli <[email protected]>
All rights reserved
This script is part of PhPeace.
PhPeace is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
PhPeace is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
The GNU General Public License (GPL) is available at
http://www.gnu.org/copyleft/gpl.html.
A copy can be found in the file COPYING distributed with
these scripts.
This copyright notice MUST APPEAR in all copies of the script!
********************************************************************/
$_SERVER['DOCUMENT_ROOT'] = realpath("../");
define('SERVER_ROOT',$_SERVER['DOCUMENT_ROOT']);
$options = getopt("k:u:");
if(is_array($options) && isset($options['k']) && isset($options['u']) && $options['k']!="" && $options['u']>0)
{
$id_user = (int)$options['u'];
include_once(SERVER_ROOT."/../classes/keyword.php");
$k = new Keyword();
$keyword = $k->KeywordCheck($options['k']);
if($id_user>0 && isset($keyword['id_keyword'])) {
$articles = array();
// find all articles associated to this keyword
$num_articles = $k->UseArticlesPaged($articles,$keyword['id_keyword'],0,0);
if($num_articles>0) {
include_once(SERVER_ROOT."/../classes/ontology.php");
$o = new Ontology;
foreach($articles as $article) {
$o->KeywordRemove($article['id_article'], $o->types['article'], $keyword['id_keyword']);
echo "Keyword {$options['k']} removed from article \"{$article['headline']}\"\n";
}
$articles_left = $num_articles - count($articles);
if($articles_left>0) {
echo "There are $articles_left articles left, please run it again\n";
}
} else {
echo "No articles with keyword $keyword by user $id_user\n";
}
}
}
?>
#! /bin/sh
CURRENTDIR=`dirname $0`
cd $CURRENTDIR
php $CURRENTDIR/remove_keyword_by_user.php -k $1 -u $2
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment