웹마스터 팁

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

 

추천, 신고기능을 관리자만 제한을 해제하도록 수정하였습니다. 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');
			}
		}
제목 글쓴이 날짜
쪽지함 모바일에서 pc로 안넘기고 모바일 레이아웃에서 띄우는법&질문 [5] file 제발도와주세요 2012.03.20
그룹별 회원정보 검색 & 회원의 추가가입폼 복수 검색 팁 (XE 1.5) sejin7940 2012.03.22
제로보드4 에서 xe 1.5 버전설치후 xml 파일 이전시 파일 누락되는 현상해결 [4] 때린데 또때려 2012.03.24
XE를 처음 설치하면 기본적으로 필요한 자료들 - 초보자용 V2013-05-20 [11] Treasurej 2012.03.26
Contact us 체크박스 및 전화번호가 array로 나오는 거 패치 [9] hhgyu 2012.03.27
이번 xe 1.5.2.1 업데이트 하고 게시판 보기 .htaccess 문제 권기성2 2012.03.29
선택된 카테고리의 공지글들만 나타나게 하는 팁 [1] sejin7940 2012.04.02
마우스 오버시 텍스트 호버링(주석나타내기..레이어적용) [1] Konghee 2012.04.02
조회수 클릭때마다 올라가기(1.5.2 버전) 송동우님 팁 [7] 때린데 또때려 2012.04.08
회원가입폼 비밀번호 찾기 질문/답변 삭제및 필수항목 선택 (송동우님 팁) 때린데 또때려 2012.04.08
이미지 외부링크 차단하는법 [6] 리리슐츠 2012.04.08
회원가입폼 비밀번호 찾기 질문/답변 삭제및 필수항목 선택 (송동우님 팁) [8] 때린데 또때려 2012.04.09
추천, 신고 제한 해제 (관리자만 v1.5.2.2) [4] mugenk 2012.04.09
게시판에 다운로드 횟수 출력하기 (스케치북 게시판 전용) [5] file 숭숭군 2012.04.20
제로보드4에서 xe로 이전시 갤러리 게시판 이미지 깨어지는 현상 해결방법 [2] 최르토스 2012.04.22
기본 css 파일 언로드 하기. [9] 엘카 2012.04.26
그누보드 데이터를 XE 로 이전하는 컨버터 입니다. [2] file joyhmbc 2012.04.27
1.5.2.3 업데이트 후 이미지, 아이콘 테두리 생김 현상 없애는 방법 [3] 비밀얌 2012.04.28
1.5.2.3 에서 게시글이 등록이 되는데 ajax XML parser 에러가 나는경우 엑스셀코드 2012.04.28
통합검색 기능에 권한 적용하기 (완전 차단 필요할 때) [9] file 모노소프트 2012.04.30