웹마스터 팁

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:

제목 글쓴이 날짜
판교오피 ⦑출장마사지안내.COM⦒ 판교마사지 판교오피 판교오피 판교OP koykoyah 2025.02.22
판교오피 ⦑출장안마사이트.COM⦒ 판교OP 판교오피 판교출장샵 판교오피 koykoyah 2025.02.22
선릉오피 선릉출장안마 ⦑오피쓰주소.COM⦒ 선릉OP 선릉오피 선릉오피 koykoyah 2025.02.22
청주오피 청주출장안마 ⦑출장마사지안내.COM⦒ 청주OP 청주오피 청주오피 koykoyah 2025.02.22
건대오피 건대출장안마 ⦑오피쓰.COM⦒ 건대OP 건대오피 건대오피 koykoyah 2025.02.22
동탄오피 동탄OP ⦑출장안마사이트.COM⦒ 동탄휴게텔 동탄오피 동탄오피 koykoyah 2025.02.22
선릉오피 ⦑오피사이트.NET⦒ 선릉마사지 선릉오피 선릉오피 선릉OP koykoyah 2025.02.22
충주오피 충주출장안마 ⦑오피.CLUB⦒ 충주OP 충주오피 충주오피 koykoyah 2025.02.22
일산오피 ⦑오피쓰주소.COM⦒ 일산오피 일산OP 일산건마 일산오피 koykoyah 2025.02.22
서면오피 ⦑오피쓰주소.COM⦒ 서면오피 서면OP 서면건마 서면오피 koykoyah 2025.02.22
강북오피 강북출장안마 ⦑오피쓰주소.COM⦒ 강북OP 강북오피 강북오피 koykoyah 2025.02.22
동대문오피 ⦑오피쓰.COM⦒ 동대문오피 동대문OP 동대문건마 동대문오피 koykoyah 2025.02.22
부천오피 부천출장안마 ⦑출장안마사이트.COM⦒ 부천OP 부천오피 부천오피 koykoyah 2025.02.22
건대오피 건대오피 ⦑출장안마사이트.COM⦒ 건대OP 건대스파 건대오피 koykoyah 2025.02.22
군산오피 ⦑오피사이트.NET⦒ 군산오피 군산OP 군산건마 군산오피 koykoyah 2025.02.22
서면오피 ⦑오피.CLUB⦒ 서면OP 서면오피 서면출장샵 서면오피 koykoyah 2025.02.22
충주오피 충주OP ⦑오피쓰.COM⦒ 충주휴게텔 충주오피 충주오피 koykoyah 2025.02.22
제주도오피 ⦑오피사이트.NET⦒ 제주도OP 제주도오피 제주도출장샵 제주도오피 koykoyah 2025.02.22
창원오피 ⦑출장마사지안내.COM⦒ 창원마사지 창원오피 창원오피 창원OP koykoyah 2025.02.22
구미오피 구미오피 ⦑오피.CLUB⦒ 구미OP 구미스파 구미오피 koykoyah 2025.02.22