웹마스터 팁

사이트를 운영하다보니 관리자에게만 가능한 몇가지들이 필요하더군요..

 

추천, 신고기능을 관리자만 제한을 해제하도록 수정하였습니다. 1.5.2.2 에서 작업하였습니다.

아래 내용을 modules/document/document.controller.php  의 updateVotedCount 와 그 바로 아래의 declaredDocument 함수를 교체해 주시면

됩니다.. 사실 기존것을 else로 묵어버리고 관리자만 새로 만들어 넣은것입니다..

 

/**
	 * @brief Increase the number of vote-up of the document
	 **/
	function updateVotedCount($document_srl, $point = 1) {
		if($point > 0) $failed_voted = 'failed_voted';
		else $failed_voted = 'failed_blamed';

		// Create a member model object
		$oMemberModel = &getModel('member');
		$member_srl = $oMemberModel->getLoggedMemberSrl();
		$logged_info = Context::get('logged_info');
		
		// Get the original document
		$oDocumentModel = &getModel('document');
		$oDocument = $oDocumentModel->getDocument($document_srl, false, false);

		if ($logged_info->is_admin == 'Y') {
			$args->member_srl = $member_srl;
			$args->document_srl = $document_srl;
			// Update the voted count
			if($point < 0)
			{
				$args->blamed_count = $oDocument->get('blamed_count') + $point;
				$output = executeQuery('document.updateBlamedCount', $args);
			}
			else
			{
				$args->voted_count = $oDocument->get('voted_count') + $point;
				$output = executeQuery('document.updateVotedCount', $args);
			}
			if(!$output->toBool()) return $output;
			// Leave logs
			$args->point = $point;
			$output = executeQuery('document.insertDocumentVotedLog', $args);
			if(!$output->toBool()) return $output;
    }
		else {
			// Return fail if session already has information about votes
			if($_SESSION['voted_document'][$document_srl]) return new Object(-1, $failed_voted);
			// Pass if the author's IP address is as same as visitor's.
			if($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR']) {
				$_SESSION['voted_document'][$document_srl] = true;
				return new Object(-1, $failed_voted);
			}
			// Check if document's author is a member.
			if($oDocument->get('member_srl')) {
				// Pass after registering a session if author's information is same as the currently logged-in user's.
				if($member_srl && $member_srl == $oDocument->get('member_srl')) {
					$_SESSION['voted_document'][$document_srl] = true;
					return new Object(-1, $failed_voted);
				}
			}
			// Use member_srl for logged-in members and IP address for non-members.
			if($member_srl) {
				$args->member_srl = $member_srl;
			} else {
				$args->ipaddress = $_SERVER['REMOTE_ADDR'];
			}
			$args->document_srl = $document_srl;
			$output = executeQuery('document.getDocumentVotedLogInfo', $args);
			// Pass after registering a session if log information has vote-up logs
			if($output->data->count) {
				$_SESSION['voted_document'][$document_srl] = true;
				return new Object(-1, $failed_voted);
			}
			// Update the voted count
			if($point < 0)
			{
				$args->blamed_count = $oDocument->get('blamed_count') + $point;
				$output = executeQuery('document.updateBlamedCount', $args);
			}
			else
			{
				$args->voted_count = $oDocument->get('voted_count') + $point;
				$output = executeQuery('document.updateVotedCount', $args);
			}
			if(!$output->toBool()) return $output;
			// Leave logs
			$args->point = $point;
			$output = executeQuery('document.insertDocumentVotedLog', $args);
			if(!$output->toBool()) return $output;
			// Leave in the session information
			$_SESSION['voted_document'][$document_srl] = true;
	
			$obj->member_srl = $oDocument->get('member_srl');
			$obj->module_srl = $oDocument->get('module_srl');
			$obj->document_srl = $oDocument->get('document_srl');
			$obj->update_target = ($point < 0) ? 'blamed_count' : 'voted_count';
			$obj->point = $point;
			$obj->before_point = ($point < 0) ? $oDocument->get('blamed_count') : $oDocument->get('voted_count');
			$obj->after_point = ($point < 0) ? $args->blamed_count : $args->voted_count;
			$output = ModuleHandler::triggerCall('document.updateVotedCount', 'after', $obj);
			if(!$output->toBool()) return $output;
		}
		// Return result
		if($point > 0)
		{
			return new Object(0, 'success_voted');
		}
		else
		{
			return new Object(0, 'success_blamed');
		}
	}

	/**
	 * @brief Report posts
	 **/
	function declaredDocument($document_srl) {
		
		// Create a member model object
		$oMemberModel = &getModel('member');
		$member_srl = $oMemberModel->getLoggedMemberSrl();
		$logged_info = Context::get('logged_info');
		
		// Get the original document
		$oDocumentModel = &getModel('document');
		$oDocument = $oDocumentModel->getDocument($document_srl, false, false);
		
		if ($logged_info->is_admin == 'Y') {
			$args->member_srl = $member_srl;
			$args->document_srl = $document_srl;
			$output = executeQuery('document.getDeclaredDocument', $args);
			if(!$output->toBool()) return $output;
			$declared_count = $output->data->declared_count;
			
			// Add the declared document
			if($declared_count > 0) $output = executeQuery('document.updateDeclaredDocument', $args);
			else $output = executeQuery('document.insertDeclaredDocument', $args);
			if(!$output->toBool()) return $output;
			// Leave logs
			$output = executeQuery('document.insertDocumentDeclaredLog', $args);
	
			$this->setMessage('success_declared');
	    }
		else {
			// Fail if session information already has a reported document
			if($_SESSION['declared_document'][$document_srl]) return new Object(-1, 'failed_declared');
			// Check if previously reported
			$args->document_srl = $document_srl;
			$output = executeQuery('document.getDeclaredDocument', $args);
			if(!$output->toBool()) return $output;
			$declared_count = $output->data->declared_count;
	
			// Pass if the author's IP address is as same as visitor's.
			/*if($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR']) {
				$_SESSION['declared_document'][$document_srl] = true;
				return new Object(-1, 'failed_declared');
			}*/
			// Check if document's author is a member.
			if($oDocument->get('member_srl')) {
				// Pass after registering a session if author's information is same as the currently logged-in user's.
				if($member_srl && $member_srl == $oDocument->get('member_srl')) {
					$_SESSION['declared_document'][$document_srl] = true;
					return new Object(-1, 'failed_declared');
				}
			}
			// Use member_srl for logged-in members and IP address for non-members.
			if($member_srl) {
				$args->member_srl = $member_srl;
			} else {
				$args->ipaddress = $_SERVER['REMOTE_ADDR'];
			}
			$args->document_srl = $document_srl;
			$output = executeQuery('document.getDocumentDeclaredLogInfo', $args);
			// Pass after registering a sesson if reported/declared documents are in the logs.
			if($output->data->count) {
				$_SESSION['declared_document'][$document_srl] = true;
				return new Object(-1, 'failed_declared');
			}
			// Add the declared document
			if($declared_count > 0) $output = executeQuery('document.updateDeclaredDocument', $args);
			else $output = executeQuery('document.insertDeclaredDocument', $args);
			if(!$output->toBool()) return $output;
			// Leave logs
			$output = executeQuery('document.insertDocumentDeclaredLog', $args);
			// Leave in the session information
			$_SESSION['declared_document'][$document_srl] = true;
	
			$this->setMessage('success_declared');
			}
		}
제목 글쓴이 날짜
[주옥시리즈]댓글 작성, 추천후 다운로드 받을수 있게 하기. socialskyo 2013.09.09
관리자에게 무제한 추천기능 부여 (XE Core 수정) [8] sejin7940 2010.06.30
새로고침없이 페이지 리로딩 간단하고 쉽게 서버한테는 미안하게 하는법 (서버단이 아니고 스킨에 ㅠ jquery load씀) 게시글,댓글,추천등 모든 부분다가능합니다. [2] 장포크 2013.08.08
XE 내가 작성한 글 모두 일괄 추천하기. [4] 엘카 2013.08.01
게시판 및 댓글 추천/비추천 카운트가 바로 적용되지 않는 경우 KS 2013.07.28
게시글에 댓글 부분 추천, 비추천 바로 노출하기 [5] file 똑디 2013.07.19
xe_default 게시판 추천/비추천 색상 변경하기 file 화랑529 2013.01.08
추천인/비추천인 표시하기 [7] file 고진감래 2009.11.05
bodex 추천 & 댓글 버튼 만들기. [1] file meanie 2012.10.28
관리자페이지 전체 댓글 리스트에서 추천/비추천수 안 나오는 버그 수정법 [2] sejin7940 2012.06.22
추천, 신고 제한 해제 (관리자만 v1.5.2.2) [4] mugenk 2012.04.09
비회원도 추천가능하게 하기 (1.5기준설명) [3] 빽짱구 2011.11.18
관리자 무한추천 팁과 추천인/비추천인 표시팁의 충돌 [1] ForHanbi 2011.09.10
"이 게시물을..." 추천/비추천/신고 메뉴를 버튼으로 [28] file xe촙5 2007.11.08
추천수와 비추천수를 합친 값을 보여주기 lol €:) 2011.03.11
윈도우즈용 메일서버 추천- NMail [3] u2em 2004.07.19
[강력추천!!] 윈도우에서 아파치,MySql,PHP 돌리기! - apmsetup.com [10] 별빛부셔 2003.09.05
추천해드리는 보안공부 사이트 [3] Dopesoul 2002.10.05
[추천 강의] NZEO.COM 에서 쓰는 북마크 구현하기 [5] 東氣號太 2002.12.28
[추천 강의] [설명] 304번 글에 대한 설명입니다. [5] [콜록]토끼군 2002.12.25