/** * Store TreasuryGallery * * @param $pParamHash contains all data to store the gallery * @param $pParamHash[title] title of the new gallery * @param $pParamHash[edit] description of the gallery * @param $pParamHash[root_structure_id] if this is set, it will add the gallery to this structure. if it's not set, a new structure / top level gallery is created * @param $pParamHash[parent_id] set the structure_id that will server as the parent in the structure * @return bool TRUE on success, FALSE if store could not occur. If FALSE, $this->mErrors will have reason why * @access public **/ function store(&$pParamHash) { $this->mDb->StartTrans(); if ($this->verify($pParamHash) && LibertyContent::store($pParamHash)) { $table = BIT_DB_PREFIX . "treasury_gallery"; // this really confusing, strange order way of saving items is due to strange behaviour of GenID // probably has to do with not null default nextval('public.liberty_structures_id_seq'::text) if (!empty($pParamHash['update'])) { if (!empty($pParamHash['gallery_store'])) { $result = $this->mDb->associateUpdate($table, $pParamHash['gallery_store'], array("content_id" => $this->mContentId)); } $pParamHash['structure_location_id'] = $this->mStructureId; } else { // update the gallery_store and structure_store content_id with the one from LibertyMime::store() $pParamHash['structure_store']['content_id'] = $pParamHash['content_id']; $pParamHash['gallery_store']['content_id'] = $pParamHash['content_id']; // we need to store the new structure node now global $gStructure; // create new object if needed if (empty($gStructure)) { $gStructure = new LibertyStructure(); } $pParamHash['structure_location_id'] = $gStructure->storeNode($pParamHash['structure_store']); // get the corrent structure_id // structure_id has to be done like this since it's screwed up in the schema $pParamHash['gallery_store']['structure_id'] = $this->mDb->getOne("SELECT MAX( `structure_id` ) FROM `" . BIT_DB_PREFIX . "liberty_structures`"); $result = $this->mDb->associateInsert($table, $pParamHash['gallery_store']); } $this->mDb->CompleteTrans(); // process image upload if (empty($this->mErrors)) { // now deal with the uploaded image if (!empty($pParamHash['thumb']['tmp_name'])) { $checkFunc = liberty_get_function('can_thumbnail'); if ($checkFunc($pParamHash['thumb']['type'])) { $fileHash = $pParamHash['thumb']; $fileHash['dest_branch'] = $this->getGalleryThumbBaseUrl(); $fileHash['source_file'] = $fileHash['tmp_name']; liberty_clear_thumbnails($fileHash); liberty_generate_thumbnails($fileHash); } else { $this->mErrors['thumb'] = tra("The file you uploaded doesn't appear to be a valid image. The reported mime type is") . ": " . $pParamHash['thumb']['type']; } } } $this->load(); } return count($this->mErrors) == 0; }
/** * Store pigeonhole data * @param $pParamHash contains all data to store the pigeonholes * @param $pParamHash[title] title of the new pigeonhole * @param $pParamHash[edit] description of the pigeonhole * @param $pParamHash[members] array of content_ids that are associated with this pigeonhole * @param $pParamHash[root_structure_id] if this is set, it will add the pigeonhole to this structure. if it's not set, a new structure / top level pigeonhole is created * @param $pParamHash[parent_id] set the structure_id that will server as the parent in the structure * @return bool TRUE on success, FALSE if store could not occur. If FALSE, $this->mErrors will have reason why * @access public **/ function store(&$pParamHash) { $this->mDb->StartTrans(); if ($this->verify($pParamHash) && LibertyMime::store($pParamHash)) { $table = BIT_DB_PREFIX . "pigeonholes"; // this really confusing, strange order way of saving items is due to strange behaviour of GenID // probably has to do with not null default nextval('public.liberty_structures_id_seq'::text) if (!empty($pParamHash['update'])) { if (!empty($pParamHash['pigeonhole_store'])) { $result = $this->mDb->associateUpdate($table, $pParamHash['pigeonhole_store'], array("content_id" => $this->mContentId)); } $pParamHash['structure_location_id'] = $this->mStructureId; } else { // update the pigeonhole_store and structure_store content_id with the one from LibertyMime::store() $pParamHash['structure_store']['content_id'] = $pParamHash['content_id']; $pParamHash['pigeonhole_store']['content_id'] = $pParamHash['content_id']; // we need to store the new structure node now global $gStructure; // create new object if needed if (empty($gStructure)) { $gStructure = new LibertyStructure(); } $pParamHash['structure_location_id'] = $gStructure->storeNode($pParamHash['structure_store']); // get the corrent structure_id // structure_id has to be done like this since it's screwed up in the schema $pParamHash['pigeonhole_store']['structure_id'] = $this->mDb->getOne("SELECT MAX( `structure_id` ) FROM `" . BIT_DB_PREFIX . "liberty_structures`"); $result = $this->mDb->associateInsert($table, $pParamHash['pigeonhole_store']); } // store content items if (!empty($pParamHash['pigeonhole_members_store'])) { // remove items first $this->expungePigeonholeMember(array('parent_id' => $this->mContentId)); if (!$this->insertPigeonholeMember($pParamHash['pigeonhole_members_store'])) { $this->mErrors['store'] = 'The content could not be inserted into the respective categories.'; } } $this->mDb->CompleteTrans(); $this->load(); } return count($this->mErrors) == 0; }
//try to add a new structure $gContent = new BitBook(); $pageId = $gContent->findByPageName($_REQUEST['name']); if ($pageId) { $gContent->mPageId = $pageId; $gContent->load(); } else { $params['title'] = $_REQUEST['name']; $params['edit'] = '{toc}'; $gContent->store($params); } if ($gContent->isValid()) { $gStructure = new LibertyStructure(); // alias => '' is a temporary setting until alias stuff has been removed $structureHash = array('content_id' => $gContent->mContentId, 'alias' => ''); $structure_id = $gStructure->storeNode($structureHash); //Cannot create a structure if a structure already exists if (!isset($structure_id)) { $gBitSmarty->assign('msg', $_REQUEST['name'] . " " . tra("page not added (Exists)")); $gBitSystem->display('error.tpl', NULL, array('display_mode' => 'edit')); die; } $chapters = explode("\n", $_REQUEST["chapters"]); foreach ($chapters as $chapter) { $chapterName = trim($chapter); if (!empty($chapterName)) { unset($params); unset($nodeHash); $nodeHash['parent_id'] = $structure_id; $nodeHash['root_structure_id'] = $structure_id; $nodeHash['level'] = 1;