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 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")); }
/** * 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; }
/** * 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 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() { // 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() { // 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; }
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); } }
/** * 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() { // 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() { // 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 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() { // 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; }
/** * 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; }
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; }
/** * Carries out the specified action */ function perform() { // fetch the values from the form which have already been validated $this->_blogName = Textfilter::filterAllHTML($this->_request->getValue("blogName")); $this->_blogLocale = $this->_request->getValue("blogLocale"); $this->_blogTemplate = $this->_request->getValue("blogTemplate"); $this->_blogOwner = $this->_request->getValue("blogOwner"); $this->_editBlogId = $this->_request->getValue("blogId"); $this->_blogTimeOffset = $this->_request->getValue("blogTimeOffset"); $this->_blogProperties = $this->_request->getValue("properties"); $this->_blogQuota = $this->_request->getValue("blogResourcesQuota"); $this->_blogUsers = $this->_request->getValue("blogUsers"); $this->_blogStatus = $this->_request->getValue("blogStatus"); //print_r($_REQUEST); // get the blog we're trying to update $blogs = new Blogs(); $blogInfo = $blogs->getBlogInfo($this->_editBlogId); if (!$blogInfo) { $this->_view = new AdminSiteBlogsListView($this->_blogInfo); $this->_view->setErrorMessage($this->_locale->tr("error_fetching_blog")); $this->setCommonData(); return false; } $this->notifyEvent(EVENT_BLOG_LOADED, array("blog" => &$blogInfo)); // make sure that the user we'd like to set as owner exists $users = new Users(); $userInfo = $users->getUserInfoFromId($this->_blogOwner); if (!$userInfo) { $this->_view = new AdminSiteBlogsListView($this->_blogInfo); $this->_view->setErrorMessage($this->_locale->tr("error_incorrect_blog_owner")); $this->setCommonData(); return false; } $this->notifyEvent(EVENT_USER_LOADED, array("user" => &$userInfo)); // set the different settings $blogSettings = $blogInfo->getSettings(); $blogSettings->setValue("locale", $this->_blogLocale); $blogSettings->setValue("template", $this->_blogTemplate); $blogSettings->setValue("time_offset", $this->_blogTimeOffset); $blogInfo->setSettings($blogSettings); $blogInfo->setResourcesQuota($this->_blogQuota); $blogInfo->setBlog($this->_blogName); $blogInfo->setProperties($this->_blogProperties); $blogInfo->setOwner($this->_blogOwner); $blogInfo->setStatus($this->_blogStatus); $blogInfo->setMangledBlog(Textfilter::urlize($blogInfo->getBlog())); $this->notifyEvent(EVENT_PRE_BLOG_UPDATE, array("blog" => &$blogInfo)); if (!$blogs->updateBlog($blogInfo->getId(), $blogInfo)) { $this->_view = new AdminSiteBlogsListView($this->_blogInfo); $this->_view->setErrorMessage($this->_locale->pr("error_updating_blog_settings", $blogInfo->getBlog())); $this->setCommonData(); return false; } // update the user permissions, even if they didn't change (but we have no way to // check that anyway!) $permissions = new UserPermissions(); if (!$permissions->updateBlogUserPermissions($this->_editBlogId, $this->_blogUsers)) { $this->_view = new AdminSiteBlogsListView($this->_blogInfo); $this->_view->setErrorMessage($this->_locale->pr("error_updating_blog_settings", $blogInfo->getBlog())); $this->setCommonData(); return false; } $this->notifyEvent(EVENT_POST_BLOG_UPDATE, array("blog" => &$blogInfo)); // do it again, baby :))) if ($this->_blogInfo->getId() == $blogInfo->getId()) { $this->_blogInfo->setSettings($blogSettings); $blogInfo->setProperties($this->_blogProperties); $this->_session->setValue("blogInfo", $this->_blogInfo); $this->saveSession(); } // if everything went fine, we can show a nice message $this->_view = new AdminSiteBlogsListView($this->_blogInfo); $this->_view->setSuccessMessage($this->_locale->pr("edit_blog_settings_updated_ok", $blogInfo->getBlog())); $this->setCommonData(); // clear the cache CacheControl::resetBlogCache($blogInfo->getId()); // better to return true if everything fine return true; }
function setUsername($newUsername) { $this->_username = Textfilter::filterAllHTML($newUsername); }
function _fetchCommonData() { $this->_postText = trim(Textfilter::xhtmlize($this->_request->getValue("postText"))); $this->_postExtendedText = trim(Textfilter::xhtmlize($this->_request->getValue("postExtendedText"))); $this->_postTopic = trim(Textfilter::xhtmlize(Textfilter::filterAllHTML($this->_request->getValue("postTopic")))); $this->_postCategories = $this->_request->getValue("postCategories"); $this->_postSlug = trim(Textfilter::filterAllHTML($this->_request->getValue("postSlug"))); $this->_postStatus = $this->_request->getValue("postStatus"); $this->_sendNotification = $this->_request->getValue("sendNotification"); $this->_sendTrackbacks = $this->_request->getValue("sendTrackbacks"); $this->_sendPings = $this->_request->getValue("sendPings"); $this->_postId = $this->_request->getValue("postId"); $this->_commentsEnabled = $this->_request->getValue("commentsEnabled"); $this->_trackbackUrls = $this->_request->getValue("trackbackUrls"); // fetch the custom fields $this->_customFields = $this->_request->getValue("customField"); // fetch the timestamp that the post will have $this->_fetchPostDateInformation(); }
function setName($name) { $this->_name = Textfilter::filterAllHTML($name); }
/** * @private */ function setBlog($blog) { $tf = new Textfilter(); $this->_blog = $tf->filterAllHTML($blog); }