Esempio n. 1
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;
}
Esempio n. 2
0
     }
     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 **/
 /** ROLES aka NODE TYPES **/
 case "getrolebyname":
     $rolename = required_param('rolename', PARAM_TEXT);
     $response = getRoleByName($rolename);
     break;
     /** LINK TYPES **/
 /** LINK TYPES **/
 case "getlinktypebylabel":
     $label = required_param('label', PARAM_TEXT);
     $response = getLinkTypeByLabel($label);
     break;
     /** USERS **/
 /** USERS **/
 case "getuser":
     $userid = required_param('userid', PARAM_ALPHANUMEXT);
     $response = getUser($userid, $style);
     break;
 case "getactiveconnectionusers":
     $response = getActiveConnectionUsers($start, $max, $style);
Esempio n. 3
0
 if ($sdt != "" && $edt != "") {
     $edate = strtotime($edt);
     $sdate = strtotime($sdt);
     if ($sdate >= $edate) {
         array_push($errors, $LNG->FORM_ISSUE_START_END_DATE_ERROR);
     }
     if ($votingstart != "") {
         $vdate = strtotime($votingstart);
         if ($vdate > $edate || $vdate < $sdate) {
             array_push($errors, $LNG->FORM_ISSUE_VOTE_START_DATE_ERROR);
         }
     }
 }
 if (empty($errors)) {
     // GET ROLES AND LINKS AS USER
     $r = getRoleByName("Issue");
     $roleIssue = $r->roleid;
     // CREATE THE ISSUE NODE
     $issuenode = addNode($issue, $desc, 'N', $roleIssue);
     if (!$issuenode instanceof Error) {
         // ISSUE DATES
         $issuenode->updateStartDate($utcstarttime);
         $issuenode->updateEndDate($utcendtime);
         // DISCUSSION
         if ($utcdiscussionendtime != 0) {
             $issuenode->updateNodeProperty('discussionstart', $utcstarttime);
         }
         $issuenode->updateNodeProperty('discussionend', $utcdiscussionendtime);
         // LEMONING
         $issuenode->updateNodeProperty('lemoningon', $lemoningon);
         $issuenode->updateNodeProperty('lemoningstart', $utclemoningstarttime);
Esempio n. 4
0
 /**
  * Add new Comment node to the database - does not check for duplication
  *
  * @param string $name
  * @param string $desc optional, default to empty string.
  * @param string $private optional, can be Y or N, defaults to user's private data option
  * @param string $nodetypeid optional, the id of the nodetype this node is. Defaults to 'Comment' node type.
  * @param string $image optional, optional, the local server path to the image used for this node. Defaults to empty string.
  * @param string $thumb optional, the local server path to the thumbnail of the image used for this node. Defaults to empty string
  * @return Node object (this) (or Error object)
  */
 function addComment($name, $desc = "", $private = "", $nodetypeid = "", $image = "", $thumb = "")
 {
     global $DB, $CFG, $USER, $HUB_SQL;
     try {
         $this->canadd();
     } catch (Exception $e) {
         return access_denied_error();
     }
     $dt = time();
     $this->nodeid = getUniqueID();
     if ($private == "") {
         $private = $USER->privatedata;
     }
     if ($nodetypeid === "") {
         $role = getRoleByName('Comment');
         $nodetypeid = $role->roleid;
     }
     $currentuser = '';
     if (isset($USER->userid)) {
         $currentuser = $USER->userid;
     }
     $params = array();
     $params[0] = $this->nodeid;
     $params[1] = $currentuser;
     $params[2] = $dt;
     $params[3] = $dt;
     $params[4] = $name;
     $params[5] = $desc;
     $params[6] = $private;
     $params[7] = $nodetypeid;
     $params[8] = $image;
     $params[9] = $thumb;
     $res = $DB->insert($HUB_SQL->DATAMODEL_NODE_ADD_COMMENT, $params);
     if (!$res) {
         return database_error();
     } else {
         $temp = $this->load();
         auditIdea($USER->userid, $temp->nodeid, $name, $desc, $CFG->actionAdd, format_object('xml', $temp));
         return $temp;
     }
 }
Esempio n. 5
0
if (isset($_POST["addissue"])) {
    if ($issue == "") {
        array_push($errors, $LNG->FORM_ISSUE_ENTER_SUMMARY_ERROR);
    }
    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 != "") {
Esempio n. 6
0
//convert any possible brackets
$handler = parseToJSON($handler);
// only want to set the default privacy if the form hasn't been posted yet
if (isset($_POST["addmap"])) {
    $private = optional_param("private", "Y", PARAM_ALPHA);
} else {
    $private = optional_param("private", $USER->privatedata, PARAM_ALPHA);
}
$groupset = getMyGroups();
$groups = $groupset->groups;
if (isset($_POST["addmap"])) {
    if ($maptitle == "") {
        array_push($errors, $LNG->FORM_MAP_ENTER_SUMMARY_ERROR);
    }
    if (empty($errors)) {
        $r = getRoleByName("Map");
        $roleMap = $r->roleid;
        // CREATE THE MAP NODE
        $mapview = addView($maptitle, $desc, $private, $roleMap, $groupid, 0, 0);
        $mapnode = $mapview->viewnode;
        if (!$mapview instanceof Error) {
            if ($_FILES['image']['error'] == 0) {
                $imagedir = $HUB_FLM->getUploadsNodeDir($mapnode->nodeid);
                $photofilename = uploadImageToFit('image', $errors, $imagedir);
                if ($photofilename == "") {
                    $photofilename = $CFG->DEFAULT_ISSUE_PHOTO;
                }
                $mapnode->updateImage($photofilename);
            }
            if ($_FILES['background']['error'] == 0) {
                $imagedir = $HUB_FLM->getUploadsNodeDir($mapnode->nodeid);
Esempio n. 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;
}
Esempio n. 8
0
$resourceurlarray = optional_param("resourceurlarray", "", PARAM_URL);
$identifierarray = optional_param("identifierarray", "", PARAM_TEXT);
$resourcenodeidsarray = optional_param("resourcenodeidsarray", "", PARAM_TEXT);
$resourcecliparray = optional_param("resourcecliparray", "", PARAM_TEXT);
$resourceclippatharray = optional_param("resourceclippatharray", "", PARAM_TEXT);
if (isset($_POST["editcomment"])) {
    $label = $summary;
    trim($label);
    if ($label == "") {
        array_push($errors, $LNG->FORM_COMMENT_ENTER_SUMMARY_ERROR);
    }
    if (empty($errors)) {
        $private = optional_param("private", "Y", PARAM_ALPHA);
        $currentUser = $USER;
        $commentnode = getNode($nodeid);
        $r = getRoleByName("Idea");
        $roleComment = $r->roleid;
        // EDIT THE COMMENT NODE
        $filename = "";
        if (isset($commentnode->filename)) {
            $filename = $commentnode->filename;
        }
        $commentnode = $commentnode->edit($label, $desc, $private, $roleComment, $filename, '');
        if (!$commentnode instanceof Error) {
            /** ADD RESOURCES/URLS **/
            if (empty($errors)) {
                $imagedelete = optional_param("imagedelete", "N", PARAM_ALPHA);
                if ($imagedelete == 'Y') {
                    $commentnode->updateImage($CFG->DEFAULT_ISSUE_PHOTO);
                } else {
                    if ($_FILES['image']['error'] == 0) {
Esempio n. 9
0
/** EVIDENCE HUB SPECIFIC FUNCTIONS **/
function updateConnectionsForTypeChange($nodeid, $type)
{
    global $USER, $CFG;
    $connectionSet = getConnectionsByNode($nodeid, 0, -1);
    $connections = $connectionSet->connections;
    $count = count($connections);
    for ($i = 0; $i < $count; $i++) {
        $con = $connections[$i];
        if ($con->from->nodeid == $nodeid) {
            $currentuser = $USER;
            $conUserID = $con->userid;
            $conUser = new User($conUserID);
            $conUser = $conUser->load();
            $USER = $conUser;
            $r = getRoleByName($type);
            $roleid = $r->roleid;
            $con->edit($con->from->nodeid, $roleid, $con->linktype->linktypeid, $con->to->nodeid, $con->torole->roleid, $con->private, $con->description);
            $USER = $currentuser;
        } else {
            if ($con->to->nodeid == $nodeid) {
                $currentuser = $USER;
                $conUserID = $con->userid;
                $conUser = new User($conUserID);
                $conUser = $conUser->load();
                $USER = $conUser;
                $r = getRoleByName($type);
                $roleid = $r->roleid;
                $con->edit($con->from->nodeid, $con->fromrole->roleid, $con->linktype->linktypeid, $con->to->nodeid, $roleid, $con->private, $con->description);
                $USER = $currentuser;
            }
        }
    }
}
Esempio n. 10
0
            $USER = $currentuser;
        } else {
            array_push($errors, $LNG->ADMIN_NEWS_MISSING_NAME_ERROR);
        }
    } else {
        array_push($errors, $LNG->ADMIN_NEWS_ID_ERROR);
    }
} else {
    if (isset($_POST["addnews"])) {
        if ($name != "") {
            //become the news admin user
            $currentuser = $USER;
            $admin = new User($CFG->adminUserID);
            $admin = $admin->load();
            $USER = $admin;
            $r = getRoleByName('News');
            $roleType = $r->roleid;
            $node = addNode($name, $desc, 'N', $roleType);
            $USER = $currentuser;
        } else {
            array_push($errors, $LNG->ADMIN_NEWS_MISSING_NAME_ERROR);
        }
    } else {
        if (isset($_POST["deletenews"])) {
            if ($nodeid != "") {
                if (!adminDeleteNews($nodeid)) {
                    array_push($errors, $LNG->ADMIN_MANAGE_NEWS_DELETE_ERROR . ' ' . $nodeid);
                }
            } else {
                array_push($errors, $LNG->ADMIN_NEWS_ID_ERROR);
            }
Esempio n. 11
0
 $desc = stripslashes(trim($desc));
 $evidencenode = editNode($nodeid, $summary, $desc, $private, $roleType);
 if ($evidencenode instanceof Error) {
     array_push($errors, $LNG->FORM_EVIDENCE_ALREADY_EXISTS);
 } else {
     // Get all connections this node is used in and update any that are now using the wrong link type or role type.
     if ($node->role->name != $nodetypename) {
         $mainConnections = getConnectionsByNode($nodeid, 0, -1, 'date', 'ASC', 'all', '', 'Solution');
         $count = count($mainConnections->connections);
         $currentuser = $USER;
         for ($i = 0; $i < $count; $i++) {
             $con = $mainConnections->connections[$i];
             // Temporarily be the connection owner.
             $USER = $con->users[0];
             // Update ContextTypeID on Change
             $r = getRoleByName($nodetypename);
             $newroleid = $r->roleid;
             $newfromroleid = $con->fromcontexttypeid;
             $newtoroleid = $con->tocontexttypeid;
             if ($con->from->nodeid == $nodeid) {
                 $newfromroleid = $newroleid;
             } else {
                 if ($con->to->nodeid == $nodeid) {
                     $newtoroleid = $newroleid;
                 }
             }
             // Update Link Type on Change
             if ($nodetypename == 'Pro') {
                 $ltp = getLinkTypeByLabel($CFG->LINK_PRO_SOLUTION);
                 $linkpro = $ltp->linktypeid;
                 $con->edit($con->from->nodeid, $newfromroleid, $linkpro, $con->to->nodeid, $newtoroleid, $con->private, $con->description);
Esempio n. 12
0
    include_once $path;
    die;
}
checkLogin();
include_once $HUB_FLM->getCodeDirPath("ui/headerdialog.php");
$nodeid = required_param("nodeid", PARAM_ALPHANUMEXT);
$handler = optional_param("handler", "", PARAM_TEXT);
//convert brackets
$handler = parseToJSON($handler);
$challenge = optional_param("challenge", "", PARAM_TEXT);
$desc = optional_param("desc", "", PARAM_HTML);
if (isset($_POST["editchallenge"])) {
    if ($challenge == "") {
        array_push($errors, $LNG->FORM_CHALLENGE_ENTER_SUMMARY_ERROR);
    } else {
        $r = getRoleByName("Challenge");
        $roleChallenge = $r->roleid;
        $challengenode = editNode($nodeid, $challenge, $desc, 'N', $roleChallenge);
        echo "<script type='text/javascript'>";
        if (isset($handler) && $handler != "") {
            echo "try { ";
            echo "window.opener." . $handler . "('" . $challengenode->nodeid . "');";
            echo "}";
            echo "catch(err) {";
            echo "}";
        } else {
            echo "try { ";
            echo "if (window.opener && window.opener.loadSelecteditemNew) {";
            echo '	  window.opener.loadSelecteditemNew("' . $nodeid . '"); }';
            echo " else {";
            echo '	  window.opener.location.reload(true); }';
Esempio n. 13
0
    if ($node->description == "") {
        $text = $node->name;
    } else {
        $text = $node->name . "\n\n" . $node->description;
    }
}
$ideanamearray = optional_param("ideanamearray", "", PARAM_TEXT);
$ideadescarray = optional_param("ideadescarray", "", PARAM_HTML);
if (isset($_POST["publish"])) {
    if (sizeof($ideanamearray) <= 1 || ($ideanamearray[0] == "" || $ideanamearray[1] == "")) {
        array_push($errors, $LNG->{$LNG}->FORM_SPLIT_IDEA_ERROR);
    }
    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);
Esempio n. 14
0
$handler = parseToJSON($handler);
$solution = optional_param("solution", "", PARAM_TEXT);
$desc = optional_param("desc", "", PARAM_HTML);
$resourcetypesarray = optional_param("resourcetypesarray", "", PARAM_TEXT);
$resourcetitlearray = optional_param("resourcetitlearray", "", PARAM_TEXT);
$resourceurlarray = optional_param("resourceurlarray", "", PARAM_URL);
$identifierarray = optional_param("identifierarray", "", PARAM_TEXT);
$resourcenodeidsarray = optional_param("resourcenodeidsarray", "", PARAM_TEXT);
$resourcecliparray = optional_param("resourcecliparray", "", PARAM_TEXT);
$resourceclippatharray = optional_param("resourceclippatharray", "", PARAM_TEXT);
if (isset($_POST["editsolution"])) {
    if ($solution == "") {
        array_push($errors, $LNG->FORM_SOLUTION_ENTER_SUMMARY_ERROR);
    } else {
        $private = optional_param("private", "Y", PARAM_ALPHA);
        $r = getRoleByName("solution");
        $rolesolution = $r->roleid;
        $solutionnode = editNode($nodeid, $solution, $desc, $private, $rolesolution);
        if (!$solutionnode instanceof Error) {
            /** ADD RESOURCES/URLS **/
            if (empty($errors)) {
                // remove all the existing urls so they can be re-added below
                $solutionnode->removeAllURLs();
                $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