Exemple #1
0
function login($ip, $nick, $password)
{
    /*$intentos = 0;
    		if (isset($_COOKIE['intentos'])){ 
    			$intentos = $_COOKIE['intentos'];
    		}
    				
    		if ($intentos <= 3){*/
    $hashedPassword = hash("sha256", $password, false);
    if (checkNickPassword($nick, $hashedPassword)) {
        $email = getEmail($nick);
        $_SESSION['nick'] = $nick;
        $_SESSION['email'] = $email;
        $_SESSION['role'] = getRole($email);
        //setcookie( 'intentos', 0, time() + 1800 ); //30 minutos
        addAction($nick, $email, $ip, 'logged_in');
        addConnection($nick, $email, $ip);
        return '0';
        // Logged.
    } else {
        //if ($intentos < 3) {
        //setcookie( 'intentos', $intentos + 1, time() + 1800 ); //30 minutos
        return '1';
        // Log in failed.
    }
    /*} 
    		
    		setcookie( 'intentos', 0, time() + 1800);
    		return '2';	// Superado el límite de intentos.
    		*/
}
Exemple #2
0
/**
 * Import nodes and connections from the given CIF url for the selected nodeids into the given map.
 * The node import limit is set by '$CFG->ImportLimit'.
 * @param url the url for the CIF data to load
 * @param mapid the id of the map to get alerts for
 * @param selectedids an array of the CIF node ides to import
 * @param poses an array of the positions of the nodes in the map each array item is in
 * the format 'x:y' and the position in the array should correspond ot the position of
 * its node in the selectednodeids array.
 * before it is considered out of date and should be refetched and recalculated.
 * Defaults to 60 seconds.
 * @param private true if the data should be created as private, else false.
 * @return View object of the map or Error.
 *
 */
function addNodesAndConnectionsFromJsonld($url, $mapid, $selectedids, $poses, $private)
{
    global $USER, $HUB_FLM, $CFG, $ERROR;
    require_once $HUB_FLM->getCodeDirPath("core/io/catalyst/catalyst_jsonld_reader.class.php");
    require_once $HUB_FLM->getCodeDirPath("core/lib/url-validation.class.php");
    //error_log(print_r($selectedids, true));
    if (count($selectedids) > $CFG->ImportLimit) {
        $ERROR = new error();
        $ERROR->createAccessDeniedError();
        return $ERROR;
    }
    //error_log(print_r($poses, true));
    // Check if the map is in a group and if so get the group id.
    $groupid = "";
    $v = new View($mapid);
    $view = $v->load();
    if (!$view instanceof Error) {
        if (isset($view->viewnode->groups)) {
            $groups = $view->viewnode->groups;
            if (count($groups) > 0) {
                $groupid = $groups[0]->groupid;
            }
        }
    } else {
        return $view;
    }
    // make sure current user in group, if group set.
    if ($groupid != "") {
        $group = new Group($groupid);
        if (!$group instanceof Error) {
            if (!$group->ismember($USER->userid)) {
                $error = new Error();
                return $error->createNotInGroup($group->name);
            }
        }
    }
    $withhistory = false;
    $withvotes = false;
    $reader = new catalyst_jsonld_reader();
    $reader = $reader->load($url, $withhistory, $withvotes);
    if (!$reader instanceof Error) {
        $nodeset = $reader->nodeSet;
        $nodes = $nodeset->nodes;
        $count = count($nodes);
        $newnodeSet = new NodeSet();
        $newNodeCheck = array();
        for ($i = 0; $i < $count; $i++) {
            $node = $nodes[$i];
            $position = array_search($node->nodeid, $selectedids);
            //error_log("position:".$position);
            if ($position !== FALSE) {
                $position = intval($position);
                $positem = $poses[$position];
                $positemArray = explode(":", $positem);
                $xpos = "";
                $ypos = "";
                if (count($positemArray) == 2) {
                    $xpos = $positemArray[0];
                    $ypos = $positemArray[1];
                }
                //error_log("xpos:".$xpos.":ypos:".$ypos);
                $role = getRoleByName($node->rolename);
                $description = "";
                if (isset($node->description)) {
                    $description = $node->description;
                }
                $newnode = addNode($node->name, $description, $private, $role->roleid);
                //error_log(print_r($newnode, true));
                if (!$newnode instanceof Error) {
                    $newNodeCheck[$node->nodeid] = $newnode;
                    //error_log($node->nodeid);
                    // if we have positioning information add the node to the map.
                    if ($xpos != "" && $ypos != "") {
                        $viewnode = $view->addNode($newnode->nodeid, $xpos, $ypos);
                        //if (!$viewnode instanceof Error) {
                    }
                    if (isset($node->homepage) && $node->homepage != "") {
                        $URLValidator = new mrsnk_URL_validation($node->homepage, MRSNK_URL_DO_NOT_PRINT_ERRORS, MRSNK_URL_DO_NOT_CONNECT_2_URL);
                        if ($URLValidator->isValid()) {
                            $urlObj = addURL($node->homepage, $node->homepage, "", $private, "", "", "", "cohere", "");
                            $newnode->addURL($urlObj->urlid, "");
                            // Add url to group? - not done on forms at present
                        } else {
                            error_log('Invalid node homepage: ' . $node->homepage . ': for ' . $node->nodeid);
                        }
                    }
                    if (isset($node->users[0])) {
                        $user = $node->users[0];
                        if (isset($user->homepage) && $user->homepage != "") {
                            $URLValidator = new mrsnk_URL_validation($user->homepage, MRSNK_URL_DO_NOT_PRINT_ERRORS, MRSNK_URL_DO_NOT_CONNECT_2_URL);
                            if ($URLValidator->isValid()) {
                                $urlObj = addURL($user->homepage, $user->homepage, "", $private, "", "", "", "cohere", "");
                                $newnode->addURL($urlObj->urlid, "");
                                // Add url to group? - not done on forms at present
                            } else {
                                error_log('Invalid user homepage: ' . $user->homepage . ': for ' . $user->userid);
                            }
                        }
                    }
                    //if ($groupid != "") {
                    //	$newnode->addGroup($groupid);
                    //}
                    $newnodeSet->add($newnode);
                } else {
                    error_log(print_r($newnode, true));
                }
            }
        }
        $connectionset = $reader->connectionSet;
        $connections = $connectionset->connections;
        $count = count($connections);
        for ($i = 0; $i < $count; $i++) {
            $conn = $connections[$i];
            $from = $conn->from;
            $to = $conn->to;
            $fromrole = $conn->fromrole;
            $torole = $conn->torole;
            if (isset($newNodeCheck[$from->nodeid]) && isset($newNodeCheck[$to->nodeid])) {
                $newFromNode = $newNodeCheck[$from->nodeid];
                $newToNode = $newNodeCheck[$to->nodeid];
                // Might not need this as it might be done already
                //if ($newFromNode->role->name != $fromrole->name) {
                //	updateNodeRole($newFromNode->nodeid,$fromrole->name);
                //}
                $linklabelname = $conn->linklabelname;
                //error_log($linklabelname);
                $lt = getLinkTypeByLabel($linklabelname);
                if (!$lt instanceof Error) {
                    $linkType = $lt->linktypeid;
                    //$frole = getRoleByName($fromrole->name);
                    //$trole = getRoleByName($torole->name);
                    $connection = addConnection($newFromNode->nodeid, $newFromNode->role->roleid, $linkType, $newToNode->nodeid, $newToNode->role->roleid, 'N', "");
                    //error_log(print_r($connection, true));
                    if (!$connection instanceof Error) {
                        // add to group
                        if (isset($groupid) && $groupid != "") {
                            $connection->addGroup($groupid);
                        }
                        $viewcon = $view->addConnection($connection->connid);
                        //error_log(print_r($viewcon,true));
                    } else {
                        error_log(print_r($connection, true));
                    }
                } else {
                    error_log("for label:" . $linklabelname . ":" . print_r($lt, true));
                }
            }
        }
    } else {
        return $reader;
    }
    return $view;
}
Exemple #3
0
                                         getContent($storyID);
                                     } else {
                                         if ($functionName == "saveContent") {
                                             saveContent($storyID);
                                         } else {
                                             if ($functionName == "getTitle") {
                                                 getTitle($storyID);
                                             } else {
                                                 if ($functionName == "getStoryDetails") {
                                                     getStoryDetails($storyID);
                                                 } else {
                                                     if ($functionName == "saveStory") {
                                                         saveStory($storyID);
                                                     } else {
                                                         if ($functionName == "addConnection") {
                                                             addConnection($localhost, $user, $pw, $db, $storyID);
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
     $linktypeid = required_param('linktypeid', PARAM_ALPHANUMEXT);
     $tonodeid = required_param('tonodeid', PARAM_ALPHANUMEXT);
     $toroleid = required_param('toroleid', PARAM_ALPHANUMEXT);
     $description = optional_param('description', "", PARAM_TEXT);
     $response = addConnection($fromnodeid, $fromroleid, $linktypeid, $tonodeid, $toroleid, $private, $description);
     break;
 case "addconnectionlinkname":
     $fromnodeid = required_param('fromnodeid', PARAM_ALPHANUMEXT);
     $fromroleid = required_param('fromroleid', PARAM_ALPHANUMEXT);
     $linktypename = required_param('linktypename', PARAM_TEXT);
     $tonodeid = required_param('tonodeid', PARAM_ALPHANUMEXT);
     $toroleid = required_param('toroleid', PARAM_ALPHANUMEXT);
     $description = optional_param('description', "", PARAM_TEXT);
     $link = getLinkTypeByLabel($linktypename);
     if (!$link instanceof Error) {
         $response = addConnection($fromnodeid, $fromroleid, $link->linktypeid, $tonodeid, $toroleid, $private, $description);
     } else {
         $ERROR = new Error();
         return $ERROR->createInvalidConnectionError();
     }
     break;
 case "editconnectiondescription":
     $connid = required_param('connid', PARAM_ALPHANUMEXT);
     $description = optional_param('description', "", PARAM_TEXT);
     $response = editConnectionDescription($connid, $description);
     break;
 case "deleteconnection":
     $connid = required_param('connid', PARAM_ALPHANUMEXT);
     $response = deleteConnection($connid);
     break;
     /** ROLES aka NODE TYPES **/
Exemple #5
0
 if (empty($errors)) {
     // GET ROLES AND LINKS AS USER
     $r = getRoleByName("Issue");
     $roleIssue = $r->roleid;
     // CREATE THE ISSUE NODE
     $issuenode = addNode($issue, $desc, $private, $roleIssue);
     if (!$issuenode instanceof Error) {
         // Add a see also to the chat comment node this was cread from if chatnodeid exists
         if ($clonenodeid != "") {
             $clonenode = getNode($clonenodeid);
             $clonerolename = $clonenode->role->name;
             $r = getRoleByName($clonerolename);
             $roleClone = $r->roleid;
             $lt = getLinkTypeByLabel($CFG->LINK_COMMENT_BUILT_FROM);
             $linkComment = $lt->linktypeid;
             $connection = addConnection($issuenode->nodeid, $roleIssue, $linkComment, $clonenodeid, $roleClone, "N");
         }
         /*if ($_FILES['image']['error'] == 0) {
         					$imagedir = $HUB_FLM->getUploadsNodeDir($issuenode->nodeid);
         
         					$photofilename = uploadImageToFit('image',$errors,$imagedir);
         					if($photofilename == ""){
         						$photofilename = $CFG->DEFAULT_ISSUE_PHOTO;
         					}
         					$issuenode->updateImage($photofilename);
         				}*/
         if (isset($groupid) && $groupid != "") {
             $issuenode->addGroup($groupid);
         }
         /** ADD RESOURCES **/
         if (empty($errors)) {
Exemple #6
0
	case "rejectUser":
	case "rejectuser":
	$oldignoreuserabort = ignore_user_abort(true);
	rejectUser(cbGetParam($_POST,'uids'));
	break;

	case "sendUserEmail":
	case "senduseremail":
	$oldignoreuserabort = ignore_user_abort(true);
	sendUserEmail( $option, (int) cbGetParam( $_POST, 'toID', 0 ), (int) cbGetParam( $_POST, 'fromID', 0 ), cbGetParam( $_POST, 'emailSubject', '' ), cbGetParam( $_POST, 'emailBody', '' ) );
	break;

	case "addConnection":
	case "addconnection":
	$oldignoreuserabort = ignore_user_abort(true);
	addConnection( $_CB_framework->myId(), (int) cbGetParam($_REQUEST,'connectionid'), ((isset($_POST['message'])) ? cbGetParam($_POST,'message') : ""));
	break;

	case "removeConnection":
	case "removeconnection":
	$oldignoreuserabort = ignore_user_abort(true);
	removeConnection( $_CB_framework->myId(), (int) cbGetParam($_REQUEST, 'connectionid') );
	break;

	case "denyConnection":
	case "denyconnection":
	$oldignoreuserabort = ignore_user_abort(true);
	denyConnection( $_CB_framework->myId(), (int) cbGetParam($_REQUEST,'connectionid'));
	break;

	case "acceptConnection":
Exemple #7
0
function mergeSelectedNodes($issuenodeid, $groupid, $ids, $title, $desc)
{
    global $CFG;
    $mainConnections = getConnectionsByNode($issuenodeid, 0, -1, 'date', 'ASC', 'all', '', 'Solution');
    $mainconns = $mainConnections->connections;
    $r = getRoleByName("Solution");
    $rolesolution = $r->roleid;
    // CREATE THE solution NODE
    $solutionnode = addNode($title, $desc, 'N', $rolesolution);
    if (!$solutionnode instanceof Error) {
        // Add to group
        if (isset($groupid) && $groupid != "") {
            addGroupToNode($solutionnode->nodeid, $groupid);
        }
        // CONNECT NODE TO FOCAL
        $node = getNode($issuenodeid);
        $r = getRoleByName($node->role->name);
        $focalroleid = $r->roleid;
        $lt = getLinkTypeByLabel($CFG->LINK_SOLUTION_ISSUE);
        $linkType = $lt->linktypeid;
        $conndesc = "";
        $connection = addConnection($solutionnode->nodeid, $rolesolution, $linkType, $issuenodeid, $focalroleid, "N", $conndesc);
        if (!$connection instanceof Error) {
            // add to group
            if (isset($groupid) && $groupid != "") {
                addGroupToConnection($connection->connid, $groupid);
            }
            // CONNECT NEW NODE TO SELECT NODES
            $lt2 = getLinkTypeByLabel($CFG->LINK_BUILT_FROM);
            $linkTypeBuiltFrom = $lt2->linktypeid;
            //error_log(print_r($linkTypeBuiltFrom, true));
            $nodesArr = split(",", $ids);
            foreach ($nodesArr as $nodeid2) {
                $n = new CNode($nodeid2);
                $n = $n->load();
                $r = getRoleByName($n->role->name);
                $roleid = $r->roleid;
                $connection2 = addConnection($solutionnode->nodeid, $rolesolution, $linkTypeBuiltFrom, $nodeid2, $roleid, "N", $conndesc);
                //error_log(print_r($connection2, true));
                if (!$connection2 instanceof Error) {
                    // add to group
                    if (isset($groupid) && $groupid != "") {
                        addGroupToConnection($connection2->connid, $groupid);
                    }
                    // Link kids to new parent
                    $conSetKids = getConnectionsByNode($nodeid2, 0, -1, 'date', 'ASC', 'all', '', 'Pro,Con,Comment');
                    $conns = $conSetKids->connections;
                    foreach ($conns as $con) {
                        $from = $con->from;
                        $r2 = getRoleByName($from->role->name);
                        $fromroleid = $r2->roleid;
                        //error_log('nextfrom:'.print_r($from, true));
                        $lt3 = getLinkTypeByLabel($CFG->LINK_COMMENT_NODE);
                        $linkType3 = $lt3->linktypeid;
                        if ($from->role->name == "Pro") {
                            $lt3 = getLinkTypeByLabel($CFG->LINK_PRO_SOLUTION);
                            $linkType3 = $lt3->linktypeid;
                        } else {
                            if ($from->role->name == "Con") {
                                $lt3 = getLinkTypeByLabel($CFG->LINK_CON_SOLUTION);
                                $linkType3 = $lt3->linktypeid;
                            }
                        }
                        // Connect the children of each node being merged to the new node
                        $connection3 = addConnection($from->nodeid, $fromroleid, $linkType3, $solutionnode->nodeid, $rolesolution, "N", $conndesc);
                        if (!$connection3 instanceof Error) {
                            // add to group
                            if (isset($groupid) && $groupid != "") {
                                addGroupToConnection($connection3->connid, $groupid);
                            }
                        } else {
                            //error_log(print_r($connection3, true));
                        }
                        // retire old connection
                        $con->updateStatus($CFG->STATUS_RETIRED);
                    }
                    // retire connection to parent
                    foreach ($mainconns as $con) {
                        $from = $con->from;
                        if ($from->nodeid == $nodeid2) {
                            $con->updateStatus($CFG->STATUS_RETIRED);
                        }
                    }
                    // retire node
                    $n->updateStatus($CFG->STATUS_RETIRED);
                } else {
                    return $connection2;
                }
            }
        } else {
            return $connection;
        }
    }
    return $solutionnode;
}
Exemple #8
0
 if (empty($errors)) {
     $currentUser = $USER;
     $orinode = getNode($nodeid);
     $r = getRoleByName($orinode->role->name);
     $roleid = $r->roleid;
     $i = 0;
     $count = count($ideanamearray);
     for ($i = 0; $i < $count; $i++) {
         $name = $ideanamearray[$i];
         $desc = $ideadescarray[$i];
         $newconn = addNodeAndConnect($name, $desc, 'Solution', $debateid, $CFG->LINK_SOLUTION_ISSUE, 'from', $groupid = "", 'N');
         $newnode = $newconn->from;
         // CONNECT NEW NODE TO SELECT NODES
         $lt2 = getLinkTypeByLabel($CFG->LINK_BUILT_FROM);
         $linkTypeBuiltFrom = $lt2->linktypeid;
         $connection = addConnection($newnode->nodeid, $newnode->role->roleid, $linkTypeBuiltFrom, $orinode->nodeid, $roleid, "N", "");
         // add to group
         if (!$connection instanceof Error && isset($groupid) && $groupid != "") {
             addGroupToConnection($connection->connid, $groupid);
         }
     }
     // need to become the owner of the node you are editing the status of
     //$USER = $orinode->users[0];
     $orinode->updateStatus($CFG->STATUS_RETIRED);
     echo '<script type=\'text/javascript\'>';
     //echo 'window.opener.location.href = "'.$CFG->homeAddress.'user.php?id='.$USER->userid.'";';
     echo "\t  window.opener.location.reload(true);";
     echo 'window.close();';
     echo '</script>';
     include_once $HUB_FLM->getCodeDirPath("ui/footerdialog.php");
     die;
 $currentUser = $USER;
 // GET ROLE FOR USER
 $r = getRoleByName("Solution");
 $roleSolution = $r->roleid;
 // CREATE THE solution NODE
 $solutionnode = addNode($solution, $desc, $private, $roleSolution);
 if (!$solutionnode instanceof Error) {
     // Add a see also to the chat comment node this was cread from if chatnodeid exists
     if ($clonenodeid != "") {
         $clonenode = getNode($clonenodeid);
         $clonerolename = $clonenode->role->name;
         $r = getRoleByName($clonerolename);
         $roleClone = $r->roleid;
         $lt = getLinkTypeByLabel($CFG->LINK_COMMENT_BUILT_FROM);
         $linkComment = $lt->linktypeid;
         $connection = addConnection($solutionnode->nodeid, $roleSolution, $linkComment, $clonenodeid, $roleClone, "N");
     }
     /** ADD RESOURCES **/
     if (empty($errors)) {
         $lt = getLinkTypeByLabel('is related to');
         $linkRelated = $lt->linktypeid;
         $i = 0;
         foreach ($resourceurlarray as $resourceurl) {
             $resourcetitle = trim($resourcetitlearray[$i]);
             // If they have entered nothing, don't do anything.
             if ($resourcetitle == "" && ($resourceurl == "http://" || $resourceurl == "")) {
                 break;
             }
             //check all fields entered
             if ($resourcetitle != "" && ($resourceurl == "http://" || $resourceurl == "")) {
                 array_push($errors, $LNG->FORM_RESOURCE_URL_REQUIRED);