function perform()
 {
     // fetch the data
     $this->_ip1 = $this->_request->getValue("ip1");
     $this->_ip2 = $this->_request->getValue("ip2");
     $this->_ip3 = $this->_request->getValue("ip3");
     $this->_ip4 = $this->_request->getValue("ip4");
     $this->_hostIp = $this->_ip1 . "." . $this->_ip2 . "." . $this->_ip3 . "." . $this->_ip4;
     $this->_mask = $this->_request->getValue("mask");
     $this->_blockType = $this->_request->getValue("blockType");
     $this->_reason = $this->_request->getValue("reason");
     // create the dao object and add the info to the db
     $blockedHosts = new BlockedHosts();
     $t = new Timestamp();
     $blockedHost = new BlockedHost($this->_hostIp, $this->_mask, $this->_reason, $t->getTimestamp(), GLOBALLY_BLOCKED_HOST, $this->_blockType, BLOCK_BLACKLIST);
     $this->notifyEvent(EVENT_PRE_BLOCK_HOST_ADD, array("host" => &$blockedHost));
     $result = $blockedHosts->add($blockedHost);
     // and give some feedback to the user
     if (!$result) {
         $this->_view = new AdminNewBlockedHostView($this->_blogInfo);
         $this->_view->setErrorMessage($this->_locale->tr("error_adding_blocked_host"));
         $this->setCommonData();
         return false;
     }
     $this->notifyEvent(EVENT_POST_BLOCK_HOST_ADD, array("host" => &$blockedHost));
     $this->_view = new AdminBlockedHostsView($this->_blogInfo);
     $this->_view->setSuccessMessage($this->_locale->tr("blocked_host_updated_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;
 }
 /**
  * Performs the action.
  */
 function perform()
 {
     // fetch the articles for the given blog
     $articles = new Articles();
     $blogSettings = $this->_blogInfo->getSettings();
     $localeCode = $blogSettings->getValue("locale");
     // fetch the default profile as chosen by the administrator
     $defaultProfile = $this->_config->getValue("default_rss_profile");
     if ($defaultProfile == "" || $defaultProfile == null) {
         $defaultProfile = DEFAULT_PROFILE;
     }
     // fetch the profile
     // if the profile specified by the user is not valid, then we will
     // use the default profile as configured
     $profile = $this->_request->getValue("profile");
     if ($profile == "") {
         $profile = $defaultProfile;
     }
     // fetch the category, or set it to '0' otherwise, which will mean
     // fetch all the most recent posts from any category
     $categoryId = $this->_request->getValue("categoryId");
     if (!is_numeric($categoryId)) {
         $categoryId = 0;
     }
     // check if the template is available
     $this->_view = new RssView($this->_blogInfo, $profile, array("profile" => $profile, "categoryId" => $categoryId));
     // do nothing if the view was already cached
     if ($this->_view->isCached()) {
         return true;
     }
     // create an instance of a locale object
     $locale = Locales::getLocale($localeCode);
     // fetch the posts, though we are going to fetch the same amount in both branches
     $amount = $blogSettings->getValue("recent_posts_max", 15);
     $t = new Timestamp();
     if ($blogSettings->getValue('show_future_posts_in_calendar')) {
         $blogArticles = $articles->getBlogArticles($this->_blogInfo->getId(), -1, $amount, $categoryId, POST_STATUS_PUBLISHED, 0);
     } else {
         $today = $t->getTimestamp();
         $blogArticles = $articles->getBlogArticles($this->_blogInfo->getId(), -1, $amount, $categoryId, POST_STATUS_PUBLISHED, 0, $today);
     }
     $pm =& PluginManager::getPluginManager();
     $pm->setBlogInfo($this->_blogInfo);
     $pm->setUserInfo($this->_userInfo);
     $result = $pm->notifyEvent(EVENT_POSTS_LOADED, array('articles' => &$blogArticles));
     $articles = array();
     foreach ($blogArticles as $article) {
         $postText = $article->getIntroText();
         $postExtendedText = $article->getExtendedText();
         $pm->notifyEvent(EVENT_TEXT_FILTER, array("text" => &$postText));
         $pm->notifyEvent(EVENT_TEXT_FILTER, array("text" => &$postExtendedText));
         $article->setIntroText($postText);
         $article->setExtendedText($postExtendedText);
         array_push($articles, $article);
     }
     $this->_view->setValue("locale", $locale);
     $this->_view->setValue("posts", $articles);
     $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;
 }
 /**
  * Creates a new FilteredContent object
  *
  * @param regExp the regular expression
  * @param blogId The blog identifier to which this rule belongs
  * @param reason Why this rule has been set-up
  * @param date When this rule was added
  * @param id Identifier of this rule
  */
 function FilteredContent($regExp, $blogId, $reason, $date = null, $id = -1)
 {
     $this->Object();
     $this->_regExp = $regExp;
     $this->_blogId = $blogId;
     $this->_reason = $reason;
     if ($date == null) {
         $t = new Timestamp();
         $this->_date = $t->getTimestamp();
     } else {
         $this->_date = $date;
     }
     $this->_id = $id;
 }
 /**
  * Adds a comment to an article
  *
  * @param comment the UserComment object that we're going to add.
  * @return Returns true if successful or false if error. Also in case of success, it will modify the UserComment
  * object passed by reference and include its new id.
  */
 function addComment(&$comment)
 {
     $filter = new Textfilter();
     $t = new Timestamp();
     $timeStamp = $t->getTimestamp();
     $query = "INSERT INTO " . $this->getPrefix() . "articles_comments (article_id,topic,text,user_name,user_email,\n\t\t\t\t\t                      user_url,parent_id,client_ip,status,date,normalized_text,normalized_topic) \n\t\t\t\t\t   VALUES (" . $comment->getArticleId() . ",'" . Db::qstr($comment->getTopic()) . "','" . Db::qstr($comment->getText()) . "','" . Db::qstr($comment->getUserName()) . "','" . Db::qstr($comment->getUserEmail()) . "','" . Db::qstr($comment->getUserUrl()) . "'," . $comment->getParentId() . ", '" . $comment->getClientIp() . "', " . $comment->getStatus() . "," . $timeStamp . ",'" . Db::qstr($filter->normalizeText($comment->getText())) . "', '" . Db::qstr($filter->normalizeText($comment->getTopic())) . "');";
     $result = $this->Execute($query);
     if (!$result) {
         return false;
     }
     // retrieve the last id and save it in the object
     $comment->setId($this->_db->Insert_ID());
     return true;
 }
 /**
  * Carries out the specified action
  */
 function perform()
 {
     // if we're blocking a single host, then the mask should be
     // as long as 32 bits
     $blockedHosts = new BlockedHosts();
     $t = new Timestamp();
     $blockedHost = new BlockedHost($this->_host, 32, "Host blocked from posting", $t->getTimestamp(), $this->_blogInfo->getId(), BLOCK_COMMENT_POSTING, BLOCK_BLACKLIST);
     $result = $blockedHosts->add($blockedHost);
     // if there was an error, let the user know about it...
     if (!$result) {
         $this->_view = new AdminErrorView($this->_blogInfo);
         $this->_view->setMessage("There was an error adding this host to the list of blocked hosts.");
         $this->setCommonData();
         return false;
     }
     $this->_view = new AdminMessageView($this->_blogInfo);
     $this->_view->setMessage("Host " . $this->_host . " blocked from posting comments successfully.");
     $this->setCommonData();
     // better to return true if everything fine
     return true;
 }
Esempio n. 8
0
 function timespan(Timestamp $other)
 {
     $other_ts = $other->getTimestamp();
     return new Timespan($this->getTimestamp() - $other_ts);
 }
Esempio n. 9
0
    $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();
// and also configure the BlogInfo and UserInfo objects so that they know
// who threw the events...
$pm->setBlogInfo($blogInfo);
$userInfo = $blogInfo->getOwnerInfo();
$pm->setUserInfo($userInfo);
// receives the request and adds it to the database
$trackbacks = new TrackBacks();
// create teh trackback object
$now = new Timestamp();
$trackback = new Trackback($url, $title, $articleId, $excerpt, $blogName, $now->getTimestamp());
// throw the event in case somebody is listening to it!
$pm->notifyEvent(EVENT_PRE_TRACKBACK_ADD, array("trackback" => &$trackback));
$result = $trackbacks->addTrackBack($trackback);
if (!$result) {
    trackbackLog("There was an error saving the trackback!");
}
// throw the post event too...
$pm->notifyEvent(EVENT_POST_TRACKBACK_ADD, array("trackback" => &$trackback));
// result
$result = '<?xml version="1.0" encoding="iso-8859-1"?>';
$result .= '<response>';
$result .= '<error>0</error>';
$result .= '</response>';
// notify the user that a new trackback has been received, if the article was
// configured to receive notifications
 /**
  * Converts a date string to a timestamp.
  * @param string $value the date string to be parsed
  * @param string $pattern the pattern that the date string is following
  * @param array $defaults the default values for year, month, day, hour, minute and second.
  * The default values will be used in case when the pattern doesn't specify the
  * corresponding fields. For example, if the pattern is 'MM/dd/yyyy' and this
  * parameter is array('minute'=>0, 'second'=>0), then the actual minute and second
  * for the parsing result will take value 0, while the actual hour value will be
  * the current hour obtained by date('H'). This parameter has been available since version 1.1.5.
  * @return integer timestamp for the date string. False if parsing fails.
  */
 public static function parse($value, $pattern = 'MM/dd/yyyy', $defaults = array())
 {
     $tokens = self::tokenize($pattern);
     $i = 0;
     $n = strlen($value);
     foreach ($tokens as $token) {
         switch ($token) {
             case 'yyyy':
                 if (($year = self::parseInteger($value, $i, 4, 4)) === false) {
                     return false;
                 }
                 $i += 4;
                 break;
             case 'yy':
                 if (($year = self::parseInteger($value, $i, 1, 2)) === false) {
                     return false;
                 }
                 $i += strlen($year);
                 break;
             case 'MM':
                 if (($month = self::parseInteger($value, $i, 2, 2)) === false) {
                     return false;
                 }
                 $i += 2;
                 break;
             case 'M':
                 if (($month = self::parseInteger($value, $i, 1, 2)) === false) {
                     return false;
                 }
                 $i += strlen($month);
                 break;
             case 'dd':
                 if (($day = self::parseInteger($value, $i, 2, 2)) === false) {
                     return false;
                 }
                 $i += 2;
                 break;
             case 'd':
                 if (($day = self::parseInteger($value, $i, 1, 2)) === false) {
                     return false;
                 }
                 $i += strlen($day);
                 break;
             case 'h':
             case 'H':
                 if (($hour = self::parseInteger($value, $i, 1, 2)) === false) {
                     return false;
                 }
                 $i += strlen($hour);
                 break;
             case 'hh':
             case 'HH':
                 if (($hour = self::parseInteger($value, $i, 2, 2)) === false) {
                     return false;
                 }
                 $i += 2;
                 break;
             case 'm':
                 if (($minute = self::parseInteger($value, $i, 1, 2)) === false) {
                     return false;
                 }
                 $i += strlen($minute);
                 break;
             case 'mm':
                 if (($minute = self::parseInteger($value, $i, 2, 2)) === false) {
                     return false;
                 }
                 $i += 2;
                 break;
             case 's':
                 if (($second = self::parseInteger($value, $i, 1, 2)) === false) {
                     return false;
                 }
                 $i += strlen($second);
                 break;
             case 'ss':
                 if (($second = self::parseInteger($value, $i, 2, 2)) === false) {
                     return false;
                 }
                 $i += 2;
                 break;
             case 'a':
                 if (($ampm = self::parseAmPm($value, $i)) === false) {
                     return false;
                 }
                 if (isset($hour)) {
                     if ($hour == 12 && $ampm === 'am') {
                         $hour = 0;
                     } else {
                         if ($hour < 12 && $ampm === 'pm') {
                             $hour += 12;
                         }
                     }
                 }
                 $i += 2;
                 break;
             default:
                 $tn = strlen($token);
                 if ($i >= $n || substr($value, $i, $tn) !== $token) {
                     return false;
                 }
                 $i += $tn;
                 break;
         }
     }
     if ($i < $n) {
         return false;
     }
     if (!isset($year)) {
         $year = isset($defaults['year']) ? $defaults['year'] : date('Y');
     }
     if (!isset($month)) {
         $month = isset($defaults['month']) ? $defaults['month'] : date('n');
     }
     if (!isset($day)) {
         $day = isset($defaults['day']) ? $defaults['day'] : date('j');
     }
     if (strlen($year) === 2) {
         if ($year >= 70) {
             $year += 1900;
         } else {
             $year += 2000;
         }
     }
     $year = (int) $year;
     $month = (int) $month;
     $day = (int) $day;
     if (!isset($hour) && !isset($minute) && !isset($second) && !isset($defaults['hour']) && !isset($defaults['minute']) && !isset($defaults['second'])) {
         $hour = $minute = $second = 0;
     } else {
         if (!isset($hour)) {
             $hour = isset($defaults['hour']) ? $defaults['hour'] : date('H');
         }
         if (!isset($minute)) {
             $minute = isset($defaults['minute']) ? $defaults['minute'] : date('i');
         }
         if (!isset($second)) {
             $second = isset($defaults['second']) ? $defaults['second'] : date('s');
         }
         $hour = (int) $hour;
         $minute = (int) $minute;
         $second = (int) $second;
     }
     if (Timestamp::isValidDate($year, $month, $day) && Timestamp::isValidTime($hour, $minute, $second)) {
         return Timestamp::getTimestamp($hour, $minute, $second, $month, $day, $year);
     } else {
         return false;
     }
 }
Esempio n. 11
0
 /**
  * Format time according to the rules of this language.
  * This function is NOT threadsafe!
  * @param Timestamp $time
  * @param int $long default false
  * @return string;
  */
 public function formatTime(Timestamp $time, $long = false)
 {
     $oldlocale = setlocale(LC_TIME, $this->locale());
     $date = strftime($long ? $this->longTimeFormat() : $this->timeFormat(), $time->getTimestamp());
     setlocale(LC_TIME, $oldlocale);
     return $date;
 }
 /**
  * Executes the action
  */
 function perform()
 {
     // first of all, we have to determine which blog we would like to see
     $blogId = $this->_blogInfo->getId();
     // fetch the settings for that blog
     $blogSettings = $this->_blogInfo->getSettings();
     // prepare the view
     $this->_view = new DefaultView($this->_blogInfo, array("categoryId" => $this->_categoryId, "blogId" => $this->_blogInfo->getId(), "categoryName" => $this->_categoryName, "date" => $this->_date, "userName" => $this->_userName, "userId" => $this->_userId));
     // check if everything's cached because if it is, then we don't have to
     // do any work... it's already been done before and we should "safely" assume
     // that there hasn't been any change so far
     if ($this->_view->isCached()) {
         return true;
     }
     // if we got a category name instead of a category id, then we
     // should first look up this category in the database and see if
     // it exists
     $categories = new ArticleCategories();
     if ($this->_categoryName) {
         $category = $categories->getCategoryByName($this->_categoryName, $this->_blogInfo->getId());
         if (!$category) {
             $this->_view = new ErrorView($this->_blogInfo);
             $this->_view->setValue('message', "error_incorrect_category_id");
             $this->setCommonData();
             return false;
         }
         // if everything went fine...
         $this->_categoryId = $category->getId();
     } else {
         // we don't do anything if the cateogry id is '0' or '-1'
         if ($this->_categoryId > 0) {
             $category = $categories->getCategory($this->_categoryId, $this->_blogInfo->getId());
             if (!$category) {
                 $this->_view = new ErrorView($this->_blogInfo);
                 $this->_view->setValue('message', "error_incorrect_category_id");
                 $this->setCommonData();
                 return false;
             }
         }
     }
     // export the category object in case it is needed
     if (isset($category)) {
         $this->_view->setValue("category", $category);
     }
     $users = new Users();
     // if we got a user user id, then we should first look up this id
     // user in the database and see if it exists
     if ($this->_userId > 0) {
         $user = $users->getUserInfoFromId($this->_userId);
         if (!$user) {
             $this->_view = new ErrorView($this->_blogInfo);
             $this->_view->setValue('message', 'error_incorrect_user_id');
             $this->setCommonData();
             return false;
         }
     } else {
         if ($this->_userName) {
             // if we got a user name instead of a user id, then we
             // should first look up this user in the database and see if
             // it exists
             $user = $users->getUserInfoFromUsername($this->_userName);
             if (!$user) {
                 $this->_view = new ErrorView($this->_blogInfo);
                 $this->_view->setValue('message', 'error_incorrect_user_username');
                 $this->setCommonData();
                 return false;
             }
             // if everything went fine...
             $this->_userId = $user->getId();
         }
     }
     // export the owner. The owner information should get from blogInfo directly
     $this->_view->setValue("owner", $this->_blogInfo->getOwnerInfo());
     $t = new Timestamp();
     $todayTimestamp = $t->getTimestamp();
     // amount of posts that we have to show, but keeping in mind that when browsing a
     // category or specific date, we should show *all* of them
     if ($this->_date > 0 || $this->_categoryId > 0) {
         $this->_postAmount = -1;
         // also, inform the template that we're showing them all!
         $this->_view->setValue('showAll', true);
     } else {
         $this->_postAmount = $blogSettings->getValue('show_posts_max');
         $this->_view->setValue('showAll', false);
     }
     //
     // :KLUDGE:
     // the more things we add here to filter, the more complicated this function
     // gets... look at this call and look at how many parameters it needs!! :(
     //
     if ($blogSettings->getValue('show_future_posts_in_calendar') && $this->_date > -1) {
         // if posts in the future are to be shown, we shouldn't set a maximum date
         $blogArticles = $this->articles->getBlogArticles($blogId, $this->_date, $this->_postAmount, $this->_categoryId, POST_STATUS_PUBLISHED, $this->_userId);
     } else {
         $blogArticles = $this->articles->getBlogArticles($blogId, $this->_date, $this->_postAmount, $this->_categoryId, POST_STATUS_PUBLISHED, $this->_userId, $todayTimestamp);
     }
     // if we couldn't fetch the articles, send an error and quit
     if (count($blogArticles) == 0) {
         $this->_view = new ErrorView($this->_blogInfo);
         $this->_view->setValue('message', 'error_fetching_articles');
     } else {
         // otherwise, continue
         // the view will take care of cutting the post if we have the "show more"
         // feature enabled or not... we could do it here but I think that belongs
         // to the view since it is presentation stuff... It could also be handled
         // by the template but then it'd make the template a little bit more
         // complicated...
         // ---
         // before finishing, let's see if there's any plugin that would like to do
         // anything with the post that we just loaded
         // ---
         $pm =& PluginManager::getPluginManager();
         $pm->setBlogInfo($this->_blogInfo);
         $pm->setUserInfo($this->_userInfo);
         $result = $pm->notifyEvent(EVENT_POSTS_LOADED, array('articles' => &$blogArticles));
         $articles = array();
         foreach ($blogArticles as $article) {
             $postText = $article->getIntroText();
             $postExtendedText = $article->getExtendedText();
             $pm->notifyEvent(EVENT_TEXT_FILTER, array("text" => &$postText));
             $pm->notifyEvent(EVENT_TEXT_FILTER, array("text" => &$postExtendedText));
             $article->setIntroText($postText);
             $article->setExtendedText($postExtendedText);
             array_push($articles, $article);
         }
         $this->_view->setValue('posts', $articles);
     }
     $this->setCommonData();
     // save the information about the session for later
     $this->saveSession();
     return true;
 }
 /**
  * returns a list with the most recent articles, but only one per blog so that
  * one blog cannot clog the whole main page because they've posted 100 posts today. Posts that were posted
  * in categories not shown in the main page of each blog will not be shown!
  *
  * @param maxPosts The maximum number of posts to return
  * @param ignoreTopic ignore posts based on a certain topic
  * @param ignoreText ignore post based on a certain text
  * @return An array of Article objects with the most recent articles.
  */
 function getRecentArticles($maxPosts, $ignoreTopic = "", $ignoreText = "")
 {
     include_once PLOG_CLASS_PATH . "class/data/timestamp.class.php";
     include_once PLOG_CLASS_PATH . "class/dao/articles.class.php";
     $t = new Timestamp();
     $date = $t->getTimestamp();
     $prefix = $this->getPrefix();
     $query = "SELECT a.id as id, a.id,a.date,\n                             a.user_id,a.blog_id, a.status, a.properties,\n                             a.num_reads, a.slug\n\t\t\t\t\t  FROM {$prefix}articles a, \n\t\t\t\t\t       {$prefix}blogs b\n\t\t\t\t\t  WHERE a.date >= " . $this->_sevenDaysAgo . " AND a.date <= " . $this->_now . "\n\t\t\t\t\t        AND a.blog_id = b.id\n\t\t\t\t\t        AND b.status = " . BLOG_STATUS_ACTIVE . "\n\t\t\t\t\t        AND a.status = " . POST_STATUS_PUBLISHED;
     $query .= " ORDER BY a.date DESC LIMIT 0, {$maxPosts}";
     $result = $this->Execute($query);
     if (!$result) {
         return array();
     }
     $blogs = array();
     $posts = array();
     $i = 0;
     while (($row = $result->FetchRow()) && $i < $maxPosts) {
         if (!in_array($row["blog_id"], $blogs)) {
             $blogs[] = $row["blog_id"];
             array_push($posts, $this->articles->_fillArticleInformation($row));
             $i++;
         }
     }
     $result->Close();
     return $posts;
 }
 /**
  * Creates a new user comment.
  */
 function UserComment($artid, $parentid, $topic, $text, $date = null, $userName = "", $userEmail = "", $userUrl = "", $clientIp = "0.0.0.0", $spamRate = 0, $status = COMMENT_STATUS_NONSPAM, $id = -1)
 {
     $this->Object();
     $this->_topic = $topic;
     $this->_text = $text;
     $this->_artid = $artid;
     $this->_parentid = $parentid;
     $this->_userName = $userName;
     $this->_userEmail = $userEmail;
     $this->setUserUrl($userUrl);
     $this->_clientIp = $clientIp;
     $this->_id = $id;
     $this->_spamRate = $spamRate;
     $this->_status = $status;
     if ($date == null) {
         $t = new Timestamp();
         $date = $t->getTimestamp();
     }
     $this->setDate($date);
     // by default this is not initialized, it will be up to the DAO class to
     // load this or not... so if I were you, I wouldn't really trust that this has been loaded :)
     // also, it is not necessary most of the times!
     $this->_article = null;
 }
 /**
  * Static method that returns a timestamp after applying a time
  * difference to it.
  *
  * @static
  * @param timeStamp The original ISO timestamp
  * @param timeDiff The time difference that we'd like to apply to the
  * original timestamp
  */
 function getDateWithOffset($timeStamp, $timeDiff)
 {
     if ($timeDiff != 0) {
         $t = new Timestamp($timeStamp);
         //
         // we can't use the addSeconds method with a negative offset
         // so we have to check wether the offset is positive or negative
         // and then use the correct one...
         //
         if ($timeDiff > 0) {
             $t->addSeconds($timeDiff * 3600);
         } else {
             $t->subtractSeconds($timeDiff * -3600);
         }
         $date = $t->getTimestamp();
     } else {
         $date = $timeStamp;
     }
     return $date;
 }
 /**
  * Retrieves the most recent posts
  *
  * @private
  */
 function _getRecentPosts()
 {
     $blogSettings = $this->_blogInfo->getSettings();
     $t = new Timestamp();
     $todayTimestamp = $t->getTimestamp();
     $recentPosts = $this->articles->getBlogArticles($this->_blogInfo->getId(), -1, $blogSettings->getValue('recent_posts_max'), 0, 1, 0, $todayTimestamp);
     $this->_pm->notifyEvent(EVENT_POSTS_LOADED, array('articles' => &$recentPosts));
     return $recentPosts;
 }