comment_srl = $comment_srl;
$this->_loadFromDB();
}
function setComment($comment_srl) {
$this->comment_srl = $comment_srl;
$this->_loadFromDB();
}
function _loadFromDB() {
if(!$this->comment_srl) return;
$args->comment_srl = $this->comment_srl;
$output = executeQuery('comment.getComment', $args);
$this->setAttribute($output->data);
}
function setAttribute($attribute) {
if(!$attribute->comment_srl) {
$this->comment_srl = null;
return;
}
$this->comment_srl = $attribute->comment_srl;
$this->adds($attribute);
// define vars on the object for backward compatibility of skins
if(count($attribute)) foreach($attribute as $key => $val) $this->{$key} = $val;
}
function isExists() {
return $this->comment_srl ? true : false;
}
function isGranted() {
if($_SESSION['own_comment'][$this->comment_srl]) return true;
if(!Context::get('is_logged')) return false;
$logged_info = Context::get('logged_info');
if($logged_info->is_admin == 'Y') return true;
$grant = Context::get('grant');
if($grant->manager) return true;
if($this->get('member_srl') && ($this->get('member_srl') == $logged_info->member_srl || $this->get('member_srl')*-1 == $logged_info->member_srl)) return true;
return false;
}
function setGrant() {
$_SESSION['own_comment'][$this->comment_srl] = true;
$this->is_granted = true;
}
function setAccessible() {
$_SESSION['accessibled_comment'][$this->comment_srl] = true;
}
function isEditable() {
if($this->isGranted() || !$this->get('member_srl')) return true;
return false;
}
function isSecret() {
return $this->get('is_secret') == 'Y' ? true : false;
}
function isAccessible() {
if($_SESSION['accessibled_comment'][$this->comment_srl]) return true;
if($this->isGranted() || !$this->isSecret()) {
$this->setAccessible();
return true;
}
$oDocumentModel = &getModel('document');
$oDocument = $oDocumentModel->getDocument($this->get('document_srl'));
if($oDocument->isGranted()) {
$this->setAccessible();
return true;
}
return false;
}
function useNotify() {
return $this->get('notify_message')=='Y' ? true : false;
}
function notify($type, $content) {
// return if not useNotify
if(!$this->useNotify()) return;
// pass if the author is not logged-in user
if(!$this->get('member_srl')) return;
// return if the currently logged-in user is an author of the comment.
$logged_info = Context::get('logged_info');
if($logged_info->member_srl == $this->get('member_srl')) return;
// get where the comment belongs to
$oDocumentModel = &getModel('document');
$oDocument = $oDocumentModel->getDocument($this->get('document_srl'));
// Variables
if($type) $title = "[".$type."] ";
$title .= cut_str(strip_tags($content), 30, '...');
$content = sprintf('%s
from : %s',$content, getFullUrl('','document_srl',$this->get('document_srl')), $this->get('comment_srl'), getFullUrl('','document_srl',$this->get('document_srl')));
$receiver_srl = $this->get('member_srl');
$sender_member_srl = $logged_info->member_srl;
// send a message
$oCommunicationController = &getController('communication');
$oCommunicationController->sendMessage($sender_member_srl, $receiver_srl, $title, $content, false);
}
function getIpaddress() {
if($this->isGranted()) return $this->get('ipaddress');
return preg_replace('/([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)/','*.$2.$3.$4', $this->get('ipaddress'));
}
function isExistsHomepage() {
if(trim($this->get('homepage'))) return true;
return false;
}
function getHomepageUrl() {
$url = trim($this->get('homepage'));
if(!$url) return;
if(!preg_match("/^http:\/\//i",$url)) $url = "http://".$url;
return $url;
}
function getMemberSrl() {
return $this->get('member_srl');
}
function getUserID() {
return htmlspecialchars($this->get('user_id'));
}
function getUserName() {
return htmlspecialchars($this->get('user_name'));
}
function getNickName() {
return htmlspecialchars($this->get('nick_name'));
}
function getContentText($strlen = 0) {
if($this->isSecret() && !$this->isAccessible()) return Context::getLang('msg_is_secret');
$content = $this->get('content');
if($strlen) return cut_str(strip_tags($content),$strlen,'...');
return htmlspecialchars($content);
}
function getContent($add_popup_menu = true, $add_content_info = true, $add_xe_content_class = true) {
if($this->isSecret() && !$this->isAccessible()) return Context::getLang('msg_is_secret');
$content = $this->get('content');
stripEmbedTagForAdmin($content, $this->get('member_srl'));
// when displaying the comment on the pop-up menu
if($add_popup_menu && Context::get('is_logged') ) {
$content = sprintf(
'%s