Jump to content
Thomasha

*solved* Admin log, add pirep id in log

Recommended Posts

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 by Thomasha

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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 by web541

Share this post


Link to post
Share on other sites

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');
    }

 

Share this post


Link to post
Share on other sites

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');
}

 

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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);

 

  • Like 1

Share this post


Link to post
Share on other sites

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

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...