Prevent editing based upon a date except for certain groups

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
User avatar
shasta59
AppGini Super Hero
AppGini Super Hero
Posts: 231
Joined: 2013-01-08 19:40
Location: Calgary, Alberta, Canada

Prevent editing based upon a date except for certain groups

Post by shasta59 » 2013-01-31 02:23

Ok, a continuation of a series.

Look at my previous posts on this topic. This is just an addition. This addition lets you decide which groups will still be able to edit records. This is stage one of this hook. Next stage will show how to have it look up in a table to see which groups are approved to edit records etc. Then, how to do it based upon member name. The whole intent is to create a system where you do not need to admin it a lot or even at all by using tables to contain various features. A little more work up front but way way less down the road. The next one will show a few more tricks to make this more of a carefree system so it can be used year over year.

In this case I am just going to post the code. Should not need explanation but if you wish one just ask and I will flesh it out. (The new code is in red).

function clinic_reg_before_update(&$data, $memberInfo, &$args){

if($memberInfo['group']=='groupname' || $memberInfo['group']=='groupname'){
return TRUE;

}else{


// get the creation date of the record
$creationDate=sqlValue("select dateAdded from membership_userrecords
where tableName='yourtablename' and pkValue='{$data['selectedID']}'");
$lastchangedate=(strtotime("25 Feb 2013"));


// if the record is older than 180 days, deny changes
if($creationDate < strtotime('180 days ago')) return FALSE;
if(($lastchangedate - strtotime("now")) < 864000) return FALSE;

}
return TRUE;
}


Alan
Calgary, Alberta, Canada - Using Appgini 5.50 -

shkdxb
Veteran Member
Posts: 40
Joined: 2013-06-28 18:18

Re: Prevent editing based upon a date except for certain groups

Post by shkdxb » 2015-08-30 02:55

Hi Shasta
thanks for the code i am trying to use your code and found not working for me.
actually i am trying to prevent editing to records if value of the field "UpdateAllowed" is "No".

used following code:

Code: Select all

function TableName_before_update(&$data, $memberInfo, &$args){		
		$UpdateAllowed = $data['UpdateAllowed'];		
		if($UpdateAllowed== 'No'){return FALSE;
		echo "You cannot Update after Delivery!!";
		}
		else
		return TRUE;
	}
But this is not working for me when the value of the "UpdateAllowed" filed is "No". still the record is getting updated
can you help me?

shkdxb
Veteran Member
Posts: 40
Joined: 2013-06-28 18:18

Re: Prevent editing based upon a date except for certain groups

Post by shkdxb » 2015-09-02 03:43

I found the reason for this code not working.

when we make a field readonly or hidden in Detail view, the above code will not work. to make the code to work after updating the records, make this field as visible and not a readonly field.

still searching for answer for "echo "You cannot Update after Delivery!!";". no message appears except Appgini's standard error message.

Post Reply