I have a local copy of a custom app that deploys to the staging server through git. My php versions are matched up. My local machine is a mac and the staging is a linux with centos.
It's confusing because the issue seems to only be happening with one feature, any advice for debugging would be helpful since I have no errors displaying locally it doesn't make sense.
Locally it works perfectly, on the staging server it display the confirmation but it's returning false for all permissions: check_associate_perm() even though I can verify in the DB that they exist. Any attempt to add or remove permissions fails to write to the database.
my form:
<form method='post' action='account.php'>
<input type="hidden" name="uid" value="<?php echo $ass['uid']; ?>">
<input type="hidden" name="f_name" value="<?php echo $ass['first_name']; ?>">
<input type="hidden" name="l_name" value="<?php echo $ass['last_name']; ?>">
<p>Allow this <?php echo user::get_role_name($ass['rid']); ?> to:</p>
<label class="checkbox-inline"><input type="checkbox" id="inlineCheckbox21" name="incentives" <?php if(user::check_associate_perm($ass['uid'],1)){echo "checked";} ?>> Incentive Program <?php echo var_dump(user::check_associate_perm($ass['uid'],1)); ?> <i data-toggle="tooltip" data-placement="right" title="Sign up, choose item(s), see status." class="fa fa-info-circle"></i></label>
<label class="checkbox-inline"><input type="checkbox" id="inlineCheckbox21" name="history" <?php if(user::check_associate_perm($ass['uid'],2)){echo "checked";} ?>> View Orders History <i data-toggle="tooltip" data-placement="right" title="Including completed orders, returns and posted credits." class="fa fa-info-circle"></i></label>
<label class="checkbox-inline"><input type="checkbox" id="inlineCheckbox21" name="order" <?php if(user::check_associate_perm($ass['uid'],3)){echo "checked";} ?>> Place Orders <i data-toggle="tooltip" data-placement="right" title="See pending orders & order status." class="fa fa-info-circle"></i></label>
<input type='submit' class='btn btn-xs green' name='save_ass' value='Save'>
<input type='submit' class='btn btn-xs red' name='delete_ass' value='Delete'>
</form>
my form action:
<?php
if(isset($_POST['save_ass'])){
if(isset($_POST['incentives'])){user::add_associate_perm($_POST['uid'],1);} else{user::delete_associate_perm($_POST['uid'],1);}
if(isset($_POST['history'])){user::add_associate_perm($_POST['uid'],2);}else{user::delete_associate_perm($_POST['uid'],2);}
if(isset($_POST['order'])){user::add_associate_perm($_POST['uid'],3);} else{user::delete_associate_perm($_POST['uid'],3);}
if(isset($_POST['reports'])){user::add_associate_perm($_POST['uid'],4);}else{user::delete_associate_perm($_POST['uid'],4);}
if(isset($_POST['catalog'])){user::add_associate_perm($_POST['uid'],5);}else{user::delete_associate_perm($_POST['uid'],5);}
$error="Permissions Saved for ".$_POST['f_name']." ".$_POST['l_name'];
$color="green";
}
?>
my model methods:
public static function add_associate_perm($uid,$apid){
global $db;
if(!self::check_associate_perm($uid,$apid)){
$db->InsertRow("associates_user_permissions",array("uid"=>$uid,"apid"=>"'".$apid."'"));
}
}
public static function delete_associate_perm($uid,$apid){
global $db;
$db->DeleteRows("associates_user_permissions",array("uid"=>$uid,"apid"=>"'".$apid."'"));
}
public static function check_associate_perm($uid,$apid){
global $db;
if($db->HasRecords("SELECT * FROM associates_user_permissions WHERE uid=$uid AND apid=$apid")) {
return TRUE;
} else { return FALSE; }
}