function _addJournal($data, $_debug) { // blog, $owner, $about, $settings, $id = -1 * <li>locale</li> if ($data["name"] == NULL) { $data["name"] = "Journal"; } if ($data["owner"] == NULL) { $data["owner"] = 1; } if ($data["about"] == NULL) { $data["about"] = "About..."; } // if ($data["blog_id"] == NULL) $data["blog_id"] = NULL; /* Individual Blog Settings have been disabled in favor of using the BlogSettings::_setDefaults() method to generate preferences based on admin settings. if ($data["locale"] == NULL) $data["locale"] = "EN_UK"; if ($data["template"] == NULL) $data["template"] = "blueish"; if ($data["show_more"] == NULL) $data["show_more"] = 0; if ($data["threshold"] == NULL) $data["threshold"] = 50; if ($data["recent"] == NULL) $data["recent"] = 10; if ($data["xmlrpc"] == NULL) $data["xmlrpc"] = 0; if ($data["htmlarea"] == NULL) $data["htmlarea"] = 1; if ($data["comments"] == NULL) $data["comments"] = 1; if ($data["order"] == NULL) $data["order"] = 1; */ $blogs = new Blogs(); if ($data["blog_id"]) { $blog = $blogs->getBlogInfoByName(TextFilter::urlize($data["name"])); if ($blog) { if ($blog->getId() == $data["blog_id"]) { if ($_debug) { print "--- --- blog " . $blog->getBlog() . " already exists at the proper id (" . $blog->getId() . "). next entry.<br />\n\r"; } return $blog->getId(); } else { if ($_debug) { print "--- --- blog " . $blog->getBlog() . " already exists, but at a new id (" . $blog->getId() . "). skip to remap.<br />\n\r"; } $blog_id = $blog->getId(); } } } if (!$blog_id) { $blog = new BlogInfo($data["name"], $data["owner"], $data["about"], "", $data["blog_id"]); $blog_id = $blogs->addBlog($blog); if ($_debug) { print "--- blog " . $blog->getBlog() . " created at a new id (" . $blog_id . "). proceed to remap.<br />\n\r"; } $this->_stats["blogs"]["write"]++; } // remap categories foreach ($this->_t_container["categories"] as $category => $val) { if ($val["blog_id"] == $data["blog_id"] || $val["blog_id"] == NULL) { if ($_debug) { print "--- --- --- remapping category #" . $category . " to the proper blog id.<br />\n\r"; } $this->_container["categories"][$category]["blog_id"] = $blog_id; } } // remap articles foreach ($this->_t_container["posts"] as $post => $val) { if ($val["blog_id"] == $data["blog_id"] || $val["blog_id"] == NULL) { if ($_debug) { print "--- --- --- remapping post #" . $post . " to the proper blog id.<br />\n\r"; } $this->_container["posts"][$post]["blog_id"] = $blog_id; } } return $blog_id; }
/** * 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); } }