コード例 #1
0
ファイル: url.class.php プロジェクト: uniteddiversity/LiteMap
 /**
  * Remove a URL from this node
  *
  * @param string $nodeid
  * @return URL object (this) (or Error object)
  */
 function removeIdea($nodeid)
 {
     global $DB, $CFG, $USER, $HUB_SQL, $HUB_CACHE;
     //check user can edit the URL
     try {
         $this->canedit();
     } catch (Exception $e) {
         return access_denied_error();
     }
     //check user can edit the Node
     $node = new CNode($nodeid);
     $node = $node->load();
     try {
         $node->canedit();
     } catch (Exception $e) {
         return access_denied_error();
     }
     if (isset($HUB_CACHE)) {
         $HUB_CACHE->deleteData($this->urlid . $this->style);
     }
     $dt = time();
     $currentuser = '';
     if (isset($USER->userid)) {
         $currentuser = $USER->userid;
     }
     $params = array();
     $params[0] = $nodeid;
     $params[1] = $this->urlid;
     $params[2] = $currentuser;
     $res = $DB->delete($HUB_SQL->DATAMODEL_URL_IDEA_DELETE, $params);
     if (res) {
         if (!auditURL($USER->userid, $this->urlid, $nodeid, "", "", "", "", "", "", "", $CFG->actionDelete, format_object('xml', $node))) {
             return database_error();
         }
     } else {
         return database_error();
     }
     return $this->load();
 }
コード例 #2
0
 /**
  * Remove a URL from this node
  *
  * @param string $urlid
  * @return Node object (this) (or Error object)
  */
 function removeURL($urlid)
 {
     global $DB, $CFG, $USER, $HUB_SQL;
     //check user can edit the Node
     try {
         $this->canedit();
     } catch (Exception $e) {
         return access_denied_error();
     }
     //check user can edit the URL
     $url = new URL($urlid);
     try {
         $url->canedit();
     } catch (Exception $e) {
         return access_denied_error();
     }
     $currentuser = '';
     if (isset($USER->userid)) {
         $currentuser = $USER->userid;
     }
     $params = array();
     $params[0] = $this->nodeid;
     $params[1] = $urlid;
     $params[2] = $currentuser;
     $res = $DB->insert($HUB_SQL->DATAMODEL_NODE_URL_DELETE, $params);
     if ($res) {
         if (!auditURL($USER->userid, $urlid, $this->nodeid, "", "", "", "", "", "", "", $CFG->actionDelete, format_object('xml', $this))) {
             return database_error();
         }
     } else {
         return database_error();
     }
     // if the url has no other connections to nodes delete the url object.
     $url = new URL($urlid);
     $url = $url->load('short');
     if ($url->ideacount == 0) {
         $url->delete();
     }
     return $this->load();
 }