00001 <?php
00002
00003 lt_include( PLOG_CLASS_PATH."class/database/dbobject.class.php" );
00004 lt_include( PLOG_CLASS_PATH."class/dao/userinfo.class.php" );
00005 lt_include( PLOG_CLASS_PATH."class/dao/article.class.php" );
00006 lt_include( PLOG_CLASS_PATH."class/dao/articlecommentstatus.class.php" );
00007
00015 class UserComment extends DbObject
00016 {
00017
00018 var $_id;
00019 var $_artid;
00020 var $_userName;
00021 var $_userEmail;
00022 var $_userUrl;
00023 var $_topic;
00024 var $_text;
00025 var $_date;
00026 var $_parentid;
00027 var $_clientIp;
00028 var $_timeStamp;
00029 var $_postInfo;
00030 var $_spamRate;
00031 var $_status;
00032 var $_type;
00033 var $_normalizedText;
00034 var $_normalizedTopic;
00035 var $_article;
00036 var $_userId;
00037 var $_user;
00038 var $_blogInfo;
00039
00043 function UserComment( $artid, $blogId, $parentid, $topic, $text, $date = null, $userName = "", $userEmail = "", $userUrl = "", $clientIp = "0.0.0.0", $spamRate = 0, $status = COMMENT_STATUS_NONSPAM, $properties = Array(), $id = -1 )
00044 {
00045
00046
00047 $this->_topic = $topic;
00048 $this->_text = $text;
00049 $this->_artid = $artid;
00050 $this->_parentid = $parentid;
00051
00052 $this->_userName = $userName;
00053 $this->_userEmail = $userEmail;
00054 $this->setUserUrl( $userUrl );
00055
00056 $this->_clientIp = $clientIp;
00057
00058 $this->_id = $id;
00059
00060 $this->_spamRate = $spamRate;
00061 $this->_status = $status;
00062
00063 if( $date == null ) {
00064 lt_include( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
00065
00066 $t = new Timestamp();
00067 $date = $t->getTimestamp();
00068 }
00069
00070 $this->setDate( $date );
00071 $this->_article = null;
00072
00073
00074 $this->_type = COMMENT_TYPE_COMMENT;
00075
00076 $this->_blogId = $blogId;
00077 $this->_sendNotification = 0;
00078
00079 $this->_normalizedTopic = '';
00080 $this->_normalizedText = '';
00081
00082 $this->setProperties( $properties );
00083
00084 $this->_blogInfo = null;
00085
00086 $this->_fields = Array(
00087 "article_id" => "getArticleId",
00088 "blog_id" => "getBlogId",
00089 "topic" => "getTopic",
00090 "text" => "getText",
00091 "date" => "getDate",
00092 "user_email" => "getUserEmail",
00093 "user_url" => "getUserUrl",
00094 "user_name" => "getUserName",
00095 "parent_id" => "getParentId",
00096 "client_ip" => "getClientIp",
00097 "send_notification" => "getSendNotification",
00098 "status" => "getStatus",
00099 "spam_rate" => "getSpamRate",
00100 "type" => "getType",
00101 "normalized_text" => "getNormalizedText",
00102 "normalized_topic" => "getNormalizedTopic",
00103 "properties" => "getProperties",
00104 "user_id" => "getUserId"
00105 );
00106 }
00107
00113 function getId()
00114 {
00115 return $this->_id;
00116 }
00117
00122 function setId( $newid )
00123 {
00124 $this->_id = $newid;
00125 }
00126
00132 function getArticleId()
00133 {
00134 return $this->_artid;
00135 }
00136
00141 function setArticleId( $newartid )
00142 {
00143 $this->_artid = $newartid;
00144 }
00145
00151 function getUserName()
00152 {
00153 return $this->_userName;
00154 }
00155
00160 function setUserName( $userName )
00161 {
00162 $this->_userName = $userName;
00163 }
00164
00170 function getUserEmail()
00171 {
00172 return $this->_userEmail;
00173 }
00174
00179 function setUserEmail( $userEmail )
00180 {
00181 $this->_userEmail = $userEmail;
00182 }
00183
00189 function getUserUrl()
00190 {
00191 return $this->_userUrl;
00192 }
00193
00198 function setUserUrl( $userUrl )
00199 {
00200
00201 if ( $userUrl != null && eregi("http", $userUrl) == null )
00202 $userUrl = "http://".$userUrl;
00203
00204 $this->_userUrl = $userUrl;
00205 }
00206
00212 function getText()
00213 {
00214 return $this->_text;
00215 }
00216
00221 function setText( $newtext )
00222 {
00223 $this->_text = $newtext;
00224 }
00225
00231 function getTopic()
00232 {
00233 return $this->_topic;
00234 }
00235
00240 function setTopic( $newtopic )
00241 {
00242 $this->_topic = $newtopic;
00243 }
00244
00250 function getDate()
00251 {
00252
00253 return $this->_date;
00254 }
00255
00260 function setDate( $newdate )
00261 {
00262
00263 lt_include( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
00264
00265 $this->_date = $newdate;
00266
00267
00268 $this->_timeStamp = new Timestamp( $this->_date );
00269 }
00270
00277 function getDateObject()
00278 {
00279 return $this->_timeStamp;
00280 }
00281
00288 function getParentId()
00289 {
00290 return $this->_parentid;
00291 }
00292
00297 function setParentId( $parentId )
00298 {
00299 return $this->_parentid;
00300 }
00301
00307 function getTimestamp()
00308 {
00309 return $this->getDateObject();
00310 }
00311
00319 function getClientIp()
00320 {
00321 return $this->_clientIp;
00322 }
00323
00328 function setClientIp( $clientIp )
00329 {
00330 $this->_clientIp = $clientIp;
00331 }
00332
00339 function setSpamRate( $spamRate )
00340 {
00341 $this->_spamRate = $spamRate;
00342 }
00343
00347 function getSpamRate()
00348 {
00349 return $this->_spamRate;
00350 }
00351
00357 function setStatus( $status )
00358 {
00359 $this->_status = $status;
00360 }
00361
00365 function getStatus()
00366 {
00367 return $this->_status;
00368 }
00369
00377 function setArticle( $article )
00378 {
00379 $this->_article = $article;
00380
00381 return true;
00382 }
00383
00389 function getArticle()
00390 {
00391 if( $this->_article == null ) {
00392 $articles = new Articles();
00393 $this->_article = $articles->getArticle( $this->_artid );
00394 }
00395
00396 return( $this->_article );
00397 }
00398
00404 function getType()
00405 {
00406 return( $this->_type );
00407 }
00408
00417 function setType( $type )
00418 {
00419 $this->_type = $type;
00420 }
00421
00422 function getSendNotification()
00423 {
00424 return( $this->_sendNotification );
00425 }
00426
00427 function setSendNotification( $sendNotification )
00428 {
00429 if( $sendNotification == "" )
00430 $sendNotificaton = 0;
00431 $this->_sendNotification = $sendNotification;
00432 }
00433
00434 function getBlogId()
00435 {
00436 return( $this->_blogId );
00437 }
00438
00439 function setBlogId( $blogId )
00440 {
00441 $this->_blogId = $blogId;
00442 }
00443
00444
00452 function getUrl()
00453 {
00454 return( $this->getUserUrl());
00455 }
00456
00465 function getTitle()
00466 {
00467 return( $this->getTopic());
00468 }
00469
00479 function getExcerpt()
00480 {
00481 return( $this->getText());
00482 }
00483
00491 function getBlogName()
00492 {
00493 return( $this->getUserName());
00494 }
00495
00501 function getBlogInfo()
00502 {
00503 if( $this->_blogInfo === null ) {
00504 lt_include( PLOG_CLASS_PATH."class/dao/bloginfo.class.php" );
00505 $blogs = new Blogs();
00506 $this->_blogInfo = $blogs->getBlogInfo( $this->getBlogId());
00507 }
00508
00509 return( $this->_blogInfo );
00510 }
00511
00517 function setNormalizedText( $normalizedText )
00518 {
00519
00520 lt_include( PLOG_CLASS_PATH."class/data/textfilter.class.php" );
00521 $this->_normalizedText = TextFilter::normalizeText( $normalizedText );
00522 }
00523
00529 function getNormalizedText()
00530 {
00531 if( $this->_normalizedText == "" ) {
00532 $this->setNormalizedText( $this->getText());
00533 }
00534
00535 return( $this->_normalizedText );
00536 }
00537
00543 function setNormalizedTopic( $normalizedTopic )
00544 {
00545
00546 lt_include( PLOG_CLASS_PATH."class/data/textfilter.class.php" );
00547 $this->_normalizedTopic = TextFilter::normalizeText( $normalizedTopic );
00548 }
00549
00555 function getNormalizedTopic()
00556 {
00557 if( $this->_normalizedTopic == "" ) {
00558 $this->setNormalizedTopic( $this->getTopic());
00559 }
00560
00561 return( $this->_normalizedTopic );
00562 }
00563
00569 function IsPosterAuthenticated()
00570 {
00571 return( $this->getUser() != false );
00572 }
00573
00581 function getUser()
00582 {
00583 if( $this->_userId != 0 ) {
00584 lt_include( PLOG_CLASS_PATH."class/dao/users.class.php" );
00585 $users = new Users();
00586 $this->_user = $users->getUserInfoFromId( $this->_userId );
00587 }
00588
00589 return( $this->_user );
00590 }
00591
00599 function getUserId()
00600 {
00601 return( $this->_userId );
00602 }
00603
00610 function setUserId( $id )
00611 {
00612 $this->_userId = $id;
00613 }
00614
00621 function setUser( $userInfo )
00622 {
00623 $this->_user = $userInfo;
00624 $this->_userId = $userInfo->getId();
00625 }
00626
00630 function __sleep()
00631 {
00632 $this->_userInfo = null;
00633 return( parent::__sleep());
00634 }
00635 }
00636 ?>