Skip to content
This repository
Browse code

fixes for #482, #487, #488, #489

Possible impact on #359, and goes some way towards #387

More robust XML information returned by processItems in response to AJAX calls: in particular, lastModified should now always be available and correct
  • Loading branch information...
commit 92dfc66e9a85a2613c0e68c6beb6fbbaa509de99 1 parent 9171c17
authored
2  addons/achievements/graph.php
@@ -43,7 +43,7 @@
43 43
 $graph->SetClipping(true);
44 44
 $graph->img->SetMargin(30,10,50,80);
45 45
 
46  
-$graph->xaxis->scale->SetDateFormat('Y-m-d');
  46
+$graph->xaxis->scale->SetDateFormat($_SESSION['config']['datemask']);
47 47
 $graph->xaxis->scale->ticks->Set(28*24*60*60,7*24*60*60);
48 48
 //$graph->xaxis->scale->SetDateAlign( MONTHADJ_1);
49 49
 $graph->xaxis->SetLabelAngle(90);
1  addons/ajax/gtdajax.js
@@ -1127,7 +1127,6 @@ function saveperspective(e) {
1127 1127
 function showcolumnselector(e) {
1128 1128
 /*
1129 1129
  * Event handler for when the user has activated the column selecter/orderer UI
1130  
- * TOFIX - dismissing it doesn't seem to be working
1131 1130
  * e: jQuery event
1132 1131
  */
1133 1132
     var coldiv,collist,
16  assignType.php
@@ -11,14 +11,12 @@
11 11
     unset($types['s']);
12 12
 ?><h2>Change the Type of <?php echo "$typename: '$title'"; ?></h2>
13 13
 <div class='submitbuttons'>
14  
-    <?php foreach ($types as $key=>$val) { ?>
15  
-        <a href='processItems.php?itemId=<?php
16  
-            echo $values['itemId'];
17  
-        ?>&amp;action=changeType&amp;type=<?php
18  
-            echo $key;
19  
-            if (!empty($_REQUEST['referrer']))
20  
-                echo "&amp;referrer=",$_REQUEST['referrer'];
21  
-        ?>'><?php echo $val; ?></a>
22  
-    <?php } ?>
  14
+    <?php foreach ($types as $key=>$val)
  15
+        echo "<a href='processItems.php?itemId=",$values['itemId']
  16
+            ,"&amp;action=changeType&amp;type=",$key
  17
+            ,"&amp;oldtype=",$type
  18
+            ,(empty($_REQUEST['referrer']))?'':"&amp;referrer={$_REQUEST['referrer']}"
  19
+            ,"'>$val</a>";
  20
+    ?>
23 21
 </div>
24 22
 <?php include 'footer.inc.php'; ?>
4  displayItems.inc.php
@@ -13,7 +13,7 @@
13 13
 $showclass=array();
14 14
 foreach ($dispArray as $key=>$val)
15 15
     $showclass[$key]=($show[$key])?'':' hidden';
16  
-foreach ($maintable as $row) if ($row) {
  16
+foreach ($maintable as $row) {
17 17
     echo '<tr'
18 18
         ,(!empty($row['row.class']))?" class='{$row['row.class']}' ":''
19 19
         ,">\n";
@@ -76,7 +76,7 @@
76 76
                         ,"</a>";
77 77
                 break;
78 78
             case 'lastModified':
79  
-                if ($row[$key]) echo date($_SESSION['config']['datemask'].' H:G:s',$row[$key]);
  79
+                if ($row[$key]) echo date($_SESSION['config']['datemask'].' H:i:s',$row[$key]);
80 80
                 break;                
81 81
             case 'NA':
82 82
                 if ($row[$key]!==null)
2  donate.php
@@ -6,7 +6,7 @@
2  gtd_constants.inc.php
... ...
@@ -1,5 +1,5 @@
1 1
 <?php
2  
-define('_GTD_REVISION',559);
  2
+define('_GTD_REVISION',560);
3 3
 define('_GTD_VERSION','0.8z.07'); // DATABASE version
4 4
 define('_GTDPHP_VERSION','0.9alpha');  // gtd-php version, as per the TRAC system
5 5
 
2  gtdfuncs.js
@@ -653,7 +653,7 @@ GTD.ParentSelector.prototype.gocreateparent=function(id,title,type,typename,rown
653 653
  */
654 654
     document.forms[0].afterCreate.value=
655 655
         document.forms[0].referrer.value=
656  
-        'item.php?nextId=0&amp;type='+type;
  656
+        'item.php?nextId='+document.forms[0].itemId.value+'&amp;type='+type;
657 657
     document.forms[0].submit();
658 658
     return false;
659 659
 };
2  install.php
@@ -558,7 +558,7 @@ function doInstall($installType,$fromPrefix) {
558 558
         /*
559 559
             Force the session to restart, to ensure that
560 560
             session variables will be initialised correctly,
561  
-            for the new installation. TOFIX needs testing
  561
+            for the new installation.
562 562
         */
563 563
         $_SESSION = array();
564 564
         session_destroy();
45  item.php
@@ -224,6 +224,7 @@
224 224
     log_value('Recurrence values going into form',$recur);
225 225
     // get the date of the next recurrence, after the current one has been completed, for the user's information
226 226
     $nextdate=getNextRecurrence($values);
  227
+    if ($nextdate) $nextdate=date($_SESSION['config']['datemask'],strtotime($nextdate));
227 228
 }
228 229
 /*
229 230
     ===========================================================================
@@ -267,11 +268,13 @@
267 268
 $sep='<p>';
268 269
 if ($show['changetypes']) foreach ($canchangetypesafely as $totype)
269 270
     if ($totype!==$values['type']) {
270  
-        echo "$sep <a href='processItems.php?action=changeType&amp;itemId="
271  
-            ,$values['itemId'],"&amp;safe=1&amp;type=$totype&amp;isSomeday="
272  
-            ,$values['isSomeday'];
273  
-        if (!empty($referrer)) echo "&amp;referrer=$referrer";
274  
-        echo "'>Convert to ",getTypes($totype),"</a>\n";
  271
+        echo "$sep <a href='processItems.php?action=changeType&amp;safe=1"
  272
+            ,"&amp;itemId=",$values['itemId']
  273
+            ,"&amp;type=$totype"
  274
+            ,"&amp;isSomeday=",$values['isSomeday']
  275
+            ,"&amp;oldtype=",$values['type']
  276
+            ,(empty($referrer))?'':"&amp;referrer=$referrer"
  277
+            ,"'>Convert to ",getTypes($totype),"</a>\n";
275 278
         $sep=' , ';
276 279
     }
277 280
 if ($show['type']) {
@@ -457,16 +460,8 @@
457 460
                     </span>
458 461
                 <?php } ?>
459 462
             </div>
460  
-        <?php } ?>
461  
-        
462  
-        <div class='hidden'>
463  
-    	   <input type='hidden' name='required' value='title:notnull:Title can not be blank.,tickledate:date:Suppress date must be a valid date.,deadline:date:Deadline must be a valid date.,dateCompleted:date:Completion date is not valid.' />
464  
-    	   <input type='hidden' name='dateformat' value='ccyy-mm-dd' />
465  
-            <?php
466  
-                if (!$values['itemId']) $hiddenvars['lastcreate']=$_SERVER['QUERY_STRING']; // TOFIX - why do this???
467  
-                foreach ($hiddenvars as $key=>$val) echo hidePostVar($key,$val);
468  
-            ?>
469  
-        </div><?php
  463
+        <?php
  464
+    }
470 465
 $key='afterCreate'.$values['type'];
471 466
 // always use config value when creating
472 467
 if (!empty($_SESSION['config']['afterCreate'][$values['type']]) && empty($_SESSION[$key]))
@@ -480,14 +475,10 @@
480 475
     <?php
481 476
     if (isset($_REQUEST['nextId'])) {
482 477
         // don't show any next item buttons: we are creating a parent item here
  478
+        $hiddenvars['referrer']='item.php?itemId='.$_REQUEST['nextId'];
  479
+        $hiddenvars['addAsParentTo']=$_REQUEST['nextId'];
483 480
         ?><div class='formbuttons'>
484 481
             <input type='submit' value='Create item and assign as parent' name='submit' />
485  
-            <input type='hidden' name='referrer' id='referrer' value='item.php?itemId=<?php
486  
-                echo $_REQUEST['nextId'];
487  
-            ?>' />
488  
-            <input type='hidden' name='addAsParentTo' value='<?php
489  
-                echo $_REQUEST['nextId'];
490  
-            ?>' />
491 482
         <?php
492 483
     } else if ($_SESSION['config']['radioButtonsForNextPage']) { ?>
493 484
         <div class='formrow'>
@@ -582,8 +573,16 @@
582 573
     }
583 574
 ?></div><?php
584 575
 } // end of if ($show['submitbuttons'])
585  
-
586  
-if ($show['recurdesc']) {
  576
+?>
  577
+<div class='hidden'>
  578
+   <input type='hidden' name='required' value='title:notnull:Title can not be blank.,tickledate:date:Suppress date must be a valid date.,deadline:date:Deadline must be a valid date.,dateCompleted:date:Completion date is not valid.' />
  579
+   <input type='hidden' name='dateformat' value='ccyy-mm-dd' />
  580
+    <?php
  581
+        if (!$values['itemId']) $hiddenvars['lastcreate']=$_SERVER['QUERY_STRING']; // TOFIX - why do this???
  582
+        foreach ($hiddenvars as $key=>$val) echo hidePostVar($key,$val);
  583
+    ?>
  584
+</div>
  585
+<?php if ($show['recurdesc']) {
587 586
 ?><div id='recur' <?php
588 587
     if ($_SESSION['useLiveEnhancements']) echo " class='togglehidden' ";
589 588
 ?>><a name='recurform' id='recurform'></a>
5  itemReport.php
@@ -125,8 +125,9 @@
125 125
     if ($comp==='n') {
126 126
         // inherit some defaults from parent:
127 127
         $createItemId="0&amp;parentId={$values['itemId']}&amp;type=$thistype";
128  
-        foreach (array('categoryId','contextId','deadline') as $field)
  128
+        foreach (array('categoryId','contextId') as $field)
129 129
             if ($item[$field]) $createItemId.="&amp;$field={$item[$field]}";
  130
+        if ($item['deadline']) $createItemId.="&amp;deadline=".date('Y-m-d',$item['deadline']);
130 131
     }
131 132
     $addnew="<a href='item.php?itemId$createItemId' class='creator'>Add new $thischildtype</a>";
132 133
     // prepare text to display for use if there are no children:
@@ -395,7 +396,7 @@
395 396
 
396 397
 if ($item['lastModified'])
397 398
     echo '<tr><th>Last modified:</th><td>'
398  
-        ,date($_SESSION['config']['datemask'].' H:G:s',$item['lastModified'])
  399
+        ,date($_SESSION['config']['datemask'].' H:i:s',$item['lastModified'])
399 400
         ,"</td></tr>\n";
400 401
 
401 402
 if ($item['dateCompleted']) {
9  mysql.inc.php
@@ -77,8 +77,8 @@ function rawQuery($query) {
77 77
   ===============================================================
78 78
 */
79 79
 function safeIntoDB($value,$key=NULL) {
80  
-	// don't clean arrays - clean individual strings/values. TOFIX: this looks very inefficient, and gets called A LOT
81 80
 	if (is_array($value)) {
  81
+        // don't clean arrays - clean individual strings/values by calling self recursively
82 82
 		foreach ($value as $key=>$string) $value[$key] = safeIntoDB($string,$key);
83 83
 		return $value;
84 84
 	} else {
@@ -688,6 +688,13 @@ function getsql($querylabel,$values,$sort) {
688 688
 				    WHERE i.`itemId` = '{$values['itemId']}'";
689 689
 			break;
690 690
 
  691
+        case 'selectlastmodified':
  692
+            $sql="SELECT UNIX_TIMESTAMP(`lastModified`) AS `lastModified`
  693
+                    ,`lastModified` AS `lmreal`
  694
+                    FROM `{$prefix}itemstatus`
  695
+                    WHERE `itemId` = '{$values['itemId']}'";
  696
+            break;
  697
+            
691 698
 		case "selectparents":
692 699
 			$sql="SELECT lu.`parentId`,i.`title` AS `ptitle`,its.`isSomeday`,its.`type` AS `ptype`
693 700
 				FROM `{$prefix}lookup` AS lu
28  processItems.php
@@ -101,10 +101,14 @@ function doAction($localAction) { // do the current action on the current item;
101 101
             break;
102 102
         //-----------------------------------------------------------------------------------
103 103
 		case 'changeType':
  104
+            $values['oldtype']=$_REQUEST['oldtype'];
104 105
 			changeType();
105 106
 			$newtype=getTypes($values['type']);
106 107
 			$msg="$newtype is now the type for item: '$title'";
107  
-			$updateGlobals['referrer']="item.php?itemId={$values['itemId']}&amp;referrer={$updateGlobals['referrer']}";
  108
+		    $updateGlobals['referrer']="item.php?itemId={$values['itemId']}&amp;referrer="
  109
+                .((empty($updateGlobals['referrer']))
  110
+                    ? "listItems.php?type={$values['oldtype']}"
  111
+                    : $updateGlobals['referrer']);
108 112
 			break;
109 113
         //-----------------------------------------------------------------------------------
110 114
         case 'checkcomplete':
@@ -470,7 +474,6 @@ function recurItem() {
470 474
         $_SESSION['message'][] = $msg;
471 475
     } else {
472 476
         $values['dateCreated']=date('Y-m-d');
473  
-        $values['lastModified']=date('Y-m-d H:G:s');
474 477
         // now need to set tickle date (either to NULL, or to date in quotes)
475 478
     	if (empty($values['deadline']) || $values['deadline']==='NULL') {
476 479
             $values['tickledate']="'$nextdue'";
@@ -615,6 +618,10 @@ function nextPage() { // set up the forwarding to the next page
615 618
     $nextURL=html_entity_decode($nextURL);
616 619
 	
617 620
 	if ($updateGlobals['captureOutput']) {
  621
+        if ($values['itemId']) {
  622
+            $result=query('selectlastmodified',$values);
  623
+            if ($result) $values['lastModified']=$result[0]['lastModified'];
  624
+        }
618 625
         $logtext=ob_get_contents();
619 626
         ob_end_clean();
620 627
         $outtext=$_SESSION['message'];
@@ -623,7 +630,6 @@ function nextPage() { // set up the forwarding to the next page
623 630
             $header="Content-Type: text/xml; charset=".$_SESSION['config']['charset'];
624 631
             header($header);
625 632
         }
626  
-        // TODO - would be nice to always return lastModified
627 633
         echo '<?xml version="1.0" ?',"><gtdphp>"; // encoding="{$_SESSION['config']['charset']}"
628 634
         echo "<values>";
629 635
         foreach ($values as $key=>$val) {
@@ -651,10 +657,15 @@ function nextPage() { // set up the forwarding to the next page
651 657
                 case 'dateCompleted':    // deliberately flows through
652 658
                 case 'dateCreated':      // deliberately flows through 
653 659
                 case 'deadline':         // deliberately flows through
654  
-                case 'lastModified':     // deliberately flows through
655 660
                 case 'oldDateCompleted': // deliberately flows through
656  
-                case 'tickledate':       // deliberately flows through
657  
-                    echo "<$key>",str_replace(array('NULL',"'"),'',$val),"</$key>";
  661
+                case 'tickledate':
  662
+                    echo "<$key>"
  663
+                        ,($val==='NULL' || empty($val)) ? '' :
  664
+                            ('<![CDATA['
  665
+                            .date($_SESSION['config']['datemask'],
  666
+                                strtotime(str_replace("'",'',$val)))
  667
+                            .']]>')
  668
+                        ,"</$key>";
658 669
                     break;
659 670
                 //-------------------------------------------------------
660 671
                 case 'description':      // deliberately flows through
@@ -663,6 +674,11 @@ function nextPage() { // set up the forwarding to the next page
663 674
                 default:
664 675
                     echo "<$key><![CDATA[$val]]></$key>";
665 676
                     break;
  677
+                case 'lastModified':
  678
+                    if ($val) echo "<$key><![CDATA["
  679
+                            ,date($_SESSION['config']['datemask'].' H:i:s',$val)
  680
+                            ,"]]></$key>";
  681
+                    break;
666 682
                 //-------------------------------------------------------
667 683
                 case 'tagname':
668 684
                 case 'alltags':
1  weekly.php
@@ -59,6 +59,7 @@
59 59
             <a href="item.php?type=w" title="Add waitingOn">things you are waiting for</a>,
60 60
             <a href="item.php?type=r" title="Add reference">references</a>,
61 61
             and <a href="item.php?type=p&amp;someday=true" title="Add Someday/Maybe">someday/maybes</a> that are not yet in the system.</td></tr>
  62
+    <?php // TOFIX - count how many inbox items there are, and amend the next message accordingly ?>
62 63
     <tr><td>Empty your <a href='listItems.php?type=i'>gtd-php inbox</a></td>
63 64
         <td>Use the 'Set Type' button to convert each one into a project, action, reference or waiting-on</td>
64 65
     </tr>

0 notes on commit 92dfc66

Please sign in to comment.
Something went wrong with that request. Please try again.