warnings fix
[mirrors/Kyberia-bloodline.git] / wwwroot / backend / mysql / backend.inc
index 01717362fe91be455dbcc7fb1147b11d38cea2a9..bd765afeb26b58f1d8a4409df126c954d3c0b32b 100644 (file)
@@ -505,7 +505,108 @@ public static function getNodeUserlist($node_id) {
        return $userlist;
 }
 
+// getNodeCommanders
 
+// Get logins of all node commanders (used in configure)
+// Secure.
+// Returns list of (node_permission, login)
+
+public static function getNodeCommanders($node_id) {
+       global $db;
+
+       if (!is_numeric($node_id))
+                { return -1; }
+
+       $set=$db->query("select node_permission,users.login from node_access 
+                       left join users on node_access.user_id=users.user_id where 
+                       node_id='$node_id' and node_permission!='' order by node_permission");
+
+       while ($set->next()) {
+               $commanders[$set->getString('node_permission')].=$set->getString('login').";";
+       }
+
+       return $commanders;
 }
 
+// logout
+
+// Log out user.
+// Secure
+
+public static function logout() {
+        global $db;
+        $q="update users set user_action_id=null where user_id='".$_SESSION['user_id']."'";
+        $db->query($q);
+}
+
+// getNodesByType
+
+// XXX
+// Secure
+// returns xxx
+public static function getNodesByType($vector,$user_id,$type,$orderby,$offset,$listing_amount) {
+       global $db;
+
+       if ((!is_numeric($user_id))
+               or (!is_numeric($offset))
+               or (!is_numeric($listing_amount))
+               or ($vector && !is_numeric($vector))
+               or (!is_numeric($type)))
+               { return -1; }
+
+       $orderby=db_escape_string($orderby);
+
+
+       $q="select parent.node_name as parent_name,users.*,nodes.*,node_access.node_user_subchild_count from nodes 
+               left join nodes as parent on parent.node_id=nodes.node_parent 
+               left join node_access on node_access.node_id=nodes.node_id and node_access.user_id='$user_id'
+               left  join users on users.user_id=nodes.node_creator where ";
+       if ($vector) $q.="nodes.node_vector like '$vector%' and";
+       $q.=" nodes.template_id='$type' and nodes.node_system_access!='private'";
+       if ($orderby) $q.=" order by $orderby ";
+       else $q.=" order by nodes.node_id desc ";
+       $q.= " LIMIT $offset,$listing_amount ";
+       $set=$db->query($q);
+
+       while ($set->next()) $result[]=$set->getRecord();
+
+       return $result;
+}
+
+// getLinkedNodes
+
+// XXX
+// Secure
+// returns XXX
+
+public static 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;
+}
+
+
+}
 ?>
This page took 0.104226 seconds and 4 git commands to generate.