コード例 #1
0
 public function delete()
 {
     global $db, $history;
     /* The global constants can be overriden by passing appropriate params */
     //sure wish I could do this once in the constructor. sadly $this->params[] isn't set yet
     $require_login = empty($this->params['require_login']) ? SIMPLENOTE_REQUIRE_LOGIN : $this->params['require_login'];
     $require_approval = empty($this->params['require_approval']) ? SIMPLENOTE_REQUIRE_APPROVAL : $this->params['require_approval'];
     $require_notification = empty($this->params['require_notification']) ? SIMPLENOTE_REQUIRE_NOTIFICATION : $this->params['require_notification'];
     $notification_email = empty($this->params['notification_email']) ? SIMPLENOTE_NOTIFICATION_EMAIL : $this->params['notification_email'];
     if (empty($this->params['id'])) {
         flash('error', gt('Missing id for the comment you would like to delete'));
         $lastUrl = expHistory::getLast('editable');
     }
     // delete the note
     $simplenote = new expSimpleNote($this->params['id']);
     $rows = $simplenote->delete();
     // delete the assocication too
     $db->delete($simplenote->attachable_table, 'expsimplenote_id=' . $this->params['id']);
     // send the user back where they came from.
     $lastUrl = expHistory::getLast('editable');
     if (!empty($this->params['tab'])) {
         $lastUrl .= "#" . $this->params['tab'];
     }
     redirect_to($lastUrl);
 }