diff --git a/FAQTag.sopm b/FAQTag.sopm new file mode 100755 index 0000000..a0bb773 --- /dev/null +++ b/FAQTag.sopm @@ -0,0 +1,39 @@ + + + FAQTag + 1.0 + SeTIC + http://setic.ufsc.br + GNU GENERAL PUBLIC LICENSE Version 2, June 1991 + Módulo criado. + Cadastro de tags para gerar links dinâmicos e reduzidos para as categorias da FAQ. + 3.3.x + Módulo de tags instalado. + ? + ? + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/GeraOpm.sh b/GeraOpm.sh new file mode 100755 index 0000000..84198a1 --- /dev/null +++ b/GeraOpm.sh @@ -0,0 +1,4 @@ +#!/bin/bash +LOCAL="$PWD" +cd /opt/otrs/bin +./otrs.PackageManager.pl -a build -p "$LOCAL"/FAQTag.sopm \ No newline at end of file diff --git a/Kernel/Config/Files/FAQTag.xml b/Kernel/Config/Files/FAQTag.xml new file mode 100755 index 0000000..b0c457f --- /dev/null +++ b/Kernel/Config/Files/FAQTag.xml @@ -0,0 +1,66 @@ + + + + Frontend module registration for the agent interface. + FAQ + Frontend::Agent::ModuleRegistration + + + faq + faq + FAQTag Overview + FAQ + + faq + Cadastro de tags para categorias + Tag + Action=AgentFAQTagOverview + + + FAQ + 970 + + + + + + + + Frontend module registration for the agent interface. + FAQ + Frontend::Agent::ModuleRegistration + + + FAQTag add + faq + Adicionar e atualizar tags + FAQ + + + + + Redirecionamento da página de categoria da FAQ. + FAQ + Frontend::Agent::ModuleRegistration + + + Redirecionar FAQ + faq + Redirecionamento da página de categoria da FAQ. + FAQ + + + + + Redirecionamento da página de categoria da FAQ. + FAQ + Frontend::Public::ModuleRegistration + + + Redirecionar FAQ + Redirecionamento da página de categoria da FAQ. + FAQ + + + + diff --git a/Kernel/Modules/AgentFAQTagAdd.pm b/Kernel/Modules/AgentFAQTagAdd.pm new file mode 100755 index 0000000..3fb1cf3 --- /dev/null +++ b/Kernel/Modules/AgentFAQTagAdd.pm @@ -0,0 +1,110 @@ + + +package Kernel::Modules::AgentFAQTagAdd; + +use strict; +use warnings; + +sub new { + my ( $Type, %Param ) = @_; + + # allocate new hash for object + my $Self = {%Param}; + bless ($Self, $Type); + + # check needed objects + for (qw(ParamObject DBObject TicketObject LayoutObject LogObject QueueObject ConfigObject EncodeObject MainObject)) { + if ( !$Self->{$_} ) { + $Self->{LayoutObject}->FatalError( Message => "Got no $_!" ); + } + } + return $Self; +} + +sub Run { + my ( $Self, %Param ) = @_; + my %Data = (); + + my $Tag_id = $Self->{ParamObject}->GetParam( Param => 'id' ); + my $Category = $Self->{ParamObject}->GetParam( Param => 'category' ); + my $Tag = $Self->{ParamObject}->GetParam( Param => 'tag' ); + my $Existe_Tag = 0; + + if ($Self->{ParamObject}->GetParam( Param => 'Subaction' ) eq "update") { + + if ($Self->_ExisteTag(tag => $Tag)){ + $Existe_Tag = 1; + + }else{ + if($Self->_GetTag(id => $Tag_id) eq undef){ + $Self->{DBObject}->Do( + SQL => "INSERT into faq_tag (category_id, tag) values ((select id from faq_category where name= ?), ?)", + Bind => [\$Category, \$Tag], + ); + return $Self->{LayoutObject}->Redirect( OP => 'Action=AgentFAQTagOverview&added='.$Tag ); + + }else{ + $Self->{DBObject}->Do( + SQL => "update faq_tag set tag=? where id=?", + Bind => [\$Tag, \$Tag_id], + ); + return $Self->{LayoutObject}->Redirect( OP => 'Action=AgentFAQTagOverview&edited='.$Tag ); + } + } + } + + $Self->{LayoutObject}->Block( + Name=> 'info', + Data=> {id => $Tag_id, + category => $Category, + tag => $Tag, + } + ); + + # build output + my $Output = $Self->{LayoutObject}->Header(Title => "Tag"); + + if($Existe_Tag == 1){ + $Output .= $Self->{LayoutObject}->Notify(Priority => 'Error', Info=> "A tag ".$Tag." j\x{e1} existe."); + } + $Output .= $Self->{LayoutObject}->NavigationBar(); + $Output .= $Self->{LayoutObject}->Output( + Data => \%Data, + TemplateFile => 'AgentFAQTagAdd', + ); + $Output .= $Self->{LayoutObject}->Footer(); + return $Output; +} + +sub _GetTag { + + my ( $Self, %Param ) = @_; + + + $Self->{DBObject}->Prepare( + SQL => "select tag from faq_tag where id = $Param{id}", + ); + my $TAG; + while (my @Row = $Self->{DBObject}->FetchrowArray()) { + $TAG = $Row[0]; + } + return $TAG; + +} + +sub _ExisteTag { + + my ( $Self, %Param ) = @_; + + + $Self->{DBObject}->Prepare( + SQL => "select id from faq_tag where tag = '$Param{tag}'", + ); + my $Id; + while (my @Row = $Self->{DBObject}->FetchrowArray()) { + $Id = $Row[0]; + } + return $Id; + +} +1; diff --git a/Kernel/Modules/AgentFAQTagOverview.pm b/Kernel/Modules/AgentFAQTagOverview.pm new file mode 100755 index 0000000..bd570a6 --- /dev/null +++ b/Kernel/Modules/AgentFAQTagOverview.pm @@ -0,0 +1,69 @@ + +package Kernel::Modules::AgentFAQTagOverview; + +use strict; +use warnings; + +sub new { + my ( $Type, %Param ) = @_; + + # allocate new hash for object + my $Self = {%Param}; + bless ($Self, $Type); + + # check needed objects + for (qw(ParamObject DBObject TicketObject LayoutObject LogObject QueueObject ConfigObject EncodeObject MainObject)) { + if ( !$Self->{$_} ) { + $Self->{LayoutObject}->FatalError( Message => "Got no $_!" ); + } + } + + return $Self; +} + +sub Run { + my ( $Self, %Param ) = @_; + my %Data = (); + + if ($Self->{ParamObject}->GetParam( Param => 'Subaction' ) eq "delete") { + my $Var1 = $Self->{ParamObject}->GetParam( Param => 'id' ); + $Self->{DBObject}->Do( + SQL => "DELETE FROM faq_tag where id=?", + Bind => [ \$Var1 ], + ); + } + + + $Self->{DBObject}->Prepare( + SQL => "select faq_tag.id, faq_tag.tag, faq_category.name from faq_category left join faq_tag on (faq_category.id = faq_tag.category_id)", + ); + + while (my @Row = $Self->{DBObject}->FetchrowArray()) { + $Self->{LayoutObject}->Block( + Name=> 'dadostabela', + Data=> {id=>$Row[0], tag=>$Row[1], category=>$Row[2]} + ); + } + + # build output + my $Output = $Self->{LayoutObject}->Header(Title => "Tag"); + + if ($Self->{ParamObject}->GetParam( Param => 'added' )) { + my $Added = $Self->{ParamObject}->GetParam( Param => 'added' ); + $Output .= $Self->{LayoutObject}->Notify( Info => 'Tag '.$Added.' adicionada!' ); + } + if ($Self->{ParamObject}->GetParam( Param => 'edited' )) { + my $Edited = $Self->{ParamObject}->GetParam( Param => 'edited' ); + $Output .= $Self->{LayoutObject}->Notify( Info => 'Tag '.$Edited.' modificada!' ); + } + + $Output .= $Self->{LayoutObject}->NavigationBar(); + $Output .= $Self->{LayoutObject}->Output( + Data => \%Data, + TemplateFile => 'AgentFAQTagOverview', + ); + $Output .= $Self->{LayoutObject}->Footer(); + return $Output; + +} +1; diff --git a/Kernel/Modules/PublicRedirectFAQ.pm b/Kernel/Modules/PublicRedirectFAQ.pm new file mode 100755 index 0000000..6a8fc9e --- /dev/null +++ b/Kernel/Modules/PublicRedirectFAQ.pm @@ -0,0 +1,55 @@ + +package Kernel::Modules::PublicRedirectFAQ; + +use strict; +use warnings; + +sub new { + my ( $Type, %Param ) = @_; + + # allocate new hash for object + my $Self = {%Param}; + bless ($Self, $Type); + + # check needed objects + for (qw(ParamObject DBObject LayoutObject LogObject ConfigObject EncodeObject MainObject)) { + if ( !$Self->{$_} ) { + $Self->{LayoutObject}->FatalError( Message => "Got no $_!" ); + } + } + return $Self; +} + +sub Run { + my ( $Self, %Param ) = @_; + my %Data = (); + + my $Tag = $Self->{ParamObject}->GetParam( Param => 'id' ); + if(!$Tag){ + $Self->{LayoutObject}->FatalError( Message => "Especifique a tag" ); + } + + my $Id = $Self->_GetCategoryID(tag => "$Tag"); + if(!$Id){ + $Self->{LayoutObject}->FatalError( Message => "A tag $Tag n\x{e3}o existe!" ); + } + + return $Self->{LayoutObject}->Redirect( ExtURL => 'public.pl?Action=PublicFAQExplorer;CategoryID='.$Id, ); + +} + +sub _GetCategoryID { + + my ( $Self, %Param ) = @_; + + + $Self->{DBObject}->Prepare( + SQL => "select category_id from faq_tag where tag = '$Param{tag}'", + ); + my $ID; + while (my @Row = $Self->{DBObject}->FetchrowArray()) { + $ID = $Row[0]; + } + return $ID; +} +1; diff --git a/Kernel/Modules/RedirectFAQ.pm b/Kernel/Modules/RedirectFAQ.pm new file mode 100755 index 0000000..db70270 --- /dev/null +++ b/Kernel/Modules/RedirectFAQ.pm @@ -0,0 +1,56 @@ + +package Kernel::Modules::RedirectFAQ; + +use strict; +use warnings; + +sub new { + my ( $Type, %Param ) = @_; + + # allocate new hash for object + my $Self = {%Param}; + bless ($Self, $Type); + + # check needed objects + for (qw(ParamObject DBObject TicketObject LayoutObject LogObject QueueObject ConfigObject EncodeObject MainObject)) { + if ( !$Self->{$_} ) { + $Self->{LayoutObject}->FatalError( Message => "Got no $_!" ); + } + } + return $Self; +} + +sub Run { + my ( $Self, %Param ) = @_; + my %Data = (); + + my $Tag = $Self->{ParamObject}->GetParam( Param => 'id' ); + if(!$Tag){ + $Self->{LayoutObject}->FatalError( Message => "Especifique a tag" ); + } + + my $Id = $Self->_GetCategoryID(tag => "$Tag"); + if(!$Id){ + $Self->{LayoutObject}->FatalError( Message => "A tag $Tag n\x{e3}o existe!" ); + } + + return $Self->{LayoutObject}->Redirect( OP => 'Action=AgentFAQExplorer;CategoryID='.$Id, ); + +} + +sub _GetCategoryID { + + my ( $Self, %Param ) = @_; + + + $Self->{DBObject}->Prepare( + SQL => "select category_id from faq_tag where tag = '$Param{tag}'", + ); + my $ID; + while (my @Row = $Self->{DBObject}->FetchrowArray()) { + $ID = $Row[0]; + } + return $ID; + +} +1; diff --git a/Kernel/Output/HTML/Standard/AgentFAQTagAdd.dtl b/Kernel/Output/HTML/Standard/AgentFAQTagAdd.dtl new file mode 100755 index 0000000..9024750 --- /dev/null +++ b/Kernel/Output/HTML/Standard/AgentFAQTagAdd.dtl @@ -0,0 +1,74 @@ + + + +
+ +
+ + +
+

$Text{"Gerenciamento de Materiais"}

+
+
+
+

$Text{"Actions"}

+
+ +
+
+
+
+
+ +

Editar Tag: $QData{"category"}

+
+
+
+ + +
+ + + +
+
+
+ + $Text{"or"} + Cancelar +
+
+ +
+
+
+
+
+ +
+
+ + + diff --git a/Kernel/Output/HTML/Standard/AgentFAQTagOverview.dtl b/Kernel/Output/HTML/Standard/AgentFAQTagOverview.dtl new file mode 100755 index 0000000..45a1c43 --- /dev/null +++ b/Kernel/Output/HTML/Standard/AgentFAQTagOverview.dtl @@ -0,0 +1,56 @@ + +
+

$Text{"Gerenciamento de Tags"}

+
+
+
+

$Text{"Hint"}

+
+
+

Tabela de todas as categorias da FAQ com suas respectivas tags.

+

Adicione uma tag para gerar um endereço mais simples a determinada categoria.

+
+
+
+
+
+
+

Lista

+
+
+ + + + + + + + + + + + + + + + + +
CategoriaTagExcluir
$QData{"category"}$QData{"tag"} + +
+
+
+
+
+ + diff --git a/README b/README new file mode 100755 index 0000000..e69de29 --- /dev/null +++ b/README -- libgit2 0.21.2