document_srl = $document_srl;
$this->_loadFromDB();
}
function setDocument($document_srl) {
$this->document_srl = $document_srl;
$this->_loadFromDB();
}
function _loadFromDB() {
if(!$this->document_srl) return;
$args->document_srl = $this->document_srl;
$output = executeQuery('document.getDocument', $args);
$this->setAttribute($output->data);
}
function setAttribute($attribute) {
if(!$attribute->document_srl || !$attribute->content) {
$this->document_srl = null;
return;
}
$this->document_srl = $attribute->document_srl;
$this->adds($attribute);
// 태그 정리
if($this->get('tags')) {
$tags = explode(',',$this->get('tags'));
$tag_count = count($tags);
for($i=0;$i<$tag_count;$i++) if(trim($tags[$i])) $tag_list[] = trim($tags[$i]);
$this->add('tag_list', $tag_list);
}
}
function isExists() {
return $this->document_srl ? true : false;
}
function isGranted() {
if($_SESSION['own_document'][$this->document_srl]) return true;
if(!Context::get('is_logged')) return false;
$logged_info = Context::get('logged_info');
if($logged_info->is_admin == 'Y') return true;
if($this->get('member_srl') && $this->get('member_srl') == $logged_info->member_srl) return true;
return false;
}
function setGrant() {
$_SESSION['own_document'][$this->document_srl] = true;
}
function isAccessible() {
return $_SESSION['accessible'][$this->document_srl]==true?true:false;
}
function allowComment() {
return $this->get('allow_comment') == 'Y' || !$this->isExists() ? true : false;
}
function allowTrackback() {
return $this->get('allow_trackback') == 'Y' || !$this->isExists() ? true : false;
}
function isLocked() {
return $this->get('lock_comment') == 'Y' ? true : false;
}
function isEditable() {
if($this->isGranted() || !$this->get('member_srl')) return true;
return false;
}
function isSecret() {
return $this->get('is_secret') == 'Y' ? true : false;
}
function isNotice() {
return $this->get('is_notice') == 'Y' ? true : false;
}
function useNotify() {
return $this->get('notify_message')=='Y' ? true : false;
}
function notify($type, $content) {
// useNotify가 아니면 return
if(!$this->useNotify()) return;
// 글쓴이가 로그인 유저가 아니면 패스~
if(!$this->get('member_srl')) return;
// 현재 로그인한 사용자와 글을 쓴 사용자를 비교하여 동일하면 return
$logged_info = Context::get('logged_info');
if($logged_info->member_srl == $this->get('member_srl')) return;
// 변수 정리
$title = sprintf("[%s] %s", $type, cut_str(strip_tags($content), 10, '...') );
$content = sprintf('%s
from : %s',$content, $this->getPermanentUrl(), $this->getPermanentUrl());
$receiver_srl = $this->get('member_srl');
$sender_member_srl = $logged_info->member_srl;
// 쪽지 발송
$oMemberController = &getController('member');
$oMemberController->sendMessage($sender_member_srl, $receiver_srl, $title, $content, false);
}
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 getTitleText($cut_size = 0, $tail='...') {
return htmlspecialchars($this->getTitle($cut_size, $tail));
}
function getTitle($cut_size = 0, $tail='...') {
if($this->isSecret() && !$this->isGranted()) return Context::getLang('msg_is_secret');
if($cut_size) return cut_str($this->get('title'), $cut_size, $tail);
return $this->get('title');
}
function getContentText() {
if($this->isSecret() && !$this->isGranted()) return Context::getLang('msg_is_secret');
$_SESSION['accessible'][$this->document_srl] = true;
$content = $this->get('content');
$content = preg_replace("!