| 1 |  |  | <?php namespace Xoopsmodules\instruction; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | //use Xoopsmodules\instruction; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | //if (!defined("XOOPS_ROOT_PATH")) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | //	die("XOOPS root path not defined"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | //} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | //include_once $GLOBALS['xoops']->path('include/common.php'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  * Class InstructionHandler | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  * @package Xoopsmodules\instruction | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | class InstructionHandler extends \XoopsPersistableObjectHandler | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |      * @param null|mixed $db | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |     public function __construct(\XoopsDatabase $db = null) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |         parent::__construct($db, 'instruction_instr', Instruction::class, 'instrid', 'title'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |     // Обновление даты обновления инструкций | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |      * @param int  $instrid | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |      * @param bool|int $time | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |      * @return mixed | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 31 |  |  |      */ | 
            
                                                                        
                            
            
                                                                    
                                                                                                        
            
            
                | 32 |  | View Code Duplication |     public function updateDateupdated($instrid = 0, $time = null) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 33 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 34 |  |  |         // Если не передали время | 
            
                                                                        
                            
            
                                    
            
            
                | 35 |  |  |         $time = null === $time ? time() : (int)$time; | 
            
                                                                        
                            
            
                                    
            
            
                | 36 |  |  |         // | 
            
                                                                        
                            
            
                                    
            
            
                | 37 |  |  |         $sql = sprintf('UPDATE `%s` SET `dateupdated` = %u WHERE `instrid` = %u', $this->table, $time, (int)$instrid); | 
            
                                                                        
                            
            
                                    
            
            
                | 38 |  |  |         // | 
            
                                                                        
                            
            
                                    
            
            
                | 39 |  |  |         return $this->db->query($sql); | 
            
                                                                        
                            
            
                                    
            
            
                | 40 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |     // Обновление числа страниц | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |      * @param int $instrid | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |      * @return mixed | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |     public function updatePages($instrid = 0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |         //        $pageHandler = xoops_getModuleHandler('page', 'instruction'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |         // Находим число активных страниц | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |         $criteria = new \CriteriaCompo(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |         $criteria->add(new \Criteria('instrid', $instrid, '=')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |         $criteria->add(new \Criteria('status ', '0', '>')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |         // Число страниц | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |         $pages = $pageHandler->getCount($criteria); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |         unset($criteria); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |         // Сохраняем это число | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |         $sql = sprintf('UPDATE `%s` SET `pages` = %u, `dateupdated` = %u WHERE `instrid` = %u', $this->table, $pages, time(), $instrid); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |         // | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |         return $this->db->query($sql); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 64 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 65 |  |  |  | 
            
                        
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.