| 1 |  |  | <?php namespace XoopsModules\Smartobject; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * Contains the basis classes for managing any objects derived from SmartObjects | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * @license    GNU | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * @author     marcan <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * @link       http://smartfactory.ca The SmartFactory | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * @package    SmartObject | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  * @subpackage SmartObjectCore | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | use XoopsModules\Smartobject; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | // defined('XOOPS_ROOT_PATH') || die('Restricted access'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  * Persistable SmartObject Controller class. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  * This class is responsible for providing operations to an object | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  * for managing the object's manipulation | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  * @package SmartObject | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |  * @author  marcan <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |  * @credit  Jan Keller Pedersen <[email protected]> - IDG Danmark A/S <www.idg.dk> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |  * @link    http://smartfactory.ca The SmartFactory | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | //require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobject.php'; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | //require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjecthandler.php'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |  * Class SmartObjectController | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  | class ObjectController | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |     public $handler; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |      * SmartObjectController constructor. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |      * @param $handler | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |     public function __construct($handler) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |         $this->handler = $handler; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |      * @param $smartObj | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |     public function postDataToObject(&$smartObj) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |         foreach (array_keys($smartObj->vars) as $key) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |             switch ($smartObj->vars[$key]['data_type']) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |                 case XOBJ_DTYPE_IMAGE: | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 55 |  | View Code Duplication |                     if (isset($_POST['url_' . $key]) && '' !== $_POST['url_' . $key]) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |                         $oldFile = $smartObj->getUploadDir(true) . $smartObj->getVar($key, 'e'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |                         $smartObj->setVar($key, $_POST['url_' . $key]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |                         if (file_exists($oldFile)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |                             unlink($oldFile); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |                         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |                     } | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 62 |  | View Code Duplication |                     if (isset($_POST['delete_' . $key]) && '1' == $_POST['delete_' . $key]) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |                         $oldFile = $smartObj->getUploadDir(true) . $smartObj->getVar($key, 'e'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |                         $smartObj->setVar($key, ''); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |                         if (file_exists($oldFile)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |                             unlink($oldFile); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |                         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |                     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |                     break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |                 case XOBJ_DTYPE_URLLINK: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |                     $linkObj = $smartObj->getUrlLinkObj($key); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |                     $linkObj->setVar('caption', $_POST['caption_' . $key]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |                     $linkObj->setVar('description', $_POST['desc_' . $key]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |                     $linkObj->setVar('target', $_POST['target_' . $key]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |                     $linkObj->setVar('url', $_POST['url_' . $key]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |                     if ('' !== $linkObj->getVar('url')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |                         $smartObj->storeUrlLinkObj($linkObj); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |                     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |                     //todo: catch errors | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |                     $smartObj->setVar($key, $linkObj->getVar('urllinkid')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |                     break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |                 case XOBJ_DTYPE_FILE: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |                     if (!isset($_FILES['upload_' . $key]['name']) || '' === $_FILES['upload_' . $key]['name']) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |                         $fileObj = $smartObj->getFileObj($key); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |                         $fileObj->setVar('caption', $_POST['caption_' . $key]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |                         $fileObj->setVar('description', $_POST['desc_' . $key]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |                         $fileObj->setVar('url', $_POST['url_' . $key]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |                         if (!('' === $fileObj->getVar('url') && '' === $fileObj->getVar('url') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |                               && '' === $fileObj->getVar('url'))) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |                             $res = $smartObj->storeFileObj($fileObj); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |                             if ($res) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |                                 $smartObj->setVar($key, $fileObj->getVar('fileid')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |                             } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |                                 //error setted, but no error message (to be improved) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |                                 $smartObj->setErrors($fileObj->getErrors()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |                             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |                         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |                     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |                     break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |                 case XOBJ_DTYPE_STIME: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |                 case XOBJ_DTYPE_MTIME: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |                 case XOBJ_DTYPE_LTIME: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |                     // check if this field's value is available in the POST array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |                     if (is_array($_POST[$key]) && isset($_POST[$key]['date'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |                         $value = strtotime($_POST[$key]['date']) + $_POST[$key]['time']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |                     } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |                         $value = strtotime($_POST[$key]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |                         //if strtotime returns false, the value is already a time stamp | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |                         if (!$value) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |                             $value = (int)$_POST[$key]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |                         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |                     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |                     $smartObj->setVar($key, $value); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |                     break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |                 default: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |                     $smartObj->setVar($key, $_POST[$key]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |                     break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |      * @param        $smartObj | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |      * @param        $objectid | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |      * @param        $created_success_msg | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |      * @param        $modified_success_msg | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |      * @param  bool  $redirect_page | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |      * @param  bool  $debug | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |      * @return mixed | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |     public function doStoreFromDefaultForm( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |         &$smartObj, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |         $objectid, | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |         $created_success_msg, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |         $modified_success_msg, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |         $redirect_page = false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |         $debug = false | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |     ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |         global $smart_previous_page; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |         $this->postDataToObject($smartObj); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |         if ($smartObj->isNew()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |             $redirect_msg = $created_success_msg; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |             $redirect_msg = $modified_success_msg; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |         // Check if there were uploaded files | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |         if (isset($_POST['smart_upload_image']) || isset($_POST['smart_upload_file'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  | //            require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartuploader.php'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |             $uploaderObj = new Uploader($smartObj->getImageDir(true), $this->handler->_allowedMimeTypes, $this->handler->_maxFileSize, $this->handler->_maxWidth, $this->handler->_maxHeight); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |             foreach ($_FILES as $name => $file_array) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |                 if (isset($file_array['name']) && '' !== $file_array['name'] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |                     && in_array(str_replace('upload_', '', $name), array_keys($smartObj->vars))) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |                     if ($uploaderObj->fetchMedia($name)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |                         $uploaderObj->setTargetFileName(time() . '_' . $uploaderObj->getMediaName()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |                         if ($uploaderObj->upload()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |                             // Find the related field in the SmartObject | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |                             $related_field   = str_replace('upload_', '', $name); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |                             $uploadedArray[] = $related_field; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |                             //si c'est un fichier Rich | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |                             if (XOBJ_DTYPE_FILE === $smartObj->vars[$related_field]['data_type']) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |                                 $object_fileurl = $smartObj->getUploadDir(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |                                 $fileObj        = $smartObj->getFileObj($related_field); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |                                 $fileObj->setVar('url', $object_fileurl . $uploaderObj->getSavedFileName()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |                                 $fileObj->setVar('caption', $_POST['caption_' . $related_field]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |                                 $fileObj->setVar('description', $_POST['desc_' . $related_field]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |                                 $smartObj->storeFileObj($fileObj); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |                                 //todo: catch errors | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |                                 $smartObj->setVar($related_field, $fileObj->getVar('fileid')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |                             } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |                                 $old_file = $smartObj->getUploadDir(true) . $smartObj->getVar($related_field); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |                                 unlink($old_file); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |                                 $smartObj->setVar($related_field, $uploaderObj->getSavedFileName()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |                             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |                         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |                             $smartObj->setErrors($uploaderObj->getErrors(false)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |                         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |                     } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |                         $smartObj->setErrors($uploaderObj->getErrors(false)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |                     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |         if ($debug) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |             $storeResult = $this->handler->insertD($smartObj); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |             $storeResult = $this->handler->insert($smartObj); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  |         if ($storeResult) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  |             if ($this->handler->getPermissions()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |                 $smartPermissionsHandler = new PermissionHandler($this->handler); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  |                 $smartPermissionsHandler->storeAllPermissionsForId($smartObj->id()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  |         if (null === $redirect_page) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  |             return $smartObj; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |             if (!$storeResult) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |                 redirect_header($smart_previous_page, 3, _CO_SOBJECT_SAVE_ERROR . $smartObj->getHtmlErrors()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |             $redirect_page = $redirect_page ?: Smartobject\Utility::getPageBeforeForm(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |             redirect_header($redirect_page, 2, $redirect_msg); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  |      * Store the object in the database autmatically from a form sending POST data | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  |      * @param  string      $created_success_msg  message to display if new object was created | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  |      * @param  string      $modified_success_msg message to display if object was successfully edited | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  |      * @param  bool|string $redirect_page        redirect page, if not set, then we backup once | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  |      * @param  bool        $debug | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  |      * @param  bool        $x_param | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  |      * @return bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  |      * @internal param string $created_redir_page redirect page after creating the object | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  |      * @internal param string $modified_redir_page redirect page after editing the object | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |      * @internal param bool $exit if set to TRUE then the script ends | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  |     public function storeFromDefaultForm( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  |         $created_success_msg, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  |         $modified_success_msg, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  |         $redirect_page = false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  |         $debug = false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  |         $x_param = false | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  |     ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  |         $objectid = isset($_POST[$this->handler->keyName]) ? (int)$_POST[$this->handler->keyName] : 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  |         if ($debug) { | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 240 |  | View Code Duplication |             if ($x_param) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  |                 $smartObj = $this->handler->getD($objectid, true, $x_param); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  |             } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  |                 $smartObj = $this->handler->getD($objectid); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  |             } | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 245 |  | View Code Duplication |         } else { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  |             if ($x_param) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  |                 $smartObj = $this->handler->get($objectid, true, false, false, $x_param); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  |             } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  |                 $smartObj = $this->handler->get($objectid); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 |  |  |         // if handler is the Multilanguage handler, we will need to treat this for multilanguage | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  |         if (is_subclass_of($this->handler, 'smartpersistablemlobjecthandler')) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  |             if ($smartObj->isNew()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  |                 // This is a new object. We need to store the meta data and then the language data | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 |  |  |                 // First, we will get rid of the multilanguage data to only store the meta data | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 |  |  |                 $smartObj->stripMultilanguageFields(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 |  |  |                 $newObject = $this->doStoreFromDefaultForm($smartObj, $objectid, $created_success_msg, $modified_success_msg, $redirect_page, $debug); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  |                 /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  |                  * @todo we need to trap potential errors here | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  |                  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 |  |  |                 // ok, the meta daa is stored. Let's recreate the object and then | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 |  |  |                 // get rid of anything not multilanguage | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 |  |  |                 unset($smartObj); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 |  |  |                 $smartObj = $this->handler->get($objectid); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 |  |  |                 $smartObj->stripNonMultilanguageFields(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 |  |  |                 $smartObj->setVar($this->handler->keyName, $newObject->getVar($this->handler->keyName)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 |  |  |                 $this->handler->changeTableNameForML(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 |  |  |                 $ret = $this->doStoreFromDefaultForm($smartObj, $objectid, $created_success_msg, $modified_success_msg, $redirect_page, $debug); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 |  |  |                 return $ret; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  |             return $this->doStoreFromDefaultForm($smartObj, $objectid, $created_success_msg, $modified_success_msg, $redirect_page, $debug); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  |      * @return bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 |  |  |     public function storeSmartObjectD() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 |  |  |         return $this->storeSmartObject(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 289 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 290 |  |  |      * @param  bool $debug | 
            
                                                                                                            
                            
            
                                    
            
            
                | 291 |  |  |      * @param  bool $xparam | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 |  |  |      * @return bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 294 |  |  |     public function storeSmartObject($debug = false, $xparam = false) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 296 |  |  |         $ret = $this->storeFromDefaultForm('', '', null, $debug, $xparam); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 297 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 298 |  |  |         return $ret; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 299 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 301 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 302 |  |  |      * Handles deletion of an object which keyid is passed as a GET param | 
            
                                                                                                            
                            
            
                                    
            
            
                | 303 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 304 |  |  |      * @param  bool   $confirm_msg | 
            
                                                                                                            
                            
            
                                    
            
            
                | 305 |  |  |      * @param  string $op | 
            
                                                                                                            
                            
            
                                    
            
            
                | 306 |  |  |      * @param  bool   $userSide | 
            
                                                                                                            
                            
            
                                    
            
            
                | 307 |  |  |      * @return void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 308 |  |  |      * @internal param string $redir_page redirect page after deleting the object | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 309 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 310 |  |  |     public function handleObjectDeletion($confirm_msg = false, $op = 'del', $userSide = false) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 311 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 312 |  |  |         global $smart_previous_page; | 
            
                                                                        
                            
            
                                    
            
            
                | 313 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 314 |  |  |         $objectid = isset($_REQUEST[$this->handler->keyName]) ? (int)$_REQUEST[$this->handler->keyName] : 0; | 
            
                                                                        
                            
            
                                    
            
            
                | 315 |  |  |         $smartObj = $this->handler->get($objectid); | 
            
                                                                        
                            
            
                                    
            
            
                | 316 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 317 |  |  |         if ($smartObj->isNew()) { | 
            
                                                                        
                            
            
                                    
            
            
                | 318 |  |  |             redirect_header('javascript:history.go(-1)', 3, _CO_SOBJECT_NOT_SELECTED); | 
            
                                                                        
                            
            
                                    
            
            
                | 319 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 320 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 321 |  |  |         $confirm = \Xmf\Request::getInt('confirm', 0, POST); | 
            
                                                                        
                            
            
                                    
            
            
                | 322 |  |  |         if ($confirm) { | 
            
                                                                        
                            
            
                                                                    
                                                                                                        
            
            
                | 323 |  | View Code Duplication |             if (!$this->handler->delete($smartObj)) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 324 |  |  |                 redirect_header($_POST['redirect_page'], 3, _CO_SOBJECT_DELETE_ERROR . $smartObj->getHtmlErrors()); | 
            
                                                                        
                            
            
                                    
            
            
                | 325 |  |  |             } | 
            
                                                                        
                            
            
                                    
            
            
                | 326 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 327 |  |  |             redirect_header($_POST['redirect_page'], 3, _CO_SOBJECT_DELETE_SUCCESS); | 
            
                                                                        
                            
            
                                    
            
            
                | 328 |  |  |         } else { | 
            
                                                                        
                            
            
                                    
            
            
                | 329 |  |  |             // no confirm: show deletion condition | 
            
                                                                        
                            
            
                                    
            
            
                | 330 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 331 |  |  |             xoops_cp_header(); | 
            
                                                                        
                            
            
                                    
            
            
                | 332 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 333 |  |  |             if (!$confirm_msg) { | 
            
                                                                        
                            
            
                                    
            
            
                | 334 |  |  |                 $confirm_msg = _CO_SOBJECT_DELETE_CONFIRM; | 
            
                                                                        
                            
            
                                    
            
            
                | 335 |  |  |             } | 
            
                                                                        
                            
            
                                    
            
            
                | 336 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 337 |  |  |             xoops_confirm([ | 
            
                                                                        
                            
            
                                    
            
            
                | 338 |  |  |                               'op'                    => $op, | 
            
                                                                        
                            
            
                                    
            
            
                | 339 |  |  |                               $this->handler->keyName => $smartObj->getVar($this->handler->keyName), | 
            
                                                                        
                            
            
                                    
            
            
                | 340 |  |  |                               'confirm'               => 1, | 
            
                                                                        
                            
            
                                    
            
            
                | 341 |  |  |                               'redirect_page'         => $smart_previous_page | 
            
                                                                        
                            
            
                                    
            
            
                | 342 |  |  |                           ], xoops_getenv('PHP_SELF'), sprintf($confirm_msg, $smartObj->getVar($this->handler->identifierName)), _CO_SOBJECT_DELETE); | 
            
                                                                        
                            
            
                                    
            
            
                | 343 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 344 |  |  |             xoops_cp_footer(); | 
            
                                                                        
                            
            
                                    
            
            
                | 345 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 346 |  |  |         exit(); | 
            
                                                                        
                            
            
                                    
            
            
                | 347 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 348 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 349 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 350 |  |  |      * @param bool   $confirm_msg | 
            
                                                                                                            
                            
            
                                    
            
            
                | 351 |  |  |      * @param string $op | 
            
                                                                                                            
                            
            
                                    
            
            
                | 352 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 353 |  |  |     public function handleObjectDeletionFromUserSide($confirm_msg = false, $op = 'del') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 354 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 355 |  |  |         global $smart_previous_page, $xoopsTpl; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 356 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 357 |  |  |         $objectid = isset($_REQUEST[$this->handler->keyName]) ? (int)$_REQUEST[$this->handler->keyName] : 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 358 |  |  |         $smartObj = $this->handler->get($objectid); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 359 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 360 |  |  |         if ($smartObj->isNew()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 361 |  |  |             redirect_header('javascript:history.go(-1)', 3, _CO_SOBJECT_NOT_SELECTED); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 362 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 363 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 364 |  |  |         $confirm = \Xmf\Request::getInt('confirm', 0, POST); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 365 |  |  |         if ($confirm) { | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 366 |  | View Code Duplication |             if (!$this->handler->delete($smartObj)) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 367 |  |  |                 redirect_header($_POST['redirect_page'], 3, _CO_SOBJECT_DELETE_ERROR . $smartObj->getHtmlErrors()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 368 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 369 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 370 |  |  |             redirect_header($_POST['redirect_page'], 3, _CO_SOBJECT_DELETE_SUCCESS); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 371 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 372 |  |  |             // no confirm: show deletion condition | 
            
                                                                                                            
                            
            
                                    
            
            
                | 373 |  |  |             if (!$confirm_msg) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 374 |  |  |                 $confirm_msg = _CO_SOBJECT_DELETE_CONFIRM; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 375 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 376 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 377 |  |  |             ob_start(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 378 |  |  |             xoops_confirm([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 379 |  |  |                               'op'                    => $op, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 380 |  |  |                               $this->handler->keyName => $smartObj->getVar($this->handler->keyName), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 381 |  |  |                               'confirm'               => 1, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 382 |  |  |                               'redirect_page'         => $smart_previous_page | 
            
                                                                                                            
                            
            
                                    
            
            
                | 383 |  |  |                           ], xoops_getenv('PHP_SELF'), sprintf($confirm_msg, $smartObj->getVar($this->handler->identifierName)), _CO_SOBJECT_DELETE); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 384 |  |  |             $smartobjectDeleteConfirm = ob_get_clean(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 385 |  |  |             $xoopsTpl->assign('smartobject_delete_confirm', $smartobjectDeleteConfirm); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 386 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 387 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 388 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 389 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 390 |  |  |      * Retreive the object admin side link for a {@link SmartObjectSingleView} page | 
            
                                                                                                            
                            
            
                                    
            
            
                | 391 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 392 |  |  |      * @param  SmartObject $smartObj reference to the object from which we want the user side link | 
            
                                                                                                            
                            
            
                                    
            
            
                | 393 |  |  |      * @param  bool        $onlyUrl  wether or not to return a simple URL or a full <a> link | 
            
                                                                                                            
                            
            
                                    
            
            
                | 394 |  |  |      * @param  bool        $withimage | 
            
                                                                                                            
                            
            
                                    
            
            
                | 395 |  |  |      * @return string      admin side link to the object | 
            
                                                                                                            
                            
            
                                    
            
            
                | 396 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 397 |  |  |     public function getAdminViewItemLink(SmartObject $smartObj, $onlyUrl = false, $withimage = false) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 398 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 399 |  |  |         $ret = $this->handler->_moduleUrl . 'admin/' . $this->handler->_page . '?op=view&' . $this->handler->keyName . '=' . $smartObj->getVar($this->handler->keyName); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 400 |  |  |         if ($onlyUrl) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 401 |  |  |             return $ret; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 402 |  |  |         } elseif ($withimage) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 403 |  |  |             return "<a href='" . $ret . "'><img src='" . SMARTOBJECT_IMAGES_ACTIONS_URL . "viewmag.png' style='vertical-align: middle;' alt='" . _CO_SOBJECT_ADMIN_VIEW . "'  title='" . _CO_SOBJECT_ADMIN_VIEW . "'></a>"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 404 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 405 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 406 |  |  |         return "<a href='" . $ret . "'>" . $smartObj->getVar($this->handler->identifierName) . '</a>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 407 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 408 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 409 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 410 |  |  |      * Retreive the object user side link | 
            
                                                                                                            
                            
            
                                    
            
            
                | 411 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 412 |  |  |      * @param  SmartObject $smartObj reference to the object from which we want the user side link | 
            
                                                                                                            
                            
            
                                    
            
            
                | 413 |  |  |      * @param  bool        $onlyUrl  wether or not to return a simple URL or a full <a> link | 
            
                                                                                                            
                            
            
                                    
            
            
                | 414 |  |  |      * @return string      user side link to the object | 
            
                                                                                                            
                            
            
                                    
            
            
                | 415 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 416 |  |  |     public function getItemLink(SmartObject $smartObj, $onlyUrl = false) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 417 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 418 |  |  |         $seoMode       = Smartobject\Utility::getModuleModeSEO($this->handler->_moduleName); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 419 |  |  |         $seoModuleName = Smartobject\Utility::getModuleNameForSEO($this->handler->_moduleName); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 420 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 421 |  |  |         /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 422 |  |  |          * $seoIncludeId feature is not finished yet, so let's put it always to true | 
            
                                                                                                            
                            
            
                                    
            
            
                | 423 |  |  |          */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 424 |  |  |         //$seoIncludeId = Smartobject\Utility::getModuleIncludeIdSEO($this->handler->_moduleName); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 425 |  |  |         $seoIncludeId = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 426 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 427 |  |  |         if ('rewrite' === $seoMode) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 428 |  |  |             $ret = XOOPS_URL . '/' . $seoModuleName . '.' . $this->handler->_itemname . ($seoIncludeId ? '.' . $smartObj->getVar($this->handler->keyName) : '') . '/' . $smartObj->getVar('short_url') . '.html'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 429 |  |  |         } elseif ('pathinfo' === $seoMode) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 430 |  |  |             $ret = SMARTOBJECT_URL . 'seo.php/' . $seoModuleName . '.' . $this->handler->_itemname . ($seoIncludeId ? '.' . $smartObj->getVar($this->handler->keyName) : '') . '/' . $smartObj->getVar('short_url') . '.html'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 431 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 432 |  |  |             $ret = $this->handler->_moduleUrl . $this->handler->_page . '?' . $this->handler->keyName . '=' . $smartObj->getVar($this->handler->keyName); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 433 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 434 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 435 |  |  |         if (!$onlyUrl) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 436 |  |  |             $ret = "<a href='" . $ret . "'>" . $smartObj->getVar($this->handler->identifierName) . '</a>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 437 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 438 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 439 |  |  |         return $ret; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 440 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 441 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 442 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 443 |  |  |      * @param         $smartObj | 
            
                                                                                                            
                            
            
                                    
            
            
                | 444 |  |  |      * @param  bool   $onlyUrl | 
            
                                                                                                            
                            
            
                                    
            
            
                | 445 |  |  |      * @param  bool   $withimage | 
            
                                                                                                            
                            
            
                                    
            
            
                | 446 |  |  |      * @return string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 447 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 448 |  |  |     public function getEditLanguageLink($smartObj, $onlyUrl = false, $withimage = true) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 449 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 450 |  |  |         $ret = $this->handler->_moduleUrl . 'admin/' . $this->handler->_page . '?op=mod&' . $this->handler->keyName . '=' . $smartObj->getVar($this->handler->keyName) . '&language=' . $smartObj->getVar('language'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 451 |  |  |         if ($onlyUrl) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 452 |  |  |             return $ret; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 453 |  |  |         } elseif ($withimage) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 454 |  |  |             return "<a href='" . $ret . "'><img src='" . SMARTOBJECT_IMAGES_ACTIONS_URL . "wizard.png' style='vertical-align: middle;' alt='" . _CO_SOBJECT_LANGUAGE_MODIFY . "'  title='" . _CO_SOBJECT_LANGUAGE_MODIFY . "'></a>"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 455 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 456 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 457 |  |  |         return "<a href='" . $ret . "'>" . $smartObj->getVar($this->handler->identifierName) . '</a>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 458 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 459 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 460 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 461 |  |  |      * @param         $smartObj | 
            
                                                                                                            
                            
            
                                    
            
            
                | 462 |  |  |      * @param  bool   $onlyUrl | 
            
                                                                                                            
                            
            
                                    
            
            
                | 463 |  |  |      * @param  bool   $withimage | 
            
                                                                                                            
                            
            
                                    
            
            
                | 464 |  |  |      * @param  bool   $userSide | 
            
                                                                                                            
                            
            
                                    
            
            
                | 465 |  |  |      * @return string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 466 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 467 |  | View Code Duplication |     public function getEditItemLink($smartObj, $onlyUrl = false, $withimage = true, $userSide = false) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 468 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 469 |  |  |         $admin_side = $userSide ? '' : 'admin/'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 470 |  |  |         $ret        = $this->handler->_moduleUrl . $admin_side . $this->handler->_page . '?op=mod&' . $this->handler->keyName . '=' . $smartObj->getVar($this->handler->keyName); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 471 |  |  |         if ($onlyUrl) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 472 |  |  |             return $ret; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 473 |  |  |         } elseif ($withimage) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 474 |  |  |             return "<a href='" . $ret . "'><img src='" . SMARTOBJECT_IMAGES_ACTIONS_URL . "edit.png' style='vertical-align: middle;' alt='" . _CO_SOBJECT_MODIFY . "'  title='" . _CO_SOBJECT_MODIFY . "'></a>"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 475 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 476 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 477 |  |  |         return "<a href='" . $ret . "'>" . $smartObj->getVar($this->handler->identifierName) . '</a>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 478 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 479 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 480 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 481 |  |  |      * @param         $smartObj | 
            
                                                                                                            
                            
            
                                    
            
            
                | 482 |  |  |      * @param  bool   $onlyUrl | 
            
                                                                                                            
                            
            
                                    
            
            
                | 483 |  |  |      * @param  bool   $withimage | 
            
                                                                                                            
                            
            
                                    
            
            
                | 484 |  |  |      * @param  bool   $userSide | 
            
                                                                                                            
                            
            
                                    
            
            
                | 485 |  |  |      * @return string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 486 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 487 |  | View Code Duplication |     public function getDeleteItemLink($smartObj, $onlyUrl = false, $withimage = true, $userSide = false) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 488 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 489 |  |  |         $admin_side = $userSide ? '' : 'admin/'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 490 |  |  |         $ret        = $this->handler->_moduleUrl . $admin_side . $this->handler->_page . '?op=del&' . $this->handler->keyName . '=' . $smartObj->getVar($this->handler->keyName); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 491 |  |  |         if ($onlyUrl) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 492 |  |  |             return $ret; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 493 |  |  |         } elseif ($withimage) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 494 |  |  |             return "<a href='" . $ret . "'><img src='" . SMARTOBJECT_IMAGES_ACTIONS_URL . "editdelete.png' style='vertical-align: middle;' alt='" . _CO_SOBJECT_DELETE . "'  title='" . _CO_SOBJECT_DELETE . "'></a>"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 495 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 496 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 497 |  |  |         return "<a href='" . $ret . "'>" . $smartObj->getVar($this->handler->identifierName) . '</a>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 498 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 499 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 500 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 501 |  |  |      * @param $smartObj | 
            
                                                                                                            
                            
            
                                    
            
            
                | 502 |  |  |      * @return string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 503 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 504 |  |  |     public function getPrintAndMailLink($smartObj) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 505 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 506 |  |  |         global $xoopsConfig; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 507 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 508 |  |  |         $printlink = $this->handler->_moduleUrl . 'print.php?' . $this->handler->keyName . '=' . $smartObj->getVar($this->handler->keyName); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 509 |  |  |         $js        = "javascript:openWithSelfMain('" . $printlink . "', 'smartpopup', 700, 519);"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 510 |  |  |         $printlink = '<a href="' . $js . '"><img  src="' . SMARTOBJECT_IMAGES_ACTIONS_URL . 'fileprint.png" alt="" style="vertical-align: middle;"></a>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 511 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 512 |  |  |         $smartModule = Smartobject\Utility::getModuleInfo($smartObj->handler->_moduleName); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 513 |  |  |         $link        = Smartobject\Utility::getCurrentPage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 514 |  |  |         $mid         = $smartModule->getVar('mid'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 515 |  |  |         $friendlink  = "<a href=\"javascript:openWithSelfMain('" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 516 |  |  |                        . SMARTOBJECT_URL | 
            
                                                                                                            
                            
            
                                    
            
            
                | 517 |  |  |                        . 'sendlink.php?link=' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 518 |  |  |                        . $link | 
            
                                                                                                            
                            
            
                                    
            
            
                | 519 |  |  |                        . '&mid=' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 520 |  |  |                        . $mid | 
            
                                                                                                            
                            
            
                                    
            
            
                | 521 |  |  |                        . "', ',',',',',','sendmessage', 674, 500);\"><img src=\"" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 522 |  |  |                        . SMARTOBJECT_IMAGES_ACTIONS_URL | 
            
                                                                                                            
                            
            
                                    
            
            
                | 523 |  |  |                        . 'mail_send.png"  alt="' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 524 |  |  |                        . _CO_SOBJECT_EMAIL | 
            
                                                                                                            
                            
            
                                    
            
            
                | 525 |  |  |                        . '" title="' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 526 |  |  |                        . _CO_SOBJECT_EMAIL | 
            
                                                                                                            
                            
            
                                    
            
            
                | 527 |  |  |                        . '" style="vertical-align: middle;"></a>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 528 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 529 |  |  |         $ret = '<span id="smartobject_print_button">' . $printlink . ' </span>' . '<span id="smartobject_mail_button">' . $friendlink . '</span>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 530 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 531 |  |  |         return $ret; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 532 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 533 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 534 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 535 |  |  |      * @return string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 536 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 537 |  |  |     public function getModuleItemString() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 538 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 539 |  |  |         $ret = $this->handler->_moduleName . '_' . $this->handler->_itemname; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 540 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 541 |  |  |         return $ret; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 542 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 543 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 544 |  |  |  | 
            
                        
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.