웹마스터 팁

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

 

추천, 신고기능을 관리자만 제한을 해제하도록 수정하였습니다. 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');
			}
		}
제목 글쓴이 날짜
bcastr 이용한 플래쉬 (flash) 최근 이미지 소스 사용 위젯 소개.. [1] 하얀마법 2010.07.11
윈도우서버에 설치된 XE에서 이슈트래커의 코드열람 사용시 proc_open 함수 에러가 발생 할때. [1] file Na5key 2010.07.08
스킨 디자인! 이미지 대신 CSS3를 사용해 보세요! [7] 정찬명_ 2010.07.08
IIS7 + MySQL 5.1.x + PHP 5.3.2 + phpMyAdmin 3.3.4 + URL Rewrite + XpressEngine 설치 [2] 키네시스 2010.07.07
이미지 여러개 삽입시 이미지 사이에 공백 및 글 쓸 수 있도록 [1] sejin7940 2010.07.07
XE 라이센스에 대한 FAQ [3] 행복한고니 2010.07.07
XE 업데이트 방법 - 제3편 (1.2.4 에서 1.4.4.1 이상의 최신버전으로 업그레이드) + 문제대응 [8] Gekkou 2010.07.07
스마트폰이 없는뒤~!! 모바일페이지를 봐야 할경우 [15] 토깽이2 2010.07.02
XE 기본 서식 - 검정 바탕용 : p, div, br 없는 기본 서식입니다. [5] file LutZ 2010.07.01
관리자에게 무제한 추천기능 부여 (XE Core 수정) [8] sejin7940 2010.06.30
게시판 설정 중 ''게시판상세설명''에 table 태그 쓰면 깨지는 현상 sejin7940 2010.06.30
레이아웃스킨의 기본 형식 [1] file mindpainter 2010.06.29
웹호스팅 이전에따른 zb4에서 xe로 디비 이전하기 김선호489 2010.06.29
제어판의 관리자 메뉴 확장해서 보기 [1] file amd짱좋아 2010.06.27
위젯 제목부분을 클릭 했을 때 해당 게시판으로 링크하기 file 화이트서리 2010.06.27
리눅스 기초 보안처리 [1] 일모도원 2010.06.27
XE 속도 향상 팁 (코어 수정 팁) [6] SMaker 2010.06.26
XE 트위터 모임 해쉬태그 " #XE당_" 로 더 가까워집시다! [3] DJinside 2010.06.24
ie8 스크롤바 때문에 레이아웃이 움직이는 경우 오실롯 2010.06.22
스크립트 오류로 고생하시는분 [2] 니오티 2010.06.21