/** * Save the record specified by GET parameters. * * @param object $user User who is saving the record. * * @return bool True on success, false on failure. * @access public */ public static function saveRecord($user) { // Fail if the user is not logged in: if (!$user) { return false; } $list = new User_list(); if (isset($_GET['list']) && $_GET['list'] != '') { $list->id = $_GET['list']; } else { if (isset($_POST['list']) && $_POST['list'] != '') { $list->id = $_POST['list']; } else { $list->user_id = $user->id; $list->title = "My Favorites"; if (!$list->find(true)) { $list->insert(); } } } // Remember that the list was used so it can be the default in future // dialog boxes: $list->rememberLastUsed(); // Setup Search Engine Connection $db = ConnectionManager::connectToIndex('MetaLib'); // Get Record Information $record = $db->getRecord($_GET['id']); if (!$record) { return false; } $resource = new Resource(); $resource->record_id = $_GET['id']; $resource->source = 'MetaLib'; if (!$resource->find(true)) { $resource->data = serialize($record); $resource->insert(); } else { $resource->data = serialize($record); $resource->update(); } preg_match_all('/"[^"]*"|[^ ]+/', isset($_GET['mytags']) ? $_GET['mytags'] : '', $tagArray); return $user->addResource($resource, $list, $tagArray[0], isset($_GET['notes']) ? $_GET['notes'] : ''); }
/** * Save a user's changes. * * @param object $user Logged in user object * * @return void * @access private */ private function _saveChanges($user) { $resource = new Resource(); unset($resource->source); $resource->record_id = $_GET['id']; $resource->find(true); // Loop through the list of lists on the edit screen: foreach ($_POST['lists'] as $listId) { // Create a list object for the current list: $list = new User_list(); if ($listId != '') { $list->id = $listId; } else { PEAR::raiseError(new PEAR_Error('List ID Missing')); } // Extract tags from the user input: preg_match_all('/"[^"]*"|[^ ]+/', $_POST['tags' . $listId], $tagArray); // Save extracted tags and notes: $user->addResource($resource, $list, $tagArray[0], $_POST['notes' . $listId]); } }
/** * Sets contents of passed object to values from current object. * * If desired, this method can also make copies of all associated (fkey referrers) * objects. * * @param object $copyObj An object of \App\Propel\ResourceType (or compatible) type. * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. * @throws PropelException */ public function copyInto($copyObj, $deepCopy = false, $makeNew = true) { $copyObj->setResourceTypeCode($this->getResourceTypeCode()); if ($deepCopy) { // important: temporarily setNew(false) because this affects the behavior of // the getter/setter methods for fkey referrer objects. $copyObj->setNew(false); foreach ($this->getResources() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addResource($relObj->copy($deepCopy)); } } } // if ($deepCopy) if ($makeNew) { $copyObj->setNew(true); $copyObj->setResourceTypeId(NULL); // this is a auto-increment column, so set to default value } }