get_linked_nodes moved to backend
authorniekt0 <niekt0@kyberia.cz>
Wed, 28 Sep 2011 22:09:36 +0000 (00:09 +0200)
committerniekt0 <niekt0@kyberia.cz>
Wed, 28 Sep 2011 22:09:36 +0000 (00:09 +0200)
wwwroot/backend/mysql/backend.inc
wwwroot/inc/smarty/node_methodz/function.get_linked_nodes.php

index f72a1025162d95aef1c54a3d78ad6a5c9c1fd812..0f66b8d55d6536372660be14ea59904788e63080 100644 (file)
@@ -574,5 +574,38 @@ public static function getNodesByType($vector,$user_id,$type,$orderby,$offset,$l
        return $result;
 }
 
+// getLinkedNodes
+
+// 
+// returns XXX
+
+function getLinkedNodes($node_id,$orderby,$offset,$listing_amount) {
+       global $db;
+
+       if ((!is_numeric($node_id))
+               or (!is_numeric($offset))
+               or (!is_numeric($listing_amount)))
+               { return -1; } // XXX check return value by caller?
+       $orderby=db_escape_string($orderby);
+
+       $q="select neurons.synapse_created,node_content,author.login,linker.login as linker,nodes.* from neurons 
+               left join nodes on neurons.src=nodes.node_id 
+               left join users as linker on neurons.synapse_creator=linker.user_id 
+               left join users as author on nodes.node_creator=author.user_id  
+               where dst='$node_id' and link in ('hard','bookmark') 
+               order by $orderby desc limit $offset , $listing_amount";
+
+       $result=$db->query($q);
+       while ($result->next()) {
+               $array=$result->getRecord();
+               transport_process_node($array); // XXX
+               $array['node_status']="linked";
+               $array['node_created']=$array['synapse_created'];
+               $get_linked_nodes[]=$array;
+       }
+       return $get_linked_nodes;
+}
+
+
 }
 ?>
index 37e003b7e892b4c3c095f5fa87cb6757ba17ca3c..ad44bacf7fd01d86378be157ee528f953f6dabcd 100644 (file)
@@ -1,48 +1,31 @@
 <?php
 //returns array of linked nodes, possible args listing_amount,offset,node_id,orderby=synapse
 
-       function smarty_function_get_linked_nodes($params,&$smarty) {
-               global $db, $error, $node;
-
-                if ($params['listing_amount']=='all') $listing_amount='23232323232323323';
-                elseif (is_numeric($params['listing_amount'])) $listing_amount=$params['listing_amount'];
-                else $listing_amount=DEFAULT_LISTING_AMOUNT;
-
-                if (is_numeric($params['offset'])) $offset=$params['offset'];
-               elseif (is_numeric($_POST['offset'])) $offset=$_POST['offset'];
-               else $offset=0;
-
-
-
-               if ($params['node_id']) {
-                       $node_id=$params['node_id'];
-               }
-
-               else {
-                       $node_id=$node['node_id'];
-               }
-
-               if ($params['orderby']='synapse') {
-                       $orderby='synapse_created';
-               }
-
-               else {
-                       $orderby='node_id';
-               }
-
-
-
-               $q="select neurons.synapse_created,node_content,author.login,linker.login as linker,nodes.* from neurons left join nodes on neurons.src=nodes.node_id left join users as linker on neurons.synapse_creator=linker.user_id left join users as author on nodes.node_creator=author.user_id  where dst='$node_id' and link in ('hard','bookmark') order by $orderby desc limit $offset , $listing_amount";
-               $result=$db->query($q);
-               while ($result->next()) {
-                       $array=$result->getRecord();
-                       transport_process_node($array);
-                       $array['node_status']="linked";
-                       $array['node_created']=$array['synapse_created'];
-                       $get_linked_nodes[]=$array;
-               }
-               $smarty->assign('get_linked_nodes',$get_linked_nodes);
-
+function smarty_function_get_linked_nodes($params,&$smarty) {
+       global $error, $node;
+
+        if ($params['listing_amount']=='all') $listing_amount=DEF_MAX_LISTING_AMMOUNT;
+        elseif (is_numeric($params['listing_amount'])) $listing_amount=$params['listing_amount'];
+        else $listing_amount=DEFAULT_LISTING_AMOUNT;
+
+        if (is_numeric($params['offset'])) $offset=$params['offset'];
+       elseif (is_numeric($_POST['offset'])) $offset=$_POST['offset'];
+       else $offset=0;
+
+       if (isset($params['node_id'])) {
+               $node_id=$params['node_id'];
+       } else {
+               $node_id=$node['node_id'];
+       }
+
+       if ($params['orderby']='synapse') {
+               $orderby='synapse_created';
+       } else {
+               $orderby='node_id';
+       }
+
+       $get_linked_nodes=nodes::getLinkedNodes($node_id,$orderby,$offset,$listing_amount);
+       $smarty->assign('get_linked_nodes',$get_linked_nodes);
 }
 
 ?>
This page took 0.17052 seconds and 4 git commands to generate.