Thomasha Posted March 25, 2020 Report Share Posted March 25, 2020 (edited) Hello Guys, when a comment is deleted from a pirep there is only "Deleted a comment" written in the Log. Is there a chance that (like when a pirep comment is added) there is also written the pirep number from which the comment was delete? I tried with "LogData::addLog(Auth::$userinfo->pilotid, 'Deleted a comment' . $pirepid);" but without success. Thanks in advance for your help. BRGDS Thomas Edited March 27, 2020 by Thomasha Quote Link to comment Share on other sites More sharing options...
Administrators ProAvia Posted March 25, 2020 Administrators Report Share Posted March 25, 2020 I assume you mean in the admin log..... You may want to find the Add Comment code and see how the pirepid is called there - and then adapt it to the delete comment code. Quote Link to comment Share on other sites More sharing options...
Thomasha Posted March 25, 2020 Author Report Share Posted March 25, 2020 Yes correct, I mean the admin log. Sorry for not being clear. Your proposal was also my first try but unfortunately I haven't been able to implement it. Quote Link to comment Share on other sites More sharing options...
web541 Posted March 25, 2020 Report Share Posted March 25, 2020 (edited) The comment id is posted but not the PIREPID so you would have to find it like this: $commentid = DB::escape($this->post->id); $pirep = "SELECT * FROM ".TABLE_PREFIX."pirepcomments WHERE `id` = '$commentid'"; LogData::addLog(Auth::$userinfo->pilotid, 'Deleted a comment to PIREP #: '.$pirep->pirepid); I would usually put the query into the PIREP Data class, but for this small example (since there's no method already available) it should be fine to leave it this way. Edited March 25, 2020 by web541 Quote Link to comment Share on other sites More sharing options...
Thomasha Posted March 26, 2020 Author Report Share Posted March 26, 2020 Thanks for your answer, I tried it but it don't worked: In the log there stands only: "Deleted a comment to PIREP #:" Here the inserted code: public function deletecomment() { if (!isset($this->post)) { return; } PIREPData::deleteComment($this->post->id); $commentid = DB::escape($this->post->id); $pirep = "SELECT * FROM ".TABLE_PREFIX."pirepcomments WHERE `id` = '$commentid'"; LogData::addLog(Auth::$userinfo->pilotid, 'Deleted a comment to PIREP #: '.$pirep->pirepid); $this->set('message', 'Comment deleted!'); $this->render('core_success.tpl'); } Quote Link to comment Share on other sites More sharing options...
web541 Posted March 26, 2020 Report Share Posted March 26, 2020 Oops I forgot a line before, try this: public function deletecomment() { if (!isset($this->post)) { return; } PIREPData::deleteComment($this->post->id); $commentid = DB::escape($this->post->id); $pirep = DB::get_row("SELECT * FROM ".TABLE_PREFIX."pirepcomments WHERE `id` = '$commentid'"); LogData::addLog(Auth::$userinfo->pilotid, 'Deleted a comment to PIREP #: '.$pirep->pirepid); $this->set('message', 'Comment deleted!'); $this->render('core_success.tpl'); } Quote Link to comment Share on other sites More sharing options...
Thomasha Posted March 26, 2020 Author Report Share Posted March 26, 2020 Thanks for your quick answer. Tested it but it don't works. 😞 Just for confirmation... with your code i only need to chage the PIREPAdmin.php file? Quote Link to comment Share on other sites More sharing options...
web541 Posted March 26, 2020 Report Share Posted March 26, 2020 Yes only the PIREPAdmin.php file, try this public function deletecomment() { if (!isset($this->post)) { return; } $commentid = DB::escape($this->post->id); $comment = DB::get_row("SELECT * FROM ".TABLE_PREFIX."pirepcomments WHERE `id` = '$commentid'"); LogData::addLog(Auth::$userinfo->pilotid, 'Deleted a comment to PIREP #: '.$comment->pirepid); PIREPData::deleteComment($this->post->id); $this->set('message', 'Comment deleted!'); $this->render('core_success.tpl'); } The query looks right, I think it might have been deleting the comment and then trying to find it which wouldn't work. You could also do it this way I would think (that way it will only log it if it has been deleted, but it should do it 99% of the time anyway) $commentid = DB::escape($this->post->id); $comment = DB::get_row("SELECT * FROM ".TABLE_PREFIX."pirepcomments WHERE `id` = '$commentid'"); PIREPData::deleteComment($this->post->id); LogData::addLog(Auth::$userinfo->pilotid, 'Deleted a comment to PIREP #: '.$comment->pirepid); 1 Quote Link to comment Share on other sites More sharing options...
Thomasha Posted March 27, 2020 Author Report Share Posted March 27, 2020 Yes it was the failure you described :-) Deleting and searching afterwards can't work. Changed the order and it works perfect. Thank you so much for your help. BRGDS Thomas Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.