function render() { // fetch the current settings $blogSettings = $this->_blogInfo->getSettings(); $pluginEnabled = $blogSettings->getValue("plugin_moblog_enabled"); $categoryId = $blogSettings->getValue("plugin_moblog_article_category_id"); $albumId = $blogSettings->getValue("plugin_moblog_gallery_resource_album_id"); $resourcePreviewType = $blogSettings->getValue("plugin_moblog_resource_preview_type"); // fetch all the current article categories $categories = new ArticleCategories(); $blogCategories = $categories->getBlogCategories($this->_blogInfo->getId()); // fetch all the current gallery albums $albums = new GalleryAlbums(); $blogAlbums = $albums->getUserAlbums($this->_blogInfo->getId()); // finally pass all these things to the templates $this->setValue("pluginEnabled", $pluginEnabled); $this->setValue("categoryId", $categoryId); $this->setValue("albumId", $albumId); $this->setValue("albums", $blogAlbums); $this->setValue("categories", $blogCategories); $this->setValue("resourcePreviewType", $resourcePreviewType); parent::render(); }
$categoryId = $blogSettings->getValue("plugin_moblog_article_category_id"); $category = $articleCategories->getCategory($categoryId, $blogInfo->getId()); // if there was no such category, we should send an error and to make it more useful, send // as part of the error message the list of available categories if (!$category) { $response = new MoblogResponse($request->getReplyTo(), "pLog Moblog: Error", "The category does not exist."); MoblogLogger::log("User '" . $request->getUser() . "' tried to use category '" . $categoryId . "' which does not exist."); $response->send(); return false; } // // finally, add the resources to the database // // first, create a new album to hold these attachments $albums = new GalleryAlbums(); $userAlbums = $albums->getUserAlbums($blogInfo->getId()); $t = new Timestamp(); $albumId = $blogSettings->getValue("plugin_moblog_gallery_resource_album_id"); $album = $albums->getAlbum($albumId, $blogInfo->getId()); // check if the album was loaded if (!$album) { $response = new MoblogResponse($request->getReplyTo(), "pLog Moblog: Error", "The album does not exist."); MoblogLogger::log("User '" . $request->getUser() . "' tried to use album '" . $albumId . "' which does not exist."); $response->send(); return false; } MoblogLogger::log("Adding resources to album " . $album->getName()); $attachments = $request->getAttachments(); $res = new GalleryResources(); $resourceIds = array(); foreach ($attachments as $attachment) {
function metaWeblogNewMediaObject($args) { global $users, $articles, $blogsG; /* "userid" => "dateCreated" => "content" => "postid" => */ $blogid = $args[0]; $username = $args[1]; $password = $args[2]; $file = $args[3]; $erg = $users->getUserInfo($username, $password); if ($erg != false) { // Save this file to the tmp directory // Create a temp file // Get the temp directory /**if (!$tmp_dir = get_cfg_var('upload_tmp_dir')) { $tmp_dir = dirname(tempnam('/tmp', '')); }*/ $config =& Config::getConfig(); $tmp_dir = $config->getTempFolder(); // Remove all characters that would need to be urlencoded // This may not be necessary, but this was causing problems when given file // names with spaces in it. $tempFile = ereg_replace("[^a-zA-Z0-9._-]", "_", basename($file['name'])); // Make the tmp name $tempFile = $tmp_dir . '/' . $tempFile; // Open the file if (!($handle = fopen($tempFile, "wb"))) { return new IXR_Error(-1, 'Could not open file'); } // It appears that the data has already been decoded, no need to call base64_decode $decodedBits = $file['bits']; // Write the data to the file if (fwrite($handle, $decodedBits) === false) { return new IXR_Error(-1, 'Could not write to file'); } // Close the file fclose($handle); // let the gallery library do its work... $resources = new GalleryResources(); // Get the first album for this blog $albums = new GalleryAlbums(); // get the list of albums for this blog $albumArray = $albums->getUserAlbums($blogid); if ($albumArray == NULL || count($albumArray) == 0) { return new IXR_Error(-1, 'Could not find album'); } // Add the resource to the first album $resId = $resources->addResourceFromDisk($blogid, $albumArray[0]->getId(), basename($file['name']), $tempFile); // Get the resource from the id $resource = $resources->getResource($resId, $blogid, $albumArray[0]->getId()); // Now we need to get the url for the resource $blogInfo = $blogsG->getBlogInfo($blogid); $url = $blogInfo->getBlogRequestGenerator(); $ret = $url->resourceDownloadLink($resource); return $ret; } else { return new IXR_Error(-1, 'You did not provide the correct password'); } }