19declare(strict_types=1);
 
   32    protected \ILIAS\Notes\Service 
$notes;
 
   39        $this->notes = 
$DIC->notes();
 
   44        return array(
"4.3.0", 
"5.0.0");
 
   47    protected function getXmlNamespace(
string $a_entity, 
string $a_schema_version): string
 
   49        return "http://www.ilias.de/xml/Modules/Poll/" . $a_entity;
 
   55    protected function getTypes(
string $a_entity, 
string $a_version): array
 
   57        if ($a_entity === 
"poll") {
 
   63                        "Description" => 
"text",
 
   66                        "ViewResults" => 
"integer",
 
   74                        "Description" => 
"text",
 
   77                        "ViewResults" => 
"integer",
 
   79                        "ShowResultsAs" => 
"integer",
 
   80                        "ShowComments" => 
"integer",
 
   81                        "MaxAnswers" => 
"integer",
 
   82                        "ResultSort" => 
"integer",
 
   83                        "NonAnon" => 
"integer",
 
   84                        "Period" => 
"integer",
 
   85                        "PeriodBegin" => 
"integer",
 
   86                        "PeriodEnd" => 
"integer" 
   93        if ($a_entity === 
"poll_answer") {
 
   99                        "PollId" => 
"integer",
 
  110    public function readData(
string $a_entity, 
string $a_version, array $a_ids): void
 
  114        if ($a_entity === 
"poll") {
 
  115            switch ($a_version) {
 
  118                        "pl.question,pl.image,pl.view_results" .
 
  120                        " JOIN object_data od ON (od.obj_id = pl.id)" .
 
  121                        " WHERE " . 
$ilDB->in(
"pl.id", $a_ids, 
false, 
"integer") .
 
  122                        " AND od.type = " . 
$ilDB->quote(
"poll", 
"text"));
 
  126                        ",pl.question,pl.image,pl.view_results,pl.show_results_as" .
 
  127                        ",pl.max_answers,pl.result_sort,pl.non_anon,pl.period,pl.period_begin,pl.period_end" .
 
  129                        " JOIN object_data od ON (od.obj_id = pl.id)" .
 
  130                        " WHERE " . 
$ilDB->in(
"pl.id", $a_ids, 
false, 
"integer") .
 
  131                        " AND od.type = " . 
$ilDB->quote(
"poll", 
"text"));
 
  137        if ($a_entity === 
"poll_answer") {
 
  138            switch ($a_version) {
 
  142                        " FROM il_poll_answer WHERE " .
 
  143                        $ilDB->in(
"poll_id", $a_ids, 
false, 
"integer"));
 
  152        ?array $a_rec = 
null,
 
  158                    "poll_answer" => array(
"ids" => $a_rec[
"Id"] ?? 
null)
 
  164    public function getXmlRecord(
string $a_entity, 
string $a_version, array $a_set): array
 
  166        if ($a_entity === 
"poll") {
 
  168            $a_set[
"Dir"] = $dir;
 
  170            $a_set[
"ShowComments"] = $this->notes->domain()->commentsActive((
int) $a_set[
"Id"]);
 
  176    public function importRecord(
 
  181        string $a_schema_version
 
  183        $a_rec = $this->stripTags(
 
  204                if ($new_id = $a_mapping->
getMapping(
"Services/Container", 
"objs", (
string) ($a_rec[
"Id"] ?? 
"0"))) {
 
  212                $newObj->setTitle((
string) ($a_rec[
"Title"] ?? 
''));
 
  213                $newObj->setDescription((
string) ($a_rec[
"Description"]));
 
  214                if ((
int) $a_rec[
"MaxAnswers"]) {
 
  215                    $newObj->setMaxNumberOfAnswers((
int) $a_rec[
"MaxAnswers"]);
 
  217                $newObj->setSortResultByVotes((
bool) ($a_rec[
"ResultSort"] ?? 
false));
 
  218                $newObj->setNonAnonymous((
bool) ($a_rec[
"NonAnon"] ?? 
false));
 
  219                if ((
int) $a_rec[
"ShowResultsAs"]) {
 
  220                    $newObj->setShowResultsAs((
int) $a_rec[
"ShowResultsAs"]);
 
  222                $newObj->setShowComments((
bool) ($a_rec[
"ShowComments"] ?? 
false));
 
  223                $newObj->setQuestion((
string) ($a_rec[
"Question"] ?? 
''));
 
  224                $newObj->setImage((
string) ($a_rec[
"Image"] ?? 
''));
 
  226                $newObj->setVotingPeriod((
bool) ($a_rec[
"Period"] ?? 0));
 
  227                $newObj->setVotingPeriodBegin((
int) ($a_rec[
"PeriodBegin"] ?? 0));
 
  228                $newObj->setVotingPeriodEnd((
int) ($a_rec[
"PeriodEnd"] ?? 0));
 
  232                if ($a_rec[
"Image"]) {
 
  233                    $dir = str_replace(
"..", 
"", (
string) ($a_rec[
"Dir"] ?? 
''));
 
  234                    if ($dir !== 
"" && $this->getImportDirectory() !== 
"") {
 
  235                        $source_dir = $this->getImportDirectory() . 
"/" . $dir;
 
  241                $a_mapping->
addMapping(
"Modules/Poll", 
"poll", (
string) ($a_rec[
"Id"] ?? 
"0"), (
string) $newObj->getId());
 
  245                $poll_id = (
int) $a_mapping->
getMapping(
"Modules/Poll", 
"poll", (
string) ($a_rec[
"PollId"] ?? 
"0"));
 
  248                    $poll->saveAnswer((
string) ($a_rec[
"Answer"] ?? 
''), (
int) ($a_rec[
"pos"] ?? 10));
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
getDirectDataFromQuery(string $a_query, bool $a_convert_to_leading_upper=true, bool $a_set=true)
Get data from query.This is a standard procedure, all db field names are directly mapped to abstract ...
 
static rCopy(string $a_sdir, string $a_tdir, bool $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
addMapping(string $a_comp, string $a_entity, string $a_old_id, string $a_new_id)
 
getMapping(string $a_comp, string $a_entity, string $a_old_id)
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
const VIEW_RESULTS_AFTER_VOTE
 
static initStorage(int $a_id, ?string $a_subdir=null)
 
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
 
getXmlNamespace(string $a_entity, string $a_schema_version)
 
getTypes(string $a_entity, string $a_version)
Get (abstract) types for (abstract) field names.Please note that the abstract fields/types only depen...
 
getXmlRecord(string $a_entity, string $a_version, array $a_set)
Get xml record for version.
 
readData(string $a_entity, string $a_version, array $a_ids)
Read data from DB.
 
getDependencies(string $a_entity, string $a_version, ?array $a_rec=null, ?array $a_ids=null)
 
ILIAS Notes Service $notes
 
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc