I am still learning PHP, and have been tasked with modifying a script. There is a function in the script that checks to see how many times a user has sent an email within a certain period of time. I need to add a little piece that allows one user (the admin) to send an unlimited amount of emails. I thought the best way to do this was to put in a piece that basically says: with this user, skip the email count. Below is the function:
Code: Select all
////////////////////////////////////////////////
public function checkUserEmailCount($uid){
$q = "SELECT DATE_FORMAT('last_email', '%Y %c') AS last_email, email_count FROM user WHERE id=".$this->quote_smart($uid);
$result = $this->query($q);
$row = mysql_fetch_assoc($result);
$today = (int) date('Ym');
$last_email = (int) $row['last_email'];
if ($last_email < $today){
$q = "UPDATE user SET email_count=0 where id=".$this->quote_smart($uid);
$result = $this->query($q);
return true;
} else if($row['email_count'] < MAX_FLYERS){
return true;
} else {
return false;
}
}
///////////////////////////////////////////////////
Code: Select all
If user ID = 285 then skip email count
} else if($last_email < $today){
$q = "UPDATE user SET email_count=0 where id=".$this->quote_smart($uid);
$result = $this->query($q);
return true;
} else if($row['email_count'] < MAX_FLYERS){
return true;
} else {
return false;
}
Thanks.