コード例 #1
0
 public function _done()
 {
     if (!isset($_GET['id']) || !ctype_digit((string) $_GET['id'])) {
         return;
     }
     $feedback_id = $_GET['id'];
     $feedback = new Feedback($feedback_id);
     $feedback->flipBoolValue('done');
     $feedback->save();
     back();
 }
コード例 #2
0
 public static function addNewFeedback(array $data, $need_to_save_in_db = true, $send_to_emails = [], $files = [])
 {
     $send_to_emails = (array) $send_to_emails;
     $cacher = Cacher::getInstance()->getDefaultCacher();
     $cache_key = 'module_feedback_add_new_feedback_last_send_ts' . VISITOR_HASH;
     // Check message is not sent too quick
     $last_sent_ts = $cacher->get($cache_key);
     if (NOW - $last_sent_ts < self::$sending_period_seconds) {
         return false;
     }
     // Autocreate db
     $feedbacks = new FeedbackRepository();
     $feedback = NULL;
     // Save to Db
     if ($need_to_save_in_db) {
         $feedback = new Feedback();
         $feedback->loadDataFromArray($data);
         $feedback->save();
     }
     // Send email to manager
     if ($send_to_emails) {
         $msg = '<table><tr><th>Field</th><th>Value</th></tr>';
         foreach ($data as $k => $v) {
             if ($v) {
                 $msg .= '<tr><td>' . $k . '</td><td>' . htmlspecialchars($v) . '</td></tr>';
             }
         }
         $msg .= '</table>';
         $mailer = Mailer::getInstance()->setSubject('New feedback from ' . CFG_DOMAIN)->setSender(Settings::getCommonEmail())->setMessage($msg);
         foreach ($send_to_emails as $email) {
             $mailer->setRecipient($email);
         }
         foreach ($files as $file) {
             $mailer->addAttachment($file);
         }
         $mailer->send();
     }
     // Save last send ts
     $cacher->set($cache_key, NOW);
     return $feedback;
 }