Commit 4081bf896bc0a39c677fe49b1ca00e50dc90e55f

Authored by Carlos Rebelato
0 parents
Exists in master

fist commit

FAQTag.sopm 0 → 100755
  1 +++ a/FAQTag.sopm
... ... @@ -0,0 +1,39 @@
  1 +<?xml version="1.0" encoding="utf-8" ?>
  2 +<otrs_package version="1.0">
  3 + <Name>FAQTag</Name>
  4 + <Version>1.0</Version>
  5 + <Vendor>SeTIC</Vendor>
  6 + <URL>http://setic.ufsc.br</URL>
  7 + <License>GNU GENERAL PUBLIC LICENSE Version 2, June 1991</License>
  8 + <ChangeLog Date="2013-03-19 9:17:53" Version="1.0">Módulo criado.</ChangeLog>
  9 + <Description Lang="pt_BR">Cadastro de tags para gerar links dinâmicos e reduzidos para as categorias da FAQ.</Description>
  10 + <Framework>3.3.x</Framework>
  11 + <IntroInstall Lang="pt_BR" Title="Instalado!" Type="post">Módulo de tags instalado.</IntroInstall>
  12 + <BuildDate>?</BuildDate>
  13 + <BuildHost>?</BuildHost>
  14 + <Filelist>
  15 + <File Location="Kernel/Modules/AgentFAQTagOverview.pm" Permission="644"/>
  16 + <File Location="Kernel/Modules/AgentFAQTagAdd.pm" Permission="644"/>
  17 + <File Location="Kernel/Modules/RedirectFAQ.pm" Permission="644"/>
  18 + <File Location="Kernel/Modules/PublicRedirectFAQ.pm" Permission="644"/>
  19 + <File Location="Kernel/Output/HTML/Standard/AgentFAQTagOverview.dtl" Permission="644"/>
  20 + <File Location="Kernel/Output/HTML/Standard/AgentFAQTagAdd.dtl" Permission="644"/>
  21 + <File Location="Kernel/Config/Files/FAQTag.xml" Permission="644"/>
  22 + </Filelist>
  23 + <DatabaseInstall>
  24 + <TableCreate Type="post" Name="faq_tag">
  25 + <Column AutoIncrement="true" Name="id" PrimaryKey="true" Required="true" Size="10" Type="INT"></Column>
  26 + <Column Name="category_id" Required="true" Size="10" Type="INT"></Column>
  27 + <Column Name="tag" Required="true" Size="20" Type="VARCHAR"></Column>
  28 + <Unique>
  29 + <UniqueColumn Name="category_id"></UniqueColumn>
  30 + </Unique>
  31 + <Unique>
  32 + <UniqueColumn Name="tag"></UniqueColumn>
  33 + </Unique>
  34 + <ForeignKey ForeignTable="faq_category">
  35 + <Reference Foreign="id" Local="category_id"/>
  36 + </ForeignKey>
  37 + </TableCreate>
  38 + </DatabaseInstall>
  39 +</otrs_package>
... ...
GeraOpm.sh 0 → 100755
  1 +++ a/GeraOpm.sh
... ... @@ -0,0 +1,4 @@
  1 +#!/bin/bash
  2 +LOCAL="$PWD"
  3 +cd /opt/otrs/bin
  4 +./otrs.PackageManager.pl -a build -p "$LOCAL"/FAQTag.sopm
0 5 \ No newline at end of file
... ...
Kernel/Config/Files/FAQTag.xml 0 → 100755
  1 +++ a/Kernel/Config/Files/FAQTag.xml
... ... @@ -0,0 +1,66 @@
  1 +<?xml version="1.0" encoding="iso-8859-1"?>
  2 +<otrs_config version="1.0" init="Application">
  3 + <ConfigItem Name="Frontend::Module###AgentFAQTagOverview" Required="0" Valid="1">
  4 + <Description Translatable="1">Frontend module registration for the agent interface.</Description>
  5 + <Group>FAQ</Group>
  6 + <SubGroup>Frontend::Agent::ModuleRegistration</SubGroup>
  7 + <Setting>
  8 + <FrontendModuleReg>
  9 + <Group>faq</Group>
  10 + <GroupRo>faq</GroupRo>
  11 + <Title>FAQTag Overview</Title>
  12 + <NavBarName>FAQ</NavBarName>
  13 + <NavBar>
  14 + <GroupRo>faq</GroupRo>
  15 + <Description Translatable="1">Cadastro de tags para categorias</Description>
  16 + <Name Translatable="1">Tag</Name>
  17 + <Link>Action=AgentFAQTagOverview</Link>
  18 + <Type></Type>
  19 + <Block></Block>
  20 + <NavBar>FAQ</NavBar>
  21 + <Prio>970</Prio>
  22 + </NavBar>
  23 + <Loader>
  24 + </Loader>
  25 + </FrontendModuleReg>
  26 + </Setting>
  27 + </ConfigItem>
  28 + <ConfigItem Name="Frontend::Module###AgentFAQTagAdd" Required="1" Valid="1">
  29 + <Description Translatable="1">Frontend module registration for the agent interface.</Description>
  30 + <Group>FAQ</Group>
  31 + <SubGroup>Frontend::Agent::ModuleRegistration</SubGroup>
  32 + <Setting>
  33 + <FrontendModuleReg>
  34 + <Title>FAQTag add</Title>
  35 + <Group>faq</Group>
  36 + <Description>Adicionar e atualizar tags</Description>
  37 + <NavBarName>FAQ</NavBarName>
  38 + </FrontendModuleReg>
  39 + </Setting>
  40 + </ConfigItem>
  41 + <ConfigItem Name="Frontend::Module###RedirectFAQ" Required="1" Valid="1">
  42 + <Description Translatable="1">Redirecionamento da p&#xe1;gina de categoria da FAQ.</Description>
  43 + <Group>FAQ</Group>
  44 + <SubGroup>Frontend::Agent::ModuleRegistration</SubGroup>
  45 + <Setting>
  46 + <FrontendModuleReg>
  47 + <Title>Redirecionar FAQ</Title>
  48 + <Group>faq</Group>
  49 + <Description>Redirecionamento da p&#xe1;gina de categoria da FAQ.</Description>
  50 + <NavBarName>FAQ</NavBarName>
  51 + </FrontendModuleReg>
  52 + </Setting>
  53 + </ConfigItem>
  54 + <ConfigItem Name="PublicFrontend::Module###PublicRedirectFAQ" Required="1" Valid="1">
  55 + <Description Translatable="1">Redirecionamento da p&#xe1;gina de categoria da FAQ.</Description>
  56 + <Group>FAQ</Group>
  57 + <SubGroup>Frontend::Public::ModuleRegistration</SubGroup>
  58 + <Setting>
  59 + <FrontendModuleReg>
  60 + <Title>Redirecionar FAQ</Title>
  61 + <Description>Redirecionamento da p&#xe1;gina de categoria da FAQ.</Description>
  62 + <NavBarName>FAQ</NavBarName>
  63 + </FrontendModuleReg>
  64 + </Setting>
  65 + </ConfigItem>
  66 +</otrs_config>
... ...
Kernel/Modules/AgentFAQTagAdd.pm 0 → 100755
  1 +++ a/Kernel/Modules/AgentFAQTagAdd.pm
... ... @@ -0,0 +1,110 @@
  1 +
  2 +
  3 +package Kernel::Modules::AgentFAQTagAdd;
  4 +
  5 +use strict;
  6 +use warnings;
  7 +
  8 +sub new {
  9 + my ( $Type, %Param ) = @_;
  10 +
  11 + # allocate new hash for object
  12 + my $Self = {%Param};
  13 + bless ($Self, $Type);
  14 +
  15 + # check needed objects
  16 + for (qw(ParamObject DBObject TicketObject LayoutObject LogObject QueueObject ConfigObject EncodeObject MainObject)) {
  17 + if ( !$Self->{$_} ) {
  18 + $Self->{LayoutObject}->FatalError( Message => "Got no $_!" );
  19 + }
  20 + }
  21 + return $Self;
  22 +}
  23 +
  24 +sub Run {
  25 + my ( $Self, %Param ) = @_;
  26 + my %Data = ();
  27 +
  28 + my $Tag_id = $Self->{ParamObject}->GetParam( Param => 'id' );
  29 + my $Category = $Self->{ParamObject}->GetParam( Param => 'category' );
  30 + my $Tag = $Self->{ParamObject}->GetParam( Param => 'tag' );
  31 + my $Existe_Tag = 0;
  32 +
  33 + if ($Self->{ParamObject}->GetParam( Param => 'Subaction' ) eq "update") {
  34 +
  35 + if ($Self->_ExisteTag(tag => $Tag)){
  36 + $Existe_Tag = 1;
  37 +
  38 + }else{
  39 + if($Self->_GetTag(id => $Tag_id) eq undef){
  40 + $Self->{DBObject}->Do(
  41 + SQL => "INSERT into faq_tag (category_id, tag) values ((select id from faq_category where name= ?), ?)",
  42 + Bind => [\$Category, \$Tag],
  43 + );
  44 + return $Self->{LayoutObject}->Redirect( OP => 'Action=AgentFAQTagOverview&added='.$Tag );
  45 +
  46 + }else{
  47 + $Self->{DBObject}->Do(
  48 + SQL => "update faq_tag set tag=? where id=?",
  49 + Bind => [\$Tag, \$Tag_id],
  50 + );
  51 + return $Self->{LayoutObject}->Redirect( OP => 'Action=AgentFAQTagOverview&edited='.$Tag );
  52 + }
  53 + }
  54 + }
  55 +
  56 + $Self->{LayoutObject}->Block(
  57 + Name=> 'info',
  58 + Data=> {id => $Tag_id,
  59 + category => $Category,
  60 + tag => $Tag,
  61 + }
  62 + );
  63 +
  64 + # build output
  65 + my $Output = $Self->{LayoutObject}->Header(Title => "Tag");
  66 +
  67 + if($Existe_Tag == 1){
  68 + $Output .= $Self->{LayoutObject}->Notify(Priority => 'Error', Info=> "A tag ".$Tag." j\x{e1} existe.");
  69 + }
  70 + $Output .= $Self->{LayoutObject}->NavigationBar();
  71 + $Output .= $Self->{LayoutObject}->Output(
  72 + Data => \%Data,
  73 + TemplateFile => 'AgentFAQTagAdd',
  74 + );
  75 + $Output .= $Self->{LayoutObject}->Footer();
  76 + return $Output;
  77 +}
  78 +
  79 +sub _GetTag {
  80 +
  81 + my ( $Self, %Param ) = @_;
  82 +
  83 +
  84 + $Self->{DBObject}->Prepare(
  85 + SQL => "select tag from faq_tag where id = $Param{id}",
  86 + );
  87 + my $TAG;
  88 + while (my @Row = $Self->{DBObject}->FetchrowArray()) {
  89 + $TAG = $Row[0];
  90 + }
  91 + return $TAG;
  92 +
  93 +}
  94 +
  95 +sub _ExisteTag {
  96 +
  97 + my ( $Self, %Param ) = @_;
  98 +
  99 +
  100 + $Self->{DBObject}->Prepare(
  101 + SQL => "select id from faq_tag where tag = '$Param{tag}'",
  102 + );
  103 + my $Id;
  104 + while (my @Row = $Self->{DBObject}->FetchrowArray()) {
  105 + $Id = $Row[0];
  106 + }
  107 + return $Id;
  108 +
  109 +}
  110 +1;
... ...
Kernel/Modules/AgentFAQTagOverview.pm 0 → 100755
  1 +++ a/Kernel/Modules/AgentFAQTagOverview.pm
... ... @@ -0,0 +1,69 @@
  1 +
  2 +package Kernel::Modules::AgentFAQTagOverview;
  3 +
  4 +use strict;
  5 +use warnings;
  6 +
  7 +sub new {
  8 + my ( $Type, %Param ) = @_;
  9 +
  10 + # allocate new hash for object
  11 + my $Self = {%Param};
  12 + bless ($Self, $Type);
  13 +
  14 + # check needed objects
  15 + for (qw(ParamObject DBObject TicketObject LayoutObject LogObject QueueObject ConfigObject EncodeObject MainObject)) {
  16 + if ( !$Self->{$_} ) {
  17 + $Self->{LayoutObject}->FatalError( Message => "Got no $_!" );
  18 + }
  19 + }
  20 +
  21 + return $Self;
  22 +}
  23 +
  24 +sub Run {
  25 + my ( $Self, %Param ) = @_;
  26 + my %Data = ();
  27 +
  28 + if ($Self->{ParamObject}->GetParam( Param => 'Subaction' ) eq "delete") {
  29 + my $Var1 = $Self->{ParamObject}->GetParam( Param => 'id' );
  30 + $Self->{DBObject}->Do(
  31 + SQL => "DELETE FROM faq_tag where id=?",
  32 + Bind => [ \$Var1 ],
  33 + );
  34 + }
  35 +
  36 +
  37 + $Self->{DBObject}->Prepare(
  38 + 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)",
  39 + );
  40 +
  41 + while (my @Row = $Self->{DBObject}->FetchrowArray()) {
  42 + $Self->{LayoutObject}->Block(
  43 + Name=> 'dadostabela',
  44 + Data=> {id=>$Row[0], tag=>$Row[1], category=>$Row[2]}
  45 + );
  46 + }
  47 +
  48 + # build output
  49 + my $Output = $Self->{LayoutObject}->Header(Title => "Tag");
  50 +
  51 + if ($Self->{ParamObject}->GetParam( Param => 'added' )) {
  52 + my $Added = $Self->{ParamObject}->GetParam( Param => 'added' );
  53 + $Output .= $Self->{LayoutObject}->Notify( Info => 'Tag '.$Added.' adicionada!' );
  54 + }
  55 + if ($Self->{ParamObject}->GetParam( Param => 'edited' )) {
  56 + my $Edited = $Self->{ParamObject}->GetParam( Param => 'edited' );
  57 + $Output .= $Self->{LayoutObject}->Notify( Info => 'Tag '.$Edited.' modificada!' );
  58 + }
  59 +
  60 + $Output .= $Self->{LayoutObject}->NavigationBar();
  61 + $Output .= $Self->{LayoutObject}->Output(
  62 + Data => \%Data,
  63 + TemplateFile => 'AgentFAQTagOverview',
  64 + );
  65 + $Output .= $Self->{LayoutObject}->Footer();
  66 + return $Output;
  67 +
  68 +}
  69 +1;
... ...
Kernel/Modules/PublicRedirectFAQ.pm 0 → 100755
  1 +++ a/Kernel/Modules/PublicRedirectFAQ.pm
... ... @@ -0,0 +1,55 @@
  1 +
  2 +package Kernel::Modules::PublicRedirectFAQ;
  3 +
  4 +use strict;
  5 +use warnings;
  6 +
  7 +sub new {
  8 + my ( $Type, %Param ) = @_;
  9 +
  10 + # allocate new hash for object
  11 + my $Self = {%Param};
  12 + bless ($Self, $Type);
  13 +
  14 + # check needed objects
  15 + for (qw(ParamObject DBObject LayoutObject LogObject ConfigObject EncodeObject MainObject)) {
  16 + if ( !$Self->{$_} ) {
  17 + $Self->{LayoutObject}->FatalError( Message => "Got no $_!" );
  18 + }
  19 + }
  20 + return $Self;
  21 +}
  22 +
  23 +sub Run {
  24 + my ( $Self, %Param ) = @_;
  25 + my %Data = ();
  26 +
  27 + my $Tag = $Self->{ParamObject}->GetParam( Param => 'id' );
  28 + if(!$Tag){
  29 + $Self->{LayoutObject}->FatalError( Message => "Especifique a tag" );
  30 + }
  31 +
  32 + my $Id = $Self->_GetCategoryID(tag => "$Tag");
  33 + if(!$Id){
  34 + $Self->{LayoutObject}->FatalError( Message => "A tag $Tag n\x{e3}o existe!" );
  35 + }
  36 +
  37 + return $Self->{LayoutObject}->Redirect( ExtURL => 'public.pl?Action=PublicFAQExplorer;CategoryID='.$Id, );
  38 +
  39 +}
  40 +
  41 +sub _GetCategoryID {
  42 +
  43 + my ( $Self, %Param ) = @_;
  44 +
  45 +
  46 + $Self->{DBObject}->Prepare(
  47 + SQL => "select category_id from faq_tag where tag = '$Param{tag}'",
  48 + );
  49 + my $ID;
  50 + while (my @Row = $Self->{DBObject}->FetchrowArray()) {
  51 + $ID = $Row[0];
  52 + }
  53 + return $ID;
  54 +}
  55 +1;
... ...
Kernel/Modules/RedirectFAQ.pm 0 → 100755
  1 +++ a/Kernel/Modules/RedirectFAQ.pm
... ... @@ -0,0 +1,56 @@
  1 +
  2 +package Kernel::Modules::RedirectFAQ;
  3 +
  4 +use strict;
  5 +use warnings;
  6 +
  7 +sub new {
  8 + my ( $Type, %Param ) = @_;
  9 +
  10 + # allocate new hash for object
  11 + my $Self = {%Param};
  12 + bless ($Self, $Type);
  13 +
  14 + # check needed objects
  15 + for (qw(ParamObject DBObject TicketObject LayoutObject LogObject QueueObject ConfigObject EncodeObject MainObject)) {
  16 + if ( !$Self->{$_} ) {
  17 + $Self->{LayoutObject}->FatalError( Message => "Got no $_!" );
  18 + }
  19 + }
  20 + return $Self;
  21 +}
  22 +
  23 +sub Run {
  24 + my ( $Self, %Param ) = @_;
  25 + my %Data = ();
  26 +
  27 + my $Tag = $Self->{ParamObject}->GetParam( Param => 'id' );
  28 + if(!$Tag){
  29 + $Self->{LayoutObject}->FatalError( Message => "Especifique a tag" );
  30 + }
  31 +
  32 + my $Id = $Self->_GetCategoryID(tag => "$Tag");
  33 + if(!$Id){
  34 + $Self->{LayoutObject}->FatalError( Message => "A tag $Tag n\x{e3}o existe!" );
  35 + }
  36 +
  37 + return $Self->{LayoutObject}->Redirect( OP => 'Action=AgentFAQExplorer;CategoryID='.$Id, );
  38 +
  39 +}
  40 +
  41 +sub _GetCategoryID {
  42 +
  43 + my ( $Self, %Param ) = @_;
  44 +
  45 +
  46 + $Self->{DBObject}->Prepare(
  47 + SQL => "select category_id from faq_tag where tag = '$Param{tag}'",
  48 + );
  49 + my $ID;
  50 + while (my @Row = $Self->{DBObject}->FetchrowArray()) {
  51 + $ID = $Row[0];
  52 + }
  53 + return $ID;
  54 +
  55 +}
  56 +1;
... ...
Kernel/Output/HTML/Standard/AgentFAQTagAdd.dtl 0 → 100755
  1 +++ a/Kernel/Output/HTML/Standard/AgentFAQTagAdd.dtl
... ... @@ -0,0 +1,74 @@
  1 +<style type="text/css">
  2 + fieldset {
  3 + background: none;
  4 + border: none;
  5 + }
  6 +</style>
  7 +
  8 +<script type="text/javascript" src="formatar_moeda.js"></script>
  9 +<div class="Content">
  10 +<!-- dtl:block:info -->
  11 + <form name="input" action="$Env{"CGIHandle"}" method="post" onSubmit="return valida_dados(this)">
  12 + <input type="hidden" name="Action" value="$Env{"Action"}" />
  13 + <input type="hidden" name="Subaction" value="update" />
  14 + <div class="MainBox ARIARoleMain LayoutFixedSidebar SidebarFirst">
  15 + <h1>$Text{"Gerenciamento de Materiais"}</h1>
  16 + <div class="SidebarColumn">
  17 + <div class="WidgetSimple">
  18 + <div class="Header">
  19 + <h2>$Text{"Actions"}</h2>
  20 + </div>
  21 + <div class="Content">
  22 + <ul class="ActionList">
  23 + <li>
  24 + <a href="$Env{"Baselink"}Action=AgentFAQTagOverview" class="CallForAction"><span>$Text{"Go to overview"}</span></a>
  25 + </li>
  26 + </ul>
  27 + </div>
  28 + </div>
  29 + </div>
  30 + <div class="ContentColumn">
  31 + <div class="WidgetSimple">
  32 + <div class="Header">
  33 +
  34 + <h2>Editar Tag: $QData{"category"}</h2>
  35 + </div>
  36 + <div class="Content SpacingBottom">
  37 + <fieldset class="TableLike">
  38 +<!-- start form -->
  39 + <label class="Mandatory" for="tag" ><span class="Marker">*</span> Tag:</label>
  40 + <div class="Field">
  41 + <input type="hidden" id="category" name="category" value="$QData{"category"}">
  42 + <input type="hidden" id="id" name="id" value="$QData{"id"}">
  43 + <input type="text" id="tag" name="tag" class="W50pc Validate_Required " length="15" value="$QData{"tag"}">
  44 + </div>
  45 + <div class="Clear"></div>
  46 + <div class="Field SpacingTop">
  47 + <button class="Primary" type="submit" id="cadastrar" value="Cadastrar">$Text{"Submit"}</button>
  48 + $Text{"or"}
  49 + <a href="/otrs/index.pl?Action=AgentFAQTagOverview">Cancelar</a>
  50 + </div>
  51 + <div class="Clear"></div>
  52 +<!-- dtl:block:info -->
  53 + </fieldset>
  54 + </div>
  55 + </div>
  56 + </div>
  57 + </div>
  58 +<!-- end form -->
  59 + </form>
  60 +</div>
  61 +
  62 +<script language="javascript">
  63 +// Torna os campos obrigatórios
  64 +function valida_dados (nomeform) {
  65 + if (nomeform.tag.value=="") {
  66 + alert ("Por favor digite o nome para a tag.");
  67 + return false;
  68 + } else {
  69 + return true;
  70 + }
  71 +}
  72 +
  73 +</script>
  74 +
... ...
Kernel/Output/HTML/Standard/AgentFAQTagOverview.dtl 0 → 100755
  1 +++ a/Kernel/Output/HTML/Standard/AgentFAQTagOverview.dtl
... ... @@ -0,0 +1,56 @@
  1 +
  2 +<div class="MainBox ARIARoleMain LayoutFixedSidebar SidebarFirst">
  3 + <h1>$Text{"Gerenciamento de Tags"}</h1>
  4 + <div class="SidebarColumn">
  5 + <div class="WidgetSimple">
  6 + <div class="Header">
  7 + <h2>$Text{"Hint"}</h2>
  8 + </div>
  9 + <div class="Content">
  10 + <p class="FieldExplanation">Tabela de todas as categorias da FAQ com suas respectivas tags.</p>
  11 + <p class="FieldExplanation">Adicione uma tag para gerar um endere&ccedil;o mais simples a determinada categoria.</p>
  12 + </div>
  13 + </div>
  14 + </div>
  15 + <div class="ContentColumn">
  16 + <div class="WidgetSimple">
  17 + <div class="Header">
  18 + <h2>Lista</h2>
  19 + </div>
  20 + <div class="Content SpacingBottom">
  21 + <table class="DataTable SpacingTop">
  22 + <thead>
  23 + <tr>
  24 + <th>Categoria</th>
  25 + <th>Tag</th>
  26 + <th>Excluir</th>
  27 + </tr>
  28 + </thead>
  29 + <tbody>
  30 +<!-- dtl:block:dadostabela -->
  31 + <tr class="MasterAction" id="$QData{"id"}">
  32 + <td><a class="AsBlock" href="$Env{"Baselink"}Action=AgentFAQTagAdd&id=$QData{"id"}&category=$QData{"category"}&tag=$QData{"tag"}"</a>$QData{"category"}</td>
  33 + <td>$QData{"tag"}</td>
  34 + <td>
  35 + <option><center><a class="TrashCan" onClick="remover('$QData{"category"}', $QData{"id"}, '$QData{"tag"}')"></a></center></option>
  36 + </td>
  37 + </tr>
  38 +<!-- dtl:block:dadostabela -->
  39 + </tbody>
  40 + </table>
  41 + </div>
  42 + </div>
  43 + </div>
  44 +</div>
  45 +
  46 +<script type="text/javascript" charset="utf-8">//<![CDATA[
  47 +function remover(category, id, tag){
  48 + var confirma = confirm("Tem certeza de que deseja remover a tag "+ tag +" da categoria " + category +"?");
  49 + if(confirma ==true){
  50 + window.location.href="index.pl?Action=AgentFAQTagOverview&Subaction=delete&id="+id;
  51 + }else{
  52 + }
  53 +
  54 +}
  55 +
  56 +</script>
... ...
README 0 → 100755
  1 +++ a/README
... ...