### Performing Module Database and Code Installations (Shell)
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/developer/general_information/example_development_environment.rst
These commands demonstrate how to manually perform database and code installation tasks for a Znuny module using 'DatabaseInstall.pl' and 'CodeInstall.pl' from 'module-tools'. They are typically used for changes that require direct SQL or Perl code execution, often after a module's initial linking and configuration rebuild.
```Shell
shell> ~/src/module-tools/DatabaseInstall.pl -m FAQ.sopm -a install
shell> ~/src/module-tools/CodeInstall.pl -m FAQ.sopm -a install
```
--------------------------------
### Enabling MariaDB and HTTPD Services on Boot (RHEL)
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/installation/index.rst
This command configures the `mariadb` and `httpd` services to start automatically upon system boot on RHEL-based distributions. This ensures Znuny's database and web server components are always available after a system restart.
```Bash
systemctl enable mariadb httpd
```
--------------------------------
### Enabling MariaDB and Apache2 Services on Boot (Debian)
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/installation/index.rst
This command configures the `mariadb` and `apache2` services to start automatically upon system boot on Debian-based distributions. This ensures Znuny's database and web server components are always available after a system restart.
```Bash
systemctl enable mariadb apache2
```
--------------------------------
### Complete SOPM Package Specification Example (XML)
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/developer/extending/package-building.rst
This comprehensive XML snippet provides a full example of an SOPM package specification file. It includes metadata like name, version, vendor, license, and changelog, along with file lists, and database operations for installation and uninstallation, demonstrating the overall structure of a Znuny/OTRS package definition.
```xml
Calendar0.0.13.2.xOTRS AGhttps://otrs.com/GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007Added some feature.New package.A web calendar.Ein Web Kalender.Thank you for choosing the Calendar module.Vielen Dank fuer die Auswahl des Kalender Modules.??
```
--------------------------------
### Cloning Znuny Module Tools Repository (Shell)
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/developer/general_information/example_development_environment.rst
This command clones the 'module-tools' repository from GitHub. This repository contains a collection of useful utilities specifically designed to assist Znuny developers with various tasks, particularly for extension development and management.
```Shell
shell> git clone git@github.com:Znuny/module-tools.git
```
--------------------------------
### Enabling Znuny Cron Jobs
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/installation/index.rst
This snippet switches to the `znuny` user and then executes the `Cron.sh start` script. This action initializes and enables Znuny's scheduled tasks, which are essential for various background operations within the system.
```Bash
```
--------------------------------
### Perldoc SYNOPSIS Section Example (Perl)
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/developer/contributing/coding_standards/code-style-guide.rst
This snippet illustrates the optional `=head1 SYNOPSIS` section in Perldoc. It provides usage examples of commonly used functions within the module, demonstrating how to instantiate the module object and call its methods. This section helps users quickly understand how to interact with the module.
```Perl
=head1 SYNOPSIS
my $Object = $Kernel::OM->Get('Kernel::System::MyModule');
Read data
my $FileContent = $Object->Read(
File => '/tmp/testfile',
);
Write data
$Object->Write(
Content => 'my file content',
File => '/tmp/testfile',
);
```
--------------------------------
### Perl: Examples of Multi-line and Complex Conditions
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/developer/contributing/coding_standards/code-style-guide.rst
These examples illustrate various complex and multi-line conditions, demonstrating proper indentation and parenthesis placement for readability, including object method calls and chained logical operations.
```Perl
if (
$XMLHash[0]->{otrs_stats}[1]{StatType}[1]{Content}
&& $XMLHash[0]->{otrs_stats}[1]{StatType}[1]{Content} eq 'static'
)
{ ... }
```
```Perl
if ( $TemplateName eq 'AgentTicketCustomer' ) {
...
}
```
```Perl
if (
( $Param{Section} eq 'Xaxis' || $Param{Section} eq 'All' )
&& $StatData{StatType} eq 'dynamic'
)
{ ... }
```
```Perl
if (
$Self->{TimeObject}->TimeStamp2SystemTime( String => $Cell->{TimeStop} )
> $Self->{TimeObject}->TimeStamp2SystemTime(
String => $ValueSeries{$Row}{$TimeStop}
)
|| $Self->{TimeObject}->TimeStamp2SystemTime( String => $Cell->{TimeStart} )
< $Self->{TimeObject}->TimeStamp2SystemTime(
String => $ValueSeries{$Row}{$TimeStart}
)
)
{ ... }
```
--------------------------------
### Modeling a Building Access Process with Mermaid
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/admin/processmanagement/processexample/index.rst
This Mermaid diagram visually represents the workflow for the 'Building Access Request' process, illustrating the sequence of steps from 'Start' to 'End' including 'Register for visit', 'Check-in', and 'Check-out' activities. It provides a high-level overview of the process flow and its key stages.
```Mermaid
graph TD
style End stroke-width:6px, width: 10px
Start((Start))
A[Register for visit]
B[Check-in]
C[Check-out]
End((End))
Start --> A
A --> B
B --> C
C --> End
```
--------------------------------
### Conditional Database Installation (SOPM XML)
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/developer/extending/package-building.rst
This snippet illustrates the use of the IfPackage attribute within a tag. When present, the database installation operations defined within this section will only be executed if the specified package (AnyPackage in this example) is found in the local package repository.
```xml
...
```
--------------------------------
### Configuring Installation Introduction (XML)
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/developer/extending/package-building.rst
This XML snippet shows how to define an introduction message to be displayed during the package installation dialog. The 'IntroInstall' tag supports 'Type' (pre/post), 'Lang' (language), and 'Title' attributes, and can contain HTML-formatted content within a CDATA section.
```XML
```
--------------------------------
### Installing Znuny from Source Archive
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/installation/index.rst
This comprehensive script downloads, extracts, and sets up Znuny from its source archive. It includes steps for creating a symlink, adding a dedicated Znuny user for both RHEL and Debian systems, copying the default configuration, setting permissions, and initializing cron jobs.
```Bash
# Download Znuny
cd /opt
wget https://download.znuny.org/releases/znuny-latest-7.1.tar.gz
# Extract
tar xfz znuny-latest-7.1.tar.gz
# Create a symlink
ln -s /opt/znuny-7.1.7 /opt/znuny
# Add user for RHEL
useradd -d /opt/znuny -c 'Znuny user' -g apache -s /bin/bash -M -N znuny
# Add user for Debian/Ubuntu
useradd -d /opt/znuny -c 'Znuny user' -g www-data -s /bin/bash -M -N znuny
# Copy default Config.pm
cp /opt/znuny/Kernel/Config.pm.dist /opt/znuny/Kernel/Config.pm
# Set permissions
/opt/znuny/bin/znuny.SetPermissions.pl
# As Znuny user - create default cronjobs
su - znuny
cd var/cron
for foo in *.dist; do cp $foo `basename $foo .dist`; done
```
--------------------------------
### Perl: Multiple Condition Parentheses Spacing
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/developer/contributing/coding_standards/code-style-guide.rst
This example demonstrates the correct spacing for multiple conditions within parentheses, ensuring readability and adherence to the style guide.
```Perl
if ( $Condition && $ABC ) { ... }
```
--------------------------------
### Configuring Apache for Znuny Source Install on RHEL
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/installation/index.rst
This command creates a symbolic link to the Znuny Apache configuration file, integrating it into the Apache web server's configuration on RHEL-based systems when installing from source. This enables Apache to serve Znuny.
```Bash
ln -s /opt/znuny/scripts/apache2-httpd.include.conf /etc/httpd/conf.d/znuny.conf
```
--------------------------------
### Executing Perl Code on Install (XML/Perl)
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/developer/extending/package-building.rst
This XML tag encapsulates Perl code to be executed during package installation. The example demonstrates logging messages using 'Kernel::System::Log' and executing SQL commands via 'Kernel::System::DB'.
```XML
Get('Kernel::System::Log')->Log(
Priority => 'notice',
Message => "Some Message!",
);
# database example
$Kernel::OM->Get('Kernel::System::DB')->Do(SQL => "SOME SQL");
]]>
```
--------------------------------
### Cloning Znuny Framework Repository (Shell)
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/developer/general_information/example_development_environment.rst
This command clones the Znuny framework repository from GitHub. It demonstrates how to clone either the 'dev' branch for active development or a specific release branch like 'rel-3_3'. It is crucial to replace the provided repository URL with your own fork to enable pushing changes and creating pull requests.
```Shell
# for git dev
shell> git clone git@github.com:znuny/Znuny.git -b dev
# for a specific branch like Znuny 3.3
shell> git clone git@github.com:znuny/Znuny.git -b rel-3_3
```
--------------------------------
### Perl: Whitespace and Parentheses for Readability
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/developer/contributing/coding_standards/code-style-guide.rst
This example illustrates the preferred use of whitespace between keywords (like 'if' and 'for') and their opening parentheses to improve code readability.
```Perl
if ()...
```
```Perl
for ()...
```
--------------------------------
### Perl Configuration Object Retrieval (DRY Infraction Example)
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/developer/contributing/coding_standards/code-style-guide.rst
An example of a Perl code snippet that demonstrates a 'Don't Repeat Yourself' (DRY) infraction, showing how to retrieve a configuration object. The accompanying comment is considered redundant as the code is self-explanatory.
```Perl
# get config object
my $ConfigObject = $Kernel::OM->Get('Kernel::Config');
```
--------------------------------
### Installing Basic Packages on RHEL-based Systems
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/installation/index.rst
This snippet updates the system and installs essential packages for Znuny on RHEL-based distributions, including HTTPD, MariaDB, cpanminus, GCC, Make, and Perl core. It also enables the CodeReady Linux Builder (CRB) repository.
```Bash
dnf update -y
dnf install -y epel-release httpd mariadb mariadb-server cpanminus gcc make dnf-plugins-core tar bash-completion perl-core
crb enable
```
--------------------------------
### Installing Znuny via RPM on RHEL-based Systems
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/installation/index.rst
This command installs the Znuny package directly from the official RPM release URL. This method simplifies the installation process for RHEL-based distributions by handling dependencies automatically.
```Bash
dnf install -y https://download.znuny.org/releases/RPMS/rhel/7/znuny-7.1.7-01.noarch.rpm
```
--------------------------------
### Installing Basic Packages on Debian-based Systems
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/installation/index.rst
This snippet updates the system and installs fundamental packages for Znuny on Debian-based distributions, such as Apache2, MariaDB client and server, Tar, and Bash completion utilities.
```Bash
apt update -y
apt install -y apache2 mariadb-client mariadb-server tar bash-completion
```
--------------------------------
### Creating Base Directory for Znuny Add-on (Shell)
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/developer/contributing/how-to-extend-otrs.rst
This shell command sequence creates the base directory for a new Znuny add-on project, 'HelloWorld', and then navigates into it. This is the initial step for setting up the project structure.
```shell
mkdir -p ~/src/HelloWorld
cd ~/src/HelloWorld
```
--------------------------------
### Rebuilding Znuny Configuration Files (Shell)
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/developer/general_information/example_development_environment.rst
This command executes the 'Maint::Config::Rebuild' action via the 'znuny.Console.pl' script. It is an essential step after linking a new module or making other structural changes to ensure that the Znuny system properly integrates and recognizes the new components.
```Shell
shell> ~/src/znuny/bin/znuny.Console.pl Maint::Config::Rebuild
```
--------------------------------
### Creating MariaDB Configuration File on RHEL-based Systems
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/installation/index.rst
This command opens the `znuny_config.cnf` file in the `/etc/my.cnf.d/` directory for editing on RHEL-based systems. This file will contain specific MariaDB configuration settings optimized for Znuny.
```Bash
vi /etc/my.cnf.d/znuny_config.cnf
```
--------------------------------
### Configuring TicketZoom Widgets via SysConfig (XML)
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/developer/extending/package-porting.rst
This XML snippet provides an example of how to configure TicketZoom widgets using the system configuration. It defines two widgets: 'TicketInformation' and 'CustomerInformation', specifying their module, location (Sidebar), and whether content should be loaded asynchronously (`Async`).
```XML
AgentTicketZoom widget that displays ticket data in the side bar.Frontend::Agent::View::TicketZoomKernel::Output::HTML::TicketZoom::TicketInformationSidebarAgentTicketZoom widget that displays customer information for the ticket in the side bar.Frontend::Agent::View::TicketZoomKernel::Output::HTML::TicketZoom::CustomerInformationSidebar1
```
--------------------------------
### Listing Articles with ArticleList - Perl
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/developer/extending/package-porting.rst
This Perl example demonstrates the usage of the new `ArticleList()` method on the `Kernel::System::Ticket::Article` object. It allows filtering articles by `TicketID`, `CommunicationChannel`, `SenderType`, `IsVisibleForCustomer`, and retrieving only the first or last match.
```perl
my @Articles = $ArticleObject->ArticleList(
TicketID => 123,
CommunicationChannel => 'Email', # optional, to limit to a certain CommunicationChannel
SenderType => 'customer', # optional, to limit to a certain article SenderType
IsVisibleForCustomer => 1, # optional, to limit to a certain visibility
OnlyFirst => 1, # optional, only return first match, or
OnlyLast => 1, # optional, only return last match
);
```
--------------------------------
### HTML Class and ID Naming Convention
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/developer/contributing/coding_standards/code-style-guide.rst
Provides an example of the CamelCase naming convention for HTML class and ID attributes, ensuring consistency with other naming rules within the project.
```HTML
```
--------------------------------
### Linking a Znuny Module to the Framework (Shell)
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/developer/general_information/example_development_environment.rst
This command uses the 'link.pl' script from 'module-tools' to create a symbolic link between a module's source directory (e.g., '~/src/FAQ/') and the Znuny framework directory (e.g., '~/src/znuny/'). This process facilitates module development by allowing direct access to the framework without modifying core framework files. It must be executed each time new package files are added to the module.
```Shell
shell> ~/src/module-tools/link.pl ~/src/FAQ/ ~/src/znuny/
```
--------------------------------
### Installing Znuny Package - Shell
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/developer/extending/how-to-publish-extensions.rst
This command installs a Znuny package from a local .opm file or a remote URL. It requires the full path to the package file or its remote resource.
```Shell
shell> bin/znuny.Console.pl Admin::Package::Install /path/to/package.opm
```
--------------------------------
### Creating HTML Elements with jQuery (Legacy)
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/developer/extending/package-porting.rst
This JavaScript snippet illustrates a traditional jQuery approach to dynamically create and append an HTML div element to the document body. This method is presented as a legacy example to be ported to the new Core.Template API for HTML templating.
```JavaScript
var DivID = 'MyDiv',
DivText = 'Hello, world!';
$('').addClass('CSSClass')
.attr('id', DivID)
.text(DivText)
.appendTo('body');
```
--------------------------------
### Installing Required Perl Modules on Debian-based Systems
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/installation/index.rst
This command installs a comprehensive list of Perl modules required for Znuny on Debian-based systems using `apt`. These modules cover various functionalities, including database connectivity, XML processing, and cryptographic operations.
```Bash
apt -y install libapache2-mod-perl2 libdbd-mysql-perl libtimedate-perl libnet-dns-perl libnet-ldap-perl libio-socket-ssl-perl libpdf-api2-perl libsoap-lite-perl libtext-csv-xs-perl libjson-xs-perl libapache-dbi-perl libxml-libxml-perl libxml-libxslt-perl libyaml-perl libarchive-zip-perl libcrypt-eksblowfish-perl libencode-hanextra-perl libmail-imapclient-perl libtemplate-perl libdatetime-perl libmoo-perl bash-completion libyaml-libyaml-perl libjavascript-minifier-xs-perl libcss-minifier-xs-perl libauthen-sasl-perl libauthen-ntlm-perl libhash-merge-perl libical-parser-perl libspreadsheet-xlsx-perl libdata-uuid-perl
```
--------------------------------
### Creating MariaDB Configuration File on Debian-based Systems
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/installation/index.rst
This command opens the `50-znuny_config.cnf` file in the `/etc/mysql/mariadb.conf.d/` directory for editing on Debian-based systems. This file will contain specific MariaDB configuration settings optimized for Znuny.
```Bash
vi /etc/mysql/mariadb.conf.d/50-znuny_config.cnf
```
--------------------------------
### Documenting Subroutines with Perldoc (Perl)
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/developer/contributing/coding_standards/code-style-guide.rst
This snippet demonstrates the correct way to document a subroutine using Perldoc. It includes a `=head2` heading for the subroutine name, a general description of its purpose, a sample call with parameters, and an example of the expected return value. This comprehensive documentation precedes the subroutine definition, ensuring clarity and ease of understanding.
```Perl
=head2 LastTimeObjectChanged()
Calculates
```
--------------------------------
### PGP Key File Format Example
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/admin/security/index.rst
This snippet illustrates the acceptable file format for PGP public and private keys, showing the standard headers and footers that define the boundaries of the key data. It serves as a visual example for users preparing key files for upload.
```Text
# Valid Public Key Content
-----BEGIN PGP PUBLIC KEY BLOCK-----
lQWGBGLX69EBDADgLc4Po64Kx9D80VZnMOWsOR
.....
# Valid Private Key Content
-----END PGP PUBLIC KEY BLOCK-----
-----BEGIN PGP PRIVATE KEY BLOCK-----
lQWGBGLX69EBDADgLc4Po64Kx9D80VZnMOWsOR
.......
-----END PGP PRIVATE KEY BLOCK-----
```
--------------------------------
### Translating Strings with Variables in JavaScript
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/developer/extending/package-porting.rst
This JavaScript example shows how to translate strings that contain placeholders (%s) which are then replaced by additional variables passed as arguments to Core.Language.Translate(). This provides a flexible way to handle dynamic translations directly within JavaScript.
```JavaScript
Core.Language.Translate('The %s to %s', 'string', 'translate');
```
--------------------------------
### Example File Path for Page Navigation in Znuny Documentation
Source: https://github.com/znuny/manual/blob/znuny-7_1/README.md
This snippet provides an example of a file path structure within the Znuny documentation, specifically for `postmaster_mail_account.rst`. This path is used as a reference when constructing internal page navigation links.
```text
source\
admin\
email\
postmaster_mail_account.rst
```
--------------------------------
### Listing Installed Znuny Packages - Shell
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/developer/extending/how-to-publish-extensions.rst
This command lists all packages currently installed within the Znuny framework. It provides an overview of deployed extensions.
```Shell
shell> bin/znuny.Console.pl Admin::Package::List
```
--------------------------------
### Creating Database Tables on Install (XML)
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/developer/extending/package-building.rst
This XML snippet defines database table creation operations to be executed during package installation. It specifies table name, and for each column, its name, required status, primary key status, auto-increment, size, and type.
```XML
```
--------------------------------
### Perldoc DESCRIPTION Section Example (Perl)
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/developer/contributing/coding_standards/code-style-guide.rst
This snippet demonstrates the optional `=head1 DESCRIPTION` section in Perldoc. This section offers more in-depth information about the module, elaborating on its capabilities beyond the brief `NAME` section. It can list additional functionalities or provide context, helping to shorten the `NAME` section.
```Perl
=head1 DESCRIPTION
This module does not only handle files.
It is also able to:
* brew coffee
* turn lead into gold
* bring world peace
```
--------------------------------
### Checking User Permissions with Kernel::System::Group
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/developer/extending/package-porting.rst
This Perl example demonstrates the new, recommended way to check user permissions using the PermissionCheck() method of Kernel::System::Group (for agents) or Kernel::System::CustomerGroup (for customers). It requires UserID, GroupName, and Type parameters.
```Perl
my $HasPermission = $Kernel::OM->Get('Kernel::System::Group')->PermissionCheck(
UserID => $UserID,
GroupName => $GroupName,
Type => 'move_into',
);
```
--------------------------------
### Installing Required Perl Modules on RHEL-based Systems
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/installation/index.rst
This snippet installs additional Perl modules necessary for Znuny's functionality on RHEL-based systems. It uses `yum` for pre-packaged modules and `cpanm` for others not available via package manager, ensuring all dependencies are met.
```Bash
yum install -y "perl(Moo)" "perl(Text::CSV_XS)" "perl(YAML::XS)" "perl(ModPerl::Util)" "perl(Mail::IMAPClient)" "perl(JSON::XS)" "perl(Encode::HanExtra)" "perl(Crypt::Eksblowfish::Bcrypt)" "perl(Data::UUID)" "perl(Date::Format)" "perl(DateTime::TimeZone)" "perl(DateTime)" "perl(DBD::mysql)" "perl(DBI)" "perl(Hash::Merge)" "perl(Net::LDAP)" "perl(Net::DNS)" "perl(Template)" "perl(Template::Stash::XS)" "perl(XML::LibXML)" "perl(XML::LibXSLT)" "perl(XML::Parser)" "perl(Spreadsheet::XLSX)" "perl(Package::Stash)"
cpanm JavaScript::Minifier::XS CSS::Minifier::XS iCal::Parser
```
--------------------------------
### Retrieving Article Backend Object by Channel - Perl
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/developer/extending/package-porting.rst
This Perl example demonstrates how to obtain the correct article backend object for a given communication channel using the `BackendForChannel()` method. It takes `ChannelName` as a parameter, allowing access to channel-specific article data manipulation methods.
```perl
my $ArticleBackendObject = $ArticleObject->BackendForChannel( ChannelName => 'Email' );
```
--------------------------------
### Starting a Connection Communication Log in Perl
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/developer/general_information/how-it-works.rst
This Perl snippet demonstrates how to start a 'Connection' type object log within an existing communication log instance. It uses ObjectLogStart to initialize the log and then ObjectLog to record a debug message related to opening a connection, specifying Priority, Key, and Value.
```perl
$CommunicationLogObject->ObjectLogStart(
ObjectLogType => 'Connection',
);
$CommunicationLogObject->ObjectLog(
ObjectLogType => 'Connection',
Priority => 'Debug', # Trace, Debug, Info, Notice, Warning or Error
Key => 'Kernel::System::MailAccount::POP3',
Value => "Open connection to 'host.example.com' (user-1).",
);
```
--------------------------------
### Example JSON Request for Znuny Time Accounting Operation
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/admin/webservices/provider/index.rst
This JSON snippet demonstrates the required parameters for a request to the Znuny Time Accounting operation. It specifies the start and end dates/times for the accounting period, the login of the agent whose time is being queried (TimeAccountingUserLogin), and the credentials (UserLogin, Password) of the user making the request.
```JSON
{
"TimeAccountingStart": "2021-01-01 10:00:00",
"TimeAccountingEnd": "2022-01-01 10:00:00",
"TimeAccountingUserLogin": "root@localhost",
"UserLogin": "user",
"Password": "password"
}
```
--------------------------------
### Restarting MariaDB Service
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/installation/index.rst
This command restarts the MariaDB service to apply any changes made to its configuration files. It's essential to restart the database after modifying settings for them to take effect.
```Bash
systemctl restart mariadb
```
--------------------------------
### Removing Module Links from Znuny (Shell)
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/developer/general_information/example_development_environment.rst
This command utilizes the 'remove_links.pl' script from 'module-tools' to unlink modules from the Znuny framework. It effectively reverses the linking process, detaching the module's source code from the Znuny installation.
```Shell
shell> ~/src/module-tools/remove_links.pl ~/src/znuny/
```
--------------------------------
### Example Framework Translation File (Perl)
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/developer/general_information/how-it-works.rst
This Perl snippet provides an example of a default framework translation file (Kernel::Language::de.pm). It defines language-specific settings like character sets, date formats, and a hash of key-value pairs for string translations (e.g., 'Yes' to 'Ja', 'No' to 'Nein').
```perl
package Kernel::Language::de;
use strict;
use warnings;
use vars qw(@ISA $VERSION);
sub Data {
my $Self = shift;
# $$START$$
# possible charsets
$Self->{Charset} = ['iso-8859-1', 'iso-8859-15', ];
# date formats (%A=WeekDay;%B=LongMonth;%T=Time;%D=Day;%M=Month;%Y=Jear;)
$Self->{DateFormat} = '%D.%M.%Y %T';
$Self->{DateFormatLong} = '%A %D %B %T %Y';
$Self->{DateFormatShort} = '%D.%M.%Y';
$Self->{DateInputFormat} = '%D.%M.%Y';
$Self->{DateInputFormatLong} = '%D.%M.%Y - %T';
$Self->{Translation} = {
# Template: AAABase
##.......
'Yes' => 'Ja',
'No' => 'Nein',
'yes' => 'ja',
'no' => 'kein',
'Off' => 'Aus',
'off' => 'aus',
##......
};
# $$STOP$$
return 1;
}
1;
```
--------------------------------
### Example Output of Multiple Unit Test Runs (Shell)
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/developer/testing/unit-test.rst
This example illustrates the console output when multiple Znuny unit tests are run concurrently. It shows the progress and results for each specified test file, followed by an overall summary of all tests executed.
```shell
shell:/opt/znuny> bin/znuny.Console.pl Dev::UnitTest::Run --test Calendar --test Appointment
+-------------------------------------------------------------------+
/opt/znuny/scripts/test/Calendar.t:
+-------------------------------------------------------------------+
.................................................................................................
+-------------------------------------------------------------------+
/opt/znuny/scripts/test/Calendar/Appointment.t:
+-------------------------------------------------------------------+
..................................................................................................................
=====================================================================
yourhost ran tests in 5s
All 212 tests passed.
shell:/opt/znuny>
```
--------------------------------
### Starting Services on Debian-based Systems
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/updating/update-7.1.rst
This snippet outlines the commands to restart core Znuny services on Debian-based Linux distributions, such as the Apache web server, the local MTA (e.g., Postfix), and filling the crontab to start the Znuny daemon. It's important to ensure the frontend is working correctly before enabling mail and cron services.
```Shell
systemctl start apache2
# Start your local MTA, mostly Postfix, sometimes Exim or Sendmail
systemctl start postfix
# Fill the crontab and wait(!) at least 5 minutes that the Daemon is started via cron
su -c 'bin/Cron.sh start' - znuny
```
--------------------------------
### Installing jq and Jq Perl Module on Debian
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/admin/webservices/invoker/index.rst
This snippet provides commands to install the `jq` command-line JSON processor and the `Jq` Perl module on a Debian-based system. These are prerequisites for using complex event condition evaluation in Znuny.
```shell
sudo apt-get install jq
sudo cpan Jq
```
--------------------------------
### Starting Services on RHEL-based Systems
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/updating/update-7.1.rst
This snippet provides commands to restart essential Znuny services on RHEL-based Linux distributions, including the web server (httpd), Mail Transfer Agent (MTA) like Postfix, and filling the crontab to start the Znuny daemon. It's crucial to verify frontend functionality before starting mail services to prevent data loss.
```Shell
systemctl start httpd
# Start your local MTA, mostly Postfix, sometimes Exim or Sendmail
systemctl start postfix
# Fill the crontab and wait(!) at least 5 minutes that the Daemon is started via cron
su -c 'bin/Cron.sh start' - znuny
```
--------------------------------
### Perldoc NAME Section Example (Perl)
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/developer/contributing/coding_standards/code-style-guide.rst
This snippet provides an example of the `=head1 NAME` section in Perldoc. This mandatory section includes the module name, a separator (` - `), and a brief, concise description of the module's primary purpose. It serves as a quick reference for understanding the module's functionality.
```Perl
=head1 NAME
Kernel::System::MyModule - Functions to read from and write to files
```
--------------------------------
### Example Output of Single Unit Test Run (Shell)
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/developer/testing/unit-test.rst
This snippet provides an example of the console output when a single Znuny unit test is executed. It displays the path to the test file, a progress indicator, and a summary of the test results, including the number of tests passed and execution time.
```shell
shell:/opt/znuny> bin/znuny.Console.pl Dev::UnitTest::Run --test Calendar
+-------------------------------------------------------------------+
/opt/znuny/scripts/test/Calendar.t:
+-------------------------------------------------------------------+
.................................................................................................
=====================================================================
yourhost ran tests in 2s
All 97 tests passed.
shell:/opt/znuny>
```
--------------------------------
### HTML Template with Nunjucks Placeholders
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/developer/extending/package-porting.rst
This HTML template demonstrates the use of Nunjucks-like placeholders ({{ VarName }}) for dynamic content and the | Translate filter for string localization. This template is designed to be rendered by the Core.Template.Render method in JavaScript.
```HTML
{{ DivText | Translate }}
```
--------------------------------
### Example JSON Request for Znuny Article Creation/Update
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/admin/webservices/provider/index.rst
This JSON snippet provides an example request payload for creating or updating an article within Znuny. It includes parameters for email sending (ArticleSend, AppendSignatureToBody, To), the article's body, character set, communication channel, content type, customer visibility, MIME type, and subject.
```JSON
"Article": {
"ArticleSend": "1",
"AppendSignatureToBody": "0",
"To": "email@example.com",
"Body": "We welcome you to Znuny, our ticketing solution...",
"Charset": "utf-8",
"CommunicationChannelID": "1",
"ContentType": "text/plain; charset=utf-8",
"IsVisibleForCustomer": "1",
"MimeType": "text/plain",
"Subject": "Znuny says hi!"
}
```
--------------------------------
### Examples of jq Expressions for Ticket Data
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/admin/webservices/invoker/index.rst
These examples demonstrate how to construct `jq` expressions to access specific elements within the ticket event payload. The expressions start with `.` to represent the entire payload and drill down to desired values, such as article sender type, article subject, or owner's full name.
```jq
# Retrieve the SenderType of the first element of the Articles array
jq#.Articles[0].SenderType
jq#.Article.Subject
jq#.OwnerData.Fullname
```
--------------------------------
### Creating Znuny Frontend HTML Template (HTML)
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/developer/contributing/how-to-extend-otrs.rst
This HTML template file, `Kernel/Output/HTML/Templates/Standard/AgentHelloWorld.tt`, defines the user interface for the 'HelloWorld' module. It displays a translated 'Overview' title and the 'Hello World' text retrieved from the core module, rendered by the frontend module.
```html
# --
# Kernel/Output/HTML/Templates/Standard/AgentHelloWorld.tt - overview
# Copyright (C) (year) (name of author) (email of author)
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (GPL). If you
# did not receive this file, see https://www.gnu.org/licenses/gpl-3.0.txt.
# --
[% Translate("Overview") | html %]: [% Translate("HelloWorld") %]
[% Data.HelloWorldText | Translate() | html %]
```
--------------------------------
### Perl: Incorrect Postfix 'if' for Multi-line Statements
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/developer/contributing/coding_standards/code-style-guide.rst
This example illustrates the incorrect use of postfix 'if' for multi-line statements, especially when it involves a 'return' that is not directly ending a loop or iteration.
```Perl
return $Self->{LogObject}->Log(
Priority => 'error',
Message => 'ItemID needed!',
) if !$ItemId;
```
--------------------------------
### Defining Reinstall Introduction Text (XML)
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/developer/extending/package-building.rst
This XML tag specifies an introduction text to be displayed in the re-installation dialog. It supports 'Type' (e.g., "post"), 'Lang' (language), and 'Title' attributes, with content provided within a CDATA section.
```XML
```
--------------------------------
### Perl: String Boundary Matching with '\A' and '\z'
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/developer/contributing/coding_standards/code-style-guide.rst
This example illustrates the use of '\A' and '\z' to match the beginning and end of an entire string, respectively. These are generally preferred over '^' and '$' for string boundaries.
```Perl
$Text =~ m{
\A # beginning of the string
Content # some string
\z # end of the string
}xms;
```
--------------------------------
### Perl: Correct Postfix 'if' for Loop Control
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/developer/contributing/coding_standards/code-style-guide.rst
This example shows the correct application of postfix 'if' statements within loops for 'next' and 'last' operations, which are acceptable exceptions to the general rule.
```Perl
for my $Needed ( 1 .. 10 ) {
next if $Needed == 5;
last if $Needed == 9;
}
```
--------------------------------
### Perl: Corrected Multi-line Conditional Block
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/developer/contributing/coding_standards/code-style-guide.rst
This snippet provides the corrected code block for the previous incorrect postfix 'if' example, demonstrating the preferred block style for multi-line conditional logic.
```Perl
if( !$ItemId ) {
$Self->{LogObject}->Log( ... );
return;
}
```
--------------------------------
### Perl: Formatting Long Conditions (Correct)
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/developer/contributing/coding_standards/code-style-guide.rst
This example shows the correct way to format conditions that exceed 120 characters, by placing each part of the condition on a new line and the closing parenthesis on its own line.
```Perl
if (
$Condition1
&& $Condition2
)
{ ... }
```
--------------------------------
### Perl Full-Line Sentence-Style Comments
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/developer/contributing/coding_standards/code-style-guide.rst
Illustrates the use of full-line, sentence-style comments in Perl to document algorithm paragraphs. Comments should be complete sentences, starting with an uppercase letter and ending with a period, with subsequent lines indented.
```Perl
# Check if object name is provided.
if ( !$_[1] ) {
$_[0]->_DieWithError(
Error => "Error: Missing parameter (object name)",
);
}
# Record the object we are about to retrieve to potentially build better error messages.
# Needs to be a statement-modifying 'if', otherwise 'local' is local
# to the scope of the 'if'-block.
local $CurrentObject = $_[1] if !$CurrentObject;
```
--------------------------------
### Displaying Znuny Restore Script Help (Shell)
Source: https://github.com/znuny/manual/blob/znuny-7_1/source/annexes/backup/index.rst
This snippet demonstrates how to display the help message for the `restore.pl` script, which is used to restore a Znuny system from a backup. It specifies the required options for providing the backup files directory and the target Znuny home directory. The script should be executed by the application user (znuny) and requires prior preparation of the target system and restoration of underlying service settings.
```shell
[znuny@example ~]$ scripts/restore.pl -h
Restore a Znuny system from backup.
Usage:
restore.pl -b /data_backup/