Merge branch 'bug-1177' into bug-1137
authorBenny Baumann <BenBE@geshi.org>
Sun, 21 Jul 2013 21:59:27 +0000 (23:59 +0200)
committerBenny Baumann <BenBE@geshi.org>
Sun, 21 Jul 2013 22:03:18 +0000 (00:03 +0200)
Conflicts:
includes/notary.inc.php
includes/wot.inc.php
www/wot.php

1  2 
includes/notary.inc.php
pages/wot/6.php
www/wot.php

  <?
        }
  
 - union
 - (SELECT u.`document`, u.`date`, u.`method`, u.`comment`, 0 as `active` FROM user_agreements u WHERE u.`document` = '".$type."' AND ( u.`secmemid`=".$memid.")) order by `date` desc limit 1" ;
+       //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`)
+               if($active==1){
+                       $filter="u.`memid`=".$memid;
+               }else{
+                       $filter="u.`secmemid`=".$memid;
+               }
+               $query="SELECT u.`document`, u.`date`, u.`method`, u.`comment`, u.`active` FROM `user_agreements` u
+                       WHERE u.`document` = '".$type."' AND ".$filter."
+                       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, $type="CCA"){
+       //returns an array (`document`,`date`,`method`, `comment`,`active`)
+               $query="(SELECT u.`document`, u.`date`, u.`method`, u.`comment`, 1 as `active` FROM user_agreements u WHERE u.`document` = '".$type."' AND (u.`memid`=".$memid." ) order by `date` desc limit 1)
 -              <td class="DataTD"><?=$field1?>:</td>
++                      union
++                      (SELECT u.`document`, u.`date`, u.`method`, u.`comment`, 0 as `active` FROM user_agreements u WHERE u.`document` = '".$type."' AND ( u.`secmemid`=".$memid.")) order by `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."'");
+       }
+       // functions for 6.php (assure somebody)
+       function AssureHead($confirmation,$checkname)
+       {
+ ?>
+ <form method="post" action="wot.php">
+ <table align="center" valign="middle" border="0" cellspacing="0" cellpadding="0" class="wrapper" width="600">
+       <tr>
+               <td colspan="2" class="title"><?=$confirmation?></td>
+       </tr>
+       <tr>
+               <td class="DataTD" colspan="2" align="left"><?=$checkname?></td>
+       </tr>
+ <?
+       }
+       function AssureTextLine($field1,$field2)
+       {
+ ?>
+       <tr>
 -              <td class="DataTD"><?=$text?></td>
++              <td class="DataTD"><?=$field1.(empty($field1)?'':':')?>:</td>
+               <td class="DataTD"><?=$field2?></td>
+       </tr>
+ <?
+       }
+       function AssureCCABoxLine($type,$text)
+       {
+               return;
+               AssureBoxLine($type,$text);
+       }
+       function AssureBoxLine($type,$text,$checked)
+       {
+ ?>
+       <tr>
+               <td class="DataTD"><input type="checkbox" name="<?=$type?>" value="1" <?=$checked?"checked":""?>></td>
+               <td class="DataTD"><?=$text?></td>
+       </tr>
+ <?
+       }
+       function AssureMethodLine($text,$methods,$remark)
+       {
+               if (count($methods) != 1) {
+ ?>
+       <tr>
 -              <td class="DataTD"><?=$field?>:</td>
++              <td class="DataTD"><?=$text.(empty($text)?'':':')?></td>
+               <td class="DataTD">
+                       <select name="method">
+ <?
+                       foreach($methods as $val) {
+ ?>
+                               <option value="<?=$val?>"><?=$val?></option>
+ <?
+                       }
+ ?>
+                       </select>
+                       <br />
+                       <?=$remark?>
+               </td>
+       </tr>
+ <?
+               } else {
+ ?>
+       <input type="hidden" name="<?=$val?>" value="<?=$methods[0]?>" />
+ <?
+               }
+       }
+       function AssureInboxLine($type,$field,$value,$description)
+       {
+ ?>
+       <tr>
++              <td class="DataTD"><?=$field.(empty($field)?'':':')?>:</td>
+               <td class="DataTD"><input type="text" name="<?=$type?>" value="<?=$value?>"><?=$description?></td>
+       </tr>
+ <?
+       }
+       function AssureFoot($oldid,$confirm)
+       {
+ ?>
+       <tr>
+               <td class="DataTD" colspan="2">
+                       <input type="submit" name="process" value="<?=$confirm?>" />
+                       <input type="submit" name="cancel" value="<?=_("Cancel")?>" />
+               </td>
+       </tr>
+ </table>
+ <input type="hidden" name="pagehash" value="<?=$_SESSION['_config']['wothash']?>" />
+ <input type="hidden" name="oldid" value="<?=$oldid?>" />
+ </form>
+ <?
+       }
++
 +      // double with notray.inc
 +      /**
 +       * write_user_agreement()
 +       * writes a new record to the table user_agreement
 +       *
 +       * @param mixed $memid
 +       * @param mixed $document
 +       * @param mixed $method
 +       * @param mixed $comment
 +       * @param integer $active
 +       * @param integer $secmemid
 +       * @return
 +       */
 +      function write_user_agreement($memid, $document, $method, $comment, $active=1, $secmemid=0){
 +              //
 +              $query="insert into `user_agreements` set `memid`=".intval($memid).", `secmemid`=".intval($secmemid).
 +                              ",`document`='".$document."',`date`=NOW(), `active`=".intval($active).",`method`='".$method."',`comment`='".$comment."'" ;
 +              $res = mysql_query($query);
 +      }
 +
 +      /**
 +       * check_date_format()
 +       * checks if the date is entered in the right date format YYYY-MM-DD and
 +       * if the date is after the 1st January of the given year
 +       *
 +       * @param mixed $date
 +       * @param integer $year
 +       * @return
 +       */
 +      function check_date_format($date, $year=2000){
 +              if (!strpos($date,'-')) {
 +                      return FALSE;
 +              }
 +              $arr=explode('-',$date);
 +
 +              if ((count($arr)!=3)) {
 +                      return FALSE;
 +              }
 +              if (intval($arr[0])<=$year) {
 +                      return FALSE;
 +              }
 +              if (intval($arr[1])>12 or intval($arr[1])<=0) {
 +                      return FALSE;
 +              }
 +              if (intval($arr[2])>31 or intval($arr[2])<=0) {
 +                      return FALSE;
 +              }
 +
 +              return checkdate( intval($arr[1]), intval($arr[2]), intval($arr[0]));
 +
 +      }
 +
 +      /**
 +       * check_date_differnce()
 +       * returns false if the date is larger then today + time diffrence
 +       *
 +       * @param mixed $date
 +       * @param integer $diff
 +       * @return
 +       */
 +      function check_date_differnce($date, $diff=1){
 +              return (strtotime($date)<=time()+$diff*86400);
 +      }
diff --cc pages/wot/6.php
Simple merge
diff --cc www/wot.php
@@@ -18,8 -18,6 +18,8 @@@
  <?
  require_once("../includes/loggedin.php");
  require_once("../includes/lib/l10n.php");
- require_once("../includes/wot.inc.php");
++require_once("../includes/notary.inc.php");
 +
  
  
  function show_page($target,$message,$error)
@@@ -115,7 -113,9 +115,6 @@@ function send_reminder(
        $_SESSION['_config']['error'] = _("A reminder notice has been sent.");
  }
  
 -
 -
--
        loadem("account");
        if(array_key_exists('date',$_POST) && $_POST['date'] != "")
                $_SESSION['_config']['date'] = $_POST['date'];