mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-05 09:41:40 +09:00
코드 정리
This commit is contained in:
parent
48c818d7de
commit
f93ad9c0f6
5 changed files with 163 additions and 102 deletions
|
|
@ -233,7 +233,7 @@ if($called_position == 'before_module_proc')
|
|||
{
|
||||
$oDocumentModel = getModel('document');
|
||||
$oDocument = $oDocumentModel->getDocument($document_srl);
|
||||
if(!$oDocument->isExists() || !$oDocument->isGranted())
|
||||
if(!$oDocument->isGranted())
|
||||
{
|
||||
printContent(getXmlRpcFailure(1, 'no permission'));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -782,7 +782,7 @@ class boardView extends board
|
|||
|
||||
// if the document is not granted, then back to the password input form
|
||||
$oModuleModel = getModel('module');
|
||||
if($oDocument->isExists()&&!$oDocument->isGranted())
|
||||
if($oDocument->isExists() && !$oDocument->isGranted())
|
||||
{
|
||||
return $this->setTemplateFile('input_password_form');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1257,7 +1257,7 @@ class commentController extends comment
|
|||
$oDocument = $oDocumentModel->getDocument($document_srl);
|
||||
}
|
||||
|
||||
if(!$oDocument->isExists() || !$oDocument->isGranted())
|
||||
if(!$oDocument->isGranted())
|
||||
{
|
||||
return new BaseObject(-1, 'msg_not_permitted');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,14 +92,19 @@ class commentItem extends BaseObject
|
|||
|
||||
function isExists()
|
||||
{
|
||||
return (bool) $this->comment_srl;
|
||||
return (bool) ($this->comment_srl);
|
||||
}
|
||||
|
||||
function isGranted()
|
||||
{
|
||||
if ($_SESSION['granted_comment'][$this->comment_srl])
|
||||
if(!$this->isExists())
|
||||
{
|
||||
return $this->grant_cache = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isset($_SESSION['granted_comment'][$this->comment_srl]))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($this->grant_cache !== null)
|
||||
|
|
@ -144,7 +149,12 @@ class commentItem extends BaseObject
|
|||
|
||||
function isAccessible()
|
||||
{
|
||||
if ($_SESSION['accessible'][$this->comment_srl] === $this->get('last_update'))
|
||||
if(!$this->isExists())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isset($_SESSION['accessible'][$this->comment_srl]) && $_SESSION['accessible'][$this->comment_srl] === $this->get('last_update'))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
@ -162,7 +172,7 @@ class commentItem extends BaseObject
|
|||
}
|
||||
|
||||
$oDocument = getModel('document')->getDocument($this->get('document_srl'));
|
||||
if ($oDocument->isExists() && $oDocument->isGranted())
|
||||
if ($oDocument->isGranted())
|
||||
{
|
||||
$this->setAccessible();
|
||||
return true;
|
||||
|
|
@ -515,25 +525,26 @@ class commentItem extends BaseObject
|
|||
|
||||
function hasUploadedFiles()
|
||||
{
|
||||
if(($this->isSecret() && !$this->isAccessible()) && !$this->isGranted())
|
||||
if(!$this->isAccessible())
|
||||
{
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->get('uploaded_count') ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
function getUploadedFiles()
|
||||
{
|
||||
if(($this->isSecret() && !$this->isAccessible()) && !$this->isGranted())
|
||||
if(!$this->isAccessible())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if(!$this->get('uploaded_count'))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$oFileModel = getModel('file');
|
||||
$file_list = $oFileModel->getFiles($this->comment_srl, array(), 'file_srl', TRUE);
|
||||
return $file_list;
|
||||
|
|
@ -646,11 +657,11 @@ class commentItem extends BaseObject
|
|||
$thumbnail_type = $config->thumbnail_type ?: 'crop';
|
||||
}
|
||||
|
||||
if($this->isSecret() && !$this->isGranted())
|
||||
if(!$this->isAccessible())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// If signiture height setting is omitted, create a square
|
||||
if(!$height)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -62,7 +62,6 @@ class documentItem extends BaseObject
|
|||
{
|
||||
$this->document_srl = $document_srl;
|
||||
$this->columnList = $columnList;
|
||||
|
||||
$this->_loadFromDB($load_extra_vars);
|
||||
}
|
||||
|
||||
|
|
@ -79,10 +78,12 @@ class documentItem extends BaseObject
|
|||
*/
|
||||
function _loadFromDB($load_extra_vars = true)
|
||||
{
|
||||
if(!$this->document_srl) return;
|
||||
|
||||
if(!$this->document_srl)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$document_item = false;
|
||||
$cache_put = false;
|
||||
$columnList = array();
|
||||
$reload_counts = true;
|
||||
|
||||
|
|
@ -127,17 +128,18 @@ class documentItem extends BaseObject
|
|||
$this->setAttribute($document_item, $load_extra_vars);
|
||||
}
|
||||
|
||||
function setAttribute($attribute, $load_extra_vars=true)
|
||||
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);
|
||||
|
||||
|
||||
// Tags
|
||||
if($this->get('tags'))
|
||||
{
|
||||
|
|
@ -145,26 +147,30 @@ class documentItem extends BaseObject
|
|||
$tag_list = array_map('utf8_trim', $tag_list);
|
||||
$this->add('tag_list', $tag_list);
|
||||
}
|
||||
|
||||
$oDocumentModel = getModel('document');
|
||||
|
||||
if($load_extra_vars)
|
||||
{
|
||||
$GLOBALS['XE_DOCUMENT_LIST'][$attribute->document_srl] = $this;
|
||||
$oDocumentModel->setToAllDocumentExtraVars();
|
||||
getModel('document')->setToAllDocumentExtraVars();
|
||||
}
|
||||
|
||||
$GLOBALS['XE_DOCUMENT_LIST'][$this->document_srl] = $this;
|
||||
}
|
||||
|
||||
function isExists()
|
||||
{
|
||||
return (bool) $this->document_srl;
|
||||
return (bool) ($this->document_srl);
|
||||
}
|
||||
|
||||
function isGranted()
|
||||
{
|
||||
if ($_SESSION['granted_document'][$this->document_srl])
|
||||
if(!$this->isExists())
|
||||
{
|
||||
return $this->grant_cache = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isset($_SESSION['granted_document'][$this->document_srl]))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($this->grant_cache !== null)
|
||||
|
|
@ -209,13 +215,18 @@ class documentItem extends BaseObject
|
|||
|
||||
function isAccessible()
|
||||
{
|
||||
if ($_SESSION['accessible'][$this->document_srl] === $this->get('last_update'))
|
||||
if(!$this->isExists())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isset($_SESSION['accessible'][$this->document_srl]) && $_SESSION['accessible'][$this->document_srl] === $this->get('last_update'))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
$status_list = getModel('document')->getStatusList();
|
||||
if ($this->get('status') === $status_list['public'] || $this->get('status') === $status_list['temp'])
|
||||
if ($this->get('status') === $status_list['public'])
|
||||
{
|
||||
$this->setAccessible();
|
||||
return true;
|
||||
|
|
@ -246,7 +257,7 @@ class documentItem extends BaseObject
|
|||
return true;
|
||||
}
|
||||
|
||||
return $this->get('comment_status') == 'ALLOW';
|
||||
return (bool) ($this->get('comment_status') == 'ALLOW');
|
||||
}
|
||||
|
||||
function allowTrackback()
|
||||
|
|
@ -293,34 +304,37 @@ class documentItem extends BaseObject
|
|||
return false;
|
||||
}
|
||||
|
||||
return $this->get('comment_status') != 'ALLOW';
|
||||
return (bool) ($this->get('comment_status') != 'ALLOW');
|
||||
}
|
||||
|
||||
function isEditable()
|
||||
{
|
||||
return !$this->get('member_srl') || $this->isGranted();
|
||||
return (bool) (!$this->get('member_srl') || $this->isGranted());
|
||||
}
|
||||
|
||||
function isSecret()
|
||||
{
|
||||
return $this->get('status') == getModel('document')->getConfigStatus('secret');
|
||||
return (bool) ($this->get('status') == getModel('document')->getConfigStatus('secret'));
|
||||
}
|
||||
|
||||
function isNotice()
|
||||
{
|
||||
return $this->get('is_notice') == 'Y';
|
||||
return (bool) ($this->get('is_notice') == 'Y');
|
||||
}
|
||||
|
||||
function useNotify()
|
||||
{
|
||||
return $this->get('notify_message') == 'Y';
|
||||
return (bool) ($this->get('notify_message') == 'Y');
|
||||
}
|
||||
|
||||
function doCart()
|
||||
{
|
||||
if(!$this->document_srl) return false;
|
||||
if($this->isCarted()) $this->removeCart();
|
||||
else $this->addCart();
|
||||
if(!$this->isExists())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->isCarted() ? $this->removeCart() : $this->addCart();
|
||||
}
|
||||
|
||||
function addCart()
|
||||
|
|
@ -335,7 +349,7 @@ class documentItem extends BaseObject
|
|||
|
||||
function isCarted()
|
||||
{
|
||||
return $_SESSION['document_management'][$this->document_srl];
|
||||
return isset($_SESSION['document_management'][$this->document_srl]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -346,23 +360,35 @@ class documentItem extends BaseObject
|
|||
*/
|
||||
function notify($type, $content)
|
||||
{
|
||||
if(!$this->document_srl) return;
|
||||
if(!$this->isExists())
|
||||
{
|
||||
return;
|
||||
}
|
||||
// return if it is not useNotify
|
||||
if(!$this->useNotify()) return;
|
||||
if(!$this->useNotify())
|
||||
{
|
||||
return;
|
||||
}
|
||||
// Pass if an author is not a logged-in user
|
||||
if(!$this->get('member_srl')) return;
|
||||
if(!$this->get('member_srl'))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Return if the currently logged-in user is an author
|
||||
$logged_info = Context::get('logged_info');
|
||||
if($logged_info->member_srl == $this->get('member_srl')) return;
|
||||
if($logged_info->member_srl == $this->get('member_srl'))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// List variables
|
||||
if($type) $title = "[".$type."] ";
|
||||
$title .= cut_str(strip_tags($content), 10, '...');
|
||||
$content = sprintf('%s<br /><br />from : <a href="%s" target="_blank">%s</a>',$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;
|
||||
$title = ($type ? sprintf('[%s] ', $type) : '') . cut_str(strip_tags($content), 10, '...');
|
||||
$content = sprintf('%s<br><br>from : <a href="%s" target="_blank">%s</a>',$content, getFullUrl('', 'document_srl', $this->document_srl), getFullUrl('', 'document_srl', $this->document_srl));
|
||||
|
||||
// Send a message
|
||||
$oCommunicationController = getController('communication');
|
||||
$oCommunicationController->sendMessage($sender_member_srl, $receiver_srl, $title, $content, false);
|
||||
$sender_member_srl = $logged_info->member_srl ?: $this->get('member_srl');
|
||||
getController('communication')->sendMessage($sender_member_srl, $this->get('member_srl'), $title, $content, false);
|
||||
}
|
||||
|
||||
function getLangCode()
|
||||
|
|
@ -382,17 +408,21 @@ class documentItem extends BaseObject
|
|||
|
||||
function isExistsHomepage()
|
||||
{
|
||||
if(trim($this->get('homepage'))) return true;
|
||||
return false;
|
||||
return (bool) trim($this->get('homepage'));
|
||||
}
|
||||
|
||||
function getHomepageUrl()
|
||||
{
|
||||
$url = trim($this->get('homepage'));
|
||||
if(!$url) return;
|
||||
|
||||
if(strncasecmp('http://', $url, 7) !== 0 && strncasecmp('https://', $url, 8) !== 0) $url = 'http://' . $url;
|
||||
|
||||
if(!$url = trim($this->get('homepage')))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(!preg_match('@^[a-z]+://@i', $url))
|
||||
{
|
||||
$url = 'http://' . $url;
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
|
|
@ -403,82 +433,94 @@ class documentItem extends BaseObject
|
|||
|
||||
function getUserID()
|
||||
{
|
||||
return htmlspecialchars($this->get('user_id'), ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
|
||||
return escape($this->get('user_id'), false);
|
||||
}
|
||||
|
||||
function getUserName()
|
||||
{
|
||||
return htmlspecialchars($this->get('user_name'), ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
|
||||
return escape($this->get('user_name'), false);
|
||||
}
|
||||
|
||||
function getNickName()
|
||||
{
|
||||
return htmlspecialchars($this->get('nick_name'), ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
|
||||
return escape($this->get('nick_name'), false);
|
||||
}
|
||||
|
||||
function getLastUpdater()
|
||||
{
|
||||
return htmlspecialchars($this->get('last_updater'), ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
|
||||
return escape($this->get('last_updater'), false);
|
||||
}
|
||||
|
||||
function getTitleText($cut_size = 0, $tail='...')
|
||||
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;
|
||||
if(!$this->isExists())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
return $cut_size ? cut_str($this->get('title'), $cut_size, $tail) : $this->get('title');
|
||||
}
|
||||
|
||||
function getVoted()
|
||||
{
|
||||
if(!$this->document_srl) return false;
|
||||
if(!$this->isExists())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$logged_info = Context::get('logged_info');
|
||||
if(!$logged_info->member_srl)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(isset($_SESSION['voted_document'][$this->document_srl]))
|
||||
{
|
||||
return $_SESSION['voted_document'][$this->document_srl];
|
||||
}
|
||||
|
||||
$logged_info = Context::get('logged_info');
|
||||
if(!$logged_info->member_srl) return false;
|
||||
|
||||
$args = new stdClass();
|
||||
|
||||
$args = new stdClass;
|
||||
$args->member_srl = $logged_info->member_srl;
|
||||
$args->document_srl = $this->document_srl;
|
||||
$output = executeQuery('document.getDocumentVotedLog', $args);
|
||||
|
||||
if($output->data->point)
|
||||
{
|
||||
return $_SESSION['voted_document'][$this->document_srl] = $output->data->point;
|
||||
}
|
||||
|
||||
|
||||
return $_SESSION['voted_document'][$this->document_srl] = false;
|
||||
}
|
||||
|
||||
function getTitle($cut_size = 0, $tail='...')
|
||||
function getTitle($cut_size = 0, $tail = '...')
|
||||
{
|
||||
if(!$this->document_srl) return;
|
||||
|
||||
$title = $this->getTitleText($cut_size, $tail);
|
||||
|
||||
$attrs = array();
|
||||
if(!$this->isExists())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$title = escape($this->getTitleText($cut_size, $tail), false);
|
||||
$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:#".ltrim($this->get('title_color'), '#');
|
||||
|
||||
|
||||
$attrs = array();
|
||||
if($this->get('title_bold') == 'Y')
|
||||
{
|
||||
$attrs[] = 'font-weight:bold';
|
||||
}
|
||||
if($this->get('title_color') && $this->get('title_color') != 'N')
|
||||
{
|
||||
$attrs[] = 'color:#' . ltrim($this->get('title_color'), '#');
|
||||
}
|
||||
if(count($attrs))
|
||||
{
|
||||
return sprintf("<span style=\"%s\">%s</span>", implode(';', $attrs), escape($title, false));
|
||||
}
|
||||
else
|
||||
{
|
||||
return escape($title, false);
|
||||
return sprintf('<span style="%s">%s</span>', implode(';', $attrs), $title);
|
||||
}
|
||||
|
||||
return $title;
|
||||
}
|
||||
|
||||
function getContentPlainText($strlen = 0)
|
||||
{
|
||||
if(!$this->document_srl)
|
||||
if(!$this->isExists())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
@ -500,7 +542,7 @@ class documentItem extends BaseObject
|
|||
|
||||
function getContentText($strlen = 0)
|
||||
{
|
||||
if(!$this->document_srl)
|
||||
if(!$this->isExists())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
@ -568,7 +610,7 @@ class documentItem extends BaseObject
|
|||
|
||||
function getContent($add_popup_menu = true, $add_content_info = true, $resource_realpath = false, $add_xe_content_class = true, $stripEmbedTagException = false)
|
||||
{
|
||||
if(!$this->document_srl)
|
||||
if(!$this->isExists())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
@ -640,11 +682,14 @@ class documentItem extends BaseObject
|
|||
*/
|
||||
function getTransContent($add_popup_menu = true, $add_content_info = true, $resource_realpath = false, $add_xe_content_class = true)
|
||||
{
|
||||
$oEditorController = getController('editor');
|
||||
|
||||
if(!$this->isExists())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$content = $this->getContent($add_popup_menu, $add_content_info, $resource_realpath, $add_xe_content_class);
|
||||
$content = $oEditorController->transComponent($content);
|
||||
|
||||
$content = getController('editor')->transComponent($content);
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
|
|
@ -712,11 +757,16 @@ class documentItem extends BaseObject
|
|||
|
||||
function getTrackbackUrl()
|
||||
{
|
||||
if(!$this->document_srl) return;
|
||||
|
||||
if(!$this->isExists())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Generate a key to prevent spams
|
||||
$oTrackbackModel = getModel('trackback');
|
||||
if($oTrackbackModel) return $oTrackbackModel->getTrackbackUrl($this->document_srl, $this->getDocumentMid());
|
||||
if($oTrackbackModel = getModel('trackback'))
|
||||
{
|
||||
return $oTrackbackModel->getTrackbackUrl($this->document_srl, $this->getDocumentMid());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue