added get_synapse_weight function
authorniekt0 <niekt0@kyberia.cz>
Mon, 4 Apr 2011 10:17:54 +0000 (12:17 +0200)
committerniekt0 <niekt0@kyberia.cz>
Mon, 4 Apr 2011 10:17:54 +0000 (12:17 +0200)
wwwroot/backend/mysql/backend.inc
wwwroot/inc/smarty/node_methodz/function.get_k_neurons.php
wwwroot/inc/smarty/node_methodz/function.get_synapse_weight.php [new file with mode: 0644]

index 87e1d2d744bd09297fafed0b8050e5eb81d66d78..3c6da90495ac84ad5161203abd618af515b62319 100644 (file)
@@ -387,6 +387,31 @@ function setSynapse($params){
        return true;
 }
 
+// getSynapseWeight
 
+// If synapse does not exists, weight is 1
+// Secure.
+// Returns synapse weight (from user to node)
+
+function getSynapseWeight($user_id,$node_id){
+       global $db;
+
+       if (!is_numeric($user_id)) 
+               { return -1; }
+       if (!is_numeric($node_id)) 
+               { return -1; }
+
+       $set=$db->query("select synapse_weight from neurons where src =".
+               $user_id." and dst = ".$node_id." and link='synapse'");
+
+       $set->next();
+       $synapes_weight=$set->getString('synapse_weight');
+
+       if (! ($synapse_weight) ) { $synapse_weight = 1;}       
+
+       return $synapse_weight;
 
 }
+}
+
+?>
index 3711415b4eb348a5273d961fa43ed1571ec637cc..c188c6ea7f8d70fe81109d8ae670e8f8b9480452 100644 (file)
@@ -2,7 +2,7 @@
 
 function smarty_function_get_k_neurons($params,&$smarty) {
 
-       global $db,$node;
+       global $db;
        if (isset($params['offset']) && (is_numeric($params['offset']))) {
                $offset=$params['offset'];
        } else {$offset=20;} 
diff --git a/wwwroot/inc/smarty/node_methodz/function.get_synapse_weight.php b/wwwroot/inc/smarty/node_methodz/function.get_synapse_weight.php
new file mode 100644 (file)
index 0000000..1e31ef3
--- /dev/null
@@ -0,0 +1,18 @@
+<?php
+
+// Function for getting synapse weight from actual user to a node 
+// used for node setting
+
+function smarty_function_get_synapse_weight($params,&$smarty) {
+
+       global $db,$node;
+
+       $user_id=$_SESSION['user_id'];
+       $node_id=$params['node_id'];
+
+       $synapse_weight=nodes::getSynapseWeight($user_id,$node_id);
+
+       $smarty->assign('synapse_weight',$synapse_weight);
+
+}
+?>
This page took 0.213997 seconds and 4 git commands to generate.