示例#1
0
文件: logs.php 项目: mrzarkovic/logz
 public function show($id = 0)
 {
     $log = new Log();
     $log = $log->fetchById($id);
     $log_entries = new Log_entry();
     $log_entries->fetchAllByFieldValue("parent_id", $id);
     $this->to_tpl['log'] = $log;
     $this->to_tpl['log_entries'] = $log_entries->list;
     $this->template = "log";
     return;
 }
示例#2
0
 /**
  * Save the entry to a log
  * @param int $parent_id
  * @throws \Exception
  */
 public function add_entry($parent_id = 0)
 {
     $logText = $_POST['logText'];
     settype($logText, "string");
     $date = $_POST['date'];
     settype($date, "string");
     $log_entry = new Log_entry();
     $log_entry->text = $logText;
     $log_entry->parent_id = (int) $parent_id;
     $log_entry->date_added = new \DateTime($date);
     if ($id = $log_entry->saveToDb()) {
         $this->print_ajax($id);
     } else {
         $this->print_ajax("false");
     }
 }