month = $_REQUEST['rec_month']; } else { $this->month = date('Y-m'); } $log = new helper_plugin_recommend_log($this->month); $this->entries = $log->getEntries(); $this->logs = $log->getLogs(); global $INPUT; global $ID; /** @var helper_plugin_recommend_assignment $assignmentsHelper */ $assignmentsHelper = plugin_load('helper', 'recommend_assignment'); if ($INPUT->str('action') && $INPUT->arr('assignment') && checkSecurityToken()) { $assignment = $INPUT->arr('assignment'); if ($INPUT->str('action') === 'delete') { $ok = $assignmentsHelper->removeAssignment($assignment); if (!$ok) { msg('failed to remove pattern', -1); } } elseif ($INPUT->str('action') === 'add') { if ($assignment['pattern'][0] == '/') { if (@preg_match($assignment['pattern'], null) === false) { msg('Invalid regular expression. Pattern not saved', -1); } else { $ok = $assignmentsHelper->addAssignment($assignment); if (!$ok) { msg('failed to add pattern', -1); } } } else { $ok = $assignmentsHelper->addAssignment($assignment); if (!$ok) { msg('failed to add pattern', -1); } } } send_redirect(wl($ID, array('do' => 'admin', 'page' => 'recommend'), true, '&')); } } public function getTOC() { return array_map([$this, 'recommendMakeTOC'], $this->logs); } public function html() { echo $this->locale_xhtml('intro'); if (!$this->logs) { echo 'No recommendations.'; } if (!$this->entries) { echo 'No recommendations were made in ' . $this->month . '.'; } echo '
In ' . $this->month . ', your users made the following ' . count($this->entries) . ' recommendations:
'; echo '