ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilForumLP.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
27 class ilForumLP extends ilObjectLP
28 {
29  public function appendModeConfiguration(int $mode): array
30  {
31  global $DIC;
32 
34  return [];
35  }
36 
37  $ui_factory = $DIC->ui()->factory();
38  $refinery = $DIC->refinery();
39  $lng = $DIC->language();
40 
41  $num_postings = $ui_factory->input()->field()->numeric(
42  $lng->txt('trac_frm_contribution_num_postings')
44  $refinery->in()->series([
45  $refinery->int()->isGreaterThanOrEqual(1),
46  $refinery->int()->isLessThanOrEqual(99999)
47  ])
48  )->withRequired(true);
49 
50  if (is_int(ilForumProperties::getInstance($this->obj_id)->getLpReqNumPostings())) {
51  $requiredNumberOfPostings = ilForumProperties::getInstance($this->obj_id)->getLpReqNumPostings();
52  $num_postings = $num_postings->withValue($requiredNumberOfPostings);
53  }
54 
55  return ['number_of_postings' => $num_postings];
56  }
57 
58  public function saveModeConfiguration(
59  string $selected_group,
60  array $group_data,
61  bool &$modeChanged
62  ): void {
63  $frm_properties = ilForumProperties::getInstance($this->obj_id);
64 
65  $current_value = $frm_properties->getLpReqNumPostings();
66 
67  if (is_numeric($group_data['number_of_postings'] ?? null)) {
68  $frm_properties->setLpReqNumPostings(
69  (int) $group_data['number_of_postings']
70  );
71  } else {
72  $frm_properties->setLpReqNumPostings(null);
73  }
74  $frm_properties->update();
75 
76  if ($current_value !== $frm_properties->getLpReqNumPostings()) {
77  $modeChanged = true;
78  }
79  }
80 
81  public static function getDefaultModes(bool $lp_active): array
82  {
83  if ($lp_active) {
84  return [
87  ];
88  }
89 
90  return [
92  ];
93  }
94 
95  public function getDefaultMode(): int
96  {
98  }
99 
100  public function getValidModes(): array
101  {
102  return [
105  ];
106  }
107 
108  public function getModeText(int $mode): string
109  {
110  global $DIC;
111 
112  $text = parent::getModeText($mode);
113 
115  $mode === $this->getCurrentMode() &&
116  is_int(($number_of_postings = ilForumProperties::getInstance($this->obj_id)->getLpReqNumPostings()))) {
117  try {
118  $text = sprintf(
119  match ($number_of_postings) {
120  1 => $DIC->language()->txt('trac_frm_contribution_num_postings_info_s'),
121  default => $DIC->language()->txt('trac_frm_contribution_num_postings_info_p')
122  },
123  $text,
124  $number_of_postings
125  );
126  } catch (Throwable) {
127  }
128  }
129 
130  return $text;
131  }
132 }
appendModeConfiguration(int $mode)
getModeText(int $mode)
saveModeConfiguration(string $selected_group, array $group_data, bool &$modeChanged)
static getInstance(int $a_obj_id=0)
const LP_MODE_CONTRIBUTION_TO_DISCUSSION
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
global $DIC
Definition: shib_login.php:22
static getDefaultModes(bool $lp_active)
global $lng
Definition: privfeed.php:31
Class ilForumLP.