summaryrefslogtreecommitdiff
path: root/includes/notary.inc.php
diff options
context:
space:
mode:
authorINOPIAE <inopiae@cacert.org>2012-12-13 07:31:10 +0100
committerINOPIAE <inopiae@cacert.org>2012-12-13 07:31:10 +0100
commit774b4d67682dd4793dad0b438791ca23f684c03c (patch)
tree6a32020007469e4c12941778f8ed20a5d1cb3c58 /includes/notary.inc.php
parent7baaa9a0ac611329539a43031ca3d0e81bba2b5f (diff)
downloadcacert-devel-774b4d67682dd4793dad0b438791ca23f684c03c.tar.gz
cacert-devel-774b4d67682dd4793dad0b438791ca23f684c03c.tar.xz
cacert-devel-774b4d67682dd4793dad0b438791ca23f684c03c.zip
bug 1121: introduced 4 new function into includes/notary.inc.php to process the cca recording, added the write_user_agreement to www/index.php and www/wot.php, added delete_user_agreement to the cron/removedead.php
Diffstat (limited to 'includes/notary.inc.php')
-rw-r--r--includes/notary.inc.php66
1 files changed, 66 insertions, 0 deletions
diff --git a/includes/notary.inc.php b/includes/notary.inc.php
index cc0e0eb..7d67abf 100644
--- a/includes/notary.inc.php
+++ b/includes/notary.inc.php
@@ -602,4 +602,70 @@
<p>[ <a href='javascript:history.go(-1)'><?=_("Go Back")?></a> ]</p>
<?
}
+
+ //functions to do with recording user agreements
+ function write_user_agreement($memid, $document, $method, $comment, $active=1, $secmemid=0){
+ // write a new record to the table user_agreement
+ $query="insert into user_agreements set memid=".$memid.", secmemid=".$secmemid.
+ ",document='".$document."',date=NOW(), active=".$active.",method='".$method."',`comment`='".$comment."'" ;
+ $res = mysql_query($query);
+ }
+
+ function get_user_agreement_status($memid, $type="CCA"){
+ //returns 0 - no user agreement, 1- at least one entry
+ $query="SELECT u.`document` FROM user_agreements u
+ WHERE u.`document` = '".$type."'' AND (u.`memid`=".$memid." or u.`secmemid`=".$memid.")" ;
+ $res = mysql_query($query);
+ if(mysql_num_rows($res) <=0){
+ return 0;
+ }else{
+ return 1;
+ }
+ }
+
+ function get_first_user_agreement($memid, $active=1, $type="CCA"){
+ //returns an array (`document`,`date`,`method`, `comment`,`active`)
+ $query="SELECT u.`document`, u.`date`, u.`method`, u.`comment`, u.`active` FROM user_agreements u
+ WHERE u.`document` = '".$type."'' AND (u.`memid`=".$memid." or u.`secmemid`=".$memid.")
+ AND u.`active`=".$active."
+ ORDER BY u.`date` Limit 1;" ;
+ $res = mysql_query($query);
+ if(mysql_num_rows($res) <=0){
+ $row = mysql_fetch_assoc($res);
+ $rec['document']= $row['document'];
+ $rec['date']= $row['date'];
+ $rec['method']= $row['method'];
+ $rec['comment']= $row['comment'];
+ $rec['active']= $row['active'];
+ }else{
+ $rec=array();
+ }
+ return $rec;
+ }
+
+ function get_last_user_agreement($memid){
+ //returns an array (`document`,`date`,`method`, `comment`,`active`)
+ $query="SELECT u.`document`, u.`date`, u.`method`, u.`comment`, u.`active` FROM user_agreements u
+ WHERE u.`document` = '".$type."'' AND (u.`memid`=".$memid." or u.`secmemid`=".$memid.")
+ ORDER BY u.`date` desc Limit 1;" ;
+ $res = mysql_query($query);
+ if(mysql_num_rows($res) <=0){
+ $row = mysql_fetch_assoc($res);
+ $rec['document']= $row['document'];
+ $rec['date']= $row['date'];
+ $rec['method']= $row['method'];
+ $rec['comment']= $row['comment'];
+ $rec['active']= $row['active'];
+ }else{
+ $rec=array();
+ }
+ return $rec;
+}
+
+ function delete_user_agreement($memid, $type="CCA"){
+ //deletes all entries to an user for the given type of user agreements
+ mysql_query("delete from `user_agreements` where `memid`='".$memid."'");
+ mysql_query("delete from `user_agreements` where `secmemid`='".$memid."'");
+ }
+
?>