Commit 01983dfd authored by Francesco Iannuzzelli's avatar Francesco Iannuzzelli

Additional role for topic keywords

parent f7286b53
......@@ -664,7 +664,7 @@ echo $hh->input_keywords($id,$o->types['article'],$keywords,$input_right);
if($id_topic>0)
{
$tikeywords = $t->KeywordsInternal($o->types['article']);
echo $hh->input_internal_keywords($id,$tikeywords,"article",$input_super_right,$input_right,true);
echo $hh->input_internal_keywords($id,$tikeywords,"article",$input_super_right,$input_right,true,$input_super_super_right);
}
echo $hh->input_checkbox("highlight","highlight",$article['highlight'],0,$input_super_super_right);
......
......@@ -211,7 +211,7 @@ if ($from=="keyword")
{
$action = $fh->ActionGet($post);
$id_keyword = $post['id_keyword'];
$only_admin = $fh->Checkbox2bool($post['only_admin']);
$role = $fh->String2Number($post['role']);
$module_admin = $ah->CheckModule();
$bb = new Books();
if($module_admin && $id_keyword>0)
......@@ -219,9 +219,9 @@ if ($from=="keyword")
if ($action=="delete")
$bb->KeywordDelete($id_keyword);
if ($action=="insert")
$bb->KeywordAdd($id_keyword,$only_admin);
$bb->KeywordAdd($id_keyword,$role);
if ($action=="update")
$bb->KeywordUpdate($id_keyword,$only_admin);
$bb->KeywordUpdate($id_keyword,$role);
}
header("Location: keywords.php");
}
......
......@@ -42,7 +42,7 @@ $row = $k->KeywordGet($id_keyword);
$title[] = array('configuration','config.php');
$title[] = array('keywords_internal','keywords.php');
$keyword = $bb->KeywordGet($id_keyword);
$only_admin = $keyword['id_keyword']>0? $keyword['only_admin'] : 1;
$role = $keyword['id_keyword']>0? $keyword['role'] : 1;
if($id_keyword>0)
{
......@@ -66,7 +66,8 @@ if($id_keyword>0)
echo $hh->input_table_open();
echo $hh->input_text("keyword","keyword",$row['keyword'],50,0,0);
echo $hh->input_textarea("description","description",$row['description'],80,7,"",0);
echo $hh->input_checkbox("only_admin","only_admin",$only_admin,0,$input_right);
$role_options = $hh->tr->Translate("role_options");
echo $hh->input_array("management","role",$role,$role_options,$input_right);
$actions = array();
$actions[] = array('action'=>($keyword['id_keyword']>0?"update":"insert"),'label'=>"submit",'right'=>$input_right);
$actions[] = array('action'=>"delete",'label'=>"delete",'right'=>($keyword['id_keyword']>0 && $input_right));
......
......@@ -260,16 +260,16 @@ if ($from=="video_keyword")
{
$action = $fh->ActionGet($post);
$id_keyword = $post['id_keyword'];
$only_admin = $fh->Checkbox2bool($post['only_admin']);
$role = $fh->String2Number($post['role']);
$module_admin = $ah->CheckModule();
if($module_admin && $id_keyword>0)
{
if ($action=="delete")
$vi->KeywordDelete($id_keyword);
if ($action=="insert")
$vi->KeywordAdd($id_keyword,$only_admin);
$vi->KeywordAdd($id_keyword,$role);
if ($action=="update")
$vi->KeywordUpdate($id_keyword,$only_admin);
$vi->KeywordUpdate($id_keyword,$role);
}
header("Location: keywords.php");
}
......@@ -278,16 +278,16 @@ if ($from=="audio_keyword")
{
$action = $fh->ActionGet($post);
$id_keyword = $post['id_keyword'];
$only_admin = $fh->Checkbox2bool($post['only_admin']);
$role = $fh->String2Number($post['role']);
$module_admin = $ah->CheckModule();
if($module_admin && $id_keyword>0)
{
if ($action=="delete")
$au->KeywordDelete($id_keyword);
if ($action=="insert")
$au->KeywordAdd($id_keyword,$only_admin);
$au->KeywordAdd($id_keyword,$role);
if ($action=="update")
$au->KeywordUpdate($id_keyword,$only_admin);
$au->KeywordUpdate($id_keyword,$role);
}
header("Location: keywords.php");
}
......
......@@ -43,7 +43,7 @@ $row = $k->KeywordGet($id_keyword);
$title[] = array('configuration','config.php');
$title[] = array('keywords_internal','keywords.php');
$keyword = $au->KeywordGet($id_keyword);
$only_admin = $keyword['id_keyword']>0? $keyword['only_admin'] : 1;
$role = $keyword['id_keyword']>0? $keyword['role'] : 1;
if($id_keyword>0)
{
......@@ -67,7 +67,8 @@ if($id_keyword>0)
echo $hh->input_table_open();
echo $hh->input_text("keyword","keyword",$row['keyword'],50,0,0);
echo $hh->input_textarea("description","description",$row['description'],80,7,"",0);
echo $hh->input_checkbox("only_admin","only_admin",$only_admin,0,$input_right);
$role_options = $hh->tr->Translate("role_options");
echo $hh->input_array("management","role",$role,$role_options,$input_right);
$actions = array();
$actions[] = array('action'=>($keyword['id_keyword']>0?"update":"insert"),'label'=>"submit",'right'=>$input_right);
$actions[] = array('action'=>"delete",'label'=>"delete",'right'=>($keyword['id_keyword']>0 && $input_right));
......
......@@ -43,7 +43,7 @@ $row = $k->KeywordGet($id_keyword);
$title[] = array('configuration','config.php');
$title[] = array('keywords_internal','keywords.php');
$keyword = $vi->KeywordGet($id_keyword);
$only_admin = $keyword['id_keyword']>0? $keyword['only_admin'] : 1;
$role = $keyword['id_keyword']>0? $keyword['role'] : 1;
if($id_keyword>0)
{
......@@ -67,7 +67,8 @@ if($id_keyword>0)
echo $hh->input_table_open();
echo $hh->input_text("keyword","keyword",$row['keyword'],50,0,0);
echo $hh->input_textarea("description","description",$row['description'],80,7,"",0);
echo $hh->input_checkbox("only_admin","only_admin",$only_admin,0,$input_right);
$role_options = $hh->tr->Translate("role_options");
echo $hh->input_array("management","role",$role,$role_options,$input_right);
$actions = array();
$actions[] = array('action'=>($keyword['id_keyword']>0?"update":"insert"),'label'=>"submit",'right'=>$input_right);
$actions[] = array('action'=>"delete",'label'=>"delete",'right'=>($keyword['id_keyword']>0 && $input_right));
......
......@@ -1530,7 +1530,7 @@ if ($from=="topic_keyword")
$action = $fh->ActionGet($post);
$id_topic = $post['id_topic'];
$id_keyword = $post['id_keyword'];
$only_admin = $fh->Checkbox2bool($post['only_admin']);
$role = $fh->String2Number($post['role']);
$id_res_type = $post['id_res_type'];
$module_admin = $ah->CheckModule();
$t = new Topic($id_topic);
......@@ -1539,9 +1539,9 @@ if ($from=="topic_keyword")
if ($action=="delete")
$t->KeywordDelete($id_keyword);
if ($action=="insert")
$t->KeywordAdd($id_keyword,$id_res_type,$only_admin);
$t->KeywordAdd($id_keyword,$id_res_type,$role);
if ($action=="update")
$t->KeywordUpdate($id_keyword,$id_res_type,$only_admin);
$t->KeywordUpdate($id_keyword,$id_res_type,$role);
}
header("Location: topic_keywords.php?id=$id_topic");
}
......
......@@ -44,7 +44,7 @@ $title[] = array($t->name,'ops.php?id='.$id_topic);
$title[] = array('settings_main','topic.php?id='.$id_topic);
$title[] = array('keywords_internal','topic_keywords.php?id='.$id_topic);
$keyword = $t->KeywordGet($id_keyword);
$only_admin = $keyword['id_keyword']>0? $keyword['only_admin'] : 1;
$role = $keyword['id_keyword']>0? $keyword['role'] : 1;
if($id_keyword>0)
{
......@@ -79,7 +79,8 @@ if($id_keyword>0)
}
}
echo $hh->input_array("resources_types","id_res_type",$keyword['id_res_type'],$resource_types,$input_right);
echo $hh->input_checkbox("only_admin","only_admin",$only_admin,0,$input_right);
$role_options = $hh->tr->Translate("role_options");
echo $hh->input_array("management","role",$role,$role_options,$input_right);
$actions = array();
$actions[] = array('action'=>($keyword['id_keyword']>0?"update":"insert"),'label'=>"submit",'right'=>$input_right);
$actions[] = array('action'=>"delete",'label'=>"delete",'right'=>($keyword['id_keyword']>0 && $input_right));
......
......@@ -50,16 +50,10 @@ $resources = $hh->tr->Translate("resources");
foreach($ikeywords as $ikeyword)
{
echo "<li>" . $hh->Wrap($ikeyword['keyword'],"<a href=\"topic_keyword.php?id_topic=$id_topic&id={$ikeyword['id_keyword']}\">","</a>",$input_right);
if($ikeyword['id_res_type']>0 || $ikeyword['only_admin'])
if($ikeyword['id_res_type']>0)
{
echo " (";
if($ikeyword['id_res_type']>0)
echo"{$resources[$ikeyword['id_res_type']]}";
if($ikeyword['id_res_type']>0 && $ikeyword['only_admin'])
echo " - ";
if($ikeyword['only_admin'])
echo $hh->tr->Translate("only_admin");
echo ")";
$role_options = $hh->tr->Translate("role_options");
echo " ({$resources[$ikeyword['id_res_type']]} - " . $hh->tr->Translate("management") . ": " . $role_options[$ikeyword['role']] . ")";
}
if($ikeyword['description']!="")
echo "<div class=\"notes\">{$ikeyword['description']}</div>";
......
......@@ -517,7 +517,7 @@ class HtmlHelper
return $input;
}
public function input_internal_keywords($id_resource,$internal_keywords,$res_type,$input_super_right,$input_right,$show_use_info=false)
public function input_internal_keywords($id_resource,$internal_keywords,$res_type,$input_super_right,$input_right,$show_use_info=false,$input_super_super_right=false)
{
$input = "";
$o = new Ontology();
......@@ -530,7 +530,21 @@ class HtmlHelper
$visible_internal_keywords = 0;
foreach($internal_keywords as $tikeyword)
{
$tik_right = $tikeyword['only_admin']? $input_super_right : $input_right;
if($input_super_super_right===false) {
$tik_right = $tikeyword['role']? $input_super_right : $input_right;
} else {
switch($tikeyword['role']) {
case 0:
$tik_right = $input_right;
break;
case 1:
$tik_right = $input_super_right;
break;
case 2:
$tik_right = $input_super_super_right;
break;
}
}
$idesc = $tikeyword['description']!=""? $tikeyword['description'] : $tikeyword['keyword'];
if($tik_right)
{
......
......@@ -196,7 +196,7 @@ class Keyword
{
$rows = array();
$db =& Db::globaldb();
$sqlstr = "SELECT tk.id_topic,t.name,t.description,tk.id_res_type,tk.only_admin
$sqlstr = "SELECT tk.id_topic,t.name,t.description,tk.id_res_type,tk.role
FROM topic_keywords tk
INNER JOIN topics t ON tk.id_topic=t.id_topic
WHERE tk.id_keyword='$id_keyword' ";
......
......@@ -245,12 +245,12 @@ class Media
return $row['id_media']>0;
}
public function KeywordAdd($id_keyword,$only_admin)
public function KeywordAdd($id_keyword,$role)
{
$db =& Db::globaldb();
$db->begin();
$db->lock( "topic_keywords" );
$sqlstr = "INSERT INTO topic_keywords (id_topic,id_keyword,id_res_type,only_admin) VALUES ('0','$id_keyword','$this->id_res_type','$only_admin')";
$sqlstr = "INSERT INTO topic_keywords (id_topic,id_keyword,id_res_type,role) VALUES ('0','$id_keyword','$this->id_res_type','$role')";
$res[] = $db->query( $sqlstr );
Db::finish( $res, $db);
}
......@@ -269,7 +269,7 @@ class Media
{
$row = array();
$db =& Db::globaldb();
$sqlstr = "SELECT k.id_keyword,k.keyword,k.description,tk.id_res_type,tk.only_admin
$sqlstr = "SELECT k.id_keyword,k.keyword,k.description,tk.id_res_type,tk.role
FROM topic_keywords tk
INNER JOIN keywords k ON tk.id_keyword=k.id_keyword
WHERE k.id_keyword='$id_keyword' AND id_topic='0' ";
......@@ -277,12 +277,12 @@ class Media
return $row;
}
public function KeywordUpdate($id_keyword,$only_admin)
public function KeywordUpdate($id_keyword,$role)
{
$db =& Db::globaldb();
$db->begin();
$db->lock( "topic_keywords" );
$sqlstr = "UPDATE topic_keywords SET id_res_type='$this->id_res_type',only_admin='$only_admin'
$sqlstr = "UPDATE topic_keywords SET id_res_type='$this->id_res_type',role='$role'
WHERE id_topic='0' AND id_keyword='$id_keyword' ";
$res[] = $db->query( $sqlstr );
Db::finish( $res, $db);
......@@ -292,7 +292,7 @@ class Media
{
$rows = array();
$db =& Db::globaldb();
$sqlstr = "SELECT tk.id_keyword,k.keyword,k.description,tk.id_res_type,tk.only_admin
$sqlstr = "SELECT tk.id_keyword,k.keyword,k.description,tk.id_res_type,tk.role
FROM topic_keywords tk
INNER JOIN keywords k ON tk.id_keyword=k.id_keyword
WHERE tk.id_topic='0' ";
......
......@@ -59,7 +59,7 @@ define('PHPEACE_VERSION',"2.6.14");
* PhPeace Database version number (integer)
* Increased by 1 for each DB schema change
*/
define('PHPEACE_DB_VERSION',263);
define('PHPEACE_DB_VERSION',264);
/* ##################################### */
......
......@@ -126,6 +126,9 @@ class PhPeaceUpdates
{
switch($version_new)
{
case "292":
$this->UpdateDB("264");
break;
case "288":
$fm->DirAction("uploads/events","check");
$fm->DirAction("uploads/events/orig","check");
......@@ -417,6 +420,9 @@ class PhPeaceUpdates
$db_impl = $dbconf['impl'];
switch($db_version)
{
case "264":
$db->query("ALTER TABLE topic_keywords CHANGE COLUMN only_admin role TINYINT(1) NOT NULL DEFAULT '1'");
break;
case "263":
$db->ColumnAdd("events","facebook_id","VARCHAR(80)","''");
$db->ColumnAdd("events","latitude","DECIMAL(10, 8)","NULL",true);
......
......@@ -1093,12 +1093,12 @@ class Topic
$this->authorized = $row['id_p']>0;
}
public function KeywordAdd($id_keyword,$id_res_type,$only_admin)
public function KeywordAdd($id_keyword,$id_res_type,$role)
{
$db =& Db::globaldb();
$db->begin();
$db->lock( "topic_keywords" );
$sqlstr = "INSERT INTO topic_keywords (id_topic,id_keyword,id_res_type,only_admin) VALUES ('$this->id','$id_keyword','$id_res_type','$only_admin')";
$sqlstr = "INSERT INTO topic_keywords (id_topic,id_keyword,id_res_type,role) VALUES ('$this->id','$id_keyword','$id_res_type','$role')";
$res[] = $db->query( $sqlstr );
Db::finish( $res, $db);
}
......@@ -1117,7 +1117,7 @@ class Topic
{
$row = array();
$db =& Db::globaldb();
$sqlstr = "SELECT k.id_keyword,k.keyword,k.description,tk.id_res_type,tk.only_admin
$sqlstr = "SELECT k.id_keyword,k.keyword,k.description,tk.id_res_type,tk.role
FROM topic_keywords tk
INNER JOIN keywords k ON tk.id_keyword=k.id_keyword
WHERE k.id_keyword='$id_keyword' AND id_topic='$this->id' ";
......@@ -1125,12 +1125,12 @@ class Topic
return $row;
}
public function KeywordUpdate($id_keyword,$id_res_type,$only_admin)
public function KeywordUpdate($id_keyword,$id_res_type,$role)
{
$db =& Db::globaldb();
$db->begin();
$db->lock( "topic_keywords" );
$sqlstr = "UPDATE topic_keywords SET id_res_type='$id_res_type',only_admin='$only_admin'
$sqlstr = "UPDATE topic_keywords SET id_res_type='$id_res_type',role='$role'
WHERE id_topic='$this->id' AND id_keyword='$id_keyword' ";
$res[] = $db->query( $sqlstr );
Db::finish( $res, $db);
......@@ -1196,7 +1196,7 @@ class Topic
{
$rows = array();
$db =& Db::globaldb();
$sqlstr = "SELECT tk.id_keyword,k.keyword,k.description,tk.id_res_type,tk.only_admin
$sqlstr = "SELECT tk.id_keyword,k.keyword,k.description,tk.id_res_type,tk.role
FROM topic_keywords tk
INNER JOIN keywords k ON tk.id_keyword=k.id_keyword
WHERE tk.id_topic='$this->id' ";
......
......@@ -2704,7 +2704,7 @@ CREATE TABLE `topic_keywords` (
`id_topic` smallint(4) NOT NULL DEFAULT '0',
`id_keyword` mediumint(9) NOT NULL DEFAULT '0',
`id_res_type` tinyint(2) NOT NULL DEFAULT '0',
`only_admin` tinyint(1) NOT NULL DEFAULT '1',
`role` tinyint(1) NOT NULL DEFAULT '1',
PRIMARY KEY (`id_topic`,`id_keyword`)
);
/*!40101 SET character_set_client = @saved_cs_client */;
......
......@@ -792,6 +792,7 @@ results = Results
reviews = Reviews
reviews_options = { All | Current topic + generic | Current topic only | Current topic language only | None }
right = Right
role_options = { Collaborators | Administrators | Topic Administrators }
row_none = --None--
salutation = Title (Mr, Mrs, ...)
schedule_add = Add new scheduler action
......
......@@ -792,6 +792,7 @@ results = Risultati
reviews = Recensioni
reviews_options = { Tutte | Questa tematica + generali | Solo questa tematica | Solo lingua di questa tematica | Nessuna }
right = Destra
role_options = { Collaboratori | Amministratori | Amministratori di tematiche }
row_none = --Nessuno--
salutation = Titolo (sig., dott., ing., associazione,...)
schedule_add = Aggiungi nuova azione
......
......@@ -253,12 +253,12 @@ class Books
}
}
public function KeywordAdd($id_keyword,$only_admin)
public function KeywordAdd($id_keyword,$role)
{
$db =& Db::globaldb();
$db->begin();
$db->lock( "topic_keywords" );
$sqlstr = "INSERT INTO topic_keywords (id_topic,id_keyword,id_res_type,only_admin) VALUES ('0','$id_keyword','$this->id_res_type','$only_admin')";
$sqlstr = "INSERT INTO topic_keywords (id_topic,id_keyword,id_res_type,role) VALUES ('0','$id_keyword','$this->id_res_type','$role')";
$res[] = $db->query( $sqlstr );
Db::finish( $res, $db);
}
......@@ -277,7 +277,7 @@ class Books
{
$row = array();
$db =& Db::globaldb();
$sqlstr = "SELECT k.id_keyword,k.keyword,k.description,tk.id_res_type,tk.only_admin
$sqlstr = "SELECT k.id_keyword,k.keyword,k.description,tk.id_res_type,tk.role
FROM topic_keywords tk
INNER JOIN keywords k ON tk.id_keyword=k.id_keyword
WHERE k.id_keyword='$id_keyword' AND id_topic='0' ";
......@@ -285,12 +285,12 @@ class Books
return $row;
}
public function KeywordUpdate($id_keyword,$only_admin)
public function KeywordUpdate($id_keyword,$role)
{
$db =& Db::globaldb();
$db->begin();
$db->lock( "topic_keywords" );
$sqlstr = "UPDATE topic_keywords SET id_res_type='$this->id_res_type',only_admin='$only_admin'
$sqlstr = "UPDATE topic_keywords SET id_res_type='$this->id_res_type',role='$role'
WHERE id_topic='0' AND id_keyword='$id_keyword' ";
$res[] = $db->query( $sqlstr );
Db::finish( $res, $db);
......@@ -300,7 +300,7 @@ class Books
{
$rows = array();
$db =& Db::globaldb();
$sqlstr = "SELECT tk.id_keyword,k.keyword,k.description,tk.id_res_type,tk.only_admin
$sqlstr = "SELECT tk.id_keyword,k.keyword,k.description,tk.id_res_type,tk.role
FROM topic_keywords tk
INNER JOIN keywords k ON tk.id_keyword=k.id_keyword
WHERE tk.id_topic='0' ";
......
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