Try:
PHP Code:
$pm = new PrivateMessage();
$pm->setsender('SYSTEM'); // Or... whatever? You can change this.
$pm->setrecipient(htmlentities(addslashes(trim($recipient->username))));
$pm->setmessage("Donation For You!", "{$mysidia->user->username} has sent you {$amount} {$mysidia->settings->cost}!");
$pm->post();
You could probably also have the sender be the user?
PHP Code:
$pm->setsender($mysidia->user->username);
Here's the whole donate.php with the addition:
PHP Code:
<?php
use Resource\Native\Integer;
use Resource\Native\String;
class DonateController extends AppController{
public function __construct(){
parent::__construct("member");
}
public function index(){
$mysidia = Registry::get("mysidia");
if($mysidia->input->post("recipient") and $mysidia->input->post("amount")){
$recipient = preg_replace("/[^a-zA-Z0-9\\040]/", "", $mysidia->input->post("recipient"));
$amount = $mysidia->input->post("amount");
$recipient = new Member($recipient);
if($amount < 0) throw new DonationException("negative");
elseif($mysidia->user->money < $amount) throw new DonationException("funds");
elseif($recipient->username == $mysidia->user->username) throw new DonationException("user");
else{
$mysidia->user->donate($recipient, $amount);
$this->setField("recipient", new String($recipient->username));
$this->setField("amount", new Integer($amount));
$pm = new PrivateMessage();
$pm->setsender('SYSTEM'); // Or... whatever? You can change this.
$pm->setrecipient(htmlentities(addslashes(trim($recipient->username))));
$pm->setmessage("Donation Acquired", "{$mysidia->user->username} has sent you {$amount} {$mysidia->settings->cost}!");
$pm->post();
}
return;
}
}
}
?>
Untested, of course. Luckily it appears to be super simple to implement notifications via PM!