Lotekovo kondicionalni linkovani relaci
authorThomas Mudrunka <tomas@mudrunka.cz>
Fri, 24 Feb 2012 17:45:13 +0000 (18:45 +0100)
committerThomas Mudrunka <tomas@mudrunka.cz>
Fri, 24 Feb 2012 17:45:13 +0000 (18:45 +0100)
index.php

index 5446db14f9ee4310bfa56f8840351b74c8813de2..5a63954b7a12b319d0132d97c74dfab9c1c23b10 100755 (executable)
--- a/index.php
+++ b/index.php
@@ -333,7 +333,8 @@ EOF;
                                'model_name' => array(array('google','http://google.com/search?q=%v',true)) //TODO: add manufacturer to google query
                        ),
                        'item' => array(
-                               'item_serial' => array(array('dispose','assistant/%d?serial=%v'),array('sell','assistant/%d?serial=%v'))
+                               'item_serial' => array(array('dispose','assistant/%d?serial=%v','not_sold'),array('sell','assistant/%d?serial=%v','not_sold')),
+                               'item_id' => array(array('edit','item/%v/edit/'))
                        ),
                        'category' => array('category_id' => array(array('item',$where_url), array('model',$where_url))),
                        'producer' => array('producer_id' => array(array('item',$where_url), array('model',$where_url))),
@@ -341,6 +342,9 @@ EOF;
                        'room' => array('room_id' => array(array('item',$where_url))),
                        'status' => array('status_id' => array(array('item',$where_url)))
                );
+               $relations_conditions=array(
+                       'not_sold' => function(&$table,$id,$class=false,$column=false) { return(@$table[$id]['status_id'] != 3); }
+               );
                foreach($table as $id => $row) {
                        foreach($row as $column => $value) {
                                if(isset($relations[$class][$column])) {
@@ -350,6 +354,10 @@ EOF;
                                                        array(urlencode($destination[0]),urlencode($column),urlencode($value)),
                                                        $destination[1]
                                                );
+                                               if(isset($destination[2])) {
+                                                       $condition = $relations_conditions[$destination[2]]($table,$id);
+                                                       if(!$condition) continue;
+                                               }
                                                @$table[$id][$class.$suffix_relations] .= $this->link($destination[0], $destination_url, !isset($destination[2])).',';
                                        }
                                }
This page took 0.139888 seconds and 4 git commands to generate.