function perform()
 {
     $this->username = $this->_request->getValue("username");
     $this->activeCode = $this->_request->getValue("activeCode");
     $users = new Users();
     $userInfo = $users->getUserInfoFromUsername($this->username);
     if (!$userInfo) {
         $this->_view = new SummaryView("summaryerror");
         $this->_view->setErrorMessage($this->_locale->tr("error_invalid_user"));
         return false;
     }
     $activeCode = $userInfo->getValue("activeCode");
     if ($activeCode != $this->activeCode) {
         $this->_view = new SummaryView("summaryerror", $this->_locale->tr("error_invalid_activation_code"));
         return false;
     }
     // active user
     $userInfo->setStatus(USER_STATUS_ACTIVE);
     $users->updateUser($userInfo);
     // also active the blog that user owned
     // FIXME: how about other blogs that this user take part in?
     $blogId = $users->getUserBlogId($this->username);
     $blogs = new Blogs();
     $blog = $blogs->getBlogInfo($blogId);
     $blog->setStatus(BLOG_STATUS_ACTIVE);
     $blogs->updateBlog($blogId, $blog);
     $blogUrl = $blog->getBlogRequestGenerator();
     // create the message that we're going to show
     $message = "<p>" . $this->_locale->tr("blog_activated_ok") . "</p><p>" . $this->_locale->pr("register_blog_link", $blog->getBlog(), $blogUrl->blogLink()) . "</p><p>" . $this->_locale->tr("register_blog_admin_link") . "</p>";
     $this->_view = new SummaryMessageView($message);
     $this->setCommonData();
     return true;
 }
 /**
  * Loads the blog info and show it
  */
 function perform()
 {
     $this->_blogId = $this->_request->getValue("blogId");
     $this->_view = new SummaryCachedView("blogprofile", array("summary" => "BlogProfile", "blogId" => $this->_blogId, "locale" => $this->_locale->getLocaleCode()));
     if ($this->_view->isCached()) {
         // nothing to do, the view is cached
         return true;
     }
     // load some information about the user
     $blogs = new Blogs();
     $blogInfo = $blogs->getBlogInfo($this->_blogId, true);
     // if there was no blog or the status was incorrect, let's not show it!
     if (!$blogInfo || $blogInfo->getStatus() != BLOG_STATUS_ACTIVE) {
         $this->_view = new SummaryView("error");
         $this->_view->setValue("message", $this->_locale->tr("error_incorrect_blog_id"));
         return false;
     }
     // fetch the blog latest posts
     $posts = array();
     $articles = new Articles();
     $t = new Timestamp();
     $posts = $articles->getBlogArticles($blogInfo->getId(), -1, SUMMARY_DEFAULT_RECENT_BLOG_POSTS, 0, POST_STATUS_PUBLISHED, 0, $t->getTimestamp());
     $this->_view->setValue("blog", $blogInfo);
     $this->_view->setValue("blogposts", $posts);
     $this->setCommonData();
     return true;
 }
 /**
  * Validate if everything is correct
  */
 function validate()
 {
     // first of all, check if we have a valid blog id
     $this->_blogId = $this->_request->getValue("blogId");
     if ($this->_blogId == "" || $this->_blogId < 0) {
         // check if the user really belongs to one or more blogs and if not, quit
         $users = new Users();
         $userBlogs = $users->getUsersBlogs($this->_userInfo->getId(), BLOG_STATUS_ACTIVE);
         if (count($userBlogs) == 0) {
             $this->_view = new AdminSimpleErrorView();
             $this->_view->setValue("message", $this->_locale->tr("error_dont_belong_to_any_blog"));
             return false;
         }
         // if everything went fine, then we can continue...
         $this->_view = new AdminDashboardView($this->_userInfo, $userBlogs);
         return false;
     }
     // load the blog
     $blogs = new Blogs();
     $this->_blogInfo = $blogs->getBlogInfo($this->_blogId);
     // check if the blog really exists
     if (!$this->_blogInfo) {
         $this->_view = new AdminSimpleErrorView();
         $this->_view->setValue("message", $this->_locale->tr("error_incorrect_blog_id"));
         return false;
     }
     // if so, check that it is active
     if ($this->_blogInfo->getStatus() != BLOG_STATUS_ACTIVE) {
         $this->_view = new AdminSimpleErrorView();
         $this->_view->setValue("message", $this->_locale->tr("error_incorrect_blog_id"));
         return false;
     }
     // if the blog identifier is valid, now we should now check if the user belongs
     // to that blog so that we know for sure that nobody has tried to forge the
     // parameter in the meantime
     $userPermissions = new UserPermissions();
     $blogUserPermissions = $userPermissions->getUserPermissions($this->_userInfo->getId(), $this->_blogInfo->getId());
     if (!$blogUserPermissions) {
         $this->_view = new AdminSimpleErrorView();
         $this->_view->setValue("message", $this->_locale->tr("error_no_permissions"));
         return false;
     }
     // if all correct, we can now set the blogInfo object in the session for later
     // use
     $this->_session->setValue("blogInfo", $this->_blogInfo);
     $session = HttpVars::getSession();
     $session["SessionInfo"] = $this->_session;
     HttpVars::setSession($session);
     return true;
 }
 /**
  * @private
  */
 function _disableBlogs()
 {
     // get the default blog id
     $config =& Config::getConfig();
     $defaultBlogId = $config->getValue("default_blog_id");
     $errorMessage = "";
     $successMessage = "";
     $totalOk = 0;
     $blogs = new Blogs();
     foreach ($this->_blogIds as $blogId) {
         // get some info about the blog before deleting it
         $blogInfo = $blogs->getBlogInfo($blogId);
         if (!$blogInfo) {
             $errorMessage .= $this->_locale->pr("error_deleting_blog2", $blogId) . "<br/>";
         } else {
             $this->notifyEvent(EVENT_PRE_BLOG_DELETE, array("blog" => &$blogInfo));
             // make sure we're not deleting the default one!
             if ($defaultBlogId == $blogId) {
                 $errorMessage .= $this->_locale->pr("error_blog_is_default_blog", $blogInfo->getBlog()) . "<br />";
             } else {
                 if ($blogs->disableBlog($blogId)) {
                     $totalOk++;
                     if ($totalOk < 2) {
                         $successMessage = $this->_locale->pr("blog_deleted_ok", $blogInfo->getBlog());
                     } else {
                         $successMessage = $this->_locale->pr("blogs_deleted_ok", $totalOk);
                     }
                     $this->notifyEvent(EVENT_POST_BLOG_DELETE, array("blog" => &$blogInfo));
                 } else {
                     $errorMessage .= $this->_locale->pr("error_deleting_blog", $blogInfo->getBlog()) . "<br/>";
                 }
             }
         }
     }
     $this->_view = new AdminSiteBlogsListView($this->_blogInfo);
     if ($errorMessage != "") {
         $this->_view->setErrorMessage($errorMessage);
     }
     if ($successMessage != "") {
         $this->_view->setSuccessMessage($successMessage);
     }
     $this->setCommonData();
     return true;
 }
 /**
  * Carries out the specified action
  */
 function perform()
 {
     // get the blog and its settings
     $this->_editBlogId = $this->_request->getValue("blogId");
     $blogs = new Blogs();
     $blogInfo = $blogs->getBlogInfo($this->_editBlogId);
     if (!$blogInfo) {
         $this->_view = new AdminSiteBlogsListView($this->_blogInfo);
         $this->_view->setErrorMessage($this->_locale->tr("error_incorrect_blog_id"));
         $this->setCommonData();
         return false;
     }
     $this->notifyEvent(EVENT_BLOG_LOADED, array("blog" => &$blogInfo));
     // create the view and render the contents
     $this->_view = new AdminEditSiteBlogView($this->_blogInfo, $blogInfo);
     $this->setCommonData();
     // better to return true if everything fine
     return true;
 }
 /**
  * Fetches the information for this blog from the database since we are going to need it
  * almost everywhere.
  */
 function _getBlogInfo()
 {
     // see if we're using subdomains
     $config =& Config::getConfig();
     if ($config->getValue("subdomains_enabled")) {
         $subdomainInfo = Subdomains::getSubdomainInfoFromRequest();
         if ($subdomainInfo["username"] != "" && $this->_request->getValue('blogUserName') == "") {
             $this->_request->setValue('blogUserName', $subdomainInfo["username"]);
         }
         if ($subdomainInfo["blogname"] != "" && $this->_request->getValue('blogName') == "") {
             $this->_request->setValue('blogName', $subdomainInfo["blogname"]);
         }
     }
     $blogId = $this->_request->getValue('blogId');
     $blogName = $this->_request->getValue('blogName');
     $userId = $this->_request->getValue('userId');
     $userName = $this->_request->getValue('blogUserName');
     // if there is a "blogId" parameter, it takes precedence over the
     // "user" parameter.
     if (!$blogId && !$blogName) {
         // check if there was a user parameter
         if (!empty($userName)) {
             // if so, check to which blogs the user belongs
             $users = new Users();
             $userInfo = $users->getUserInfoFromUsername($userName);
             // if the user exists and is valid...
             if ($userInfo) {
                 $userBlogs = $users->getUsersBlogs($userInfo->getId(), BLOG_STATUS_ACTIVE);
                 // check if he or she belogs to any blog. If he or she does, simply
                 // get the first one (any better rule for this?)
                 if (!empty($userBlogs)) {
                     $blogId = $userBlogs[0]->getId();
                 } else {
                     $blogId = $this->_config->getValue('default_blog_id');
                 }
             } else {
                 $blogId = $this->_config->getValue('default_blog_id');
             }
         } else {
             // if there is no user parameter, we take the blogId from the session
             if ($this->_session->getValue('blogId') != '') {
                 $blogId = $this->_session->getValue('blogId');
             } else {
                 // get the default blog id from the database
                 $blogId = $this->_config->getValue('default_blog_id');
             }
         }
     }
     // fetch the BlogInfo object
     $blogs = new Blogs();
     if ($blogId) {
         $this->_blogInfo = $blogs->getBlogInfo($blogId);
     } else {
         $this->_blogInfo = $blogs->getBlogInfoByName($blogName);
     }
 }
示例#7
0
$blogName = $tf->filterAllHTML($params->getValue("blog_name"));
$excerpt = $tf->filterAllHTML($params->getValue("excerpt"));
$title = $tf->filterAllHTML($params->getValue("title"));
$articleId = $params->getValue("id");
$url = $tf->filterAllHTML($params->getValue("url"));
// try to see if the article is correct
$articles = new Articles();
$article = $articles->getBlogArticle($articleId);
if (!$article) {
    trackbackLog("ERROR: Incorrect error identifier");
    $result = errorResponse("Incorrect article identifier");
    die($result);
}
// try to load the blog info too, as we are going to need it
$blogs = new Blogs();
$blogInfo = $blogs->getBlogInfo($article->getBlog());
// a bit of protection...
if (!$blogInfo) {
    trackbackLog("ERROR: Article id " . $article->getId() . " points to blog " . $article->getBlog() . " that doesn't exist!");
    $result = errorResponse("The blog does not exist");
    die($result);
}
// if the blog is disabled, then we shoulnd't take trackbacks...
if ($blogInfo->getStatus() != BLOG_STATUS_ACTIVE) {
    trackbackLog("ERROR: The blog " . $blogInfo->getBlog() . " is set as disabled and cannot receive trackbacks!");
    $result = errorResponse("The blog is not active");
    die($result);
}
// if everything went fine, load the plugins so that we can throw some events...
$pm =& PluginManager::getPluginManager();
$pm->loadPlugins();
示例#8
0
        while (!$found && !empty($allBlogs)) {
            $blogInfo = array_pop($allBlogs);
            if (strcasecmp($blogInfo->getBlog(), $blogName) == 0) {
                $found = true;
                MoblogLogger::log("Blog '" . $blogInfo->getBlog() . "' found with id = '" . $blogInfo->getId() . "'");
            }
        }
        if (!$found) {
            $response = new MoblogResponse($request->getReplyTo(), "pLog Moblog: Error", "Incorrect blog.");
            MoblogLogger::log("Blog " . $request->getBlogId() . " does not exist.");
            $response->send();
            return false;
        }
    }
} else {
    $blogInfo = $blogs->getBlogInfo($request->getBlogId());
    if (!$blogInfo) {
        $response = new MoblogResponse($request->getReplyTo(), "pLog Moblog: Error", "Incorrect blog identifier.");
        MoblogLogger::log("Blog " . $request->getBlogId() . " is not valid.");
        $response->send();
        return false;
    }
}
//
// check if the plugin has been enabled for this blog
//
$blogSettings = $blogInfo->getSettings();
$pluginEnabled = $blogSettings->getValue("plugin_moblog_enabled");
if (!$pluginEnabled) {
    $response = new MoblogResponse($request->getReplyTo(), "pLog Moblog: Error", "The plugin has not been enabled for this blog.");
    MoblogLogger::log("Plugin not enabled for blog " . $request->getBlogId());
示例#9
0
function metaWeblogGetRecentPosts($args)
{
    global $users, $articles;
    /*
        "userid" =>
        "dateCreated" =>
        "content" =>
        "postid" =>
    */
    $blogid = $args[0];
    $username = $args[1];
    $password = $args[2];
    $number = $args[3];
    $erg = $users->getUserInfo($username, $password);
    if ($erg != false) {
        $ret = array();
        $list = $articles->getBlogArticles($blogid, -1, $number, 0, POST_STATUS_PUBLISHED);
        foreach ($list as $item) {
            $dateObject = $item->getDateObject();
            $time = $dateObject->getTimestamp();
            $time = mktime(substr($time, 8, 2), substr($time, 10, 2), substr($time, 12, 2), substr($time, 4, 2), substr($time, 6, 2), substr($time, 0, 4));
            $articleCat = $item->getCategory();
            $dummy = array();
            $dummy["userid"] = $item->_userInfo->_id;
            $dummy["dateCreated"] = new IXR_Date($time);
            $dummy["title"] = $item->_topic;
            $dummy["description"] = $item->_text;
            $dummy["postid"] = $item->_id;
            $blogId = $item->getBlog();
            $blogs = new Blogs();
            $blogInfo = $blogs->getBlogInfo($blogId);
            $url = $blogInfo->getBlogRequestGenerator();
            $dummy["link"] = $url->postLink($item);
            $dummy["permaLink"] = $url->postPermalink($item);
            $catArray = array();
            $catArray[] = $articleCat->getName();
            $dummy["categories"] = $catArray;
            $ret[] = $dummy;
        }
        return $ret;
    } else {
        return new IXR_Error(-1, 'You did not provide the correct password');
    }
}
 /**
  * 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;
 }
 /**
  * create the blog
  */
 function createBlog($userId)
 {
     $this->blogName = stripslashes($this->_request->getValue("blogName"));
     $this->blogLocale = $this->_request->getValue("blogLocale");
     $this->templateId = $this->_request->getValue("templateId");
     // get the default locale configured for the site
     $blogs = new Blogs();
     $blogInfo = new BlogInfo($this->blogName, $userId, "", "");
     if ($this->need_confirm == 1) {
         $blogInfo->setStatus(BLOG_STATUS_UNCONFIRMED);
     } else {
         $blogInfo->setStatus(BLOG_STATUS_ACTIVE);
     }
     $locale = Locales::getLocale($this->blogLocale);
     $blogInfo->setLocale($locale);
     $blogInfo->setTemplate($this->templateId);
     $newblogId = $blogs->addBlog($blogInfo);
     if (!$newblogId) {
         $this->_view = new SummaryView("registererror");
         $this->_view->setErrorMessage($this->_locale->tr("error_creating_blog"));
         return false;
     }
     // get info about the blog
     $blogInfo = $blogs->getBlogInfo($newblogId);
     $this->_blogInfo = $blogInfo;
     // if the blog was created, we can add some basic information
     // add a category
     $articleCategories = new ArticleCategories();
     $articleCategory = new ArticleCategory($locale->tr("register_default_category"), "", $newblogId, true);
     $catId = $articleCategories->addArticleCategory($articleCategory);
     // add an article based on that category
     $articleTopic = $locale->tr("register_default_article_topic");
     $articleText = $locale->tr("register_default_article_text");
     $article = new Article($articleTopic, $articleText, array($catId), $userId, $newblogId, POST_STATUS_PUBLISHED, 0, array(), "welcome");
     $article->setDateObject(new Timestamp());
     // set it to the current date
     $article->setCommentsEnabled(true);
     // enable comments
     $articles = new Articles();
     $articles->addArticle($article);
     return true;
 }