コード例 #1
0
 /**
  * Load in the tags for the given SQL statement
  *
  * @param string $sql
  * @param array $params the parameters that go into the sql statement
  * @return TagSet (this)
  */
 function load($sql, $params)
 {
     global $DB;
     if (!isset($params)) {
         $params = array();
     }
     $resArray = $DB->select($sql, $params);
     $count = count($resArray);
     for ($i = 0; $i < $count; $i++) {
         $array = $resArray[$i];
         $r = new Tag($array["TagID"]);
         $this->add($r->load());
     }
     return $this;
 }
コード例 #2
0
 /**
  * Loads the data for the connection from the database
  *
  * @param String $style (optional - default 'long') may be 'short' or 'long' of 'cif'
  * @return Connection object (this) or Error
  */
 function load($style = 'long')
 {
     global $DB, $CFG, $HUB_SQL;
     try {
         $this->canview();
     } catch (Exception $e) {
         return access_denied_error();
     }
     $this->style = $style;
     $params = array();
     $params[0] = $this->connid;
     $resArray = $DB->select($HUB_SQL->DATAMODEL_CONNECTION_SELECT, $params);
     $count = count($resArray);
     if ($count == 0) {
         $ERROR = new error();
         $ERROR->createConnectionNotFoundError($this->connid);
         return $ERROR;
     }
     $fromid = 0;
     $toid = 0;
     for ($i = 0; $i < $count; $i++) {
         $array = $resArray[$i];
         $fromid = trim($array['FromID']);
         $toid = trim($array['ToID']);
         $this->fromcontexttypeid = trim($array['FromContextTypeID']);
         $this->tocontexttypeid = trim($array['ToContextTypeID']);
         $this->creationdate = trim($array['CreationDate']);
         $this->modificationdate = trim($array['ModificationDate']);
         $this->userid = trim($array['UserID']);
         $this->users = array();
         $this->users[0] = getUser($this->userid, $style);
         $this->linktypeid = trim($array['LinkTypeID']);
         $this->private = $array['Private'];
         $this->description = $array['Description'];
     }
     //now add in from/to nodes
     $from = new CNode($fromid);
     $this->from = $from->load($style);
     // we need to for the resource node title
     // $this->from->description = ""; // we don't need the long descriptions on connections - even if style for rest is long
     $to = new CNode($toid);
     $this->to = $to->load($style);
     // we need to for the resource node title
     //$this->to->description = ""; // we don't need the long descriptions on connections - even if style for rest is long
     $r = new Role($this->fromcontexttypeid);
     $this->fromrole = $r->load();
     $r = new Role($this->tocontexttypeid);
     $this->torole = $r->load();
     //If both ends of the connection are Comments, it's part of a chat tree.
     //and if the description holds a nodeid, load it as the parent item the chat is against
     if (isset($this->fromrole->name) && $this->fromrole->name == "Comment" || isset($this->torole->name) && $this->torole->name == "Comment") {
         if (isset($this->description) && $this->description != "") {
             // the description could hold a list of id'd id1:id2:id3 etc
             // if it does, the first item is the one to use.
             //echo $this->description;
             $reply = split(":", $this->description);
             $id = $reply[0];
             if ($reply[0] == "") {
                 $id = $reply[1];
             }
             $parentnode = new CNode($id);
             $parentnode = $parentnode->load();
             if (!$parentnode instanceof Error) {
                 $this->parentnode = $parentnode;
             }
         }
     }
     $l = new LinkType($this->linktypeid);
     $this->linktype = $l->load();
     if ($style == 'long') {
         // add in the groups
         $resArray2 = $DB->select($HUB_SQL->DATAMODEL_CONNECTION_SELECT_GROUP, $params);
         $count2 = count($resArray2);
         if ($count2 > 0) {
             $this->groups = array();
             for ($i = 0; $i < $count2; $i++) {
                 $array = $resArray2[$i];
                 $group = new Group(trim($array['GroupID']));
                 array_push($this->groups, $group->load());
             }
         }
         //now add in any tags
         $resArray3 = $DB->select($HUB_SQL->DATAMODEL_CONNECTION_SELECT_TAGS, $params);
         $count3 = count($resArray3);
         if ($count3 > 0) {
             $this->tags = array();
             for ($i = 0; $i < $count3; $i++) {
                 $array = $resArray3[$i];
                 $tag = new Tag(trim($array['TagID']));
                 array_push($this->tags, $tag->load());
             }
         }
     }
     if ($style != 'cif') {
         $this->loadVotes();
     }
     return $this;
 }
コード例 #3
0
ファイル: url.class.php プロジェクト: uniteddiversity/LiteMap
 /**
  * Loads the data for the node from the database
  *
  * @return URL object (this)
  */
 function load($style = 'long')
 {
     global $DB, $ERROR, $HUB_FLM, $HUB_SQL, $HUB_CACHE, $CFG;
     try {
         $this->canview();
     } catch (Exception $e) {
         return access_denied_error();
     }
     $this->style = $style;
     if (isset($HUB_CACHE)) {
         $cachedused = $HUB_CACHE->getObjData($this->urlid . $this->style);
         if ($cachedused !== FALSE) {
             return $cachedused;
         }
     }
     $params = array();
     $params[0] = $this->urlid;
     $resArray = $DB->select($HUB_SQL->DATAMODEL_URL_SELECT, $params);
     if ($resArray !== false) {
         $count = count($resArray);
         if ($count == 0) {
             $ERROR = new error();
             $ERROR->createUrlNotFoundError($this->urlid);
             return $ERROR;
         } else {
             for ($i = 0; $i < $count; $i++) {
                 $array = $resArray[$i];
                 $this->url = stripslashes($array['URL']);
                 $this->description = stripslashes($array['Description']);
                 $this->userid = $array['UserID'];
                 $this->title = stripslashes($array['Title']);
                 $this->creationdate = $array['CreationDate'];
                 $this->modificationdate = $array['ModificationDate'];
                 $this->clip = $array['Clip'];
                 $this->private = $array['Private'];
                 if (isset($array['ClipPath'])) {
                     $this->clippath = $array['ClipPath'];
                 }
                 if (isset($array['ClipHTML'])) {
                     $this->cliphtml = $array['ClipHTML'];
                 }
                 $this->user = new user($this->userid);
                 if (isset($array['CurrentStatus'])) {
                     $this->status = $array['CurrentStatus'];
                 }
                 if (isset($array['AdditionalIdentifier'])) {
                     $this->identifier = $array['AdditionalIdentifier'];
                 }
                 if (isset($array['CreatedFrom'])) {
                     $this->createdfrom = $array['CreatedFrom'];
                 }
             }
         }
     } else {
         return database_error();
     }
     // Virtuoso required this part to be in a separate statement.
     // Was originally part of the select.
     $resArray = $DB->select($HUB_SQL->DATAMODEL_URL_IDEA_COUNT, $params);
     if ($resArray !== false) {
         $count = count($resArray);
         if ($count == 0) {
             $ERROR = new error();
             $ERROR->createUrlNotFoundError($this->urlid);
             return $ERROR;
         } else {
             for ($i = 0; $i < $count; $i++) {
                 $array = $resArray[$i];
                 $this->ideacount = $array['ideacount'];
             }
         }
     } else {
         return database_error();
     }
     if ($style == 'long') {
         //now add in any tags
         $params = array();
         $params[0] = $this->urlid;
         $resArray = $DB->select($HUB_SQL->DATAMODEL_URL_TAGS_SELECT, $params);
         if ($resArray !== false) {
             $count = count($resArray);
             if ($count > 0) {
                 $this->tags = array();
                 for ($i = 0; $i < $count; $i++) {
                     $array = $resArray[$i];
                     $tag = new Tag(trim($array['TagID']));
                     array_push($this->tags, $tag->load());
                 }
             }
         } else {
             return database_error();
         }
         // add in the groups
         $params = array();
         $params[0] = $this->urlid;
         $resArray = $DB->select($HUB_SQL->DATAMODEL_URL_GROUPS_SELECT, $params);
         if ($resArray !== false) {
             $count = count($resArray);
             if ($count > 0) {
                 $this->groups = array();
                 for ($i = 0; $i < $count; $i++) {
                     $array = $resArray[$i];
                     $group = new Group(trim($array['GroupID']));
                     array_push($this->groups, $group->load());
                 }
             }
         } else {
             return database_error();
         }
     }
     if (isset($HUB_CACHE)) {
         $HUB_CACHE->setObjData($this->urlid . $this->style, $this, $CFG->CACHE_DEFAULT_TIMEOUT);
     }
     return $this;
 }
コード例 #4
0
ファイル: apilib.php プロジェクト: uniteddiversity/LiteMap
/**
* Get a tag (by id)
*
* @param string $tagid
* @return Tag or Error
*/
function getTag($tagid)
{
    $t = new Tag($tagid);
    return $t->load();
}
コード例 #5
0
 /**
  * Loads the data for the connection from the database
  *
  * @param String $style (optional - default 'long') may be 'short' or 'long' of 'cif'
  * @return Connection object (this) or Error
  */
 function load($style = 'long')
 {
     global $DB, $CFG, $HUB_SQL;
     try {
         $this->canview();
     } catch (Exception $e) {
         return access_denied_error();
     }
     $this->style = $style;
     $params = array();
     $params[0] = $this->connid;
     $resArray = $DB->select($HUB_SQL->DATAMODEL_CONNECTION_SELECT, $params);
     $count = count($resArray);
     if ($count == 0) {
         $ERROR = new error();
         $ERROR->createConnectionNotFoundError($this->connid);
         return $ERROR;
     }
     $fromid = 0;
     $toid = 0;
     for ($i = 0; $i < $count; $i++) {
         $array = $resArray[$i];
         $fromid = trim($array['FromID']);
         $toid = trim($array['ToID']);
         $this->fromcontexttypeid = trim($array['FromContextTypeID']);
         $this->tocontexttypeid = trim($array['ToContextTypeID']);
         $this->creationdate = trim($array['CreationDate']);
         $this->modificationdate = trim($array['ModificationDate']);
         $this->userid = trim($array['UserID']);
         $this->users = array();
         $this->users[0] = getUser($this->userid, $style);
         $this->linktypeid = trim($array['LinkTypeID']);
         $this->private = $array['Private'];
         $this->description = $array['Description'];
     }
     //now add in from/to nodes. Try from the cache first?
     $from = new CNode($fromid);
     $this->from = $from->load($style);
     $to = new CNode($toid);
     $this->to = $to->load($style);
     $r = new Role($this->fromcontexttypeid);
     $this->fromrole = $r->load();
     $r = new Role($this->tocontexttypeid);
     $this->torole = $r->load();
     $l = new LinkType($this->linktypeid);
     $this->linktype = $l->load();
     if ($style == 'long') {
         // add in the groups
         $resArray2 = $DB->select($HUB_SQL->DATAMODEL_CONNECTION_SELECT_GROUP, $params);
         $count2 = count($resArray2);
         if ($count2 > 0) {
             $this->groups = array();
             for ($i = 0; $i < $count2; $i++) {
                 $array = $resArray2[$i];
                 $group = new Group(trim($array['GroupID']));
                 array_push($this->groups, $group->load());
             }
         }
         //now add in any tags
         $resArray3 = $DB->select($HUB_SQL->DATAMODEL_CONNECTION_SELECT_TAGS, $params);
         $count3 = count($resArray3);
         if ($count3 > 0) {
             $this->tags = array();
             for ($i = 0; $i < $count3; $i++) {
                 $array = $resArray3[$i];
                 $tag = new Tag(trim($array['TagID']));
                 array_push($this->tags, $tag->load());
             }
         }
     }
     if ($style != 'cif') {
         $this->loadVotes();
     }
     return $this;
 }
コード例 #6
0
 /**
  * Loads the data for the user from the database
  * This will not return a "group" (even though groups are
  * stored in the Users table)
  *
  * @param String $style (optional - default 'long') may be 'short' or 'long'
  * @return User object (this) (or Error object)
  */
 function load($style = 'long')
 {
     global $DB, $USER, $CFG, $ERROR, $HUB_FLM, $HUB_SQL, $HUB_CACHE;
     $this->style = $style;
     if (isset($HUB_CACHE)) {
         $cachedused = $HUB_CACHE->getObjData($this->userid . $style);
         if ($cachedused !== FALSE) {
             return $cachedused;
         }
     }
     $params = array();
     $params[0] = $this->userid;
     $resArray = $DB->select($HUB_SQL->DATAMODEL_USER_SELECT, $params);
     if ($resArray !== false) {
         $count = count($resArray);
         if ($count == 0) {
             $ERROR = new error();
             $ERROR->createUserNotFoundError($this->userid);
             return $ERROR;
         } else {
             for ($i = 0; $i < $count; $i++) {
                 $array = $resArray[$i];
                 $this->name = stripslashes($array['Name']);
                 $this->isgroup = $array['IsGroup'];
                 $this->creationdate = $array['CreationDate'];
                 $this->testgroup = $array['TestGroup'];
                 if ($array['Photo']) {
                     //set user photo and thumb the thumb creation is done during registration
                     $originalphotopath = $HUB_FLM->createUploadsDirPath($this->userid . "/" . stripslashes($array['Photo']));
                     if (file_exists($originalphotopath)) {
                         $this->photo = $HUB_FLM->getUploadsWebPath($this->userid . "/" . stripslashes($array['Photo']));
                         $this->thumb = $HUB_FLM->getUploadsWebPath($this->userid . "/" . str_replace('.', '_thumb.', stripslashes($array['Photo'])));
                         if (!file_exists($this->thumb)) {
                             create_image_thumb($array['Photo'], $CFG->IMAGE_THUMB_WIDTH, $this->userid);
                         }
                     } else {
                         //if the file does not exists how to get it from a upper level? change it to
                         //if file doesnot exists directly using default photo
                         if ($this->isgroup == "Y") {
                             $this->photo = $HUB_FLM->getUploadsWebPath($CFG->DEFAULT_GROUP_PHOTO);
                             $this->thumb = $HUB_FLM->getUploadsWebPath(str_replace('.', '_thumb.', stripslashes($CFG->DEFAULT_GROUP_PHOTO)));
                         } else {
                             $this->photo = $HUB_FLM->getUploadsWebPath($CFG->DEFAULT_USER_PHOTO);
                             $this->thumb = $HUB_FLM->getUploadsWebPath(str_replace('.', '_thumb.', stripslashes($CFG->DEFAULT_USER_PHOTO)));
                         }
                     }
                 } else {
                     if ($this->isgroup == "Y") {
                         $this->photo = $HUB_FLM->getUploadsWebPath($CFG->DEFAULT_GROUP_PHOTO);
                         $this->thumb = $HUB_FLM->getUploadsWebPath(str_replace('.', '_thumb.', stripslashes($CFG->DEFAULT_GROUP_PHOTO)));
                     } else {
                         $this->photo = $HUB_FLM->getUploadsWebPath($CFG->DEFAULT_USER_PHOTO);
                         $this->thumb = $HUB_FLM->getUploadsWebPath(str_replace('.', '_thumb.', stripslashes($CFG->DEFAULT_USER_PHOTO)));
                     }
                 }
                 $this->lastlogin = $array['LastLogin'];
                 $this->followsendemail = $array['FollowSendEmail'];
                 $this->followruninterval = $array['FollowRunInterval'];
                 $this->followlastrun = $array['FollowLastRun'];
                 if (isset($array['Newsletter'])) {
                     $this->newsletter = $array['Newsletter'];
                 }
                 if (isset($array['RecentActivitiesEmail'])) {
                     $this->recentactivitiesemail = $array['RecentActivitiesEmail'];
                 }
                 if (isset($array['CurrentStatus'])) {
                     $this->status = $array['CurrentStatus'];
                 }
                 if ($style == 'long') {
                     $this->description = stripslashes($array['Description']);
                     $this->modificationdate = $array['ModificationDate'];
                     $this->privatedata = $array['Private'];
                     $this->isadmin = $array['IsAdministrator'];
                     $this->authtype = $array['AuthType'];
                     $this->password = $array['Password'];
                     $this->website = $array['Website'];
                     $this->email = $array['Email'];
                     if (isset($array['Interest'])) {
                         $this->interest = $array['Interest'];
                     }
                     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']];
                         }
                     } else {
                         $this->countrycode = "";
                     }
                     if (isset($array['LocationLat'])) {
                         $this->locationlat = $array['LocationLat'];
                     }
                     if (isset($array['LocationLng'])) {
                         $this->locationlng = $array['LocationLng'];
                     }
                     // REPAIR MISSING COODINATES
                     if (isset($this->location) && isset($this->countrycode) && $this->location != "" && $this->countrycode != "" && ((!isset($array['LocationLng']) || $array['LocationLng'] == "") && (!isset($array['LocationLat']) || $array['LocationLat'] == ""))) {
                         $coords = geoCode($this->location, $this->countrycode);
                         if ($coords["lat"] != "" && $coords["lng"] != "") {
                             $params = array();
                             $params[0] = $coords["lat"];
                             $params[1] = $coords["lng"];
                             $params[2] = $this->userid;
                             $res = $DB->insert($HUB_SQL->DATAMODEL_USER_LATLONG_UPDATE, $params);
                             $this->locationlat = $coords["lat"];
                             $this->locationlng = $coords["lng"];
                         }
                     }
                 }
             }
         }
     } else {
         return database_error();
     }
     //now add in any tags
     if ($style == 'long') {
         $params = array();
         $params[0] = $this->userid;
         $resArray = $DB->select($HUB_SQL->DATAMODEL_USER_TAGS, $params);
         if ($resArray !== false) {
             $count = count($resArray);
             if ($count > 0) {
                 $this->tags = array();
                 for ($i = 0; $i < $count; $i++) {
                     $array = $resArray[$i];
                     $tag = new Tag(trim($array['TagID']));
                     array_push($this->tags, $tag->load());
                 }
             }
         } else {
             return database_error();
         }
     }
     //load the current user's following for this user if any
     $this->userfollow = "N";
     $currentuser = '';
     if (isset($USER->userid)) {
         $currentuser = $USER->userid;
     }
     $params = array();
     $params[0] = $currentuser;
     $params[1] = $this->userid;
     $resArray = $DB->select($HUB_SQL->DATAMODEL_USER_FOLLOW, $params);
     if ($resArray !== false) {
         $count = count($resArray);
         if ($count > 0) {
             $this->userfollow = "Y";
         }
     } else {
         return database_error();
     }
     if (isset($HUB_CACHE)) {
         $HUB_CACHE->setObjData($this->userid . $style, $this, $CFG->CACHE_DEFAULT_TIMEOUT);
     }
     return $this;
 }
コード例 #7
0
ファイル: Content.php プロジェクト: RichieDupes/PeoplePods
 function getTagIdByValue($value)
 {
     $t = new Tag($this->POD);
     $t->load('value', $value);
     if ($t->success()) {
         return $t->get('id');
     } else {
         $t->set('value', $value);
         $t->save();
         return $t->get('id');
     }
 }
コード例 #8
0
 /**
  * Remove a Tag from this node
  *
  * @param string $urlid
  * @return Node object (this) (or Error object)
  */
 function removeTag($tagid)
 {
     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 Tag
     $tag = new Tag($tagid);
     $tag - $tag->load();
     try {
         $tag->canedit();
     } catch (Exception $e) {
         return access_denied_error();
     }
     $currentuser = '';
     if (isset($USER->userid)) {
         $currentuser = $USER->userid;
     }
     $params = array();
     $params[0] = $this->nodeid;
     $params[1] = $tagid;
     $params[2] = $currentuser;
     $res = $DB->delete($HUB_SQL->DATAMODEL_NODE_TAG_DELETE, $params);
     if (!$res) {
         return database_error();
     }
     return $this->load();
 }
コード例 #9
0
 /**
  * Load associated tags
  */
 function loadTags()
 {
     global $DB, $CFG, $USER, $HUB_SQL;
     $params = array();
     $params[0] = $this->nodeid;
     $resArray = $DB->select($HUB_SQL->DATAMODEL_NODE_TAGS, $params);
     if ($resArray !== false) {
         $count = count($resArray);
         if (count($resArray) > 0) {
             $this->tags = array();
             for ($i = 0; $i < $count; $i++) {
                 $array = $resArray[$i];
                 $tag = new Tag(trim($array['TagID']));
                 array_push($this->tags, $tag->load());
             }
         }
     } else {
         return database_error();
     }
 }
コード例 #10
0
ファイル: Repository.php プロジェクト: satully/dev_socialapp
 /**
  * リポジトリサーバのマッピングファイルを読み込む
  */
 public static function load_map()
 {
     $path = App::path("__repository__.xml");
     if (Tag::load($tag, $path, "map")) {
         foreach ($tag->in("repository") as $rep) {
             if ($rep->is_param("domain")) {
                 $url = $rep->in_param("url", "http://" . $rep->in_param("domain"));
                 if (substr($url, -1) === "/") {
                     $url = substr($url, 0, -1);
                 }
                 self::$server_alias[$rep->in_param("domain")] = $url;
             }
         }
     }
 }
コード例 #11
0
ファイル: Obj.php プロジェクト: RichieDupes/PeoplePods
 function addTag($tag)
 {
     $this->success = false;
     if ($this->get('id')) {
         $t = new Tag($this->POD);
         $t->load('value', $tag);
         if (!$t->success()) {
             $this->POD->tolog("content->addTag: Adding tag {$tag}");
             $t->set('value', $tag);
             $t->save();
         }
         $sql = "DELETE FROM tagRef WHERE itemId=" . $this->get('id') . " AND type='" . $this->TYPE . "' AND tagId=" . $t->get('id') . ';';
         $this->POD->tolog($sql, 2);
         mysql_query($sql, $this->POD->DATABASE);
         $sql = "INSERT INTO tagRef(itemId,tagId,type) VALUES (" . $this->get('id') . "," . $t->get('id') . ",'" . $this->TYPE . "');";
         $this->POD->tolog($sql, 2);
         mysql_query($sql, $this->POD->DATABASE);
         $this->tags()->add($t);
         $this->success = true;
         return $t;
     } else {
         $this->throwError("Object not saved yet!");
         $this->error_code = 500;
         return null;
     }
 }