GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — develop (#1930)
by
unknown
13:51
created

boardController::procBoardInsertDocument()   F

Complexity

Conditions 31
Paths 15842

Size

Total Lines 156
Code Lines 77

Duplication

Lines 11
Ratio 7.05 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
cc 31
eloc 77
c 2
b 1
f 0
nc 15842
nop 0
dl 11
loc 156
rs 2

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/* Copyright (C) NAVER <http://www.navercorp.com> */
3
4
/**
5
 * @class  boardController
6
 * @author NAVER ([email protected])
7
 * @brief  board module Controller class
8
 **/
9
10
class boardController extends board
11
{
12
13
	/**
14
	 * @brief initialization
15
	 **/
16
	function init()
17
	{
18
	}
19
20
	/**
21
	 * @brief insert document
22
	 **/
23
	function procBoardInsertDocument()
24
	{
25
		// check grant
26
		if($this->module_info->module != "board")
0 ignored issues
show
Bug introduced by
The property module_info cannot be accessed from this context as it is declared private in class ModuleObject.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
27
		{
28
			return new Object(-1, "msg_invalid_request");
29
		}
30
		if(!$this->grant->write_document)
0 ignored issues
show
Bug introduced by
The property grant does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
31
		{
32
			return new Object(-1, 'msg_not_permitted');
33
		}
34
		$logged_info = Context::get('logged_info');
35
36
		// setup variables
37
		$obj = Context::getRequestVars();
38
		$obj->module_srl = $this->module_srl;
0 ignored issues
show
Bug introduced by
The property module_srl cannot be accessed from this context as it is declared private in class ModuleObject.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
39
		if($obj->is_notice!='Y'||!$this->grant->manager) $obj->is_notice = 'N';
40
		$obj->commentStatus = $obj->comment_status;
41
42
		settype($obj->title, "string");
43
		if($obj->title == '') $obj->title = cut_str(trim(strip_tags(nl2br($obj->content))),20,'...');
44
		//setup dpcument title tp 'Untitled'
45
		if($obj->title == '') $obj->title = 'Untitled';
46
47
		// unset document style if the user is not the document manager
48
		if(!$this->grant->manager)
49
		{
50
			unset($obj->title_color);
51
			unset($obj->title_bold);
52
		}
53
54
		// generate document module model object
55
		$oDocumentModel = getModel('document');
56
57
		// generate document module의 controller object
58
		$oDocumentController = getController('document');
59
60
		// check if the document is existed
61
		$oDocument = $oDocumentModel->getDocument($obj->document_srl, $this->grant->manager);
62
63
		// update the document if it is existed
64
		$is_update = false;
65
		if($oDocument->isExists() && $oDocument->document_srl == $obj->document_srl)
66
		{
67
			$is_update = true;
68
		}
69
70
		// if use anonymous is true
71
		if($this->module_info->use_anonymous == 'Y')
0 ignored issues
show
Bug introduced by
The property module_info cannot be accessed from this context as it is declared private in class ModuleObject.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
72
		{
73
			$this->module_info->admin_mail = '';
0 ignored issues
show
Bug introduced by
The property module_info cannot be accessed from this context as it is declared private in class ModuleObject.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
74
			$obj->notify_message = 'N';
75
			if($is_update===false)
76
			{
77
				$obj->member_srl = -1*$logged_info->member_srl;
78
			}
79
			$obj->email_address = $obj->homepage = $obj->user_id = '';
80
			$obj->user_name = $obj->nick_name = 'anonymous';
81
			$bAnonymous = true;
82
			if($is_update===false)
83
			{
84
				$oDocument->add('member_srl', $obj->member_srl);
85
			}
86
		}
87
		else
88
		{
89
			$bAnonymous = false;
90
		}
91
92
		if($obj->is_secret == 'Y' || strtoupper($obj->status == 'SECRET'))
93
		{
94
			$use_status = explode('|@|', $this->module_info->use_status);
0 ignored issues
show
Bug introduced by
The property module_info cannot be accessed from this context as it is declared private in class ModuleObject.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
95
			if(!is_array($use_status) || !in_array('SECRET', $use_status))
96
			{
97
				unset($obj->is_secret);
98
				$obj->status = 'PUBLIC';
99
			}
100
		}
101
102
		// update the document if it is existed
103
		if($is_update)
104
		{
105
			if(!$oDocument->isGranted())
106
			{
107
				return new Object(-1,'msg_not_permitted');
108
			}
109
110
			if($this->module_info->use_anonymous == 'Y') {
0 ignored issues
show
Bug introduced by
The property module_info cannot be accessed from this context as it is declared private in class ModuleObject.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
111
				$obj->member_srl = abs($oDocument->get('member_srl')) * -1;
112
				$oDocument->add('member_srl', $obj->member_srl);
113
			}
114
115 View Code Duplication
			if($this->module_info->protect_content=="Y" && $oDocument->get('comment_count')>0 && $this->grant->manager==false)
0 ignored issues
show
Bug introduced by
The property module_info cannot be accessed from this context as it is declared private in class ModuleObject.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
116
			{
117
				return new Object(-1,'msg_protect_content');
118
			}
119
120
			if(!$this->grant->manager)
121
			{
122
				// notice & document style same as before if not manager
123
				$obj->is_notice = $oDocument->get('is_notice');
124
				$obj->title_color = $oDocument->get('title_color');
125
				$obj->title_bold = $oDocument->get('title_bold');
126
			}
127
			
128
			// modify list_order if document status is temp
129
			if($oDocument->get('status') == 'TEMP')
130
			{
131
				$obj->last_update = $obj->regdate = date('YmdHis');
132
				$obj->update_order = $obj->list_order = (getNextSequence() * -1);
133
			}
134
135
			$output = $oDocumentController->updateDocument($oDocument, $obj, true);
136
			$msg_code = 'success_updated';
137
138
		// insert a new document otherwise
139
		} else {
140
			$output = $oDocumentController->insertDocument($obj, $bAnonymous);
141
			$msg_code = 'success_registed';
142
			$obj->document_srl = $output->get('document_srl');
143
144
			// send an email to admin user
145
			if($output->toBool() && $this->module_info->admin_mail)
0 ignored issues
show
Bug introduced by
The property module_info cannot be accessed from this context as it is declared private in class ModuleObject.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
146
			{
147
				$oMail = new Mail();
148
				$oMail->setTitle($obj->title);
149
				$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));
150
				$oMail->setSender($obj->user_name, $obj->email_address);
151
152
				$target_mail = explode(',',$this->module_info->admin_mail);
0 ignored issues
show
Bug introduced by
The property module_info cannot be accessed from this context as it is declared private in class ModuleObject.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
153 View Code Duplication
				for($i=0;$i<count($target_mail);$i++)
0 ignored issues
show
Performance Best Practice introduced by
It seems like you are calling the size function count() as part of the test condition. You might want to compute the size beforehand, and not on each iteration.

If the size of the collection does not change during the iteration, it is generally a good practice to compute it beforehand, and not on each iteration:

for ($i=0; $i<count($array); $i++) { // calls count() on each iteration
}

// Better
for ($i=0, $c=count($array); $i<$c; $i++) { // calls count() just once
}
Loading history...
154
				{
155
					$email_address = trim($target_mail[$i]);
156
					if(!$email_address) continue;
157
					$oMail->setReceiptor($email_address, $email_address);
158
					$oMail->send();
159
				}
160
			}
161
		}
162
163
		// if there is an error
164
		if(!$output->toBool())
165
		{
166
			return $output;
167
		}
168
169
		// return the results
170
		$this->add('mid', Context::get('mid'));
171
		$this->add('document_srl', $output->get('document_srl'));
172
173
		// alert a message
174
		if(Context::get('xeVirtualRequestMethod') !== 'xml')
175
		{
176
			$this->setMessage($msg_code);
177
		}
178
	}
179
180
	/**
181
	 * @brief delete the document
182
	 **/
183
	function procBoardDeleteDocument()
184
	{
185
		// get the document_srl
186
		$document_srl = Context::get('document_srl');
187
188
		// if the document is not existed
189
		if(!$document_srl)
190
		{
191
			return $this->doError('msg_invalid_document');
0 ignored issues
show
Bug introduced by
The method doError() does not seem to exist on object<boardController>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
192
		}
193
194
		$oDocumentModel = &getModel('document');
195
		$oDocument = $oDocumentModel->getDocument($document_srl);
196
		// check protect content
197 View Code Duplication
		if($this->module_info->protect_content=="Y" && $oDocument->get('comment_count')>0 && $this->grant->manager==false)
0 ignored issues
show
Bug introduced by
The property module_info cannot be accessed from this context as it is declared private in class ModuleObject.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
198
		{
199
			return new Object(-1, 'msg_protect_content');
200
		}
201
202
		// generate document module controller object
203
		$oDocumentController = getController('document');
204
205
		// delete the document
206
		$output = $oDocumentController->deleteDocument($document_srl, $this->grant->manager);
207
		if(!$output->toBool())
208
		{
209
			return $output;
210
		}
211
212
		// alert an message
213
		$this->setRedirectUrl(getNotEncodedUrl('', 'mid', Context::get('mid'), 'act', '', 'page', Context::get('page'), 'document_srl', ''));
214
		$this->add('mid', Context::get('mid'));
215
		$this->add('page', Context::get('page'));
216
		if(Context::get('xeVirtualRequestMethod') !== 'xml')
217
		{
218
			$this->setMessage('success_deleted');
219
		}
220
	}
221
222
	/**
223
	 * @brief vote
224
	 **/
225
	function procBoardVoteDocument()
226
	{
227
		// generate document module controller object
228
		$oDocumentController = getController('document');
229
230
		$document_srl = Context::get('document_srl');
231
		return $oDocumentController->updateVotedCount($document_srl);
232
	}
233
234
	/**
235
	 * @brief insert comments
236
	 **/
237
	function procBoardInsertComment()
238
	{
239
		// check grant
240
		if(!$this->grant->write_comment)
241
		{
242
			return new Object(-1, 'msg_not_permitted');
243
		}
244
		$logged_info = Context::get('logged_info');
245
246
		// get the relevant data for inserting comment
247
		$obj = Context::getRequestVars();
248
		$obj->module_srl = $this->module_srl;
0 ignored issues
show
Bug introduced by
The property module_srl cannot be accessed from this context as it is declared private in class ModuleObject.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
249
250
		if(!$this->module_info->use_status) $this->module_info->use_status = 'PUBLIC';
0 ignored issues
show
Bug introduced by
The property module_info cannot be accessed from this context as it is declared private in class ModuleObject.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
251
		if(!is_array($this->module_info->use_status))
0 ignored issues
show
Bug introduced by
The property module_info cannot be accessed from this context as it is declared private in class ModuleObject.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
252
		{
253
			$this->module_info->use_status = explode('|@|', $this->module_info->use_status);
0 ignored issues
show
Bug introduced by
The property module_info cannot be accessed from this context as it is declared private in class ModuleObject.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
254
		}
255
256
		if(in_array('SECRET', $this->module_info->use_status))
0 ignored issues
show
Bug introduced by
The property module_info cannot be accessed from this context as it is declared private in class ModuleObject.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
257
		{
258
			$this->module_info->secret = 'Y';
0 ignored issues
show
Bug introduced by
The property module_info cannot be accessed from this context as it is declared private in class ModuleObject.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
259
		}
260
		else
261
		{
262
			unset($obj->is_secret);
263
			$this->module_info->secret = 'N';
0 ignored issues
show
Bug introduced by
The property module_info cannot be accessed from this context as it is declared private in class ModuleObject.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
264
		}
265
266
		// check if the doument is existed
267
		$oDocumentModel = getModel('document');
268
		$oDocument = $oDocumentModel->getDocument($obj->document_srl);
269
		if(!$oDocument->isExists())
270
		{
271
			return new Object(-1,'msg_not_founded');
272
		}
273
274
		// For anonymous use, remove writer's information and notifying information
275
		if($this->module_info->use_anonymous == 'Y')
0 ignored issues
show
Bug introduced by
The property module_info cannot be accessed from this context as it is declared private in class ModuleObject.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
276
		{
277
			$this->module_info->admin_mail = '';
0 ignored issues
show
Bug introduced by
The property module_info cannot be accessed from this context as it is declared private in class ModuleObject.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
278
			$obj->notify_message = 'N';
279
			$obj->member_srl = -1*$logged_info->member_srl;
280
			$obj->email_address = $obj->homepage = $obj->user_id = '';
281
			$obj->user_name = $obj->nick_name = 'anonymous';
282
			$bAnonymous = true;
283
		}
284
		else
285
		{
286
			$bAnonymous = false;
287
		}
288
289
		// generate comment  module model object
290
		$oCommentModel = getModel('comment');
291
292
		// generate comment module controller object
293
		$oCommentController = getController('comment');
294
295
		// check the comment is existed
296
		// if the comment is not existed, then generate a new sequence
297
		if(!$obj->comment_srl)
298
		{
299
			$obj->comment_srl = getNextSequence();
300
		} else {
301
			$comment = $oCommentModel->getComment($obj->comment_srl, $this->grant->manager);
302
		}
303
304
		// if comment_srl is not existed, then insert the comment
305
		if($comment->comment_srl != $obj->comment_srl)
306
		{
307
308
			// parent_srl is existed
309
			if($obj->parent_srl)
310
			{
311
				$parent_comment = $oCommentModel->getComment($obj->parent_srl);
312
				if(!$parent_comment->comment_srl)
313
				{
314
					return new Object(-1, 'msg_invalid_request');
315
				}
316
317
				$output = $oCommentController->insertComment($obj, $bAnonymous);
318
319
			// parent_srl is not existed
320
			} else {
321
				$output = $oCommentController->insertComment($obj, $bAnonymous);
322
			}
323
		// update the comment if it is not existed
324
		} else {
325
			// check the grant
326
			if(!$comment->isGranted())
0 ignored issues
show
Bug introduced by
The variable $comment does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
327
			{
328
				return new Object(-1,'msg_not_permitted');
329
			}
330
331
			$obj->parent_srl = $comment->parent_srl;
332
			$output = $oCommentController->updateComment($obj, $this->grant->manager);
333
			$comment_srl = $obj->comment_srl;
0 ignored issues
show
Unused Code introduced by
$comment_srl is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
334
		}
335
336
		if(!$output->toBool())
337
		{
338
			return $output;
339
		}
340
341
		if(Context::get('xeVirtualRequestMethod') !== 'xml')
342
		{
343
			$this->setMessage('success_registed');
344
		}
345
		$this->add('mid', Context::get('mid'));
346
		$this->add('document_srl', $obj->document_srl);
347
		$this->add('comment_srl', $obj->comment_srl);
348
	}
349
350
	/**
351
	 * @brief delete the comment
352
	 **/
353 View Code Duplication
	function procBoardDeleteComment()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
354
	{
355
		// get the comment_srl
356
		$comment_srl = Context::get('comment_srl');
357
		if(!$comment_srl)
358
		{
359
			return $this->doError('msg_invalid_request');
0 ignored issues
show
Bug introduced by
The method doError() does not seem to exist on object<boardController>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
360
		}
361
362
		// generate comment  controller object
363
		$oCommentController = getController('comment');
364
365
		$output = $oCommentController->deleteComment($comment_srl, $this->grant->manager);
366
		if(!$output->toBool())
367
		{
368
			return $output;
369
		}
370
371
		$this->add('mid', Context::get('mid'));
372
		$this->add('page', Context::get('page'));
373
		$this->add('document_srl', $output->get('document_srl'));
374
		if(Context::get('xeVirtualRequestMethod') !== 'xml')
375
		{
376
			$this->setMessage('success_deleted');
377
		}
378
	}
379
380
	/**
381
	 * @brief delete the tracjback
382
	 **/
383 View Code Duplication
	function procBoardDeleteTrackback()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
384
	{
385
		$trackback_srl = Context::get('trackback_srl');
386
387
		// generate trackback module controller object
388
		$oTrackbackController = getController('trackback');
389
390
		if(!$oTrackbackController) return;
391
392
		$output = $oTrackbackController->deleteTrackback($trackback_srl, $this->grant->manager);
0 ignored issues
show
Bug introduced by
The method deleteTrackback() does not seem to exist on object<ModuleObject>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
393
		if(!$output->toBool())
394
		{
395
			return $output;
396
		}
397
398
		$this->add('mid', Context::get('mid'));
399
		$this->add('page', Context::get('page'));
400
		$this->add('document_srl', $output->get('document_srl'));
401
		if(Context::get('xeVirtualRequestMethod') !== 'xml')
402
		{
403
			$this->setMessage('success_deleted');
404
		}
405
	}
406
407
	/**
408
	 * @brief check the password for document and comment
409
	 **/
410
	function procBoardVerificationPassword()
411
	{
412
		// get the id number of the document and the comment
413
		$password = Context::get('password');
414
		$document_srl = Context::get('document_srl');
415
		$comment_srl = Context::get('comment_srl');
416
417
		$oMemberModel = getModel('member');
418
419
		// if the comment exists
420
		if($comment_srl)
421
		{
422
			// get the comment information
423
			$oCommentModel = getModel('comment');
424
			$oComment = $oCommentModel->getComment($comment_srl);
425
			if(!$oComment->isExists())
426
			{
427
				return new Object(-1, 'msg_invalid_request');
428
			}
429
430
			// compare the comment password and the user input password
431
			if(!$oMemberModel->isValidPassword($oComment->get('password'),$password))
432
			{
433
				return new Object(-1, 'msg_invalid_password');
434
			}
435
436
			$oComment->setGrant();
437
		} else {
438
			 // get the document information
439
			$oDocumentModel = getModel('document');
440
			$oDocument = $oDocumentModel->getDocument($document_srl);
441
			if(!$oDocument->isExists())
442
			{
443
				return new Object(-1, 'msg_invalid_request');
444
			}
445
446
			// compare the document password and the user input password
447
			if(!$oMemberModel->isValidPassword($oDocument->get('password'),$password))
448
			{
449
				return new Object(-1, 'msg_invalid_password');
450
			}
451
452
			$oDocument->setGrant();
453
		}
454
	}
455
456
	/**
457
	 * @brief the trigger for displaying 'view document' link when click the user ID
458
	 **/
459
	function triggerMemberMenu(&$obj)
0 ignored issues
show
Unused Code introduced by
The parameter $obj is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
460
	{
461
		$member_srl = Context::get('target_srl');
462
		$mid = Context::get('cur_mid');
463
464
		if(!$member_srl || !$mid)
465
		{
466
			return new Object();
467
		}
468
469
		$logged_info = Context::get('logged_info');
470
471
		// get the module information
472
		$oModuleModel = getModel('module');
473
		$columnList = array('module');
474
		$cur_module_info = $oModuleModel->getModuleInfoByMid($mid, 0, $columnList);
475
476
		if($cur_module_info->module != 'board')
477
		{
478
			return new Object();
479
		}
480
481
		// get the member information
482
		if($member_srl == $logged_info->member_srl)
483
		{
484
			$member_info = $logged_info;
485
		} else {
486
			$oMemberModel = getModel('member');
487
			$member_info = $oMemberModel->getMemberInfoByMemberSrl($member_srl);
488
		}
489
490
		if(!$member_info->user_id)
491
		{
492
			return new Object();
493
		}
494
495
		//search
496
		$url = getUrl('','mid',$mid,'search_target','nick_name','search_keyword',$member_info->nick_name);
497
		$oMemberController = getController('member');
498
		$oMemberController->addMemberPopupMenu($url, 'cmd_view_own_document', '');
499
500
		return new Object();
501
	}
502
}
503