*  substitute goods or services; loss of use, data, or profits; or business    *
 *  interruption) however caused and on any theory of liability, whether in     *
 *  contract, strict liability, or tort (including negligence or otherwise)     *
 *  arising in any way out of the use of this software, even if advised of the  *
 *  possibility of such damage.                                                 *
 *                                                                              *
 ********************************************************************************/
/** Author: Michelle Bachler, KMi, The Open University **/
include_once $_SERVER['DOCUMENT_ROOT'] . '/config.php';
require_once $HUB_FLM->getCodeDirPath("core/io/catalyst/analyticservices.php");
$nodeid = required_param("nodeid", PARAM_ALPHANUMEXT);
$node = getNode($nodeid);
$nodes = array();
array_push($nodes, $node);
$checkNodes = array();
$conSet = getDebate($nodeid, 'long');
if (!$conSet instanceof Error) {
    $countj = count($conSet->connections);
    for ($j = 0; $j < $countj; $j++) {
        $con = $conSet->connections[$j];
        $from = $con->from;
        if (in_array($from->nodeid, $checkNodes) === FALSE) {
            $checkNodes[$from->nodeid] = $from->nodeid;
            array_push($nodes, $from);
        }
    }
}
$count = count($nodes);
$data = array();
$usersCheck = array();
$users = array();
 $k = 0;
 $countk = count($itemArray);
 for ($k = 0; $k < $countk; $k++) {
     $array = $itemArray[$k];
     $nodeid = $array['NodeID'];
     $nodename = $array['Name'];
     $nodetype = $array['NodeType'];
     $as = getNodeActivity($nodeid, $followlastrun, false);
     $activities = $as->activities;
     if (count($activities) > 0) {
         $nextMessage .= '<br /><br /><hr />' . $LNG->ADMIN_CRON_FOLLOW_ACTIVITY_FOR . ' ' . getNodeTypeText($nodetype, false) . ': <span style="font-weight:bold">' . $nodename . '</span> <a href="' . $CFG->homeAddress . 'ui/popups/activityviewer.php?nodeid=' . $nodeid . '&fromtime=' . $followlastrun . '">' . $LNG->ADMIN_CRON_FOLLOW_EXPLORE_LINK . '</a>';
         $nextMessage .= processActivityList($activities, $array, $user);
     }
     /** IF THE NODE IS AN DEBATE ISSUE GET THE ACTIVITY ALSO FOR ALL THE ITEMS BELOW IN THE TREE **/
     if ($nodetype == "Issue") {
         $conSet = getDebate($nodeid);
         $conns = $conSet->connections;
         $countl = count($conns);
         for ($l = 0; $l < $countl; $l++) {
             $con = $conns[$l];
             $from = $con->from;
             $to = $con->to;
             $node = array();
             $node['NodeID'] = $from->nodeid;
             $node['Name'] = $from->name;
             $node['NodeType'] = $from->role->name;
             $node['UserID'] = $from->users[0]->userid;
             $as = getNodeActivity($from->nodeid, $followlastrun, false);
             $activities = $as->activities;
             if (count($activities) > 0) {
                 $nextMessage .= '<br /><br /><br />' . $LNG->ADMIN_CRON_FOLLOW_ACTIVITY_FOR . ' ' . getNodeTypeText($node['NodeType'], false) . ': <span style="font-weight:bold">' . $from->name . '</span> <a href="' . $CFG->homeAddress . 'ui/popups/activityviewer.php?nodeid=' . $from->nodeid . '&fromtime=' . $followlastrun . '">' . $LNG->ADMIN_CRON_FOLLOW_EXPLORE_LINK . '</a>';
     $userid = required_param('userid', PARAM_ALPHANUMEXT);
     $response = approveGroupMemberJoin($groupid, $userid);
     break;
 case "mergeselectednodes":
     $groupid = required_param('groupid', PARAM_ALPHANUMEXT);
     $issuenodeid = required_param('issuenodeid', PARAM_ALPHANUMEXT);
     $ids = required_param('ids', PARAM_TEXT);
     $title = required_param('title', PARAM_TEXT);
     $desc = required_param('desc', PARAM_TEXT);
     $response = mergeSelectedNodes($issuenodeid, $groupid, $ids, $title, $desc);
     break;
     /** DEBATES **/
 /** DEBATES **/
 case "getdebate":
     $nodeid = required_param('nodeid', PARAM_ALPHANUMEXT);
     $response = getDebate($nodeid, $style);
     break;
 case "getdebateideaconnections":
     $issueid = required_param('issueid', PARAM_ALPHANUMEXT);
     $response = getDebateIdeaConnections($issueid, $o, $s, $status);
     break;
 case "getdebateideaconnectionswithlemoning":
     $issueid = required_param('issueid', PARAM_ALPHANUMEXT);
     $response = getDebateIdeaConnectionsWithLemoning($issueid, $o, $s);
     break;
 case "getdebateideaconnectionsremoved":
     $issueid = required_param('issueid', PARAM_ALPHANUMEXT);
     $response = getDebateIdeaConnectionsRemoved($issueid);
     break;
 case "getdebateministats":
     $nodeid = required_param('nodeid', PARAM_ALPHANUMEXT);
Exemple #4
0
/**
 * Return an object with the Debate contribution stats.
 *
 * @param nodeid the nodeid of the Issue node to get the contribution stats for.
 * @param style, the style of node to return - how much data it has (defaults to 'mini' can also be 'long' or 'short')
 * @return 	debatecontributionstats class containing properties:
 * 	positivevotes,negativevotes,totalvotes,ideacount,procount,concount.
 *  or an Error.
 */
function getDebateContributionStats($nodeid, $style = 'mini')
{
    //$node = getNode($nodeid, 'mini');
    $consSet = getDebate($nodeid, $style);
    $cons = $consSet->connections;
    $count = count($cons);
    $nodeCheck = array();
    $positivevotes = 0;
    $negativevotes = 0;
    $totalvotes = 0;
    $ideacount = 0;
    $procount = 0;
    $concount = 0;
    for ($i = 0; $i < $count; $i++) {
        $next = $cons[$i];
        $from = $next->from;
        $to = $next->to;
        $positivevotes = $positivevotes + $next->positivevotes;
        $negativevotes = $negativevotes + $next->negativevotes;
        $totalvotes = $totalvotes + $next->positivevotes;
        $totalvotes = $totalvotes + $next->negativevotes;
        if (!in_array($from->nodeid, $nodeCheck)) {
            array_push($nodeCheck, $from->nodeid);
            $positivevotes = $positivevotes + $from->positivevotes;
            $negativevotes = $negativevotes + $from->negativevotes;
            $totalvotes = $totalvotes + $from->positivevotes;
            $totalvotes = $totalvotes + $from->negativevotes;
            if ($from->role->name == "Solution") {
                $ideacount++;
            }
            if ($from->role->name == "Pro") {
                $procount++;
            }
            if ($from->role->name == "Con") {
                $concount++;
            }
        }
        if (!in_array($to->nodeid, $nodeCheck)) {
            array_push($nodeCheck, $to->nodeid);
            $positivevotes = $positivevotes + $to->positivevotes;
            $negativevotes = $negativevotes + $to->negativevotes;
            $totalvotes = $totalvotes + $to->positivevotes;
            $totalvotes = $totalvotes + $to->negativevotes;
            if ($to->role->name == "Solution") {
                $ideacount++;
            }
            if ($to->role->name == "Pro") {
                $procount++;
            }
            if ($to->role->name == "Con") {
                $concount++;
            }
        }
    }
    class debatecontributionstats
    {
        public $positivevotes = 0;
        public $negativevotes = 0;
        public $totalvotes = 0;
        public $ideacount = 0;
        public $procount = 0;
        public $concount = 0;
    }
    $stats = new debatecontributionstats();
    $stats->positivevotes = $positivevotes;
    $stats->negativevotes = $negativevotes;
    $stats->totalvotes = $totalvotes;
    $stats->ideacount = $ideacount;
    $stats->procount = $procount;
    $stats->concount = $concount;
    return $stats;
}
 if (!array_key_exists($node->nodeid, $nodeCheck)) {
     $nodeCheck[$node->nodeid] = $node;
 }
 if (!array_key_exists($node->users[0]->userid, $userHashtable)) {
     $globaluser = clone $node->users[0];
     $globaluser->procount = 0;
     $globaluser->concount = 0;
     $globaluser->ideacount = 0;
     $globaluser->debatecount = 1;
     $userHashtable[$node->users[0]->userid] = $globaluser;
 } else {
     $globaluser = $userHashtable[$node->users[0]->userid];
     $globaluser->debatecount = $globaluser->debatecount + 1;
     $userHashtable[$node->users[0]->userid] = $globaluser;
 }
 $debateConnections = getDebate($node->nodeid);
 $cons = $debateConnections->connections;
 $countcons = count($cons);
 $localusers = array();
 $debateowner = clone $node->users[0];
 $debateowner->procount = 0;
 $debateowner->concount = 0;
 $debateowner->ideacount = 0;
 $debateowner->debatecount = 1;
 $localusers[$node->users[0]->userid] = $debateowner;
 if (!array_key_exists($node->users[0]->userid, $userCheck)) {
     $userCheck[$node->users[0]->userid] = $node->users[0];
 }
 for ($j = 0; $j < $countcons; $j++) {
     $con = $cons[$j];
     $fromNode = $con->from;
function getConnectionsForDebate($nodeid)
{
    return getDebate($nodeid);
}
/**
 * Return a ViewSet for the given groupid;
 */
function getConversationData($groupid)
{
    $issueNodes = getNodesByGroup($groupid, 0, -1, 'date', 'DESC', '', 'Issue', 'cif');
    $checkNodes = array();
    $checkConns = array();
    $group = new Group($groupid);
    $view = new View($groupid);
    if (!$issueNodes instanceof Error) {
        $nodes = $issueNodes->nodes;
        $count = count($nodes);
        for ($i = 0; $i < $count; $i++) {
            $node = $nodes[$i];
            if (!$node instanceof Error) {
                if (array_key_exists($node->nodeid, $checkNodes) === FALSE) {
                    $checkNodes[$node->nodeid] = $node->nodeid;
                    $view->addNode($node);
                }
                $conSet = getDebate($node->nodeid, 'cif');
                if (!$conSet instanceof Error) {
                    $countj = count($conSet->connections);
                    for ($j = 0; $j < $countj; $j++) {
                        $con = $conSet->connections[$j];
                        if (array_key_exists($con->connid, $checkConns) === FALSE) {
                            $checkConns[$con->connid] = $con->connid;
                            $view->addConnection($con);
                        }
                        $from = $con->from;
                        if (!$from instanceof Error && array_key_exists($from->nodeid, $checkNodes) === FALSE) {
                            $checkNodes[$from->nodeid] = $from->nodeid;
                            $view->addNode($from);
                        }
                        $to = $con->to;
                        if (!$to instanceof Error && array_key_exists($to->nodeid, $checkNodes) === FALSE) {
                            $checkNodes[$to->nodeid] = $to->nodeid;
                            $view->addNode($to);
                        }
                    }
                }
            }
        }
    }
    $group->view = $view;
    return $group;
}