function perform() { // // update the plugin configurations to blog setting $blogSettings = $this->_blogInfo->getSettings(); $blogSettings->setValue("plugin_authimage_enabled", $this->_pluginEnabled); $blogSettings->setValue("plugin_authimage_length", $this->_length); $blogSettings->setValue("plugin_authimage_key", $this->_key); $blogSettings->setValue("plugin_authimage_expiredtime", $this->_expiredTime); $blogSettings->setValue("plugin_authimage_default", $this->_default); $this->_blogInfo->setSettings($blogSettings); // save the blogs settings $blogs = new Blogs(); if (!$blogs->updateBlog($this->_blogInfo->getId(), $this->_blogInfo)) { $this->_view = new PluginAuthImageConfigView($this->_blogInfo); $this->_view->setErrorMessage($this->_locale->tr("error_updating_settings")); $this->setCommonData(); return false; } // if everything went ok... $this->_blogInfo->setSettings($blogSettings); $this->_session->setValue("blogInfo", $this->_blogInfo); $this->saveSession(); $this->_view = new PluginAuthImageConfigView($this->_blogInfo); $this->_view->setSuccessMessage($this->_locale->tr("authimage_settings_saved_ok")); $this->setCommonData(); // clear the cache CacheControl::resetBlogCache($this->_blogInfo->getId()); return true; }
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; }
/** * Carries out the specified action */ function perform() { // // update the plugin configurations to blog setting $blogSettings = $this->_blogInfo->getSettings(); $blogSettings->setValue("plugin_moderate_enabled", $this->_pluginEnabled); $this->_blogInfo->setSettings($blogSettings); // save the blogs settings $blogs = new Blogs(); if (!$blogs->updateBlog($this->_blogInfo->getId(), $this->_blogInfo)) { $this->_view = new AdminModeratePluginSettingsView($this->_blogInfo); $this->_view->setErrorMessage($this->_locale->tr("error_updating_settings")); $this->setCommonData(); return false; } // if everything went ok... $this->_blogInfo->setSettings($blogSettings); $this->_session->setValue("blogInfo", $this->_blogInfo); $this->saveSession(); $this->_view = new AdminModeratePluginSettingsView($this->_blogInfo); $this->_view->setSuccessMessage($this->_locale->tr("moderate_settings_saved_ok")); $this->setCommonData(); // clear the cache CacheControl::resetBlogCache($this->_blogInfo->getId()); 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; }
/** * sends xmlrpc pings */ function sendXmlRpcPings() { // send the xmlrpc ping if (!$this->_config->getValue("xmlrpc_ping_enabled", false)) { return ""; } $blogs = new Blogs(); $resultArray = $blogs->updateNotify($this->_blogInfo); // check to prevent throwing an error if the list is empty if ($resultArray == "" || empty($resultArray)) { return ""; } foreach ($resultArray as $host => $result) { if ($result == "OK") { $message .= $this->_locale->tr("xmlrpc_ping_ok") . $host . ".<br/>"; } else { $message .= $this->_locale->tr("error_sending_xmlrpc_ping") . $host . "."; if ($result != "") { $message .= "<br/>" . $this->_locale->tr("error_sending_xmlrpc_ping_message") . $result . "."; } $message .= "<br/>"; } } return $message; }
function render() { // load the list of blogs $blogs = new Blogs(); $siteBlogs = $blogs->getAllBlogs(); $this->setValue('siteblogs', $siteBlogs); $this->setValue('userStatusList', UserStatus::getStatusList()); parent::render(); }
/** * returns the current quota allocated for a blog * * @param blogId * @return * @static */ function getBlogResourceQuota($blogId) { $blogs = new Blogs(); $blogSettings = $blogs->getBlogSettings($blogId); $blogQuota = $blogSettings->getValue("resources_quota"); if ($blogQuota == "") { $blogQuota = GalleryResourceQuotas::getGlobalResourceQuota(); } return $blogQuota; }
function test_insert_new_blog() { $blog = new Blogs(); $blog->blog_name = 'test1'; $blog->blog_author = 'wei'; $this->assertTrue($blog->save()); $blog->blog_name = 'test2'; $this->assertTrue($blog->save()); $check = Blogs::finder()->findByPk($blog->blog_id); $this->assertSameBlog($check, $blog); $this->assertTrue($blog->delete()); }
/** * resets all the caches in the site * @static * @return Always true */ function resetAllCaches() { // get a list of all the blogs $blogs = new Blogs(); $siteBlogs = $blogs->getAllBlogIds(); // and loop through them foreach ($siteBlogs as $blogId) { CacheControl::resetBlogCache($blogId, false); } // clear the cache used by the summary CacheControl::clearSummaryCache(); 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; }
/** * 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; }
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; }
public function run() { echo '<div class="popular-topics"> <div id="topics" class="gradient-bg"><span style="float:left; padding-top:5px; padding-left:10px;">Topics</span></div> <div class="popular-topics-content"> <ul>'; $criteria = new CDbCriteria(); $criteria->limit = 10; $criteria->order = 'created_date DESC'; $criteria->group = 'blog_post_under'; $BlogPostedUnder = Blogs::model()->findAll($criteria); foreach ($BlogPostedUnder as $posts) { $coutning = Blogs::model()->findAllByAttributes(array('blog_post_under' => $posts->blog_post_under)); $counts = count($coutning); if ($posts->type == "blogs") { echo '<div id="populartags">'; echo '<input type="hidden" id="blogid-' . $posts->blog_id . '" value="' . $posts->blog_id . '" />'; echo '<div class="orange-link"><a class="blue-link font-12px" onclick="showpost(' . $posts->blog_id . ')">' . ucfirst($posts->blog_post_under) . ' (' . $counts . ')</a></div>'; // echo "(".count($tagcount).")"; echo '<br>'; echo '</div>'; } } // $criteria->with = 'Blogs'; echo '</ul></div></div>'; }
function display_page_content() { ?> <h1>Choose Blog to Edit</h1> <div class="listhead"><label>Click Name to Edit</label>Associated User</div> <ul id="list_items"> <?php $blogs = Blogs::FindAll(); foreach ($blogs as $blog) { $user = Users::FindById($blog->user_id); ?> <li> <a href="<?php echo get_link("/admin/edit_blog/" . $blog->user_id); ?> "><?php echo $blog->name; ?> </a> <?php echo $user->email; ?> </li> <?php } ?> </ul> <?php }
/** * @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; }
/** * 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); } }
/** * 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; }
/** * Atualiza os dados de preferência do blog * @param string $blog_name nome do blog * @param string $blog_url url do blog * @param string $blog_mail email principal * @param string $blog_mail_password senha do email principal * @param bool $blog_send_mail Informa se o envio de email está ativo * @param string $blog_about pequeno texto sobre o blog * @return boolean true caso sucesso ou false caso de erro. */ public function updateBlog($blog_name, $blog_url, $blog_mail, $blog_mail_password, $blog_send_mail, $blog_about) { $blog = Blogs::findFirst(); $blog->blog_name = $blog_name; $blog->blog_url = $blog_url; $blog->blog_mail = $blog_mail; $blog->blog_mail_password = $blog_mail_password; $blog->blog_send_mail = $blog_send_mail; $blog->blog_about = $blog_about; return $blog->save(); }
function perform() { // save the settings $blogSettings = $this->_blogInfo->getSettings(); $blogSettings->setValue("plugin_moblog_article_category_id", $this->_categoryId); $blogSettings->setValue("plugin_moblog_gallery_resource_album_id", $this->_albumId); $blogSettings->setValue("plugin_moblog_resource_preview_type", $this->_previewType); $blogSettings->setValue("plugin_moblog_enabled", $this->_pluginEnabled); // update the settings in the database *and* in the session, otherwise we will // keep using the old settings!! $blogs = new Blogs(); $this->_blogInfo->setSettings($blogSettings); $blogs->updateBlogSettings($this->_blogInfo->getId(), $this->_blogInfo->getSettings()); $this->_session->setValue("blogInfo", $this->_blogInfo); $this->saveSession(); // show an informative message $this->_view = new AdminMoblogPluginSettingsView($this->_blogInfo, $this->_userInfo); $this->_view->setSuccessMessage($this->_locale->tr("atom_plugin_settings_saved_ok")); $this->setCommonData(); return true; }
function AdminBlogSettingsView($blogInfo) { $this->AdminTemplatedView($blogInfo, "blogsettings"); $blogs = new Blogs(); $blogSettings = $blogs->getBlogSettings($this->_blogInfo->getId()); $this->setValue("blogAbout", $this->_blogInfo->getAbout()); $this->setValue("blogName", $this->_blogInfo->getBlog()); $this->setValue("blogLocale", $blogSettings->getValue("locale")); $this->setValue("blogMaxRecentItems", $blogSettings->getValue("recent_posts_max")); $this->setValue("blogMaxMainPageItems", $blogSettings->getValue("show_posts_max")); $this->setValue("blogTemplate", $blogSettings->getValue("template")); $this->setValue("blogTimeOffset", $blogSettings->getValue("time_offset")); $this->setValue("blogCategoriesOrder", $blogSettings->getValue("categories_order")); $this->setValue("blogLinkCategoriesOrder", $blogSettings->getValue("link_categories_order")); $this->setValue("blogShowMoreEnabled", $blogSettings->getValue("show_more_enabled")); $this->setValue("blogEnableHtmlarea", $blogSettings->getValue("htmlarea_enabled")); $this->setValue("blogCommentsEnabled", $blogSettings->getValue("comments_enabled")); $this->setValue("blogShowFuturePosts", $blogSettings->getValue("show_future_posts_in_calendar")); $this->setValue("blogEnableAutosaveDrafts", $blogSettings->getValue("new_drafts_autosave_enabled")); $this->setValue("blogCommentsOrder", $blogSettings->getValue("comments_order")); }
function render() { // do nothing if the contents of our view are cached if ($this->isCached()) { parent::render(); return true; } // get the data itself $blogs = new Blogs(); $siteBlogs = $blogs->getAllBlogs(BLOG_STATUS_ACTIVE, $this->_page, $this->_numBlogsPerPage); $numBlogs = $blogs->getNumBlogs(BLOG_STATUS_ACTIVE); if (!$siteBlogs) { // if there was an error, show the error view $siteBlogs = array(); } // calculate the links to the different pages $pager = new Pager("?op=BlogList&page=", $this->_page, $numBlogs, $this->_numBlogsPerPage); $this->setValue("blogs", $siteBlogs); $this->setValue("pager", $pager); // let the parent view do its job parent::render(); }
function render() { // we need to get all the blogs // get the data itself $this->_status = $this->getStatusFromRequest(); $blogs = new Blogs(); $siteBlogs = $blogs->getAllBlogs($this->_status, $this->_page, DEFAULT_ITEMS_PER_PAGE); $numBlogs = $blogs->getNumBlogs($this->_status); if (!$siteBlogs) { $siteBlogs = array(); } // throw the right event $this->notifyEvent(EVENT_BLOGS_LOADED, array("blogs" => &$siteBlogs)); // calculate the links to the different pages $pager = new Pager("?op=editSiteBlogs&status=" . $this->_status . "&page=", $this->_page, $numBlogs, DEFAULT_ITEMS_PER_PAGE); $this->setValue("siteblogs", $siteBlogs); $this->setValue("pager", $pager); $this->setValue("currentstatus", $this->_status); $this->setValue("blogstatus", BlogStatus::getStatusList(true)); // let the parent view do its job parent::render(); }
/** * Loads the posts and shows them. */ function perform() { $this->_view = new SummaryCachedView("index", array("summary" => "default", "locale" => $this->_locale->getLocaleCode())); if ($this->_view->isCached()) { // if the view is already cached... move along! nothing to see here return true; } $blogs = new Blogs(); $stats = new SummaryStats(); // load the posts, filtering out all those registration messages... $registerTopic = $this->_locale->tr("register_default_article_topic"); $registerText = $this->_locale->tr("register_default_article_text"); $recentPosts = $stats->getRecentArticles($this->_numPosts, $registerTopic, $registerText); // get all the blogs $siteBlogs = $blogs->getAllBlogs(true); $recentBlogs = $stats->getRecentBlogs($this->_numPosts); $activeBlogs = $stats->getMostActiveBlogs($this->_numPosts); $commentedPosts = $stats->getMostCommentedArticles($this->_numPosts, $registerTopic, $registerText); $readestBlogs = $stats->getMostReadArticles($this->_numPosts, $registerTopic, $registerText); // export all these things to the view $this->_view->setValue("posts", $recentPosts); $this->_view->setValue("recentBlogs", $recentBlogs); $this->_view->setValue("activeBlogs", $activeBlogs); $this->_view->setValue("commentedPosts", $commentedPosts); $this->_view->setValue("readestBlogs", $readestBlogs); $this->_view->setValue("blogs", $siteBlogs); // // :KLUDGE: // we just need a random blog so... we'll get one :) // $randomBlog = array_pop($siteBlogs); $url = $randomBlog->getBlogRequestGenerator(); $this->_view->setValue("url", $url); $this->setCommonData(); return true; }
/** * Returns an array of BlogInfo objects with the information of all the blogs to which * a user belongs * * @param userId Identifier of the user * @return An array of BlogInfo objects to whom the user belongs. */ function getUsersBlogs($userid, $status = BLOG_STATUS_ALL) { $usersBlogs = array(); $blogs = new Blogs(); $ids = array(); // check if the user is the owner of any blog $prefix = $this->getPrefix(); $owner = "SELECT * FROM {$prefix}blogs WHERE owner_id = " . $userid; if ($status != BLOG_STATUS_ALL) { $owner .= " AND status = '" . Db::qstr($status) . "'"; } $result = $this->Execute($owner); while ($row = $result->FetchRow($result)) { $usersBlogs[] = $blogs->_fillBlogInformation($row); $ids[] = $row["id"]; } // and now check to which other blogs he or she belongs $otherBlogs = "SELECT b.* FROM {$prefix}blogs b, {$prefix}users_permissions p \n WHERE p.user_id = '" . Db::qstr($userid) . "' AND b.id = p.blog_id"; if (!empty($usersBlogs)) { $blogIds = implode(",", $ids); $otherBlogs .= " AND p.blog_id NOT IN (" . $blogIds . ")"; } if ($status != BLOG_STATUS_ALL) { $otherBlogs .= " AND b.status = '" . Db::qstr($status) . "'"; } $result = $this->Execute($otherBlogs); // now we know to which he or she belongs, so we only have // to load the information about those blogs while ($row = $result->FetchRow($result)) { $usersBlogs[] = $blogs->_fillBlogInformation($row); } return $usersBlogs; }
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; }
$tf = new TextFilter(); $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();
function perform() { // retrieve the values from the view $this->_blogName = $this->_request->getValue("blogName"); $this->_ownerId = $this->_request->getValue("ownerid"); $this->_blogProperties = $this->_request->getValue("properties"); $this->_blogTemplate = $this->_request->getValue("blogTemplate"); $this->_blogLocale = $this->_request->getValue("blogLocale"); // configure the blog $blogs = new Blogs(); $blog = new BlogInfo($this->_blogName, $this->_ownerId, "", ""); $blog->setProperties($this->_blogProperties); $blog->setStatus(BLOG_STATUS_ACTIVE); $blogSettings = $blog->getSettings(); $blogSettings->setValue("locale", $this->_blogLocale); $blogSettings->setValue("template", $this->_blogTemplate); $blog->setSettings($blogSettings); // and now save it to the database $newblogId = $blogs->addBlog($blog); if (!$newblogId) { $this->_view = new WizardView("step4"); $this->_view->setValue("siteLocales", Locales::getLocales()); $ts = new TemplateSets(); $this->_view->setValue("siteTemplates", $ts->getGlobalTemplateSets()); $this->_view->setErrorMessage("There was an error creating the new blog"); $this->setCommonData(true); return false; } // if the blog was created, we can add some basic information // add a category $articleCategories = new ArticleCategories(); $articleCategory = new ArticleCategory("General", "", $newblogId, true); $catId = $articleCategories->addArticleCategory($articleCategory); // load the right locale $locale =& Locales::getLocale($this->_blogLocale); // and load the right text $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); // save a few things in the default configuration $config =& Config::getConfig(); // default blog id $config->saveValue("default_blog_id", (int) $newblogId); // default locale $config->saveValue("default_locale", $this->_blogLocale); // and finally, the default template $config->saveValue("default_template", $this->_blogTemplate); // // detect wether we have GD available and set the blog to use it // if (GdDetector::detectGd()) { $config->saveValue("thumbnail_method", "gd"); $message = "GD has been detected and set as the backend for dealing with images."; } else { $pathToConvert = $config->getValue("path_to_convert"); if ($pathToConvert) { $config->saveValue("thumbnail_method", "imagemagick"); $message = "ImageMagick has been detected and set as the backend for dealing with images."; } else { // nothing was found, so we'll have to do away with the 'null' resizer... $config->saveValue("thumbnail_method", "null"); $message = "Neither GD nor ImageMagick have been detected in this host so it will not be possible to generate thumbnails from images."; } } $this->_view = new WizardView("step5"); $this->_view->setValue("message", $message); return true; }
/** */ function getViewedTotal() { if ($this->_viewedTotal == null) { $blogs = new Blogs(); $this->_viewedTotal = $blogs->getBlogViewedTotal($this->getId()); } return $this->_viewedTotal; }
<?php foreach ($comments as $eachcmnt) { ?> <?php $var = Yii::app()->session['login']['id']; ?> <?php $blogid = Blogs::model()->findAllByAttributes(array('blog_id' => $eachcmnt->goal_id)); foreach ($blogid as $blogtype) { ?> <!------------------------------ Start of Blog Comments ----------------------> <?php if ($blogtype->type == "blogs") { ?> <div class="comment-tab" style="position:relative;"> <div class="comment-tab-left"><img src="<?php echo $eachcmnt->commentAuthor->profile_image != "" ? Yii::app()->baseUrl . "/images/uploads/parentimages/" . $eachcmnt->commentAuthor->profile_image : Yii::app()->baseUrl . "/images/default-photo.png"; ?> " width="25"/></div> <div class="comment-tab-right"> <div class="run-text font-12px"><span class="blue-font12"><?php $name = $eachcmnt->commentAuthor->fname . ' ' . $eachcmnt->commentAuthor->lname; echo $name; ?>  commented as:</span></br> <span class="blue-font11"> <?php
// first, try to authenticate the user // $users = new Users(); $userInfo = $users->getUserInfo($request->getUser(), $request->getPassword()); if (!$userInfo) { $response = new MoblogResponse($request->getReplyTo(), "pLog Moblog: Error", "User or password are not correct."); MoblogLogger::log("User " . $request->getUser() . " did not authenticate correctly."); $response->send(); return false; } // // if user was authenticated, then proceed... and the first thing we should do // is see if the blog id is correct and if the user has permissions in that // blog // $blogs = new Blogs(); if ($request->getBlogId() == "") { // user gave a blog name instead of a blog id $allBlogs = $blogs->getAllBlogs(); if ($allBlogs) { $found = false; $blogName = stripslashes($request->getBlogName()); 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.");