Commit 0e2f5e22 authored by lfagundes's avatar lfagundes

[ADD] browse users with morcego

a replication of tiki-browse_freetags, extracting user relations from wiki page edition history
parent 3da18544
......@@ -4531,6 +4531,7 @@ tiki/templates/tiki-browse_categories.tpl -text
tiki/templates/tiki-browse_freetags.tpl -text
tiki/templates/tiki-browse_gallery.tpl -text
tiki/templates/tiki-browse_image.tpl -text
tiki/templates/tiki-browse_users.tpl -text
tiki/templates/tiki-calendar.tpl -text
tiki/templates/tiki-calendar_box.tpl -text
tiki/templates/tiki-calendar_import.tpl -text
......@@ -4873,6 +4874,7 @@ tiki/tiki-browse_categories.php -text
tiki/tiki-browse_freetags.php -text
tiki/tiki-browse_gallery.php -text
tiki/tiki-browse_image.php -text
tiki/tiki-browse_users.php -text
tiki/tiki-calendar.php -text
tiki/tiki-calendar_import.php -text
tiki/tiki-categpermissions.php -text
......@@ -5133,6 +5135,7 @@ tiki/tiki-user_tasks.php -text
tiki/tiki-user_watches.php -text
tiki/tiki-userfiles.php -text
tiki/tiki-usermenu.php -text
tiki/tiki-users3d_xmlrpc.php -text
tiki/tiki-userversions.php -text
tiki/tiki-view_articles.php -text
tiki/tiki-view_banner.php -text
......
......@@ -1981,6 +1981,41 @@ function get_included_groups($group) {
return $rv[$group];
}
function related_users($user, $max=10, $type='wiki') {
if(!isset($user) || empty($user)) {
return array();
}
// This query was written using a double join for PHP. If you're trying to eke
// additional performance and are running MySQL 4.X, you might want to try a
// subselect and compare perf numbers.
if ($type == 'wiki') {
$query = "SELECT u1.`login`, COUNT( p1.`pageName` ) AS quantity
FROM `tiki_history` p1
INNER JOIN `users_users` u1 ON ( u1.`login` = p1.`user` )
INNER JOIN `tiki_history` p2 ON ( p1.`pageName` = p2.`pageName` )
INNER JOIN `users_users` u2 ON ( u2.`login` = p2.`user` )
WHERE u2.`login` = ? AND u1.`login` <> ?
GROUP BY p1.`pageName`
ORDER BY quantity DESC
";
} else {
return array();
}
$bindvals = array($user, $user);
$result = $this->query($query, $bindvals, $max, 0);
$ret = array();
while ($row = $result->fetchRow()) {
$ret[] = $row;
}
return $ret;
}
// Friends methods
// TODO: if there's already a friendship request from friend to user, accept it
function request_friendship($user, $friend)
......
{* $Header: /cvsroot/tikiwiki/tiki/templates/tiki-browse_users.tpl,v 1.1 2005-12-14 17:40:34 lfagundes Exp $ *}
<script src="lib/cpaint/cpaint2.inc.compressed.js" type="text/javascript"></script>
<script src="lib/freetag/freetag_ajax.js" type="text/javascript"></script>
<div class="pageheading">
<h1>{tr}Browse related users{/tr}</h1>
</div>
<div class="morcego_embedded">
<h2>{tr}Network of Users related to{/tr}: <span id="currentTag1">{$tag}</span></h2>
<applet codebase="./lib/wiki3d" archive="morcego-0.4.0.jar" code="br.arca.morcego.Morcego" width="{$wiki_3d_width}" height="{$wiki_3d_height}">
<param name="serverUrl" value="{$base_url}/tiki-users3d_xmlrpc.php">
<param name="startNode" value="{$view_user}">
<param name="windowWidth" value="{$wiki_3d_width}">
<param name="windowHeight" value="{$wiki_3d_height}">
<param name="viewWidth" value="{$wiki_3d_width}">
<param name="viewHeight" value="{$wiki_3d_height}">
<param name="navigationDepth" value="{$wiki_3d_navigation_depth}">
<param name="feedAnimationInterval" value="{$wiki_3d_feed_animation_interval}">
<param name="controlWindowName" value="tiki">
<param name="showArcaLogo" value="false">
<param name="showMorcegoLogo" value="false">
<param name="loadPageOnCenter" value="{$wiki_3d_autoload|default:"true"}">
<param name="cameraDistance" value="{$wiki_3d_camera_distance|default:"200"}">
<param name="adjustCameraPosition" value="{$wiki_3d_adjust_camera|default:"true"}">
<param name="fieldOfView" value="{$wiki_3d_fov|default:"250"}">
<param name="nodeSize" value="{$wiki_3d_node_size|default:"30"}">
<param name="textSize" value="{$wiki_3d_text_size|default:"40"}">
<param name="frictionConstant" value="{$wiki_3d_friction_constant|default:"0.4f"}">
<param name="elasticConstant" value="{$wiki_3d_elastic_constant|default:"0.5f"}">
<param name="eletrostaticConstant" value="{$wiki_3d_eletrostatic_constant|default:"1000f"}">
<param name="springSize" value="{$wiki_3d_spring_size|default:"100"}">
<param name="nodeMass" value="{$wiki_3d_node_mass|default:"5"}">
<param name="nodeCharge" value="{$wiki_3d_node_charde|default:"1"}">
</applet>
</div>
<h2>Profile for <span id="currentTag2">{$view_user}</span></h2>
<?php
// $Header: /cvsroot/tikiwiki/tiki/tiki-browse_users.php,v 1.1 2005-12-14 17:40:31 lfagundes Exp $
// Copyright (c) 2002-2005, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
//
// $Header: /cvsroot/tikiwiki/tiki/tiki-browse_users.php,v 1.1 2005-12-14 17:40:31 lfagundes Exp $
//
// Initialization
require_once ('tiki-setup.php');
if (!isset($_REQUEST["type"])) {
$type = 'wiki';
} else {
$type = $_REQUEST["type"];
}
$smarty->assign('type', $type);
$smarty->assign('view_user', $_REQUEST['view_user']);
$base_url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$base_url = preg_replace('/\/tiki-browse_users.php.+$/','',$base_url);
$smarty->assign('base_url',$base_url);
$section = 'community';
include_once ('tiki-section_options.php');
ask_ticket('browse-users');
// Display the template
$smarty->assign('mid', 'tiki-browse_users.tpl');
$smarty->display("tiki.tpl");
?>
<?php
// $HEADER$
include_once("lib/init/initlib.php");
require_once('db/tiki-db.php');
require_once('lib/tikilib.php');
require_once('lib/userslib.php');
require_once("XML/Server.php");
$map = array ("getSubGraph" => array( "function" => "getSubGraph" ) );
$server = new XML_RPC_Server( $map );
function getSubGraph($params) {
global $dbTiki;
$userlib = new UsersLib($dbTiki);
$nodeName = $params->getParam(0); $nodeName = $nodeName->scalarVal();
$depth = $params->getParam(1); $depth = $depth->scalarVal();
$nodes = array();
$passed = array($nodeName => true);
$queue = array($nodeName);
$i = 0;
$neighbours = array();
while ($i <= $depth && sizeof($queue) > 0) {
$nextQueue = array();
foreach ($queue as $nodeName) {
$similar = $userlib->related_users($nodeName,5);
if (isset($neighbours[$nodeName])) {
$myNeighbours = $neighbours[$nodeName];
} else {
$myNeighbours = array();
}
foreach ($similar as $user) {
$myNeighbours[] = $user['login'];
$neighbours[$user['login']][] = $nodeName;
}
$temp_max = sizeof($myNeighbours);
for ($j = 0; $j < $temp_max; $j++) {
if (!isset($passed[$myNeighbours[$j]])) {
$nextQueue[] = $myNeighbours[$j];
$passed[$myNeighbours[$j]] = true;
}
$myNeighbours[$j] = new XML_RPC_Value($myNeighbours[$j]);
}
$node = array();
$base_url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$base_url = preg_replace('/\/tiki-users3d_xmlrpc.php.*$/','',$base_url);
$actionUrl = "javascript:listObjects('$nodeName');";
$color = '#0000FF';
$node['neighbours'] = new XML_RPC_Value($myNeighbours, "array");
if (!empty($color)) {
$node['color'] = new XML_RPC_Value($color, "string");
}
$node['actionUrl'] = new XML_RPC_Value($actionUrl, "string");
$nodes[$nodeName] = new XML_RPC_Value($node, "struct");
}
$i++;
$queue = $nextQueue;
}
$response = array("graph" => new XML_RPC_Value($nodes, "struct"));
return new XML_RPC_Response(new XML_RPC_Value($response, "struct"));
}
?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment