- $r = q("INSERT INTO `term` (`uid`, `oid`, `otype`, `type`, `term`, `url`) VALUES (%d, %d, %d, %d, '%s', '%s')",
- intval($message["uid"]), intval($itemid), intval(TERM_OBJ_POST), intval($type), dbesc($term), dbesc($link));
+ if ($message["uid"] == 0) {
+ $global = true;
+
+ q("UPDATE `term` SET `global` = 1 WHERE `otype` = %d AND `guid` = '%s'",
+ intval(TERM_OBJ_POST), dbesc($message["guid"]));
+ } else {
+ $isglobal = q("SELECT `global` FROM `term` WHERE `uid` = 0 AND `otype` = %d AND `guid` = '%s'",
+ intval(TERM_OBJ_POST), dbesc($message["guid"]));
+
+ $global = (count($isglobal) > 0);
+ }
+
+ $r = q("INSERT INTO `term` (`uid`, `oid`, `otype`, `type`, `term`, `url`, `guid`, `created`, `received`, `global`)
+ VALUES (%d, %d, %d, %d, '%s', '%s', '%s', '%s', '%s', %d)",
+ intval($message["uid"]), intval($itemid), intval(TERM_OBJ_POST), intval($type), dbesc($term),
+ dbesc($link), dbesc($message["guid"]), dbesc($message["created"]), dbesc($message["received"]), intval($global));