function File($POD, $PARAMETERS = null) { parent::Obj($POD, 'file', array('table_name' => "files", 'table_shortname' => "f", 'fields' => self::$DEFAULT_FIELDS, 'ignore_fields' => self::$IGNORE_FIELDS, 'joins' => self::$DEFAULT_JOINS, 'field_processors' => self::$FIELD_PROCESSORS)); if (!$this->success()) { return null; } if (isset($PARAMETERS['id']) && sizeof($PARAMETERS) == 1) { if ($d = $POD->checkcache('File', 'id', $PARAMETERS['id'])) { $this->DATA = $d; } else { $this->load('id', $PARAMETERS['id']); $this->loadMeta(); } } else { if ($PARAMETERS) { foreach ($PARAMETERS as $key => $value) { if ($key != 'POD') { $this->set($key, $value); } } $this->loadMeta(); } } if ($this->get('id')) { // if this is an existing file, set up some path stuff if (preg_match("/^image/", $this->get('mime_type'))) { $this->isImage = true; } $this->generatePermalink(); } $POD->cachestore($this); $this->success = true; return $this; }
function Thread($POD, $threadInfo = null) { parent::Obj($POD, 'thread'); if (!$this->success()) { return $this; } if (isset($threadInfo)) { foreach ($threadInfo as $key => $value) { $this->set($key, $value); } $this->RECIPIENT = $this->POD->getPerson(array('id' => $this->get('targetUserId'))); // get unread count. $sql = "SELECT count(1) as count FROM messages WHERE userId=" . $this->get('ownerId') . " AND targetUserId=" . $this->get('targetUserId') . " and status='new';"; $this->POD->tolog($sql, 2); $res = mysql_query($sql, $this->POD->DATABASE); if ($ur = mysql_fetch_assoc($res)) { $this->UNREAD_COUNT = $ur['count']; } mysql_free_result($res); $this->set('permalink', $this->POD->siteRoot(false) . $this->POD->libOptions('messagePath') . "/" . $this->RECIPIENT->get('stub')); $this->MESSAGES = new Stack($this->POD, 'messages', array('userId' => $this->get('ownerId'), 'targetUserId' => $this->get('targetUserId')), null, 1000); } $this->success = true; return $this; }
function Comment($POD, $PARAMETERS = null) { parent::Obj($POD, 'comment', array('table_name' => "comments", 'table_shortname' => "c", 'fields' => self::$DEFAULT_FIELDS, 'ignore_fields' => self::$IGNORE_FIELDS, 'joins' => self::$DEFAULT_JOINS, 'field_processors' => self::$FIELD_PROCESSORS)); if (!$this->success()) { return null; } if (isset($PARAMETERS['id']) && sizeof($PARAMETERS) == 1) { if ($d = $POD->checkcache('Comment', 'id', $PARAMETERS['id'])) { $this->DATA = $d; } else { $this->load('id', $PARAMETERS['id']); $this->generatePermalink(); $this->loadMeta(); } $POD->cachestore($this); return $this; } else { if ($PARAMETERS) { // create based on parameters foreach ($PARAMETERS as $key => $value) { if ($key != 'POD') { $this->set($key, $value); } } } } $this->generatePermalink(); $this->loadMeta(); $POD->cachestore($this); $this->success = true; return $this; }
function Tag($POD, $PARAMETERS = null) { parent::Obj($POD, 'tag'); if (!$this->success()) { return $this; } if ($PARAMETERS) { // create based on parameters foreach ($PARAMETERS as $key => $value) { $this->set($key, $value); } } }
function Group($POD, $PARAMETERS = null) { $this->success = null; parent::Obj($POD, 'group', array('table_name' => "groups", 'table_shortname' => "g", 'fields' => self::$DEFAULT_FIELDS, 'ignore_fields' => self::$IGNORE_FIELDS, 'joins' => self::$DEFAULT_JOINS, 'field_processors' => self::$FIELD_PROCESSORS)); if (isset($PARAMETERS['id']) && sizeof($PARAMETERS) == 1) { $this->loadById($PARAMETERS['id']); if (!$this->success()) { return; } } else { if (isset($PARAMETERS['stub']) && sizeof($PARAMETERS) == 1) { $this->loadByStub($PARAMETERS['stub']); if (!$this->success()) { return; } } else { $fill = true; if (isset($PARAMETERS['id'])) { $d = $this->POD->checkcache('Group', 'id', $PARAMETERS['id']); if ($d) { $fill = false; $this->DATA = $d; } } if ($PARAMETERS) { // fill in the deets with the parameters passed in_array foreach ($PARAMETERS as $key => $value) { $this->set($key, $value); } } if ($fill && $this->get('id')) { $this->loadMeta(); } } } $this->generatePermalink(); $this->POD->cachestore($this); $this->success = true; }
function Msg($POD, $type, $object_definition) { parent::Obj($POD, $type, $object_definition); $this->success = true; return $this; }
function Person($POD, $PARAMETERS = null) { parent::Obj($POD, 'user', array('table_name' => "users", 'table_shortname' => "u", 'fields' => self::$DEFAULT_FIELDS, 'ignore_fields' => self::$IGNORE_FIELDS, 'joins' => self::$DEFAULT_JOINS, 'field_processors' => self::$FIELD_PROCESSORS)); if (!$this->success()) { return $this; } $this->success = false; if (isset($PARAMETERS['authSecret']) && sizeof($PARAMETERS) == 1) { $this->POD->tolog("user->new(): Attempting to verify user..."); $this->getUserByAuthSecret($PARAMETERS['authSecret']); } else { if (isset($PARAMETERS['passwordResetCode']) && sizeof($PARAMETERS) == 1) { $this->POD->tolog("user->new(): Load by reset code..."); $this->getUserByPasswordResetCode($PARAMETERS['passwordResetCode']); } else { if (isset($PARAMETERS['id']) && sizeof($PARAMETERS) == 1) { $this->POD->tolog("user->new(): Load user by id " . $PARAMETERS['id']); $this->getUserById($PARAMETERS['id']); } else { if (isset($PARAMETERS['stub']) && sizeof($PARAMETERS) == 1) { $this->POD->tolog("user->new(): Load user by stub " . $PARAMETERS['stub']); $this->getUserByStub($PARAMETERS['stub']); } else { if (isset($PARAMETERS['email']) && sizeof($PARAMETERS) == 1) { $this->POD->tolog("user->new(): Load user by email"); $this->getUserByEmail($PARAMETERS['email']); } else { if (isset($PARAMETERS['nick']) && sizeof($PARAMETERS) == 1) { $this->POD->tolog("user->new(): Load user by nick"); $this->getUserByNick($PARAMETERS['nick']); } else { if (isset($PARAMETERS['nick']) && isset($PARAMETERS['email']) && ($PARAMETERS['password'] || $PARAMETERS['id'])) { $this->POD->tolog("user->new(): Creating user from parameters"); $fill = true; if (isset($PARAMETERS['id'])) { $d = $this->POD->checkcache('Person', 'id', $PARAMETERS['id']); if ($d) { $fill = false; $this->DATA = $d; $this->success = true; } } if ($fill) { foreach ($PARAMETERS as $key => $value) { if ($key != 'POD') { $this->set($key, $value); } } $this->success = true; $this->stuffUser(); $this->loadMeta(); $this->POD->cachestore($this); } } else { $this->success = true; $this->POD->tolog("user->new(): Empty User"); } } } } } } } // if we failed to create the user by this point, we're screwed. if (!$this->success()) { return; } return $this; }
function Content($POD, $PARAMETERS = null) { parent::Obj($POD, 'content', array('table_name' => "content", 'table_shortname' => "d", 'fields' => self::$DEFAULT_FIELDS, 'ignore_fields' => self::$IGNORE_FIELDS, 'joins' => self::$DEFAULT_JOINS, 'field_processors' => self::$FIELD_PROCESSORS)); if (!$this->success()) { return $this; } // Load a document from the database or from defaults, based on the parameters if (isset($PARAMETERS['id']) && sizeof($PARAMETERS) == 1) { // load by ID $this->getContentById($PARAMETERS['id']); if (!$this->success()) { return; } } else { if (isset($PARAMETERS['stub']) && sizeof($PARAMETERS) == 1) { // load by unique stub $this->getContentByStub($PARAMETERS['stub']); if (!$this->success()) { return; } } else { if ($PARAMETERS) { // create based on parameters $this->POD->tolog("content->new Create doc from parameters"); $fill = true; if (isset($PARAMETERS['id'])) { $d = $this->POD->checkcache('Content', 'id', $PARAMETERS['id']); if ($d) { $fill = false; $this->DATA = $d; } } if ($fill) { foreach ($PARAMETERS as $key => $value) { $this->set($key, $value); } if (!$this->get('id')) { if (!$this->POD->isAuthenticated()) { $this->success = false; $this->throwError("No current user! Can't create content!"); return null; } $this->set('userId', $this->POD->currentUser()->get('id')); } $this->stuffDoc(); $this->POD->cachestore($this); } } else { // this is a brand new content object // we still need to call generatePermalink because some other stuff gets set up $this->generatePermalink(); } } } if (!$this->isViewable()) { // do not use throwError because we don't necessarily need to complain about this to the logs $this->error = "Access denied to " . ($this->POD->isAuthenticated() ? 'user #' . $this->POD->currentUser()->id : 'anon user') . " to content #" . $this->id . " because of insufficient permissions."; $this->success = false; $this->DATA = array(); return $this; } $this->success = true; return $this; }