$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();
$countUsers = 1;
for ($i = 0; $i < $count; $i++) {
    $node = $nodes[$i];
    $activitieSet = getAllNodeActivity($node->nodeid, 0, 0, -1);
    $activities = $activitieSet->activities;
    foreach ($activities as $activity) {
        if (isset($activity)) {
            $date = $activity->modificationdate;
            $type = $activity->type;
            $changetype = $activity->changetype;
            if ($type == "Node" && $changetype == 'add' || $type == "Vote") {
                $role = $node->role->name;
                if ($type == "Vote") {
                    $role = $LNG->STATS_ACTIVITY_VOTE;
                    //if ($changetype == "Y") {
                    //	$role = $LNG->STATS_ACTIVITY_VOTED_FOR;
                    //} else {
                    //	$role = $LNG->STATS_ACTIVITY_VOTED_AGAINST;
                    //}
示例#2
0
 function addNodeHistory($nodes, $viewid, $viewname)
 {
     global $CFG;
     $this->dataGraphStr .= '{';
     $this->dataGraphStr .= '"history_graph": "' . $viewname . ':history",';
     $this->dataGraphStr .= '"@id": "' . $viewid . '"';
     $this->dataGraphStr .= '},';
     $this->historyGraphStr .= "{";
     $this->historyGraphStr .= '"@graph": [';
     $count = count($nodes);
     for ($i = 0; $i < $count; $i++) {
         $node = $nodes[$i];
         $as = getAllNodeActivity($node->nodeid, 0, 0, -1, 'cif');
         $activities = $as->activities;
         foreach ($activities as $activity) {
             $this->addNodeHistoryItem($activity);
         }
     }
     // trim last comma
     $this->historyGraphStr = $this->trimFinalComma($this->historyGraphStr);
     $this->historyGraphStr .= '],';
     $this->historyGraphStr .= '"@id": "' . $viewname . ':history"';
     $this->historyGraphStr .= "},";
 }
示例#3
0
 /**
  * Loads the data for the node from the database
  *
  * @param String $style (optional - default 'long') may be 'short' or 'long' or 'mini' or 'full' or 'shortactivity' (mini used for graphs)
  * 'mini' include the base information like name, description, role, user, private, creation and modifications dates, connectedness, image, thumb.
  * 'short' includes 'mini' plus address information, start and end date, otherconnections, userfollow.
  * 'long' includes 'short' and associated website objects, tag objects, group onjects, votes, view counts and extra properties.
  * 'full' includes 'long' and all activity and voting data. This is likely to be very heavy. Use wisely.
  * 'shortactivity' includes 'short' plus the activity and voting data.
  * 'cif' just what is needed for cif.
  * @return Node object (this)
  */
 function load($style = 'long')
 {
     global $DB, $CFG, $USER, $ERROR, $HUB_FLM, $HUB_SQL;
     try {
         $this->canview();
     } catch (Exception $e) {
         return access_denied_error();
     }
     $this->style = $style;
     $params = array();
     $params[0] = $this->nodeid;
     $resArray = $DB->select($HUB_SQL->DATAMODEL_NODE_SELECT, $params);
     if ($resArray !== false) {
         $count = count($resArray);
         if ($count == 0) {
             $ERROR = new error();
             $ERROR->createNodeNotFoundError($this->nodeid);
             return $ERROR;
         } else {
             for ($i = 0; $i < $count; $i++) {
                 $array = $resArray[$i];
                 $this->name = stripslashes(trim($array['Name']));
                 $this->creationdate = $array['CreationDate'];
                 $this->modificationdate = $array['ModificationDate'];
                 if (isset($array['NodeTypeID'])) {
                     $this->role = new Role($array['NodeTypeID']);
                     $this->role = $this->role->load();
                 }
                 if (trim($array['Description']) != "") {
                     $this->hasdesc = true;
                 }
                 if ($style == 'long' || $style == 'cif') {
                     $this->description = stripslashes(trim($array['Description']));
                 }
                 $this->users = array();
                 if ($style == 'cif') {
                     //CIF does not need the whole user info at present
                     // or just userid at this level?
                     $this->users[0] = new User($array['UserID']);
                 } else {
                     $maps = getMapsForNode($this->nodeid, 0, 0);
                     $this->mapcount = $maps->totalno;
                     $this->connectedness = $array['connectedness'];
                     $this->private = $array['Private'];
                     $this->users[0] = getUser($array['UserID'], $style);
                     if ($array['Image']) {
                         $this->filename = $array['Image'];
                         $imagedir = $HUB_FLM->getUploadsNodeDir($this->nodeid, $array['UserID']);
                         $originalphotopath = $HUB_FLM->createUploadsDirPath($imagedir . "/" . stripslashes($array['Image']));
                         if (file_exists($originalphotopath)) {
                             $this->image = $HUB_FLM->getUploadsWebPath($imagedir . "/" . stripslashes($array['Image']));
                             $this->thumb = $HUB_FLM->getUploadsWebPath($imagedir . "/" . str_replace('.', '_thumb.', stripslashes($array['Image'])));
                             if (!file_exists($this->thumb)) {
                                 create_image_thumb($array['Image'], $CFG->IMAGE_THUMB_WIDTH, $imagedir);
                             }
                         } else {
                             if ($this->role->name == 'Map') {
                                 $this->image = $HUB_FLM->getUploadsWebPath($CFG->DEFAULT_ISSUE_PHOTO);
                                 $this->thumb = $HUB_FLM->getUploadsWebPath(str_replace('.', '_thumb.', stripslashes($CFG->DEFAULT_ISSUE_PHOTO)));
                             }
                         }
                     } else {
                         if ($this->role->name == 'Map') {
                             $this->image = $HUB_FLM->getUploadsWebPath($CFG->DEFAULT_ISSUE_PHOTO);
                             $this->thumb = $HUB_FLM->getUploadsWebPath(str_replace('.', '_thumb.', stripslashes($CFG->DEFAULT_ISSUE_PHOTO)));
                         }
                     }
                     //if(isset($array['Image'])){
                     //    $this->imageurlid = $array['Image'];
                     //}
                     //if(isset($array['ImageThumbnail'])){
                     //    $this->thum = $array['ImageThumbnail'];
                     //}
                     if ($style != 'mini') {
                         if (isset($array['StartDate']) && $array['StartDate'] != 0) {
                             $this->startdatetime = $array['StartDate'];
                         }
                         if (isset($array['EndDate']) && $array['EndDate'] != 0) {
                             $this->enddatetime = $array['EndDate'];
                         }
                         if (isset($array['LocationText'])) {
                             $this->location = $array['LocationText'];
                         } else {
                             $this->location = '';
                         }
                         if (isset($array['LocationCountry'])) {
                             $cs = getCountryList();
                             $this->countrycode = $array['LocationCountry'];
                             if (isset($cs[$array['LocationCountry']])) {
                                 $this->country = $cs[$array['LocationCountry']];
                             }
                         }
                         if (isset($array['LocationLat'])) {
                             $this->locationlat = $array['LocationLat'];
                         }
                         if (isset($array['LocationLng'])) {
                             $this->locationlng = $array['LocationLng'];
                         }
                         if (isset($array['LocationAddress1'])) {
                             $this->locationaddress1 = $array['LocationAddress1'];
                         }
                         if (isset($array['LocationAddress2'])) {
                             $this->locationaddress2 = $array['LocationAddress2'];
                         }
                         if (isset($array['LocationPostCode'])) {
                             $this->locationpostcode = $array['LocationPostCode'];
                         }
                         if (isset($array['AdditionalIdentifier'])) {
                             $this->identifier = $array['AdditionalIdentifier'];
                         }
                         if (isset($array['CurrentStatus'])) {
                             $this->status = $array['CurrentStatus'];
                         }
                     }
                 }
             }
         }
     } else {
         return database_error();
     }
     $currentuser = '';
     if (isset($USER->userid)) {
         $currentuser = $USER->userid;
     }
     if ($style != 'mini' && $style != 'cif') {
         $params = array();
         $params[0] = $this->nodeid;
         $params[1] = $this->nodeid;
         $params[2] = $currentuser;
         $resArray = $DB->select($HUB_SQL->DATAMODEL_NODE_EXTERNAL_CONNECTIONS, $params);
         if ($resArray !== false) {
             if (count($resArray) > 0) {
                 $this->otheruserconnections = $resArray[0]['connectedness'];
             } else {
                 $this->otheruserconnections = 0;
             }
         }
         $this->userfollow = "N";
         //load the current user's following status for this node if any
         $params = array();
         $params[0] = $currentuser;
         $params[1] = $this->nodeid;
         $resArray = $DB->select($HUB_SQL->DATAMODEL_NODE_USER_FOLLOW, $params);
         if ($resArray !== false) {
             if (count($resArray) > 0) {
                 $this->userfollow = "Y";
             }
         }
     }
     if ($style == 'long' || $style == 'full' || $style == 'cif') {
         $this->loadWebsites($style);
     }
     if ($style == 'long' || $style == 'full') {
         $this->loadTags();
         $this->loadGroups();
         $this->loadVotes();
         $this->loadProperties();
         $this->loadViewCount();
     }
     if ($style == 'full' || $style == 'shortactivity') {
         $this->activity = getAllNodeActivity($this->nodeid, 0, 0, -1);
         $this->votes = getVotes($this->nodeid);
     }
     //load comments, pro count and con count if Solution.
     /*if ($this->role->name == "Solution") {
     			$this->haschildren = 'N';
     			$conSetKids = getConnectionsByNode($this->nodeid,0,0,'date','ASC', 'all', '', 'Pro,Con,Comment');
     			if (!$conSetKids instanceof Error) {
     				if ($conSetKids->totalno > 0) {
     					$this->haschildren = 'Y';
     				}
     			} else {
     				return database_error();
     			}
     		}*/
     return $this;
 }