From d9f44e9d4885425779161b8870d3b5c09467a608 Mon Sep 17 00:00:00 2001 From: ovclas Date: Fri, 16 Nov 2012 05:16:42 +0000 Subject: [PATCH] issue 2662 comment, communication git-svn-id: http://xe-core.googlecode.com/svn/branches/maserati@12239 201d5d3c-b55e-5fd7-737f-ddc643e51545 --- modules/comment/comment.item.php | 858 ++++++++-------- .../communication.admin.controller.php | 73 +- .../communication.admin.model.php | 101 +- .../communication.admin.view.php | 104 +- modules/communication/communication.class.php | 140 +-- .../communication.controller.php | 925 +++++++++--------- .../communication/communication.mobile.php | 9 +- modules/communication/communication.model.php | 361 +++---- modules/communication/communication.view.php | 512 +++++----- 9 files changed, 1607 insertions(+), 1476 deletions(-) diff --git a/modules/comment/comment.item.php b/modules/comment/comment.item.php index d93dfcb25..85e962287 100644 --- a/modules/comment/comment.item.php +++ b/modules/comment/comment.item.php @@ -1,450 +1,506 @@ comment_srl = $comment_srl; - $this->columnList = $columnList; - $this->_loadFromDB(); - } + /** + * Constructor + * @param int $comment_srl + * @param array $columnList + * @return void + */ + function commentItem($comment_srl = 0, $columnList = array()) + { + $this->comment_srl = $comment_srl; + $this->columnList = $columnList; + $this->_loadFromDB(); + } - function setComment($comment_srl) { - $this->comment_srl = $comment_srl; - $this->_loadFromDB(); - } + function setComment($comment_srl) + { + $this->comment_srl = $comment_srl; + $this->_loadFromDB(); + } - /** - * Load comment data from DB and set to commentItem object - * @return void - */ - function _loadFromDB() { - if(!$this->comment_srl) return; + /** + * Load comment data from DB and set to commentItem object + * @return void + */ + function _loadFromDB() + { + if(!$this->comment_srl) return; - $args->comment_srl = $this->comment_srl; - $output = executeQuery('comment.getComment', $args, $this->columnList); + $args->comment_srl = $this->comment_srl; + $output = executeQuery('comment.getComment', $args, $this->columnList); - $this->setAttribute($output->data); - } + $this->setAttribute($output->data); + } - /** - * Comment attribute set to Object object - * @return void - */ - 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; - } + /** + * Comment attribute set to Object object + * @return void + */ + 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 isExists() + { + return $this->comment_srl ? true : false; + } - function isGranted() { - if($_SESSION['own_comment'][$this->comment_srl]) return true; + function isGranted() + { + if($_SESSION['own_comment'][$this->comment_srl]) return true; - if(!Context::get('is_logged')) return false; + if(!Context::get('is_logged')) return false; - $logged_info = Context::get('logged_info'); - if($logged_info->is_admin == 'Y') return true; + $logged_info = Context::get('logged_info'); + if($logged_info->is_admin == 'Y') return true; - $grant = Context::get('grant'); - if($grant->manager) 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; + 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; - } + return false; + } - function setGrant() { - $_SESSION['own_comment'][$this->comment_srl] = true; - $this->is_granted = true; - } + function setGrant() + { + $_SESSION['own_comment'][$this->comment_srl] = true; + $this->is_granted = true; + } - function setAccessible() { - $_SESSION['accessibled_comment'][$this->comment_srl] = true; - } + function setAccessible() + { + $_SESSION['accessibled_comment'][$this->comment_srl] = true; + } - function isEditable() { - if($this->isGranted() || !$this->get('member_srl')) return true; - return 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 isSecret() + { + return $this->get('is_secret') == 'Y' ? true : false; + } - function isAccessible() { - if($_SESSION['accessibled_comment'][$this->comment_srl]) return true; + function isAccessible() + { + if($_SESSION['accessibled_comment'][$this->comment_srl]) return true; - if($this->isGranted() || !$this->isSecret()) { - $this->setAccessible(); - 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; - } + $oDocumentModel = &getModel('document'); + $oDocument = $oDocumentModel->getDocument($this->get('document_srl')); + if($oDocument->isGranted()) + { + $this->setAccessible(); + return true; + } - return false; - } + return false; + } - function useNotify() { - return $this->get('notify_message')=='Y' ? true : false; - } + function useNotify() + { + return $this->get('notify_message')=='Y' ? true : false; + } - /** - * Notify to comment owner - * @return void - */ - 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); - } + /** + * Notify to comment owner + * @return void + */ + 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 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 isExistsHomepage() + { + if(trim($this->get('homepage'))) return true; + return false; + } - function getHomepageUrl() { - $url = trim($this->get('homepage')); - if(!$url) return; + function getHomepageUrl() + { + $url = trim($this->get('homepage')); + if(!$url) return; - if(!preg_match("/^http:\/\//i",$url)) $url = "http://".$url; + if(!preg_match("/^http:\/\//i",$url)) $url = "http://".$url; - return $url; - } + return $url; + } - function getMemberSrl() { - return $this->get('member_srl'); - } + function getMemberSrl() + { + return $this->get('member_srl'); + } - function getUserID() { - return htmlspecialchars($this->get('user_id')); - } + function getUserID() + { + return htmlspecialchars($this->get('user_id')); + } - function getUserName() { - return htmlspecialchars($this->get('user_name')); - } + function getUserName() + { + return htmlspecialchars($this->get('user_name')); + } - function getNickName() { - return htmlspecialchars($this->get('nick_name')); - } + function getNickName() + { + return htmlspecialchars($this->get('nick_name')); + } - /** - * Return content with htmlspecialchars - * @return string - */ - function getContentText($strlen = 0) { - if($this->isSecret() && !$this->isAccessible()) return Context::getLang('msg_is_secret'); + /** + * Return content with htmlspecialchars + * @return string + */ + function getContentText($strlen = 0) + { + if($this->isSecret() && !$this->isAccessible()) return Context::getLang('msg_is_secret'); - $content = $this->get('content'); + $content = $this->get('content'); - if($strlen) return cut_str(strip_tags($content),$strlen,'...'); + if($strlen) return cut_str(strip_tags($content),$strlen,'...'); - return htmlspecialchars($content); - } + return htmlspecialchars($content); + } - /** - * Return content after filter - * @return string - */ - 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'); + /** + * Return content after filter + * @return string + */ + 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
%s
', - $content, - $this->comment_srl, Context::getLang('cmd_comment_do') - ); - } - // if additional information which can access contents is set - if($add_content_info) { - $memberSrl = $this->get('member_srl'); - if($memberSrl < 0) + $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
%s
', + $content, + $this->comment_srl, Context::getLang('cmd_comment_do') + ); + } + // if additional information which can access contents is set + if($add_content_info) + { + $memberSrl = $this->get('member_srl'); + if($memberSrl < 0) + { + $memberSrl = 0; + } + $content = sprintf( + '
%s
', + $this->comment_srl, $memberSrl, + $this->comment_srl, $memberSrl, + $content, + $this->comment_srl, $memberSrl + ); + // xe_content class name should be specified although content access is not necessary. + } + else + { + if($add_xe_content_class) $content = sprintf('
%s
', $content); + } + + return $content; + } + + /** + * Return summary content + * @return string + */ + function getSummary($str_size = 50, $tail = '...') + { + $content = $this->getContent(false, false); + // for newline, insert a blank. + $content = preg_replace('!([\s]*)+!is', ' ', $content); + // replace tags such as

, , by blanks. + $content = str_replace(array('

', '', ''), ' ', $content); + // Remove tags + $content = preg_replace('!<([^>]*?)>!is','', $content); + // replace < , >, " + $content = str_replace(array('<','>','"',' '), array('<','>','"',' '), $content); + // delete a series of blanks + $content = preg_replace('/ ( +)/is', ' ', $content); + // truncate strings + $content = trim(cut_str($content, $str_size, $tail)); + // restore >, <, , "\ + $content = str_replace(array('<','>','"'),array('<','>','"'), $content); + + return $content; + } + + function getRegdate($format = 'Y.m.d H:i:s') + { + return zdate($this->get('regdate'), $format); + } + + function getRegdateTime() + { + $regdate = $this->get('regdate'); + $year = substr($regdate,0,4); + $month = substr($regdate,4,2); + $day = substr($regdate,6,2); + $hour = substr($regdate,8,2); + $min = substr($regdate,10,2); + $sec = substr($regdate,12,2); + return mktime($hour,$min,$sec,$month,$day,$year); + } + + function getRegdateGM() + { + return $this->getRegdate('D, d M Y H:i:s').' '.$GLOBALS['_time_zone']; + } + + function getUpdate($format = 'Y.m.d H:i:s') + { + return zdate($this->get('last_update'), $format); + } + + function getPermanentUrl() + { + return getFullUrl('','document_srl',$this->get('document_srl')).'#comment_'.$this->get('comment_srl'); + } + + function getUpdateTime() + { + $year = substr($this->get('last_update'),0,4); + $month = substr($this->get('last_update'),4,2); + $day = substr($this->get('last_update'),6,2); + $hour = substr($this->get('last_update'),8,2); + $min = substr($this->get('last_update'),10,2); + $sec = substr($this->get('last_update'),12,2); + return mktime($hour,$min,$sec,$month,$day,$year); + } + + function getUpdateGM() + { + return gmdate("D, d M Y H:i:s", $this->getUpdateTime()); + } + + function hasUploadedFiles() + { + if(($this->isSecret() && !$this->isAccessible()) && !$this->isGranted()) return false; + return $this->get('uploaded_count')? true : false; + } + + function getUploadedFiles() + { + if(($this->isSecret() && !$this->isAccessible()) && !$this->isGranted()) return; + if(!$this->get('uploaded_count')) return; + + $oFileModel = &getModel('file'); + $file_list = $oFileModel->getFiles($this->comment_srl, $is_admin); + return $file_list; + } + + /** + * Return the editor html + * @return string + */ + function getEditor() + { + $module_srl = $this->get('module_srl'); + if(!$module_srl) $module_srl = Context::get('module_srl'); + $oEditorModel = &getModel('editor'); + return $oEditorModel->getModuleEditor('comment', $module_srl, $this->comment_srl, 'comment_srl', 'content'); + } + + /** + * Return author's profile image + * @return object + */ + function getProfileImage() + { + if(!$this->isExists() || !$this->get('member_srl')) return; + $oMemberModel = &getModel('member'); + $profile_info = $oMemberModel->getProfileImage($this->get('member_srl')); + if(!$profile_info) return; + + return $profile_info->src; + } + + /** + * Return author's signiture + * @return string + */ + function getSignature() + { + // pass if the posting not exists. + if(!$this->isExists() || !$this->get('member_srl')) return; + // get the signiture information + $oMemberModel = &getModel('member'); + $signature = $oMemberModel->getSignature($this->get('member_srl')); + // check if max height of the signiture is specified on the member module + if(!isset($GLOBALS['__member_signature_max_height'])) + { + $oModuleModel = &getModel('module'); + $member_config = $oModuleModel->getModuleConfig('member'); + $GLOBALS['__member_signature_max_height'] = $member_config->signature_max_height; + } + $max_signature_height = $GLOBALS['__member_signature_max_height']; + if($max_signature_height) $signature = sprintf('
%s
', $max_signature_height, $max_signature_height, $max_signature_height, $signature); + + return $signature; + } + + function thumbnailExists($width = 80, $height = 0, $type = '') + { + if(!$this->comment_srl) return false; + if(!$this->getThumbnail($width, $height, $type)) return false; + return true; + } + + function getThumbnail($width = 80, $height = 0, $thumbnail_type = '') + { + // return false if no doc exists + if(!$this->comment_srl) return; + // If signiture height setting is omitted, create a square + if(!$height) $height = $width; + // return false if neigher attached file nor image; + if(!$this->hasUploadedFiles() && !preg_match("!get('content'))) return; + // get thumbail generation info on the doc module configuration. + if(!in_array($thumbnail_type, array('crop','ratio'))) $thumbnail_type = 'crop'; + // Define thumbnail information + $thumbnail_path = sprintf('files/cache/thumbnails/%s',getNumberingPath($this->comment_srl, 3)); + $thumbnail_file = sprintf('%s%dx%d.%s.jpg', $thumbnail_path, $width, $height, $thumbnail_type); + $thumbnail_url = Context::getRequestUri().$thumbnail_file; + // return false if a size of existing thumbnail file is 0. otherwise return the file path + if(file_exists($thumbnail_file)) + { + if(filesize($thumbnail_file)<1) return false; + else return $thumbnail_url; + } + // Target file + $source_file = null; + $is_tmp_file = false; + // find an image file among attached files + if($this->hasUploadedFiles()) + { + $file_list = $this->getUploadedFiles(); + if(count($file_list)) + { + foreach($file_list as $file) { - $memberSrl = 0; + if($file->direct_download!='Y') continue; + if(!preg_match("/\.(jpg|png|jpeg|gif|bmp)$/i",$file->source_filename)) continue; + + $source_file = $file->uploaded_filename; + if(!file_exists($source_file)) $source_file = null; + else break; } - $content = sprintf( - '
%s
', - $this->comment_srl, $memberSrl, - $this->comment_srl, $memberSrl, - $content, - $this->comment_srl, $memberSrl - ); - // xe_content class name should be specified although content access is not necessary. - } else { - if($add_xe_content_class) $content = sprintf('
%s
', $content); - } + } + } + // get an image file from the doc content if no file attached. + if(!$source_file) + { + $content = $this->get('content'); + $target_src = null; + preg_match_all("!src=(\"|')([^\"' ]*?)(\"|')!is", $content, $matches, PREG_SET_ORDER); + $cnt = count($matches); + for($i=0;$i<$cnt;$i++) + { + $target_src = $matches[$i][2]; + if(preg_match('/\/(common|modules|widgets|addons|layouts)\//i', $target_src)) continue; + else + { + if(!preg_match('/^(http|https):\/\//i',$target_src)) $target_src = Context::getRequestUri().$target_src; - return $content; - } + $tmp_file = sprintf('./files/cache/tmp/%d', md5(rand(111111,999999).$this->comment_srl)); + if(!is_dir('./files/cache/tmp')) FileHandler::makeDir('./files/cache/tmp'); + FileHandler::getRemoteFile($target_src, $tmp_file); + if(!file_exists($tmp_file)) continue; + else + { + list($_w, $_h, $_t, $_a) = @getimagesize($tmp_file); + if($_w<$width || $_h<$height) continue; - /** - * Return summary content - * @return string - */ - function getSummary($str_size = 50, $tail = '...') { - $content = $this->getContent(false, false); - // for newline, insert a blank. - $content = preg_replace('!([\s]*)+!is', ' ', $content); - // replace tags such as

, , by blanks. - $content = str_replace(array('

', '', ''), ' ', $content); - // Remove tags - $content = preg_replace('!<([^>]*?)>!is','', $content); - // replace < , >, " - $content = str_replace(array('<','>','"',' '), array('<','>','"',' '), $content); - // delete a series of blanks - $content = preg_replace('/ ( +)/is', ' ', $content); - // truncate strings - $content = trim(cut_str($content, $str_size, $tail)); - // restore >, <, , "\ - $content = str_replace(array('<','>','"'),array('<','>','"'), $content); + $source_file = $tmp_file; + $is_tmp_file = true; + break; + } + } + } + } - return $content; - } + $output = FileHandler::createImageFile($source_file, $thumbnail_file, $width, $height, 'jpg', $thumbnail_type); - function getRegdate($format = 'Y.m.d H:i:s') { - return zdate($this->get('regdate'), $format); - } + if($is_tmp_file) FileHandler::removeFile($source_file); + // return the thumbnail path if successfully generated. + if($output) return $thumbnail_url; + // create an empty file not to attempt to generate the thumbnail afterwards + else FileHandler::writeFile($thumbnail_file, '','w'); - function getRegdateTime() { - $regdate = $this->get('regdate'); - $year = substr($regdate,0,4); - $month = substr($regdate,4,2); - $day = substr($regdate,6,2); - $hour = substr($regdate,8,2); - $min = substr($regdate,10,2); - $sec = substr($regdate,12,2); - return mktime($hour,$min,$sec,$month,$day,$year); - } + return; + } - function getRegdateGM() { - return $this->getRegdate('D, d M Y H:i:s').' '.$GLOBALS['_time_zone']; - } - - function getUpdate($format = 'Y.m.d H:i:s') { - return zdate($this->get('last_update'), $format); - } - - function getPermanentUrl() { - return getFullUrl('','document_srl',$this->get('document_srl')).'#comment_'.$this->get('comment_srl'); - } - - - function getUpdateTime() { - $year = substr($this->get('last_update'),0,4); - $month = substr($this->get('last_update'),4,2); - $day = substr($this->get('last_update'),6,2); - $hour = substr($this->get('last_update'),8,2); - $min = substr($this->get('last_update'),10,2); - $sec = substr($this->get('last_update'),12,2); - return mktime($hour,$min,$sec,$month,$day,$year); - } - - function getUpdateGM() { - return gmdate("D, d M Y H:i:s", $this->getUpdateTime()); - } - - function hasUploadedFiles() { - if(($this->isSecret() && !$this->isAccessible()) && !$this->isGranted()) return false; - return $this->get('uploaded_count')? true : false; - } - - function getUploadedFiles() { - if(($this->isSecret() && !$this->isAccessible()) && !$this->isGranted()) return; - if(!$this->get('uploaded_count')) return; - - $oFileModel = &getModel('file'); - $file_list = $oFileModel->getFiles($this->comment_srl, $is_admin); - return $file_list; - } - - /** - * Return the editor html - * @return string - */ - function getEditor() { - $module_srl = $this->get('module_srl'); - if(!$module_srl) $module_srl = Context::get('module_srl'); - $oEditorModel = &getModel('editor'); - return $oEditorModel->getModuleEditor('comment', $module_srl, $this->comment_srl, 'comment_srl', 'content'); - } - - /** - * Return author's profile image - * @return object - */ - function getProfileImage() { - if(!$this->isExists() || !$this->get('member_srl')) return; - $oMemberModel = &getModel('member'); - $profile_info = $oMemberModel->getProfileImage($this->get('member_srl')); - if(!$profile_info) return; - - return $profile_info->src; - } - - /** - * Return author's signiture - * @return string - */ - function getSignature() { - // pass if the posting not exists. - if(!$this->isExists() || !$this->get('member_srl')) return; - // get the signiture information - $oMemberModel = &getModel('member'); - $signature = $oMemberModel->getSignature($this->get('member_srl')); - // check if max height of the signiture is specified on the member module - if(!isset($GLOBALS['__member_signature_max_height'])) { - $oModuleModel = &getModel('module'); - $member_config = $oModuleModel->getModuleConfig('member'); - $GLOBALS['__member_signature_max_height'] = $member_config->signature_max_height; - } - $max_signature_height = $GLOBALS['__member_signature_max_height']; - if($max_signature_height) $signature = sprintf('
%s
', $max_signature_height, $max_signature_height, $max_signature_height, $signature); - - return $signature; - } - - function thumbnailExists($width = 80, $height = 0, $type = '') { - if(!$this->comment_srl) return false; - if(!$this->getThumbnail($width, $height, $type)) return false; - return true; - } - - function getThumbnail($width = 80, $height = 0, $thumbnail_type = '') { - // return false if no doc exists - if(!$this->comment_srl) return; - // If signiture height setting is omitted, create a square - if(!$height) $height = $width; - // return false if neigher attached file nor image; - if(!$this->hasUploadedFiles() && !preg_match("!get('content'))) return; - // get thumbail generation info on the doc module configuration. - if(!in_array($thumbnail_type, array('crop','ratio'))) $thumbnail_type = 'crop'; - // Define thumbnail information - $thumbnail_path = sprintf('files/cache/thumbnails/%s',getNumberingPath($this->comment_srl, 3)); - $thumbnail_file = sprintf('%s%dx%d.%s.jpg', $thumbnail_path, $width, $height, $thumbnail_type); - $thumbnail_url = Context::getRequestUri().$thumbnail_file; - // return false if a size of existing thumbnail file is 0. otherwise return the file path - if(file_exists($thumbnail_file)) { - if(filesize($thumbnail_file)<1) return false; - else return $thumbnail_url; - } - // Target file - $source_file = null; - $is_tmp_file = false; - // find an image file among attached files - if($this->hasUploadedFiles()) { - $file_list = $this->getUploadedFiles(); - if(count($file_list)) { - foreach($file_list as $file) { - if($file->direct_download!='Y') continue; - if(!preg_match("/\.(jpg|png|jpeg|gif|bmp)$/i",$file->source_filename)) continue; - - $source_file = $file->uploaded_filename; - if(!file_exists($source_file)) $source_file = null; - else break; - } - } - } - // get an image file from the doc content if no file attached. - if(!$source_file) { - $content = $this->get('content'); - $target_src = null; - preg_match_all("!src=(\"|')([^\"' ]*?)(\"|')!is", $content, $matches, PREG_SET_ORDER); - $cnt = count($matches); - for($i=0;$i<$cnt;$i++) { - $target_src = $matches[$i][2]; - if(preg_match('/\/(common|modules|widgets|addons|layouts)\//i', $target_src)) continue; - else { - if(!preg_match('/^(http|https):\/\//i',$target_src)) $target_src = Context::getRequestUri().$target_src; - $tmp_file = sprintf('./files/cache/tmp/%d', md5(rand(111111,999999).$this->comment_srl)); - if(!is_dir('./files/cache/tmp')) FileHandler::makeDir('./files/cache/tmp'); - FileHandler::getRemoteFile($target_src, $tmp_file); - if(!file_exists($tmp_file)) continue; - else { - list($_w, $_h, $_t, $_a) = @getimagesize($tmp_file); - if($_w<$width || $_h<$height) continue; - - $source_file = $tmp_file; - $is_tmp_file = true; - break; - } - } - } - } - - $output = FileHandler::createImageFile($source_file, $thumbnail_file, $width, $height, 'jpg', $thumbnail_type); - - if($is_tmp_file) FileHandler::removeFile($source_file); - // return the thumbnail path if successfully generated. - if($output) return $thumbnail_url; - // create an empty file not to attempt to generate the thumbnail afterwards - else FileHandler::writeFile($thumbnail_file, '','w'); - - return; - } - - function isCarted() { - return $_SESSION['comment_management'][$this->comment_srl]; - } - } -?> + function isCarted() + { + return $_SESSION['comment_management'][$this->comment_srl]; + } +} +/* End of file comment.item.php */ +/* Location: ./modules/comment/comment.item.php */ diff --git a/modules/communication/communication.admin.controller.php b/modules/communication/communication.admin.controller.php index 0fd2f3621..75900a8ac 100644 --- a/modules/communication/communication.admin.controller.php +++ b/modules/communication/communication.admin.controller.php @@ -1,41 +1,42 @@ editor_colorset = $args->sel_editor_colorset; + unset($args->sel_editor_colorset); - /** - * Initialization - **/ - function init() { - } + if(!$args->skin) $args->skin = 'default'; + if(!$args->colorset) $args->colorset = 'white'; + if(!$args->editor_skin) $args->editor_skin = 'default'; + if(!$args->mskin) $args->mskin = 'default'; + if(!$args->layout_srl) $args->layout_srl = null; - /** - * save configurations of the communication module - * @return void|Object (success : void, fail : Object) - **/ - function procCommunicationAdminInsertConfig() { - // get the default information - $args = Context::gets('skin','colorset','editor_skin','sel_editor_colorset', 'mskin', 'mcolorset', 'layout_srl', 'mlayout_srl'); - $args->editor_colorset = $args->sel_editor_colorset; - unset($args->sel_editor_colorset); + // create the module module Controller object + $oModuleController = &getController('module'); + $output = $oModuleController->insertModuleConfig('communication',$args); - if(!$args->skin) $args->skin = 'default'; - if(!$args->colorset) $args->colorset = 'white'; - if(!$args->editor_skin) $args->editor_skin = 'default'; - if(!$args->mskin) $args->mskin = 'default'; - if(!$args->layout_srl) $args->layout_srl = null; - - // create the module module Controller object - $oModuleController = &getController('module'); - $output = $oModuleController->insertModuleConfig('communication',$args); - - $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispCommunicationAdminConfig'); - return $this->setRedirectUrl($returnUrl, $output); - } - - } -?> + $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispCommunicationAdminConfig'); + return $this->setRedirectUrl($returnUrl, $output); + } +} +/* End of file communication.admin.controller.php */ +/* Location: ./modules/comment/communication.admin.controller.php */ diff --git a/modules/communication/communication.admin.model.php b/modules/communication/communication.admin.model.php index 626d800bd..2f3681534 100644 --- a/modules/communication/communication.admin.model.php +++ b/modules/communication/communication.admin.model.php @@ -1,58 +1,61 @@ loadSkinInfo($this->module_path, $skin, $dir); + Context::set('skin_info', $skin_info); - if($type == 'P') - { - $dir = 'skins'; - } - else - { - $dir = 'm.skins'; - } + $oModuleModel = &getModel('module'); + $communication_config = $oModuleModel->getModuleConfig('communication'); + if(!$communication_config->colorset) $communication_config->colorset = "white"; + Context::set('communication_config', $communication_config); - if(!$skin) $tpl = ""; - else { - $oModuleModel = &getModel('module'); - $skin_info = $oModuleModel->loadSkinInfo($this->module_path, $skin, $dir); - Context::set('skin_info', $skin_info); + $security = new Security(); + $security->encodeHTML('skin_info.colorset..title','skin_info.colorset..name'); + $security->encodeHTML('skin_info.colorset..name'); - $oModuleModel = &getModel('module'); - $communication_config = $oModuleModel->getModuleConfig('communication'); - if(!$communication_config->colorset) $communication_config->colorset = "white"; - Context::set('communication_config', $communication_config); - - $security = new Security(); - $security->encodeHTML('skin_info.colorset..title','skin_info.colorset..name'); - $security->encodeHTML('skin_info.colorset..name'); + $oTemplate = &TemplateHandler::getInstance(); + $tpl = $oTemplate->compile($this->module_path.'tpl', 'colorset_list'); + } - $oTemplate = &TemplateHandler::getInstance(); - $tpl = $oTemplate->compile($this->module_path.'tpl', 'colorset_list'); - } + $this->add('tpl', $tpl); + $this->add('type', $type); + } - $this->add('tpl', $tpl); - $this->add('type', $type); - } - - } -?> +} +/* End of file communication.admin.model.php */ +/* Location: ./modules/comment/communication.admin.model.php */ diff --git a/modules/communication/communication.admin.view.php b/modules/communication/communication.admin.view.php index 3b3c26448..b0fddfa43 100644 --- a/modules/communication/communication.admin.view.php +++ b/modules/communication/communication.admin.view.php @@ -1,58 +1,58 @@ getConfig() ); + // get a list of layout + Context::set('layout_list', $oLayoutModel->getLayoutList() ); + // get a list of editor skins + Context::set('editor_skin_list', $oEditorModel->getEditorSkinList() ); + // get a list of communication skins + Context::set('communication_skin_list', $oModuleModel->getSkins($this->module_path) ); + // get a list of communication skins + Context::set('communication_mobile_skin_list', $oModuleModel->getSkins($this->module_path, 'm.skins') ); - /** - * Initialization - **/ - function init() { - } + // Get a layout list + $layout_list = $oLayoutModel->getLayoutList(); + Context::set('layout_list', $layout_list); - /** - * configuration to manage messages and friends - * @return void - **/ - function dispCommunicationAdminConfig() - { - // Creating an object - $oEditorModel = &getModel('editor'); - $oModuleModel = &getModel('module'); - $oLayoutModel = &getModel('layout'); - $oCommunicationModel = &getModel('communication'); - // get the configurations of communication module - Context::set('communication_config', $oCommunicationModel->getConfig() ); - // get a list of layout - Context::set('layout_list', $oLayoutModel->getLayoutList() ); - // get a list of editor skins - Context::set('editor_skin_list', $oEditorModel->getEditorSkinList() ); - // get a list of communication skins - Context::set('communication_skin_list', $oModuleModel->getSkins($this->module_path) ); - // get a list of communication skins - Context::set('communication_mobile_skin_list', $oModuleModel->getSkins($this->module_path, 'm.skins') ); + $mlayout_list = $oLayoutModel->getLayoutList(0, 'M'); + Context::set('mlayout_list', $mlayout_list); - // Get a layout list - $layout_list = $oLayoutModel->getLayoutList(); - Context::set('layout_list', $layout_list); + $security = new Security(); + $security->encodeHTML('communication_config..'); + $security->encodeHTML('layout_list..'); + $security->encodeHTML('editor_skin_list..'); + $security->encodeHTML('communication_skin_list..title'); + $security->encodeHTML('communication_mobile_skin_list..title'); - $mlayout_list = $oLayoutModel->getLayoutList(0, 'M'); - Context::set('mlayout_list', $mlayout_list); - - $security = new Security(); - $security->encodeHTML('communication_config..'); - $security->encodeHTML('layout_list..'); - $security->encodeHTML('editor_skin_list..'); - $security->encodeHTML('communication_skin_list..title'); - $security->encodeHTML('communication_mobile_skin_list..title'); - - // specify a template - $this->setTemplatePath($this->module_path.'tpl'); - $this->setTemplateFile('index'); - } - - } -?> + // specify a template + $this->setTemplatePath($this->module_path.'tpl'); + $this->setTemplateFile('index'); + } +} +/* End of file communication.admin.view.php */ +/* Location: ./modules/comment/communication.admin.view.php */ diff --git a/modules/communication/communication.class.php b/modules/communication/communication.class.php index 9c22b7443..d274996f8 100644 --- a/modules/communication/communication.class.php +++ b/modules/communication/communication.class.php @@ -1,77 +1,81 @@ getModuleConfig('message'); - /** - * method to check if successfully installed. - * @return boolean true : need to update false : don't need to update - **/ - function checkUpdate() { - if(!is_dir("./files/member_extra_info/new_message_flags")) return true; - - $oModuleModel = &getModel('module'); - $config = $oModuleModel->getModuleConfig('message'); - - if($config->skin) + if($config->skin) + { + $config_parse = explode('.', $config->skin); + if (count($config_parse) > 1) { - $config_parse = explode('.', $config->skin); - if (count($config_parse) > 1) + $template_path = sprintf('./themes/%s/modules/communication/', $config_parse[0]); + if(is_dir($template_path)) return true; + } + } + return false; + } + + /** + * Update + * @return Object + */ + function moduleUpdate() + { + if(!is_dir("./files/member_extra_info/new_message_flags")) + FileHandler::makeDir('./files/member_extra_info/new_message_flags'); + + $oModuleModel = &getModel('module'); + $config = $oModuleModel->getModuleConfig('message'); + + if($config->skin) + { + $config_parse = explode('.', $config->skin); + if (count($config_parse) > 1) + { + $template_path = sprintf('./themes/%s/modules/communication/', $config_parse[0]); + if(is_dir($template_path)) { - $template_path = sprintf('./themes/%s/modules/communication/', $config_parse[0]); - if(is_dir($template_path)) return true; + $config->skin = implode('|@|', $config_parse); + $oModuleController = &getController('module'); + $oModuleController->updateModuleConfig('communication', $config); } } - return false; - } + } + return new Object(0, 'success_updated'); + } - /** - * Update - * @return Object - **/ - function moduleUpdate() { - if(!is_dir("./files/member_extra_info/new_message_flags")) - FileHandler::makeDir('./files/member_extra_info/new_message_flags'); - - $oModuleModel = &getModel('module'); - $config = $oModuleModel->getModuleConfig('message'); - - if($config->skin) - { - $config_parse = explode('.', $config->skin); - if (count($config_parse) > 1) - { - $template_path = sprintf('./themes/%s/modules/communication/', $config_parse[0]); - if(is_dir($template_path)) - { - $config->skin = implode('|@|', $config_parse); - $oModuleController = &getController('module'); - $oModuleController->updateModuleConfig('communication', $config); - } - } - } - return new Object(0, 'success_updated'); - } - - /** - * Re-generate the cache file - * @return void - **/ - function recompileCache() { - } - } -?> + /** + * Re-generate the cache file + * @return void + */ + function recompileCache() + { + } +} +/* End of file communication.class.php */ +/* Location: ./modules/comment/communication.class.php */ diff --git a/modules/communication/communication.controller.php b/modules/communication/communication.controller.php index 7965872e1..896206cb5 100644 --- a/modules/communication/communication.controller.php +++ b/modules/communication/communication.controller.php @@ -1,483 +1,514 @@ allow_message = Context::get('allow_message'); + if(!in_array($args->allow_message, array('Y','N','F'))) $args->allow_message = 'Y'; - /** - * change the settings of message box - * @return void|Object (success : void, fail : Object) - **/ - function procCommunicationUpdateAllowMessage() { - if(!Context::get('is_logged')) return new Object(-1, 'msg_not_logged'); + $logged_info = Context::get('logged_info'); + $args->member_srl = $logged_info->member_srl; - $args->allow_message = Context::get('allow_message'); - if(!in_array($args->allow_message, array('Y','N','F'))) $args->allow_message = 'Y'; + $output = executeQuery('communication.updateAllowMessage', $args); - $logged_info = Context::get('logged_info'); - $args->member_srl = $logged_info->member_srl; + $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'mid', Context::get('mid'), 'act', 'dispCommunicationMessages', 'message_type', Context::get('message_type')); + return $this->setRedirectUrl($returnUrl, $output); + } - $output = executeQuery('communication.updateAllowMessage', $args); + /** + * Send a message + * @return Object + */ + function procCommunicationSendMessage() + { + // Check login information + if(!Context::get('is_logged')) return new Object(-1, 'msg_not_logged'); + $logged_info = Context::get('logged_info'); + // Check variables + $receiver_srl = Context::get('receiver_srl'); + if(!$receiver_srl) return new Object(-1, 'msg_not_exists_member'); - $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'mid', Context::get('mid'), 'act', 'dispCommunicationMessages', 'message_type', Context::get('message_type')); - return $this->setRedirectUrl($returnUrl, $output); - } + $title = trim(Context::get('title')); + if(!$title) return new Object(-1, 'msg_title_is_null'); - /** - * Send a message - * @return Object - **/ - function procCommunicationSendMessage() { - // Check login information - if(!Context::get('is_logged')) return new Object(-1, 'msg_not_logged'); - $logged_info = Context::get('logged_info'); - // Check variables - $receiver_srl = Context::get('receiver_srl'); - if(!$receiver_srl) return new Object(-1, 'msg_not_exists_member'); + $content = trim(Context::get('content')); + if(!$content) return new Object(-1, 'msg_content_is_null'); - $title = trim(Context::get('title')); - if(!$title) return new Object(-1, 'msg_title_is_null'); + $send_mail = Context::get('send_mail'); + if($send_mail != 'Y') $send_mail = 'N'; + // Check if there is a member to receive a message + $oMemberModel = &getModel('member'); + $oCommunicationModel = &getModel('communication'); + $receiver_member_info = $oMemberModel->getMemberInfoByMemberSrl($receiver_srl); + if($receiver_member_info->member_srl != $receiver_srl) return new Object(-1, 'msg_not_exists_member'); + // check whether to allow to receive the message(pass if a top-administrator) + if($logged_info->is_admin != 'Y') + { + if($receiver_member_info->allow_message == 'F') + { + if(!$oCommunicationModel->isFriend($receiver_member_info->member_srl)) return new object(-1, 'msg_allow_message_to_friend'); + } + else if($receiver_member_info->allow_message == 'N') + { + return new object(-1, 'msg_disallow_message'); + } + } + // send a message + $output = $this->sendMessage($logged_info->member_srl, $receiver_srl, $title, $content); + // send an e-mail + if($output->toBool() && $send_mail == 'Y') + { + $view_url = Context::getRequestUri(); + $content = sprintf("%s

From : %s",$content, $view_url, $view_url); + $oMail = new Mail(); + $oMail->setTitle($title); + $oMail->setContent($content); + $oMail->setSender($logged_info->nick_name, $logged_info->email_address); + $oMail->setReceiptor($receiver_member_info->nick_name, $receiver_member_info->email_address); + $oMail->send(); + } - $content = trim(Context::get('content')); - if(!$content) return new Object(-1, 'msg_content_is_null'); + if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) + { + global $lang; + htmlHeader(); + alertScript($lang->success_sended); + closePopupScript(); + htmlFooter(); + Context::close(); + exit; + } + return $output; + } - $send_mail = Context::get('send_mail'); - if($send_mail != 'Y') $send_mail = 'N'; - // Check if there is a member to receive a message - $oMemberModel = &getModel('member'); - $oCommunicationModel = &getModel('communication'); - $receiver_member_info = $oMemberModel->getMemberInfoByMemberSrl($receiver_srl); - if($receiver_member_info->member_srl != $receiver_srl) return new Object(-1, 'msg_not_exists_member'); - // check whether to allow to receive the message(pass if a top-administrator) - if($logged_info->is_admin != 'Y') { - if($receiver_member_info->allow_message == 'F') { - if(!$oCommunicationModel->isFriend($receiver_member_info->member_srl)) return new object(-1, 'msg_allow_message_to_friend'); - } elseif($receiver_member_info->allow_message == 'N') { - return new object(-1, 'msg_disallow_message'); - } - } - // send a message - $output = $this->sendMessage($logged_info->member_srl, $receiver_srl, $title, $content); - // send an e-mail - if($output->toBool() && $send_mail == 'Y') { - $view_url = Context::getRequestUri(); - $content = sprintf("%s

From : %s",$content, $view_url, $view_url); - $oMail = new Mail(); - $oMail->setTitle($title); - $oMail->setContent($content); - $oMail->setSender($logged_info->nick_name, $logged_info->email_address); - $oMail->setReceiptor($receiver_member_info->nick_name, $receiver_member_info->email_address); - $oMail->send(); - } + /** + * Send a message (DB controll) + * @param int $sender_srl member_srl of sender + * @param int $receiver_srl member_srl of receiver_srl + * @param string $title + * @param string $content + * @param boolean $sender_log (default true) + * @return Object + */ + function sendMessage($sender_srl, $receiver_srl, $title, $content, $sender_log = true) + { + $content = removeHackTag($content); + $title = htmlspecialchars($title); + // messages to save in the sendor's message box + $sender_args->sender_srl = $sender_srl; + $sender_args->receiver_srl = $receiver_srl; + $sender_args->message_type = 'S'; + $sender_args->title = $title; + $sender_args->content = $content; + $sender_args->readed = 'N'; + $sender_args->regdate = date("YmdHis"); + $sender_args->related_srl = getNextSequence(); + $sender_args->message_srl = getNextSequence(); + $sender_args->list_order = getNextSequence()*-1; + // messages to save in the receiver's message box + $receiver_args->message_srl = $sender_args->related_srl; + $receiver_args->related_srl = 0; + $receiver_args->list_order = $sender_args->related_srl*-1; + $receiver_args->sender_srl = $sender_srl; + if(!$receiver_args->sender_srl) $receiver_args->sender_srl = $receiver_srl; + $receiver_args->receiver_srl = $receiver_srl; + $receiver_args->message_type = 'R'; + $receiver_args->title = $title; + $receiver_args->content = $content; + $receiver_args->readed = 'N'; + $receiver_args->regdate = date("YmdHis"); - if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) { + $oDB = &DB::getInstance(); + $oDB->begin(); + // messages to save in the sendor's message box + if($sender_srl && $sender_log) + { + $output = executeQuery('communication.sendMessage', $sender_args); + if(!$output->toBool()) + { + $oDB->rollback(); + return $output; + } + } + // messages to save in the receiver's message box + $output = executeQuery('communication.sendMessage', $receiver_args); + if(!$output->toBool()) + { + $oDB->rollback(); + return $output; + } + // create a flag that message is sent (in file format) + $flag_path = './files/member_extra_info/new_message_flags/'.getNumberingPath($receiver_srl); + FileHandler::makeDir($flag_path); + $flag_file = sprintf('%s%s', $flag_path, $receiver_srl); + $flag_count = FileHandler::readFile($flag_file); + FileHandler::writeFile($flag_file, ++$flag_count); + + $oDB->commit(); + + return new Object(0,'success_sended'); + } + + /** + * store a specific message into the archive + * @return void|Object (success : void, fail : Object) + */ + function procCommunicationStoreMessage() + { + // Check login information + if(!Context::get('is_logged')) return new Object(-1, 'msg_not_logged'); + $logged_info = Context::get('logged_info'); + // Check variable + $message_srl = Context::get('message_srl'); + if(!$message_srl) return new Object(-1,'msg_invalid_request'); + // get the message + $oCommunicationModel = &getModel('communication'); + $message = $oCommunicationModel->getSelectedMessage($message_srl); + if(!$message || $message->message_type != 'R') return new Object(-1,'msg_invalid_request'); + + $args->message_srl = $message_srl; + $args->receiver_srl = $logged_info->member_srl; + $output = executeQuery('communication.setMessageStored', $args); + if(!$output->toBool()) return $output; + + $this->setMessage('success_registed'); + } + + /** + * Delete a message + * @return void|Object (success : void, fail : Object) + */ + function procCommunicationDeleteMessage() + { + // Check login information + if(!Context::get('is_logged')) return new Object(-1, 'msg_not_logged'); + $logged_info = Context::get('logged_info'); + $member_srl = $logged_info->member_srl; + // Check the variable + $message_srl = Context::get('message_srl'); + if(!$message_srl) return new Object(-1,'msg_invalid_request'); + // Get the message + $oCommunicationModel = &getModel('communication'); + $message = $oCommunicationModel->getSelectedMessage($message_srl); + if(!$message) return new Object(-1,'msg_invalid_request'); + // Check the grant + switch($message->message_type) + { + case 'S': + if($message->sender_srl != $member_srl) return new Object(-1, 'msg_invalid_request'); + break; + case 'R': + if($message->receiver_srl != $member_srl) return new Object(-1, 'msg_invalid_request'); + break; + } + // Delete + $args->message_srl = $message_srl; + $output = executeQuery('communication.deleteMessage', $args); + if(!$output->toBool()) return $output; + + $this->setMessage('success_deleted'); + } + + /** + * Delete the multiple messages + * @return void|Object (success : void, fail : Object) + */ + function procCommunicationDeleteMessages() + { + // Check login information + if(!Context::get('is_logged')) return new Object(-1, 'msg_not_logged'); + $logged_info = Context::get('logged_info'); + $member_srl = $logged_info->member_srl; + // check variables + if(!Context::get('message_srl_list')) return new Object(-1, 'msg_cart_is_null'); + + $message_srl_list = Context::get('message_srl_list'); + if(!is_array($message_srl_list)) $message_srl_list = explode('|@|', trim($message_srl_list)); + if(!count($message_srl_list)) return new Object(-1, 'msg_cart_is_null'); + + $message_type = Context::get('message_type'); + if(!$message_type || !in_array($message_type, array('R','S','T'))) return new Object(-1, 'msg_invalid_request'); + + $message_count = count($message_srl_list); + $target = array(); + for($i=0;$i<$message_count;$i++) + { + $message_srl = (int)trim($message_srl_list[$i]); + if(!$message_srl) continue; + $target[] = $message_srl; + } + if(!count($target)) return new Object(-1,'msg_cart_is_null'); + // Delete + $args->message_srls = implode(',',$target); + $args->message_type = $message_type; + + if($message_type == 'S') $args->sender_srl = $member_srl; + else $args->receiver_srl = $member_srl; + + $output = executeQuery('communication.deleteMessages', $args); + if(!$output->toBool()) return $output; + + $this->setMessage('success_deleted'); + + $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'mid', Context::get('mid'), 'act', 'dispCommunicationMessages', 'message_type', Context::get('message_type')); + $this->setRedirectUrl($returnUrl); + } + + /** + * Add a friend + * @return void|Object (success : void, fail : Object) + */ + function procCommunicationAddFriend() + { + // Check login information + if(!Context::get('is_logged')) return new Object(-1, 'msg_not_logged'); + $logged_info = Context::get('logged_info'); + + $target_srl = (int)trim(Context::get('target_srl')); + if(!$target_srl) return new Object(-1,'msg_invalid_request'); + // Variable + $args->friend_srl = getNextSequence(); + $args->list_order = $args->friend_srl * -1; + $args->friend_group_srl = Context::get('friend_group_srl'); + $args->member_srl = $logged_info->member_srl; + $args->target_srl = $target_srl; + $output = executeQuery('communication.addFriend', $args); + if(!$output->toBool()) return $output; + + $this->add('member_srl', $target_srl); + $this->setMessage('success_registed'); + + if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) + { + global $lang; + htmlHeader(); + alertScript($lang->success_registed); + closePopupScript(); + htmlFooter(); + Context::close(); + exit; + } + } + + /** + * Move a group of the friend + * @return void|Object (success : void, fail : Object) + */ + function procCommunicationMoveFriend() + { + // Check login information + if(!Context::get('is_logged')) + { + return new Object(-1, 'msg_not_logged'); + } + + $logged_info = Context::get('logged_info'); + // Check variables + $friend_srl_list = Context::get('friend_srl_list'); + if(!$friend_srl_list) + { + return new Object(-1, 'msg_cart_is_null'); + } + + if(!is_array($friend_srl_list)) + { + $friend_srl_list = explode('|@|', $friend_srl_list); + } + + if(!count($friend_srl_list)) return new Object(-1, 'msg_cart_is_null'); + + $friend_count = count($friend_srl_list); + $target = array(); + for($i=0;$i<$friend_count;$i++) + { + $friend_srl = (int)trim($friend_srl_list[$i]); + if(!$friend_srl) continue; + $target[] = $friend_srl; + } + if(!count($target)) return new Object(-1,'msg_cart_is_null'); + // Variables + $args->friend_srls = implode(',',$target); + $args->member_srl = $logged_info->member_srl; + $args->friend_group_srl = Context::get('target_friend_group_srl'); + + $output = executeQuery('communication.moveFriend', $args); + if(!$output->toBool()) return $output; + + $this->setMessage('success_moved'); + + $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'mid', Context::get('mid'), 'act', 'dispCommunicationFriend'); + $this->setRedirectUrl($returnUrl); + } + + /** + * Delete a friend + * @return void|Object (success : void, fail : Object) + */ + function procCommunicationDeleteFriend() + { + // Check login information + if(!Context::get('is_logged')) return new Object(-1, 'msg_not_logged'); + $logged_info = Context::get('logged_info'); + $member_srl = $logged_info->member_srl; + // Check variables + $friend_srl_list = Context::get('friend_srl_list'); + + if(!is_array($friend_srl_list)) + { + $friend_srl_list = explode('|@|', $friend_srl_list); + } + if(!count($friend_srl_list)) return new Object(-1, 'msg_cart_is_null'); + + $friend_count = count($friend_srl_list); + $target = array(); + for($i=0;$i<$friend_count;$i++) + { + $friend_srl = (int)trim($friend_srl_list[$i]); + if(!$friend_srl) continue; + $target[] = $friend_srl; + } + if(!count($target)) return new Object(-1,'msg_cart_is_null'); + // Delete + $args->friend_srls = implode(',',$target); + $args->member_srl = $logged_info->member_srl; + $output = executeQuery('communication.deleteFriend', $args); + if(!$output->toBool()) return $output; + + $this->setMessage('success_deleted'); + + $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'mid', Context::get('mid'), 'act', 'dispCommunicationFriend'); + $this->setRedirectUrl($returnUrl); + } + + /** + * Add a group of friends + * @return void|Object (success : void, fail : Object) + */ + function procCommunicationAddFriendGroup() + { + // Check login information + if(!Context::get('is_logged')) return new Object(-1, 'msg_not_logged'); + $logged_info = Context::get('logged_info'); + // Variables + $args->friend_group_srl = trim(Context::get('friend_group_srl')); + $args->member_srl = $logged_info->member_srl; + $args->title = Context::get('title'); + $args->title = htmlspecialchars($args->title); + if(!$args->title) return new Object(-1, 'msg_invalid_request'); + // modify if friend_group_srl exists. + if($args->friend_group_srl) + { + $output = executeQuery('communication.renameFriendGroup', $args); + $msg_code = 'success_updated'; + // add if not exists + } + else + { + $output = executeQuery('communication.addFriendGroup', $args); + $msg_code = 'success_registed'; + } + + if(!$output->toBool()) + { + if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) + { global $lang; htmlHeader(); - alertScript($lang->success_sended); + alertScript($lang->fail_to_registed); closePopupScript(); htmlFooter(); Context::close(); exit; } - return $output; - } - - /** - * Send a message (DB controll) - * @param int $sender_srl member_srl of sender - * @param int $receiver_srl member_srl of receiver_srl - * @param string $title - * @param string $content - * @param boolean $sender_log (default true) - * @return Object - **/ - function sendMessage($sender_srl, $receiver_srl, $title, $content, $sender_log = true) { - $content = removeHackTag($content); - $title = htmlspecialchars($title); - // messages to save in the sendor's message box - $sender_args->sender_srl = $sender_srl; - $sender_args->receiver_srl = $receiver_srl; - $sender_args->message_type = 'S'; - $sender_args->title = $title; - $sender_args->content = $content; - $sender_args->readed = 'N'; - $sender_args->regdate = date("YmdHis"); - $sender_args->related_srl = getNextSequence(); - $sender_args->message_srl = getNextSequence(); - $sender_args->list_order = getNextSequence()*-1; - // messages to save in the receiver's message box - $receiver_args->message_srl = $sender_args->related_srl; - $receiver_args->related_srl = 0; - $receiver_args->list_order = $sender_args->related_srl*-1; - $receiver_args->sender_srl = $sender_srl; - if(!$receiver_args->sender_srl) $receiver_args->sender_srl = $receiver_srl; - $receiver_args->receiver_srl = $receiver_srl; - $receiver_args->message_type = 'R'; - $receiver_args->title = $title; - $receiver_args->content = $content; - $receiver_args->readed = 'N'; - $receiver_args->regdate = date("YmdHis"); - - $oDB = &DB::getInstance(); - $oDB->begin(); - // messages to save in the sendor's message box - if($sender_srl && $sender_log) { - $output = executeQuery('communication.sendMessage', $sender_args); - if(!$output->toBool()) { - $oDB->rollback(); - return $output; - } - } - // messages to save in the receiver's message box - $output = executeQuery('communication.sendMessage', $receiver_args); - if(!$output->toBool()) { - $oDB->rollback(); - return $output; - } - // create a flag that message is sent (in file format) - $flag_path = './files/member_extra_info/new_message_flags/'.getNumberingPath($receiver_srl); - FileHandler::makeDir($flag_path); - $flag_file = sprintf('%s%s', $flag_path, $receiver_srl); - $flag_count = FileHandler::readFile($flag_file); - FileHandler::writeFile($flag_file, ++$flag_count); - - $oDB->commit(); - - return new Object(0,'success_sended'); - } - - /** - * store a specific message into the archive - * @return void|Object (success : void, fail : Object) - **/ - function procCommunicationStoreMessage() { - // Check login information - if(!Context::get('is_logged')) return new Object(-1, 'msg_not_logged'); - $logged_info = Context::get('logged_info'); - // Check variable - $message_srl = Context::get('message_srl'); - if(!$message_srl) return new Object(-1,'msg_invalid_request'); - // get the message - $oCommunicationModel = &getModel('communication'); - $message = $oCommunicationModel->getSelectedMessage($message_srl); - if(!$message || $message->message_type != 'R') return new Object(-1,'msg_invalid_request'); - - $args->message_srl = $message_srl; - $args->receiver_srl = $logged_info->member_srl; - $output = executeQuery('communication.setMessageStored', $args); - if(!$output->toBool()) return $output; - - $this->setMessage('success_registed'); - } - - /** - * Delete a message - * @return void|Object (success : void, fail : Object) - **/ - function procCommunicationDeleteMessage() { - // Check login information - if(!Context::get('is_logged')) return new Object(-1, 'msg_not_logged'); - $logged_info = Context::get('logged_info'); - $member_srl = $logged_info->member_srl; - // Check the variable - $message_srl = Context::get('message_srl'); - if(!$message_srl) return new Object(-1,'msg_invalid_request'); - // Get the message - $oCommunicationModel = &getModel('communication'); - $message = $oCommunicationModel->getSelectedMessage($message_srl); - if(!$message) return new Object(-1,'msg_invalid_request'); - // Check the grant - switch($message->message_type) + else return $output; + } + else + { + if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) { - case 'S': - if($message->sender_srl != $member_srl) return new Object(-1, 'msg_invalid_request'); - break; - case 'R': - if($message->receiver_srl != $member_srl) return new Object(-1, 'msg_invalid_request'); - break; - } - // Delete - $args->message_srl = $message_srl; - $output = executeQuery('communication.deleteMessage', $args); - if(!$output->toBool()) return $output; - - $this->setMessage('success_deleted'); - } - - /** - * Delete the multiple messages - * @return void|Object (success : void, fail : Object) - **/ - function procCommunicationDeleteMessages() { - // Check login information - if(!Context::get('is_logged')) return new Object(-1, 'msg_not_logged'); - $logged_info = Context::get('logged_info'); - $member_srl = $logged_info->member_srl; - // check variables - if(!Context::get('message_srl_list')) return new Object(-1, 'msg_cart_is_null'); - - $message_srl_list = Context::get('message_srl_list'); - if(!is_array($message_srl_list)) $message_srl_list = explode('|@|', trim($message_srl_list)); - if(!count($message_srl_list)) return new Object(-1, 'msg_cart_is_null'); - - $message_type = Context::get('message_type'); - if(!$message_type || !in_array($message_type, array('R','S','T'))) return new Object(-1, 'msg_invalid_request'); - - $message_count = count($message_srl_list); - $target = array(); - for($i=0;$i<$message_count;$i++) { - $message_srl = (int)trim($message_srl_list[$i]); - if(!$message_srl) continue; - $target[] = $message_srl; - } - if(!count($target)) return new Object(-1,'msg_cart_is_null'); - // Delete - $args->message_srls = implode(',',$target); - $args->message_type = $message_type; - - if($message_type == 'S') $args->sender_srl = $member_srl; - else $args->receiver_srl = $member_srl; - - $output = executeQuery('communication.deleteMessages', $args); - if(!$output->toBool()) return $output; - - $this->setMessage('success_deleted'); - - $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'mid', Context::get('mid'), 'act', 'dispCommunicationMessages', 'message_type', Context::get('message_type')); - $this->setRedirectUrl($returnUrl); - } - - /** - * Add a friend - * @return void|Object (success : void, fail : Object) - **/ - function procCommunicationAddFriend() { - // Check login information - if(!Context::get('is_logged')) return new Object(-1, 'msg_not_logged'); - $logged_info = Context::get('logged_info'); - - $target_srl = (int)trim(Context::get('target_srl')); - if(!$target_srl) return new Object(-1,'msg_invalid_request'); - // Variable - $args->friend_srl = getNextSequence(); - $args->list_order = $args->friend_srl * -1; - $args->friend_group_srl = Context::get('friend_group_srl'); - $args->member_srl = $logged_info->member_srl; - $args->target_srl = $target_srl; - $output = executeQuery('communication.addFriend', $args); - if(!$output->toBool()) return $output; - - $this->add('member_srl', $target_srl); - $this->setMessage('success_registed'); - - if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) { global $lang; htmlHeader(); alertScript($lang->success_registed); + reload(true); closePopupScript(); htmlFooter(); Context::close(); exit; } - } + else $this->setMessage($msg_code); + } + } - /** - * Move a group of the friend - * @return void|Object (success : void, fail : Object) - **/ - function procCommunicationMoveFriend() - { - // Check login information - if(!Context::get('is_logged')) - { - return new Object(-1, 'msg_not_logged'); - } + /** + * change a name of friend group + * @return void|Object (success : void, fail : Object) + */ + function procCommunicationRenameFriendGroup() + { + // Check login information + if(!Context::get('is_logged')) return new Object(-1, 'msg_not_logged'); + $logged_info = Context::get('logged_info'); + // Variables + $args->friend_group_srl= Context::get('friend_group_srl'); + $args->member_srl = $logged_info->member_srl; + $args->title = Context::get('title'); + $args->title = htmlspecialchars($args->title); + if(!$args->title) return new Object(-1, 'msg_invalid_request'); - $logged_info = Context::get('logged_info'); - // Check variables - $friend_srl_list = Context::get('friend_srl_list'); - if(!$friend_srl_list) - { - return new Object(-1, 'msg_cart_is_null'); - } + $output = executeQuery('communication.renameFriendGroup', $args); + if(!$output->toBool()) return $output; - if(!is_array($friend_srl_list)) - { - $friend_srl_list = explode('|@|', $friend_srl_list); - } + $this->setMessage('success_updated'); + } - if(!count($friend_srl_list)) return new Object(-1, 'msg_cart_is_null'); + /** + * Delete a group of friends + * @return void|Object (success : void, fail : Object) + */ + function procCommunicationDeleteFriendGroup() + { + // Check login information + if(!Context::get('is_logged')) return new Object(-1, 'msg_not_logged'); + $logged_info = Context::get('logged_info'); + // Variables + $args->friend_group_srl = Context::get('friend_group_srl'); + $args->member_srl = $logged_info->member_srl; + $output = executeQuery('communication.deleteFriendGroup', $args); + if(!$output->toBool()) return $output; - $friend_count = count($friend_srl_list); - $target = array(); - for($i=0;$i<$friend_count;$i++) { - $friend_srl = (int)trim($friend_srl_list[$i]); - if(!$friend_srl) continue; - $target[] = $friend_srl; - } - if(!count($target)) return new Object(-1,'msg_cart_is_null'); - // Variables - $args->friend_srls = implode(',',$target); - $args->member_srl = $logged_info->member_srl; - $args->friend_group_srl = Context::get('target_friend_group_srl'); + $this->setMessage('success_deleted'); + } - $output = executeQuery('communication.moveFriend', $args); - if(!$output->toBool()) return $output; + /** + * set a message status to be 'already read' + * @param int $message_srl + * @return Object + */ + function setMessageReaded($message_srl) + { + $args->message_srl = $message_srl; + $args->related_srl = $message_srl; + return executeQuery('communication.setMessageReaded', $args); + } - $this->setMessage('success_moved'); - - $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'mid', Context::get('mid'), 'act', 'dispCommunicationFriend'); - $this->setRedirectUrl($returnUrl); - } - - /** - * Delete a friend - * @return void|Object (success : void, fail : Object) - **/ - function procCommunicationDeleteFriend() { - // Check login information - if(!Context::get('is_logged')) return new Object(-1, 'msg_not_logged'); - $logged_info = Context::get('logged_info'); - $member_srl = $logged_info->member_srl; - // Check variables - $friend_srl_list = Context::get('friend_srl_list'); - - if(!is_array($friend_srl_list)) - { - $friend_srl_list = explode('|@|', $friend_srl_list); - } - if(!count($friend_srl_list)) return new Object(-1, 'msg_cart_is_null'); - - $friend_count = count($friend_srl_list); - $target = array(); - for($i=0;$i<$friend_count;$i++) { - $friend_srl = (int)trim($friend_srl_list[$i]); - if(!$friend_srl) continue; - $target[] = $friend_srl; - } - if(!count($target)) return new Object(-1,'msg_cart_is_null'); - // Delete - $args->friend_srls = implode(',',$target); - $args->member_srl = $logged_info->member_srl; - $output = executeQuery('communication.deleteFriend', $args); - if(!$output->toBool()) return $output; - - $this->setMessage('success_deleted'); - - $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'mid', Context::get('mid'), 'act', 'dispCommunicationFriend'); - $this->setRedirectUrl($returnUrl); - } - - /** - * Add a group of friends - * @return void|Object (success : void, fail : Object) - **/ - function procCommunicationAddFriendGroup() { - // Check login information - if(!Context::get('is_logged')) return new Object(-1, 'msg_not_logged'); - $logged_info = Context::get('logged_info'); - // Variables - $args->friend_group_srl = trim(Context::get('friend_group_srl')); - $args->member_srl = $logged_info->member_srl; - $args->title = Context::get('title'); - $args->title = htmlspecialchars($args->title); - if(!$args->title) return new Object(-1, 'msg_invalid_request'); - // modify if friend_group_srl exists. - if($args->friend_group_srl) { - $output = executeQuery('communication.renameFriendGroup', $args); - $msg_code = 'success_updated'; - // add if not exists - } else { - $output = executeQuery('communication.addFriendGroup', $args); - $msg_code = 'success_registed'; - } - - if(!$output->toBool()) - { - if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) { - global $lang; - htmlHeader(); - alertScript($lang->fail_to_registed); - closePopupScript(); - htmlFooter(); - Context::close(); - exit; - } - else return $output; - } - else - { - if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) { - global $lang; - htmlHeader(); - alertScript($lang->success_registed); - reload(true); - closePopupScript(); - htmlFooter(); - Context::close(); - exit; - } - else $this->setMessage($msg_code); - } - } - - /** - * change a name of friend group - * @return void|Object (success : void, fail : Object) - **/ - function procCommunicationRenameFriendGroup() { - // Check login information - if(!Context::get('is_logged')) return new Object(-1, 'msg_not_logged'); - $logged_info = Context::get('logged_info'); - // Variables - $args->friend_group_srl= Context::get('friend_group_srl'); - $args->member_srl = $logged_info->member_srl; - $args->title = Context::get('title'); - $args->title = htmlspecialchars($args->title); - if(!$args->title) return new Object(-1, 'msg_invalid_request'); - - $output = executeQuery('communication.renameFriendGroup', $args); - if(!$output->toBool()) return $output; - - $this->setMessage('success_updated'); - } - - /** - * Delete a group of friends - * @return void|Object (success : void, fail : Object) - **/ - function procCommunicationDeleteFriendGroup() { - // Check login information - if(!Context::get('is_logged')) return new Object(-1, 'msg_not_logged'); - $logged_info = Context::get('logged_info'); - // Variables - $args->friend_group_srl = Context::get('friend_group_srl'); - $args->member_srl = $logged_info->member_srl; - $output = executeQuery('communication.deleteFriendGroup', $args); - if(!$output->toBool()) return $output; - - $this->setMessage('success_deleted'); - } - - /** - * set a message status to be 'already read' - * @param int $message_srl - * @return Object - **/ - function setMessageReaded($message_srl) { - $args->message_srl = $message_srl; - $args->related_srl = $message_srl; - return executeQuery('communication.setMessageReaded', $args); - } - - } -?> +} +/* End of file communication.controller.php */ +/* Location: ./modules/comment/communication.controller.php */ diff --git a/modules/communication/communication.mobile.php b/modules/communication/communication.mobile.php index fa96c1c1c..e5a80d0bc 100644 --- a/modules/communication/communication.mobile.php +++ b/modules/communication/communication.mobile.php @@ -1,7 +1,10 @@ communication_config = $oCommunicationModel->getConfig(); @@ -74,3 +77,5 @@ class communicationMobile extends communicationView { $this->setTemplateFile($templateFile); } } +/* End of file communication.mobile.php */ +/* Location: ./modules/comment/communication.mobile.php */ diff --git a/modules/communication/communication.model.php b/modules/communication/communication.model.php index b4ee804ca..dc20ea416 100644 --- a/modules/communication/communication.model.php +++ b/modules/communication/communication.model.php @@ -1,199 +1,212 @@ getModuleConfig('communication'); - /** - * Initialization - * @return void - **/ - function init() { - } + if(!$communication_config->skin) $communication_config->skin = 'default'; + if(!$communication_config->colorset) $communication_config->colorset = 'white'; + if(!$communication_config->editor_skin) $communication_config->editor_skin = 'default'; + if(!$communication_config->mskin) $communication_config->mskin = 'default'; - /** - * get the configuration - * @return object config of communication module - **/ - function getConfig() { - $oModuleModel = &getModel('module'); - $communication_config = $oModuleModel->getModuleConfig('communication'); + return $communication_config; + } - if(!$communication_config->skin) $communication_config->skin = 'default'; - if(!$communication_config->colorset) $communication_config->colorset = 'white'; - if(!$communication_config->editor_skin) $communication_config->editor_skin = 'default'; - if(!$communication_config->mskin) $communication_config->mskin = 'default'; + /** + * get the message contents + * @param int $message_srl + * @param array $columnList + * @return object message information + */ + function getSelectedMessage($message_srl, $columnList = array()) + { + $logged_info = Context::get('logged_info'); - return $communication_config; - } + $args->message_srl = $message_srl; + $output = executeQuery('communication.getMessage',$args, $columnList); + $message = $output->data; + if(!$message) return ; + // get recipient's information if it is a sent message + $oMemberModel = &getModel('member'); + if($message->sender_srl == $logged_info->member_srl && $message->message_type == 'S') $member_info = $oMemberModel->getMemberInfoByMemberSrl($message->receiver_srl); + // get sendor's information if it is a received/archived message + else $member_info = $oMemberModel->getMemberInfoByMemberSrl($message->sender_srl); - /** - * get the message contents - * @param int $message_srl - * @param array $columnList - * @return object message information - **/ - function getSelectedMessage($message_srl, $columnList = array()) { - $logged_info = Context::get('logged_info'); + if($member_info) + { + foreach($member_info as $key => $val) + { + if($key != 'regdate') $message->{$key} = $val; + } + } + // change the status if is a received and not yet read message + if($message->message_type == 'R' && $message->readed != 'Y') + { + $oCommunicationController = &getController('communication'); + $oCommunicationController->setMessageReaded($message_srl); + } - $args->message_srl = $message_srl; - $output = executeQuery('communication.getMessage',$args, $columnList); - $message = $output->data; - if(!$message) return ; - // get recipient's information if it is a sent message - $oMemberModel = &getModel('member'); - if($message->sender_srl == $logged_info->member_srl && $message->message_type == 'S') $member_info = $oMemberModel->getMemberInfoByMemberSrl($message->receiver_srl); - // get sendor's information if it is a received/archived message - else $member_info = $oMemberModel->getMemberInfoByMemberSrl($message->sender_srl); + return $message; + } - if($member_info) { - foreach($member_info as $key => $val) { - if($key != 'regdate') $message->{$key} = $val; - } - } - // change the status if is a received and not yet read message - if($message->message_type == 'R' && $message->readed != 'Y') { - $oCommunicationController = &getController('communication'); - $oCommunicationController->setMessageReaded($message_srl); - } + /** + * get a new message + * @param array $columnList + * @return object message information + */ + function getNewMessage($columnList = array()) + { + $logged_info = Context::get('logged_info'); + $args->receiver_srl = $logged_info->member_srl; + $args->readed = 'N'; - return $message; - } + $output = executeQuery('communication.getNewMessage', $args, $columnList); + if(!count($output->data)) return; + $message = array_pop($output->data); - /** - * get a new message - * @param array $columnList - * @return object message information - **/ - function getNewMessage($columnList = array()) { - $logged_info = Context::get('logged_info'); - $args->receiver_srl = $logged_info->member_srl; - $args->readed = 'N'; + $oCommunicationController = &getController('communication'); + $oCommunicationController->setMessageReaded($message->message_srl); - $output = executeQuery('communication.getNewMessage', $args, $columnList); - if(!count($output->data)) return; - $message = array_pop($output->data); + return $message; + } - $oCommunicationController = &getController('communication'); - $oCommunicationController->setMessageReaded($message->message_srl); + /** + * get a message list + * @param string $message_type (R: Received Message, S: Sent Message, T: Archive) + * @param array $columnList + * @return Object + */ + function getMessages($message_type = "R", $columnList = array()) + { + $logged_info = Context::get('logged_info'); - return $message; - } + switch($message_type) + { + case 'R' : + $args->member_srl = $logged_info->member_srl; + $args->message_type = 'R'; + $query_id = 'communication.getReceivedMessages'; + break; + case 'T' : + $args->member_srl = $logged_info->member_srl; + $args->message_type = 'T'; + $query_id = 'communication.getStoredMessages'; + break; + default : + $args->member_srl = $logged_info->member_srl; + $args->message_type = 'S'; + $query_id = 'communication.getSendedMessages'; + break; + } + // Other variables + $args->sort_index = 'message.list_order'; + $args->page = Context::get('page'); + $args->list_count = 20; + $args->page_count = 10; + return executeQuery($query_id, $args, $columnList); + } - /** - * get a message list - * @param string $message_type (R: Received Message, S: Sent Message, T: Archive) - * @param array $columnList - * @return Object - **/ - function getMessages($message_type = "R", $columnList = array()) { - $logged_info = Context::get('logged_info'); + /** + * Get a list of friends + * @param int $friend_group_srl (default 0) + * @param array $columnList + * @return Object + */ + function getFriends($friend_group_srl = 0, $columnList = array()) + { + $logged_info = Context::get('logged_info'); - switch($message_type) { - case 'R' : - $args->member_srl = $logged_info->member_srl; - $args->message_type = 'R'; - $query_id = 'communication.getReceivedMessages'; - break; - case 'T' : - $args->member_srl = $logged_info->member_srl; - $args->message_type = 'T'; - $query_id = 'communication.getStoredMessages'; - break; - default : - $args->member_srl = $logged_info->member_srl; - $args->message_type = 'S'; - $query_id = 'communication.getSendedMessages'; - break; - - } - // Other variables - $args->sort_index = 'message.list_order'; - $args->page = Context::get('page'); - $args->list_count = 20; - $args->page_count = 10; - return executeQuery($query_id, $args, $columnList); - } + $args->friend_group_srl = $friend_group_srl; + $args->member_srl = $logged_info->member_srl; + // Other variables + $args->page = Context::get('page'); + $args->sort_index = 'friend.list_order'; + $args->list_count = 10; + $args->page_count = 10; + $output = executeQuery('communication.getFriends', $args, $columnList); + return $output; + } - /** - * Get a list of friends - * @param int $friend_group_srl (default 0) - * @param array $columnList - * @return Object - **/ - function getFriends($friend_group_srl = 0, $columnList = array()) { - $logged_info = Context::get('logged_info'); + /** + * check if a friend is already added + * @param int $member_srl + * @return int + */ + function isAddedFriend($member_srl) + { + $logged_info = Context::get('logged_info'); - $args->friend_group_srl = $friend_group_srl; - $args->member_srl = $logged_info->member_srl; - // Other variables - $args->page = Context::get('page'); - $args->sort_index = 'friend.list_order'; - $args->list_count = 10; - $args->page_count = 10; - $output = executeQuery('communication.getFriends', $args, $columnList); - return $output; - } + $args->member_srl = $logged_info->member_srl; + $args->target_srl = $member_srl; + $output = executeQuery('communication.isAddedFriend', $args); + return $output->data->count; + } - /** - * check if a friend is already added - * @param int $member_srl - * @return int - **/ - function isAddedFriend($member_srl) { - $logged_info = Context::get('logged_info'); + /** + * Get a group of friends + * @param int $friend_group_srl + * @return object + */ + function getFriendGroupInfo($friend_group_srl) + { + $logged_info = Context::get('logged_info'); - $args->member_srl = $logged_info->member_srl; - $args->target_srl = $member_srl; - $output = executeQuery('communication.isAddedFriend', $args); - return $output->data->count; - } + $args->member_srl = $logged_info->member_srl; + $args->friend_group_srl = $friend_group_srl; - /** - * Get a group of friends - * @param int $friend_group_srl - * @return object - **/ - function getFriendGroupInfo($friend_group_srl) { - $logged_info = Context::get('logged_info'); + $output = executeQuery('communication.getFriendGroup', $args); + return $output->data; + } - $args->member_srl = $logged_info->member_srl; - $args->friend_group_srl = $friend_group_srl; + /** + * Get a list of groups + * @return array + */ + function getFriendGroups() + { + $logged_info = Context::get('logged_info'); + $args->member_srl = $logged_info->member_srl; - $output = executeQuery('communication.getFriendGroup', $args); - return $output->data; - } + $output = executeQueryArray('communication.getFriendGroups', $args); + $group_list = $output->data; + if(!$group_list) return; + return $group_list; + } - /** - * Get a list of groups - * @return array - **/ - function getFriendGroups() { - $logged_info = Context::get('logged_info'); - $args->member_srl = $logged_info->member_srl; + /** + * check whether to be added in the friend list + * @param int $target_srl + * @return boolean (true : friend, false : not friend) + */ + function isFriend($target_srl) + { + $logged_info = Context::get('logged_info'); - $output = executeQueryArray('communication.getFriendGroups', $args); - $group_list = $output->data; - if(!$group_list) return; - return $group_list; - } - - /** - * check whether to be added in the friend list - * @param int $target_srl - * @return boolean (true : friend, false : not friend) - **/ - function isFriend($target_srl) { - $logged_info = Context::get('logged_info'); - - $args->member_srl = $target_srl; - $args->target_srl = $logged_info->member_srl; - $output = executeQuery('communication.isAddedFriend', $args); - if($output->data->count) return true; - return false; - } - } -?> + $args->member_srl = $target_srl; + $args->target_srl = $logged_info->member_srl; + $output = executeQuery('communication.isAddedFriend', $args); + if($output->data->count) return true; + return false; + } +} +/* End of file communication.model.php */ +/* Location: ./modules/comment/communication.model.php */ diff --git a/modules/communication/communication.view.php b/modules/communication/communication.view.php index d30d20214..f76312fb5 100644 --- a/modules/communication/communication.view.php +++ b/modules/communication/communication.view.php @@ -1,276 +1,294 @@ communication_config = $oCommunicationModel->getConfig(); + $skin = $this->communication_config->skin; - /** - * Initialization - * @return void - **/ - function init() { - $oCommunicationModel = &getModel('communication'); + Context::set('communication_config', $this->communication_config); - $this->communication_config = $oCommunicationModel->getConfig(); - $skin = $this->communication_config->skin; + $config_parse = explode('|@|', $skin); + if (count($config_parse) > 1) + { + $tpl_path = sprintf('./themes/%s/modules/communication/', $config_parse[0]); + } + else + { + $tpl_path = sprintf('%sskins/%s', $this->module_path, $skin); + } + $this->setTemplatePath($tpl_path); - Context::set('communication_config', $this->communication_config); + $oLayoutModel = &getModel('layout'); + $layout_info = $oLayoutModel->getLayout($this->communication_config->layout_srl); + if($layout_info) + { + $this->module_info->layout_srl = $this->communication_config->layout_srl; + $this->setLayoutPath($layout_info->path); + } + } - $config_parse = explode('|@|', $skin); - if (count($config_parse) > 1){ - $tpl_path = sprintf('./themes/%s/modules/communication/', $config_parse[0]); - }else{ - $tpl_path = sprintf('%sskins/%s', $this->module_path, $skin); - } - $this->setTemplatePath($tpl_path); + /** + * Display message box + * @return void|Object (void : success, Object : fail) + */ + function dispCommunicationMessages() + { + // Error appears if not logged-in + if(!Context::get('is_logged')) return $this->stop('msg_not_logged'); + $logged_info = Context::get('logged_info'); + if(!array_key_exists('dispCommunicationMessages', $logged_info->menu_list)) + { + return $this->stop('msg_invalid_request'); + } - $oLayoutModel = &getModel('layout'); - $layout_info = $oLayoutModel->getLayout($this->communication_config->layout_srl); - if($layout_info) + // Set the variables + $message_srl = Context::get('message_srl'); + $message_type = Context::get('message_type'); + if(!in_array($message_type, array('R','S','T'))) + { + $message_type = 'R'; + Context::set('message_type', $message_type); + } + + $oCommunicationModel = &getModel('communication'); + // extract contents if message_srl exists + if($message_srl) + { + $columnList = array('message_srl', 'sender_srl', 'receiver_srl', 'message_type', 'title', 'content', 'readed', 'regdate'); + $message = $oCommunicationModel->getSelectedMessage($message_srl, $columnList); + switch($message->message_type) { - $this->module_info->layout_srl = $this->communication_config->layout_srl; - $this->setLayoutPath($layout_info->path); + case 'R': + if($message->receiver_srl != $logged_info->member_srl) + { + return $this->stop('msg_invalid_request'); + } + break; + case 'S': + if($message->sender_srl != $logged_info->member_srl) + { + return $this->stop('msg_invalid_request'); + } + break; + case 'T': + if($message->receiver_srl != $logged_info->member_srl && $message->sender_srl != $logged_info->member_srl) + { + return $this->stop('msg_invalid_request'); + } + break; } - } - - /** - * Display message box - * @return void|Object (void : success, Object : fail) - **/ - function dispCommunicationMessages() { - // Error appears if not logged-in - if(!Context::get('is_logged')) return $this->stop('msg_not_logged'); - $logged_info = Context::get('logged_info'); - if(!array_key_exists('dispCommunicationMessages', $logged_info->menu_list)) + if($message->message_srl == $message_srl && ($message->receiver_srl == $logged_info->member_srl || $message->sender_srl == $logged_info->member_srl) ) { - return $this->stop('msg_invalid_request'); - } - - // Set the variables - $message_srl = Context::get('message_srl'); - $message_type = Context::get('message_type'); - if(!in_array($message_type, array('R','S','T'))) { - $message_type = 'R'; - Context::set('message_type', $message_type); - } - - $oCommunicationModel = &getModel('communication'); - // extract contents if message_srl exists - if($message_srl) { - $columnList = array('message_srl', 'sender_srl', 'receiver_srl', 'message_type', 'title', 'content', 'readed', 'regdate'); - $message = $oCommunicationModel->getSelectedMessage($message_srl, $columnList); - switch($message->message_type) - { - case 'R': - if($message->receiver_srl != $logged_info->member_srl) - { - return $this->stop('msg_invalid_request'); - } - break; - case 'S': - if($message->sender_srl != $logged_info->member_srl) - { - return $this->stop('msg_invalid_request'); - } - break; - case 'T': - if($message->receiver_srl != $logged_info->member_srl && $message->sender_srl != $logged_info->member_srl) - { - return $this->stop('msg_invalid_request'); - } - break; - } - if($message->message_srl == $message_srl && ($message->receiver_srl == $logged_info->member_srl || $message->sender_srl == $logged_info->member_srl) ) { - stripEmbedTagForAdmin($message->content, $message->sender_srl); - Context::set('message', $message); - } - } - // Extract a list - $columnList = array('message_srl', 'readed', 'title', 'member.member_srl', 'member.nick_name', 'message.regdate', 'readed_date'); - $output = $oCommunicationModel->getMessages($message_type, $columnList); - - // set a template file - Context::set('total_count', $output->total_count); - Context::set('total_page', $output->total_page); - Context::set('page', $output->page); - Context::set('message_list', $output->data); - Context::set('page_navigation', $output->page_navigation); - - $oSecurity = new Security(); - $oSecurity->encodeHTML('message_list..nick_name'); - - $this->setTemplateFile('messages'); - } - - /** - * display a new message - * @return void|Object (void : success, Object : fail) - **/ - function dispCommunicationNewMessage() { - $this->setLayoutPath('./common/tpl/'); - $this->setLayoutFile('popup_layout'); - // Error appears if not logged-in - if(!Context::get('is_logged')) return $this->stop('msg_not_logged'); - $logged_info = Context::get('logged_info'); - - $oCommunicationModel = &getModel('communication'); - // get a new message - $columnList = array('message_srl', 'member_srl', 'nick_name', 'title', 'content', 'sender_srl'); - $message = $oCommunicationModel->getNewMessage($columnList); - if($message) { stripEmbedTagForAdmin($message->content, $message->sender_srl); Context::set('message', $message); } - - // Delete a flag - $flag_path = './files/communication_extra_info/new_message_flags/'.getNumberingPath($logged_info->member_srl); - $flag_file = sprintf('%s%s', $flag_path, $logged_info->member_srl); - FileHandler::removeFile($flag_file); + } + // Extract a list + $columnList = array('message_srl', 'readed', 'title', 'member.member_srl', 'member.nick_name', 'message.regdate', 'readed_date'); + $output = $oCommunicationModel->getMessages($message_type, $columnList); - $this->setTemplateFile('new_message'); - } + // set a template file + Context::set('total_count', $output->total_count); + Context::set('total_page', $output->total_page); + Context::set('page', $output->page); + Context::set('message_list', $output->data); + Context::set('page_navigation', $output->page_navigation); - /** - * Display message sending - * @return void|Object (void : success, Object : fail) - **/ - function dispCommunicationSendMessage() { - $this->setLayoutPath('./common/tpl/'); - $this->setLayoutFile("popup_layout"); - $oCommunicationModel = &getModel('communication'); - $oMemberModel = &getModel('member'); - // Error appears if not logged-in - if(!Context::get('is_logged')) return $this->stop('msg_not_logged'); - $logged_info = Context::get('logged_info'); - // get receipient's information + $oSecurity = new Security(); + $oSecurity->encodeHTML('message_list..nick_name'); - // check inalid request - $receiver_srl = Context::get('receiver_srl'); - if(!$receiver_srl) return $this->stop('msg_invalid_request'); + $this->setTemplateFile('messages'); + } - // check receiver and sender are same - if($logged_info->member_srl == $receiver_srl) return $this->stop('msg_cannot_send_to_yourself'); - // get message_srl of the original message if it is a reply - $message_srl = Context::get('message_srl'); - if($message_srl) { - $source_message = $oCommunicationModel->getSelectedMessage($message_srl); - if($source_message->message_srl == $message_srl && $source_message->sender_srl == $receiver_srl) { - $source_message->title = "[re] ".$source_message->title; - $source_message->content = "\r\n
\r\n
".trim($source_message->content)."
"; - Context::set('source_message', $source_message); - } - } + /** + * display a new message + * @return void|Object (void : success, Object : fail) + */ + function dispCommunicationNewMessage() + { + $this->setLayoutPath('./common/tpl/'); + $this->setLayoutFile('popup_layout'); + // Error appears if not logged-in + if(!Context::get('is_logged')) return $this->stop('msg_not_logged'); + $logged_info = Context::get('logged_info'); - $receiver_info = $oMemberModel->getMemberInfoByMemberSrl($receiver_srl); - if(!$receiver_info) + $oCommunicationModel = &getModel('communication'); + // get a new message + $columnList = array('message_srl', 'member_srl', 'nick_name', 'title', 'content', 'sender_srl'); + $message = $oCommunicationModel->getNewMessage($columnList); + if($message) + { + stripEmbedTagForAdmin($message->content, $message->sender_srl); + Context::set('message', $message); + } + + // Delete a flag + $flag_path = './files/communication_extra_info/new_message_flags/'.getNumberingPath($logged_info->member_srl); + $flag_file = sprintf('%s%s', $flag_path, $logged_info->member_srl); + FileHandler::removeFile($flag_file); + + $this->setTemplateFile('new_message'); + } + + /** + * Display message sending + * @return void|Object (void : success, Object : fail) + */ + function dispCommunicationSendMessage() + { + $this->setLayoutPath('./common/tpl/'); + $this->setLayoutFile("popup_layout"); + $oCommunicationModel = &getModel('communication'); + $oMemberModel = &getModel('member'); + // Error appears if not logged-in + if(!Context::get('is_logged')) return $this->stop('msg_not_logged'); + $logged_info = Context::get('logged_info'); + // get receipient's information + + // check inalid request + $receiver_srl = Context::get('receiver_srl'); + if(!$receiver_srl) return $this->stop('msg_invalid_request'); + + // check receiver and sender are same + if($logged_info->member_srl == $receiver_srl) return $this->stop('msg_cannot_send_to_yourself'); + // get message_srl of the original message if it is a reply + $message_srl = Context::get('message_srl'); + if($message_srl) + { + $source_message = $oCommunicationModel->getSelectedMessage($message_srl); + if($source_message->message_srl == $message_srl && $source_message->sender_srl == $receiver_srl) { - return $this->stop('msg_invalid_request'); + $source_message->title = "[re] ".$source_message->title; + $source_message->content = "\r\n
\r\n
".trim($source_message->content)."
"; + Context::set('source_message', $source_message); } + } - Context::set('receiver_info', $receiver_info); - // set a signiture by calling getEditor of the editor module - $oEditorModel = &getModel('editor'); - $option->primary_key_name = 'receiver_srl'; - $option->content_key_name = 'content'; - $option->allow_fileupload = false; - $option->enable_autosave = false; - $option->enable_default_component = true;// false; - $option->enable_component = false; - $option->resizable = false; - $option->disable_html = true; - $option->height = 300; - $option->skin = $this->communication_config->editor_skin; - $option->colorset = $this->communication_config->editor_colorset; - $editor = $oEditorModel->getEditor($logged_info->member_srl, $option); - Context::set('editor', $editor); + $receiver_info = $oMemberModel->getMemberInfoByMemberSrl($receiver_srl); + if(!$receiver_info) + { + return $this->stop('msg_invalid_request'); + } - $this->setTemplateFile('send_message'); - } + Context::set('receiver_info', $receiver_info); + // set a signiture by calling getEditor of the editor module + $oEditorModel = &getModel('editor'); + $option->primary_key_name = 'receiver_srl'; + $option->content_key_name = 'content'; + $option->allow_fileupload = false; + $option->enable_autosave = false; + $option->enable_default_component = true;// false; + $option->enable_component = false; + $option->resizable = false; + $option->disable_html = true; + $option->height = 300; + $option->skin = $this->communication_config->editor_skin; + $option->colorset = $this->communication_config->editor_colorset; + $editor = $oEditorModel->getEditor($logged_info->member_srl, $option); + Context::set('editor', $editor); - /** - * display a list of friends - * @return void|Object (void : success, Object : fail) - **/ - function dispCommunicationFriend() { - // Error appears if not logged-in - if(!Context::get('is_logged')) return $this->stop('msg_not_logged'); + $this->setTemplateFile('send_message'); + } - $oCommunicationModel = &getModel('communication'); - // get a group list - $tmp_group_list = $oCommunicationModel->getFriendGroups(); - $group_count = count($tmp_group_list); - for($i=0;$i<$group_count;$i++) $friend_group_list[$tmp_group_list[$i]->friend_group_srl] = $tmp_group_list[$i]; - Context::set('friend_group_list', $friend_group_list); - // get a list of friends - $friend_group_srl = Context::get('friend_group_srl'); - $columnList = array('friend_srl', 'friend_group_srl', 'target_srl', 'member.nick_name', 'friend.regdate'); - $output = $oCommunicationModel->getFriends($friend_group_srl, $columnList); - $friend_count = count($output->data); - if($friend_count) { - foreach($output->data as $key => $val) { - $group_srl = $val->friend_group_srl; - $group_title = $friend_group_list[$group_srl]->title; - if(!$group_title) $group_title = Context::get('default_friend_group'); - $output->data[$key]->group_title = $group_title; - } - } - // set a template file - Context::set('total_count', $output->total_count); - Context::set('total_page', $output->total_page); - Context::set('page', $output->page); - Context::set('friend_list', $output->data); - Context::set('page_navigation', $output->page_navigation); + /** + * display a list of friends + * @return void|Object (void : success, Object : fail) + */ + function dispCommunicationFriend() { + // Error appears if not logged-in + if(!Context::get('is_logged')) return $this->stop('msg_not_logged'); - $this->setTemplateFile('friends'); - } + $oCommunicationModel = &getModel('communication'); + // get a group list + $tmp_group_list = $oCommunicationModel->getFriendGroups(); + $group_count = count($tmp_group_list); + for($i=0;$i<$group_count;$i++) $friend_group_list[$tmp_group_list[$i]->friend_group_srl] = $tmp_group_list[$i]; + Context::set('friend_group_list', $friend_group_list); + // get a list of friends + $friend_group_srl = Context::get('friend_group_srl'); + $columnList = array('friend_srl', 'friend_group_srl', 'target_srl', 'member.nick_name', 'friend.regdate'); + $output = $oCommunicationModel->getFriends($friend_group_srl, $columnList); + $friend_count = count($output->data); + if($friend_count) + { + foreach($output->data as $key => $val) + { + $group_srl = $val->friend_group_srl; + $group_title = $friend_group_list[$group_srl]->title; + if(!$group_title) $group_title = Context::get('default_friend_group'); + $output->data[$key]->group_title = $group_title; + } + } + // set a template file + Context::set('total_count', $output->total_count); + Context::set('total_page', $output->total_page); + Context::set('page', $output->page); + Context::set('friend_list', $output->data); + Context::set('page_navigation', $output->page_navigation); - /** - * display Add a friend - * @return void|Object (void : success, Object : fail) - **/ - function dispCommunicationAddFriend() { - $this->setLayoutPath('./common/tpl/'); - $this->setLayoutFile("popup_layout"); - // error appears if not logged-in - if(!Context::get('is_logged')) return $this->stop('msg_not_logged'); - $logged_info = Context::get('logged_info'); + $this->setTemplateFile('friends'); + } - $target_srl = Context::get('target_srl'); - if(!$target_srl) return $this->stop('msg_invalid_request'); - // get information of the member - $oMemberModel = &getModel('member'); - $oCommunicationModel = &getModel('communication'); - $communication_info = $oMemberModel->getMemberInfoByMemberSrl($target_srl); - if($communication_info->member_srl != $target_srl) return $this->stop('msg_invalid_request'); - Context::set('target_info', $communication_info); - // get a group list - $friend_group_list = $oCommunicationModel->getFriendGroups(); - Context::set('friend_group_list', $friend_group_list); + /** + * display Add a friend + * @return void|Object (void : success, Object : fail) + */ + function dispCommunicationAddFriend() + { + $this->setLayoutPath('./common/tpl/'); + $this->setLayoutFile("popup_layout"); + // error appears if not logged-in + if(!Context::get('is_logged')) return $this->stop('msg_not_logged'); + $logged_info = Context::get('logged_info'); - $this->setTemplateFile('add_friend'); - } + $target_srl = Context::get('target_srl'); + if(!$target_srl) return $this->stop('msg_invalid_request'); + // get information of the member + $oMemberModel = &getModel('member'); + $oCommunicationModel = &getModel('communication'); + $communication_info = $oMemberModel->getMemberInfoByMemberSrl($target_srl); + if($communication_info->member_srl != $target_srl) return $this->stop('msg_invalid_request'); + Context::set('target_info', $communication_info); + // get a group list + $friend_group_list = $oCommunicationModel->getFriendGroups(); + Context::set('friend_group_list', $friend_group_list); - /** - * display add a group of friends - * @return void|Object (void : success, Object : fail) - **/ - function dispCommunicationAddFriendGroup() { - $this->setLayoutPath('./common/tpl/'); - $this->setLayoutFile("popup_layout"); - // error apprears if not logged-in - if(!Context::get('is_logged')) return $this->stop('msg_not_logged'); - $logged_info = Context::get('logged_info'); - // change to edit mode when getting the group_srl - $friend_group_srl = Context::get('friend_group_srl'); - if($friend_group_srl) { - $oCommunicationModel = &getModel('communication'); - $friend_group = $oCommunicationModel->getFriendGroupInfo($friend_group_srl); - if($friend_group->friend_group_srl == $friend_group_srl) Context::set('friend_group', $friend_group); - } - $this->setTemplateFile('add_friend_group'); - } - } -?> + $this->setTemplateFile('add_friend'); + } + + /** + * display add a group of friends + * @return void|Object (void : success, Object : fail) + */ + function dispCommunicationAddFriendGroup() + { + $this->setLayoutPath('./common/tpl/'); + $this->setLayoutFile("popup_layout"); + // error apprears if not logged-in + if(!Context::get('is_logged')) return $this->stop('msg_not_logged'); + $logged_info = Context::get('logged_info'); + // change to edit mode when getting the group_srl + $friend_group_srl = Context::get('friend_group_srl'); + if($friend_group_srl) + { + $oCommunicationModel = &getModel('communication'); + $friend_group = $oCommunicationModel->getFriendGroupInfo($friend_group_srl); + if($friend_group->friend_group_srl == $friend_group_srl) Context::set('friend_group', $friend_group); + } + $this->setTemplateFile('add_friend_group'); + } +} +/* End of file communication.view.php */ +/* Location: ./modules/comment/communication.view.php */