Jump to content

*solved* Admin log, add pirep id in log


Thomasha

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

 

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

 

Link to comment
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
Link to comment
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...