document_srl = $document_srl;
$this->_loadFromDB($load_extra_vars);
}
function setDocument($document_srl, $load_extra_vars = true) {
$this->document_srl = $document_srl;
$this->_loadFromDB($load_extra_vars);
}
function _loadFromDB($load_extra_vars=true) {
if(!$this->document_srl) return;
$args->document_srl = $this->document_srl;
$output = executeQuery('document.getDocument', $args);
$this->setAttribute($output->data,$load_extra_vars);
}
function setAttribute($attribute,$load_extra_vars=true) {
if(!$attribute->document_srl) {
$this->document_srl = null;
return;
}
$this->document_srl = $attribute->document_srl;
$this->lang_code = $attribute->lang_code;
$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);
}
$oDocumentModel = &getModel('document');
$GLOBALS['XE_DOCUMENT_LIST'][$this->document_srl] = $this;
if($load_extra_vars) {
$oDocumentModel->setToAllDocumentExtraVars();
$this->add('title', $GLOBALS['XE_DOCUMENT_LIST'][$this->document_srl]->get('title'));
$this->add('content', $GLOBALS['XE_DOCUMENT_LIST'][$this->document_srl]->get('content'));
}
}
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 || $this->get('member_srl')*-1 == $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() {
if(!$this->isExists()) return true;
return $this->get('allow_comment') == 'Y' ? true : false;
}
function allowTrackback() {
static $allow_trackback_status = null;
if(is_null($allow_trackback_status)) {
// 엮인글 관리 모듈의 사용금지 설정 상태이면 무조건 금지, 그렇지 않으면 개별 체크
$oModuleModel = &getModel('module');
$trackback_config = $oModuleModel->getModuleConfig('trackback');
if(!isset($trackback_config->enable_trackback)) $trackback_config->enable_trackback = 'Y';
if($trackback_config->enable_trackback != 'Y') $allow_trackback_status = false;
else {
$module_srl = $this->get('module_srl');
// 모듈별 설정을 체크
$module_config = $oModuleModel->getModulePartConfig('trackback', $module_srl);
if($module_config->enable_trackback == 'N') $allow_trackback_status = false;
else if($this->get('allow_trackback')=='Y' || !$this->isExists()) $allow_trackback_status = true;
}
}
return $allow_trackback_status;
}
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 doCart() {
if(!$this->document_srl) return false;
if($this->isCarted()) $this->removeCart();
else $this->addCart();
}
function addCart() {
$_SESSION['document_management'][$this->document_srl] = true;
}
function removeCart() {
unset($_SESSION['document_management'][$this->document_srl]);
}
function isCarted() {
return $_SESSION['document_management'][$this->document_srl];
}
function notify($type, $content) {
if(!$this->document_srl) return;
// 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;
// 변수 정리
if($type) $title = "[".$type."] ";
$title .= cut_str(strip_tags($content), 10, '...');
$content = sprintf('%s
from : %s',$content, getFullUrl('','document_srl',$this->document_srl), getFullUrl('','document_srl',$this->document_srl));
$receiver_srl = $this->get('member_srl');
$sender_member_srl = $logged_info->member_srl;
// 쪽지 발송
$oCommunicationController = &getController('communication');
$oCommunicationController->sendMessage($sender_member_srl, $receiver_srl, $title, $content, false);
}
function getLangCode() {
return $this->get('lang_code');
}
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 getTitleText($cut_size = 0, $tail='...') {
if(!$this->document_srl) return;
if($cut_size) $title = cut_str($this->get('title'), $cut_size, $tail);
else $title = $this->get('title');
return $title;
}
function getTitle($cut_size = 0, $tail='...') {
if(!$this->document_srl) return;
$title = $this->getTitleText($cut_size, $tail);
$attrs = array();
$this->add('title_color', trim($this->get('title_color')));
if($this->get('title_bold')=='Y') $attrs[] = "font-weight:bold;";
if($this->get('title_color') && $this->get('title_color') != 'N') $attrs[] = "color:#".$this->get('title_color');
if(count($attrs)) return sprintf("%s", implode(';',$attrs), htmlspecialchars($title));
else return htmlspecialchars($title);
}
function getContentText($strlen = 0) {
if(!$this->document_srl) return;
if($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) return Context::getLang('msg_is_secret');
$_SESSION['accessible'][$this->document_srl] = true;
$content = $this->get('content');
if($strlen) return cut_str(strip_tags($content),$strlen,'...');
return htmlspecialchars($content);
}
function stripEmbedTagForAdmin(&$content)
{
if(!Context::get('is_logged')) return;
$oModuleModel = &getModel('module');
$logged_info = Context::get('logged_info');
$writer_member_srl = $this->get('member_srl');
if($writer_member_srl != $logged_info->member_srl && ($logged_info->is_admin == "Y" || $oModuleModel->isSiteAdmin($logged_info)) )
{
if($writer_member_srl)
{
$oMemberModel =& getModel('member');
$member_info = $oMemberModel->getMemberInfoByMemberSrl($writer_member_srl);
if($member_info->is_admin == "Y")
{
return;
}
}
$security_msg = "
".Context::getLang('security_warning_embed')."
";
$content = preg_replace('/