웹마스터 팁

1. 개요

이 코드는 1.7.5.2 버전이상에서 테스트 했습니다.

member_srl 을 기록하여 익명게시판에 글 수정권한을 유저가 가지도록 하는데 이를 운영진이 글을 수정하엿을 경우 그 글의 권한이 운영진으로 넘어가게 됩니다. 그렇게 되면서 그 글을 적었던 유저는 그 글을 삭제, 수정 권한이 뺐기는 문제가 있습니다.

2. 해결 방안

기본적으로 XE 게시판 모듈에서 글쓰기와 글수정은 한곳에서 이루어지며, 글 수정의 경우 update 하는 방안으로 처리가 되고 있습니다. 이를 이용하여 동시 다발적으로 member_srl 을 처리하는 부분을 각각 나눠서 글 수정시에는 member_srl 을 다시 기록하지 않도록 하는 것이 바람직합니다.

3. 코드 제공.

https://github.com/xpressengine/xe-core/pull/778/files
을 기본바탕으로 보고 따라코드 적으시면 됩니다.

xe/modules/board/board.controller.php
파일에서

63번째줄부터 77번째줄까지 (빈 줄도 함께 잘라내세요..)을 잘라내기로 짜릅니다. (지워지면서 복사 붙여넣기 되어야 합니다.)

            // if use anonymous is true
            if($this->module_info->use_anonymous == 'Y')
            {
                $this->module_info->admin_mail = '';
                $obj->notify_message = 'N';
                $obj->member_srl = -1*$logged_info->member_srl;
                $obj->email_address = $obj->homepage = $obj->user_id = '';
                $obj->user_name = $obj->nick_name = 'anonymous';
                $bAnonymous = true;
                $oDocument->add('member_srl', $obj->member_srl);
            }
            else
            {
                $bAnonymous = false;
            }

이 코드입니다.

이 잘라낸 코드는 
if($oDocument->isExists() && $oDocument->document_srl == $obj->document_srl)
이라고 적혀있는 if문 속에 넣어주시면 됩니다./100번째줄에 넣으세요./
넣어주실때 $obj->member_srl = -1*$logged_info->member_srl; 문구는 지워야합니다.

            // if use anonymous is true
            if($this->module_info->use_anonymous == 'Y')
            {
                $this->module_info->admin_mail = '';
                $obj->notify_message = 'N';
                $obj->email_address = $obj->homepage = $obj->user_id = '';
                $obj->user_name = $obj->nick_name = 'anonymous';
                $bAnonymous = true;
                $oDocument->add('member_srl', $obj->member_srl);
            }
            else
            {
                $bAnonymous = false;
            }

이렇게 되어야 합니다..

그리고 121번째줄에도 마찬가지로 붙여넣으시고 해당 member_srl 은 지우시지 않으셔도 됩니다

            // if use anonymous is true
            if($this->module_info->use_anonymous == 'Y')
            {
                $this->module_info->admin_mail = '';
                $obj->notify_message = 'N';
                $obj->member_srl = -1*$logged_info->member_srl;
                $obj->email_address = $obj->homepage = $obj->user_id = '';
                $obj->user_name = $obj->nick_name = 'anonymous';
                $bAnonymous = true;
                $oDocument->add('member_srl', $obj->member_srl);
            }
            else
            {
                $bAnonymous = false;
            }

이렇게 해서 procBoardInsertDocument 의 총 코드는 아래코드와 같아야 합니다.

    function procBoardInsertDocument()
    {
        // check grant
        if($this->module_info->module != "board")
        {
            return new Object(-1, "msg_invalid_request");
        }
        if(!$this->grant->write_document)
        {
            return new Object(-1, 'msg_not_permitted');
        }
        $logged_info = Context::get('logged_info');

        // setup variables
        $obj = Context::getRequestVars();
        $obj->module_srl = $this->module_srl;
        if($obj->is_notice!='Y'||!$this->grant->manager) $obj->is_notice = 'N';
        $obj->commentStatus = $obj->comment_status;

        settype($obj->title, "string");
        if($obj->title == '') $obj->title = cut_str(strip_tags($obj->content),20,'...');
        //setup dpcument title tp 'Untitled'
        if($obj->title == '') $obj->title = 'Untitled';

        // unset document style if the user is not the document manager
        if(!$this->grant->manager)
        {
            unset($obj->title_color);
            unset($obj->title_bold);
        }

        // generate document module model object
        $oDocumentModel = getModel('document');

        // generate document module의 controller object
        $oDocumentController = getController('document');

        // check if the document is existed
        $oDocument = $oDocumentModel->getDocument($obj->document_srl, $this->grant->manager);

        if((!$obj->status && $obj->is_secret == 'Y') || strtoupper($obj->status == 'SECRET'))
        {
            $use_status = explode('|@|', $this->module_info->use_status);
            if(!is_array($use_status) || !in_array('SECRET', $use_status))
            {
                $obj->status = 'PUBLIC';
            }
        }

        // update the document if it is existed
        if($oDocument->isExists() && $oDocument->document_srl == $obj->document_srl)
        {
            if(!$oDocument->isGranted())
            {
                return new Object(-1,'msg_not_permitted');
            }

            if($this->module_info->protect_content=="Y" && $oDocument->get('comment_count')>0 && $this->grant->manager==false)
            {
                return new Object(-1,'msg_protect_content');
            }

            if(!$this->grant->manager)
            {
                // notice & document style same as before if not manager
                $obj->is_notice = $oDocument->get('is_notice');
                $obj->title_color = $oDocument->get('title_color');
                $obj->title_bold = $oDocument->get('title_bold');
            }

            // modify list_order if document status is temp
            if($oDocument->get('status') == 'TEMP')
            {
                $obj->last_update = $obj->regdate = date('YmdHis');
                $obj->update_order = $obj->list_order = (getNextSequence() * -1);
            }

            // if use anonymous is true
            if($this->module_info->use_anonymous == 'Y')
            {
                $this->module_info->admin_mail = '';
                $obj->notify_message = 'N';
                $obj->email_address = $obj->homepage = $obj->user_id = '';
                $obj->user_name = $obj->nick_name = 'anonymous';
                $bAnonymous = true;
                $oDocument->add('member_srl', $obj->member_srl);
            }
            else
            {
                $bAnonymous = false;
            }


            $output = $oDocumentController->updateDocument($oDocument, $obj);
            $msg_code = 'success_updated';

        // insert a new document otherwise
        } else {
            // if use anonymous is true
            if($this->module_info->use_anonymous == 'Y')
            {
                $this->module_info->admin_mail = '';
                $obj->notify_message = 'N';
                $obj->member_srl = -1*$logged_info->member_srl;
                $obj->email_address = $obj->homepage = $obj->user_id = '';
                $obj->user_name = $obj->nick_name = 'anonymous';
                $bAnonymous = true;
                $oDocument->add('member_srl', $obj->member_srl);
            }
            else
            {
                $bAnonymous = false;
            }

            $output = $oDocumentController->insertDocument($obj, $bAnonymous);
            $msg_code = 'success_registed';
            $obj->document_srl = $output->get('document_srl');

            // send an email to admin user
            if($output->toBool() && $this->module_info->admin_mail)
            {
                $oMail = new Mail();
                $oMail->setTitle($obj->title);
                $oMail->setContent( sprintf("From : <a href=\"%s\">%s</a><br/>\r\n%s", getFullUrl('','document_srl',$obj->document_srl), getFullUrl('','document_srl',$obj->document_srl), $obj->content));
                $oMail->setSender($obj->user_name, $obj->email_address);

                $target_mail = explode(',',$this->module_info->admin_mail);
                for($i=0;$i<count($target_mail);$i++)
                {
                    $email_address = trim($target_mail[$i]);
                    if(!$email_address) continue;
                    $oMail->setReceiptor($email_address, $email_address);
                    $oMail->send();
                }
            }
        }

        // if there is an error
        if(!$output->toBool())
        {
            return $output;
        }

        // return the results
        $this->add('mid', Context::get('mid'));
        $this->add('document_srl', $output->get('document_srl'));

        // alert a message
        $this->setMessage($msg_code);
    }

여기까지 오시느라 수고 많으셧습니다.

댓글로 질문 남겨주셔도 좋습니다 :+1:

제목 글쓴이 날짜
신천오피 신천OP ⦑오피쓰.COM⦒ 신천휴게텔 신천오피 신천오피 koykoyah 2025.02.21
군산오피 ⦑출장안마사이트.COM⦒ 군산오피 군산출장마사지 군산오피 군산OP koykoyah 2025.02.21
강서오피 ⦑오피쓰.COM⦒ 강서마사지 강서오피 강서오피 강서OP koykoyah 2025.02.21
수원오피 수원OP ⦑오피.CLUB⦒ 수원휴게텔 수원오피 수원오피 koykoyah 2025.02.21
포항오피 ⦑오피쓰.COM⦒ 포항마사지 포항오피 포항오피 포항OP koykoyah 2025.02.21
신도림오피 ⦑오피쓰주소.COM⦒ 신도림오피 신도림OP 신도림건마 신도림오피 koykoyah 2025.02.21
안산오피 ⦑오피사이트.NET⦒ 안산OP 안산오피 안산출장샵 안산오피 koykoyah 2025.02.21
익산오피 ⦑출장마사지안내.COM⦒ 익산오피 익산출장마사지 익산오피 익산OP koykoyah 2025.02.21
건대오피 건대OP ⦑오피사이트.NET⦒ 건대휴게텔 건대오피 건대오피 koykoyah 2025.02.21
역삼오피 ⦑오피쓰주소.COM⦒ 역삼오피 역삼출장마사지 역삼오피 역삼OP koykoyah 2025.02.21
대구오피 대구오피 ⦑오피쓰주소.COM⦒ 대구OP 대구스파 대구오피 koykoyah 2025.02.21
남양주오피 ⦑오피사이트.NET⦒ 남양주오피 남양주OP 남양주건마 남양주오피 koykoyah 2025.02.21
부천오피 ⦑오피쓰.COM⦒ 부천마사지 부천오피 부천오피 부천OP koykoyah 2025.02.21
송탄오피 ⦑오피.CLUB⦒ 송탄오피 송탄출장마사지 송탄오피 송탄OP koykoyah 2025.02.21
역삼오피 ⦑오피.CLUB⦒ 역삼오피 역삼출장마사지 역삼오피 역삼OP koykoyah 2025.02.21
신도림오피 ⦑오피사이트.NET⦒ 신도림오피 신도림출장마사지 신도림오피 신도림OP koykoyah 2025.02.21
분당오피 분당오피 ⦑오피쓰주소.COM⦒ 분당OP 분당스파 분당오피 koykoyah 2025.02.21
대구오피 대구OP ⦑오피쓰주소.COM⦒ 대구휴게텔 대구오피 대구오피 koykoyah 2025.02.21
강북오피 ⦑오피사이트.NET⦒ 강북마사지 강북오피 강북오피 강북OP koykoyah 2025.02.21
압구정오피 압구정오피 ⦑오피.CLUB⦒ 압구정OP 압구정스파 압구정오피 koykoyah 2025.02.21