/**
  * takes the search string as originally input by a user and makes it "better", in the sense
  * that for example converts it to "term1 AND term2" instead of "term1 OR term2" which is the
  * default behaviour. In order to do so, the "+" operator must be added before each one of the
  * search terms as long as it is not already there.
  *
  * @param searchTerms The original search string
  * @return Returns an 'improved' version of the search terms
  */
 function _adaptSearchString($searchTerms)
 {
     // load this module only if needed...
     include_once PLOG_CLASS_PATH . "class/data/textfilter.class.php";
     $tf = new Textfilter();
     $resultTerms = $tf->filterCharacters($searchTerms, array('"', ';', '.'));
     $resultTerms = Db::qstr($resultTerms);
     $resultTerms = trim($resultTerms);
     return $resultTerms;
 }
 /**
  * Adds a comment to an article
  *
  * @param comment the UserComment object that we're going to add.
  * @return Returns true if successful or false if error. Also in case of success, it will modify the UserComment
  * object passed by reference and include its new id.
  */
 function addComment(&$comment)
 {
     $filter = new Textfilter();
     $t = new Timestamp();
     $timeStamp = $t->getTimestamp();
     $query = "INSERT INTO " . $this->getPrefix() . "articles_comments (article_id,topic,text,user_name,user_email,\n\t\t\t\t\t                      user_url,parent_id,client_ip,status,date,normalized_text,normalized_topic) \n\t\t\t\t\t   VALUES (" . $comment->getArticleId() . ",'" . Db::qstr($comment->getTopic()) . "','" . Db::qstr($comment->getText()) . "','" . Db::qstr($comment->getUserName()) . "','" . Db::qstr($comment->getUserEmail()) . "','" . Db::qstr($comment->getUserUrl()) . "'," . $comment->getParentId() . ", '" . $comment->getClientIp() . "', " . $comment->getStatus() . "," . $timeStamp . ",'" . Db::qstr($filter->normalizeText($comment->getText())) . "', '" . Db::qstr($filter->normalizeText($comment->getTopic())) . "');";
     $result = $this->Execute($query);
     if (!$result) {
         return false;
     }
     // retrieve the last id and save it in the object
     $comment->setId($this->_db->Insert_ID());
     return true;
 }
 /**
  * Carries out the specified action
  */
 function perform()
 {
     // fetch our data
     $this->_albumName = Textfilter::filterAllHTML($this->_request->getValue("albumName"));
     $this->_albumDescription = Textfilter::filterAllHTML($this->_request->getValue("albumDescription"));
     $this->_parentId = $this->_request->getValue("parentId");
     $showAlbum = $this->_request->getValue("showAlbum") ? 1 : 0;
     // create the album
     $albums = new GalleryAlbums();
     $t = new Timestamp();
     $album = new GalleryAlbum($this->_blogInfo->getId(), $this->_albumName, $this->_albumDescription, GALLERY_RESOURCE_PREVIEW_AVAILABLE, $this->_parentId, $t->getTimestamp(), array(), $showAlbum);
     $this->notifyEvent(EVENT_PRE_ALBUM_ADD, array("album" => &$album));
     // and add it to the database
     $result = $albums->addAlbum($album);
     $this->_view = new AdminResourcesListView($this->_blogInfo, array("albumId" => $this->_parentId));
     if ($result) {
         $this->_view->setSuccessMessage($this->_locale->pr("album_added_ok", $album->getName()));
         $this->notifyEvent(EVENT_POST_ALBUM_ADD, array("album" => &$album));
         // clear the cache if everything went fine
         CacheControl::resetBlogCache($this->_blogInfo->getId(), false);
     } else {
         $this->_view->setErrorMessage($this->_locale->tr("error_adding_album"));
     }
     $this->setCommonData();
     // better to return true if everything fine
     return true;
 }
 /**
  * Carries out the specified action
  */
 function perform()
 {
     // fetch the category we're trying to update
     $this->_categoryId = $this->_request->getValue("linkCategoryId");
     $this->_categoryName = Textfilter::filterAllHTML($this->_request->getValue("linkCategoryName"));
     $categories = new MyLinksCategories();
     $category = $categories->getMyLinksCategory($this->_categoryId, $this->_blogInfo->getId());
     if (!$category) {
         $this->_view = new AdminLinkCategoriesListView($this->_blogInfo);
         $this->_view->setErrorMessage($this->_locale->tr("error_fetching_link_category"));
         $this->setCommonData();
         return false;
     }
     // update the fields
     $category->setName($this->_categoryName);
     $this->notifyEvent(EVENT_PRE_LINK_CATEGORY_UPDATE, array("linkcategory" => &$category));
     if (!$categories->updateMyLinksCategory($category)) {
         $this->_view = new AdminLinkCategoriesListView($this->_blogInfo);
         $this->_view->setErrorMessage($this->_locale->tr("error_updating_link_category"));
         $this->setCommonData();
         return false;
     }
     $this->notifyEvent(EVENT_POST_LINK_CATEGORY_UPDATE, array("linkcategory" => &$category));
     // clear the cache
     CacheControl::resetBlogCache($this->_blogInfo->getId(), false);
     $this->_view = new AdminLinkCategoriesListView($this->_blogInfo);
     $this->_view->setSuccessMessage($this->_locale->pr("link_category_updated_ok", $category->getName()));
     $this->setCommonData();
     // better to return true if everything fine
     return true;
 }
 /**
  * Carries out the specified action
  */
 function perform()
 {
     // load the resource
     $this->_resourceDescription = Textfilter::filterAllHTML($this->_request->getValue("resourceDescription"));
     $this->_albumId = $this->_request->getValue("albumId");
     $this->_resourceId = $this->_request->getValue("resourceId");
     $resources = new GalleryResources();
     $resource = $resources->getResource($this->_resourceId, $this->_blogInfo->getId());
     // update the fields we'd like to update
     $resource->setAlbumId($this->_albumId);
     $resource->setDescription($this->_resourceDescription);
     // send the event
     $this->notifyEvent(EVENT_PRE_RESOURCE_UPDATE, array("resource" => &$resource));
     // and update it in the db
     $result = $resources->updateResource($resource);
     if (!$result) {
         $this->_view = new AdminResourcesListView($this->_blogInfo);
         $this->_view->setErrorMessage($this->_locale->tr("error_updating_resource"));
     } else {
         // check which submit button was pressed
         if ($this->_request->getValue("regenerate") != "") {
             return Controller::setForwardAction("regeneratePreview");
         }
         $this->_view = new AdminResourcesListView($this->_blogInfo);
         $this->_view->setSuccessMessage($this->_locale->pr("resource_updated_ok", $resource->getFileName()));
         $this->notifyEvent(EVENT_POST_RESOURCE_UPDATE, array("resource" => &$resource));
         // clear the cache
         CacheControl::resetBlogCache($this->_blogInfo->getId(), false);
     }
     $this->setCommonData();
     // better to return true if everything fine
     return true;
 }
 /**
  * Carries out the specified action
  */
 function perform()
 {
     // fetch the data
     $this->_linkName = Textfilter::filterAllHTML($this->_request->getValue("linkName"));
     $this->_linkUrl = Textfilter::filterAllHTML($this->_request->getValue("linkUrl"));
     $this->_linkCategoryId = $this->_request->getValue("linkCategoryId");
     $this->_linkDescription = Textfilter::filterAllHTML($this->_request->getValue("linkDescription"));
     $this->_linkRss = Textfilter::filterAllHTML($this->_request->getValue("linkRssFeed"));
     $this->_properties = array();
     // adds the new link to the database
     $myLinks = new MyLinks();
     $myLink = new MyLink($this->_linkName, $this->_linkDescription, $this->_linkUrl, $this->_blogInfo->getId(), $this->_linkCategoryId, 0, $this->_linkRss, $this->_properties);
     $this->notifyEvent(EVENT_PRE_LINK_ADD, array("link" => &$link));
     if (!$myLinks->addMyLink($myLink, $this->_blogInfo->getId())) {
         $this->_view = new AdminNewLinkView($this->_blogInfo);
         $this->_view->setErrorMessage($this->_locale->tr("error_adding_link"));
         $this->setCommonData();
         return false;
     }
     $this->notifyEvent(EVENT_POST_LINK_ADD, array("link" => &$link));
     $this->_view = new AdminLinksListView($this->_blogInfo);
     $this->_view->setSuccessMessage($this->_locale->pr("link_added_ok", $myLink->getName()));
     $this->setCommonData();
     // clear the cache
     CacheControl::resetBlogCache($this->_blogInfo->getId(), false);
     // better to return true if everything fine
     return true;
 }
 /**
  * Carries out the specified action
  */
 function perform()
 {
     //print_r($_REQUEST);
     // fetch all the information that we need for the dummy Article object
     $this->_fetchCommonData();
     // and now, create a harmless Article object with it
     $postText = Textfilter::xhtmlize($this->_postText) . POST_EXTENDED_TEXT_MODIFIER . Textfilter::xhtmlize($this->_postExtendedText);
     // create the main object
     $article = new Article($this->_postTopic, $postText, $this->_postCategories, $this->_userInfo->getId(), $this->_blogInfo->getId(), $status, 0, array(), $this->_postSlug);
     // and a few more properties that we need to know about
     $this->_fetchPostDateInformation();
     $article->setDateObject($this->_postTimestamp);
     // we will not allow comments because it wouldn't work!
     $article->setCommentsEnabled(false);
     $article->setFields($this->_getArticleCustomFields());
     // the next two fields are also required in order to show an article
     $article->setUserInfo($this->_userInfo);
     $article->setBlogInfo($this->_blogInfo);
     $article->setCategories($this->_loadArticleCategories($this->_postCategories));
     // and now trick the ViewArticleView class into thinking that we're showing
     // a real article just fetched from the database (even though it makes no difference
     // to the class itself whence the article came from :)
     // the 'random' parameter in the array is to provide the view with a random view id
     // every time that we run the preview, otherwise when caching is enabled we would always be
     // getting the same page!!
     $this->_view = new ViewArticleView($this->_blogInfo, array('random' => md5(time())));
     $this->_view->setArticle($article);
     //$this->setCommonData();
     return true;
 }
 /**
  * Carries out the specified action
  */
 function perform()
 {
     // fetch the data
     $this->_fieldName = Textfilter::filterAllHTML($this->_request->getValue("fieldName"));
     $this->_fieldDescription = Textfilter::filterAllHTML($this->_request->getValue("fieldDescription"));
     $this->_fieldType = $this->_request->getValue("fieldType");
     $this->_fieldSearchable = (int) ($this->_request->getValue("fieldSearchable") != "");
     $this->_fieldHidden = (int) ($this->_request->getValue("fieldHidden") != "");
     $fields = new CustomFields();
     // build the new custom field
     $customField = new CustomField($this->_fieldName, $this->_fieldDescription, $this->_fieldType, $this->_blogInfo->getId(), $this->_fieldHidden, $this->_fieldSearchable);
     // throw the pre-event
     $this->notifyEvent(EVENT_PRE_CUSTOM_FIELD_ADD, array("field" => &$customField));
     $result = $fields->addCustomField($customField);
     if (!$result) {
         $this->_view = new AdminCustomFieldsListView($this->_blogInfo);
         $this->_view->setErrorMessage($this->_locale->tr("error_adding_custom_field"));
     } else {
         $this->_view = new AdminCustomFieldsListView($this->_blogInfo);
         $this->_view->setSuccessMessage($this->_locale->pr("custom_field_added_ok", $customField->getName()));
         // throw the post-event if all went fine
         $this->notifyEvent(EVENT_POST_CUSTOM_FIELD_ADD, array("field" => &$customField));
     }
     $this->setCommonData();
     return true;
 }
 /**
  * Carries out the specified action
  */
 function perform()
 {
     // update the user information
     $this->_userInfo->setEmail(Textfilter::filterAllHTML($this->_request->getValue("userEmail")));
     if ($this->_userPassword != "") {
         $this->_userInfo->setPassword($this->_userPassword);
     }
     $this->_userInfo->setAboutMyself(Textfilter::filterAllHTML($this->_request->getValue("userAbout")));
     $this->_userInfo->setFullName(Textfilter::filterAllHTML($this->_request->getValue("userFullName")));
     $this->_userInfo->setPictureId($this->_request->getValue("userPictureId"));
     $this->_userInfo->setProperties($this->_request->getValue("properties"));
     $this->notifyEvent(EVENT_PRE_USER_UPDATE, array("user" => &$this->_userInfo));
     $this->_session->setValue("userInfo", $this->_userInfo);
     $this->saveSession();
     // update the user information
     $this->_view = new AdminUserProfileView($this->_blogInfo, $this->_userInfo);
     $users = new Users();
     if (!$users->updateUser($this->_userInfo)) {
         $this->_view->setErrorMessage($this->_locale->tr("error_updating_user_settings"));
     } else {
         $this->_view->setSuccessMessage($this->_locale->pr("user_settings_updated_ok", $this->_userInfo->getUsername()));
         // if everything fine, also say so...
         $this->notifyEvent(EVENT_POST_USER_UPDATE, array("user" => &$this->_userInfo));
     }
     $this->setCommonData();
     return true;
 }
 function _fetchFields()
 {
     $this->_articleId = $this->_request->getValue("articleId");
     $this->_blogId = $this->_request->getValue("blogId");
     $this->_opId = $this->_request->getValue("op");
     $this->_parentId = $this->_request->getValue("parentId");
     if ($this->_parentId == null || $this->_parentId == "") {
         $this->_parentId = 0;
     }
     $this->_userEmail = Textfilter::filterAllHTML($this->_request->getValue("userEmail"));
     $this->_userUrl = Textfilter::filterAllHTML($this->_request->getValue("userUrl"));
     if (strlen($this->_userUrl) != 0 && substr($this->_userUrl, 0, 7) != "http://") {
         $this->_userUrl = "http://" . $this->_userUrl;
     }
     $this->_userName = Textfilter::filterAllHTML($this->_request->getValue("userName"));
     $this->_commentText = trim($this->_request->getValue("commentText"));
     $this->_commentTopic = trim(Textfilter::filterAllHTML($this->_request->getValue("commentTopic")));
     // remove all weird stuff from the comment text
     $tf = new TextFilter();
     $this->_commentText = $tf->xhtmlize($tf->filterHTML($this->_commentText));
     // now, if the option is set, we 'beautify' the text typed by users
     if ($this->_config->getValue("beautify_comments_text")) {
         $this->_commentText = $tf->autop($this->_commentText);
     }
 }
 /**
  * Constructor. It initializes certain things such as the base url, checks whether subdomains are
  * enabled, etc. This method will fetch the values of the following configuration settings:
  *
  * - base_url: this is the base URL that will be used to generate all other URLs in the system
  * - subdomains_base_url: if subdomains are enabled, we should also set this URL to something valid. We can
  *   either use {blogname} or {username} to specify whether the URLs should be generated including the
  *   name of the user who owns the blog or the name of the blog.
  * - include_blog_id_in_url
  * - script_name: use this setting to rename index.php to something else and still have pLog generate
  *   URLs pointing to the right script.
  *
  * @param blogInfo A valid BlogInfo object
  */
 function BaseRequestGenerator($blogInfo = null)
 {
     $this->Object();
     $this->_params = array();
     $this->_blogInfo = $blogInfo;
     $config =& Config::getConfig();
     $this->_baseUrl = $config->getValue("base_url");
     $this->_subdomainsBaseUrl = $config->getValue("subdomains_base_url");
     // get some information about the configuration of subdomains
     $this->_subdomainsEnabled = $config->getValue("subdomains_enabled");
     if ($this->_subdomainsEnabled) {
         $this->_includeBlogId = $config->getValue("include_blog_id_in_url");
     } else {
         $this->_includeBlogId = true;
     }
     // prepare the correct url if subdomains are enabled...
     if ($this->_subdomainsEnabled && $blogInfo != null) {
         $this->_subdomainsBaseUrl = str_replace("{blogname}", Textfilter::urlize($blogInfo->getBlog()), $this->_subdomainsBaseUrl);
         $ownerInfo = $blogInfo->getOwnerInfo();
         $this->_subdomainsBaseUrl = str_replace("{username}", Textfilter::urlize($ownerInfo->getUsername()), $this->_subdomainsBaseUrl);
     }
     $this->_scriptName = $config->getValue("script_name", DEFAULT_SCRIPT_NAME);
     // enable the xhtml mode by default, but it can be turned off
     // via the setXHTML() method
     $this->_xhtmlEnabled = true;
 }
 /**
  * Carries out the specified action
  */
 function perform()
 {
     // get the parameters, which have already been validated
     $this->_userName = Textfilter::filterAllHTML($this->_request->getValue("userName"));
     $this->_userPassword = $this->_request->getValue("userPassword");
     $this->_op = Textfilter::filterAllHTML($this->_request->getValue("op"));
     // create a plugin manager
     $pm =& PluginManager::getPluginManager();
     // try to authenticate the user
     $users = new Users();
     if (!$users->authenticateUser($this->_userName, $this->_userPassword)) {
         $this->_view = new AdminDefaultView();
         $this->_view->setErrorMessage($this->_locale->tr("error_incorrect_username_or_password"));
         $this->setCommonData();
         $pm->notifyEvent(EVENT_LOGIN_FAILURE, array("user" => $this->_userName));
         return false;
     }
     // if the user is correct, get and put his or her information in the session
     $userInfo = $users->getUserInfo($this->_userName, $this->_userPassword);
     if (!$userInfo) {
         $this->_view = new AdminDefaultView();
         $this->_view->setErrorMessage($this->_locale->tr("error_incorrect_username_or_password"));
         $this->setCommonData();
         $pm->notifyEvent(EVENT_LOGIN_FAILURE, array("user" => $this->_userName));
         return false;
     }
     $pm->notifyEvent(EVENT_USER_LOADED, array("user" => &$userInfo, "from" => "Login"));
     //$sessionInfo = $_SESSION["SessionInfo"];
     $session = HttpVars::getSession();
     $sessionInfo = $session["SessionInfo"];
     $sessionInfo->setValue("userInfo", $userInfo);
     $session["SessionInfo"] = $sessionInfo;
     HttpVars::setSession($session);
     // get the list of blogs to which the user belongs
     $userBlogs = $users->getUsersBlogs($userInfo->getId(), BLOG_STATUS_ACTIVE);
     // but if he or she does not belong to any yet, we quit
     if (empty($userBlogs)) {
         $this->_view = new AdminDefaultView();
         $this->_view->setErrorMessage($this->_locale->tr("error_dont_belong_to_any_blog"));
         $this->setCommonData();
         return false;
     }
     $pm->notifyEvent(EVENT_BLOGS_LOADED, array("blogs" => &$userBlogs, "from" => "Login"));
     // check if we are skipping the dashboard
     if ($this->_config->getValue("skip_dashboard")) {
         // get the first blog that came
         $this->_blogInfo = end($userBlogs);
         // set it in the session
         $session = HttpVars::getSession();
         $session["SessionInfo"]->setValue("blogInfo", $this->_blogInfo);
         HttpVars::setSession($session);
         // and then continue...
         AdminController::setForwardAction("newPost");
     } else {
         $this->_view = new AdminDashboardView($userInfo, $userBlogs);
     }
     // better to return true if everything's fine
     return true;
 }
 /**
  * Carries out the specified action
  */
 function perform()
 {
     // fetch the information coming from the resource
     $this->_description = Textfilter::filterAllHTML($this->_request->getValue("resourceDescription"));
     $this->_albumId = $this->_request->getValue("albumId");
     $this->_resource = $this->_request->getValue("resourceFile");
     // check if there is any file uploaded
     $files = HttpVars::getFiles();
     // we probably need to rearrange the $files array a bit better...
     $this->_files = array();
     foreach ($files as $file) {
         if ($file["error"] == 0 && $file["size"] > 0 && $file["name"] != "") {
             $this->_files[] = $file;
         }
     }
     // let the gallery library do its work...
     $resources = new GalleryResources();
     $this->_view = new AdminResourcesListView($this->_blogInfo, array("albumId" => $this->_albumId));
     $successMessage = "";
     $errorMessage = "";
     foreach ($this->_files as $file) {
         // create a new FileUpload object based on the file
         $upload = new FileUpload($file);
         // add the resource to the db
         $this->notifyEvent(EVENT_PRE_RESOURCE_ADD, array("upload" => &$upload));
         $res = $resources->addResource($this->_blogInfo->getId(), $this->_albumId, $this->_description, $upload);
         // check if everything went fine and if not, show an error message
         if ($res > 0) {
             $successMessage .= $this->_locale->pr("resource_added_ok", $file["name"]) . "<br/>";
             // try to fetch the resource so that we can send it in the event
             $resource = $resources->getResource($res, $this->_blogInfo->getId());
             $this->notifyEvent(EVENT_POST_RESOURCE_ADD, array("resource" => &$resource));
         } else {
             if ($res == GALLERY_ERROR_RESOURCE_FORBIDDEN_EXTENSION) {
                 $errorMessage .= $this->_locale->pr("error_resource_forbidden_extension", $file["name"]) . "<br/>";
             } elseif ($res == GALLERY_ERROR_RESOURCE_TOO_BIG) {
                 $errorMessage .= $this->_locale->pr("error_resource_too_big", $file["name"]) . "<br/>";
             } elseif ($res == GALLERY_ERROR_UPLOADS_NOT_ENABLED) {
                 $errorMessage .= $this->_locale->tr("error_uploads_disabled") . "<br/>";
             } elseif ($res == GALLERY_ERROR_QUOTA_EXCEEDED) {
                 $errorMessage .= $this->_locale->tr("error_quota_exceeded") . "<br/>";
             } else {
                 $errorMessage .= $this->_locale->pr("error_adding_resource", $file["name"]) . "<br/>";
             }
         }
     }
     // clear the cache no matter what happened... we should only clear it if there was at least one
     // file uploaded but this way is not that bad after all...
     CacheControl::resetBlogCache($this->_blogInfo->getId(), false);
     if ($successMessage != "") {
         $this->_view->setSuccessMessage($successMessage);
     }
     if ($errorMessage != "") {
         $this->_view->setErrorMessage($errorMessage);
     }
     $this->setCommonData();
     return true;
 }
 /**
  * Carries out the specified action
  */
 function perform()
 {
     // fetch the settings from the db and update them accordingly
     $blogs = new Blogs();
     $blogSettings = $blogs->getBlogSettings($this->_blogInfo->getId());
     $blogSettings->setValue("locale", $this->_request->getValue("blogLocale"));
     $blogSettings->setValue("show_posts_max", $this->_request->getValue("blogMaxMainPageItems"));
     $blogSettings->setValue("recent_posts_max", $this->_request->getValue("blogMaxRecentItems"));
     $blogSettings->setValue("template", $this->_request->getValue("blogTemplate"));
     $blogSettings->setValue("time_offset", $this->_request->getValue("blogTimeOffset"));
     $blogSettings->setValue("categories_order", $this->_request->getValue("blogCategoriesOrder"));
     $blogSettings->setValue("link_categories_order", $this->_request->getValue("blogLinkCategoriesOrder"));
     $blogSettings->setValue("show_more_enabled", Textfilter::checkboxToBoolean($this->_request->getValue("blogShowMoreEnabled")));
     $blogSettings->setValue("htmlarea_enabled", Textfilter::checkboxToBoolean($this->_request->getValue("blogEnableHtmlarea")));
     $blogSettings->setValue("comments_enabled", Textfilter::checkboxToBoolean($this->_request->getValue("blogCommentsEnabled")));
     $blogSettings->setValue("show_future_posts_in_calendar", Textfilter::checkboxToBoolean($this->_request->getValue("blogShowFuturePosts")));
     $blogSettings->setValue("new_drafts_autosave_enabled", Textfilter::checkboxToBoolean($this->_request->getValue("blogEnableAutosaveDrafts")));
     $blogSettings->setValue("comments_order", $this->_request->getValue("blogCommentsOrder"));
     $this->_blogInfo->setAbout(Textfilter::filterAllHTML($this->_request->getValue("blogAbout")));
     $this->_blogInfo->setBlog(Textfilter::filterAllHTML($this->_request->getValue("blogName")));
     $this->_blogInfo->setSettings($blogSettings);
     $this->_blogInfo->setProperties($this->_request->getValue("properties"));
     $this->_blogInfo->setMangledBlog(Textfilter::urlize($this->_blogInfo->getBlog()));
     // and now update the settings in the database
     $blogs = new Blogs();
     // and now we can proceed...
     $this->notifyEvent(EVENT_PRE_BLOG_UPDATE, array("blog" => &$this->_blogInfo));
     if (!$blogs->updateBlog($this->_blogInfo->getId(), $this->_blogInfo)) {
         $this->_view = new AdminBlogSettingsView($this->_blogInfo);
         $this->_view->setErrorMessage($this->_locale->tr("error_updating_settings"));
         $this->setCommonData();
         return false;
     }
     // do it again, baby :)))
     $this->_blogInfo->setAbout(Textfilter::filterAllHTML(stripslashes($this->_request->getValue("blogAbout"))));
     $this->_blogInfo->setBlog(Textfilter::filterAllHTML(stripslashes($this->_request->getValue("blogName"))));
     $this->_blogInfo->setSettings($blogSettings);
     $this->_blogInfo->setProperties($this->_blogProperties);
     $this->_session->setValue("blogInfo", $this->_blogInfo);
     $this->saveSession();
     $this->notifyEvent(EVENT_POST_BLOG_UPDATE, array("blog" => &$this->_blogInfo));
     $this->_view = new AdminBlogSettingsView($this->_blogInfo);
     $this->_locale =& Locales::getLocale($blogSettings->getValue("locale"));
     $this->_view->setSuccessMessage($this->_locale->pr("blog_settings_updated_ok", $this->_blogInfo->getBlog()));
     $this->setCommonData();
     // clear the cache
     CacheControl::resetBlogCache($this->_blogInfo->getId());
     // better to return true if everything fine
     return true;
 }
 function perform()
 {
     // if all data is correct, then we can proceed and use it
     $tf = new Textfilter();
     $this->userName = $tf->filterAllHTML($this->_request->getValue("userName"));
     $this->userPassword = $tf->filterAllHTML($this->_request->getValue("userPassword"));
     $this->confirmPassword = $tf->filterAllHTML($this->_request->getValue("userPasswordCheck"));
     $this->userEmail = $tf->filterAllHTML($this->_request->getValue("userEmail"));
     $this->userFullName = $tf->filterAllHTML($this->_request->getValue("userFullName"));
     $this->captcha = $this->_request->getValue("userAuth");
     // check if there is already a user with the same username and quit if so
     $users = new Users();
     if ($users->userExists($this->userName)) {
         $this->_view = new SummaryUserCreationView();
         //$this->_form->hasRun( true );
         $this->_form->setFieldValidationStatus("userName", false);
         $this->setCommonData(true);
         return false;
     }
     // check if this email account has registered and quit if so, but only if the configuration
     // says that we should only allow one blog per email account
     if ($this->_config->getValue("force_one_blog_per_email_account")) {
         if ($users->emailExists($this->userEmail)) {
             $this->_view = new SummaryUserCreationView();
             //$this->_form->hasRun( true );
             $this->_form->setFieldValidationStatus("userEmail", false);
             $this->setCommonData(true);
             return false;
         }
     }
     // check if the passwords match, and stop processing if so too
     if ($this->userPassword != $this->confirmPassword) {
         $this->_view = new SummaryUserCreationView();
         $this->_view->setErrorMessage($this->_locale->tr("error_passwords_dont_match"));
         $this->_form->setFieldValidationStatus("userPasswordCheck", false);
         $this->setCommonData(true);
         return false;
     }
     // check if the captcha matches
     if ($this->_config->getValue("use_captcha_auth")) {
         include_once PLOG_CLASS_PATH . "class/data/captcha/captcha.class.php";
         $captcha = new Captcha();
         if (!$captcha->validate($this->captcha)) {
             $this->_view = new SummaryUserCreationView();
             $this->_view->setErrorMessage($this->_locale->tr("error_invalid_auth_code"));
             $this->_form->setFieldValidationStatus("userAuth", false);
             $this->setCommonData(true);
             return false;
         }
     }
     // if everything went fine, then proceed
     $this->_view = new doBlogRegistrationView();
     $this->setValues();
     $this->setCommonData();
     return true;
 }
 function perform()
 {
     // fetch the validated data
     $this->_blogName = Textfilter::filterAllHTML($this->_request->getValue("blogName"));
     $this->_ownerId = $this->_request->getValue("blogOwner");
     $this->_blogProperties = $this->_request->getValue("properties");
     // check that the user really exists
     $users = new Users();
     $userInfo = $users->getUserInfoFromId($this->_ownerId);
     if (!$userInfo) {
         $this->_view = new AdminCreateBlogView($this->_blogInfo);
         $this->_form->setFieldValidationStatus("blogOwner", false);
         $this->setCommonData(true);
         return false;
     }
     // now that we have validated the data, we can proceed to create the user, making
     // sure that it doesn't already exists
     $blogs = new Blogs();
     $blog = new BlogInfo($this->_blogName, $this->_ownerId, "", "");
     $blog->setProperties($this->_blogProperties);
     $this->notifyEvent(EVENT_PRE_BLOG_ADD, array("blog" => &$blog));
     $newBlogId = $blogs->addBlog($blog);
     if (!$newBlogId) {
         $this->_view = new AdminCreateBlogView($this->_blogInfo);
         $this->_form->setFieldValidationStatus("blogName", false);
         $this->setCommonData();
         return false;
     }
     // add a default category and a default post
     $articleCategories = new ArticleCategories();
     $articleCategory = new ArticleCategory("General", "", $newBlogId, true);
     $catId = $articleCategories->addArticleCategory($articleCategory);
     $config =& Config::getConfig();
     $locale =& Locales::getLocale($config->getValue("default_locale"));
     $articleTopic = $locale->tr("register_default_article_topic");
     $articleText = $locale->tr("register_default_article_text");
     $article = new Article($articleTopic, $articleText, array($catId), $this->_ownerId, $newBlogId, POST_STATUS_PUBLISHED, 0, array(), "welcome");
     $t = new Timestamp();
     $article->setDateObject($t);
     $articles = new Articles();
     $articles->addArticle($article);
     // and inform everyone that everything went ok
     $this->notifyEvent(EVENT_POST_BLOG_ADD, array("blog" => &$blog));
     $this->_view = new AdminSiteBlogsListView($this->_blogInfo);
     $this->_view->setSuccessMessage($this->_locale->pr("blog_added_ok", $blog->getBlog()));
     $this->setCommonData();
     return true;
 }
 function RegisterAction($actionInfo, $request)
 {
     $this->SummaryAction($actionInfo, $request);
     $tf = new Textfilter();
     $this->blogName = $tf->filterAllHTML($this->_request->getValue("blogName"));
     $this->blogLocale = $this->_request->getValue("blogLocale");
     $this->userName = $tf->filterAllHTML($this->_request->getValue("userName"));
     $this->userPassword = $tf->filterAllHTML($this->_request->getValue("userPassword"));
     $this->userEmail = $tf->filterAllHTML($this->_request->getValue("userEmail"));
     $this->userFullName = $tf->filterAllHTML($this->_request->getValue("userFullName"));
 }
 function perform()
 {
     // get the data
     $this->_userId = $this->_request->getValue("userId");
     $this->_userPassword = trim(Textfilter::filterAllHTML($this->_request->getValue("userProfilePassword")));
     $this->_userEmail = Textfilter::filterAllHTML($this->_request->getValue("userEmail"));
     $this->_userAbout = Textfilter::filterAllHTML($this->_request->getValue("userAbout"));
     $this->_userFullName = Textfilter::filterAllHTML($this->_request->getValue("userFullName"));
     $this->_adminPrivs = $this->_request->getValue("userIsSiteAdmin");
     $this->_userProperties = $this->_request->getValue("properties");
     $this->_userStatus = $this->_request->getValue("userStatus");
     // load the user settings
     $users = new Users();
     $user = $users->getUserInfoFromId($this->_userId);
     // if no info could be fetched, shown an error and quit
     if (!$user) {
         $this->_view = new AdminSiteUsersListView($this->_blogInfo);
         $this->_view->setErrorMessage($this->_locale->tr("error_invalid_user"));
         $this->setCommonData();
         return false;
     }
     // update the user settings
     $user->setEmail($this->_userEmail);
     $user->setAboutMyself($this->_userAbout);
     $user->setSiteAdmin($this->_adminPrivs);
     $user->setFullName($this->_userFullName);
     $user->setProperties($this->_userProperties);
     $user->setStatus($this->_userStatus);
     if ($this->_userPassword != "") {
         $user->setPassword($this->_userPassword);
     }
     $this->notifyEvent(EVENT_PRE_USER_UPDATE, array("user" => &$user));
     // and now update them
     if (!$users->updateUser($user)) {
         $this->_view = new AdminSiteUsersListView($this->_blogInfo);
         $this->_view->setErrorMessage($this->_locale->tr("error_updating_user"));
         $this->setCommonData();
         return false;
     }
     // the post-update event... if needed
     $this->notifyEvent(EVENT_POST_USER_UPDATE, array("user" => &$user));
     $this->_view = new AdminSiteUsersListView($this->_blogInfo);
     $this->_view->setSuccessMessage($this->_locale->pr("user_updated_ok", $user->getUsername()));
     $this->setCommonData();
     return true;
 }
 /**
  * Carries out the specified action
  */
 function perform()
 {
     // add the new link category to the database
     $this->_linkCategoryName = Textfilter::filterAllHTML($this->_request->getValue("linkCategoryName"));
     $mylinksCategories = new MyLinksCategories();
     $mylinksCategory = new MyLinksCategory($this->_linkCategoryName, $this->_blogInfo->getId(), 0, $this->_properties);
     // the view is the same for both conditions
     $this->_view = new AdminLinkCategoriesListView($this->_blogInfo);
     if (!$mylinksCategories->addMyLinksCategory($mylinksCategory, $this->_blogInfo->getId())) {
         // set an error message
         $this->_view->setErrorMessage($this->_locale->tr("error_adding_link_category"));
     } else {
         // clear the cache
         CacheControl::resetBlogCache($this->_blogInfo->getId(), false);
         $this->_view->setSuccessMessage($this->_locale->pr("link_category_added_ok", $mylinksCategory->getName()));
     }
     $this->setCommonData();
     return true;
 }
 /**
  * Carries out the specified action
  */
 function perform()
 {
     $this->_albumId = $this->_request->getValue("albumId");
     $this->_parentId = $this->_request->getValue("parentId");
     $this->_albumName = Textfilter::filterAllHTML($this->_request->getValue("albumName"));
     $this->_albumDescription = Textfilter::filterAllHTML($this->_request->getValue("albumDescription"));
     $this->_showAlbum = $this->_request->getValue("showAlbum");
     if ($this->_showAlbum == "") {
         $this->_showAlbum = 0;
     }
     // fetch the albums for this blog
     $albums = new GalleryAlbums();
     $album = $albums->getAlbum($this->_albumId, $this->_blogInfo->getId());
     if (!$album) {
         $this->_view = new AdminResourcesListView($this->_blogInfo);
         $this->_blogInfo;
         $this->_view->setErrorMessage($this->_locale->tr("error_updating_album"));
         $this->setCommonData();
         return false;
     }
     // update the fields in the object
     $album->setName($this->_albumName);
     $album->setDescription($this->_albumDescription);
     $album->setParentId($this->_parentId);
     $album->setShowAlbum($this->_showAlbum);
     $this->notifyEvent(EVENT_PRE_ALBUM_UPDATE, array("album" => &$album));
     // and update the data in the database
     if (!$albums->updateAlbum($album)) {
         $this->_view = new AdminResourcesListView($this->_blogInfo);
         $this->_blogInfo;
         $this->_view->setErrorMessage($this->_locale->tr("error_updating_album"));
         $this->setCommonData();
         return false;
     }
     $this->_view = new AdminResourcesListView($this->_blogInfo);
     $this->_view->setSuccessMessage($this->_locale->pr("album_updated_ok", $album->getName()));
     $this->notifyEvent(EVENT_POST_ALBUM_UPDATE, array("album" => &$album));
     $this->setCommonData();
     // clear the cache
     CacheControl::resetBlogCache($this->_blogInfo->getId(), false);
     // better to return true if everything fine
     return true;
 }
 /**
  * Carries out the specified action
  */
 function perform()
 {
     // data is fine, we have already validated it
     $this->_linkName = Textfilter::filterAllHTML($this->_request->getValue("linkName"));
     $this->_linkDescription = Textfilter::filterAllHTML($this->_request->getValue("linkDescription"));
     $this->_linkUrl = Textfilter::filterAllHTML($this->_request->getValue("linkUrl"));
     $this->_linkCategoryId = $this->_request->getValue("linkCategoryId");
     $this->_linkId = $this->_request->getValue("linkId");
     $this->_linkFeed = Textfilter::filterAllHTML($this->_request->getValue("linkRssFeed"));
     // fetch the link we're trying to update
     $links = new MyLinks();
     $link = $links->getMyLink($this->_linkId, $this->_blogInfo->getId());
     if (!$link) {
         $this->_view = new AdminLinksListView($this->_blogInfo);
         $this->_view->setErrorMessage($this->_locale->tr("error_fetching_link"));
         $this->setCommonData();
         return false;
     }
     // update the fields
     $link->setName($this->_linkName);
     $link->setDescription($this->_linkDescription);
     $link->setCategoryId($this->_linkCategoryId);
     $link->setUrl($this->_linkUrl);
     $link->setProperties($this->_properties);
     $link->setRssFeed($this->_linkFeed);
     $this->notifyEvent(EVENT_PRE_LINK_UPDATE, array("link" => &$link));
     // and now update it in the database
     if (!$links->updateMyLink($link)) {
         $this->_view = new AdminLinksListView($this->_blogInfo);
         $this->_view->setErrorMessage($this->_locale->tr("error_updating_link"));
         $this->setCommonData();
         return false;
     }
     $this->notifyEvent(EVENT_POST_LINK_UPDATE, array("link" => &$link));
     // clear the cache
     CacheControl::resetBlogCache($this->_blogInfo->getId(), false);
     // and go back to the view with the list of links
     $this->_view = new AdminLinksListView($this->_blogInfo);
     $this->_view->setSuccessMessage($this->_locale->pr("link_updated_ok", $link->getName()));
     $this->setCommonData();
     // better to return true if everything fine
     return true;
 }
 function perform()
 {
     $status = POST_STATUS_DRAFT;
     $articles = new Articles();
     $postText = Textfilter::xhtmlize($this->_postText) . POST_EXTENDED_TEXT_MODIFIER . Textfilter::xhtmlize($this->_postExtendedText);
     $article = new Article($this->_postTopic, $postText, $this->_postCategories, $this->_userInfo->getId(), $this->_blogInfo->getId(), $status, 0, array(), $this->_postSlug);
     // set also the date before it's too late
     $article->setDateObject($this->_postTimestamp);
     $article->setCommentsEnabled($this->_commentsEnabled);
     // prepare the custom fields
     $fields = array();
     if (is_array($this->_customFields)) {
         foreach ($this->_customFields as $fieldId => $fieldValue) {
             // 3 of those parameters are not really need when creating a new object... it's enough that
             // we know the field definition id.
             $customField = new CustomFieldValue($fieldId, $fieldValue, "", -1, "", $artId, $this->_blogInfo->getId(), -1);
             array_push($fields, $customField);
         }
         $article->setFields($fields);
     }
     // in case the post is already in the db
     if ($this->_postId != "") {
         $article->setId($this->_postId);
         $postSavedOk = $articles->updateArticle($article);
         if ($postSavedOk) {
             $artId = $this->_postId;
         } else {
             $artId = false;
         }
     } else {
         $artId = $articles->addArticle($article);
     }
     // once we have built the object, we can add it to the database
     $this->_view = new AdminXmlView($this->_blogInfo, "response");
     $this->_view->setValue("method", "saveXmlDraft");
     if ($artId) {
         $this->_view->setValue("result", $artId);
     } else {
         $this->_view->setValue("result", "0");
     }
     return true;
 }
 function perform()
 {
     // fetch the validated data
     $this->_userName = Textfilter::filterAllHTML($this->_request->getValue("userName"));
     $this->_userPassword = $this->_request->getValue("newUserPassword");
     $this->_userEmail = Textfilter::filterAllHTML($this->_request->getValue("userEmail"));
     $this->_userFullName = Textfilter::filterAllHTML($this->_request->getValue("userFullName"));
     $this->_userStatus = $this->_request->getValue("userStatus");
     $this->_userBlog = $this->_request->getValue("userBlog");
     // now that we have validated the data, we can proceed to create the user, making
     // sure that it doesn't already exists
     $users = new Users();
     $userInfo = $users->userExists($this->_userName);
     if ($userInfo) {
         $this->_form->setFieldValidationStatus("userName", false);
         $this->_view = new AdminAddUserView($this->_blogInfo);
         $this->setCommonData(true);
         return false;
     }
     // otherwise, we can create a new one
     $user = new UserInfo($this->_userName, $this->_userPassword, $this->_userEmail, "", $this->_userFullName, 0, $this->_properties);
     $user->setStatus($this->_userStatus);
     $this->notifyEvent(EVENT_PRE_USER_ADD, array("user" => &$user));
     $newUserId = $users->addUser($user);
     if (!$newUserId) {
         $this->_view = new AdminAddUserView($this->_blogInfo);
         $this->_form->setFieldValidationStatus("userName", false);
         $this->setCommonData(true);
         return false;
     }
     // if the userBlog parameter is different than 0, we have to add a relationship
     // between that user and the blog
     if ($this->_userBlog > 0) {
         $permissions = new UserPermissions();
         $result = $permissions->grantPermission($newUserId, $this->_userBlog, PERMISSION_BLOG_USER);
     }
     $this->notifyEvent(EVENT_POST_USER_ADD, array("user" => &$user));
     $this->_view = new AdminSiteUsersListView($this->_blogInfo);
     $this->_view->setSuccessMessage($this->_locale->pr("user_added_ok", $user->getUsername()));
     $this->setCommonData();
     return true;
 }
 /**
  * Carries out the specified action
  */
 function perform()
 {
     // get the data from the form
     $this->_categoryName = Textfilter::filterAllHTML($this->_request->getValue("categoryName"));
     $this->_categoryId = $this->_request->getValue("categoryId");
     $this->_categoryDescription = Textfilter::filterAllHTML($this->_request->getValue("categoryDescription"));
     $this->_categoryInMainPage = $this->_request->getValue("categoryInMainPage");
     $this->_properties = array();
     // fetch the category we're trying to update
     $categories = new ArticleCategories();
     $category = $categories->getCategory($this->_categoryId, $this->_blogInfo->getId());
     if (!$category) {
         $this->_view = new AdminArticleCategoriesListView($this->_blogInfo);
         $this->_view->setErrorMessage($this->_locale->tr("error_fetching_category"));
         $this->setCommonData();
         return false;
     }
     // fire the pre-event
     $this->notifyEvent(EVENT_PRE_CATEGORY_UPDATE, array("category" => &$category));
     // update the fields
     $category->setName($this->_categoryName);
     $category->setUrl("");
     $category->setInMainPage($this->_categoryInMainPage);
     $category->setProperties($this->_properties);
     $category->setDescription($this->_categoryDescription);
     // this is view we're going to use to show our messages
     $this->_view = new AdminArticleCategoriesListView($this->_blogInfo);
     if (!$categories->updateCategory($category)) {
         $this->_view->setErrorMessage($this->_locale->tr("error_updating_article_category"));
     } else {
         // if everything fine, load the list of categories
         $this->_view->setSuccessMessage($this->_locale->pr("article_category_updated_ok", $category->getName()));
         // fire the post-event
         $this->notifyEvent(EVENT_POST_CATEGORY_UPDATE, array("category" => &$category));
         // clear the cache
         CacheControl::resetBlogCache($this->_blogInfo->getId());
     }
     $this->setCommonData();
     // better to return true if everything fine
     return true;
 }
 /**
  * Carries out the specified action
  */
 function perform()
 {
     // fetch the fields from the request
     $this->_fieldId = $this->_request->getValue("fieldId");
     $this->_fieldName = Textfilter::filterAllHTML($this->_request->getValue("fieldName"));
     $this->_fieldDescription = Textfilter::filterAllHTML($this->_request->getValue("fieldDescription"));
     $this->_fieldType = $this->_request->getValue("fieldType");
     $this->_fieldSearchable = $this->_request->getValue("fieldSearchable");
     $this->_fieldHidden = $this->_request->getValue("fieldHidden");
     // and start to update the field
     $fields = new CustomFields();
     $field = $fields->getCustomField($this->_fieldId);
     // view that we're going to use for all different flows...
     $this->_view = new AdminCustomFieldsListView($this->_blogInfo);
     // field couldn't be loaded...
     if (!$field) {
         $this->_view->setErrorMessage($this->_locale->tr("error_updating_custom_field"));
         return false;
     }
     // ...update its information...
     $field->setName($this->_fieldName);
     $field->setDescription($this->_fieldDescription);
     $field->setType($this->_fieldType);
     $field->setHidden($this->_fieldHidden);
     // fire the pre-event
     $this->notifyEvent(EVENT_PRE_CUSTOM_FIELD_UPDATE, array("field" => &$field));
     // ...and finally the data in the database
     $result = $fields->updateCustomField($field);
     // check the result
     if (!$result) {
         $this->_view->setErrorMessage($this->_locale->tr("error_updating_custom_field"));
     } else {
         $this->_view->setSuccessMessage($this->_locale->pr("custom_field_updated_ok", $field->getName()));
         // fire the post-event
         $this->notifyEvent(EVENT_POST_CUSTOM_FIELD_UPDATE, array("field" => &$field));
     }
     $this->setCommonData();
     return true;
 }
 /**
  * Carries out the specified action
  */
 function perform()
 {
     // fetch the data, we already know it's valid and that we can trust it!
     $this->_categoryName = Textfilter::filterAllHTML($this->_request->getValue("categoryName"));
     $this->_categoryUrl = $this->_request->getValue("categoryUrl");
     $this->_categoryInMainPage = Textfilter::checkboxToBoolean($this->_request->getValue("categoryInMainPage"));
     $this->_categoryDescription = Textfilter::filterAllHTML($this->_request->getValue("categoryDescription"));
     $this->_properties = $this->_request->getValue("properties");
     // create the object...
     $categories = new ArticleCategories();
     $category = new ArticleCategory($this->_categoryName, $this->_categoryUrl, $this->_blogInfo->getId(), $this->_categoryInMainPage, $this->_categoryDescription, 0, $this->_properties);
     // fire the pre event...
     $this->notifyEvent(EVENT_PRE_CATEGORY_ADD, array("category" => &$category));
     // once we have built the object, we can add it to the database!
     if ($categories->addArticleCategory($category)) {
         // if everything went fine, transfer the execution flow to the action that
         // lists all the article categories... without forgetting that we should let the
         // next class know that we actually added a category alongside a message
         // and the category that we just added!
         $this->_view = new AdminArticleCategoriesListView($this->_blogInfo);
         $this->_view->setSuccess(true);
         $this->_view->setSuccessMessage($this->_locale->pr("category_added_ok", $category->getName()));
         // fire the post event
         $this->notifyEvent(EVENT_POST_CATEGORY_ADD, array("category" => &$category));
         // clear the cache if everything went fine
         CacheControl::resetBlogCache($this->_blogInfo->getId(), false);
         $this->setCommonData();
     } else {
         // if there was an error, we should say so... as well as not changing the view since
         // we're going back to the original view where we can add the category
         $this->_view->setError(true);
         $this->_view->setErrorMessage($this->_locale->tr("error_adding_article_category"));
         $this->setCommonData(true);
     }
     // better to return true if everything fine
     return true;
 }
 function perform()
 {
     $this->_notificationText = $this->_request->getValue("newBlogUserText");
     $this->_newUsername = Textfilter::filterAllHTML($this->_request->getValue("newBlogUserName"));
     // see if the user exists
     $users = new Users();
     $userInfo = $users->getUserInfoFromUsername($this->_newUsername);
     if (!$userInfo) {
         $this->_view = new AdminTemplatedView($this->_blogInfo, "addbloguser");
         $this->_view->setErrorMessage($this->_locale->pr("error_invalid_user"), $this->_newUsername);
         $this->_form->setFieldValidationStatus("newBlogUserName", false);
         $this->setCommonData(true);
         return false;
     }
     $this->notifyEvent(EVENT_USER_LOADED, array("user" => &$userInfo));
     // now we can add this user to the blog
     $userPerms = new UserPermissions();
     $res = $userPerms->grantPermission($userInfo->getId(), $this->_blogInfo->getId(), PERMISSION_BLOG_USER);
     $this->notifyEvent(EVENT_PRE_USER_UPDATE, array("user" => &$userInfo));
     if (!$res) {
         // there was an error adding the user to the blog
         $this->_view = new AdminTemplatedView($this->_blogInfo, "addbloguser");
         $this->_view->setErrorMessage($this->_locale->pr("error_adding_user", $userInfo->getUsername()));
         $this->setCommonData();
         return false;
     }
     $this->notifyEvent(EVENT_POST_USER_UPDATE, array("user" => &$userInfo));
     // send a notification if enabled
     if ($this->_sendNotification) {
         $this->sendNotificationEmail($userInfo);
     }
     $this->_view = new AdminBlogUsersListView($this->_blogInfo);
     $this->_view->setSuccessMessage($this->_locale->pr("user_added_to_blog_ok", $userInfo->getUsername()));
     $this->setCommonData();
     return true;
 }
 /**
  * @private
  */
 function _fillResourceParameters($resource)
 {
     $album = $resource->getAlbum();
     $blogId = $this->_blogInfo->getId();
     $ownerId = $resource->getOwnerId();
     if ($blogId != $ownerId) {
         $blogId = $ownerId;
         $blogs =& new Blogs();
         $blogInfo = $blogs->getBlogInfo($blogId);
         $blogShortName = $blogInfo->getMangledBlog();
         $ownerInfo = $blogInfo->getOwnerInfo();
     } else {
         $blogShortName = $this->_blogInfo->getMangledBlog();
         $ownerInfo = $this->_blogInfo->getOwnerInfo();
     }
     $params = array("{blogid}" => $blogId, "{blogname}" => $blogShortName, "{blogowner}" => $ownerInfo->getUsername(), "{resourceid}" => $resource->getId(), "{resourcename}" => rawurlencode($resource->getFileName()), "{albumid}" => $album->getId(), "{albumname}" => Textfilter::urlize($album->getName()));
     return $params;
 }
 function getMangledBlog()
 {
     // fill in the field if it hasn't been filled yet
     if ($this->_mangledBlog === null) {
         $this->_mangledBlog = Textfilter::urlize($this->getBlog());
     }
     return $this->_mangledBlog;
 }
 function setName($name)
 {
     $this->_name = Textfilter::filterAllHTML($name);
 }