View Single Post
  #2  
Old 02-18-2016, 03:29 PM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 125,679
Kyttias is on a distinguished road
Default

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:
  Spoiler: donate.php 
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!
__________________
Please do not contact me directly outside of Mysidia.
I also cannot troubleshoot code more than two years old - I legit don't remember it.

Last edited by Kyttias; 02-18-2016 at 03:31 PM.
Reply With Quote