Completed
Branch master (2d4977)
by Michael
03:20
created
class/smarthookhandler.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
 	/**
13 13
 	 * Access the only instance of this class
14 14
      *
15
-     * @return	object
15
+     * @return	SmartHookHandler
16 16
      *
17 17
      * @static
18 18
      * @staticvar   object
Please login to merge, or discard this patch.
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,21 +1,21 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if (!defined("XOOPS_ROOT_PATH")) {
3
-    die("XOOPS root path not defined");
3
+	die("XOOPS root path not defined");
4 4
 }
5 5
 
6 6
 class SmartHookHandler {
7 7
 
8
-    function SmartHookHandler() {
8
+	function SmartHookHandler() {
9 9
 
10
-    }
10
+	}
11 11
 
12 12
 	/**
13 13
 	 * Access the only instance of this class
14
-     *
15
-     * @return	object
16
-     *
17
-     * @static
18
-     * @staticvar   object
14
+	 *
15
+	 * @return	object
16
+	 *
17
+	 * @static
18
+	 * @staticvar   object
19 19
 	 */
20 20
 	function &getInstance()
21 21
 	{
@@ -26,8 +26,8 @@  discard block
 block discarded – undo
26 26
 		return $instance;
27 27
 	}
28 28
 
29
-    function executeHook($hook_name) {
30
-    	$lower_hook_name = strtolower($hook_name);
29
+	function executeHook($hook_name) {
30
+		$lower_hook_name = strtolower($hook_name);
31 31
 		$filename = SMARTOBJECT_ROOT_PATH . 'include/custom_code/' . $lower_hook_name . '.php';
32 32
 		if (file_exists($filename)) {
33 33
 			include_once($filename);
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 				$function();
37 37
 			}
38 38
 		}
39
-    }
39
+	}
40 40
 
41 41
 }
42 42
 ?>
43 43
\ No newline at end of file
Please login to merge, or discard this patch.
class/smartmetagen.php 1 patch
Doc Comments   +13 added lines patch added patch discarded remove patch
@@ -156,17 +156,26 @@  discard block
 block discarded – undo
156 156
         $this->_title = $ret;
157 157
     }
158 158
 
159
+    /**
160
+     * @param string|boolean $keywords
161
+     */
159 162
     function setKeywords($keywords)
160 163
     {
161 164
         $this->_keywords = $keywords;
162 165
     }
163 166
 
167
+    /**
168
+     * @param boolean $categoryPath
169
+     */
164 170
     function setCategoryPath($categoryPath)
165 171
     {
166 172
         $categoryPath = $this->html2text($categoryPath);
167 173
         $this->_categoryPath = $categoryPath;
168 174
     }
169 175
 
176
+    /**
177
+     * @param boolean $description
178
+     */
170 179
     function setDescription($description)
171 180
     {
172 181
         if (!$description) {
@@ -217,6 +226,10 @@  discard block
 block discarded – undo
217 226
         return $ret;
218 227
     }
219 228
 
229
+    /**
230
+     * @param string $text
231
+     * @param integer $minChar
232
+     */
220 233
     function findMetaKeywords($text, $minChar)
221 234
     {
222 235
         $keywords = array();
Please login to merge, or discard this patch.
class/smartobject.php 5 patches
Doc Comments   +20 added lines, -4 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	/**
69 69
 	* Checks if the user has a specific access on this object
70 70
 	*
71
-	* @param string $gperm_name name of the permission to test
71
+	* @param string $perm_name name of the permission to test
72 72
 	* @return boolean : TRUE if user has access, false if not
73 73
 	**/
74 74
 	function accessGranted($perm_name) {
@@ -127,6 +127,9 @@  discard block
 block discarded – undo
127 127
         'readonly' => false));
128 128
     }
129 129
 
130
+    /**
131
+     * @param string $key
132
+     */
130 133
     function initNonPersistableVar($key, $data_type, $itemName=false, $form_caption='', $sortby=false, $value='', $displayOnForm=false, $required=false) {
131 134
 		$this->initVar($key, $data_type, $value, $required, null, '', false, $form_caption, '', $sortby, false, $displayOnForm);
132 135
 		$this->vars[$key]['itemName'] = $itemName;
@@ -145,13 +148,16 @@  discard block
 block discarded – undo
145 148
     * @param bool $required set to TRUE if this variable needs to have a value set before storing the object in the table
146 149
     * @param string $form_caption caption of this variable in a {@link SmartobjectForm} and title of a column in a  {@link SmartObjectTable}
147 150
     * @param string $form_dsc description of this variable in a {@link SmartobjectForm}
148
-    * @param mixed $value default value of this variable
151
+    * @param string|false $value default value of this variable
149 152
     */
150 153
 	function quickInitVar($key, $data_type, $required=false, $form_caption='', $form_dsc='', $value = null) {
151 154
 		$maxlength = $data_type == 'XOBJ_DTYPE_TXTBOX' ? 255 : null;
152 155
 		$this->initVar($key, $data_type, $value, $required, $maxlength, '', false, $form_caption, $form_dsc, false, true, true);
153 156
 	}
154 157
 
158
+    /**
159
+     * @param string $varname
160
+     */
155 161
     function initCommonVar($varname, $displayOnForm=true, $default='notdefined') {
156 162
 
157 163
     	switch ($varname) {
@@ -393,8 +399,8 @@  discard block
 block discarded – undo
393 399
     /**
394 400
      * add an error
395 401
      *
396
-     * @param string $value error to add
397 402
      * @access public
403
+     * @param string $err_str
398 404
      */
399 405
     function setErrors($err_str, $prefix=false)
400 406
     {
@@ -585,10 +591,17 @@  discard block
 block discarded – undo
585 591
 		$this->vars[$key]['data_type'] = $newType;
586 592
 	}
587 593
 
594
+	/**
595
+	 * @param string $info
596
+	 * @param boolean $value
597
+	 */
588 598
 	function setVarInfo($key, $info, $value) {
589 599
 		$this->vars[$key][$info] = $value;
590 600
 	}
591 601
 
602
+	/**
603
+	 * @param string $key
604
+	 */
592 605
 	function getValueFor($key, $editor=true) {
593 606
     	global $xoopsModuleConfig;
594 607
 
@@ -759,7 +772,7 @@  discard block
 block discarded – undo
759 772
     * @access public
760 773
     * @param string $key key of the object's variable to be returned
761 774
     * @param string $format format to use for the output
762
-    * @return mixed formatted value of the variable
775
+    * @return string formatted value of the variable
763 776
     */
764 777
     function getVar($key, $format = 's')
765 778
     {
@@ -1035,6 +1048,9 @@  discard block
 block discarded – undo
1035 1048
 		}
1036 1049
 	}
1037 1050
 
1051
+	/**
1052
+	 * @param string $key
1053
+	 */
1038 1054
 	function hideFieldFromForm($key) {
1039 1055
 		if (is_array($key)) {
1040 1056
 			foreach($key as $v) {
Please login to merge, or discard this patch.
Indentation   +791 added lines, -793 removed lines patch added patch discarded remove patch
@@ -5,16 +5,14 @@  discard block
 block discarded – undo
5 5
  *
6 6
  * @license GNU
7 7
  * @author marcan <[email protected]>
8
-
9 8
  * @version $Id: smartobject.php 1409 2008-04-02 20:48:27Z malanciault $
10
-
11 9
  * @link http://smartfactory.ca The SmartFactory
12 10
  * @package SmartObject
13 11
  * @subpackage SmartObjectCore
14 12
  */
15 13
 
16 14
 if (!defined("XOOPS_ROOT_PATH")) {
17
-    die("XOOPS root path not defined");
15
+	die("XOOPS root path not defined");
18 16
 }
19 17
 
20 18
 include_once XOOPS_ROOT_PATH . "/modules/smartobject/include/common.php";
@@ -42,35 +40,35 @@  discard block
 block discarded – undo
42 40
  */
43 41
 class SmartObject extends XoopsObject {
44 42
 
45
-    var $_image_path;
46
-    var $_image_url;
43
+	var $_image_path;
44
+	var $_image_url;
47 45
 
48
-    var $seoEnabled = false;
49
-    var $titleField;
50
-    var $summaryField=false;
46
+	var $seoEnabled = false;
47
+	var $titleField;
48
+	var $summaryField=false;
51 49
 
52
-    /**
50
+	/**
53 51
 	 * Reference to the handler managing this object
54 52
 	 *
55 53
 	 * @var object reference to {@link SmartPersistableObjectHandler}
56 54
 	 */
57
-    var $handler;
55
+	var $handler;
58 56
 
59
-    /**
57
+	/**
60 58
 	 * References to control objects, managing the form fields of this object
61 59
 	 */
62
-    var $controls = array();
60
+	var $controls = array();
63 61
 
64
-    function SmartObject(&$handler) {
65
-    	$this->handler = $handler;
66
-    }
62
+	function SmartObject(&$handler) {
63
+		$this->handler = $handler;
64
+	}
67 65
 
68 66
 	/**
69
-	* Checks if the user has a specific access on this object
70
-	*
71
-	* @param string $gperm_name name of the permission to test
72
-	* @return boolean : TRUE if user has access, false if not
73
-	**/
67
+	 * Checks if the user has a specific access on this object
68
+	 *
69
+	 * @param string $gperm_name name of the permission to test
70
+	 * @return boolean : TRUE if user has access, false if not
71
+	 **/
74 72
 	function accessGranted($perm_name) {
75 73
 		$smartpermissions_handler = new SmartobjectPermissionHandler($this->handler);
76 74
 		return $smartpermissions_handler->accessGranted($perm_name, $this->id());
@@ -83,295 +81,295 @@  discard block
 block discarded – undo
83 81
 		$this->initVar('close_section_' . $section_name, XOBJ_DTYPE_FORM_SECTION_CLOSE, '', false, null, '', false, '', '', false, false, true);
84 82
 	}
85 83
 
86
-    /**
87
-    *
88
-    * @param string $key key of this field. This needs to be the name of the field in the related database table
89
-    * @param int $data_type  set to one of XOBJ_DTYPE_XXX constants (set to XOBJ_DTYPE_OTHER if no data type ckecking nor text sanitizing is required)
90
-    * @param mixed $value default value of this variable
91
-    * @param bool $required set to TRUE if this variable needs to have a value set before storing the object in the table
92
-    * @param int $maxlength maximum length of this variable, for XOBJ_DTYPE_TXTBOX type only
93
-    * @param string $options does this data have any select options?
94
-    * @param bool $multilingual is this field needs to support multilingual features (NOT YET IMPLEMENTED...)
95
-    * @param string $form_caption caption of this variable in a {@link SmartobjectForm} and title of a column in a  {@link SmartObjectTable}
96
-    * @param string $form_dsc description of this variable in a {@link SmartobjectForm}
97
-    * @param bool $sortby set to TRUE to make this field used to sort objects in SmartObjectTable
98
-    * @param bool $persistent set to FALSE if this field is not to be saved in the database
99
-    */
100
-    function initVar($key, $data_type, $value = null, $required = false, $maxlength = null, $options = '', $multilingual=false, $form_caption='', $form_dsc='', $sortby=false, $persistent=true, $displayOnForm=true) {
101
-        //url_ is reserved for files.
102
-        if (substr($key, 0,4) == 'url_' ) {
103
-	        trigger_error("Cannot use variable starting with 'url_'.");
104
-	    }
105
-        parent::initVar($key, $data_type, $value, $required, $maxlength, $options);
106
-        if ($this->handler && (!$form_caption || $form_caption == '')) {
107
-        	$dyn_form_caption = strtoupper('_CO_' . $this->handler->_moduleName . '_' . $this->handler->_itemname . '_' . $key);
108
-        	if (defined($dyn_form_caption)) {
84
+	/**
85
+	 *
86
+	 * @param string $key key of this field. This needs to be the name of the field in the related database table
87
+	 * @param int $data_type  set to one of XOBJ_DTYPE_XXX constants (set to XOBJ_DTYPE_OTHER if no data type ckecking nor text sanitizing is required)
88
+	 * @param mixed $value default value of this variable
89
+	 * @param bool $required set to TRUE if this variable needs to have a value set before storing the object in the table
90
+	 * @param int $maxlength maximum length of this variable, for XOBJ_DTYPE_TXTBOX type only
91
+	 * @param string $options does this data have any select options?
92
+	 * @param bool $multilingual is this field needs to support multilingual features (NOT YET IMPLEMENTED...)
93
+	 * @param string $form_caption caption of this variable in a {@link SmartobjectForm} and title of a column in a  {@link SmartObjectTable}
94
+	 * @param string $form_dsc description of this variable in a {@link SmartobjectForm}
95
+	 * @param bool $sortby set to TRUE to make this field used to sort objects in SmartObjectTable
96
+	 * @param bool $persistent set to FALSE if this field is not to be saved in the database
97
+	 */
98
+	function initVar($key, $data_type, $value = null, $required = false, $maxlength = null, $options = '', $multilingual=false, $form_caption='', $form_dsc='', $sortby=false, $persistent=true, $displayOnForm=true) {
99
+		//url_ is reserved for files.
100
+		if (substr($key, 0,4) == 'url_' ) {
101
+			trigger_error("Cannot use variable starting with 'url_'.");
102
+		}
103
+		parent::initVar($key, $data_type, $value, $required, $maxlength, $options);
104
+		if ($this->handler && (!$form_caption || $form_caption == '')) {
105
+			$dyn_form_caption = strtoupper('_CO_' . $this->handler->_moduleName . '_' . $this->handler->_itemname . '_' . $key);
106
+			if (defined($dyn_form_caption)) {
109 107
 				$form_caption = constant($dyn_form_caption);
110
-        	}
111
-        }
112
-        if ($this->handler && (!$form_dsc || $form_dsc == '')) {
113
-        	$dyn_form_dsc = strtoupper('_CO_' . $this->handler->_moduleName . '_' . $this->handler->_itemname . '_' . $key . '_DSC');
114
-        	if (defined($dyn_form_dsc)) {
108
+			}
109
+		}
110
+		if ($this->handler && (!$form_dsc || $form_dsc == '')) {
111
+			$dyn_form_dsc = strtoupper('_CO_' . $this->handler->_moduleName . '_' . $this->handler->_itemname . '_' . $key . '_DSC');
112
+			if (defined($dyn_form_dsc)) {
115 113
 				$form_dsc = constant($dyn_form_dsc);
116
-        	}
117
-        }
114
+			}
115
+		}
118 116
 
119 117
 
120
-        $this->vars[$key] = array_merge($this->vars[$key], array('multilingual' => $multilingual,
121
-        'form_caption' => $form_caption,
122
-        'form_dsc' => $form_dsc,
123
-        'sortby' => $sortby,
124
-        'persistent' => $persistent,
125
-        'displayOnForm' => $displayOnForm,
126
-        'displayOnSingleView' => true,
127
-        'readonly' => false));
128
-    }
118
+		$this->vars[$key] = array_merge($this->vars[$key], array('multilingual' => $multilingual,
119
+		'form_caption' => $form_caption,
120
+		'form_dsc' => $form_dsc,
121
+		'sortby' => $sortby,
122
+		'persistent' => $persistent,
123
+		'displayOnForm' => $displayOnForm,
124
+		'displayOnSingleView' => true,
125
+		'readonly' => false));
126
+	}
129 127
 
130
-    function initNonPersistableVar($key, $data_type, $itemName=false, $form_caption='', $sortby=false, $value='', $displayOnForm=false, $required=false) {
128
+	function initNonPersistableVar($key, $data_type, $itemName=false, $form_caption='', $sortby=false, $value='', $displayOnForm=false, $required=false) {
131 129
 		$this->initVar($key, $data_type, $value, $required, null, '', false, $form_caption, '', $sortby, false, $displayOnForm);
132 130
 		$this->vars[$key]['itemName'] = $itemName;
133
-    }
131
+	}
134 132
 
135 133
 	/**
136
-	* Quickly initiate a var
137
-	*
138
-	* Since many vars do have the same config, let's use this method with some of these configuration as a convention ;-)
139
-	*
140
-	* - $maxlength = 0 unless $data_type is a TEXTBOX, then $maxlength will be 255
141
-	* - all other vars are NULL or '' depending of the parameter
142
-	*
143
-    * @param string $key key of this field. This needs to be the name of the field in the related database table
144
-    * @param int $data_type  set to one of XOBJ_DTYPE_XXX constants (set to XOBJ_DTYPE_OTHER if no data type ckecking nor text sanitizing is required)
145
-    * @param bool $required set to TRUE if this variable needs to have a value set before storing the object in the table
146
-    * @param string $form_caption caption of this variable in a {@link SmartobjectForm} and title of a column in a  {@link SmartObjectTable}
147
-    * @param string $form_dsc description of this variable in a {@link SmartobjectForm}
148
-    * @param mixed $value default value of this variable
149
-    */
134
+	 * Quickly initiate a var
135
+	 *
136
+	 * Since many vars do have the same config, let's use this method with some of these configuration as a convention ;-)
137
+	 *
138
+	 * - $maxlength = 0 unless $data_type is a TEXTBOX, then $maxlength will be 255
139
+	 * - all other vars are NULL or '' depending of the parameter
140
+	 *
141
+	 * @param string $key key of this field. This needs to be the name of the field in the related database table
142
+	 * @param int $data_type  set to one of XOBJ_DTYPE_XXX constants (set to XOBJ_DTYPE_OTHER if no data type ckecking nor text sanitizing is required)
143
+	 * @param bool $required set to TRUE if this variable needs to have a value set before storing the object in the table
144
+	 * @param string $form_caption caption of this variable in a {@link SmartobjectForm} and title of a column in a  {@link SmartObjectTable}
145
+	 * @param string $form_dsc description of this variable in a {@link SmartobjectForm}
146
+	 * @param mixed $value default value of this variable
147
+	 */
150 148
 	function quickInitVar($key, $data_type, $required=false, $form_caption='', $form_dsc='', $value = null) {
151 149
 		$maxlength = $data_type == 'XOBJ_DTYPE_TXTBOX' ? 255 : null;
152 150
 		$this->initVar($key, $data_type, $value, $required, $maxlength, '', false, $form_caption, $form_dsc, false, true, true);
153 151
 	}
154 152
 
155
-    function initCommonVar($varname, $displayOnForm=true, $default='notdefined') {
156
-
157
-    	switch ($varname) {
158
-            case "dohtml":
159
-            	$value = $default != 'notdefined' ? $default : true;
160
-                $this->initVar($varname, XOBJ_DTYPE_INT, $value, false, null, "", false, _CO_SOBJECT_DOHTML_FORM_CAPTION, '', false, true, $displayOnForm);
161
-                $this->setControl($varname, "yesno");
162
-                break;
163
-
164
-            case "dobr":
165
-            	$value = ($default === 'notdefined') ? true : $default;
166
-                $this->initVar($varname, XOBJ_DTYPE_INT,$value, false, null, "", false, _CO_SOBJECT_DOBR_FORM_CAPTION, '', false, true, $displayOnForm);
167
-                $this->setControl($varname, "yesno");
168
-                break;
169
-
170
-            case "doimage":
171
-            	$value = $default != 'notdefined' ? $default : true;
172
-                $this->initVar($varname, XOBJ_DTYPE_INT,$value, false, null, "", false, _CO_SOBJECT_DOIMAGE_FORM_CAPTION, '', false, true, $displayOnForm);
173
-                $this->setControl($varname, "yesno");
174
-                break;
175
-
176
-            case "dosmiley":
177
-            	$value = $default != 'notdefined' ? $default : true;
178
-                $this->initVar($varname, XOBJ_DTYPE_INT,$value, false, null, "", false, _CO_SOBJECT_DOSMILEY_FORM_CAPTION, '', false, true, $displayOnForm);
179
-                $this->setControl($varname, "yesno");
180
-                break;
181
-
182
-            case "doxcode":
183
-            	$value = $default != 'notdefined' ? $default : true;
184
-                $this->initVar($varname, XOBJ_DTYPE_INT,$value, false, null, "", false, _CO_SOBJECT_DOXCODE_FORM_CAPTION, '', false, true, $displayOnForm);
185
-                $this->setControl($varname, "yesno");
186
-                break;
187
-
188
-            case "meta_keywords":
189
-            	$value = $default != 'notdefined' ? $default : '';
190
-                $this->initVar($varname, XOBJ_DTYPE_TXTAREA, $value, false, null, '', false, _CO_SOBJECT_META_KEYWORDS, _CO_SOBJECT_META_KEYWORDS_DSC, false, true, $displayOnForm);
191
-        		$this->setControl('meta_keywords', array(
153
+	function initCommonVar($varname, $displayOnForm=true, $default='notdefined') {
154
+
155
+		switch ($varname) {
156
+			case "dohtml":
157
+				$value = $default != 'notdefined' ? $default : true;
158
+				$this->initVar($varname, XOBJ_DTYPE_INT, $value, false, null, "", false, _CO_SOBJECT_DOHTML_FORM_CAPTION, '', false, true, $displayOnForm);
159
+				$this->setControl($varname, "yesno");
160
+				break;
161
+
162
+			case "dobr":
163
+				$value = ($default === 'notdefined') ? true : $default;
164
+				$this->initVar($varname, XOBJ_DTYPE_INT,$value, false, null, "", false, _CO_SOBJECT_DOBR_FORM_CAPTION, '', false, true, $displayOnForm);
165
+				$this->setControl($varname, "yesno");
166
+				break;
167
+
168
+			case "doimage":
169
+				$value = $default != 'notdefined' ? $default : true;
170
+				$this->initVar($varname, XOBJ_DTYPE_INT,$value, false, null, "", false, _CO_SOBJECT_DOIMAGE_FORM_CAPTION, '', false, true, $displayOnForm);
171
+				$this->setControl($varname, "yesno");
172
+				break;
173
+
174
+			case "dosmiley":
175
+				$value = $default != 'notdefined' ? $default : true;
176
+				$this->initVar($varname, XOBJ_DTYPE_INT,$value, false, null, "", false, _CO_SOBJECT_DOSMILEY_FORM_CAPTION, '', false, true, $displayOnForm);
177
+				$this->setControl($varname, "yesno");
178
+				break;
179
+
180
+			case "doxcode":
181
+				$value = $default != 'notdefined' ? $default : true;
182
+				$this->initVar($varname, XOBJ_DTYPE_INT,$value, false, null, "", false, _CO_SOBJECT_DOXCODE_FORM_CAPTION, '', false, true, $displayOnForm);
183
+				$this->setControl($varname, "yesno");
184
+				break;
185
+
186
+			case "meta_keywords":
187
+				$value = $default != 'notdefined' ? $default : '';
188
+				$this->initVar($varname, XOBJ_DTYPE_TXTAREA, $value, false, null, '', false, _CO_SOBJECT_META_KEYWORDS, _CO_SOBJECT_META_KEYWORDS_DSC, false, true, $displayOnForm);
189
+				$this->setControl('meta_keywords', array(
192 190
 										'name' => 'textarea',
193
-                                        'form_editor'=>'textarea'
194
-                                        ));
195
-                break;
196
-
197
-            case "meta_description":
198
-            	$value = $default != 'notdefined' ? $default : '';
199
-                $this->initVar($varname, XOBJ_DTYPE_TXTAREA, $value, false, null, '', false, _CO_SOBJECT_META_DESCRIPTION, _CO_SOBJECT_META_DESCRIPTION_DSC, false, true, $displayOnForm);
200
-        		$this->setControl('meta_description', array(
191
+										'form_editor'=>'textarea'
192
+										));
193
+				break;
194
+
195
+			case "meta_description":
196
+				$value = $default != 'notdefined' ? $default : '';
197
+				$this->initVar($varname, XOBJ_DTYPE_TXTAREA, $value, false, null, '', false, _CO_SOBJECT_META_DESCRIPTION, _CO_SOBJECT_META_DESCRIPTION_DSC, false, true, $displayOnForm);
198
+				$this->setControl('meta_description', array(
201 199
 										'name' => 'textarea',
202
-                                        'form_editor'=>'textarea'
203
-                                        ));
204
-                break;
205
-
206
-            case "short_url":
207
-            	$value = $default != 'notdefined' ? $default : '';
208
-                $this->initVar($varname, XOBJ_DTYPE_TXTBOX,$value, false, null, "", false, _CO_SOBJECT_SHORT_URL, _CO_SOBJECT_SHORT_URL_DSC, false, true, $displayOnForm);
209
-                break;
210
-
211
-            case "hierarchy_path":
212
-            	$value = $default != 'notdefined' ? $default : '';
213
-                $this->initVar($varname, XOBJ_DTYPE_ARRAY, $value, false, null, "", false, _CO_SOBJECT_HIERARCHY_PATH, _CO_SOBJECT_HIERARCHY_PATH_DSC, false, true, $displayOnForm);
214
-                break;
215
-
216
-            case "counter":
217
-            	$value = $default != 'notdefined' ? $default : 0;
218
-                $this->initVar($varname, XOBJ_DTYPE_INT,$value, false, null, '', false, _CO_SOBJECT_COUNTER_FORM_CAPTION, '', false, true, $displayOnForm);
219
-                break;
220
-
221
-            case "weight":
222
-            	$value = $default != 'notdefined' ? $default : 0;
223
-                $this->initVar($varname, XOBJ_DTYPE_INT,$value, false, null, '', false, _CO_SOBJECT_WEIGHT_FORM_CAPTION, '', true, true, $displayOnForm);
224
-                break;
225
-            case "custom_css":
226
-            	$value = $default != 'notdefined' ? $default : '';
227
-                $this->initVar($varname, XOBJ_DTYPE_TXTAREA, $value, false, null, '', false, _CO_SOBJECT_CUSTOM_CSS, _CO_SOBJECT_CUSTOM_CSS_DSC, false, true, $displayOnForm);
228
-        		$this->setControl('custom_css', array(
200
+										'form_editor'=>'textarea'
201
+										));
202
+				break;
203
+
204
+			case "short_url":
205
+				$value = $default != 'notdefined' ? $default : '';
206
+				$this->initVar($varname, XOBJ_DTYPE_TXTBOX,$value, false, null, "", false, _CO_SOBJECT_SHORT_URL, _CO_SOBJECT_SHORT_URL_DSC, false, true, $displayOnForm);
207
+				break;
208
+
209
+			case "hierarchy_path":
210
+				$value = $default != 'notdefined' ? $default : '';
211
+				$this->initVar($varname, XOBJ_DTYPE_ARRAY, $value, false, null, "", false, _CO_SOBJECT_HIERARCHY_PATH, _CO_SOBJECT_HIERARCHY_PATH_DSC, false, true, $displayOnForm);
212
+				break;
213
+
214
+			case "counter":
215
+				$value = $default != 'notdefined' ? $default : 0;
216
+				$this->initVar($varname, XOBJ_DTYPE_INT,$value, false, null, '', false, _CO_SOBJECT_COUNTER_FORM_CAPTION, '', false, true, $displayOnForm);
217
+				break;
218
+
219
+			case "weight":
220
+				$value = $default != 'notdefined' ? $default : 0;
221
+				$this->initVar($varname, XOBJ_DTYPE_INT,$value, false, null, '', false, _CO_SOBJECT_WEIGHT_FORM_CAPTION, '', true, true, $displayOnForm);
222
+				break;
223
+			case "custom_css":
224
+				$value = $default != 'notdefined' ? $default : '';
225
+				$this->initVar($varname, XOBJ_DTYPE_TXTAREA, $value, false, null, '', false, _CO_SOBJECT_CUSTOM_CSS, _CO_SOBJECT_CUSTOM_CSS_DSC, false, true, $displayOnForm);
226
+				$this->setControl('custom_css', array(
229 227
 									'name' => 'textarea',
230 228
 									'form_editor'=>'textarea',
231 229
 									));
232
-                break;
233
-        }
230
+				break;
231
+		}
234 232
 		$this->hideFieldFromSingleView($varname);
235
-    }
236
-
237
-    /**
238
-     * Set control information for an instance variable
239
-     *
240
-     * The $options parameter can be a string or an array. Using a string
241
-     * is the quickest way :
242
-     *
243
-     * $this->setControl('date', 'date_time');
244
-     *
245
-     * This will create a date and time selectbox for the 'date' var on the
246
-     * form to edit or create this item.
247
-     *
248
-     * Here are the currently supported controls :
233
+	}
234
+
235
+	/**
236
+	 * Set control information for an instance variable
237
+	 *
238
+	 * The $options parameter can be a string or an array. Using a string
239
+	 * is the quickest way :
240
+	 *
241
+	 * $this->setControl('date', 'date_time');
242
+	 *
243
+	 * This will create a date and time selectbox for the 'date' var on the
244
+	 * form to edit or create this item.
245
+	 *
246
+	 * Here are the currently supported controls :
247
+	 *
248
+	 * 		- color
249
+	 * 		- country
250
+	 * 		- date_time
251
+	 * 		- date
252
+	 * 		- email
253
+	 * 		- group
254
+	 * 		- group_multi
255
+	 * 		- image
256
+	 * 		- imageupload
257
+	 * 		- label
258
+	 * 		- language
259
+	 * 		- parentcategory
260
+	 * 		- password
261
+	 * 		- select_multi
262
+	 * 		- select
263
+	 * 		- text
264
+	 * 		- textarea
265
+	 * 		- theme
266
+	 * 		- theme_multi
267
+	 * 		- timezone
268
+	 * 		- user
269
+	 * 		- user_multi
270
+	 * 		- yesno
271
+	 *
272
+	 * Now, using an array as $options, you can customize what information to
273
+	 * use in the control. For example, if one needs to display a select box for
274
+	 * the user to choose the status of an item. We only need to tell SmartObject
275
+	 * what method to execute within what handler to retreive the options of the
276
+	 * selectbox.
277
+	 *
278
+	 * $this->setControl('status', array('name' => false,
279
+	 * 	                                 'itemHandler' => 'item',
280
+	 *                                   'method' => 'getStatus',
281
+	 *                                   'module' => 'smartshop'));
282
+	 *
283
+	 * In this example, the array elements are the following :
284
+	 * 		- name : false, as we don't need to set a special control here.
285
+	 * 				 we will use the default control related to the object type (defined in initVar)
286
+	 * 		- itemHandler : name of the object for which we will use the handler
287
+	 * 		- method : name of the method of this handler that we will execute
288
+	 * 		- module : name of the module from wich the handler is
289
+	 *
290
+	 * So in this example, SmartObject will create a selectbox for the variable 'status' and it will
291
+	 * populate this selectbox with the result from SmartshopItemHandler::getStatus()
292
+	 *
293
+	 * Another example of the use of $options as an array is for TextArea :
294
+	 *
295
+	 * $this->setControl('body', array('name' => 'textarea',
296
+	 *                                   'form_editor' => 'default'));
297
+	 *
298
+	 * In this example, SmartObject will create a TextArea for the variable 'body'. And it will use
299
+	 * the 'default' editor, providing it is defined in the module
300
+	 * preferences : $xoopsModuleConfig['default_editor']
301
+	 *
302
+	 * Of course, you can force the use of a specific editor :
303
+	 *
304
+	 * $this->setControl('body', array('name' => 'textarea',
305
+	 *                                   'form_editor' => 'koivi'));
306
+	 *
307
+	 * Here is a list of supported editor :
308
+	 * 		- tiny : TinyEditor
309
+	 * 		- dhtmltextarea : XOOPS DHTML Area
310
+	 * 		- fckeditor	: FCKEditor
311
+	 * 		- inbetween : InBetween
312
+	 * 		- koivi : Koivi
313
+	 * 		- spaw : Spaw WYSIWYG Editor
314
+	 * 		- htmlarea : HTMLArea
315
+	 * 		- textarea : basic textarea with no options
316
+	 *
317
+	 * @param string $var name of the variable for which we want to set a control
318
+	 * @param array $options
319
+	 */
320
+	function setControl($var, $options=array()) {
321
+		if (isset($this->controls[$var])) {
322
+			unset($this->controls[$var]);
323
+		}
324
+		if (is_string($options)) {
325
+			$options = array('name' => $options);
326
+		}
327
+		$this->controls[$var] = $options;
328
+	}
329
+
330
+	/**
331
+	 * Get control information for an instance variable
249 332
 	 *
250
-     * 		- color
251
-     * 		- country
252
-     * 		- date_time
253
-     * 		- date
254
-     * 		- email
255
-     * 		- group
256
-     * 		- group_multi
257
-     * 		- image
258
-     * 		- imageupload
259
-     * 		- label
260
-     * 		- language
261
-     * 		- parentcategory
262
-     * 		- password
263
-     * 		- select_multi
264
-     * 		- select
265
-     * 		- text
266
-     * 		- textarea
267
-     * 		- theme
268
-     * 		- theme_multi
269
-     * 		- timezone
270
-     * 		- user
271
-     * 		- user_multi
272
-     * 		- yesno
273
-     *
274
-     * Now, using an array as $options, you can customize what information to
275
-     * use in the control. For example, if one needs to display a select box for
276
-     * the user to choose the status of an item. We only need to tell SmartObject
277
-     * what method to execute within what handler to retreive the options of the
278
-     * selectbox.
279
-     *
280
-     * $this->setControl('status', array('name' => false,
281
-     * 	                                 'itemHandler' => 'item',
282
-     *                                   'method' => 'getStatus',
283
-     *                                   'module' => 'smartshop'));
284
-     *
285
-     * In this example, the array elements are the following :
286
-     * 		- name : false, as we don't need to set a special control here.
287
-     * 				 we will use the default control related to the object type (defined in initVar)
288
-     * 		- itemHandler : name of the object for which we will use the handler
289
-     * 		- method : name of the method of this handler that we will execute
290
-     * 		- module : name of the module from wich the handler is
291
-     *
292
-     * So in this example, SmartObject will create a selectbox for the variable 'status' and it will
293
-     * populate this selectbox with the result from SmartshopItemHandler::getStatus()
294
-     *
295
-     * Another example of the use of $options as an array is for TextArea :
296
-     *
297
-     * $this->setControl('body', array('name' => 'textarea',
298
-     *                                   'form_editor' => 'default'));
299
-     *
300
-     * In this example, SmartObject will create a TextArea for the variable 'body'. And it will use
301
-     * the 'default' editor, providing it is defined in the module
302
-     * preferences : $xoopsModuleConfig['default_editor']
303
-     *
304
-     * Of course, you can force the use of a specific editor :
305
-     *
306
-     * $this->setControl('body', array('name' => 'textarea',
307
-     *                                   'form_editor' => 'koivi'));
308
-     *
309
-     * Here is a list of supported editor :
310
-     * 		- tiny : TinyEditor
311
-     * 		- dhtmltextarea : XOOPS DHTML Area
312
-     * 		- fckeditor	: FCKEditor
313
-     * 		- inbetween : InBetween
314
-     * 		- koivi : Koivi
315
-     * 		- spaw : Spaw WYSIWYG Editor
316
-     * 		- htmlarea : HTMLArea
317
-     * 		- textarea : basic textarea with no options
318
-     *
319
-     * @param string $var name of the variable for which we want to set a control
320
-     * @param array $options
321
-     */
322
-    function setControl($var, $options=array()) {
323
-        if (isset($this->controls[$var])) {
324
-        	unset($this->controls[$var]);
325
-        }
326
-        if (is_string($options)) {
327
-            $options = array('name' => $options);
328
-        }
329
-        $this->controls[$var] = $options;
330
-    }
331
-
332
-    /**
333
-     * Get control information for an instance variable
334
-     *
335
-     * @param string $var
336
-     */
337
-    function getControl($var) {
338
-        return isset($this->controls[$var]) ? $this->controls[$var] : false;
339
-    }
340
-
341
-    /**
342
-    * Create the form for this object
343
-    *
344
-    * @return a {@link SmartobjectForm} object for this object
345
-    *
346
-    * @see SmartObjectForm::SmartObjectForm()
347
-    */
348
-    function getForm($form_caption, $form_name, $form_action=false, $submit_button_caption = _CO_SOBJECT_SUBMIT, $cancel_js_action=false, $captcha=false)
349
-    {
350
-        include_once SMARTOBJECT_ROOT_PATH . "class/form/smartobjectform.php";
351
-        $form = new SmartobjectForm($this, $form_name, $form_caption, $form_action, null, $submit_button_caption, $cancel_js_action, $captcha);
352
-
353
-        return $form;
354
-    }
355
-
356
-    function toArray()
357
-    {
358
-        $ret = array();
359
-        $vars = $this->getVars();
360
-        foreach ($vars as $key=>$var) {
361
-            $value = $this->getVar($key);
362
-            $ret[$key] = $value;
363
-        }
364
-        if ($this->handler->identifierName != "") {
365
-        	$controller = new SmartObjectController($this->handler);
366
-        	/**
367
-	    	 * Addition of some automatic value
368
-	    	 */
369
-        	$ret['itemLink'] = $controller->getItemLink($this);
370
-        	$ret['itemUrl'] = $controller->getItemLink($this, true);
371
-        	$ret['editItemLink'] = $controller->getEditItemLink($this, false, true);
372
-        	$ret['deleteItemLink'] = $controller->getDeleteItemLink($this, false, true);
373
-        	$ret['printAndMailLink'] = $controller->getPrintAndMailLink($this);
374
-        }
333
+	 * @param string $var
334
+	 */
335
+	function getControl($var) {
336
+		return isset($this->controls[$var]) ? $this->controls[$var] : false;
337
+	}
338
+
339
+	/**
340
+	 * Create the form for this object
341
+	 *
342
+	 * @return a {@link SmartobjectForm} object for this object
343
+	 *
344
+	 * @see SmartObjectForm::SmartObjectForm()
345
+	 */
346
+	function getForm($form_caption, $form_name, $form_action=false, $submit_button_caption = _CO_SOBJECT_SUBMIT, $cancel_js_action=false, $captcha=false)
347
+	{
348
+		include_once SMARTOBJECT_ROOT_PATH . "class/form/smartobjectform.php";
349
+		$form = new SmartobjectForm($this, $form_name, $form_caption, $form_action, null, $submit_button_caption, $cancel_js_action, $captcha);
350
+
351
+		return $form;
352
+	}
353
+
354
+	function toArray()
355
+	{
356
+		$ret = array();
357
+		$vars = $this->getVars();
358
+		foreach ($vars as $key=>$var) {
359
+			$value = $this->getVar($key);
360
+			$ret[$key] = $value;
361
+		}
362
+		if ($this->handler->identifierName != "") {
363
+			$controller = new SmartObjectController($this->handler);
364
+			/**
365
+			 * Addition of some automatic value
366
+			 */
367
+			$ret['itemLink'] = $controller->getItemLink($this);
368
+			$ret['itemUrl'] = $controller->getItemLink($this, true);
369
+			$ret['editItemLink'] = $controller->getEditItemLink($this, false, true);
370
+			$ret['deleteItemLink'] = $controller->getDeleteItemLink($this, false, true);
371
+			$ret['printAndMailLink'] = $controller->getPrintAndMailLink($this);
372
+		}
375 373
 
376 374
 		// Hightlighting searched words
377 375
 		include_once(SMARTOBJECT_ROOT_PATH . 'class/smarthighlighter.php');
@@ -387,64 +385,64 @@  discard block
 block discarded – undo
387 385
 			}
388 386
 		}
389 387
 
390
-        return $ret;
391
-    }
392
-
393
-    /**
394
-     * add an error
395
-     *
396
-     * @param string $value error to add
397
-     * @access public
398
-     */
399
-    function setErrors($err_str, $prefix=false)
400
-    {
401
-    	if (is_array($err_str)) {
402
-            foreach($err_str as $str) {
403
-                $this->setErrors($str, $prefix);
404
-            }
405
-        } else {
406
-        	if ($prefix) {
407
-        		$err_str = "[" . $prefix . "] " . $err_str;
408
-        	}
409
-            parent::setErrors($err_str);
410
-        }
411
-    }
412
-
413
-    function setFieldAsRequired($field, $required=true) {
414
-    	if (is_array($field)) {
388
+		return $ret;
389
+	}
390
+
391
+	/**
392
+	 * add an error
393
+	 *
394
+	 * @param string $value error to add
395
+	 * @access public
396
+	 */
397
+	function setErrors($err_str, $prefix=false)
398
+	{
399
+		if (is_array($err_str)) {
400
+			foreach($err_str as $str) {
401
+				$this->setErrors($str, $prefix);
402
+			}
403
+		} else {
404
+			if ($prefix) {
405
+				$err_str = "[" . $prefix . "] " . $err_str;
406
+			}
407
+			parent::setErrors($err_str);
408
+		}
409
+	}
410
+
411
+	function setFieldAsRequired($field, $required=true) {
412
+		if (is_array($field)) {
415 413
 			foreach($field as $v) {
416 414
 				$this->doSetFieldAsRequired($v, $required);
417 415
 			}
418
-    	} else {
419
-    		$this->doSetFieldAsRequired($field, $required);
420
-    	}
421
-    }
416
+		} else {
417
+			$this->doSetFieldAsRequired($field, $required);
418
+		}
419
+	}
422 420
 
423
-    function setFieldForSorting($field) {
424
-    	if (is_array($field)) {
421
+	function setFieldForSorting($field) {
422
+		if (is_array($field)) {
425 423
 			foreach($field as $v) {
426 424
 				$this->doSetFieldForSorting($v);
427 425
 			}
428
-    	} else {
429
-    		$this->doSetFieldForSorting($field);
430
-    	}
431
-    }
432
-
433
-    function hasError() {
434
-    	return count($this->_errors) > 0;
435
-    }
436
-
437
-    function setImageDir($url, $path)
438
-    {
439
-        $this->_image_url = $url;
440
-        $this->_image_path = $path;
441
-    }
442
-
443
-    /**
444
-     * Retreive the group that have been granted access to a specific permission for this object
445
-     *
446
-     * @return string $group_perm name of the permission
447
-     */
426
+		} else {
427
+			$this->doSetFieldForSorting($field);
428
+		}
429
+	}
430
+
431
+	function hasError() {
432
+		return count($this->_errors) > 0;
433
+	}
434
+
435
+	function setImageDir($url, $path)
436
+	{
437
+		$this->_image_url = $url;
438
+		$this->_image_path = $path;
439
+	}
440
+
441
+	/**
442
+	 * Retreive the group that have been granted access to a specific permission for this object
443
+	 *
444
+	 * @return string $group_perm name of the permission
445
+	 */
448 446
 	function getGroupPerm($group_perm) {
449 447
 		if (!$this->handler->getPermissions()) {
450 448
 			$this->setError("Trying to access a permission that does not exists for thisobject's handler");
@@ -461,25 +459,25 @@  discard block
 block discarded – undo
461 459
 		}
462 460
 	}
463 461
 
464
-    function getImageDir($path=false)
465
-    {
466
-        if ($path) {
467
-            return $this->_image_path;
468
-        } else {
469
-            return $this->_image_url;
470
-        }
471
-    }
462
+	function getImageDir($path=false)
463
+	{
464
+		if ($path) {
465
+			return $this->_image_path;
466
+		} else {
467
+			return $this->_image_url;
468
+		}
469
+	}
472 470
 
473 471
 	function getUploadDir($path=false)
474
-    {
475
-        if ($path) {
476
-            return $this->_image_path;
477
-        } else {
478
-            return $this->_image_url;
479
-        }
480
-    }
481
-
482
-    function getVarInfo($key = '', $info = '') {
472
+	{
473
+		if ($path) {
474
+			return $this->_image_path;
475
+		} else {
476
+			return $this->_image_url;
477
+		}
478
+	}
479
+
480
+	function getVarInfo($key = '', $info = '') {
483 481
 		if (isset($this->vars[$key][$info])) {
484 482
 			return $this->vars[$key][$info];
485 483
 		}elseif ($info == '' && isset($this->vars[$key])) {
@@ -489,80 +487,80 @@  discard block
 block discarded – undo
489 487
 		}
490 488
 	}
491 489
 
492
-    /**
493
-     * Get the id of the object
494
-     *
495
-     * @return int id of this object
496
-     */
497
-    function id() {
498
-    	return $this->getVar($this->handler->keyName, 'e');
499
-    }
500
-
501
-    /**
502
-     * Return the value of the title field of this object
503
-     *
504
-     * @return string
505
-     */
506
-    function title($format='s')
507
-    {
508
-        return $this->getVar($this->handler->identifierName, $format);
509
-    }
510
-
511
-    /**
512
-     * Return the value of the title field of this object
513
-     *
514
-     * @return string
515
-     */
516
-    function summary()
517
-    {
518
-        if ($this->handler->summaryName) {
519
-            return $this->getVar($this->handler->summaryName);
520
-        } else {
521
-            return false;
522
-        }
523
-    }
524
-
525
-    /**
526
-     * Retreive the object admin side link, displayijng a SingleView page
527
-     *
528
-     * @param bool $onlyUrl wether or not to return a simple URL or a full <a> link
529
-     * @return string user side link to the object
530
-     */
531
-    function getAdminViewItemLink($onlyUrl=false)
532
-    {
533
-    	$controller = new SmartObjectController($this->handler);
534
-    	return $controller->getAdminViewItemLink($this, $onlyUrl);
535
-    }
536
-
537
-    /**
538
-     * Retreive the object user side link
539
-     *
540
-     * @param bool $onlyUrl wether or not to return a simple URL or a full <a> link
541
-     * @return string user side link to the object
542
-     */
543
-    function getItemLink($onlyUrl=false)
544
-    {
545
-    	$controller = new SmartObjectController($this->handler);
546
-    	return $controller->getItemLink($this, $onlyUrl);
547
-    }
548
-
549
-    function getEditItemLink($onlyUrl=false, $withimage=true, $userSide=false)
550
-    {
551
-    	$controller = new SmartObjectController($this->handler);
552
-    	return $controller->getEditItemLink($this, $onlyUrl, $withimage, $userSide);
553
-    }
554
-
555
-    function getDeleteItemLink($onlyUrl=false, $withimage=false, $userSide=false)
556
-    {
557
-    	$controller = new SmartObjectController($this->handler);
558
-    	return $controller->getDeleteItemLink($this, $onlyUrl, $withimage, $userSide);
559
-    }
560
-
561
-    function getPrintAndMailLink()
562
-    {
563
-    	$controller = new SmartObjectController($this->handler);
564
-    	return $controller->getPrintAndMailLink($this);
565
-    }
490
+	/**
491
+	 * Get the id of the object
492
+	 *
493
+	 * @return int id of this object
494
+	 */
495
+	function id() {
496
+		return $this->getVar($this->handler->keyName, 'e');
497
+	}
498
+
499
+	/**
500
+	 * Return the value of the title field of this object
501
+	 *
502
+	 * @return string
503
+	 */
504
+	function title($format='s')
505
+	{
506
+		return $this->getVar($this->handler->identifierName, $format);
507
+	}
508
+
509
+	/**
510
+	 * Return the value of the title field of this object
511
+	 *
512
+	 * @return string
513
+	 */
514
+	function summary()
515
+	{
516
+		if ($this->handler->summaryName) {
517
+			return $this->getVar($this->handler->summaryName);
518
+		} else {
519
+			return false;
520
+		}
521
+	}
522
+
523
+	/**
524
+	 * Retreive the object admin side link, displayijng a SingleView page
525
+	 *
526
+	 * @param bool $onlyUrl wether or not to return a simple URL or a full <a> link
527
+	 * @return string user side link to the object
528
+	 */
529
+	function getAdminViewItemLink($onlyUrl=false)
530
+	{
531
+		$controller = new SmartObjectController($this->handler);
532
+		return $controller->getAdminViewItemLink($this, $onlyUrl);
533
+	}
534
+
535
+	/**
536
+	 * Retreive the object user side link
537
+	 *
538
+	 * @param bool $onlyUrl wether or not to return a simple URL or a full <a> link
539
+	 * @return string user side link to the object
540
+	 */
541
+	function getItemLink($onlyUrl=false)
542
+	{
543
+		$controller = new SmartObjectController($this->handler);
544
+		return $controller->getItemLink($this, $onlyUrl);
545
+	}
546
+
547
+	function getEditItemLink($onlyUrl=false, $withimage=true, $userSide=false)
548
+	{
549
+		$controller = new SmartObjectController($this->handler);
550
+		return $controller->getEditItemLink($this, $onlyUrl, $withimage, $userSide);
551
+	}
552
+
553
+	function getDeleteItemLink($onlyUrl=false, $withimage=false, $userSide=false)
554
+	{
555
+		$controller = new SmartObjectController($this->handler);
556
+		return $controller->getDeleteItemLink($this, $onlyUrl, $withimage, $userSide);
557
+	}
558
+
559
+	function getPrintAndMailLink()
560
+	{
561
+		$controller = new SmartObjectController($this->handler);
562
+		return $controller->getPrintAndMailLink($this);
563
+	}
566 564
 
567 565
 	function getFieldsForSorting($sortsel) {
568 566
 		$ret = array();
@@ -590,12 +588,12 @@  discard block
 block discarded – undo
590 588
 	}
591 589
 
592 590
 	function getValueFor($key, $editor=true) {
593
-    	global $xoopsModuleConfig;
591
+		global $xoopsModuleConfig;
594 592
 
595
-    	$ret = $this->getVar($key, 'n');
596
-    	$myts = MyTextSanitizer::getInstance();
593
+		$ret = $this->getVar($key, 'n');
594
+		$myts = MyTextSanitizer::getInstance();
597 595
 
598
-    	$control = isset($this->controls[$key]) ? $this->controls[$key] : false;
596
+		$control = isset($this->controls[$key]) ? $this->controls[$key] : false;
599 597
 		$form_editor = isset($control['form_editor']) ? $control['form_editor'] : 'textarea';
600 598
 
601 599
 		$html = isset($this->vars['dohtml']) ? $this->getVar('dohtml') : true;
@@ -605,7 +603,7 @@  discard block
 block discarded – undo
605 603
 		$br = isset($this->vars['dobr']) ? $this->getVar('dobr') : true;
606 604
 		$formatML = true;
607 605
 
608
-    	if ($form_editor == 'default') {
606
+		if ($form_editor == 'default') {
609 607
 			global $xoopsModuleConfig;
610 608
 			$form_editor = isset($xoopsModuleConfig['default_editor']) ? $xoopsModuleConfig['default_editor'] : 'textarea';
611 609
 		}
@@ -626,260 +624,260 @@  discard block
 block discarded – undo
626 624
 		}
627 625
 	}
628 626
 
629
-    /**
630
-     * clean values of all variables of the object for storage.
631
-     * also add slashes whereever needed
632
-     *
633
-     * We had to put this method in the SmartObject because the XOBJ_DTYPE_ARRAY does not work properly
634
-     * at least on PHP 5.1. So we have created a new type XOBJ_DTYPE_SIMPLE_ARRAY to handle 1 level array
635
-     * as a string separated by |
636
-     *
637
-     * @return bool true if successful
638
-     * @access public
639
-     */
640
-    function cleanVars()
641
-    {
642
-        $ts =& MyTextSanitizer::getInstance();
643
-        $existing_errors = $this->getErrors();
644
-        $this->_errors = array();
645
-        foreach ($this->vars as $k => $v) {
627
+	/**
628
+	 * clean values of all variables of the object for storage.
629
+	 * also add slashes whereever needed
630
+	 *
631
+	 * We had to put this method in the SmartObject because the XOBJ_DTYPE_ARRAY does not work properly
632
+	 * at least on PHP 5.1. So we have created a new type XOBJ_DTYPE_SIMPLE_ARRAY to handle 1 level array
633
+	 * as a string separated by |
634
+	 *
635
+	 * @return bool true if successful
636
+	 * @access public
637
+	 */
638
+	function cleanVars()
639
+	{
640
+		$ts =& MyTextSanitizer::getInstance();
641
+		$existing_errors = $this->getErrors();
642
+		$this->_errors = array();
643
+		foreach ($this->vars as $k => $v) {
646 644
 			$cleanv = $v['value'];
647
-            if (!$v['changed']) {
648
-            } else {
649
-                $cleanv = is_string($cleanv) ? trim($cleanv) : $cleanv;
650
-                switch ($v['data_type']) {
651
-                case XOBJ_DTYPE_TXTBOX:
652
-                    if ($v['required'] && $cleanv != '0' && $cleanv == '') {
653
-                        $this->setErrors( sprintf( _XOBJ_ERR_REQUIRED, $k ) );
654
-                        continue;
655
-                    }
656
-                    if (isset($v['maxlength']) && strlen($cleanv) > intval($v['maxlength'])) {
657
-                        $this->setErrors( sprintf( _XOBJ_ERR_SHORTERTHAN, $k, intval( $v['maxlength'] ) ) );
658
-                        continue;
659
-                    }
660
-                    if (!$v['not_gpc']) {
661
-                        $cleanv = $ts->stripSlashesGPC($ts->censorString($cleanv));
662
-                    } else {
663
-                        $cleanv = $ts->censorString($cleanv);
664
-                    }
665
-                    break;
666
-                case XOBJ_DTYPE_TXTAREA:
667
-                    if ($v['required'] && $cleanv != '0' && $cleanv == '') {
668
-                        $this->setErrors( sprintf( _XOBJ_ERR_REQUIRED, $k ) );
669
-                        continue;
670
-                    }
671
-                    if (!$v['not_gpc']) {
672
-                        $cleanv = $ts->stripSlashesGPC($ts->censorString($cleanv));
673
-                    } else {
674
-                        $cleanv = $ts->censorString($cleanv);
675
-                    }
676
-                    break;
677
-                case XOBJ_DTYPE_SOURCE:
678
-                    if (!$v['not_gpc']) {
679
-                        $cleanv = $ts->stripSlashesGPC($cleanv);
680
-                    } else {
681
-                        $cleanv = $cleanv;
682
-                    }
683
-                    break;
684
-                case XOBJ_DTYPE_INT:
685
-                case XOBJ_DTYPE_TIME_ONLY:
686
-                    $cleanv = intval($cleanv);
687
-                    break;
688
-
689
-                case XOBJ_DTYPE_CURRENCY:
690
-                    $cleanv = smart_currency($cleanv);
691
-                    break;
692
-
693
-                case XOBJ_DTYPE_FLOAT:
694
-                    $cleanv = smart_float($cleanv);
695
-                    break;
696
-
697
-                case XOBJ_DTYPE_EMAIL:
698
-                    if ($v['required'] && $cleanv == '') {
699
-                        $this->setErrors( sprintf( _XOBJ_ERR_REQUIRED, $k ) );
700
-                        continue;
701
-                    }
702
-                    if ($cleanv != '' && !preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+([\.][a-z0-9-]+)+$/i",$cleanv)) {
703
-                        $this->setErrors("Invalid Email");
704
-                        continue;
705
-                    }
706
-                    if (!$v['not_gpc']) {
707
-                        $cleanv = $ts->stripSlashesGPC($cleanv);
708
-                    }
709
-                    break;
710
-                case XOBJ_DTYPE_URL:
711
-                    if ($v['required'] && $cleanv == '') {
712
-                        $this->setErrors( sprintf( _XOBJ_ERR_REQUIRED, $k ) );
713
-                        continue;
714
-                    }
715
-                    if ($cleanv != '' && !preg_match("/^http[s]*:\/\//i", $cleanv)) {
716
-                        $cleanv = 'http://' . $cleanv;
717
-                    }
718
-                    if (!$v['not_gpc']) {
719
-                        $cleanv =& $ts->stripSlashesGPC($cleanv);
720
-                    }
721
-                    break;
722
-                case XOBJ_DTYPE_SIMPLE_ARRAY:
723
-                    $cleanv = implode('|', $cleanv);
724
-                    break;
725
-                case XOBJ_DTYPE_ARRAY:
726
-                    $cleanv = serialize($cleanv);
727
-                    break;
728
-                case XOBJ_DTYPE_STIME:
729
-                case XOBJ_DTYPE_MTIME:
730
-                case XOBJ_DTYPE_LTIME:
731
-                    $cleanv = !is_string($cleanv) ? intval($cleanv) : strtotime($cleanv);
732
-                    if (!($cleanv > 0)) {
733
-                    	$cleanv = strtotime($cleanv);
734
-                    }
735
-                    break;
736
-                default:
737
-                    break;
738
-                }
739
-            }
740
-            $this->cleanVars[$k] =& $cleanv;
741
-            unset($cleanv);
742
-        }
743
-        if (count($this->_errors) > 0) {
744
-	        $this->_errors = array_merge($existing_errors, $this->_errors);
745
-            return false;
746
-        }
747
-	    $this->_errors = array_merge($existing_errors, $this->_errors);
748
-        $this->unsetDirty();
749
-        return true;
750
-    }
751
-
752
-    /**
753
-    * returns a specific variable for the object in a proper format
754
-    *
755
-    * We had to put this method in the SmartObject because the XOBJ_DTYPE_ARRAY does not work properly
756
-    * at least on PHP 5.1. So we have created a new type XOBJ_DTYPE_SIMPLE_ARRAY to handle 1 level array
757
-    * as a string separated by |
758
-    *
759
-    * @access public
760
-    * @param string $key key of the object's variable to be returned
761
-    * @param string $format format to use for the output
762
-    * @return mixed formatted value of the variable
763
-    */
764
-    function getVar($key, $format = 's')
765
-    {
766
-    	global $myts;
767
-
768
-        $ret = $this->vars[$key]['value'];
769
-
770
-        switch ($this->vars[$key]['data_type']) {
771
-
772
-        case XOBJ_DTYPE_TXTBOX:
773
-            switch (strtolower($format)) {
774
-            case 's':
775
-            case 'show':
776
-            	// ML Hack by marcan
777
-                $ts =& MyTextSanitizer::getInstance();
778
-                $ret = $ts->htmlSpecialChars($ret);
779
-
780
-                if (method_exists($myts, 'formatForML')) {
781
-                	return $ts->formatForML($ret);
782
-                } else {
783
-                	return $ret;
784
-                }
785
-            	break 1;
786
-            	// End of ML Hack by marcan
787
-
788
-            case 'clean':
645
+			if (!$v['changed']) {
646
+			} else {
647
+				$cleanv = is_string($cleanv) ? trim($cleanv) : $cleanv;
648
+				switch ($v['data_type']) {
649
+				case XOBJ_DTYPE_TXTBOX:
650
+					if ($v['required'] && $cleanv != '0' && $cleanv == '') {
651
+						$this->setErrors( sprintf( _XOBJ_ERR_REQUIRED, $k ) );
652
+						continue;
653
+					}
654
+					if (isset($v['maxlength']) && strlen($cleanv) > intval($v['maxlength'])) {
655
+						$this->setErrors( sprintf( _XOBJ_ERR_SHORTERTHAN, $k, intval( $v['maxlength'] ) ) );
656
+						continue;
657
+					}
658
+					if (!$v['not_gpc']) {
659
+						$cleanv = $ts->stripSlashesGPC($ts->censorString($cleanv));
660
+					} else {
661
+						$cleanv = $ts->censorString($cleanv);
662
+					}
663
+					break;
664
+				case XOBJ_DTYPE_TXTAREA:
665
+					if ($v['required'] && $cleanv != '0' && $cleanv == '') {
666
+						$this->setErrors( sprintf( _XOBJ_ERR_REQUIRED, $k ) );
667
+						continue;
668
+					}
669
+					if (!$v['not_gpc']) {
670
+						$cleanv = $ts->stripSlashesGPC($ts->censorString($cleanv));
671
+					} else {
672
+						$cleanv = $ts->censorString($cleanv);
673
+					}
674
+					break;
675
+				case XOBJ_DTYPE_SOURCE:
676
+					if (!$v['not_gpc']) {
677
+						$cleanv = $ts->stripSlashesGPC($cleanv);
678
+					} else {
679
+						$cleanv = $cleanv;
680
+					}
681
+					break;
682
+				case XOBJ_DTYPE_INT:
683
+				case XOBJ_DTYPE_TIME_ONLY:
684
+					$cleanv = intval($cleanv);
685
+					break;
686
+
687
+				case XOBJ_DTYPE_CURRENCY:
688
+					$cleanv = smart_currency($cleanv);
689
+					break;
690
+
691
+				case XOBJ_DTYPE_FLOAT:
692
+					$cleanv = smart_float($cleanv);
693
+					break;
694
+
695
+				case XOBJ_DTYPE_EMAIL:
696
+					if ($v['required'] && $cleanv == '') {
697
+						$this->setErrors( sprintf( _XOBJ_ERR_REQUIRED, $k ) );
698
+						continue;
699
+					}
700
+					if ($cleanv != '' && !preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+([\.][a-z0-9-]+)+$/i",$cleanv)) {
701
+						$this->setErrors("Invalid Email");
702
+						continue;
703
+					}
704
+					if (!$v['not_gpc']) {
705
+						$cleanv = $ts->stripSlashesGPC($cleanv);
706
+					}
707
+					break;
708
+				case XOBJ_DTYPE_URL:
709
+					if ($v['required'] && $cleanv == '') {
710
+						$this->setErrors( sprintf( _XOBJ_ERR_REQUIRED, $k ) );
711
+						continue;
712
+					}
713
+					if ($cleanv != '' && !preg_match("/^http[s]*:\/\//i", $cleanv)) {
714
+						$cleanv = 'http://' . $cleanv;
715
+					}
716
+					if (!$v['not_gpc']) {
717
+						$cleanv =& $ts->stripSlashesGPC($cleanv);
718
+					}
719
+					break;
720
+				case XOBJ_DTYPE_SIMPLE_ARRAY:
721
+					$cleanv = implode('|', $cleanv);
722
+					break;
723
+				case XOBJ_DTYPE_ARRAY:
724
+					$cleanv = serialize($cleanv);
725
+					break;
726
+				case XOBJ_DTYPE_STIME:
727
+				case XOBJ_DTYPE_MTIME:
728
+				case XOBJ_DTYPE_LTIME:
729
+					$cleanv = !is_string($cleanv) ? intval($cleanv) : strtotime($cleanv);
730
+					if (!($cleanv > 0)) {
731
+						$cleanv = strtotime($cleanv);
732
+					}
733
+					break;
734
+				default:
735
+					break;
736
+				}
737
+			}
738
+			$this->cleanVars[$k] =& $cleanv;
739
+			unset($cleanv);
740
+		}
741
+		if (count($this->_errors) > 0) {
742
+			$this->_errors = array_merge($existing_errors, $this->_errors);
743
+			return false;
744
+		}
745
+		$this->_errors = array_merge($existing_errors, $this->_errors);
746
+		$this->unsetDirty();
747
+		return true;
748
+	}
749
+
750
+	/**
751
+	 * returns a specific variable for the object in a proper format
752
+	 *
753
+	 * We had to put this method in the SmartObject because the XOBJ_DTYPE_ARRAY does not work properly
754
+	 * at least on PHP 5.1. So we have created a new type XOBJ_DTYPE_SIMPLE_ARRAY to handle 1 level array
755
+	 * as a string separated by |
756
+	 *
757
+	 * @access public
758
+	 * @param string $key key of the object's variable to be returned
759
+	 * @param string $format format to use for the output
760
+	 * @return mixed formatted value of the variable
761
+	 */
762
+	function getVar($key, $format = 's')
763
+	{
764
+		global $myts;
765
+
766
+		$ret = $this->vars[$key]['value'];
767
+
768
+		switch ($this->vars[$key]['data_type']) {
769
+
770
+		case XOBJ_DTYPE_TXTBOX:
771
+			switch (strtolower($format)) {
772
+			case 's':
773
+			case 'show':
774
+				// ML Hack by marcan
775
+				$ts =& MyTextSanitizer::getInstance();
776
+				$ret = $ts->htmlSpecialChars($ret);
777
+
778
+				if (method_exists($myts, 'formatForML')) {
779
+					return $ts->formatForML($ret);
780
+				} else {
781
+					return $ret;
782
+				}
783
+				break 1;
784
+				// End of ML Hack by marcan
785
+
786
+			case 'clean':
789 787
 				$ts =& MyTextSanitizer::getInstance();
790 788
 
791 789
 				$ret = smart_html2text($ret);
792 790
 				$ret = smart_purifyText($ret);
793 791
 
794
-                if (method_exists($myts, 'formatForML')) {
795
-                	return $ts->formatForML($ret);
796
-                } else {
797
-                	return $ret;
798
-                }
799
-            	break 1;
800
-            	// End of ML Hack by marcan
801
-
802
-            case 'e':
803
-            case 'edit':
804
-                $ts =& MyTextSanitizer::getInstance();
805
-                return $ts->htmlSpecialChars($ret);
806
-                break 1;
807
-            case 'p':
808
-            case 'preview':
809
-            case 'f':
810
-            case 'formpreview':
811
-                $ts =& MyTextSanitizer::getInstance();
812
-                return $ts->htmlSpecialChars($ts->stripSlashesGPC($ret));
813
-                break 1;
814
-            case 'n':
815
-            case 'none':
816
-            default:
817
-                break 1;
818
-            }
819
-            break;
820
-        case XOBJ_DTYPE_LTIME:
821
-            switch (strtolower($format)) {
822
-            case 's':
823
-            case 'show':
824
-            case 'p':
825
-            case 'preview':
826
-            case 'f':
827
-            case 'formpreview':
828
-                $ret = formatTimestamp($ret, _DATESTRING);
829
-                return $ret;
830
-            	break 1;
831
-            case 'n':
832
-            case 'none':
833
-            case 'e':
834
-            case 'edit':
835
-                break 1;
836
-            default:
837
-                break 1;
838
-            }
839
-            break;
840
-        case XOBJ_DTYPE_STIME:
841
-            switch (strtolower($format)) {
842
-            case 's':
843
-            case 'show':
844
-            case 'p':
845
-            case 'preview':
846
-            case 'f':
847
-            case 'formpreview':
848
-                $ret = formatTimestamp($ret, _SHORTDATESTRING);
849
-                return $ret;
850
-            	break 1;
851
-            case 'n':
852
-            case 'none':
853
-            case 'e':
854
-            case 'edit':
855
-                break 1;
856
-            default:
857
-                break 1;
858
-            }
859
-            break;
860
-        case XOBJ_DTYPE_TIME_ONLY:
861
-            switch (strtolower($format)) {
862
-            case 's':
863
-            case 'show':
864
-            case 'p':
865
-            case 'preview':
866
-            case 'f':
867
-            case 'formpreview':
868
-                $ret = formatTimestamp($ret, 'G:i');
869
-                return $ret;
870
-            	break 1;
871
-            case 'n':
872
-            case 'none':
873
-            case 'e':
874
-            case 'edit':
875
-                break 1;
876
-            default:
877
-                break 1;
878
-            }
879
-            break;
880
-
881
-        case XOBJ_DTYPE_CURRENCY:
882
-	        $decimal_section_original = strstr($ret, '.');
792
+				if (method_exists($myts, 'formatForML')) {
793
+					return $ts->formatForML($ret);
794
+				} else {
795
+					return $ret;
796
+				}
797
+				break 1;
798
+				// End of ML Hack by marcan
799
+
800
+			case 'e':
801
+			case 'edit':
802
+				$ts =& MyTextSanitizer::getInstance();
803
+				return $ts->htmlSpecialChars($ret);
804
+				break 1;
805
+			case 'p':
806
+			case 'preview':
807
+			case 'f':
808
+			case 'formpreview':
809
+				$ts =& MyTextSanitizer::getInstance();
810
+				return $ts->htmlSpecialChars($ts->stripSlashesGPC($ret));
811
+				break 1;
812
+			case 'n':
813
+			case 'none':
814
+			default:
815
+				break 1;
816
+			}
817
+			break;
818
+		case XOBJ_DTYPE_LTIME:
819
+			switch (strtolower($format)) {
820
+			case 's':
821
+			case 'show':
822
+			case 'p':
823
+			case 'preview':
824
+			case 'f':
825
+			case 'formpreview':
826
+				$ret = formatTimestamp($ret, _DATESTRING);
827
+				return $ret;
828
+				break 1;
829
+			case 'n':
830
+			case 'none':
831
+			case 'e':
832
+			case 'edit':
833
+				break 1;
834
+			default:
835
+				break 1;
836
+			}
837
+			break;
838
+		case XOBJ_DTYPE_STIME:
839
+			switch (strtolower($format)) {
840
+			case 's':
841
+			case 'show':
842
+			case 'p':
843
+			case 'preview':
844
+			case 'f':
845
+			case 'formpreview':
846
+				$ret = formatTimestamp($ret, _SHORTDATESTRING);
847
+				return $ret;
848
+				break 1;
849
+			case 'n':
850
+			case 'none':
851
+			case 'e':
852
+			case 'edit':
853
+				break 1;
854
+			default:
855
+				break 1;
856
+			}
857
+			break;
858
+		case XOBJ_DTYPE_TIME_ONLY:
859
+			switch (strtolower($format)) {
860
+			case 's':
861
+			case 'show':
862
+			case 'p':
863
+			case 'preview':
864
+			case 'f':
865
+			case 'formpreview':
866
+				$ret = formatTimestamp($ret, 'G:i');
867
+				return $ret;
868
+				break 1;
869
+			case 'n':
870
+			case 'none':
871
+			case 'e':
872
+			case 'edit':
873
+				break 1;
874
+			default:
875
+				break 1;
876
+			}
877
+			break;
878
+
879
+		case XOBJ_DTYPE_CURRENCY:
880
+			$decimal_section_original = strstr($ret, '.');
883 881
 			$decimal_section = $decimal_section_original;
884 882
 			if ($decimal_section) {
885 883
 				if (strlen($decimal_section) == 1) {
@@ -893,118 +891,118 @@  discard block
 block discarded – undo
893 891
 			}
894 892
 		break;
895 893
 
896
-        case XOBJ_DTYPE_TXTAREA:
897
-            switch (strtolower($format)) {
898
-            case 's':
899
-            case 'show':
900
-                $ts =& MyTextSanitizer::getInstance();
901
-                $html = !empty($this->vars['dohtml']['value']) ? 1 : 0;
894
+		case XOBJ_DTYPE_TXTAREA:
895
+			switch (strtolower($format)) {
896
+			case 's':
897
+			case 'show':
898
+				$ts =& MyTextSanitizer::getInstance();
899
+				$html = !empty($this->vars['dohtml']['value']) ? 1 : 0;
902 900
 
903
-                $xcode = (!isset($this->vars['doxcode']['value']) || $this->vars['doxcode']['value'] == 1) ? 1 : 0;
901
+				$xcode = (!isset($this->vars['doxcode']['value']) || $this->vars['doxcode']['value'] == 1) ? 1 : 0;
904 902
 
905
-                $smiley = (!isset($this->vars['dosmiley']['value']) || $this->vars['dosmiley']['value'] == 1) ? 1 : 0;
906
-                $image = (!isset($this->vars['doimage']['value']) || $this->vars['doimage']['value'] == 1) ? 1 : 0;
907
-                $br = (!isset($this->vars['dobr']['value']) || $this->vars['dobr']['value'] == 1) ? 1 : 0;
903
+				$smiley = (!isset($this->vars['dosmiley']['value']) || $this->vars['dosmiley']['value'] == 1) ? 1 : 0;
904
+				$image = (!isset($this->vars['doimage']['value']) || $this->vars['doimage']['value'] == 1) ? 1 : 0;
905
+				$br = (!isset($this->vars['dobr']['value']) || $this->vars['dobr']['value'] == 1) ? 1 : 0;
908 906
 
909 907
 				/**
910
-		 		 * Hack by marcan <INBOX> for SCSPRO
908
+				 * Hack by marcan <INBOX> for SCSPRO
911 909
 				 * Setting mastop as the main editor
912
-		 		 */
913
-                if (defined('XOOPS_EDITOR_IS_HTML')) {
914
-                	$br = false;
915
-                }
910
+				 */
911
+				if (defined('XOOPS_EDITOR_IS_HTML')) {
912
+					$br = false;
913
+				}
916 914
 				/**
917
-		 		 * Hack by marcan <INBOX> for SCSPRO
915
+				 * Hack by marcan <INBOX> for SCSPRO
918 916
 				 * Setting mastop as the main editor
919
-		 		 */
920
-
921
-                return $ts->displayTarea($ret, $html, $smiley, $xcode, $image, $br);
922
-                break 1;
923
-            case 'e':
924
-            case 'edit':
925
-                return htmlspecialchars($ret, ENT_QUOTES);
926
-                break 1;
927
-            case 'p':
928
-            case 'preview':
929
-                $ts =& MyTextSanitizer::getInstance();
930
-                $html = !empty($this->vars['dohtml']['value']) ? 1 : 0;
931
-                $xcode = (!isset($this->vars['doxcode']['value']) || $this->vars['doxcode']['value'] == 1) ? 1 : 0;
932
-                $smiley = (!isset($this->vars['dosmiley']['value']) || $this->vars['dosmiley']['value'] == 1) ? 1 : 0;
933
-                $image = (!isset($this->vars['doimage']['value']) || $this->vars['doimage']['value'] == 1) ? 1 : 0;
934
-                $br = (!isset($this->vars['dobr']['value']) || $this->vars['dobr']['value'] == 1) ? 1 : 0;
935
-                return $ts->previewTarea($ret, $html, $smiley, $xcode, $image, $br);
936
-                break 1;
937
-            case 'f':
938
-            case 'formpreview':
939
-                $ts =& MyTextSanitizer::getInstance();
940
-                return htmlspecialchars($ts->stripSlashesGPC($ret), ENT_QUOTES);
941
-                break 1;
942
-            case 'n':
943
-            case 'none':
944
-            default:
945
-                break 1;
946
-            }
947
-            break;
948
-        case XOBJ_DTYPE_SIMPLE_ARRAY:
949
-            $ret =& explode('|', $ret);
950
-            break;
951
-        case XOBJ_DTYPE_ARRAY:
952
-            $ret =& unserialize($ret);
953
-            break;
954
-        case XOBJ_DTYPE_SOURCE:
955
-            switch (strtolower($format)) {
956
-            case 's':
957
-            case 'show':
958
-                break 1;
959
-            case 'e':
960
-            case 'edit':
961
-                return htmlspecialchars($ret, ENT_QUOTES);
962
-                break 1;
963
-            case 'p':
964
-            case 'preview':
965
-                $ts =& MyTextSanitizer::getInstance();
966
-                return $ts->stripSlashesGPC($ret);
967
-                break 1;
968
-            case 'f':
969
-            case 'formpreview':
970
-                $ts =& MyTextSanitizer::getInstance();
971
-                return htmlspecialchars($ts->stripSlashesGPC($ret), ENT_QUOTES);
972
-                break 1;
973
-            case 'n':
974
-            case 'none':
975
-            default:
976
-                break 1;
977
-            }
978
-            break;
979
-        default:
980
-            if ($this->vars[$key]['options'] != '' && $ret != '') {
981
-                switch (strtolower($format)) {
982
-                case 's':
983
-                case 'show':
917
+				 */
918
+
919
+				return $ts->displayTarea($ret, $html, $smiley, $xcode, $image, $br);
920
+				break 1;
921
+			case 'e':
922
+			case 'edit':
923
+				return htmlspecialchars($ret, ENT_QUOTES);
924
+				break 1;
925
+			case 'p':
926
+			case 'preview':
927
+				$ts =& MyTextSanitizer::getInstance();
928
+				$html = !empty($this->vars['dohtml']['value']) ? 1 : 0;
929
+				$xcode = (!isset($this->vars['doxcode']['value']) || $this->vars['doxcode']['value'] == 1) ? 1 : 0;
930
+				$smiley = (!isset($this->vars['dosmiley']['value']) || $this->vars['dosmiley']['value'] == 1) ? 1 : 0;
931
+				$image = (!isset($this->vars['doimage']['value']) || $this->vars['doimage']['value'] == 1) ? 1 : 0;
932
+				$br = (!isset($this->vars['dobr']['value']) || $this->vars['dobr']['value'] == 1) ? 1 : 0;
933
+				return $ts->previewTarea($ret, $html, $smiley, $xcode, $image, $br);
934
+				break 1;
935
+			case 'f':
936
+			case 'formpreview':
937
+				$ts =& MyTextSanitizer::getInstance();
938
+				return htmlspecialchars($ts->stripSlashesGPC($ret), ENT_QUOTES);
939
+				break 1;
940
+			case 'n':
941
+			case 'none':
942
+			default:
943
+				break 1;
944
+			}
945
+			break;
946
+		case XOBJ_DTYPE_SIMPLE_ARRAY:
947
+			$ret =& explode('|', $ret);
948
+			break;
949
+		case XOBJ_DTYPE_ARRAY:
950
+			$ret =& unserialize($ret);
951
+			break;
952
+		case XOBJ_DTYPE_SOURCE:
953
+			switch (strtolower($format)) {
954
+			case 's':
955
+			case 'show':
956
+				break 1;
957
+			case 'e':
958
+			case 'edit':
959
+				return htmlspecialchars($ret, ENT_QUOTES);
960
+				break 1;
961
+			case 'p':
962
+			case 'preview':
963
+				$ts =& MyTextSanitizer::getInstance();
964
+				return $ts->stripSlashesGPC($ret);
965
+				break 1;
966
+			case 'f':
967
+			case 'formpreview':
968
+				$ts =& MyTextSanitizer::getInstance();
969
+				return htmlspecialchars($ts->stripSlashesGPC($ret), ENT_QUOTES);
970
+				break 1;
971
+			case 'n':
972
+			case 'none':
973
+			default:
974
+				break 1;
975
+			}
976
+			break;
977
+		default:
978
+			if ($this->vars[$key]['options'] != '' && $ret != '') {
979
+				switch (strtolower($format)) {
980
+				case 's':
981
+				case 'show':
984 982
 					$selected = explode('|', $ret);
985
-                    $options = explode('|', $this->vars[$key]['options']);
986
-                    $i = 1;
987
-                    $ret = array();
988
-                    foreach ($options as $op) {
989
-                        if (in_array($i, $selected)) {
990
-                            $ret[] = $op;
991
-                        }
992
-                        $i++;
993
-                    }
994
-                    return implode(', ', $ret);
995
-                case 'e':
996
-                case 'edit':
997
-                    $ret = explode('|', $ret);
998
-                    break 1;
999
-                default:
1000
-                    break 1;
1001
-                }
1002
-
1003
-            }
1004
-            break;
1005
-        }
1006
-        return $ret;
1007
-    }
983
+					$options = explode('|', $this->vars[$key]['options']);
984
+					$i = 1;
985
+					$ret = array();
986
+					foreach ($options as $op) {
987
+						if (in_array($i, $selected)) {
988
+							$ret[] = $op;
989
+						}
990
+						$i++;
991
+					}
992
+					return implode(', ', $ret);
993
+				case 'e':
994
+				case 'edit':
995
+					$ret = explode('|', $ret);
996
+					break 1;
997
+				default:
998
+					break 1;
999
+				}
1000
+
1001
+			}
1002
+			break;
1003
+		}
1004
+		return $ret;
1005
+	}
1008 1006
 
1009 1007
 	function doMakeFieldreadOnly($key) {
1010 1008
 		if (isset($this->vars[$key])) {
@@ -1068,7 +1066,7 @@  discard block
 block discarded – undo
1068 1066
 	 * @param bool $userSide for futur use, to do something different on the user side
1069 1067
 	 * @return content of the template if $fetchOnly or nothing if !$fetchOnly
1070 1068
 	 */
1071
-    function displaySingleObject($fetchOnly=false, $userSide=false, $actions=array(), $headerAsRow=true) {
1069
+	function displaySingleObject($fetchOnly=false, $userSide=false, $actions=array(), $headerAsRow=true) {
1072 1070
 		include_once SMARTOBJECT_ROOT_PATH."class/smartobjectsingleview.php";
1073 1071
 		$singleview = new SmartObjectSingleView($this, $userSide, $actions, $headerAsRow);
1074 1072
 		// add all fields mark as displayOnSingleView except the keyid
@@ -1085,7 +1083,7 @@  discard block
 block discarded – undo
1085 1083
 		}else {
1086 1084
 			$singleview->render($fetchOnly);
1087 1085
 		}
1088
-    }
1086
+	}
1089 1087
 
1090 1088
 	function doDisplayFieldOnSingleView($key) {
1091 1089
 		if (isset($this->vars[$key])) {
@@ -1093,13 +1091,13 @@  discard block
 block discarded – undo
1093 1091
 		}
1094 1092
 	}
1095 1093
 
1096
-    function doSetFieldAsRequired($field, $required=true) {
1094
+	function doSetFieldAsRequired($field, $required=true) {
1097 1095
 		$this->setVarInfo($field, 'required', $required);
1098
-    }
1096
+	}
1099 1097
 
1100
-    function doSetFieldForSorting($field) {
1098
+	function doSetFieldForSorting($field) {
1101 1099
 		$this->setVarInfo($field, 'sortby', true);
1102
-    }
1100
+	}
1103 1101
 
1104 1102
 	function showFieldOnForm($key) {
1105 1103
 		if (is_array($key)) {
Please login to merge, or discard this patch.
Switch Indentation   +298 added lines, -298 removed lines patch added patch discarded remove patch
@@ -648,93 +648,93 @@  discard block
 block discarded – undo
648 648
             } else {
649 649
                 $cleanv = is_string($cleanv) ? trim($cleanv) : $cleanv;
650 650
                 switch ($v['data_type']) {
651
-                case XOBJ_DTYPE_TXTBOX:
652
-                    if ($v['required'] && $cleanv != '0' && $cleanv == '') {
653
-                        $this->setErrors( sprintf( _XOBJ_ERR_REQUIRED, $k ) );
654
-                        continue;
655
-                    }
656
-                    if (isset($v['maxlength']) && strlen($cleanv) > intval($v['maxlength'])) {
657
-                        $this->setErrors( sprintf( _XOBJ_ERR_SHORTERTHAN, $k, intval( $v['maxlength'] ) ) );
658
-                        continue;
659
-                    }
660
-                    if (!$v['not_gpc']) {
661
-                        $cleanv = $ts->stripSlashesGPC($ts->censorString($cleanv));
662
-                    } else {
663
-                        $cleanv = $ts->censorString($cleanv);
664
-                    }
665
-                    break;
666
-                case XOBJ_DTYPE_TXTAREA:
667
-                    if ($v['required'] && $cleanv != '0' && $cleanv == '') {
668
-                        $this->setErrors( sprintf( _XOBJ_ERR_REQUIRED, $k ) );
669
-                        continue;
670
-                    }
671
-                    if (!$v['not_gpc']) {
672
-                        $cleanv = $ts->stripSlashesGPC($ts->censorString($cleanv));
673
-                    } else {
674
-                        $cleanv = $ts->censorString($cleanv);
675
-                    }
676
-                    break;
677
-                case XOBJ_DTYPE_SOURCE:
678
-                    if (!$v['not_gpc']) {
679
-                        $cleanv = $ts->stripSlashesGPC($cleanv);
680
-                    } else {
681
-                        $cleanv = $cleanv;
682
-                    }
683
-                    break;
684
-                case XOBJ_DTYPE_INT:
685
-                case XOBJ_DTYPE_TIME_ONLY:
686
-                    $cleanv = intval($cleanv);
687
-                    break;
688
-
689
-                case XOBJ_DTYPE_CURRENCY:
690
-                    $cleanv = smart_currency($cleanv);
691
-                    break;
692
-
693
-                case XOBJ_DTYPE_FLOAT:
694
-                    $cleanv = smart_float($cleanv);
695
-                    break;
696
-
697
-                case XOBJ_DTYPE_EMAIL:
698
-                    if ($v['required'] && $cleanv == '') {
699
-                        $this->setErrors( sprintf( _XOBJ_ERR_REQUIRED, $k ) );
700
-                        continue;
701
-                    }
702
-                    if ($cleanv != '' && !preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+([\.][a-z0-9-]+)+$/i",$cleanv)) {
703
-                        $this->setErrors("Invalid Email");
704
-                        continue;
705
-                    }
706
-                    if (!$v['not_gpc']) {
707
-                        $cleanv = $ts->stripSlashesGPC($cleanv);
708
-                    }
709
-                    break;
710
-                case XOBJ_DTYPE_URL:
711
-                    if ($v['required'] && $cleanv == '') {
712
-                        $this->setErrors( sprintf( _XOBJ_ERR_REQUIRED, $k ) );
713
-                        continue;
714
-                    }
715
-                    if ($cleanv != '' && !preg_match("/^http[s]*:\/\//i", $cleanv)) {
716
-                        $cleanv = 'http://' . $cleanv;
717
-                    }
718
-                    if (!$v['not_gpc']) {
719
-                        $cleanv =& $ts->stripSlashesGPC($cleanv);
720
-                    }
721
-                    break;
722
-                case XOBJ_DTYPE_SIMPLE_ARRAY:
723
-                    $cleanv = implode('|', $cleanv);
724
-                    break;
725
-                case XOBJ_DTYPE_ARRAY:
726
-                    $cleanv = serialize($cleanv);
727
-                    break;
728
-                case XOBJ_DTYPE_STIME:
729
-                case XOBJ_DTYPE_MTIME:
730
-                case XOBJ_DTYPE_LTIME:
731
-                    $cleanv = !is_string($cleanv) ? intval($cleanv) : strtotime($cleanv);
732
-                    if (!($cleanv > 0)) {
733
-                    	$cleanv = strtotime($cleanv);
734
-                    }
735
-                    break;
736
-                default:
737
-                    break;
651
+                	case XOBJ_DTYPE_TXTBOX:
652
+                    	if ($v['required'] && $cleanv != '0' && $cleanv == '') {
653
+                        	$this->setErrors( sprintf( _XOBJ_ERR_REQUIRED, $k ) );
654
+                        	continue;
655
+                    	}
656
+                    	if (isset($v['maxlength']) && strlen($cleanv) > intval($v['maxlength'])) {
657
+                        	$this->setErrors( sprintf( _XOBJ_ERR_SHORTERTHAN, $k, intval( $v['maxlength'] ) ) );
658
+                        	continue;
659
+                    	}
660
+                    	if (!$v['not_gpc']) {
661
+                        	$cleanv = $ts->stripSlashesGPC($ts->censorString($cleanv));
662
+                    	} else {
663
+                        	$cleanv = $ts->censorString($cleanv);
664
+                    	}
665
+                    	break;
666
+                	case XOBJ_DTYPE_TXTAREA:
667
+                    	if ($v['required'] && $cleanv != '0' && $cleanv == '') {
668
+                        	$this->setErrors( sprintf( _XOBJ_ERR_REQUIRED, $k ) );
669
+                        	continue;
670
+                    	}
671
+                    	if (!$v['not_gpc']) {
672
+                        	$cleanv = $ts->stripSlashesGPC($ts->censorString($cleanv));
673
+                    	} else {
674
+                        	$cleanv = $ts->censorString($cleanv);
675
+                    	}
676
+                    	break;
677
+                	case XOBJ_DTYPE_SOURCE:
678
+                    	if (!$v['not_gpc']) {
679
+                        	$cleanv = $ts->stripSlashesGPC($cleanv);
680
+                    	} else {
681
+                        	$cleanv = $cleanv;
682
+                    	}
683
+                    	break;
684
+                	case XOBJ_DTYPE_INT:
685
+                	case XOBJ_DTYPE_TIME_ONLY:
686
+                    	$cleanv = intval($cleanv);
687
+                    	break;
688
+
689
+                	case XOBJ_DTYPE_CURRENCY:
690
+                    	$cleanv = smart_currency($cleanv);
691
+                    	break;
692
+
693
+                	case XOBJ_DTYPE_FLOAT:
694
+                    	$cleanv = smart_float($cleanv);
695
+                    	break;
696
+
697
+                	case XOBJ_DTYPE_EMAIL:
698
+                    	if ($v['required'] && $cleanv == '') {
699
+                        	$this->setErrors( sprintf( _XOBJ_ERR_REQUIRED, $k ) );
700
+                        	continue;
701
+                    	}
702
+                    	if ($cleanv != '' && !preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+([\.][a-z0-9-]+)+$/i",$cleanv)) {
703
+                        	$this->setErrors("Invalid Email");
704
+                        	continue;
705
+                    	}
706
+                    	if (!$v['not_gpc']) {
707
+                        	$cleanv = $ts->stripSlashesGPC($cleanv);
708
+                    	}
709
+                    	break;
710
+                	case XOBJ_DTYPE_URL:
711
+                    	if ($v['required'] && $cleanv == '') {
712
+                        	$this->setErrors( sprintf( _XOBJ_ERR_REQUIRED, $k ) );
713
+                        	continue;
714
+                    	}
715
+                    	if ($cleanv != '' && !preg_match("/^http[s]*:\/\//i", $cleanv)) {
716
+                        	$cleanv = 'http://' . $cleanv;
717
+                    	}
718
+                    	if (!$v['not_gpc']) {
719
+                        	$cleanv =& $ts->stripSlashesGPC($cleanv);
720
+                    	}
721
+                    	break;
722
+                	case XOBJ_DTYPE_SIMPLE_ARRAY:
723
+                    	$cleanv = implode('|', $cleanv);
724
+                    	break;
725
+                	case XOBJ_DTYPE_ARRAY:
726
+                    	$cleanv = serialize($cleanv);
727
+                    	break;
728
+                	case XOBJ_DTYPE_STIME:
729
+                	case XOBJ_DTYPE_MTIME:
730
+                	case XOBJ_DTYPE_LTIME:
731
+                    	$cleanv = !is_string($cleanv) ? intval($cleanv) : strtotime($cleanv);
732
+                    	if (!($cleanv > 0)) {
733
+                    		$cleanv = strtotime($cleanv);
734
+                    	}
735
+                    	break;
736
+                	default:
737
+                    	break;
738 738
                 }
739 739
             }
740 740
             $this->cleanVars[$k] =& $cleanv;
@@ -769,236 +769,236 @@  discard block
 block discarded – undo
769 769
 
770 770
         switch ($this->vars[$key]['data_type']) {
771 771
 
772
-        case XOBJ_DTYPE_TXTBOX:
773
-            switch (strtolower($format)) {
774
-            case 's':
775
-            case 'show':
776
-            	// ML Hack by marcan
777
-                $ts =& MyTextSanitizer::getInstance();
778
-                $ret = $ts->htmlSpecialChars($ret);
779
-
780
-                if (method_exists($myts, 'formatForML')) {
781
-                	return $ts->formatForML($ret);
782
-                } else {
783
-                	return $ret;
784
-                }
785
-            	break 1;
786
-            	// End of ML Hack by marcan
787
-
788
-            case 'clean':
789
-				$ts =& MyTextSanitizer::getInstance();
790
-
791
-				$ret = smart_html2text($ret);
792
-				$ret = smart_purifyText($ret);
793
-
794
-                if (method_exists($myts, 'formatForML')) {
795
-                	return $ts->formatForML($ret);
796
-                } else {
797
-                	return $ret;
798
-                }
799
-            	break 1;
800
-            	// End of ML Hack by marcan
801
-
802
-            case 'e':
803
-            case 'edit':
804
-                $ts =& MyTextSanitizer::getInstance();
805
-                return $ts->htmlSpecialChars($ret);
806
-                break 1;
807
-            case 'p':
808
-            case 'preview':
809
-            case 'f':
810
-            case 'formpreview':
811
-                $ts =& MyTextSanitizer::getInstance();
812
-                return $ts->htmlSpecialChars($ts->stripSlashesGPC($ret));
813
-                break 1;
814
-            case 'n':
815
-            case 'none':
816
-            default:
817
-                break 1;
818
-            }
772
+        	case XOBJ_DTYPE_TXTBOX:
773
+            	switch (strtolower($format)) {
774
+            		case 's':
775
+            		case 'show':
776
+            			// ML Hack by marcan
777
+                		$ts =& MyTextSanitizer::getInstance();
778
+                		$ret = $ts->htmlSpecialChars($ret);
779
+
780
+                		if (method_exists($myts, 'formatForML')) {
781
+                			return $ts->formatForML($ret);
782
+                		} else {
783
+                			return $ret;
784
+                		}
785
+            			break 1;
786
+            			// End of ML Hack by marcan
787
+
788
+            		case 'clean':
789
+						$ts =& MyTextSanitizer::getInstance();
790
+
791
+						$ret = smart_html2text($ret);
792
+						$ret = smart_purifyText($ret);
793
+
794
+                		if (method_exists($myts, 'formatForML')) {
795
+                			return $ts->formatForML($ret);
796
+                		} else {
797
+                			return $ret;
798
+                		}
799
+            			break 1;
800
+            			// End of ML Hack by marcan
801
+
802
+            		case 'e':
803
+            		case 'edit':
804
+                		$ts =& MyTextSanitizer::getInstance();
805
+                		return $ts->htmlSpecialChars($ret);
806
+                		break 1;
807
+            		case 'p':
808
+            		case 'preview':
809
+            		case 'f':
810
+            		case 'formpreview':
811
+                		$ts =& MyTextSanitizer::getInstance();
812
+                		return $ts->htmlSpecialChars($ts->stripSlashesGPC($ret));
813
+                		break 1;
814
+            		case 'n':
815
+            		case 'none':
816
+            		default:
817
+                		break 1;
818
+            	}
819 819
             break;
820
-        case XOBJ_DTYPE_LTIME:
821
-            switch (strtolower($format)) {
822
-            case 's':
823
-            case 'show':
824
-            case 'p':
825
-            case 'preview':
826
-            case 'f':
827
-            case 'formpreview':
828
-                $ret = formatTimestamp($ret, _DATESTRING);
829
-                return $ret;
830
-            	break 1;
831
-            case 'n':
832
-            case 'none':
833
-            case 'e':
834
-            case 'edit':
835
-                break 1;
836
-            default:
837
-                break 1;
838
-            }
820
+        	case XOBJ_DTYPE_LTIME:
821
+            	switch (strtolower($format)) {
822
+            		case 's':
823
+            		case 'show':
824
+            		case 'p':
825
+            		case 'preview':
826
+            		case 'f':
827
+            		case 'formpreview':
828
+                		$ret = formatTimestamp($ret, _DATESTRING);
829
+                		return $ret;
830
+            			break 1;
831
+            		case 'n':
832
+            		case 'none':
833
+            		case 'e':
834
+            		case 'edit':
835
+                		break 1;
836
+            		default:
837
+                		break 1;
838
+            	}
839 839
             break;
840
-        case XOBJ_DTYPE_STIME:
841
-            switch (strtolower($format)) {
842
-            case 's':
843
-            case 'show':
844
-            case 'p':
845
-            case 'preview':
846
-            case 'f':
847
-            case 'formpreview':
848
-                $ret = formatTimestamp($ret, _SHORTDATESTRING);
849
-                return $ret;
850
-            	break 1;
851
-            case 'n':
852
-            case 'none':
853
-            case 'e':
854
-            case 'edit':
855
-                break 1;
856
-            default:
857
-                break 1;
858
-            }
840
+        	case XOBJ_DTYPE_STIME:
841
+            	switch (strtolower($format)) {
842
+            		case 's':
843
+            		case 'show':
844
+            		case 'p':
845
+            		case 'preview':
846
+            		case 'f':
847
+            		case 'formpreview':
848
+                		$ret = formatTimestamp($ret, _SHORTDATESTRING);
849
+                		return $ret;
850
+            			break 1;
851
+            		case 'n':
852
+            		case 'none':
853
+            		case 'e':
854
+            		case 'edit':
855
+                		break 1;
856
+            		default:
857
+                		break 1;
858
+            	}
859 859
             break;
860
-        case XOBJ_DTYPE_TIME_ONLY:
861
-            switch (strtolower($format)) {
862
-            case 's':
863
-            case 'show':
864
-            case 'p':
865
-            case 'preview':
866
-            case 'f':
867
-            case 'formpreview':
868
-                $ret = formatTimestamp($ret, 'G:i');
869
-                return $ret;
870
-            	break 1;
871
-            case 'n':
872
-            case 'none':
873
-            case 'e':
874
-            case 'edit':
875
-                break 1;
876
-            default:
877
-                break 1;
878
-            }
860
+        	case XOBJ_DTYPE_TIME_ONLY:
861
+            	switch (strtolower($format)) {
862
+            		case 's':
863
+            		case 'show':
864
+            		case 'p':
865
+            		case 'preview':
866
+            		case 'f':
867
+            		case 'formpreview':
868
+                		$ret = formatTimestamp($ret, 'G:i');
869
+                		return $ret;
870
+            			break 1;
871
+            		case 'n':
872
+            		case 'none':
873
+            		case 'e':
874
+            		case 'edit':
875
+                		break 1;
876
+            		default:
877
+                		break 1;
878
+            	}
879 879
             break;
880 880
 
881
-        case XOBJ_DTYPE_CURRENCY:
882
-	        $decimal_section_original = strstr($ret, '.');
883
-			$decimal_section = $decimal_section_original;
884
-			if ($decimal_section) {
885
-				if (strlen($decimal_section) == 1) {
886
-					$decimal_section = '.00';
887
-				} elseif(strlen($decimal_section) == 2) {
888
-					$decimal_section = $decimal_section . '0';
881
+        	case XOBJ_DTYPE_CURRENCY:
882
+	        	$decimal_section_original = strstr($ret, '.');
883
+				$decimal_section = $decimal_section_original;
884
+				if ($decimal_section) {
885
+					if (strlen($decimal_section) == 1) {
886
+						$decimal_section = '.00';
887
+					} elseif(strlen($decimal_section) == 2) {
888
+						$decimal_section = $decimal_section . '0';
889
+					}
890
+					$ret = str_replace($decimal_section_original, $decimal_section, $ret);
891
+				} else {
892
+					$ret = $ret . '.00';
889 893
 				}
890
-				$ret = str_replace($decimal_section_original, $decimal_section, $ret);
891
-			} else {
892
-				$ret = $ret . '.00';
893
-			}
894
-		break;
894
+			break;
895 895
 
896
-        case XOBJ_DTYPE_TXTAREA:
897
-            switch (strtolower($format)) {
898
-            case 's':
899
-            case 'show':
900
-                $ts =& MyTextSanitizer::getInstance();
901
-                $html = !empty($this->vars['dohtml']['value']) ? 1 : 0;
896
+        	case XOBJ_DTYPE_TXTAREA:
897
+            	switch (strtolower($format)) {
898
+            		case 's':
899
+            		case 'show':
900
+                		$ts =& MyTextSanitizer::getInstance();
901
+                		$html = !empty($this->vars['dohtml']['value']) ? 1 : 0;
902 902
 
903
-                $xcode = (!isset($this->vars['doxcode']['value']) || $this->vars['doxcode']['value'] == 1) ? 1 : 0;
903
+                		$xcode = (!isset($this->vars['doxcode']['value']) || $this->vars['doxcode']['value'] == 1) ? 1 : 0;
904 904
 
905
-                $smiley = (!isset($this->vars['dosmiley']['value']) || $this->vars['dosmiley']['value'] == 1) ? 1 : 0;
906
-                $image = (!isset($this->vars['doimage']['value']) || $this->vars['doimage']['value'] == 1) ? 1 : 0;
907
-                $br = (!isset($this->vars['dobr']['value']) || $this->vars['dobr']['value'] == 1) ? 1 : 0;
905
+                		$smiley = (!isset($this->vars['dosmiley']['value']) || $this->vars['dosmiley']['value'] == 1) ? 1 : 0;
906
+                		$image = (!isset($this->vars['doimage']['value']) || $this->vars['doimage']['value'] == 1) ? 1 : 0;
907
+                		$br = (!isset($this->vars['dobr']['value']) || $this->vars['dobr']['value'] == 1) ? 1 : 0;
908 908
 
909
-				/**
909
+						/**
910 910
 		 		 * Hack by marcan <INBOX> for SCSPRO
911 911
 				 * Setting mastop as the main editor
912 912
 		 		 */
913
-                if (defined('XOOPS_EDITOR_IS_HTML')) {
914
-                	$br = false;
915
-                }
916
-				/**
913
+                		if (defined('XOOPS_EDITOR_IS_HTML')) {
914
+                			$br = false;
915
+                		}
916
+						/**
917 917
 		 		 * Hack by marcan <INBOX> for SCSPRO
918 918
 				 * Setting mastop as the main editor
919 919
 		 		 */
920 920
 
921
-                return $ts->displayTarea($ret, $html, $smiley, $xcode, $image, $br);
922
-                break 1;
923
-            case 'e':
924
-            case 'edit':
925
-                return htmlspecialchars($ret, ENT_QUOTES);
926
-                break 1;
927
-            case 'p':
928
-            case 'preview':
929
-                $ts =& MyTextSanitizer::getInstance();
930
-                $html = !empty($this->vars['dohtml']['value']) ? 1 : 0;
931
-                $xcode = (!isset($this->vars['doxcode']['value']) || $this->vars['doxcode']['value'] == 1) ? 1 : 0;
932
-                $smiley = (!isset($this->vars['dosmiley']['value']) || $this->vars['dosmiley']['value'] == 1) ? 1 : 0;
933
-                $image = (!isset($this->vars['doimage']['value']) || $this->vars['doimage']['value'] == 1) ? 1 : 0;
934
-                $br = (!isset($this->vars['dobr']['value']) || $this->vars['dobr']['value'] == 1) ? 1 : 0;
935
-                return $ts->previewTarea($ret, $html, $smiley, $xcode, $image, $br);
936
-                break 1;
937
-            case 'f':
938
-            case 'formpreview':
939
-                $ts =& MyTextSanitizer::getInstance();
940
-                return htmlspecialchars($ts->stripSlashesGPC($ret), ENT_QUOTES);
941
-                break 1;
942
-            case 'n':
943
-            case 'none':
944
-            default:
945
-                break 1;
946
-            }
921
+                		return $ts->displayTarea($ret, $html, $smiley, $xcode, $image, $br);
922
+                		break 1;
923
+            		case 'e':
924
+            		case 'edit':
925
+                		return htmlspecialchars($ret, ENT_QUOTES);
926
+                		break 1;
927
+            		case 'p':
928
+            		case 'preview':
929
+                		$ts =& MyTextSanitizer::getInstance();
930
+                		$html = !empty($this->vars['dohtml']['value']) ? 1 : 0;
931
+                		$xcode = (!isset($this->vars['doxcode']['value']) || $this->vars['doxcode']['value'] == 1) ? 1 : 0;
932
+                		$smiley = (!isset($this->vars['dosmiley']['value']) || $this->vars['dosmiley']['value'] == 1) ? 1 : 0;
933
+                		$image = (!isset($this->vars['doimage']['value']) || $this->vars['doimage']['value'] == 1) ? 1 : 0;
934
+                		$br = (!isset($this->vars['dobr']['value']) || $this->vars['dobr']['value'] == 1) ? 1 : 0;
935
+                		return $ts->previewTarea($ret, $html, $smiley, $xcode, $image, $br);
936
+                		break 1;
937
+            		case 'f':
938
+            		case 'formpreview':
939
+                		$ts =& MyTextSanitizer::getInstance();
940
+                		return htmlspecialchars($ts->stripSlashesGPC($ret), ENT_QUOTES);
941
+                		break 1;
942
+            		case 'n':
943
+            		case 'none':
944
+            		default:
945
+                		break 1;
946
+            	}
947 947
             break;
948
-        case XOBJ_DTYPE_SIMPLE_ARRAY:
949
-            $ret =& explode('|', $ret);
948
+        	case XOBJ_DTYPE_SIMPLE_ARRAY:
949
+            	$ret =& explode('|', $ret);
950
+            	break;
951
+        	case XOBJ_DTYPE_ARRAY:
952
+            	$ret =& unserialize($ret);
953
+            	break;
954
+        	case XOBJ_DTYPE_SOURCE:
955
+            	switch (strtolower($format)) {
956
+            		case 's':
957
+            		case 'show':
958
+                		break 1;
959
+            		case 'e':
960
+            		case 'edit':
961
+                		return htmlspecialchars($ret, ENT_QUOTES);
962
+                		break 1;
963
+            		case 'p':
964
+            		case 'preview':
965
+                		$ts =& MyTextSanitizer::getInstance();
966
+                		return $ts->stripSlashesGPC($ret);
967
+                		break 1;
968
+            		case 'f':
969
+            		case 'formpreview':
970
+                		$ts =& MyTextSanitizer::getInstance();
971
+                		return htmlspecialchars($ts->stripSlashesGPC($ret), ENT_QUOTES);
972
+                		break 1;
973
+            		case 'n':
974
+            		case 'none':
975
+            		default:
976
+                		break 1;
977
+            	}
950 978
             break;
951
-        case XOBJ_DTYPE_ARRAY:
952
-            $ret =& unserialize($ret);
953
-            break;
954
-        case XOBJ_DTYPE_SOURCE:
955
-            switch (strtolower($format)) {
956
-            case 's':
957
-            case 'show':
958
-                break 1;
959
-            case 'e':
960
-            case 'edit':
961
-                return htmlspecialchars($ret, ENT_QUOTES);
962
-                break 1;
963
-            case 'p':
964
-            case 'preview':
965
-                $ts =& MyTextSanitizer::getInstance();
966
-                return $ts->stripSlashesGPC($ret);
967
-                break 1;
968
-            case 'f':
969
-            case 'formpreview':
970
-                $ts =& MyTextSanitizer::getInstance();
971
-                return htmlspecialchars($ts->stripSlashesGPC($ret), ENT_QUOTES);
972
-                break 1;
973
-            case 'n':
974
-            case 'none':
975
-            default:
976
-                break 1;
977
-            }
978
-            break;
979
-        default:
980
-            if ($this->vars[$key]['options'] != '' && $ret != '') {
981
-                switch (strtolower($format)) {
982
-                case 's':
983
-                case 'show':
984
-					$selected = explode('|', $ret);
985
-                    $options = explode('|', $this->vars[$key]['options']);
986
-                    $i = 1;
987
-                    $ret = array();
988
-                    foreach ($options as $op) {
989
-                        if (in_array($i, $selected)) {
990
-                            $ret[] = $op;
991
-                        }
992
-                        $i++;
993
-                    }
994
-                    return implode(', ', $ret);
995
-                case 'e':
996
-                case 'edit':
997
-                    $ret = explode('|', $ret);
998
-                    break 1;
999
-                default:
1000
-                    break 1;
1001
-                }
979
+        	default:
980
+            	if ($this->vars[$key]['options'] != '' && $ret != '') {
981
+                	switch (strtolower($format)) {
982
+                		case 's':
983
+                		case 'show':
984
+							$selected = explode('|', $ret);
985
+                    		$options = explode('|', $this->vars[$key]['options']);
986
+                    		$i = 1;
987
+                    		$ret = array();
988
+                    		foreach ($options as $op) {
989
+                        		if (in_array($i, $selected)) {
990
+                            		$ret[] = $op;
991
+                        		}
992
+                        		$i++;
993
+                    		}
994
+                    		return implode(', ', $ret);
995
+                		case 'e':
996
+                		case 'edit':
997
+                    		$ret = explode('|', $ret);
998
+                    		break 1;
999
+                		default:
1000
+                    		break 1;
1001
+                	}
1002 1002
 
1003 1003
             }
1004 1004
             break;
Please login to merge, or discard this patch.
Spacing   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 
48 48
     var $seoEnabled = false;
49 49
     var $titleField;
50
-    var $summaryField=false;
50
+    var $summaryField = false;
51 51
 
52 52
     /**
53 53
 	 * Reference to the handler managing this object
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 		$smartpermissions_handler = new SmartobjectPermissionHandler($this->handler);
76 76
 		return $smartpermissions_handler->accessGranted($perm_name, $this->id());
77 77
 	}
78
-	function addFormSection($section_name, $value=false, $hide=false) {
78
+	function addFormSection($section_name, $value = false, $hide = false) {
79 79
 		$this->initVar($section_name, XOBJ_DTYPE_FORM_SECTION, $value, false, null, '', false, '', '', false, false, true);
80 80
 		$this->vars[$section_name]['hide'] = $hide;
81 81
 	}
@@ -97,9 +97,9 @@  discard block
 block discarded – undo
97 97
     * @param bool $sortby set to TRUE to make this field used to sort objects in SmartObjectTable
98 98
     * @param bool $persistent set to FALSE if this field is not to be saved in the database
99 99
     */
100
-    function initVar($key, $data_type, $value = null, $required = false, $maxlength = null, $options = '', $multilingual=false, $form_caption='', $form_dsc='', $sortby=false, $persistent=true, $displayOnForm=true) {
100
+    function initVar($key, $data_type, $value = null, $required = false, $maxlength = null, $options = '', $multilingual = false, $form_caption = '', $form_dsc = '', $sortby = false, $persistent = true, $displayOnForm = true) {
101 101
         //url_ is reserved for files.
102
-        if (substr($key, 0,4) == 'url_' ) {
102
+        if (substr($key, 0, 4) == 'url_') {
103 103
 	        trigger_error("Cannot use variable starting with 'url_'.");
104 104
 	    }
105 105
         parent::initVar($key, $data_type, $value, $required, $maxlength, $options);
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
         'readonly' => false));
128 128
     }
129 129
 
130
-    function initNonPersistableVar($key, $data_type, $itemName=false, $form_caption='', $sortby=false, $value='', $displayOnForm=false, $required=false) {
130
+    function initNonPersistableVar($key, $data_type, $itemName = false, $form_caption = '', $sortby = false, $value = '', $displayOnForm = false, $required = false) {
131 131
 		$this->initVar($key, $data_type, $value, $required, null, '', false, $form_caption, '', $sortby, false, $displayOnForm);
132 132
 		$this->vars[$key]['itemName'] = $itemName;
133 133
     }
@@ -147,12 +147,12 @@  discard block
 block discarded – undo
147 147
     * @param string $form_dsc description of this variable in a {@link SmartobjectForm}
148 148
     * @param mixed $value default value of this variable
149 149
     */
150
-	function quickInitVar($key, $data_type, $required=false, $form_caption='', $form_dsc='', $value = null) {
150
+	function quickInitVar($key, $data_type, $required = false, $form_caption = '', $form_dsc = '', $value = null) {
151 151
 		$maxlength = $data_type == 'XOBJ_DTYPE_TXTBOX' ? 255 : null;
152 152
 		$this->initVar($key, $data_type, $value, $required, $maxlength, '', false, $form_caption, $form_dsc, false, true, true);
153 153
 	}
154 154
 
155
-    function initCommonVar($varname, $displayOnForm=true, $default='notdefined') {
155
+    function initCommonVar($varname, $displayOnForm = true, $default = 'notdefined') {
156 156
 
157 157
     	switch ($varname) {
158 158
             case "dohtml":
@@ -163,25 +163,25 @@  discard block
 block discarded – undo
163 163
 
164 164
             case "dobr":
165 165
             	$value = ($default === 'notdefined') ? true : $default;
166
-                $this->initVar($varname, XOBJ_DTYPE_INT,$value, false, null, "", false, _CO_SOBJECT_DOBR_FORM_CAPTION, '', false, true, $displayOnForm);
166
+                $this->initVar($varname, XOBJ_DTYPE_INT, $value, false, null, "", false, _CO_SOBJECT_DOBR_FORM_CAPTION, '', false, true, $displayOnForm);
167 167
                 $this->setControl($varname, "yesno");
168 168
                 break;
169 169
 
170 170
             case "doimage":
171 171
             	$value = $default != 'notdefined' ? $default : true;
172
-                $this->initVar($varname, XOBJ_DTYPE_INT,$value, false, null, "", false, _CO_SOBJECT_DOIMAGE_FORM_CAPTION, '', false, true, $displayOnForm);
172
+                $this->initVar($varname, XOBJ_DTYPE_INT, $value, false, null, "", false, _CO_SOBJECT_DOIMAGE_FORM_CAPTION, '', false, true, $displayOnForm);
173 173
                 $this->setControl($varname, "yesno");
174 174
                 break;
175 175
 
176 176
             case "dosmiley":
177 177
             	$value = $default != 'notdefined' ? $default : true;
178
-                $this->initVar($varname, XOBJ_DTYPE_INT,$value, false, null, "", false, _CO_SOBJECT_DOSMILEY_FORM_CAPTION, '', false, true, $displayOnForm);
178
+                $this->initVar($varname, XOBJ_DTYPE_INT, $value, false, null, "", false, _CO_SOBJECT_DOSMILEY_FORM_CAPTION, '', false, true, $displayOnForm);
179 179
                 $this->setControl($varname, "yesno");
180 180
                 break;
181 181
 
182 182
             case "doxcode":
183 183
             	$value = $default != 'notdefined' ? $default : true;
184
-                $this->initVar($varname, XOBJ_DTYPE_INT,$value, false, null, "", false, _CO_SOBJECT_DOXCODE_FORM_CAPTION, '', false, true, $displayOnForm);
184
+                $this->initVar($varname, XOBJ_DTYPE_INT, $value, false, null, "", false, _CO_SOBJECT_DOXCODE_FORM_CAPTION, '', false, true, $displayOnForm);
185 185
                 $this->setControl($varname, "yesno");
186 186
                 break;
187 187
 
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 
206 206
             case "short_url":
207 207
             	$value = $default != 'notdefined' ? $default : '';
208
-                $this->initVar($varname, XOBJ_DTYPE_TXTBOX,$value, false, null, "", false, _CO_SOBJECT_SHORT_URL, _CO_SOBJECT_SHORT_URL_DSC, false, true, $displayOnForm);
208
+                $this->initVar($varname, XOBJ_DTYPE_TXTBOX, $value, false, null, "", false, _CO_SOBJECT_SHORT_URL, _CO_SOBJECT_SHORT_URL_DSC, false, true, $displayOnForm);
209 209
                 break;
210 210
 
211 211
             case "hierarchy_path":
@@ -215,12 +215,12 @@  discard block
 block discarded – undo
215 215
 
216 216
             case "counter":
217 217
             	$value = $default != 'notdefined' ? $default : 0;
218
-                $this->initVar($varname, XOBJ_DTYPE_INT,$value, false, null, '', false, _CO_SOBJECT_COUNTER_FORM_CAPTION, '', false, true, $displayOnForm);
218
+                $this->initVar($varname, XOBJ_DTYPE_INT, $value, false, null, '', false, _CO_SOBJECT_COUNTER_FORM_CAPTION, '', false, true, $displayOnForm);
219 219
                 break;
220 220
 
221 221
             case "weight":
222 222
             	$value = $default != 'notdefined' ? $default : 0;
223
-                $this->initVar($varname, XOBJ_DTYPE_INT,$value, false, null, '', false, _CO_SOBJECT_WEIGHT_FORM_CAPTION, '', true, true, $displayOnForm);
223
+                $this->initVar($varname, XOBJ_DTYPE_INT, $value, false, null, '', false, _CO_SOBJECT_WEIGHT_FORM_CAPTION, '', true, true, $displayOnForm);
224 224
                 break;
225 225
             case "custom_css":
226 226
             	$value = $default != 'notdefined' ? $default : '';
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
      * @param string $var name of the variable for which we want to set a control
320 320
      * @param array $options
321 321
      */
322
-    function setControl($var, $options=array()) {
322
+    function setControl($var, $options = array()) {
323 323
         if (isset($this->controls[$var])) {
324 324
         	unset($this->controls[$var]);
325 325
         }
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
     *
346 346
     * @see SmartObjectForm::SmartObjectForm()
347 347
     */
348
-    function getForm($form_caption, $form_name, $form_action=false, $submit_button_caption = _CO_SOBJECT_SUBMIT, $cancel_js_action=false, $captcha=false)
348
+    function getForm($form_caption, $form_name, $form_action = false, $submit_button_caption = _CO_SOBJECT_SUBMIT, $cancel_js_action = false, $captcha = false)
349 349
     {
350 350
         include_once SMARTOBJECT_ROOT_PATH . "class/form/smartobjectform.php";
351 351
         $form = new SmartobjectForm($this, $form_name, $form_caption, $form_action, null, $submit_button_caption, $cancel_js_action, $captcha);
@@ -377,12 +377,12 @@  discard block
 block discarded – undo
377 377
 		include_once(SMARTOBJECT_ROOT_PATH . 'class/smarthighlighter.php');
378 378
 		$highlight = smart_getConfig('module_search_highlighter', false, true);
379 379
 
380
-		if($highlight && isset($_GET['keywords']))
380
+		if ($highlight && isset($_GET['keywords']))
381 381
 		{
382
-			$myts =& MyTextSanitizer::getInstance();
383
-			$keywords=$myts->htmlSpecialChars(trim(urldecode($_GET['keywords'])));
384
-			$h= new SmartHighlighter ($keywords, true , 'smart_highlighter');
385
-			foreach($this->handler->highlightFields as $field) {
382
+			$myts = & MyTextSanitizer::getInstance();
383
+			$keywords = $myts->htmlSpecialChars(trim(urldecode($_GET['keywords'])));
384
+			$h = new SmartHighlighter($keywords, true, 'smart_highlighter');
385
+			foreach ($this->handler->highlightFields as $field) {
386 386
 				$ret[$field] = $h->highlight($ret[$field]);
387 387
 			}
388 388
 		}
@@ -396,10 +396,10 @@  discard block
 block discarded – undo
396 396
      * @param string $value error to add
397 397
      * @access public
398 398
      */
399
-    function setErrors($err_str, $prefix=false)
399
+    function setErrors($err_str, $prefix = false)
400 400
     {
401 401
     	if (is_array($err_str)) {
402
-            foreach($err_str as $str) {
402
+            foreach ($err_str as $str) {
403 403
                 $this->setErrors($str, $prefix);
404 404
             }
405 405
         } else {
@@ -410,9 +410,9 @@  discard block
 block discarded – undo
410 410
         }
411 411
     }
412 412
 
413
-    function setFieldAsRequired($field, $required=true) {
413
+    function setFieldAsRequired($field, $required = true) {
414 414
     	if (is_array($field)) {
415
-			foreach($field as $v) {
415
+			foreach ($field as $v) {
416 416
 				$this->doSetFieldAsRequired($v, $required);
417 417
 			}
418 418
     	} else {
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
 
423 423
     function setFieldForSorting($field) {
424 424
     	if (is_array($field)) {
425
-			foreach($field as $v) {
425
+			foreach ($field as $v) {
426 426
 				$this->doSetFieldForSorting($v);
427 427
 			}
428 428
     	} else {
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
 		}
462 462
 	}
463 463
 
464
-    function getImageDir($path=false)
464
+    function getImageDir($path = false)
465 465
     {
466 466
         if ($path) {
467 467
             return $this->_image_path;
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
         }
471 471
     }
472 472
 
473
-	function getUploadDir($path=false)
473
+	function getUploadDir($path = false)
474 474
     {
475 475
         if ($path) {
476 476
             return $this->_image_path;
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
 			return $this->vars[$key][$info];
485 485
 		}elseif ($info == '' && isset($this->vars[$key])) {
486 486
 			return $this->vars[$key];
487
-		}  else {
487
+		} else {
488 488
 			return $this->vars;
489 489
 		}
490 490
 	}
@@ -503,7 +503,7 @@  discard block
 block discarded – undo
503 503
      *
504 504
      * @return string
505 505
      */
506
-    function title($format='s')
506
+    function title($format = 's')
507 507
     {
508 508
         return $this->getVar($this->handler->identifierName, $format);
509 509
     }
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
      * @param bool $onlyUrl wether or not to return a simple URL or a full <a> link
529 529
      * @return string user side link to the object
530 530
      */
531
-    function getAdminViewItemLink($onlyUrl=false)
531
+    function getAdminViewItemLink($onlyUrl = false)
532 532
     {
533 533
     	$controller = new SmartObjectController($this->handler);
534 534
     	return $controller->getAdminViewItemLink($this, $onlyUrl);
@@ -540,19 +540,19 @@  discard block
 block discarded – undo
540 540
      * @param bool $onlyUrl wether or not to return a simple URL or a full <a> link
541 541
      * @return string user side link to the object
542 542
      */
543
-    function getItemLink($onlyUrl=false)
543
+    function getItemLink($onlyUrl = false)
544 544
     {
545 545
     	$controller = new SmartObjectController($this->handler);
546 546
     	return $controller->getItemLink($this, $onlyUrl);
547 547
     }
548 548
 
549
-    function getEditItemLink($onlyUrl=false, $withimage=true, $userSide=false)
549
+    function getEditItemLink($onlyUrl = false, $withimage = true, $userSide = false)
550 550
     {
551 551
     	$controller = new SmartObjectController($this->handler);
552 552
     	return $controller->getEditItemLink($this, $onlyUrl, $withimage, $userSide);
553 553
     }
554 554
 
555
-    function getDeleteItemLink($onlyUrl=false, $withimage=false, $userSide=false)
555
+    function getDeleteItemLink($onlyUrl = false, $withimage = false, $userSide = false)
556 556
     {
557 557
     	$controller = new SmartObjectController($this->handler);
558 558
     	return $controller->getDeleteItemLink($this, $onlyUrl, $withimage, $userSide);
@@ -567,7 +567,7 @@  discard block
 block discarded – undo
567 567
 	function getFieldsForSorting($sortsel) {
568 568
 		$ret = array();
569 569
 
570
-		foreach($this->vars as $key=>$field_info) {
570
+		foreach ($this->vars as $key=>$field_info) {
571 571
 			if ($field_info['sortby']) {
572 572
 				$ret[$key]['caption'] = $field_info['form_caption'];
573 573
 				$ret[$key]['selected'] = $key == $sortsel ? "selected='selected'" : '';
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
 		$this->vars[$key][$info] = $value;
590 590
 	}
591 591
 
592
-	function getValueFor($key, $editor=true) {
592
+	function getValueFor($key, $editor = true) {
593 593
     	global $xoopsModuleConfig;
594 594
 
595 595
     	$ret = $this->getVar($key, 'n');
@@ -639,7 +639,7 @@  discard block
 block discarded – undo
639 639
      */
640 640
     function cleanVars()
641 641
     {
642
-        $ts =& MyTextSanitizer::getInstance();
642
+        $ts = & MyTextSanitizer::getInstance();
643 643
         $existing_errors = $this->getErrors();
644 644
         $this->_errors = array();
645 645
         foreach ($this->vars as $k => $v) {
@@ -650,11 +650,11 @@  discard block
 block discarded – undo
650 650
                 switch ($v['data_type']) {
651 651
                 case XOBJ_DTYPE_TXTBOX:
652 652
                     if ($v['required'] && $cleanv != '0' && $cleanv == '') {
653
-                        $this->setErrors( sprintf( _XOBJ_ERR_REQUIRED, $k ) );
653
+                        $this->setErrors(sprintf(_XOBJ_ERR_REQUIRED, $k));
654 654
                         continue;
655 655
                     }
656 656
                     if (isset($v['maxlength']) && strlen($cleanv) > intval($v['maxlength'])) {
657
-                        $this->setErrors( sprintf( _XOBJ_ERR_SHORTERTHAN, $k, intval( $v['maxlength'] ) ) );
657
+                        $this->setErrors(sprintf(_XOBJ_ERR_SHORTERTHAN, $k, intval($v['maxlength'])));
658 658
                         continue;
659 659
                     }
660 660
                     if (!$v['not_gpc']) {
@@ -665,7 +665,7 @@  discard block
 block discarded – undo
665 665
                     break;
666 666
                 case XOBJ_DTYPE_TXTAREA:
667 667
                     if ($v['required'] && $cleanv != '0' && $cleanv == '') {
668
-                        $this->setErrors( sprintf( _XOBJ_ERR_REQUIRED, $k ) );
668
+                        $this->setErrors(sprintf(_XOBJ_ERR_REQUIRED, $k));
669 669
                         continue;
670 670
                     }
671 671
                     if (!$v['not_gpc']) {
@@ -696,10 +696,10 @@  discard block
 block discarded – undo
696 696
 
697 697
                 case XOBJ_DTYPE_EMAIL:
698 698
                     if ($v['required'] && $cleanv == '') {
699
-                        $this->setErrors( sprintf( _XOBJ_ERR_REQUIRED, $k ) );
699
+                        $this->setErrors(sprintf(_XOBJ_ERR_REQUIRED, $k));
700 700
                         continue;
701 701
                     }
702
-                    if ($cleanv != '' && !preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+([\.][a-z0-9-]+)+$/i",$cleanv)) {
702
+                    if ($cleanv != '' && !preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+([\.][a-z0-9-]+)+$/i", $cleanv)) {
703 703
                         $this->setErrors("Invalid Email");
704 704
                         continue;
705 705
                     }
@@ -709,14 +709,14 @@  discard block
 block discarded – undo
709 709
                     break;
710 710
                 case XOBJ_DTYPE_URL:
711 711
                     if ($v['required'] && $cleanv == '') {
712
-                        $this->setErrors( sprintf( _XOBJ_ERR_REQUIRED, $k ) );
712
+                        $this->setErrors(sprintf(_XOBJ_ERR_REQUIRED, $k));
713 713
                         continue;
714 714
                     }
715 715
                     if ($cleanv != '' && !preg_match("/^http[s]*:\/\//i", $cleanv)) {
716 716
                         $cleanv = 'http://' . $cleanv;
717 717
                     }
718 718
                     if (!$v['not_gpc']) {
719
-                        $cleanv =& $ts->stripSlashesGPC($cleanv);
719
+                        $cleanv = & $ts->stripSlashesGPC($cleanv);
720 720
                     }
721 721
                     break;
722 722
                 case XOBJ_DTYPE_SIMPLE_ARRAY:
@@ -737,7 +737,7 @@  discard block
 block discarded – undo
737 737
                     break;
738 738
                 }
739 739
             }
740
-            $this->cleanVars[$k] =& $cleanv;
740
+            $this->cleanVars[$k] = & $cleanv;
741 741
             unset($cleanv);
742 742
         }
743 743
         if (count($this->_errors) > 0) {
@@ -774,7 +774,7 @@  discard block
 block discarded – undo
774 774
             case 's':
775 775
             case 'show':
776 776
             	// ML Hack by marcan
777
-                $ts =& MyTextSanitizer::getInstance();
777
+                $ts = & MyTextSanitizer::getInstance();
778 778
                 $ret = $ts->htmlSpecialChars($ret);
779 779
 
780 780
                 if (method_exists($myts, 'formatForML')) {
@@ -786,7 +786,7 @@  discard block
 block discarded – undo
786 786
             	// End of ML Hack by marcan
787 787
 
788 788
             case 'clean':
789
-				$ts =& MyTextSanitizer::getInstance();
789
+				$ts = & MyTextSanitizer::getInstance();
790 790
 
791 791
 				$ret = smart_html2text($ret);
792 792
 				$ret = smart_purifyText($ret);
@@ -801,14 +801,14 @@  discard block
 block discarded – undo
801 801
 
802 802
             case 'e':
803 803
             case 'edit':
804
-                $ts =& MyTextSanitizer::getInstance();
804
+                $ts = & MyTextSanitizer::getInstance();
805 805
                 return $ts->htmlSpecialChars($ret);
806 806
                 break 1;
807 807
             case 'p':
808 808
             case 'preview':
809 809
             case 'f':
810 810
             case 'formpreview':
811
-                $ts =& MyTextSanitizer::getInstance();
811
+                $ts = & MyTextSanitizer::getInstance();
812 812
                 return $ts->htmlSpecialChars($ts->stripSlashesGPC($ret));
813 813
                 break 1;
814 814
             case 'n':
@@ -884,7 +884,7 @@  discard block
 block discarded – undo
884 884
 			if ($decimal_section) {
885 885
 				if (strlen($decimal_section) == 1) {
886 886
 					$decimal_section = '.00';
887
-				} elseif(strlen($decimal_section) == 2) {
887
+				} elseif (strlen($decimal_section) == 2) {
888 888
 					$decimal_section = $decimal_section . '0';
889 889
 				}
890 890
 				$ret = str_replace($decimal_section_original, $decimal_section, $ret);
@@ -897,7 +897,7 @@  discard block
 block discarded – undo
897 897
             switch (strtolower($format)) {
898 898
             case 's':
899 899
             case 'show':
900
-                $ts =& MyTextSanitizer::getInstance();
900
+                $ts = & MyTextSanitizer::getInstance();
901 901
                 $html = !empty($this->vars['dohtml']['value']) ? 1 : 0;
902 902
 
903 903
                 $xcode = (!isset($this->vars['doxcode']['value']) || $this->vars['doxcode']['value'] == 1) ? 1 : 0;
@@ -926,7 +926,7 @@  discard block
 block discarded – undo
926 926
                 break 1;
927 927
             case 'p':
928 928
             case 'preview':
929
-                $ts =& MyTextSanitizer::getInstance();
929
+                $ts = & MyTextSanitizer::getInstance();
930 930
                 $html = !empty($this->vars['dohtml']['value']) ? 1 : 0;
931 931
                 $xcode = (!isset($this->vars['doxcode']['value']) || $this->vars['doxcode']['value'] == 1) ? 1 : 0;
932 932
                 $smiley = (!isset($this->vars['dosmiley']['value']) || $this->vars['dosmiley']['value'] == 1) ? 1 : 0;
@@ -936,7 +936,7 @@  discard block
 block discarded – undo
936 936
                 break 1;
937 937
             case 'f':
938 938
             case 'formpreview':
939
-                $ts =& MyTextSanitizer::getInstance();
939
+                $ts = & MyTextSanitizer::getInstance();
940 940
                 return htmlspecialchars($ts->stripSlashesGPC($ret), ENT_QUOTES);
941 941
                 break 1;
942 942
             case 'n':
@@ -946,10 +946,10 @@  discard block
 block discarded – undo
946 946
             }
947 947
             break;
948 948
         case XOBJ_DTYPE_SIMPLE_ARRAY:
949
-            $ret =& explode('|', $ret);
949
+            $ret = & explode('|', $ret);
950 950
             break;
951 951
         case XOBJ_DTYPE_ARRAY:
952
-            $ret =& unserialize($ret);
952
+            $ret = & unserialize($ret);
953 953
             break;
954 954
         case XOBJ_DTYPE_SOURCE:
955 955
             switch (strtolower($format)) {
@@ -962,12 +962,12 @@  discard block
 block discarded – undo
962 962
                 break 1;
963 963
             case 'p':
964 964
             case 'preview':
965
-                $ts =& MyTextSanitizer::getInstance();
965
+                $ts = & MyTextSanitizer::getInstance();
966 966
                 return $ts->stripSlashesGPC($ret);
967 967
                 break 1;
968 968
             case 'f':
969 969
             case 'formpreview':
970
-                $ts =& MyTextSanitizer::getInstance();
970
+                $ts = & MyTextSanitizer::getInstance();
971 971
                 return htmlspecialchars($ts->stripSlashesGPC($ret), ENT_QUOTES);
972 972
                 break 1;
973 973
             case 'n':
@@ -1015,7 +1015,7 @@  discard block
 block discarded – undo
1015 1015
 
1016 1016
 	function makeFieldReadOnly($key) {
1017 1017
 		if (is_array($key)) {
1018
-			foreach($key as $v) {
1018
+			foreach ($key as $v) {
1019 1019
 				$this->doMakeFieldreadOnly($v);
1020 1020
 			}
1021 1021
 		} else {
@@ -1037,7 +1037,7 @@  discard block
 block discarded – undo
1037 1037
 
1038 1038
 	function hideFieldFromForm($key) {
1039 1039
 		if (is_array($key)) {
1040
-			foreach($key as $v) {
1040
+			foreach ($key as $v) {
1041 1041
 				$this->doHideFieldFromForm($v);
1042 1042
 			}
1043 1043
 		} else {
@@ -1047,7 +1047,7 @@  discard block
 block discarded – undo
1047 1047
 
1048 1048
 	function hideFieldFromSingleView($key) {
1049 1049
 		if (is_array($key)) {
1050
-			foreach($key as $v) {
1050
+			foreach ($key as $v) {
1051 1051
 				$this->doHideFieldFromSingleView($v);
1052 1052
 			}
1053 1053
 		} else {
@@ -1068,11 +1068,11 @@  discard block
 block discarded – undo
1068 1068
 	 * @param bool $userSide for futur use, to do something different on the user side
1069 1069
 	 * @return content of the template if $fetchOnly or nothing if !$fetchOnly
1070 1070
 	 */
1071
-    function displaySingleObject($fetchOnly=false, $userSide=false, $actions=array(), $headerAsRow=true) {
1072
-		include_once SMARTOBJECT_ROOT_PATH."class/smartobjectsingleview.php";
1071
+    function displaySingleObject($fetchOnly = false, $userSide = false, $actions = array(), $headerAsRow = true) {
1072
+		include_once SMARTOBJECT_ROOT_PATH . "class/smartobjectsingleview.php";
1073 1073
 		$singleview = new SmartObjectSingleView($this, $userSide, $actions, $headerAsRow);
1074 1074
 		// add all fields mark as displayOnSingleView except the keyid
1075
-		foreach($this->vars as $key=>$var) {
1075
+		foreach ($this->vars as $key=>$var) {
1076 1076
 			if ($key != $this->handler->keyName && $var['displayOnSingleView']) {
1077 1077
 				$is_header = ($key == $this->handler->identifierName);
1078 1078
 				$singleview->addRow(new SmartObjectRow($key, false, $is_header));
@@ -1080,9 +1080,9 @@  discard block
 block discarded – undo
1080 1080
 		}
1081 1081
 
1082 1082
 		if ($fetchOnly) {
1083
-			$ret = $singleview->render($fetchOnly);;
1083
+			$ret = $singleview->render($fetchOnly); ;
1084 1084
 			return $ret;
1085
-		}else {
1085
+		} else {
1086 1086
 			$singleview->render($fetchOnly);
1087 1087
 		}
1088 1088
     }
@@ -1093,7 +1093,7 @@  discard block
 block discarded – undo
1093 1093
 		}
1094 1094
 	}
1095 1095
 
1096
-    function doSetFieldAsRequired($field, $required=true) {
1096
+    function doSetFieldAsRequired($field, $required = true) {
1097 1097
 		$this->setVarInfo($field, 'required', $required);
1098 1098
     }
1099 1099
 
@@ -1103,7 +1103,7 @@  discard block
 block discarded – undo
1103 1103
 
1104 1104
 	function showFieldOnForm($key) {
1105 1105
 		if (is_array($key)) {
1106
-			foreach($key as $v) {
1106
+			foreach ($key as $v) {
1107 1107
 				$this->doShowFieldOnForm($v);
1108 1108
 			}
1109 1109
 		} else {
@@ -1113,7 +1113,7 @@  discard block
 block discarded – undo
1113 1113
 
1114 1114
 	function displayFieldOnSingleView($key) {
1115 1115
 		if (is_array($key)) {
1116
-			foreach($key as $v) {
1116
+			foreach ($key as $v) {
1117 1117
 				$this->doDisplayFieldOnSingleView($v);
1118 1118
 			}
1119 1119
 		} else {
@@ -1121,7 +1121,7 @@  discard block
 block discarded – undo
1121 1121
 		}
1122 1122
 	}
1123 1123
 
1124
-	function doSetAdvancedFormFields($key){
1124
+	function doSetAdvancedFormFields($key) {
1125 1125
 		if (isset($this->vars[$key])) {
1126 1126
 			$this->vars[$key]['advancedform'] = true;
1127 1127
 		}
@@ -1129,7 +1129,7 @@  discard block
 block discarded – undo
1129 1129
 
1130 1130
 	function setAdvancedFormFields($key) {
1131 1131
 		if (is_array($key)) {
1132
-			foreach($key as $v) {
1132
+			foreach ($key as $v) {
1133 1133
 				$this->doSetAdvancedFormFields($v);
1134 1134
 			}
1135 1135
 		} else {
@@ -1137,12 +1137,12 @@  discard block
 block discarded – undo
1137 1137
 		}
1138 1138
 	}
1139 1139
 
1140
-	function getUrlLinkObj($key){
1140
+	function getUrlLinkObj($key) {
1141 1141
 		$smartobject_linkurl_handler = xoops_getModuleHandler('urllink', 'smartobject');
1142 1142
 		$urllinkid = $this->getVar($key) != null ? $this->getVar($key) : 0;
1143
-		if($urllinkid != 0){
1143
+		if ($urllinkid != 0) {
1144 1144
 			return  $smartobject_linkurl_handler->get($urllinkid);
1145
-		}else{
1145
+		} else {
1146 1146
 			return $smartobject_linkurl_handler->create();
1147 1147
 		}
1148 1148
 	}
@@ -1152,12 +1152,12 @@  discard block
 block discarded – undo
1152 1152
 		return $smartobject_linkurl_handler->insert($urlLinkObj);
1153 1153
 	}
1154 1154
 
1155
-	function getFileObj($key){
1155
+	function getFileObj($key) {
1156 1156
 		$smartobject_file_handler = xoops_getModuleHandler('file', 'smartobject');
1157 1157
 		$fileid = $this->getVar($key) != null ? $this->getVar($key) : 0;
1158
-		if($fileid != 0){
1158
+		if ($fileid != 0) {
1159 1159
 			return  $smartobject_file_handler->get($fileid);
1160
-		}else{
1160
+		} else {
1161 1161
 			return $smartobject_file_handler->create();
1162 1162
 		}
1163 1163
 	}
Please login to merge, or discard this patch.
Braces   +32 added lines, -14 removed lines patch added patch discarded remove patch
@@ -21,15 +21,33 @@  discard block
 block discarded – undo
21 21
 
22 22
 include_once SMARTOBJECT_ROOT_PATH . "class/smartobjectcontroller.php";
23 23
 
24
-if (!defined('XOBJ_DTYPE_SIMPLE_ARRAY')) define('XOBJ_DTYPE_SIMPLE_ARRAY', 101);
25
-if (!defined('XOBJ_DTYPE_CURRENCY')) define('XOBJ_DTYPE_CURRENCY', 200);
26
-if (!defined('XOBJ_DTYPE_FLOAT')) define('XOBJ_DTYPE_FLOAT', 201);
27
-if (!defined('XOBJ_DTYPE_TIME_ONLY')) define('XOBJ_DTYPE_TIME_ONLY', 202);
28
-if (!defined('XOBJ_DTYPE_URLLINK')) define('XOBJ_DTYPE_URLLINK', 203);
29
-if (!defined('XOBJ_DTYPE_FILE')) define('XOBJ_DTYPE_FILE', 204);
30
-if (!defined('XOBJ_DTYPE_IMAGE')) define('XOBJ_DTYPE_IMAGE', 205);
31
-if (!defined('XOBJ_DTYPE_FORM_SECTION')) define('XOBJ_DTYPE_FORM_SECTION', 210);
32
-if (!defined('XOBJ_DTYPE_FORM_SECTION_CLOSE')) define('XOBJ_DTYPE_FORM_SECTION_CLOSE', 211);
24
+if (!defined('XOBJ_DTYPE_SIMPLE_ARRAY')) {
25
+	define('XOBJ_DTYPE_SIMPLE_ARRAY', 101);
26
+}
27
+if (!defined('XOBJ_DTYPE_CURRENCY')) {
28
+	define('XOBJ_DTYPE_CURRENCY', 200);
29
+}
30
+if (!defined('XOBJ_DTYPE_FLOAT')) {
31
+	define('XOBJ_DTYPE_FLOAT', 201);
32
+}
33
+if (!defined('XOBJ_DTYPE_TIME_ONLY')) {
34
+	define('XOBJ_DTYPE_TIME_ONLY', 202);
35
+}
36
+if (!defined('XOBJ_DTYPE_URLLINK')) {
37
+	define('XOBJ_DTYPE_URLLINK', 203);
38
+}
39
+if (!defined('XOBJ_DTYPE_FILE')) {
40
+	define('XOBJ_DTYPE_FILE', 204);
41
+}
42
+if (!defined('XOBJ_DTYPE_IMAGE')) {
43
+	define('XOBJ_DTYPE_IMAGE', 205);
44
+}
45
+if (!defined('XOBJ_DTYPE_FORM_SECTION')) {
46
+	define('XOBJ_DTYPE_FORM_SECTION', 210);
47
+}
48
+if (!defined('XOBJ_DTYPE_FORM_SECTION_CLOSE')) {
49
+	define('XOBJ_DTYPE_FORM_SECTION_CLOSE', 211);
50
+}
33 51
 
34 52
 /**
35 53
  * SmartObject base class
@@ -482,9 +500,9 @@  discard block
 block discarded – undo
482 500
     function getVarInfo($key = '', $info = '') {
483 501
 		if (isset($this->vars[$key][$info])) {
484 502
 			return $this->vars[$key][$info];
485
-		}elseif ($info == '' && isset($this->vars[$key])) {
503
+		} elseif ($info == '' && isset($this->vars[$key])) {
486 504
 			return $this->vars[$key];
487
-		}  else {
505
+		} else {
488 506
 			return $this->vars;
489 507
 		}
490 508
 	}
@@ -1082,7 +1100,7 @@  discard block
 block discarded – undo
1082 1100
 		if ($fetchOnly) {
1083 1101
 			$ret = $singleview->render($fetchOnly);;
1084 1102
 			return $ret;
1085
-		}else {
1103
+		} else {
1086 1104
 			$singleview->render($fetchOnly);
1087 1105
 		}
1088 1106
     }
@@ -1142,7 +1160,7 @@  discard block
 block discarded – undo
1142 1160
 		$urllinkid = $this->getVar($key) != null ? $this->getVar($key) : 0;
1143 1161
 		if($urllinkid != 0){
1144 1162
 			return  $smartobject_linkurl_handler->get($urllinkid);
1145
-		}else{
1163
+		} else{
1146 1164
 			return $smartobject_linkurl_handler->create();
1147 1165
 		}
1148 1166
 	}
@@ -1157,7 +1175,7 @@  discard block
 block discarded – undo
1157 1175
 		$fileid = $this->getVar($key) != null ? $this->getVar($key) : 0;
1158 1176
 		if($fileid != 0){
1159 1177
 			return  $smartobject_file_handler->get($fileid);
1160
-		}else{
1178
+		} else{
1161 1179
 			return $smartobject_file_handler->create();
1162 1180
 		}
1163 1181
 	}
Please login to merge, or discard this patch.
class/smartobjectcontroller.php 4 patches
Doc Comments   +14 added lines, -7 removed lines patch added patch discarded remove patch
@@ -111,6 +111,11 @@  discard block
 block discarded – undo
111 111
     	}
112 112
     }
113 113
 
114
+    /**
115
+     * @param integer $objectid
116
+     * @param string $created_success_msg
117
+     * @param string $modified_success_msg
118
+     */
114 119
     function &doStoreFromDefaultForm(&$smartObj, $objectid, $created_success_msg, $modified_success_msg, $redirect_page=false, $debug=false)
115 120
     {
116 121
     	global $smart_previous_page;
@@ -193,10 +198,7 @@  discard block
 block discarded – undo
193 198
      *
194 199
      * @param string $created_success_msg message to display if new object was created
195 200
      * @param string $modified_success_msg message to display if object was successfully edited
196
-     * @param string $created_redir_page redirect page after creating the object
197
-     * @param string $modified_redir_page redirect page after editing the object
198 201
      * @param string $redirect_page redirect page, if not set, then we backup once
199
-     * @param bool $exit if set to TRUE then the script ends
200 202
      * @return bool
201 203
      */
202 204
     function &storeFromDefaultForm($created_success_msg, $modified_success_msg, $redirect_page=false, $debug=false, $x_param = false)
@@ -261,8 +263,7 @@  discard block
 block discarded – undo
261 263
     /**
262 264
      * Handles deletion of an object which keyid is passed as a GET param
263 265
      *
264
-     * @param string $redir_page redirect page after deleting the object
265
-     * @return bool
266
+     * @return boolean|null
266 267
      */
267 268
     function handleObjectDeletion($confirm_msg = false, $op='del', $userSide=false)
268 269
     {
@@ -338,7 +339,7 @@  discard block
 block discarded – undo
338 339
     /**
339 340
      * Retreive the object admin side link for a {@link SmartObjectSingleView} page
340 341
      *
341
-     * @param object $smartObj reference to the object from which we want the user side link
342
+     * @param SmartObject $smartObj reference to the object from which we want the user side link
342 343
      * @param bool $onlyUrl wether or not to return a simple URL or a full <a> link
343 344
      * @return string admin side link to the object
344 345
      */
@@ -358,7 +359,7 @@  discard block
 block discarded – undo
358 359
     /**
359 360
      * Retreive the object user side link
360 361
      *
361
-     * @param object $smartObj reference to the object from which we want the user side link
362
+     * @param SmartObject $smartObj reference to the object from which we want the user side link
362 363
      * @param bool $onlyUrl wether or not to return a simple URL or a full <a> link
363 364
      * @return string user side link to the object
364 365
      */
@@ -391,6 +392,9 @@  discard block
 block discarded – undo
391 392
     	return $ret;
392 393
     }
393 394
 
395
+    /**
396
+     * @param SmartMlObject $smartObj
397
+     */
394 398
     function getEditLanguageLink($smartObj, $onlyUrl=false, $withimage=true)
395 399
     {
396 400
     	$ret = $this->handler->_moduleUrl . "admin/" . $this->handler->_page . "?op=mod&" . $this->handler->keyName . "=" . $smartObj->getVar($this->handler->keyName) . "&language=" . $smartObj->getVar('language');
@@ -432,6 +436,9 @@  discard block
 block discarded – undo
432 436
     	return "<a href='" . $ret . "'>" . $smartObj->getVar($this->handler->identifierName) . "</a>";
433 437
     }
434 438
 
439
+    /**
440
+     * @param SmartObject $smartObj
441
+     */
435 442
     function getPrintAndMailLink($smartObj) {
436 443
     	global $xoopsConfig;
437 444
 
Please login to merge, or discard this patch.
Indentation   +208 added lines, -208 removed lines patch added patch discarded remove patch
@@ -31,93 +31,93 @@  discard block
 block discarded – undo
31 31
 include_once XOOPS_ROOT_PATH."/modules/smartobject/class/smartobjecthandler.php";
32 32
 
33 33
 class SmartObjectController {
34
-    var $handler;
35
-    function SmartObjectController($handler) {
36
-        $this->handler=$handler;
37
-    }
38
-
39
-    function postDataToObject(&$smartObj) {
40
-    	foreach(array_keys($smartObj->vars) as $key) {
41
-    		switch ($smartObj->vars[$key]['data_type']) {
42
-    			case XOBJ_DTYPE_IMAGE:
43
-	    			if(isset($_POST['url_'.$key]) && $_POST['url_'.$key] !=''){
44
-	    				$oldFile = $smartObj->getUploadDir(true).$smartObj->getVar($key, 'e');
45
-	    				$smartObj->setVar($key, $_POST['url_'.$key]);
46
-	    				if(file_exists($oldFile)){
47
-		    				unlink($oldFile);
48
-		    			}
49
-	    			}
50
-	    			if(isset($_POST['delete_'.$key]) && $_POST['delete_'.$key] == '1'){
51
-	    				$oldFile = $smartObj->getUploadDir(true).$smartObj->getVar($key, 'e');
52
-	    				$smartObj->setVar($key, '');
53
-	    				if(file_exists($oldFile)){
54
-		    				unlink($oldFile);
55
-		    			}
56
-	    			}
57
-    			break;
58
-
59
-    			case XOBJ_DTYPE_URLLINK:
60
-	    			$linkObj = $smartObj->getUrlLinkObj($key);
61
-	    			$linkObj->setVar('caption', $_POST['caption_'.$key]);
62
-	    			$linkObj->setVar('description', $_POST['desc_'.$key]);
63
-	    			$linkObj->setVar('target', $_POST['target_'.$key]);
64
-	    			$linkObj->setVar('url', $_POST['url_'.$key]);
65
-	    			if($linkObj->getVar('url') != '' ){
66
-	    				$smartObj->storeUrlLinkObj($linkObj);
67
-	    			}
68
-	    			//todo: catch errors
69
-	    			$smartObj->setVar($key, $linkObj->getVar('urllinkid'));
70
-    			break;
71
-
72
-    			case XOBJ_DTYPE_FILE:
73
-	    			if(!isset($_FILES['upload_'.$key]['name']) || $_FILES['upload_'.$key]['name'] == ''){
74
-	    				$fileObj = $smartObj->getFileObj($key);
75
-		    			$fileObj->setVar('caption', $_POST['caption_'.$key]);
76
-		    			$fileObj->setVar('description', $_POST['desc_'.$key]);
77
-		    			$fileObj->setVar('url', $_POST['url_'.$key]);
78
-		    			if(!($fileObj->getVar('url') == '' && $fileObj->getVar('url') == '' && $fileObj->getVar('url') == '')){
79
-		    				$res = $smartObj->storeFileObj($fileObj);
34
+	var $handler;
35
+	function SmartObjectController($handler) {
36
+		$this->handler=$handler;
37
+	}
38
+
39
+	function postDataToObject(&$smartObj) {
40
+		foreach(array_keys($smartObj->vars) as $key) {
41
+			switch ($smartObj->vars[$key]['data_type']) {
42
+				case XOBJ_DTYPE_IMAGE:
43
+					if(isset($_POST['url_'.$key]) && $_POST['url_'.$key] !=''){
44
+						$oldFile = $smartObj->getUploadDir(true).$smartObj->getVar($key, 'e');
45
+						$smartObj->setVar($key, $_POST['url_'.$key]);
46
+						if(file_exists($oldFile)){
47
+							unlink($oldFile);
48
+						}
49
+					}
50
+					if(isset($_POST['delete_'.$key]) && $_POST['delete_'.$key] == '1'){
51
+						$oldFile = $smartObj->getUploadDir(true).$smartObj->getVar($key, 'e');
52
+						$smartObj->setVar($key, '');
53
+						if(file_exists($oldFile)){
54
+							unlink($oldFile);
55
+						}
56
+					}
57
+				break;
58
+
59
+				case XOBJ_DTYPE_URLLINK:
60
+					$linkObj = $smartObj->getUrlLinkObj($key);
61
+					$linkObj->setVar('caption', $_POST['caption_'.$key]);
62
+					$linkObj->setVar('description', $_POST['desc_'.$key]);
63
+					$linkObj->setVar('target', $_POST['target_'.$key]);
64
+					$linkObj->setVar('url', $_POST['url_'.$key]);
65
+					if($linkObj->getVar('url') != '' ){
66
+						$smartObj->storeUrlLinkObj($linkObj);
67
+					}
68
+					//todo: catch errors
69
+					$smartObj->setVar($key, $linkObj->getVar('urllinkid'));
70
+				break;
71
+
72
+				case XOBJ_DTYPE_FILE:
73
+					if(!isset($_FILES['upload_'.$key]['name']) || $_FILES['upload_'.$key]['name'] == ''){
74
+						$fileObj = $smartObj->getFileObj($key);
75
+						$fileObj->setVar('caption', $_POST['caption_'.$key]);
76
+						$fileObj->setVar('description', $_POST['desc_'.$key]);
77
+						$fileObj->setVar('url', $_POST['url_'.$key]);
78
+						if(!($fileObj->getVar('url') == '' && $fileObj->getVar('url') == '' && $fileObj->getVar('url') == '')){
79
+							$res = $smartObj->storeFileObj($fileObj);
80 80
 							if($res){
81
-			    				$smartObj->setVar($key, $fileObj->getVar('fileid'));
81
+								$smartObj->setVar($key, $fileObj->getVar('fileid'));
82 82
 							}else{
83 83
 								//error setted, but no error message (to be improved)
84 84
 								$smartObj->setErrors($fileObj->getErrors());
85 85
 							}
86
-		    			}
87
-	    			}
88
-    			break;
89
-
90
-    			case XOBJ_DTYPE_STIME:
91
-    			case XOBJ_DTYPE_MTIME:
92
-    			case XOBJ_DTYPE_LTIME:
93
-	    			// check if this field's value is available in the POST array
94
-	    			if (is_array($_POST[$key]) && isset($_POST[$key]['date']))  {
95
-	    				$value = strtotime($_POST[$key]['date']) + $_POST[$key]['time'];
96
-	    			}else {
97
-	    				$value = strtotime($_POST[$key]);
98
-	    				//if strtotime returns false, the value is already a time stamp
99
-	    				if(!$value){
100
-	    					$value = intval($_POST[$key]);
101
-	    				}
102
-	    			}	
103
-	    			$smartObj->setVar($key, $value);
86
+						}
87
+					}
88
+				break;
89
+
90
+				case XOBJ_DTYPE_STIME:
91
+				case XOBJ_DTYPE_MTIME:
92
+				case XOBJ_DTYPE_LTIME:
93
+					// check if this field's value is available in the POST array
94
+					if (is_array($_POST[$key]) && isset($_POST[$key]['date']))  {
95
+						$value = strtotime($_POST[$key]['date']) + $_POST[$key]['time'];
96
+					}else {
97
+						$value = strtotime($_POST[$key]);
98
+						//if strtotime returns false, the value is already a time stamp
99
+						if(!$value){
100
+							$value = intval($_POST[$key]);
101
+						}
102
+					}	
103
+					$smartObj->setVar($key, $value);
104 104
 	     			
105
-    			break;
105
+				break;
106 106
 
107
-    			default:
107
+				default:
108 108
 					$smartObj->setVar($key, $_POST[$key]);
109
-    			break;
110
-    		}
111
-    	}
112
-    }
109
+				break;
110
+			}
111
+		}
112
+	}
113 113
 
114
-    function &doStoreFromDefaultForm(&$smartObj, $objectid, $created_success_msg, $modified_success_msg, $redirect_page=false, $debug=false)
115
-    {
116
-    	global $smart_previous_page;
114
+	function &doStoreFromDefaultForm(&$smartObj, $objectid, $created_success_msg, $modified_success_msg, $redirect_page=false, $debug=false)
115
+	{
116
+		global $smart_previous_page;
117 117
 
118 118
 		$this->postDataToObject($smartObj);
119 119
 
120
-    	if ($smartObj->isNew()) {
120
+		if ($smartObj->isNew()) {
121 121
 			$redirect_msg = $created_success_msg;
122 122
 		} else {
123 123
 			$redirect_msg = $modified_success_msg;
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 
126 126
 		// Check if there were uploaded files
127 127
 		if (isset($_POST['smart_upload_image']) || isset($_POST['smart_upload_file'])) {
128
-		    include_once XOOPS_ROOT_PATH."/modules/smartobject/class/smartuploader.php";
128
+			include_once XOOPS_ROOT_PATH."/modules/smartobject/class/smartuploader.php";
129 129
 			$uploaderObj = new SmartUploader($smartObj->getImageDir(true), $this->handler->_allowedMimeTypes, $this->handler->_maxFileSize, $this->handler->_maxWidth, $this->handler->_maxHeight);
130 130
 			foreach ($_FILES as $name=>$file_array) {
131 131
 				if (isset ($file_array['name']) && $file_array['name'] != "" && in_array(str_replace('upload_', '', $name), array_keys($smartObj->vars))) {
@@ -137,16 +137,16 @@  discard block
 block discarded – undo
137 137
 							$uploadedArray[] = $related_field;
138 138
 							//si c'est un fichier Rich
139 139
 							if($smartObj->vars[$related_field]['data_type'] == XOBJ_DTYPE_FILE) {
140
-				    			$object_fileurl = $smartObj->getUploadDir();
141
-				    			$fileObj = $smartObj->getFileObj($related_field);
142
-				    			$fileObj->setVar('url', $object_fileurl.$uploaderObj->getSavedFileName());
143
-				    			$fileObj->setVar('caption', $_POST['caption_'.$related_field]);
144
-	    						$fileObj->setVar('description', $_POST['desc_'.$related_field]);
145
-	    			   			$smartObj->storeFileObj($fileObj);
146
-    							//todo : catch errors
147
-				    			$smartObj->setVar($related_field, $fileObj->getVar('fileid'));
148
-
149
-				    		}else{
140
+								$object_fileurl = $smartObj->getUploadDir();
141
+								$fileObj = $smartObj->getFileObj($related_field);
142
+								$fileObj->setVar('url', $object_fileurl.$uploaderObj->getSavedFileName());
143
+								$fileObj->setVar('caption', $_POST['caption_'.$related_field]);
144
+								$fileObj->setVar('description', $_POST['desc_'.$related_field]);
145
+					   			$smartObj->storeFileObj($fileObj);
146
+								//todo : catch errors
147
+								$smartObj->setVar($related_field, $fileObj->getVar('fileid'));
148
+
149
+							}else{
150 150
 								$old_file = $smartObj->getUploadDir(true).$smartObj->getVar($related_field);
151 151
 								unlink($old_file);
152 152
 								$smartObj->setVar($related_field, $uploaderObj->getSavedFileName());
@@ -186,36 +186,36 @@  discard block
 block discarded – undo
186 186
 
187 187
 			redirect_header($redirect_page, 2, $redirect_msg);
188 188
 		}
189
-    }
190
-
191
-    /**
192
-     * Store the object in the database autmatically from a form sending POST data
193
-     *
194
-     * @param string $created_success_msg message to display if new object was created
195
-     * @param string $modified_success_msg message to display if object was successfully edited
196
-     * @param string $created_redir_page redirect page after creating the object
197
-     * @param string $modified_redir_page redirect page after editing the object
198
-     * @param string $redirect_page redirect page, if not set, then we backup once
199
-     * @param bool $exit if set to TRUE then the script ends
200
-     * @return bool
201
-     */
202
-    function &storeFromDefaultForm($created_success_msg, $modified_success_msg, $redirect_page=false, $debug=false, $x_param = false)
203
-    {
204
-    	$objectid = (isset($_POST[$this->handler->keyName])) ? intval($_POST[$this->handler->keyName]) : 0;
205
-    	if ($debug) {
206
-    		if($x_param){
207
-    			$smartObj = $this->handler->getD($objectid, true,  $x_param);
208
-    		}else{
209
-    			$smartObj = $this->handler->getD($objectid);
210
-    		}
211
-
212
-    	} else {
213
-    		if($x_param){
214
-    			$smartObj = $this->handler->get($objectid, true, false, false, $x_param);
215
-    		}else{
216
-    			$smartObj = $this->handler->get($objectid);
217
-    		}
218
-    	}
189
+	}
190
+
191
+	/**
192
+	 * Store the object in the database autmatically from a form sending POST data
193
+	 *
194
+	 * @param string $created_success_msg message to display if new object was created
195
+	 * @param string $modified_success_msg message to display if object was successfully edited
196
+	 * @param string $created_redir_page redirect page after creating the object
197
+	 * @param string $modified_redir_page redirect page after editing the object
198
+	 * @param string $redirect_page redirect page, if not set, then we backup once
199
+	 * @param bool $exit if set to TRUE then the script ends
200
+	 * @return bool
201
+	 */
202
+	function &storeFromDefaultForm($created_success_msg, $modified_success_msg, $redirect_page=false, $debug=false, $x_param = false)
203
+	{
204
+		$objectid = (isset($_POST[$this->handler->keyName])) ? intval($_POST[$this->handler->keyName]) : 0;
205
+		if ($debug) {
206
+			if($x_param){
207
+				$smartObj = $this->handler->getD($objectid, true,  $x_param);
208
+			}else{
209
+				$smartObj = $this->handler->getD($objectid);
210
+			}
211
+
212
+		} else {
213
+			if($x_param){
214
+				$smartObj = $this->handler->get($objectid, true, false, false, $x_param);
215
+			}else{
216
+				$smartObj = $this->handler->get($objectid);
217
+			}
218
+		}
219 219
 
220 220
 
221 221
 		// if handler is the Multilanguage handler, we will need to treat this for multilanguage
@@ -245,31 +245,31 @@  discard block
 block discarded – undo
245 245
 		} else {
246 246
 			return $this->doStoreFromDefaultForm($smartObj, $objectid, $created_success_msg, $modified_success_msg, $redirect_page, $debug);
247 247
 		}
248
-    }
249
-
250
-    function &storeSmartObjectD() {
251
-    	return $this->storeSmartObject(true);
252
-    }
253
-
254
-    function &storeSmartObject($debug=false, $xparam = false)
255
-    {
256
-    	$ret =& $this->storeFromDefaultForm('', '', null, $debug, $xparam);
257
-
258
-    	return $ret;
259
-    }
260
-
261
-    /**
262
-     * Handles deletion of an object which keyid is passed as a GET param
263
-     *
264
-     * @param string $redir_page redirect page after deleting the object
265
-     * @return bool
266
-     */
267
-    function handleObjectDeletion($confirm_msg = false, $op='del', $userSide=false)
268
-    {
248
+	}
249
+
250
+	function &storeSmartObjectD() {
251
+		return $this->storeSmartObject(true);
252
+	}
253
+
254
+	function &storeSmartObject($debug=false, $xparam = false)
255
+	{
256
+		$ret =& $this->storeFromDefaultForm('', '', null, $debug, $xparam);
257
+
258
+		return $ret;
259
+	}
260
+
261
+	/**
262
+	 * Handles deletion of an object which keyid is passed as a GET param
263
+	 *
264
+	 * @param string $redir_page redirect page after deleting the object
265
+	 * @return bool
266
+	 */
267
+	function handleObjectDeletion($confirm_msg = false, $op='del', $userSide=false)
268
+	{
269 269
 		global $smart_previous_page;
270 270
 
271
-    	$objectid = (isset($_REQUEST[$this->handler->keyName])) ? intval($_REQUEST[$this->handler->keyName]) : 0;
272
-    	$smartObj = $this->handler->get($objectid);
271
+		$objectid = (isset($_REQUEST[$this->handler->keyName])) ? intval($_REQUEST[$this->handler->keyName]) : 0;
272
+		$smartObj = $this->handler->get($objectid);
273 273
 
274 274
 		if ($smartObj->isNew()) {
275 275
 			redirect_header("javascript:history.go(-1)", 3, _CO_SOBJECT_NOT_SELECTED);
@@ -300,13 +300,13 @@  discard block
 block discarded – undo
300 300
 
301 301
 		}
302 302
 		exit();
303
-    }
303
+	}
304 304
 
305
-    function handleObjectDeletionFromUserSide($confirm_msg = false, $op='del') {
305
+	function handleObjectDeletionFromUserSide($confirm_msg = false, $op='del') {
306 306
 		global $smart_previous_page, $xoopsTpl;
307 307
 
308
-    	$objectid = (isset($_REQUEST[$this->handler->keyName])) ? intval($_REQUEST[$this->handler->keyName]) : 0;
309
-    	$smartObj = $this->handler->get($objectid);
308
+		$objectid = (isset($_REQUEST[$this->handler->keyName])) ? intval($_REQUEST[$this->handler->keyName]) : 0;
309
+		$smartObj = $this->handler->get($objectid);
310 310
 
311 311
 		if ($smartObj->isNew()) {
312 312
 			redirect_header("javascript:history.go(-1)", 3, _CO_SOBJECT_NOT_SELECTED);
@@ -333,18 +333,18 @@  discard block
 block discarded – undo
333 333
 			$smartobject_delete_confirm = ob_get_clean();
334 334
 			$xoopsTpl->assign('smartobject_delete_confirm', $smartobject_delete_confirm);
335 335
 		}
336
-    }
337
-
338
-    /**
339
-     * Retreive the object admin side link for a {@link SmartObjectSingleView} page
340
-     *
341
-     * @param object $smartObj reference to the object from which we want the user side link
342
-     * @param bool $onlyUrl wether or not to return a simple URL or a full <a> link
343
-     * @return string admin side link to the object
344
-     */
345
-    function getAdminViewItemLink($smartObj, $onlyUrl=false, $withimage=false)
346
-    {
347
-    	$ret = $this->handler->_moduleUrl . "admin/" . $this->handler->_page . "?op=view&" . $this->handler->keyName . "=" . $smartObj->getVar($this->handler->keyName);
336
+	}
337
+
338
+	/**
339
+	 * Retreive the object admin side link for a {@link SmartObjectSingleView} page
340
+	 *
341
+	 * @param object $smartObj reference to the object from which we want the user side link
342
+	 * @param bool $onlyUrl wether or not to return a simple URL or a full <a> link
343
+	 * @return string admin side link to the object
344
+	 */
345
+	function getAdminViewItemLink($smartObj, $onlyUrl=false, $withimage=false)
346
+	{
347
+		$ret = $this->handler->_moduleUrl . "admin/" . $this->handler->_page . "?op=view&" . $this->handler->keyName . "=" . $smartObj->getVar($this->handler->keyName);
348 348
 		if ($onlyUrl) {
349 349
 			return $ret;
350 350
 		}
@@ -352,48 +352,48 @@  discard block
 block discarded – undo
352 352
 			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>";
353 353
 		}
354 354
 
355
-    	return "<a href='" . $ret . "'>" . $smartObj->getVar($this->handler->identifierName) . "</a>";
356
-    }
357
-
358
-    /**
359
-     * Retreive the object user side link
360
-     *
361
-     * @param object $smartObj reference to the object from which we want the user side link
362
-     * @param bool $onlyUrl wether or not to return a simple URL or a full <a> link
363
-     * @return string user side link to the object
364
-     */
365
-    function getItemLink(&$smartObj, $onlyUrl=false)
366
-    {
367
-        $seoMode = smart_getModuleModeSEO($this->handler->_moduleName);
368
-        $seoModuleName = smart_getModuleNameForSEO($this->handler->_moduleName);
369
-
370
-        /**
371
-         * $seoIncludeId feature is not finished yet, so let's put it always to true
372
-         */
373
-        //$seoIncludeId = smart_getModuleIncludeIdSEO($this->handler->_moduleName);
355
+		return "<a href='" . $ret . "'>" . $smartObj->getVar($this->handler->identifierName) . "</a>";
356
+	}
357
+
358
+	/**
359
+	 * Retreive the object user side link
360
+	 *
361
+	 * @param object $smartObj reference to the object from which we want the user side link
362
+	 * @param bool $onlyUrl wether or not to return a simple URL or a full <a> link
363
+	 * @return string user side link to the object
364
+	 */
365
+	function getItemLink(&$smartObj, $onlyUrl=false)
366
+	{
367
+		$seoMode = smart_getModuleModeSEO($this->handler->_moduleName);
368
+		$seoModuleName = smart_getModuleNameForSEO($this->handler->_moduleName);
369
+
370
+		/**
371
+		 * $seoIncludeId feature is not finished yet, so let's put it always to true
372
+		 */
373
+		//$seoIncludeId = smart_getModuleIncludeIdSEO($this->handler->_moduleName);
374 374
 		$seoIncludeId = true;
375 375
 
376
-        if ($seoMode == 'rewrite') {
377
-	    	$ret = XOOPS_URL . '/' . $seoModuleName .
376
+		if ($seoMode == 'rewrite') {
377
+			$ret = XOOPS_URL . '/' . $seoModuleName .
378 378
 				'.' . $this->handler->_itemname .
379 379
 				($seoIncludeId ? '.'	. $smartObj->getVar($this->handler->keyName) : ''). '/' . $smartObj->getVar('short_url') . '.html';
380
-        } else if ($seoMode == 'pathinfo') {
381
-	    	$ret = SMARTOBJECT_URL . 'seo.php/' . $seoModuleName .
380
+		} else if ($seoMode == 'pathinfo') {
381
+			$ret = SMARTOBJECT_URL . 'seo.php/' . $seoModuleName .
382 382
 				'.' . $this->handler->_itemname .
383 383
 				($seoIncludeId ? '.'	. $smartObj->getVar($this->handler->keyName) : ''). '/' . $smartObj->getVar('short_url') . '.html';
384
-        } else {
385
-    		$ret = $this->handler->_moduleUrl . $this->handler->_page . "?" . $this->handler->keyName . "=" . $smartObj->getVar($this->handler->keyName);
386
-        }
384
+		} else {
385
+			$ret = $this->handler->_moduleUrl . $this->handler->_page . "?" . $this->handler->keyName . "=" . $smartObj->getVar($this->handler->keyName);
386
+		}
387 387
 
388 388
 		if (!$onlyUrl) {
389 389
 			$ret = "<a href='" . $ret . "'>" . $smartObj->getVar($this->handler->identifierName) . "</a>";
390 390
 		}
391
-    	return $ret;
392
-    }
391
+		return $ret;
392
+	}
393 393
 
394
-    function getEditLanguageLink($smartObj, $onlyUrl=false, $withimage=true)
395
-    {
396
-    	$ret = $this->handler->_moduleUrl . "admin/" . $this->handler->_page . "?op=mod&" . $this->handler->keyName . "=" . $smartObj->getVar($this->handler->keyName) . "&language=" . $smartObj->getVar('language');
394
+	function getEditLanguageLink($smartObj, $onlyUrl=false, $withimage=true)
395
+	{
396
+		$ret = $this->handler->_moduleUrl . "admin/" . $this->handler->_page . "?op=mod&" . $this->handler->keyName . "=" . $smartObj->getVar($this->handler->keyName) . "&language=" . $smartObj->getVar('language');
397 397
 		if ($onlyUrl) {
398 398
 			return $ret;
399 399
 		}
@@ -401,13 +401,13 @@  discard block
 block discarded – undo
401 401
 			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>";
402 402
 		}
403 403
 
404
-    	return "<a href='" . $ret . "'>" . $smartObj->getVar($this->handler->identifierName) . "</a>";
405
-    }
404
+		return "<a href='" . $ret . "'>" . $smartObj->getVar($this->handler->identifierName) . "</a>";
405
+	}
406 406
 
407
-    function getEditItemLink($smartObj, $onlyUrl=false, $withimage=true, $userSide=false)
408
-    {
409
-    	$admin_side = $userSide ? '' : 'admin/';
410
-    	$ret = $this->handler->_moduleUrl . $admin_side . $this->handler->_page . "?op=mod&" . $this->handler->keyName . "=" . $smartObj->getVar($this->handler->keyName);
407
+	function getEditItemLink($smartObj, $onlyUrl=false, $withimage=true, $userSide=false)
408
+	{
409
+		$admin_side = $userSide ? '' : 'admin/';
410
+		$ret = $this->handler->_moduleUrl . $admin_side . $this->handler->_page . "?op=mod&" . $this->handler->keyName . "=" . $smartObj->getVar($this->handler->keyName);
411 411
 		if ($onlyUrl) {
412 412
 			return $ret;
413 413
 		}
@@ -415,13 +415,13 @@  discard block
 block discarded – undo
415 415
 			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>";
416 416
 		}
417 417
 
418
-    	return "<a href='" . $ret . "'>" . $smartObj->getVar($this->handler->identifierName) . "</a>";
419
-    }
418
+		return "<a href='" . $ret . "'>" . $smartObj->getVar($this->handler->identifierName) . "</a>";
419
+	}
420 420
 
421
-    function getDeleteItemLink($smartObj, $onlyUrl=false, $withimage=true, $userSide=false)
422
-    {
423
-    	$admin_side = $userSide ? '' : 'admin/';
424
-    	$ret = $this->handler->_moduleUrl . $admin_side . $this->handler->_page . "?op=del&" . $this->handler->keyName . "=" . $smartObj->getVar($this->handler->keyName);
421
+	function getDeleteItemLink($smartObj, $onlyUrl=false, $withimage=true, $userSide=false)
422
+	{
423
+		$admin_side = $userSide ? '' : 'admin/';
424
+		$ret = $this->handler->_moduleUrl . $admin_side . $this->handler->_page . "?op=del&" . $this->handler->keyName . "=" . $smartObj->getVar($this->handler->keyName);
425 425
 		if ($onlyUrl) {
426 426
 			return $ret;
427 427
 		}
@@ -429,13 +429,13 @@  discard block
 block discarded – undo
429 429
 			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>";
430 430
 		}
431 431
 
432
-    	return "<a href='" . $ret . "'>" . $smartObj->getVar($this->handler->identifierName) . "</a>";
433
-    }
432
+		return "<a href='" . $ret . "'>" . $smartObj->getVar($this->handler->identifierName) . "</a>";
433
+	}
434 434
 
435
-    function getPrintAndMailLink($smartObj) {
436
-    	global $xoopsConfig;
435
+	function getPrintAndMailLink($smartObj) {
436
+		global $xoopsConfig;
437 437
 
438
-    	$printlink = $this->handler->_moduleUrl . "print.php?" . $this->handler->keyName . "=" . $smartObj->getVar($this->handler->keyName);
438
+		$printlink = $this->handler->_moduleUrl . "print.php?" . $this->handler->keyName . "=" . $smartObj->getVar($this->handler->keyName);
439 439
 		$js = "javascript:openWithSelfMain('" . $printlink . "', 'smartpopup', 700, 519);";
440 440
 		$printlink = '<a href="' . $js . '"><img  src="' . SMARTOBJECT_IMAGES_ACTIONS_URL . 'fileprint.png" alt="" style="vertical-align: middle;"/></a>';
441 441
 
@@ -446,10 +446,10 @@  discard block
 block discarded – undo
446 446
 
447 447
 		$ret = '<span id="smartobject_print_button">' . $printlink . "&nbsp;</span>" . '<span id="smartobject_mail_button">' . $friendlink . '</span>';
448 448
 		return $ret;
449
-    }
449
+	}
450 450
 
451
-    function getModuleItemString() {
452
-    	$ret = $this->handler->_moduleName . '_' . $this->handler->_itemname;
453
-    	return $ret;
454
-    }
451
+	function getModuleItemString() {
452
+		$ret = $this->handler->_moduleName . '_' . $this->handler->_itemname;
453
+		return $ret;
454
+	}
455 455
 }
456 456
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -27,30 +27,30 @@  discard block
 block discarded – undo
27 27
  * @credit Jan Keller Pedersen <[email protected]> - IDG Danmark A/S <www.idg.dk>
28 28
  * @link http://smartfactory.ca The SmartFactory
29 29
  */
30
-include_once XOOPS_ROOT_PATH."/modules/smartobject/class/smartobject.php";
31
-include_once XOOPS_ROOT_PATH."/modules/smartobject/class/smartobjecthandler.php";
30
+include_once XOOPS_ROOT_PATH . "/modules/smartobject/class/smartobject.php";
31
+include_once XOOPS_ROOT_PATH . "/modules/smartobject/class/smartobjecthandler.php";
32 32
 
33 33
 class SmartObjectController {
34 34
     var $handler;
35 35
     function SmartObjectController($handler) {
36
-        $this->handler=$handler;
36
+        $this->handler = $handler;
37 37
     }
38 38
 
39 39
     function postDataToObject(&$smartObj) {
40
-    	foreach(array_keys($smartObj->vars) as $key) {
40
+    	foreach (array_keys($smartObj->vars) as $key) {
41 41
     		switch ($smartObj->vars[$key]['data_type']) {
42 42
     			case XOBJ_DTYPE_IMAGE:
43
-	    			if(isset($_POST['url_'.$key]) && $_POST['url_'.$key] !=''){
44
-	    				$oldFile = $smartObj->getUploadDir(true).$smartObj->getVar($key, 'e');
45
-	    				$smartObj->setVar($key, $_POST['url_'.$key]);
46
-	    				if(file_exists($oldFile)){
43
+	    			if (isset($_POST['url_' . $key]) && $_POST['url_' . $key] != '') {
44
+	    				$oldFile = $smartObj->getUploadDir(true) . $smartObj->getVar($key, 'e');
45
+	    				$smartObj->setVar($key, $_POST['url_' . $key]);
46
+	    				if (file_exists($oldFile)) {
47 47
 		    				unlink($oldFile);
48 48
 		    			}
49 49
 	    			}
50
-	    			if(isset($_POST['delete_'.$key]) && $_POST['delete_'.$key] == '1'){
51
-	    				$oldFile = $smartObj->getUploadDir(true).$smartObj->getVar($key, 'e');
50
+	    			if (isset($_POST['delete_' . $key]) && $_POST['delete_' . $key] == '1') {
51
+	    				$oldFile = $smartObj->getUploadDir(true) . $smartObj->getVar($key, 'e');
52 52
 	    				$smartObj->setVar($key, '');
53
-	    				if(file_exists($oldFile)){
53
+	    				if (file_exists($oldFile)) {
54 54
 		    				unlink($oldFile);
55 55
 		    			}
56 56
 	    			}
@@ -58,11 +58,11 @@  discard block
 block discarded – undo
58 58
 
59 59
     			case XOBJ_DTYPE_URLLINK:
60 60
 	    			$linkObj = $smartObj->getUrlLinkObj($key);
61
-	    			$linkObj->setVar('caption', $_POST['caption_'.$key]);
62
-	    			$linkObj->setVar('description', $_POST['desc_'.$key]);
63
-	    			$linkObj->setVar('target', $_POST['target_'.$key]);
64
-	    			$linkObj->setVar('url', $_POST['url_'.$key]);
65
-	    			if($linkObj->getVar('url') != '' ){
61
+	    			$linkObj->setVar('caption', $_POST['caption_' . $key]);
62
+	    			$linkObj->setVar('description', $_POST['desc_' . $key]);
63
+	    			$linkObj->setVar('target', $_POST['target_' . $key]);
64
+	    			$linkObj->setVar('url', $_POST['url_' . $key]);
65
+	    			if ($linkObj->getVar('url') != '') {
66 66
 	    				$smartObj->storeUrlLinkObj($linkObj);
67 67
 	    			}
68 68
 	    			//todo: catch errors
@@ -70,16 +70,16 @@  discard block
 block discarded – undo
70 70
     			break;
71 71
 
72 72
     			case XOBJ_DTYPE_FILE:
73
-	    			if(!isset($_FILES['upload_'.$key]['name']) || $_FILES['upload_'.$key]['name'] == ''){
73
+	    			if (!isset($_FILES['upload_' . $key]['name']) || $_FILES['upload_' . $key]['name'] == '') {
74 74
 	    				$fileObj = $smartObj->getFileObj($key);
75
-		    			$fileObj->setVar('caption', $_POST['caption_'.$key]);
76
-		    			$fileObj->setVar('description', $_POST['desc_'.$key]);
77
-		    			$fileObj->setVar('url', $_POST['url_'.$key]);
78
-		    			if(!($fileObj->getVar('url') == '' && $fileObj->getVar('url') == '' && $fileObj->getVar('url') == '')){
75
+		    			$fileObj->setVar('caption', $_POST['caption_' . $key]);
76
+		    			$fileObj->setVar('description', $_POST['desc_' . $key]);
77
+		    			$fileObj->setVar('url', $_POST['url_' . $key]);
78
+		    			if (!($fileObj->getVar('url') == '' && $fileObj->getVar('url') == '' && $fileObj->getVar('url') == '')) {
79 79
 		    				$res = $smartObj->storeFileObj($fileObj);
80
-							if($res){
80
+							if ($res) {
81 81
 			    				$smartObj->setVar($key, $fileObj->getVar('fileid'));
82
-							}else{
82
+							} else {
83 83
 								//error setted, but no error message (to be improved)
84 84
 								$smartObj->setErrors($fileObj->getErrors());
85 85
 							}
@@ -91,12 +91,12 @@  discard block
 block discarded – undo
91 91
     			case XOBJ_DTYPE_MTIME:
92 92
     			case XOBJ_DTYPE_LTIME:
93 93
 	    			// check if this field's value is available in the POST array
94
-	    			if (is_array($_POST[$key]) && isset($_POST[$key]['date']))  {
94
+	    			if (is_array($_POST[$key]) && isset($_POST[$key]['date'])) {
95 95
 	    				$value = strtotime($_POST[$key]['date']) + $_POST[$key]['time'];
96
-	    			}else {
96
+	    			} else {
97 97
 	    				$value = strtotime($_POST[$key]);
98 98
 	    				//if strtotime returns false, the value is already a time stamp
99
-	    				if(!$value){
99
+	    				if (!$value) {
100 100
 	    					$value = intval($_POST[$key]);
101 101
 	    				}
102 102
 	    			}	
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
     	}
112 112
     }
113 113
 
114
-    function &doStoreFromDefaultForm(&$smartObj, $objectid, $created_success_msg, $modified_success_msg, $redirect_page=false, $debug=false)
114
+    function &doStoreFromDefaultForm(&$smartObj, $objectid, $created_success_msg, $modified_success_msg, $redirect_page = false, $debug = false)
115 115
     {
116 116
     	global $smart_previous_page;
117 117
 
@@ -125,29 +125,29 @@  discard block
 block discarded – undo
125 125
 
126 126
 		// Check if there were uploaded files
127 127
 		if (isset($_POST['smart_upload_image']) || isset($_POST['smart_upload_file'])) {
128
-		    include_once XOOPS_ROOT_PATH."/modules/smartobject/class/smartuploader.php";
128
+		    include_once XOOPS_ROOT_PATH . "/modules/smartobject/class/smartuploader.php";
129 129
 			$uploaderObj = new SmartUploader($smartObj->getImageDir(true), $this->handler->_allowedMimeTypes, $this->handler->_maxFileSize, $this->handler->_maxWidth, $this->handler->_maxHeight);
130 130
 			foreach ($_FILES as $name=>$file_array) {
131 131
 				if (isset ($file_array['name']) && $file_array['name'] != "" && in_array(str_replace('upload_', '', $name), array_keys($smartObj->vars))) {
132 132
 					if ($uploaderObj->fetchMedia($name)) {
133
-						$uploaderObj->setTargetFileName(time()."_". $uploaderObj->getMediaName());
133
+						$uploaderObj->setTargetFileName(time() . "_" . $uploaderObj->getMediaName());
134 134
 						if ($uploaderObj->upload()) {
135 135
 							// Find the related field in the SmartObject
136 136
 							$related_field = str_replace('upload_', '', $name);
137 137
 							$uploadedArray[] = $related_field;
138 138
 							//si c'est un fichier Rich
139
-							if($smartObj->vars[$related_field]['data_type'] == XOBJ_DTYPE_FILE) {
139
+							if ($smartObj->vars[$related_field]['data_type'] == XOBJ_DTYPE_FILE) {
140 140
 				    			$object_fileurl = $smartObj->getUploadDir();
141 141
 				    			$fileObj = $smartObj->getFileObj($related_field);
142
-				    			$fileObj->setVar('url', $object_fileurl.$uploaderObj->getSavedFileName());
143
-				    			$fileObj->setVar('caption', $_POST['caption_'.$related_field]);
144
-	    						$fileObj->setVar('description', $_POST['desc_'.$related_field]);
142
+				    			$fileObj->setVar('url', $object_fileurl . $uploaderObj->getSavedFileName());
143
+				    			$fileObj->setVar('caption', $_POST['caption_' . $related_field]);
144
+	    						$fileObj->setVar('description', $_POST['desc_' . $related_field]);
145 145
 	    			   			$smartObj->storeFileObj($fileObj);
146 146
     							//todo : catch errors
147 147
 				    			$smartObj->setVar($related_field, $fileObj->getVar('fileid'));
148 148
 
149
-				    		}else{
150
-								$old_file = $smartObj->getUploadDir(true).$smartObj->getVar($related_field);
149
+				    		} else {
150
+								$old_file = $smartObj->getUploadDir(true) . $smartObj->getVar($related_field);
151 151
 								unlink($old_file);
152 152
 								$smartObj->setVar($related_field, $uploaderObj->getSavedFileName());
153 153
 							}
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 		if ($redirect_page === null) {
179 179
 			return $smartObj;
180 180
 		} else {
181
-			if ( !$storeResult ) {
181
+			if (!$storeResult) {
182 182
 				redirect_header($smart_previous_page, 3, _CO_SOBJECT_SAVE_ERROR . $smartObj->getHtmlErrors());
183 183
 			}
184 184
 
@@ -199,20 +199,20 @@  discard block
 block discarded – undo
199 199
      * @param bool $exit if set to TRUE then the script ends
200 200
      * @return bool
201 201
      */
202
-    function &storeFromDefaultForm($created_success_msg, $modified_success_msg, $redirect_page=false, $debug=false, $x_param = false)
202
+    function &storeFromDefaultForm($created_success_msg, $modified_success_msg, $redirect_page = false, $debug = false, $x_param = false)
203 203
     {
204 204
     	$objectid = (isset($_POST[$this->handler->keyName])) ? intval($_POST[$this->handler->keyName]) : 0;
205 205
     	if ($debug) {
206
-    		if($x_param){
207
-    			$smartObj = $this->handler->getD($objectid, true,  $x_param);
208
-    		}else{
206
+    		if ($x_param) {
207
+    			$smartObj = $this->handler->getD($objectid, true, $x_param);
208
+    		} else {
209 209
     			$smartObj = $this->handler->getD($objectid);
210 210
     		}
211 211
 
212 212
     	} else {
213
-    		if($x_param){
213
+    		if ($x_param) {
214 214
     			$smartObj = $this->handler->get($objectid, true, false, false, $x_param);
215
-    		}else{
215
+    		} else {
216 216
     			$smartObj = $this->handler->get($objectid);
217 217
     		}
218 218
     	}
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 				// This is a new object. We need to store the meta data and then the language data
226 226
 				// First, we will get rid of the multilanguage data to only store the meta data
227 227
 				$smartObj->stripMultilanguageFields();
228
-				$newObject =& $this->doStoreFromDefaultForm($smartObj, $objectid, $created_success_msg, $modified_success_msg, $redirect_page, $debug);
228
+				$newObject = & $this->doStoreFromDefaultForm($smartObj, $objectid, $created_success_msg, $modified_success_msg, $redirect_page, $debug);
229 229
 				/**
230 230
 				 * @todo we need to trap potential errors here
231 231
 				 */
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 
239 239
 				$smartObj->setVar($this->handler->keyName, $newObject->getVar($this->handler->keyName));
240 240
 				$this->handler->changeTableNameForML();
241
-				$ret =& $this->doStoreFromDefaultForm($smartObj, $objectid, $created_success_msg, $modified_success_msg, $redirect_page, $debug);
241
+				$ret = & $this->doStoreFromDefaultForm($smartObj, $objectid, $created_success_msg, $modified_success_msg, $redirect_page, $debug);
242 242
 
243 243
 				return $ret;
244 244
 			}
@@ -251,9 +251,9 @@  discard block
 block discarded – undo
251 251
     	return $this->storeSmartObject(true);
252 252
     }
253 253
 
254
-    function &storeSmartObject($debug=false, $xparam = false)
254
+    function &storeSmartObject($debug = false, $xparam = false)
255 255
     {
256
-    	$ret =& $this->storeFromDefaultForm('', '', null, $debug, $xparam);
256
+    	$ret = & $this->storeFromDefaultForm('', '', null, $debug, $xparam);
257 257
 
258 258
     	return $ret;
259 259
     }
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
      * @param string $redir_page redirect page after deleting the object
265 265
      * @return bool
266 266
      */
267
-    function handleObjectDeletion($confirm_msg = false, $op='del', $userSide=false)
267
+    function handleObjectDeletion($confirm_msg = false, $op = 'del', $userSide = false)
268 268
     {
269 269
 		global $smart_previous_page;
270 270
 
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 
279 279
 		$confirm = (isset($_POST['confirm'])) ? $_POST['confirm'] : 0;
280 280
 		if ($confirm) {
281
-			if( !$this->handler->delete($smartObj)) {
281
+			if (!$this->handler->delete($smartObj)) {
282 282
 				redirect_header($_POST['redirect_page'], 3, _CO_SOBJECT_DELETE_ERROR . $smartObj->getHtmlErrors());
283 283
 				exit;
284 284
 			}
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 				$confirm_msg = _CO_SOBJECT_DELETE_CONFIRM;
295 295
 			}
296 296
 
297
-			xoops_confirm(array('op' => $op, $this->handler->keyName => $smartObj->getVar($this->handler->keyName), 'confirm' => 1, 'redirect_page' => $smart_previous_page), xoops_getenv('PHP_SELF'), sprintf($confirm_msg , $smartObj->getVar($this->handler->identifierName)), _CO_SOBJECT_DELETE);
297
+			xoops_confirm(array('op' => $op, $this->handler->keyName => $smartObj->getVar($this->handler->keyName), 'confirm' => 1, 'redirect_page' => $smart_previous_page), xoops_getenv('PHP_SELF'), sprintf($confirm_msg, $smartObj->getVar($this->handler->identifierName)), _CO_SOBJECT_DELETE);
298 298
 
299 299
 			xoops_cp_footer();
300 300
 
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 		exit();
303 303
     }
304 304
 
305
-    function handleObjectDeletionFromUserSide($confirm_msg = false, $op='del') {
305
+    function handleObjectDeletionFromUserSide($confirm_msg = false, $op = 'del') {
306 306
 		global $smart_previous_page, $xoopsTpl;
307 307
 
308 308
     	$objectid = (isset($_REQUEST[$this->handler->keyName])) ? intval($_REQUEST[$this->handler->keyName]) : 0;
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 
316 316
 		$confirm = (isset($_POST['confirm'])) ? $_POST['confirm'] : 0;
317 317
 		if ($confirm) {
318
-			if( !$this->handler->delete($smartObj)) {
318
+			if (!$this->handler->delete($smartObj)) {
319 319
 				redirect_header($_POST['redirect_page'], 3, _CO_SOBJECT_DELETE_ERROR . $smartObj->getHtmlErrors());
320 320
 				exit;
321 321
 			}
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
 			}
330 330
 
331 331
 			ob_start();
332
-			xoops_confirm(array('op' => $op, $this->handler->keyName => $smartObj->getVar($this->handler->keyName), 'confirm' => 1, 'redirect_page' => $smart_previous_page), xoops_getenv('PHP_SELF'), sprintf($confirm_msg , $smartObj->getVar($this->handler->identifierName)), _CO_SOBJECT_DELETE);
332
+			xoops_confirm(array('op' => $op, $this->handler->keyName => $smartObj->getVar($this->handler->keyName), 'confirm' => 1, 'redirect_page' => $smart_previous_page), xoops_getenv('PHP_SELF'), sprintf($confirm_msg, $smartObj->getVar($this->handler->identifierName)), _CO_SOBJECT_DELETE);
333 333
 			$smartobject_delete_confirm = ob_get_clean();
334 334
 			$xoopsTpl->assign('smartobject_delete_confirm', $smartobject_delete_confirm);
335 335
 		}
@@ -342,13 +342,13 @@  discard block
 block discarded – undo
342 342
      * @param bool $onlyUrl wether or not to return a simple URL or a full <a> link
343 343
      * @return string admin side link to the object
344 344
      */
345
-    function getAdminViewItemLink($smartObj, $onlyUrl=false, $withimage=false)
345
+    function getAdminViewItemLink($smartObj, $onlyUrl = false, $withimage = false)
346 346
     {
347 347
     	$ret = $this->handler->_moduleUrl . "admin/" . $this->handler->_page . "?op=view&" . $this->handler->keyName . "=" . $smartObj->getVar($this->handler->keyName);
348 348
 		if ($onlyUrl) {
349 349
 			return $ret;
350 350
 		}
351
-		elseif($withimage) {
351
+		elseif ($withimage) {
352 352
 			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>";
353 353
 		}
354 354
 
@@ -362,7 +362,7 @@  discard block
 block discarded – undo
362 362
      * @param bool $onlyUrl wether or not to return a simple URL or a full <a> link
363 363
      * @return string user side link to the object
364 364
      */
365
-    function getItemLink(&$smartObj, $onlyUrl=false)
365
+    function getItemLink(&$smartObj, $onlyUrl = false)
366 366
     {
367 367
         $seoMode = smart_getModuleModeSEO($this->handler->_moduleName);
368 368
         $seoModuleName = smart_getModuleNameForSEO($this->handler->_moduleName);
@@ -376,11 +376,11 @@  discard block
 block discarded – undo
376 376
         if ($seoMode == 'rewrite') {
377 377
 	    	$ret = XOOPS_URL . '/' . $seoModuleName .
378 378
 				'.' . $this->handler->_itemname .
379
-				($seoIncludeId ? '.'	. $smartObj->getVar($this->handler->keyName) : ''). '/' . $smartObj->getVar('short_url') . '.html';
379
+				($seoIncludeId ? '.' . $smartObj->getVar($this->handler->keyName) : '') . '/' . $smartObj->getVar('short_url') . '.html';
380 380
         } else if ($seoMode == 'pathinfo') {
381 381
 	    	$ret = SMARTOBJECT_URL . 'seo.php/' . $seoModuleName .
382 382
 				'.' . $this->handler->_itemname .
383
-				($seoIncludeId ? '.'	. $smartObj->getVar($this->handler->keyName) : ''). '/' . $smartObj->getVar('short_url') . '.html';
383
+				($seoIncludeId ? '.' . $smartObj->getVar($this->handler->keyName) : '') . '/' . $smartObj->getVar('short_url') . '.html';
384 384
         } else {
385 385
     		$ret = $this->handler->_moduleUrl . $this->handler->_page . "?" . $this->handler->keyName . "=" . $smartObj->getVar($this->handler->keyName);
386 386
         }
@@ -391,41 +391,41 @@  discard block
 block discarded – undo
391 391
     	return $ret;
392 392
     }
393 393
 
394
-    function getEditLanguageLink($smartObj, $onlyUrl=false, $withimage=true)
394
+    function getEditLanguageLink($smartObj, $onlyUrl = false, $withimage = true)
395 395
     {
396 396
     	$ret = $this->handler->_moduleUrl . "admin/" . $this->handler->_page . "?op=mod&" . $this->handler->keyName . "=" . $smartObj->getVar($this->handler->keyName) . "&language=" . $smartObj->getVar('language');
397 397
 		if ($onlyUrl) {
398 398
 			return $ret;
399 399
 		}
400
-		elseif($withimage) {
400
+		elseif ($withimage) {
401 401
 			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>";
402 402
 		}
403 403
 
404 404
     	return "<a href='" . $ret . "'>" . $smartObj->getVar($this->handler->identifierName) . "</a>";
405 405
     }
406 406
 
407
-    function getEditItemLink($smartObj, $onlyUrl=false, $withimage=true, $userSide=false)
407
+    function getEditItemLink($smartObj, $onlyUrl = false, $withimage = true, $userSide = false)
408 408
     {
409 409
     	$admin_side = $userSide ? '' : 'admin/';
410 410
     	$ret = $this->handler->_moduleUrl . $admin_side . $this->handler->_page . "?op=mod&" . $this->handler->keyName . "=" . $smartObj->getVar($this->handler->keyName);
411 411
 		if ($onlyUrl) {
412 412
 			return $ret;
413 413
 		}
414
-		elseif($withimage) {
414
+		elseif ($withimage) {
415 415
 			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>";
416 416
 		}
417 417
 
418 418
     	return "<a href='" . $ret . "'>" . $smartObj->getVar($this->handler->identifierName) . "</a>";
419 419
     }
420 420
 
421
-    function getDeleteItemLink($smartObj, $onlyUrl=false, $withimage=true, $userSide=false)
421
+    function getDeleteItemLink($smartObj, $onlyUrl = false, $withimage = true, $userSide = false)
422 422
     {
423 423
     	$admin_side = $userSide ? '' : 'admin/';
424 424
     	$ret = $this->handler->_moduleUrl . $admin_side . $this->handler->_page . "?op=del&" . $this->handler->keyName . "=" . $smartObj->getVar($this->handler->keyName);
425 425
 		if ($onlyUrl) {
426 426
 			return $ret;
427 427
 		}
428
-		elseif($withimage) {
428
+		elseif ($withimage) {
429 429
 			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>";
430 430
 		}
431 431
 
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
 		$smartModule = smart_getModuleInfo($smartObj->handler->_moduleName);
443 443
 		$link = smart_getCurrentPage();
444 444
 		$mid = $smartModule->getVar('mid');
445
-		$friendlink = "<a href=\"javascript:openWithSelfMain('".SMARTOBJECT_URL."sendlink.php?link=" . $link . "&amp;mid=" . $mid . "', ',',',',',','sendmessage', 674, 500);\"><img src=\"".SMARTOBJECT_IMAGES_ACTIONS_URL . "mail_send.png\"  alt=\"" . _CO_SOBJECT_EMAIL . "\" title=\"" . _CO_SOBJECT_EMAIL . "\" style=\"vertical-align: middle;\"/></a>";
445
+		$friendlink = "<a href=\"javascript:openWithSelfMain('" . SMARTOBJECT_URL . "sendlink.php?link=" . $link . "&amp;mid=" . $mid . "', ',',',',',','sendmessage', 674, 500);\"><img src=\"" . SMARTOBJECT_IMAGES_ACTIONS_URL . "mail_send.png\"  alt=\"" . _CO_SOBJECT_EMAIL . "\" title=\"" . _CO_SOBJECT_EMAIL . "\" style=\"vertical-align: middle;\"/></a>";
446 446
 
447 447
 		$ret = '<span id="smartobject_print_button">' . $printlink . "&nbsp;</span>" . '<span id="smartobject_mail_button">' . $friendlink . '</span>';
448 448
 		return $ret;
Please login to merge, or discard this patch.
Braces   +9 added lines, -13 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 		    				$res = $smartObj->storeFileObj($fileObj);
80 80
 							if($res){
81 81
 			    				$smartObj->setVar($key, $fileObj->getVar('fileid'));
82
-							}else{
82
+							} else{
83 83
 								//error setted, but no error message (to be improved)
84 84
 								$smartObj->setErrors($fileObj->getErrors());
85 85
 							}
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 	    			// check if this field's value is available in the POST array
94 94
 	    			if (is_array($_POST[$key]) && isset($_POST[$key]['date']))  {
95 95
 	    				$value = strtotime($_POST[$key]['date']) + $_POST[$key]['time'];
96
-	    			}else {
96
+	    			} else {
97 97
 	    				$value = strtotime($_POST[$key]);
98 98
 	    				//if strtotime returns false, the value is already a time stamp
99 99
 	    				if(!$value){
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
     							//todo : catch errors
147 147
 				    			$smartObj->setVar($related_field, $fileObj->getVar('fileid'));
148 148
 
149
-				    		}else{
149
+				    		} else{
150 150
 								$old_file = $smartObj->getUploadDir(true).$smartObj->getVar($related_field);
151 151
 								unlink($old_file);
152 152
 								$smartObj->setVar($related_field, $uploaderObj->getSavedFileName());
@@ -205,14 +205,14 @@  discard block
 block discarded – undo
205 205
     	if ($debug) {
206 206
     		if($x_param){
207 207
     			$smartObj = $this->handler->getD($objectid, true,  $x_param);
208
-    		}else{
208
+    		} else{
209 209
     			$smartObj = $this->handler->getD($objectid);
210 210
     		}
211 211
 
212 212
     	} else {
213 213
     		if($x_param){
214 214
     			$smartObj = $this->handler->get($objectid, true, false, false, $x_param);
215
-    		}else{
215
+    		} else{
216 216
     			$smartObj = $this->handler->get($objectid);
217 217
     		}
218 218
     	}
@@ -347,8 +347,7 @@  discard block
 block discarded – undo
347 347
     	$ret = $this->handler->_moduleUrl . "admin/" . $this->handler->_page . "?op=view&" . $this->handler->keyName . "=" . $smartObj->getVar($this->handler->keyName);
348 348
 		if ($onlyUrl) {
349 349
 			return $ret;
350
-		}
351
-		elseif($withimage) {
350
+		} elseif($withimage) {
352 351
 			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>";
353 352
 		}
354 353
 
@@ -396,8 +395,7 @@  discard block
 block discarded – undo
396 395
     	$ret = $this->handler->_moduleUrl . "admin/" . $this->handler->_page . "?op=mod&" . $this->handler->keyName . "=" . $smartObj->getVar($this->handler->keyName) . "&language=" . $smartObj->getVar('language');
397 396
 		if ($onlyUrl) {
398 397
 			return $ret;
399
-		}
400
-		elseif($withimage) {
398
+		} elseif($withimage) {
401 399
 			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>";
402 400
 		}
403 401
 
@@ -410,8 +408,7 @@  discard block
 block discarded – undo
410 408
     	$ret = $this->handler->_moduleUrl . $admin_side . $this->handler->_page . "?op=mod&" . $this->handler->keyName . "=" . $smartObj->getVar($this->handler->keyName);
411 409
 		if ($onlyUrl) {
412 410
 			return $ret;
413
-		}
414
-		elseif($withimage) {
411
+		} elseif($withimage) {
415 412
 			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>";
416 413
 		}
417 414
 
@@ -424,8 +421,7 @@  discard block
 block discarded – undo
424 421
     	$ret = $this->handler->_moduleUrl . $admin_side . $this->handler->_page . "?op=del&" . $this->handler->keyName . "=" . $smartObj->getVar($this->handler->keyName);
425 422
 		if ($onlyUrl) {
426 423
 			return $ret;
427
-		}
428
-		elseif($withimage) {
424
+		} elseif($withimage) {
429 425
 			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>";
430 426
 		}
431 427
 
Please login to merge, or discard this patch.
class/smartobjecthandler.php 4 patches
Doc Comments   +9 added lines, -4 removed lines patch added patch discarded remove patch
@@ -136,12 +136,12 @@  discard block
 block discarded – undo
136 136
      * Constructor - called from child classes
137 137
      *
138 138
      * @param object $db {@link XoopsDatabase} object
139
-     * @param string $tablename Name of the table use to store this {@link SmartObject}
139
+     * @param string $itemname Name of the table use to store this {@link SmartObject}
140 140
      * @param string Name of the class derived from {@link SmartObject} and which this handler is handling
141 141
      * @param string $keyname Name of the table key that uniquely identify each {@link SmartObject}
142 142
      * @param string $idenfierName Name of the field which properly identify the {@link SmartObject}
143
-     * @param string $page Page name use to basically manage and display the {@link SmartObject}
144
-     * @param string $moduleName name of the module
143
+     * @param string $modulename name of the module
144
+     * @param string $summaryName
145 145
      */
146 146
     function SmartPersistableObjectHandler(&$db, $itemname, $keyname, $idenfierName, $summaryName, $modulename) {
147 147
 
@@ -184,6 +184,9 @@  discard block
 block discarded – undo
184 184
         );
185 185
     }
186 186
 
187
+    /**
188
+     * @param boolean $perm_name
189
+     */
187 190
     function setGrantedObjectsCriteria(&$criteria, $perm_name) {
188 191
         $smartpermissions_handler = new SmartobjectPermissionHandler($this);
189 192
         $grantedItems = $smartpermissions_handler->getGrantedItems($perm_name);
@@ -335,6 +338,9 @@  discard block
 block discarded – undo
335 338
         return $this->convertResultSet($result, $id_as_key, $as_object);
336 339
     }
337 340
 
341
+    /**
342
+     * @param string $sql
343
+     */
338 344
     function query($sql, $criteria, $force=false, $debug=false)
339 345
     {
340 346
         $ret = array();
@@ -848,7 +854,6 @@  discard block
 block discarded – undo
848 854
      * This method will check if the function is available
849 855
      *
850 856
      * @param string $event name of the event
851
-     * @param object $obj $object on which is performed the event
852 857
      * @return mixed result of the execution of the function or FALSE if the function was not executed
853 858
      */
854 859
     function executeEvent($event, &$executeEventObj) {
Please login to merge, or discard this patch.
Indentation   +847 added lines, -847 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 if (!defined("XOOPS_ROOT_PATH")) {
15
-    die("XOOPS root path not defined");
15
+	die("XOOPS root path not defined");
16 16
 }
17 17
 
18 18
 
@@ -30,855 +30,855 @@  discard block
 block discarded – undo
30 30
 
31 31
 class SmartPersistableObjectHandler extends XoopsObjectHandler {
32 32
 
33
-    var $_itemname;
34
-
35
-    /**
36
-     * Name of the table use to store this {@link SmartObject}
37
-     *
38
-     * Note that the name of the table needs to be free of the database prefix.
39
-     * For example "smartsection_categories"
40
-     * @var string
41
-     */
42
-    var $table;
43
-
44
-    /**
45
-     * Name of the table key that uniquely identify each {@link SmartObject}
46
-     *
47
-     * For example : "categoryid"
48
-     * @var string
49
-     */
50
-    var $keyName;
51
-
52
-    /**
53
-     * Name of the class derived from {@link SmartObject} and which this handler is handling
54
-     *
55
-     * Note that this string needs to be lowercase
56
-     *
57
-     * For example : "smartsectioncategory"
58
-     * @var string
59
-     */
60
-    var $className;
61
-
62
-    /**
63
-     * Name of the field which properly identify the {@link SmartObject}
64
-     *
65
-     * For example : "name" (this will be the category's name)
66
-     * @var string
67
-     */
68
-    var $identifierName;
69
-
70
-    /**
71
-     * Name of the field which will be use as a summary for the object
72
-     *
73
-     * For example : "summary"
74
-     * @var string
75
-     */
76
-    var $summaryName;
77
-
78
-    /**
79
-     * Page name use to basically manage and display the {@link SmartObject}
80
-     *
81
-     * This page needs to be the same in user side and admin side
82
-     *
83
-     * For example category.php - we will deduct smartsection/category.php as well as smartsection/admin/category.php
84
-     * @todo this could probably be automatically deducted from the class name - for example, the class SmartsectionCategory will have "category.php" as it's managing page
85
-     * @var string
86
-     */
87
-    var $_page;
88
-
89
-    /**
90
-     * Full path of the module using this {@link SmartObject}
91
-     *
92
-     * <code>XOOPS_URL . "/modules/smartsection/"</code>
93
-     * @todo this could probably be automatically deducted from the class name as it is always prefixed with the module name
94
-     * @var string
95
-     */
96
-    var $_modulePath;
97
-
98
-    var $_moduleUrl;
99
-
100
-    var $_moduleName;
101
-
102
-    var $_uploadUrl;
103
-
104
-    var $_uploadPath;
105
-
106
-    var $_allowedMimeTypes = 0;
107
-
108
-    var $_maxFileSize = 1000000;
109
-
110
-    var $_maxWidth = 500;
111
-
112
-    var $_maxHeight = 500;
113
-
114
-    var $highlightFields = array();
115
-
116
-    /**
117
-     * Array containing the events name and functions
118
-     *
119
-     * @var array
120
-     */
121
-    var $eventArray = array();
122
-
123
-    /**
124
-     * Array containing the permissions that this handler will manage on the objects
125
-     *
126
-     * @var array
127
-     */
128
-    var $permissionsArray = false;
129
-
130
-    var $generalSQL=false;
131
-
132
-    var $_eventHooks=array();
133
-    var $_disabledEvents=array();
134
-
135
-    /**
136
-     * Constructor - called from child classes
137
-     *
138
-     * @param object $db {@link XoopsDatabase} object
139
-     * @param string $tablename Name of the table use to store this {@link SmartObject}
140
-     * @param string Name of the class derived from {@link SmartObject} and which this handler is handling
141
-     * @param string $keyname Name of the table key that uniquely identify each {@link SmartObject}
142
-     * @param string $idenfierName Name of the field which properly identify the {@link SmartObject}
143
-     * @param string $page Page name use to basically manage and display the {@link SmartObject}
144
-     * @param string $moduleName name of the module
145
-     */
146
-    function SmartPersistableObjectHandler(&$db, $itemname, $keyname, $idenfierName, $summaryName, $modulename) {
147
-
148
-        $this->XoopsObjectHandler($db);
149
-
150
-        $this->_itemname = $itemname;
151
-        $this->_moduleName = $modulename;
152
-        $this->table = $db->prefix($modulename . "_" . $itemname);
153
-        $this->keyName = $keyname;
154
-        $this->className = ucfirst($modulename) . ucfirst($itemname);
155
-        $this->identifierName = $idenfierName;
156
-        $this->summaryName = $summaryName;
157
-        $this->_page = $itemname . ".php";
158
-        $this->_modulePath = XOOPS_ROOT_PATH . "/modules/" . $this->_moduleName . "/";
159
-        $this->_moduleUrl = XOOPS_URL . "/modules/" . $this->_moduleName . "/";
160
-        $this->_uploadPath = XOOPS_UPLOAD_PATH . "/" . $this->_moduleName . "/";
161
-        $this->_uploadUrl = XOOPS_UPLOAD_URL . "/" . $this->_moduleName . "/";
162
-    }
163
-
164
-    function addEventHook($event, $method) {
165
-        $this->_eventHooks[$event] = $method;
166
-    }
167
-
168
-    /**
169
-     * Add a permission that this handler will manage for its objects
170
-     *
171
-     * Example : $this->addPermission('view', _AM_SSHOP_CAT_PERM_READ, _AM_SSHOP_CAT_PERM_READ_DSC);
172
-     *
173
-     * @param string $perm_name name of the permission
174
-     * @param string $caption caption of the control that will be displayed in the form
175
-     * @param string $description description of the control that will be displayed in the form
176
-     */
177
-    function addPermission($perm_name, $caption, $description=false) {
178
-        include_once(SMARTOBJECT_ROOT_PATH . 'class/smartobjectpermission.php');
179
-
180
-        $this->permissionsArray[] = array(
33
+	var $_itemname;
34
+
35
+	/**
36
+	 * Name of the table use to store this {@link SmartObject}
37
+	 *
38
+	 * Note that the name of the table needs to be free of the database prefix.
39
+	 * For example "smartsection_categories"
40
+	 * @var string
41
+	 */
42
+	var $table;
43
+
44
+	/**
45
+	 * Name of the table key that uniquely identify each {@link SmartObject}
46
+	 *
47
+	 * For example : "categoryid"
48
+	 * @var string
49
+	 */
50
+	var $keyName;
51
+
52
+	/**
53
+	 * Name of the class derived from {@link SmartObject} and which this handler is handling
54
+	 *
55
+	 * Note that this string needs to be lowercase
56
+	 *
57
+	 * For example : "smartsectioncategory"
58
+	 * @var string
59
+	 */
60
+	var $className;
61
+
62
+	/**
63
+	 * Name of the field which properly identify the {@link SmartObject}
64
+	 *
65
+	 * For example : "name" (this will be the category's name)
66
+	 * @var string
67
+	 */
68
+	var $identifierName;
69
+
70
+	/**
71
+	 * Name of the field which will be use as a summary for the object
72
+	 *
73
+	 * For example : "summary"
74
+	 * @var string
75
+	 */
76
+	var $summaryName;
77
+
78
+	/**
79
+	 * Page name use to basically manage and display the {@link SmartObject}
80
+	 *
81
+	 * This page needs to be the same in user side and admin side
82
+	 *
83
+	 * For example category.php - we will deduct smartsection/category.php as well as smartsection/admin/category.php
84
+	 * @todo this could probably be automatically deducted from the class name - for example, the class SmartsectionCategory will have "category.php" as it's managing page
85
+	 * @var string
86
+	 */
87
+	var $_page;
88
+
89
+	/**
90
+	 * Full path of the module using this {@link SmartObject}
91
+	 *
92
+	 * <code>XOOPS_URL . "/modules/smartsection/"</code>
93
+	 * @todo this could probably be automatically deducted from the class name as it is always prefixed with the module name
94
+	 * @var string
95
+	 */
96
+	var $_modulePath;
97
+
98
+	var $_moduleUrl;
99
+
100
+	var $_moduleName;
101
+
102
+	var $_uploadUrl;
103
+
104
+	var $_uploadPath;
105
+
106
+	var $_allowedMimeTypes = 0;
107
+
108
+	var $_maxFileSize = 1000000;
109
+
110
+	var $_maxWidth = 500;
111
+
112
+	var $_maxHeight = 500;
113
+
114
+	var $highlightFields = array();
115
+
116
+	/**
117
+	 * Array containing the events name and functions
118
+	 *
119
+	 * @var array
120
+	 */
121
+	var $eventArray = array();
122
+
123
+	/**
124
+	 * Array containing the permissions that this handler will manage on the objects
125
+	 *
126
+	 * @var array
127
+	 */
128
+	var $permissionsArray = false;
129
+
130
+	var $generalSQL=false;
131
+
132
+	var $_eventHooks=array();
133
+	var $_disabledEvents=array();
134
+
135
+	/**
136
+	 * Constructor - called from child classes
137
+	 *
138
+	 * @param object $db {@link XoopsDatabase} object
139
+	 * @param string $tablename Name of the table use to store this {@link SmartObject}
140
+	 * @param string Name of the class derived from {@link SmartObject} and which this handler is handling
141
+	 * @param string $keyname Name of the table key that uniquely identify each {@link SmartObject}
142
+	 * @param string $idenfierName Name of the field which properly identify the {@link SmartObject}
143
+	 * @param string $page Page name use to basically manage and display the {@link SmartObject}
144
+	 * @param string $moduleName name of the module
145
+	 */
146
+	function SmartPersistableObjectHandler(&$db, $itemname, $keyname, $idenfierName, $summaryName, $modulename) {
147
+
148
+		$this->XoopsObjectHandler($db);
149
+
150
+		$this->_itemname = $itemname;
151
+		$this->_moduleName = $modulename;
152
+		$this->table = $db->prefix($modulename . "_" . $itemname);
153
+		$this->keyName = $keyname;
154
+		$this->className = ucfirst($modulename) . ucfirst($itemname);
155
+		$this->identifierName = $idenfierName;
156
+		$this->summaryName = $summaryName;
157
+		$this->_page = $itemname . ".php";
158
+		$this->_modulePath = XOOPS_ROOT_PATH . "/modules/" . $this->_moduleName . "/";
159
+		$this->_moduleUrl = XOOPS_URL . "/modules/" . $this->_moduleName . "/";
160
+		$this->_uploadPath = XOOPS_UPLOAD_PATH . "/" . $this->_moduleName . "/";
161
+		$this->_uploadUrl = XOOPS_UPLOAD_URL . "/" . $this->_moduleName . "/";
162
+	}
163
+
164
+	function addEventHook($event, $method) {
165
+		$this->_eventHooks[$event] = $method;
166
+	}
167
+
168
+	/**
169
+	 * Add a permission that this handler will manage for its objects
170
+	 *
171
+	 * Example : $this->addPermission('view', _AM_SSHOP_CAT_PERM_READ, _AM_SSHOP_CAT_PERM_READ_DSC);
172
+	 *
173
+	 * @param string $perm_name name of the permission
174
+	 * @param string $caption caption of the control that will be displayed in the form
175
+	 * @param string $description description of the control that will be displayed in the form
176
+	 */
177
+	function addPermission($perm_name, $caption, $description=false) {
178
+		include_once(SMARTOBJECT_ROOT_PATH . 'class/smartobjectpermission.php');
179
+
180
+		$this->permissionsArray[] = array(
181 181
    			'perm_name' => $perm_name,
182 182
    			'caption' => $caption,
183 183
    			'description' => $description
184
-        );
185
-    }
186
-
187
-    function setGrantedObjectsCriteria(&$criteria, $perm_name) {
188
-        $smartpermissions_handler = new SmartobjectPermissionHandler($this);
189
-        $grantedItems = $smartpermissions_handler->getGrantedItems($perm_name);
190
-        if (count($grantedItems) > 0) {
191
-            $criteria->add(new Criteria($this->keyName, '(' . implode(', ', $grantedItems) . ')', 'IN'));
192
-            return true;
193
-        } else {
194
-            return false;
195
-        }
196
-    }
197
-
198
-    function setUploaderConfig($_uploadPath=false, $_allowedMimeTypes=false, $_maxFileSize=false, $_maxWidth=false, $_maxHeight=false) {
199
-        $this->_uploadPath = $_uploadPath ? $_uploadPath : $this->_uploadPath;
200
-        $this->_allowedMimeTypes = $_allowedMimeTypes ? $_allowedMimeTypes : $this->_allowedMimeTypes;
201
-        $this->_maxFileSize = $_maxFileSize ? $_maxFileSize : $this->_maxFileSize;
202
-        $this->_maxWidth = $_maxWidth ? $_maxWidth : $this->_maxWidth;
203
-        $this->_maxHeight = $_maxHeight ? $_maxHeight : $this->_maxHeight;
204
-    }
205
-
206
-    /**
207
-     * create a new {@link SmartObject}
208
-     *
209
-     * @param bool $isNew Flag the new objects as "new"?
210
-     *
211
-     * @return object {@link SmartObject}
212
-     */
213
-    function &create($isNew = true) {
214
-        $obj = new $this->className($this);
215
-        $obj->setImageDir($this->getImageUrl(), $this->getImagePath());
216
-        if (!$obj->handler) {
217
-            $obj->handler =& $this;
218
-        }
219
-
220
-        if ($isNew === true) {
221
-            $obj->setNew();
222
-        }
223
-        return $obj;
224
-    }
225
-
226
-    function getImageUrl() {
227
-        return $this->_uploadUrl . $this->_itemname . "/";
228
-    }
229
-
230
-    function getImagePath() {
231
-        $dir = $this->_uploadPath . $this->_itemname;
232
-        if (!file_exists($dir)) {
233
-            smart_admin_mkdir($dir);
234
-        }
235
-        return $dir . "/";
236
-    }
237
-
238
-    /**
239
-     * retrieve a {@link SmartObject}
240
-     *
241
-     * @param mixed $id ID of the object - or array of ids for joint keys. Joint keys MUST be given in the same order as in the constructor
242
-     * @param bool $as_object whether to return an object or an array
243
-     * @return mixed reference to the {@link SmartObject}, FALSE if failed
244
-     */
245
-    function &get($id, $as_object = true, $debug=false, $criteria=false) {
246
-        if (!$criteria) {
247
-            $criteria = new CriteriaCompo();
248
-        }
249
-        if (is_array($this->keyName)) {
250
-            for ($i = 0; $i < count($this->keyName); $i++) {
251
-                /**
252
-                 * In some situations, the $id is not an INTEGER. SmartObjectTag is an example.
253
-                 * Is the fact that we removed the intval() represents a security risk ?
254
-                 */
255
-                //$criteria->add(new Criteria($this->keyName[$i], ($id[$i]), '=', $this->_itemname));
256
-                $criteria->add(new Criteria($this->keyName[$i], $id[$i], '=', $this->_itemname));
257
-            }
258
-        }
259
-        else {
260
-            //$criteria = new Criteria($this->keyName, intval($id), '=', $this->_itemname);
261
-            /**
262
-            * In some situations, the $id is not an INTEGER. SmartObjectTag is an example.
263
-            * Is the fact that we removed the intval() represents a security risk ?
264
-            */
265
-            $criteria->add(new Criteria($this->keyName, $id, '=', $this->_itemname));
266
-        }
267
-        $criteria->setLimit(1);
268
-        if ($debug) {
269
-            $obj_array = $this->getObjectsD($criteria, false, $as_object);
270
-        } else {
271
-            $obj_array = $this->getObjects($criteria, false, $as_object);
272
-            //patch : weird bug of indexing by id even if id_as_key = false;
273
-            if(!isset($obj_array[0]) && is_object($obj_array[$id])){
274
-                $obj_array[0] = $obj_array[$id];
275
-                unset($obj_array[$id]);
276
-                $obj_array[0]->unsetNew();
277
-            }
278
-        }
279
-
280
-        if (count($obj_array) != 1) {
281
-            $obj = $this->create();
282
-            return $obj;
283
-        }
284
-
285
-        return $obj_array[0];
286
-    }
287
-
288
-    /**
289
-     * retrieve a {@link SmartObject}
290
-     *
291
-     * @param mixed $id ID of the object - or array of ids for joint keys. Joint keys MUST be given in the same order as in the constructor
292
-     * @param bool $as_object whether to return an object or an array
293
-     * @return mixed reference to the {@link SmartObject}, FALSE if failed
294
-     */
295
-    function &getD($id, $as_object = true) {
296
-        return $this->get($id, $as_object, true);
297
-    }
298
-
299
-    /**
300
-     * retrieve objects from the database
301
-     *
302
-     * @param object $criteria {@link CriteriaElement} conditions to be met
303
-     * @param bool $id_as_key use the ID as key for the array?
304
-     * @param bool $as_object return an array of objects?
305
-     *
306
-     * @return array
307
-     */
308
-    function getObjects($criteria = null, $id_as_key = false, $as_object = true, $sql=false, $debug=false)
309
-    {
310
-        $ret = array();
311
-        $limit = $start = 0;
312
-
313
-        if ($this->generalSQL) {
314
-            $sql = $this->generalSQL;
315
-        } elseif(!$sql) {
316
-            $sql = 'SELECT * FROM '.$this->table . " AS " . $this->_itemname;
317
-        }
318
-
319
-        if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
320
-            $sql .= ' '.$criteria->renderWhere();
321
-            if ($criteria->getSort() != '') {
322
-                $sql .= ' ORDER BY '.$criteria->getSort().' '.$criteria->getOrder();
323
-            }
324
-            $limit = $criteria->getLimit();
325
-            $start = $criteria->getStart();
326
-        }
327
-        if ($debug) {
328
-            xoops_debug($sql);
329
-        }
330
-
331
-        $result = $this->db->query($sql, $limit, $start);
332
-        if (!$result) {
333
-            return $ret;
334
-        }
335
-        return $this->convertResultSet($result, $id_as_key, $as_object);
336
-    }
337
-
338
-    function query($sql, $criteria, $force=false, $debug=false)
339
-    {
340
-        $ret = array();
341
-
342
-        if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
343
-            $sql .= ' '.$criteria->renderWhere();
344
-            if ($criteria->groupby) {
345
-                $sql .= $criteria->getGroupby();
346
-            }
347
-            if ($criteria->getSort() != '') {
348
-                $sql .= ' ORDER BY '.$criteria->getSort().' '.$criteria->getOrder();
349
-            }
350
-
351
-        }
352
-        if ($debug) {
353
-            xoops_debug($sql);
354
-        }
355
-
356
-        if ($force) {
357
-            $result = $this->db->queryF($sql);
358
-        } else {
359
-            $result = $this->db->query($sql);
360
-        }
361
-
362
-        if (!$result) {
363
-            return $ret;
364
-        }
365
-
366
-        while ($myrow = $this->db->fetchArray($result)) {
367
-            $ret[] = $myrow;
368
-        }
369
-
370
-        return $ret;
371
-    }
372
-
373
-    /**
374
-     * retrieve objects with debug mode - so will show the query
375
-     *
376
-     * @param object $criteria {@link CriteriaElement} conditions to be met
377
-     * @param bool $id_as_key use the ID as key for the array?
378
-     * @param bool $as_object return an array of objects?
379
-     *
380
-     * @return array
381
-     */
382
-    function getObjectsD($criteria = null, $id_as_key = false, $as_object = true, $sql = false)
383
-    {
384
-        return $this->getObjects($criteria, $id_as_key, $as_object, $sql, true);
385
-    }
386
-
387
-    function getObjectsAsArray($arrayObjects) {
388
-        $ret = array();
389
-        foreach ($arrayObjects as $key => $object) {
390
-            $ret[$key] = $object->toArray();
391
-        }
392
-        if (count($ret > 0)) {
393
-            return $ret;
394
-        } else {
395
-            return false;
396
-        }
397
-    }
398
-
399
-    /**
400
-     * Convert a database resultset to a returnable array
401
-     *
402
-     * @param object $result database resultset
403
-     * @param bool $id_as_key - should NOT be used with joint keys
404
-     * @param bool $as_object
405
-     *
406
-     * @return array
407
-     */
408
-    function convertResultSet($result, $id_as_key = false, $as_object = true) {
409
-        $ret = array();
410
-        while ($myrow = $this->db->fetchArray($result)) {
411
-
412
-            $obj =& $this->create(false);
413
-            $obj->assignVars($myrow);
414
-            if (!$id_as_key) {
415
-                if ($as_object) {
416
-                    $ret[] =& $obj;
417
-                }
418
-                else {
419
-                    $ret[] = $obj->toArray();
420
-                }
421
-            } else {
422
-                if ($as_object) {
423
-                    $value =& $obj;
424
-                }
425
-                else {
426
-                    $value = $obj->toArray();
427
-                }
428
-                if ($id_as_key === 'parentid') {
429
-                    $ret[$obj->getVar('parentid', 'e')][$obj->getVar($this->keyName)] =& $value;
430
-                } else {
431
-                    $ret[$obj->getVar($this->keyName)] = $value;
432
-                }
433
-            }
434
-            unset($obj);
435
-        }
436
-
437
-        return $ret;
438
-    }
439
-
440
-    function getListD($criteria = null, $limit = 0, $start = 0) {
441
-        return $this->getList($criteria, $limit, $start, true);
442
-    }
443
-
444
-    /**
445
-     * Retrieve a list of objects as arrays - DON'T USE WITH JOINT KEYS
446
-     *
447
-     * @param object $criteria {@link CriteriaElement} conditions to be met
448
-     * @param int   $limit      Max number of objects to fetch
449
-     * @param int   $start      Which record to start at
450
-     *
451
-     * @return array
452
-     */
453
-    function getList($criteria = null, $limit = 0, $start = 0, $debug=false) {
454
-        $ret = array();
455
-        if ($criteria == null) {
456
-            $criteria = new CriteriaCompo();
457
-        }
458
-
459
-        if ($criteria->getSort() == '') {
460
-            $criteria->setSort($this->getIdentifierName());
461
-        }
462
-
463
-        $sql = 'SELECT '.(is_array($this->keyName) ? implode(', ', $this->keyName) : $this->keyName) ;
464
-        if(!empty($this->identifierName)){
465
-            $sql .= ', '.$this->getIdentifierName();
466
-        }
467
-        $sql .= ' FROM '.$this->table . " AS " . $this->_itemname;
468
-        if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
469
-            $sql .= ' '.$criteria->renderWhere();
470
-            if ($criteria->getSort() != '') {
471
-                $sql .= ' ORDER BY '.$criteria->getSort().' '.$criteria->getOrder();
472
-            }
473
-            $limit = $criteria->getLimit();
474
-            $start = $criteria->getStart();
475
-        }
476
-
477
-        if ($debug) {
478
-            xoops_debug($sql);
479
-        }
480
-
481
-        $result = $this->db->query($sql, $limit, $start);
482
-        if (!$result) {
483
-            return $ret;
484
-        }
485
-
486
-        $myts =& MyTextSanitizer::getInstance();
487
-        while ($myrow = $this->db->fetchArray($result)) {
488
-            //identifiers should be textboxes, so sanitize them like that
489
-            $ret[$myrow[$this->keyName]] = empty($this->identifierName)?1:$myts->displayTarea($myrow[$this->identifierName]);
490
-        }
491
-        return $ret;
492
-    }
493
-
494
-    /**
495
-     * count objects matching a condition
496
-     *
497
-     * @param object $criteria {@link CriteriaElement} to match
498
-     * @return int count of objects
499
-     */
500
-    function getCount($criteria = null)
501
-    {
502
-        $field = "";
503
-        $groupby = false;
504
-        if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
505
-            if ($criteria->groupby != "") {
506
-                $groupby = true;
507
-                $field = $criteria->groupby.", "; //Not entirely secure unless you KNOW that no criteria's groupby clause is going to be mis-used
508
-            }
509
-        }
510
-        /**
511
-         * if we have a generalSQL, lets used this one.
512
-         * This needs to be improved...
513
-         */
514
-        if ($this->generalSQL) {
515
-            $sql = $this->generalSQL;
516
-            $sql = str_replace('SELECT *', 'SELECT COUNT(*)', $sql);
517
-        } else {
518
-            $sql = 'SELECT '.$field.'COUNT(*) FROM '.$this->table . ' AS ' . $this->_itemname;
519
-        }
520
-        if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
521
-            $sql .= ' '.$criteria->renderWhere();
522
-            if ($criteria->groupby != "") {
523
-                $sql .= $criteria->getGroupby();
524
-            }
525
-        }
526
-
527
-        $result = $this->db->query($sql);
528
-        if (!$result) {
529
-            return 0;
530
-        }
531
-        if ($groupby == false) {
532
-            list($count) = $this->db->fetchRow($result);
533
-            return $count;
534
-        }
535
-        else {
536
-            $ret = array();
537
-            while (list($id, $count) = $this->db->fetchRow($result)) {
538
-                $ret[$id] = $count;
539
-            }
540
-            return $ret;
541
-        }
542
-    }
543
-
544
-    /**
545
-     * delete an object from the database
546
-     *
547
-     * @param object $obj reference to the object to delete
548
-     * @param bool $force
549
-     * @return bool FALSE if failed.
550
-     */
551
-    function delete(&$obj, $force = false)
552
-    {
553
-        $eventResult = $this->executeEvent('beforeDelete', $obj);
554
-        if (!$eventResult) {
555
-            $obj->setErrors("An error occured during the BeforeDelete event");
556
-            return false;
557
-        }
558
-
559
-        if (is_array($this->keyName)) {
560
-            $clause = array();
561
-            for ($i = 0; $i < count($this->keyName); $i++) {
562
-                $clause[] = $this->keyName[$i]." = ".$obj->getVar($this->keyName[$i]);
563
-            }
564
-            $whereclause = implode(" AND ", $clause);
565
-        }
566
-        else {
567
-            $whereclause = $this->keyName." = ".$obj->getVar($this->keyName);
568
-        }
569
-        $sql = "DELETE FROM ".$this->table . " WHERE ".$whereclause;
570
-        if (false != $force) {
571
-            $result = $this->db->queryF($sql);
572
-        } else {
573
-            $result = $this->db->query($sql);
574
-        }
575
-        if (!$result) {
576
-            return false;
577
-        }
578
-
579
-        $eventResult = $this->executeEvent('afterDelete', $obj);
580
-        if (!$eventResult) {
581
-            $obj->setErrors("An error occured during the AfterDelete event");
582
-            return false;
583
-        }
584
-        return true;
585
-    }
586
-
587
-    function disableEvent($event) {
588
-        if (is_array($event)) {
589
-            foreach($event as $v) {
590
-                $this->_disabledEvents[] = $v;
591
-            }
592
-        } else {
593
-            $this->_disabledEvents[] = $event;
594
-        }
595
-    }
596
-
597
-    function getPermissions() {
598
-        return $this->permissionsArray;
599
-    }
600
-
601
-    /**
602
-     * insert a new object in the database
603
-     *
604
-     * @param object $obj reference to the object
605
-     * @param bool $force whether to force the query execution despite security settings
606
-     * @param bool $checkObject check if the object is dirty and clean the attributes
607
-     * @return bool FALSE if failed, TRUE if already present and unchanged or successful
608
-     */
609
-    function insert(&$obj, $force = false, $checkObject = true, $debug=false)
610
-    {
611
-        if ($checkObject != false) {
612
-            if (!is_object($obj)) {
613
-                return false;
614
-            }
615
-            /**
616
-             * @TODO: Change to if (!(class_exists($this->className) && $obj instanceof $this->className)) when going fully PHP5
617
-             */
618
-            if (!is_a($obj, $this->className)) {
619
-                $obj->setError(get_class($obj)." Differs from ".$this->className);
620
-                return false;
621
-            }
622
-            if (!$obj->isDirty()) {
623
-                $obj->setErrors("Not dirty"); //will usually not be outputted as errors are not displayed when the method returns true, but it can be helpful when troubleshooting code - Mith
624
-                return true;
625
-            }
626
-        }
627
-
628
-        if ($obj->seoEnabled) {
629
-            // Auto create meta tags if empty
630
-            $smartobject_metagen = new SmartMetagen($obj->title(), $obj->getVar('meta_keywords'), $obj->summary());
631
-
632
-            if (!$obj->getVar('meta_keywords') || !$obj->getVar('meta_description')) {
633
-
634
-                if (!$obj->meta_keywords()) {
635
-                    $obj->setVar('meta_keywords', $smartobject_metagen->_keywords);
636
-                }
637
-
638
-                if (!$obj->meta_description()) {
639
-                    $obj->setVar('meta_description', $smartobject_metagen->_meta_description);
640
-                }
641
-            }
642
-
643
-            // Auto create short_url if empty
644
-            if (!$obj->short_url()) {
645
-                $obj->setVar('short_url', $smartobject_metagen->generateSeoTitle($obj->title('n'), false));
646
-            }
647
-        }
648
-
649
-        $eventResult = $this->executeEvent('beforeSave', $obj);
650
-        if (!$eventResult) {
651
-            $obj->setErrors("An error occured during the BeforeSave event");
652
-            return false;
653
-        }
654
-
655
-        if ($obj->isNew()) {
656
-            $eventResult = $this->executeEvent('beforeInsert', $obj);
657
-            if (!$eventResult) {
658
-                $obj->setErrors("An error occured during the BeforeInsert event");
659
-                return false;
660
-            }
661
-
662
-        }	else {
663
-            $eventResult = $this->executeEvent('beforeUpdate', $obj);
664
-            if (!$eventResult) {
665
-                $obj->setErrors("An error occured during the BeforeUpdate event");
666
-                return false;
667
-            }
668
-        }
669
-        if (!$obj->cleanVars()) {
670
-            $obj->setErrors('Variables were not cleaned properly.');
671
-            return false;
672
-        }
673
-        $fieldsToStoreInDB = array();
674
-        foreach ($obj->cleanVars as $k => $v) {
675
-            if ($obj->vars[$k]['data_type'] == XOBJ_DTYPE_INT) {
676
-                $cleanvars[$k] = intval($v);
677
-            } elseif (is_array($v) ) {
678
-                $cleanvars[ $k ] = $this->db->quoteString( implode( ',', $v ) );
679
-            } else {
680
-                $cleanvars[$k] = $this->db->quoteString($v);
681
-            }
682
-            if ($obj->vars[$k]['persistent']) {
683
-                $fieldsToStoreInDB[$k] = $cleanvars[$k];
684
-            }
685
-
686
-        }
687
-        if ($obj->isNew()) {
688
-            if (!is_array($this->keyName)) {
689
-                if ($cleanvars[$this->keyName] < 1) {
690
-                    $cleanvars[$this->keyName] = $this->db->genId($this->table.'_'.$this->keyName.'_seq');
691
-                }
692
-            }
693
-
694
-            $sql = "INSERT INTO ".$this->table." (".implode(',', array_keys($fieldsToStoreInDB)).") VALUES (".implode(',', array_values($fieldsToStoreInDB)) .")";
695
-
696
-        } else {
697
-
698
-            $sql = "UPDATE ".$this->table." SET";
699
-            foreach ($fieldsToStoreInDB as $key => $value) {
700
-                if ((!is_array($this->keyName) && $key == $this->keyName) || (is_array($this->keyName) && in_array($key, $this->keyName))) {
701
-                    continue;
702
-                }
703
-                if (isset($notfirst) ) {
704
-                    $sql .= ",";
705
-                }
706
-                $sql .= " ".$key." = ".$value;
707
-                $notfirst = true;
708
-            }
709
-            if (is_array($this->keyName)) {
710
-                $whereclause = "";
711
-                for ($i = 0; $i < count($this->keyName); $i++) {
712
-                    if ($i > 0) {
713
-                        $whereclause .= " AND ";
714
-                    }
715
-                    $whereclause .= $this->keyName[$i]." = ".$obj->getVar($this->keyName[$i]);
716
-                }
717
-            }
718
-            else {
719
-                $whereclause = $this->keyName." = ".$obj->getVar($this->keyName);
720
-            }
721
-            $sql .= " WHERE ".$whereclause;
722
-        }
723
-
724
-        if ($debug) {
725
-            xoops_debug($sql);
726
-        }
727
-
728
-        if (false != $force) {
729
-            $result = $this->db->queryF($sql);
730
-        } else {
731
-            $result = $this->db->query($sql);
732
-        }
733
-
734
-        if (!$result) {
735
-            $obj->setErrors($this->db->error());
736
-            return false;
737
-        }
738
-
739
-        if ($obj->isNew() && !is_array($this->keyName)) {
740
-            $obj->assignVar($this->keyName, $this->db->getInsertId());
741
-        }
742
-        $eventResult = $this->executeEvent('afterSave', $obj);
743
-        if (!$eventResult) {
744
-            $obj->setErrors("An error occured during the AfterSave event");
745
-            return false;
746
-        }
747
-
748
-        if ($obj->isNew()) {
749
-            $obj->unsetNew();
750
-            $eventResult = $this->executeEvent('afterInsert', $obj);
751
-            if (!$eventResult) {
752
-                $obj->setErrors("An error occured during the AfterInsert event");
753
-                return false;
754
-            }
755
-        } else {
756
-            $eventResult = $this->executeEvent('afterUpdate', $obj);
757
-            if (!$eventResult) {
758
-                $obj->setErrors("An error occured during the AfterUpdate event");
759
-                return false;
760
-            }
761
-        }
762
-        return true;
763
-    }
764
-
765
-    function insertD(&$obj, $force = false, $checkObject = true, $debug=false)
766
-    {
767
-        return $this->insert($obj, $force, $checkObject, true);
768
-    }
769
-
770
-    /**
771
-     * Change a value for objects with a certain criteria
772
-     *
773
-     * @param   string  $fieldname  Name of the field
774
-     * @param   string  $fieldvalue Value to write
775
-     * @param   object  $criteria   {@link CriteriaElement}
776
-     *
777
-     * @return  bool
778
-     **/
779
-    function updateAll($fieldname, $fieldvalue, $criteria = null, $force = false)
780
-    {
781
-        $set_clause = $fieldname . ' = ';
782
-        if ( is_numeric( $fieldvalue ) ) {
783
-            $set_clause .=  $fieldvalue;
784
-        } elseif ( is_array( $fieldvalue ) ) {
785
-            $set_clause .= $this->db->quoteString( implode( ',', $fieldvalue ) );
786
-        } else {
787
-            $set_clause .= $this->db->quoteString( $fieldvalue );
788
-        }
789
-        $sql = 'UPDATE '.$this->table.' SET '.$set_clause;
790
-        if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
791
-            $sql .= ' '.$criteria->renderWhere();
792
-        }
793
-        if (false != $force) {
794
-            $result = $this->db->queryF($sql);
795
-        } else {
796
-            $result = $this->db->query($sql);
797
-        }
798
-        if (!$result) {
799
-            return false;
800
-        }
801
-        return true;
802
-    }
803
-
804
-    /**
805
-     * delete all objects meeting the conditions
806
-     *
807
-     * @param object $criteria {@link CriteriaElement} with conditions to meet
808
-     * @return bool
809
-     */
810
-
811
-    function deleteAll($criteria = null)
812
-    {
813
-        if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
814
-            $sql = 'DELETE FROM '.$this->table;
815
-            $sql .= ' '.$criteria->renderWhere();
816
-            if (!$this->db->query($sql)) {
817
-                return false;
818
-            }
819
-            $rows = $this->db->getAffectedRows();
820
-            return $rows > 0 ? $rows : true;
821
-        }
822
-        return false;
823
-    }
824
-
825
-    function getModuleInfo() {
826
-        return smart_getModuleInfo($this->_moduleName);
827
-    }
828
-
829
-    function getModuleConfig() {
830
-        return smart_getModuleConfig($this->_moduleName);
831
-    }
832
-
833
-    function getModuleItemString() {
834
-        $ret = $this->_moduleName . '_' . $this->_itemname;
835
-        return $ret;
836
-    }
837
-
838
-    function updateCounter($object) {
839
-        if (isset($object->vars['counter'])) {
840
-            $new_counter = $object->getVar('counter') + 1;
841
-            $sql = 'UPDATE ' . $this->table . ' SET counter=' . $new_counter . ' WHERE ' . $this->keyName . '=' . $object->id();
842
-            $this->query($sql, null, true);
843
-        }
844
-    }
845
-
846
-    /**
847
-     * Execute the function associated with an event
848
-     * This method will check if the function is available
849
-     *
850
-     * @param string $event name of the event
851
-     * @param object $obj $object on which is performed the event
852
-     * @return mixed result of the execution of the function or FALSE if the function was not executed
853
-     */
854
-    function executeEvent($event, &$executeEventObj) {
855
-        if (!in_array($event, $this->_disabledEvents)) {
856
-            if (method_exists($this, $event)) {
857
-                $ret = $this->$event($executeEventObj);
858
-            } else {
859
-                // check to see if there is a hook for this event
860
-                if (isset($this->_eventHooks[$event])) {
861
-                    $method = $this->_eventHooks[$event];
862
-                    // check to see if the method specified by this hook exists
863
-                    if (method_exists($this, $method)) {
864
-                        $ret = $this->$method($executeEventObj);
865
-
866
-                    }
867
-                }
868
-                $ret = true;
869
-            }
870
-            return $ret;
871
-        }
872
-        return true;
873
-    }
874
-
875
-    function getIdentifierName($withprefix=true) {
876
-        if ($withprefix) {
877
-            return $this->_itemname . "." . $this->identifierName;
878
-        } else {
879
-            return $this->identifierName;
880
-        }
881
-    }
184
+		);
185
+	}
186
+
187
+	function setGrantedObjectsCriteria(&$criteria, $perm_name) {
188
+		$smartpermissions_handler = new SmartobjectPermissionHandler($this);
189
+		$grantedItems = $smartpermissions_handler->getGrantedItems($perm_name);
190
+		if (count($grantedItems) > 0) {
191
+			$criteria->add(new Criteria($this->keyName, '(' . implode(', ', $grantedItems) . ')', 'IN'));
192
+			return true;
193
+		} else {
194
+			return false;
195
+		}
196
+	}
197
+
198
+	function setUploaderConfig($_uploadPath=false, $_allowedMimeTypes=false, $_maxFileSize=false, $_maxWidth=false, $_maxHeight=false) {
199
+		$this->_uploadPath = $_uploadPath ? $_uploadPath : $this->_uploadPath;
200
+		$this->_allowedMimeTypes = $_allowedMimeTypes ? $_allowedMimeTypes : $this->_allowedMimeTypes;
201
+		$this->_maxFileSize = $_maxFileSize ? $_maxFileSize : $this->_maxFileSize;
202
+		$this->_maxWidth = $_maxWidth ? $_maxWidth : $this->_maxWidth;
203
+		$this->_maxHeight = $_maxHeight ? $_maxHeight : $this->_maxHeight;
204
+	}
205
+
206
+	/**
207
+	 * create a new {@link SmartObject}
208
+	 *
209
+	 * @param bool $isNew Flag the new objects as "new"?
210
+	 *
211
+	 * @return object {@link SmartObject}
212
+	 */
213
+	function &create($isNew = true) {
214
+		$obj = new $this->className($this);
215
+		$obj->setImageDir($this->getImageUrl(), $this->getImagePath());
216
+		if (!$obj->handler) {
217
+			$obj->handler =& $this;
218
+		}
219
+
220
+		if ($isNew === true) {
221
+			$obj->setNew();
222
+		}
223
+		return $obj;
224
+	}
225
+
226
+	function getImageUrl() {
227
+		return $this->_uploadUrl . $this->_itemname . "/";
228
+	}
229
+
230
+	function getImagePath() {
231
+		$dir = $this->_uploadPath . $this->_itemname;
232
+		if (!file_exists($dir)) {
233
+			smart_admin_mkdir($dir);
234
+		}
235
+		return $dir . "/";
236
+	}
237
+
238
+	/**
239
+	 * retrieve a {@link SmartObject}
240
+	 *
241
+	 * @param mixed $id ID of the object - or array of ids for joint keys. Joint keys MUST be given in the same order as in the constructor
242
+	 * @param bool $as_object whether to return an object or an array
243
+	 * @return mixed reference to the {@link SmartObject}, FALSE if failed
244
+	 */
245
+	function &get($id, $as_object = true, $debug=false, $criteria=false) {
246
+		if (!$criteria) {
247
+			$criteria = new CriteriaCompo();
248
+		}
249
+		if (is_array($this->keyName)) {
250
+			for ($i = 0; $i < count($this->keyName); $i++) {
251
+				/**
252
+				 * In some situations, the $id is not an INTEGER. SmartObjectTag is an example.
253
+				 * Is the fact that we removed the intval() represents a security risk ?
254
+				 */
255
+				//$criteria->add(new Criteria($this->keyName[$i], ($id[$i]), '=', $this->_itemname));
256
+				$criteria->add(new Criteria($this->keyName[$i], $id[$i], '=', $this->_itemname));
257
+			}
258
+		}
259
+		else {
260
+			//$criteria = new Criteria($this->keyName, intval($id), '=', $this->_itemname);
261
+			/**
262
+			 * In some situations, the $id is not an INTEGER. SmartObjectTag is an example.
263
+			 * Is the fact that we removed the intval() represents a security risk ?
264
+			 */
265
+			$criteria->add(new Criteria($this->keyName, $id, '=', $this->_itemname));
266
+		}
267
+		$criteria->setLimit(1);
268
+		if ($debug) {
269
+			$obj_array = $this->getObjectsD($criteria, false, $as_object);
270
+		} else {
271
+			$obj_array = $this->getObjects($criteria, false, $as_object);
272
+			//patch : weird bug of indexing by id even if id_as_key = false;
273
+			if(!isset($obj_array[0]) && is_object($obj_array[$id])){
274
+				$obj_array[0] = $obj_array[$id];
275
+				unset($obj_array[$id]);
276
+				$obj_array[0]->unsetNew();
277
+			}
278
+		}
279
+
280
+		if (count($obj_array) != 1) {
281
+			$obj = $this->create();
282
+			return $obj;
283
+		}
284
+
285
+		return $obj_array[0];
286
+	}
287
+
288
+	/**
289
+	 * retrieve a {@link SmartObject}
290
+	 *
291
+	 * @param mixed $id ID of the object - or array of ids for joint keys. Joint keys MUST be given in the same order as in the constructor
292
+	 * @param bool $as_object whether to return an object or an array
293
+	 * @return mixed reference to the {@link SmartObject}, FALSE if failed
294
+	 */
295
+	function &getD($id, $as_object = true) {
296
+		return $this->get($id, $as_object, true);
297
+	}
298
+
299
+	/**
300
+	 * retrieve objects from the database
301
+	 *
302
+	 * @param object $criteria {@link CriteriaElement} conditions to be met
303
+	 * @param bool $id_as_key use the ID as key for the array?
304
+	 * @param bool $as_object return an array of objects?
305
+	 *
306
+	 * @return array
307
+	 */
308
+	function getObjects($criteria = null, $id_as_key = false, $as_object = true, $sql=false, $debug=false)
309
+	{
310
+		$ret = array();
311
+		$limit = $start = 0;
312
+
313
+		if ($this->generalSQL) {
314
+			$sql = $this->generalSQL;
315
+		} elseif(!$sql) {
316
+			$sql = 'SELECT * FROM '.$this->table . " AS " . $this->_itemname;
317
+		}
318
+
319
+		if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
320
+			$sql .= ' '.$criteria->renderWhere();
321
+			if ($criteria->getSort() != '') {
322
+				$sql .= ' ORDER BY '.$criteria->getSort().' '.$criteria->getOrder();
323
+			}
324
+			$limit = $criteria->getLimit();
325
+			$start = $criteria->getStart();
326
+		}
327
+		if ($debug) {
328
+			xoops_debug($sql);
329
+		}
330
+
331
+		$result = $this->db->query($sql, $limit, $start);
332
+		if (!$result) {
333
+			return $ret;
334
+		}
335
+		return $this->convertResultSet($result, $id_as_key, $as_object);
336
+	}
337
+
338
+	function query($sql, $criteria, $force=false, $debug=false)
339
+	{
340
+		$ret = array();
341
+
342
+		if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
343
+			$sql .= ' '.$criteria->renderWhere();
344
+			if ($criteria->groupby) {
345
+				$sql .= $criteria->getGroupby();
346
+			}
347
+			if ($criteria->getSort() != '') {
348
+				$sql .= ' ORDER BY '.$criteria->getSort().' '.$criteria->getOrder();
349
+			}
350
+
351
+		}
352
+		if ($debug) {
353
+			xoops_debug($sql);
354
+		}
355
+
356
+		if ($force) {
357
+			$result = $this->db->queryF($sql);
358
+		} else {
359
+			$result = $this->db->query($sql);
360
+		}
361
+
362
+		if (!$result) {
363
+			return $ret;
364
+		}
365
+
366
+		while ($myrow = $this->db->fetchArray($result)) {
367
+			$ret[] = $myrow;
368
+		}
369
+
370
+		return $ret;
371
+	}
372
+
373
+	/**
374
+	 * retrieve objects with debug mode - so will show the query
375
+	 *
376
+	 * @param object $criteria {@link CriteriaElement} conditions to be met
377
+	 * @param bool $id_as_key use the ID as key for the array?
378
+	 * @param bool $as_object return an array of objects?
379
+	 *
380
+	 * @return array
381
+	 */
382
+	function getObjectsD($criteria = null, $id_as_key = false, $as_object = true, $sql = false)
383
+	{
384
+		return $this->getObjects($criteria, $id_as_key, $as_object, $sql, true);
385
+	}
386
+
387
+	function getObjectsAsArray($arrayObjects) {
388
+		$ret = array();
389
+		foreach ($arrayObjects as $key => $object) {
390
+			$ret[$key] = $object->toArray();
391
+		}
392
+		if (count($ret > 0)) {
393
+			return $ret;
394
+		} else {
395
+			return false;
396
+		}
397
+	}
398
+
399
+	/**
400
+	 * Convert a database resultset to a returnable array
401
+	 *
402
+	 * @param object $result database resultset
403
+	 * @param bool $id_as_key - should NOT be used with joint keys
404
+	 * @param bool $as_object
405
+	 *
406
+	 * @return array
407
+	 */
408
+	function convertResultSet($result, $id_as_key = false, $as_object = true) {
409
+		$ret = array();
410
+		while ($myrow = $this->db->fetchArray($result)) {
411
+
412
+			$obj =& $this->create(false);
413
+			$obj->assignVars($myrow);
414
+			if (!$id_as_key) {
415
+				if ($as_object) {
416
+					$ret[] =& $obj;
417
+				}
418
+				else {
419
+					$ret[] = $obj->toArray();
420
+				}
421
+			} else {
422
+				if ($as_object) {
423
+					$value =& $obj;
424
+				}
425
+				else {
426
+					$value = $obj->toArray();
427
+				}
428
+				if ($id_as_key === 'parentid') {
429
+					$ret[$obj->getVar('parentid', 'e')][$obj->getVar($this->keyName)] =& $value;
430
+				} else {
431
+					$ret[$obj->getVar($this->keyName)] = $value;
432
+				}
433
+			}
434
+			unset($obj);
435
+		}
436
+
437
+		return $ret;
438
+	}
439
+
440
+	function getListD($criteria = null, $limit = 0, $start = 0) {
441
+		return $this->getList($criteria, $limit, $start, true);
442
+	}
443
+
444
+	/**
445
+	 * Retrieve a list of objects as arrays - DON'T USE WITH JOINT KEYS
446
+	 *
447
+	 * @param object $criteria {@link CriteriaElement} conditions to be met
448
+	 * @param int   $limit      Max number of objects to fetch
449
+	 * @param int   $start      Which record to start at
450
+	 *
451
+	 * @return array
452
+	 */
453
+	function getList($criteria = null, $limit = 0, $start = 0, $debug=false) {
454
+		$ret = array();
455
+		if ($criteria == null) {
456
+			$criteria = new CriteriaCompo();
457
+		}
458
+
459
+		if ($criteria->getSort() == '') {
460
+			$criteria->setSort($this->getIdentifierName());
461
+		}
462
+
463
+		$sql = 'SELECT '.(is_array($this->keyName) ? implode(', ', $this->keyName) : $this->keyName) ;
464
+		if(!empty($this->identifierName)){
465
+			$sql .= ', '.$this->getIdentifierName();
466
+		}
467
+		$sql .= ' FROM '.$this->table . " AS " . $this->_itemname;
468
+		if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
469
+			$sql .= ' '.$criteria->renderWhere();
470
+			if ($criteria->getSort() != '') {
471
+				$sql .= ' ORDER BY '.$criteria->getSort().' '.$criteria->getOrder();
472
+			}
473
+			$limit = $criteria->getLimit();
474
+			$start = $criteria->getStart();
475
+		}
476
+
477
+		if ($debug) {
478
+			xoops_debug($sql);
479
+		}
480
+
481
+		$result = $this->db->query($sql, $limit, $start);
482
+		if (!$result) {
483
+			return $ret;
484
+		}
485
+
486
+		$myts =& MyTextSanitizer::getInstance();
487
+		while ($myrow = $this->db->fetchArray($result)) {
488
+			//identifiers should be textboxes, so sanitize them like that
489
+			$ret[$myrow[$this->keyName]] = empty($this->identifierName)?1:$myts->displayTarea($myrow[$this->identifierName]);
490
+		}
491
+		return $ret;
492
+	}
493
+
494
+	/**
495
+	 * count objects matching a condition
496
+	 *
497
+	 * @param object $criteria {@link CriteriaElement} to match
498
+	 * @return int count of objects
499
+	 */
500
+	function getCount($criteria = null)
501
+	{
502
+		$field = "";
503
+		$groupby = false;
504
+		if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
505
+			if ($criteria->groupby != "") {
506
+				$groupby = true;
507
+				$field = $criteria->groupby.", "; //Not entirely secure unless you KNOW that no criteria's groupby clause is going to be mis-used
508
+			}
509
+		}
510
+		/**
511
+		 * if we have a generalSQL, lets used this one.
512
+		 * This needs to be improved...
513
+		 */
514
+		if ($this->generalSQL) {
515
+			$sql = $this->generalSQL;
516
+			$sql = str_replace('SELECT *', 'SELECT COUNT(*)', $sql);
517
+		} else {
518
+			$sql = 'SELECT '.$field.'COUNT(*) FROM '.$this->table . ' AS ' . $this->_itemname;
519
+		}
520
+		if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
521
+			$sql .= ' '.$criteria->renderWhere();
522
+			if ($criteria->groupby != "") {
523
+				$sql .= $criteria->getGroupby();
524
+			}
525
+		}
526
+
527
+		$result = $this->db->query($sql);
528
+		if (!$result) {
529
+			return 0;
530
+		}
531
+		if ($groupby == false) {
532
+			list($count) = $this->db->fetchRow($result);
533
+			return $count;
534
+		}
535
+		else {
536
+			$ret = array();
537
+			while (list($id, $count) = $this->db->fetchRow($result)) {
538
+				$ret[$id] = $count;
539
+			}
540
+			return $ret;
541
+		}
542
+	}
543
+
544
+	/**
545
+	 * delete an object from the database
546
+	 *
547
+	 * @param object $obj reference to the object to delete
548
+	 * @param bool $force
549
+	 * @return bool FALSE if failed.
550
+	 */
551
+	function delete(&$obj, $force = false)
552
+	{
553
+		$eventResult = $this->executeEvent('beforeDelete', $obj);
554
+		if (!$eventResult) {
555
+			$obj->setErrors("An error occured during the BeforeDelete event");
556
+			return false;
557
+		}
558
+
559
+		if (is_array($this->keyName)) {
560
+			$clause = array();
561
+			for ($i = 0; $i < count($this->keyName); $i++) {
562
+				$clause[] = $this->keyName[$i]." = ".$obj->getVar($this->keyName[$i]);
563
+			}
564
+			$whereclause = implode(" AND ", $clause);
565
+		}
566
+		else {
567
+			$whereclause = $this->keyName." = ".$obj->getVar($this->keyName);
568
+		}
569
+		$sql = "DELETE FROM ".$this->table . " WHERE ".$whereclause;
570
+		if (false != $force) {
571
+			$result = $this->db->queryF($sql);
572
+		} else {
573
+			$result = $this->db->query($sql);
574
+		}
575
+		if (!$result) {
576
+			return false;
577
+		}
578
+
579
+		$eventResult = $this->executeEvent('afterDelete', $obj);
580
+		if (!$eventResult) {
581
+			$obj->setErrors("An error occured during the AfterDelete event");
582
+			return false;
583
+		}
584
+		return true;
585
+	}
586
+
587
+	function disableEvent($event) {
588
+		if (is_array($event)) {
589
+			foreach($event as $v) {
590
+				$this->_disabledEvents[] = $v;
591
+			}
592
+		} else {
593
+			$this->_disabledEvents[] = $event;
594
+		}
595
+	}
596
+
597
+	function getPermissions() {
598
+		return $this->permissionsArray;
599
+	}
600
+
601
+	/**
602
+	 * insert a new object in the database
603
+	 *
604
+	 * @param object $obj reference to the object
605
+	 * @param bool $force whether to force the query execution despite security settings
606
+	 * @param bool $checkObject check if the object is dirty and clean the attributes
607
+	 * @return bool FALSE if failed, TRUE if already present and unchanged or successful
608
+	 */
609
+	function insert(&$obj, $force = false, $checkObject = true, $debug=false)
610
+	{
611
+		if ($checkObject != false) {
612
+			if (!is_object($obj)) {
613
+				return false;
614
+			}
615
+			/**
616
+			 * @TODO: Change to if (!(class_exists($this->className) && $obj instanceof $this->className)) when going fully PHP5
617
+			 */
618
+			if (!is_a($obj, $this->className)) {
619
+				$obj->setError(get_class($obj)." Differs from ".$this->className);
620
+				return false;
621
+			}
622
+			if (!$obj->isDirty()) {
623
+				$obj->setErrors("Not dirty"); //will usually not be outputted as errors are not displayed when the method returns true, but it can be helpful when troubleshooting code - Mith
624
+				return true;
625
+			}
626
+		}
627
+
628
+		if ($obj->seoEnabled) {
629
+			// Auto create meta tags if empty
630
+			$smartobject_metagen = new SmartMetagen($obj->title(), $obj->getVar('meta_keywords'), $obj->summary());
631
+
632
+			if (!$obj->getVar('meta_keywords') || !$obj->getVar('meta_description')) {
633
+
634
+				if (!$obj->meta_keywords()) {
635
+					$obj->setVar('meta_keywords', $smartobject_metagen->_keywords);
636
+				}
637
+
638
+				if (!$obj->meta_description()) {
639
+					$obj->setVar('meta_description', $smartobject_metagen->_meta_description);
640
+				}
641
+			}
642
+
643
+			// Auto create short_url if empty
644
+			if (!$obj->short_url()) {
645
+				$obj->setVar('short_url', $smartobject_metagen->generateSeoTitle($obj->title('n'), false));
646
+			}
647
+		}
648
+
649
+		$eventResult = $this->executeEvent('beforeSave', $obj);
650
+		if (!$eventResult) {
651
+			$obj->setErrors("An error occured during the BeforeSave event");
652
+			return false;
653
+		}
654
+
655
+		if ($obj->isNew()) {
656
+			$eventResult = $this->executeEvent('beforeInsert', $obj);
657
+			if (!$eventResult) {
658
+				$obj->setErrors("An error occured during the BeforeInsert event");
659
+				return false;
660
+			}
661
+
662
+		}	else {
663
+			$eventResult = $this->executeEvent('beforeUpdate', $obj);
664
+			if (!$eventResult) {
665
+				$obj->setErrors("An error occured during the BeforeUpdate event");
666
+				return false;
667
+			}
668
+		}
669
+		if (!$obj->cleanVars()) {
670
+			$obj->setErrors('Variables were not cleaned properly.');
671
+			return false;
672
+		}
673
+		$fieldsToStoreInDB = array();
674
+		foreach ($obj->cleanVars as $k => $v) {
675
+			if ($obj->vars[$k]['data_type'] == XOBJ_DTYPE_INT) {
676
+				$cleanvars[$k] = intval($v);
677
+			} elseif (is_array($v) ) {
678
+				$cleanvars[ $k ] = $this->db->quoteString( implode( ',', $v ) );
679
+			} else {
680
+				$cleanvars[$k] = $this->db->quoteString($v);
681
+			}
682
+			if ($obj->vars[$k]['persistent']) {
683
+				$fieldsToStoreInDB[$k] = $cleanvars[$k];
684
+			}
685
+
686
+		}
687
+		if ($obj->isNew()) {
688
+			if (!is_array($this->keyName)) {
689
+				if ($cleanvars[$this->keyName] < 1) {
690
+					$cleanvars[$this->keyName] = $this->db->genId($this->table.'_'.$this->keyName.'_seq');
691
+				}
692
+			}
693
+
694
+			$sql = "INSERT INTO ".$this->table." (".implode(',', array_keys($fieldsToStoreInDB)).") VALUES (".implode(',', array_values($fieldsToStoreInDB)) .")";
695
+
696
+		} else {
697
+
698
+			$sql = "UPDATE ".$this->table." SET";
699
+			foreach ($fieldsToStoreInDB as $key => $value) {
700
+				if ((!is_array($this->keyName) && $key == $this->keyName) || (is_array($this->keyName) && in_array($key, $this->keyName))) {
701
+					continue;
702
+				}
703
+				if (isset($notfirst) ) {
704
+					$sql .= ",";
705
+				}
706
+				$sql .= " ".$key." = ".$value;
707
+				$notfirst = true;
708
+			}
709
+			if (is_array($this->keyName)) {
710
+				$whereclause = "";
711
+				for ($i = 0; $i < count($this->keyName); $i++) {
712
+					if ($i > 0) {
713
+						$whereclause .= " AND ";
714
+					}
715
+					$whereclause .= $this->keyName[$i]." = ".$obj->getVar($this->keyName[$i]);
716
+				}
717
+			}
718
+			else {
719
+				$whereclause = $this->keyName." = ".$obj->getVar($this->keyName);
720
+			}
721
+			$sql .= " WHERE ".$whereclause;
722
+		}
723
+
724
+		if ($debug) {
725
+			xoops_debug($sql);
726
+		}
727
+
728
+		if (false != $force) {
729
+			$result = $this->db->queryF($sql);
730
+		} else {
731
+			$result = $this->db->query($sql);
732
+		}
733
+
734
+		if (!$result) {
735
+			$obj->setErrors($this->db->error());
736
+			return false;
737
+		}
738
+
739
+		if ($obj->isNew() && !is_array($this->keyName)) {
740
+			$obj->assignVar($this->keyName, $this->db->getInsertId());
741
+		}
742
+		$eventResult = $this->executeEvent('afterSave', $obj);
743
+		if (!$eventResult) {
744
+			$obj->setErrors("An error occured during the AfterSave event");
745
+			return false;
746
+		}
747
+
748
+		if ($obj->isNew()) {
749
+			$obj->unsetNew();
750
+			$eventResult = $this->executeEvent('afterInsert', $obj);
751
+			if (!$eventResult) {
752
+				$obj->setErrors("An error occured during the AfterInsert event");
753
+				return false;
754
+			}
755
+		} else {
756
+			$eventResult = $this->executeEvent('afterUpdate', $obj);
757
+			if (!$eventResult) {
758
+				$obj->setErrors("An error occured during the AfterUpdate event");
759
+				return false;
760
+			}
761
+		}
762
+		return true;
763
+	}
764
+
765
+	function insertD(&$obj, $force = false, $checkObject = true, $debug=false)
766
+	{
767
+		return $this->insert($obj, $force, $checkObject, true);
768
+	}
769
+
770
+	/**
771
+	 * Change a value for objects with a certain criteria
772
+	 *
773
+	 * @param   string  $fieldname  Name of the field
774
+	 * @param   string  $fieldvalue Value to write
775
+	 * @param   object  $criteria   {@link CriteriaElement}
776
+	 *
777
+	 * @return  bool
778
+	 **/
779
+	function updateAll($fieldname, $fieldvalue, $criteria = null, $force = false)
780
+	{
781
+		$set_clause = $fieldname . ' = ';
782
+		if ( is_numeric( $fieldvalue ) ) {
783
+			$set_clause .=  $fieldvalue;
784
+		} elseif ( is_array( $fieldvalue ) ) {
785
+			$set_clause .= $this->db->quoteString( implode( ',', $fieldvalue ) );
786
+		} else {
787
+			$set_clause .= $this->db->quoteString( $fieldvalue );
788
+		}
789
+		$sql = 'UPDATE '.$this->table.' SET '.$set_clause;
790
+		if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
791
+			$sql .= ' '.$criteria->renderWhere();
792
+		}
793
+		if (false != $force) {
794
+			$result = $this->db->queryF($sql);
795
+		} else {
796
+			$result = $this->db->query($sql);
797
+		}
798
+		if (!$result) {
799
+			return false;
800
+		}
801
+		return true;
802
+	}
803
+
804
+	/**
805
+	 * delete all objects meeting the conditions
806
+	 *
807
+	 * @param object $criteria {@link CriteriaElement} with conditions to meet
808
+	 * @return bool
809
+	 */
810
+
811
+	function deleteAll($criteria = null)
812
+	{
813
+		if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
814
+			$sql = 'DELETE FROM '.$this->table;
815
+			$sql .= ' '.$criteria->renderWhere();
816
+			if (!$this->db->query($sql)) {
817
+				return false;
818
+			}
819
+			$rows = $this->db->getAffectedRows();
820
+			return $rows > 0 ? $rows : true;
821
+		}
822
+		return false;
823
+	}
824
+
825
+	function getModuleInfo() {
826
+		return smart_getModuleInfo($this->_moduleName);
827
+	}
828
+
829
+	function getModuleConfig() {
830
+		return smart_getModuleConfig($this->_moduleName);
831
+	}
832
+
833
+	function getModuleItemString() {
834
+		$ret = $this->_moduleName . '_' . $this->_itemname;
835
+		return $ret;
836
+	}
837
+
838
+	function updateCounter($object) {
839
+		if (isset($object->vars['counter'])) {
840
+			$new_counter = $object->getVar('counter') + 1;
841
+			$sql = 'UPDATE ' . $this->table . ' SET counter=' . $new_counter . ' WHERE ' . $this->keyName . '=' . $object->id();
842
+			$this->query($sql, null, true);
843
+		}
844
+	}
845
+
846
+	/**
847
+	 * Execute the function associated with an event
848
+	 * This method will check if the function is available
849
+	 *
850
+	 * @param string $event name of the event
851
+	 * @param object $obj $object on which is performed the event
852
+	 * @return mixed result of the execution of the function or FALSE if the function was not executed
853
+	 */
854
+	function executeEvent($event, &$executeEventObj) {
855
+		if (!in_array($event, $this->_disabledEvents)) {
856
+			if (method_exists($this, $event)) {
857
+				$ret = $this->$event($executeEventObj);
858
+			} else {
859
+				// check to see if there is a hook for this event
860
+				if (isset($this->_eventHooks[$event])) {
861
+					$method = $this->_eventHooks[$event];
862
+					// check to see if the method specified by this hook exists
863
+					if (method_exists($this, $method)) {
864
+						$ret = $this->$method($executeEventObj);
865
+
866
+					}
867
+				}
868
+				$ret = true;
869
+			}
870
+			return $ret;
871
+		}
872
+		return true;
873
+	}
874
+
875
+	function getIdentifierName($withprefix=true) {
876
+		if ($withprefix) {
877
+			return $this->_itemname . "." . $this->identifierName;
878
+		} else {
879
+			return $this->identifierName;
880
+		}
881
+	}
882 882
 }
883 883
 
884 884
 
Please login to merge, or discard this patch.
Spacing   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -127,10 +127,10 @@  discard block
 block discarded – undo
127 127
      */
128 128
     var $permissionsArray = false;
129 129
 
130
-    var $generalSQL=false;
130
+    var $generalSQL = false;
131 131
 
132
-    var $_eventHooks=array();
133
-    var $_disabledEvents=array();
132
+    var $_eventHooks = array();
133
+    var $_disabledEvents = array();
134 134
 
135 135
     /**
136 136
      * Constructor - called from child classes
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
      * @param string $caption caption of the control that will be displayed in the form
175 175
      * @param string $description description of the control that will be displayed in the form
176 176
      */
177
-    function addPermission($perm_name, $caption, $description=false) {
177
+    function addPermission($perm_name, $caption, $description = false) {
178 178
         include_once(SMARTOBJECT_ROOT_PATH . 'class/smartobjectpermission.php');
179 179
 
180 180
         $this->permissionsArray[] = array(
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
         }
196 196
     }
197 197
 
198
-    function setUploaderConfig($_uploadPath=false, $_allowedMimeTypes=false, $_maxFileSize=false, $_maxWidth=false, $_maxHeight=false) {
198
+    function setUploaderConfig($_uploadPath = false, $_allowedMimeTypes = false, $_maxFileSize = false, $_maxWidth = false, $_maxHeight = false) {
199 199
         $this->_uploadPath = $_uploadPath ? $_uploadPath : $this->_uploadPath;
200 200
         $this->_allowedMimeTypes = $_allowedMimeTypes ? $_allowedMimeTypes : $this->_allowedMimeTypes;
201 201
         $this->_maxFileSize = $_maxFileSize ? $_maxFileSize : $this->_maxFileSize;
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
         $obj = new $this->className($this);
215 215
         $obj->setImageDir($this->getImageUrl(), $this->getImagePath());
216 216
         if (!$obj->handler) {
217
-            $obj->handler =& $this;
217
+            $obj->handler = & $this;
218 218
         }
219 219
 
220 220
         if ($isNew === true) {
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
      * @param bool $as_object whether to return an object or an array
243 243
      * @return mixed reference to the {@link SmartObject}, FALSE if failed
244 244
      */
245
-    function &get($id, $as_object = true, $debug=false, $criteria=false) {
245
+    function &get($id, $as_object = true, $debug = false, $criteria = false) {
246 246
         if (!$criteria) {
247 247
             $criteria = new CriteriaCompo();
248 248
         }
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
         } else {
271 271
             $obj_array = $this->getObjects($criteria, false, $as_object);
272 272
             //patch : weird bug of indexing by id even if id_as_key = false;
273
-            if(!isset($obj_array[0]) && is_object($obj_array[$id])){
273
+            if (!isset($obj_array[0]) && is_object($obj_array[$id])) {
274 274
                 $obj_array[0] = $obj_array[$id];
275 275
                 unset($obj_array[$id]);
276 276
                 $obj_array[0]->unsetNew();
@@ -305,21 +305,21 @@  discard block
 block discarded – undo
305 305
      *
306 306
      * @return array
307 307
      */
308
-    function getObjects($criteria = null, $id_as_key = false, $as_object = true, $sql=false, $debug=false)
308
+    function getObjects($criteria = null, $id_as_key = false, $as_object = true, $sql = false, $debug = false)
309 309
     {
310 310
         $ret = array();
311 311
         $limit = $start = 0;
312 312
 
313 313
         if ($this->generalSQL) {
314 314
             $sql = $this->generalSQL;
315
-        } elseif(!$sql) {
316
-            $sql = 'SELECT * FROM '.$this->table . " AS " . $this->_itemname;
315
+        } elseif (!$sql) {
316
+            $sql = 'SELECT * FROM ' . $this->table . " AS " . $this->_itemname;
317 317
         }
318 318
 
319 319
         if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
320
-            $sql .= ' '.$criteria->renderWhere();
320
+            $sql .= ' ' . $criteria->renderWhere();
321 321
             if ($criteria->getSort() != '') {
322
-                $sql .= ' ORDER BY '.$criteria->getSort().' '.$criteria->getOrder();
322
+                $sql .= ' ORDER BY ' . $criteria->getSort() . ' ' . $criteria->getOrder();
323 323
             }
324 324
             $limit = $criteria->getLimit();
325 325
             $start = $criteria->getStart();
@@ -335,17 +335,17 @@  discard block
 block discarded – undo
335 335
         return $this->convertResultSet($result, $id_as_key, $as_object);
336 336
     }
337 337
 
338
-    function query($sql, $criteria, $force=false, $debug=false)
338
+    function query($sql, $criteria, $force = false, $debug = false)
339 339
     {
340 340
         $ret = array();
341 341
 
342 342
         if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
343
-            $sql .= ' '.$criteria->renderWhere();
343
+            $sql .= ' ' . $criteria->renderWhere();
344 344
             if ($criteria->groupby) {
345 345
                 $sql .= $criteria->getGroupby();
346 346
             }
347 347
             if ($criteria->getSort() != '') {
348
-                $sql .= ' ORDER BY '.$criteria->getSort().' '.$criteria->getOrder();
348
+                $sql .= ' ORDER BY ' . $criteria->getSort() . ' ' . $criteria->getOrder();
349 349
             }
350 350
 
351 351
         }
@@ -409,24 +409,24 @@  discard block
 block discarded – undo
409 409
         $ret = array();
410 410
         while ($myrow = $this->db->fetchArray($result)) {
411 411
 
412
-            $obj =& $this->create(false);
412
+            $obj = & $this->create(false);
413 413
             $obj->assignVars($myrow);
414 414
             if (!$id_as_key) {
415 415
                 if ($as_object) {
416
-                    $ret[] =& $obj;
416
+                    $ret[] = & $obj;
417 417
                 }
418 418
                 else {
419 419
                     $ret[] = $obj->toArray();
420 420
                 }
421 421
             } else {
422 422
                 if ($as_object) {
423
-                    $value =& $obj;
423
+                    $value = & $obj;
424 424
                 }
425 425
                 else {
426 426
                     $value = $obj->toArray();
427 427
                 }
428 428
                 if ($id_as_key === 'parentid') {
429
-                    $ret[$obj->getVar('parentid', 'e')][$obj->getVar($this->keyName)] =& $value;
429
+                    $ret[$obj->getVar('parentid', 'e')][$obj->getVar($this->keyName)] = & $value;
430 430
                 } else {
431 431
                     $ret[$obj->getVar($this->keyName)] = $value;
432 432
                 }
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
      *
451 451
      * @return array
452 452
      */
453
-    function getList($criteria = null, $limit = 0, $start = 0, $debug=false) {
453
+    function getList($criteria = null, $limit = 0, $start = 0, $debug = false) {
454 454
         $ret = array();
455 455
         if ($criteria == null) {
456 456
             $criteria = new CriteriaCompo();
@@ -460,15 +460,15 @@  discard block
 block discarded – undo
460 460
             $criteria->setSort($this->getIdentifierName());
461 461
         }
462 462
 
463
-        $sql = 'SELECT '.(is_array($this->keyName) ? implode(', ', $this->keyName) : $this->keyName) ;
464
-        if(!empty($this->identifierName)){
465
-            $sql .= ', '.$this->getIdentifierName();
463
+        $sql = 'SELECT ' . (is_array($this->keyName) ? implode(', ', $this->keyName) : $this->keyName);
464
+        if (!empty($this->identifierName)) {
465
+            $sql .= ', ' . $this->getIdentifierName();
466 466
         }
467
-        $sql .= ' FROM '.$this->table . " AS " . $this->_itemname;
467
+        $sql .= ' FROM ' . $this->table . " AS " . $this->_itemname;
468 468
         if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
469
-            $sql .= ' '.$criteria->renderWhere();
469
+            $sql .= ' ' . $criteria->renderWhere();
470 470
             if ($criteria->getSort() != '') {
471
-                $sql .= ' ORDER BY '.$criteria->getSort().' '.$criteria->getOrder();
471
+                $sql .= ' ORDER BY ' . $criteria->getSort() . ' ' . $criteria->getOrder();
472 472
             }
473 473
             $limit = $criteria->getLimit();
474 474
             $start = $criteria->getStart();
@@ -483,10 +483,10 @@  discard block
 block discarded – undo
483 483
             return $ret;
484 484
         }
485 485
 
486
-        $myts =& MyTextSanitizer::getInstance();
486
+        $myts = & MyTextSanitizer::getInstance();
487 487
         while ($myrow = $this->db->fetchArray($result)) {
488 488
             //identifiers should be textboxes, so sanitize them like that
489
-            $ret[$myrow[$this->keyName]] = empty($this->identifierName)?1:$myts->displayTarea($myrow[$this->identifierName]);
489
+            $ret[$myrow[$this->keyName]] = empty($this->identifierName) ? 1 : $myts->displayTarea($myrow[$this->identifierName]);
490 490
         }
491 491
         return $ret;
492 492
     }
@@ -504,7 +504,7 @@  discard block
 block discarded – undo
504 504
         if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
505 505
             if ($criteria->groupby != "") {
506 506
                 $groupby = true;
507
-                $field = $criteria->groupby.", "; //Not entirely secure unless you KNOW that no criteria's groupby clause is going to be mis-used
507
+                $field = $criteria->groupby . ", "; //Not entirely secure unless you KNOW that no criteria's groupby clause is going to be mis-used
508 508
             }
509 509
         }
510 510
         /**
@@ -515,10 +515,10 @@  discard block
 block discarded – undo
515 515
             $sql = $this->generalSQL;
516 516
             $sql = str_replace('SELECT *', 'SELECT COUNT(*)', $sql);
517 517
         } else {
518
-            $sql = 'SELECT '.$field.'COUNT(*) FROM '.$this->table . ' AS ' . $this->_itemname;
518
+            $sql = 'SELECT ' . $field . 'COUNT(*) FROM ' . $this->table . ' AS ' . $this->_itemname;
519 519
         }
520 520
         if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
521
-            $sql .= ' '.$criteria->renderWhere();
521
+            $sql .= ' ' . $criteria->renderWhere();
522 522
             if ($criteria->groupby != "") {
523 523
                 $sql .= $criteria->getGroupby();
524 524
             }
@@ -559,14 +559,14 @@  discard block
 block discarded – undo
559 559
         if (is_array($this->keyName)) {
560 560
             $clause = array();
561 561
             for ($i = 0; $i < count($this->keyName); $i++) {
562
-                $clause[] = $this->keyName[$i]." = ".$obj->getVar($this->keyName[$i]);
562
+                $clause[] = $this->keyName[$i] . " = " . $obj->getVar($this->keyName[$i]);
563 563
             }
564 564
             $whereclause = implode(" AND ", $clause);
565 565
         }
566 566
         else {
567
-            $whereclause = $this->keyName." = ".$obj->getVar($this->keyName);
567
+            $whereclause = $this->keyName . " = " . $obj->getVar($this->keyName);
568 568
         }
569
-        $sql = "DELETE FROM ".$this->table . " WHERE ".$whereclause;
569
+        $sql = "DELETE FROM " . $this->table . " WHERE " . $whereclause;
570 570
         if (false != $force) {
571 571
             $result = $this->db->queryF($sql);
572 572
         } else {
@@ -586,7 +586,7 @@  discard block
 block discarded – undo
586 586
 
587 587
     function disableEvent($event) {
588 588
         if (is_array($event)) {
589
-            foreach($event as $v) {
589
+            foreach ($event as $v) {
590 590
                 $this->_disabledEvents[] = $v;
591 591
             }
592 592
         } else {
@@ -606,7 +606,7 @@  discard block
 block discarded – undo
606 606
      * @param bool $checkObject check if the object is dirty and clean the attributes
607 607
      * @return bool FALSE if failed, TRUE if already present and unchanged or successful
608 608
      */
609
-    function insert(&$obj, $force = false, $checkObject = true, $debug=false)
609
+    function insert(&$obj, $force = false, $checkObject = true, $debug = false)
610 610
     {
611 611
         if ($checkObject != false) {
612 612
             if (!is_object($obj)) {
@@ -616,7 +616,7 @@  discard block
 block discarded – undo
616 616
              * @TODO: Change to if (!(class_exists($this->className) && $obj instanceof $this->className)) when going fully PHP5
617 617
              */
618 618
             if (!is_a($obj, $this->className)) {
619
-                $obj->setError(get_class($obj)." Differs from ".$this->className);
619
+                $obj->setError(get_class($obj) . " Differs from " . $this->className);
620 620
                 return false;
621 621
             }
622 622
             if (!$obj->isDirty()) {
@@ -659,7 +659,7 @@  discard block
 block discarded – undo
659 659
                 return false;
660 660
             }
661 661
 
662
-        }	else {
662
+        } else {
663 663
             $eventResult = $this->executeEvent('beforeUpdate', $obj);
664 664
             if (!$eventResult) {
665 665
                 $obj->setErrors("An error occured during the BeforeUpdate event");
@@ -674,8 +674,8 @@  discard block
 block discarded – undo
674 674
         foreach ($obj->cleanVars as $k => $v) {
675 675
             if ($obj->vars[$k]['data_type'] == XOBJ_DTYPE_INT) {
676 676
                 $cleanvars[$k] = intval($v);
677
-            } elseif (is_array($v) ) {
678
-                $cleanvars[ $k ] = $this->db->quoteString( implode( ',', $v ) );
677
+            } elseif (is_array($v)) {
678
+                $cleanvars[$k] = $this->db->quoteString(implode(',', $v));
679 679
             } else {
680 680
                 $cleanvars[$k] = $this->db->quoteString($v);
681 681
             }
@@ -687,23 +687,23 @@  discard block
 block discarded – undo
687 687
         if ($obj->isNew()) {
688 688
             if (!is_array($this->keyName)) {
689 689
                 if ($cleanvars[$this->keyName] < 1) {
690
-                    $cleanvars[$this->keyName] = $this->db->genId($this->table.'_'.$this->keyName.'_seq');
690
+                    $cleanvars[$this->keyName] = $this->db->genId($this->table . '_' . $this->keyName . '_seq');
691 691
                 }
692 692
             }
693 693
 
694
-            $sql = "INSERT INTO ".$this->table." (".implode(',', array_keys($fieldsToStoreInDB)).") VALUES (".implode(',', array_values($fieldsToStoreInDB)) .")";
694
+            $sql = "INSERT INTO " . $this->table . " (" . implode(',', array_keys($fieldsToStoreInDB)) . ") VALUES (" . implode(',', array_values($fieldsToStoreInDB)) . ")";
695 695
 
696 696
         } else {
697 697
 
698
-            $sql = "UPDATE ".$this->table." SET";
698
+            $sql = "UPDATE " . $this->table . " SET";
699 699
             foreach ($fieldsToStoreInDB as $key => $value) {
700 700
                 if ((!is_array($this->keyName) && $key == $this->keyName) || (is_array($this->keyName) && in_array($key, $this->keyName))) {
701 701
                     continue;
702 702
                 }
703
-                if (isset($notfirst) ) {
703
+                if (isset($notfirst)) {
704 704
                     $sql .= ",";
705 705
                 }
706
-                $sql .= " ".$key." = ".$value;
706
+                $sql .= " " . $key . " = " . $value;
707 707
                 $notfirst = true;
708 708
             }
709 709
             if (is_array($this->keyName)) {
@@ -712,13 +712,13 @@  discard block
 block discarded – undo
712 712
                     if ($i > 0) {
713 713
                         $whereclause .= " AND ";
714 714
                     }
715
-                    $whereclause .= $this->keyName[$i]." = ".$obj->getVar($this->keyName[$i]);
715
+                    $whereclause .= $this->keyName[$i] . " = " . $obj->getVar($this->keyName[$i]);
716 716
                 }
717 717
             }
718 718
             else {
719
-                $whereclause = $this->keyName." = ".$obj->getVar($this->keyName);
719
+                $whereclause = $this->keyName . " = " . $obj->getVar($this->keyName);
720 720
             }
721
-            $sql .= " WHERE ".$whereclause;
721
+            $sql .= " WHERE " . $whereclause;
722 722
         }
723 723
 
724 724
         if ($debug) {
@@ -762,7 +762,7 @@  discard block
 block discarded – undo
762 762
         return true;
763 763
     }
764 764
 
765
-    function insertD(&$obj, $force = false, $checkObject = true, $debug=false)
765
+    function insertD(&$obj, $force = false, $checkObject = true, $debug = false)
766 766
     {
767 767
         return $this->insert($obj, $force, $checkObject, true);
768 768
     }
@@ -779,16 +779,16 @@  discard block
 block discarded – undo
779 779
     function updateAll($fieldname, $fieldvalue, $criteria = null, $force = false)
780 780
     {
781 781
         $set_clause = $fieldname . ' = ';
782
-        if ( is_numeric( $fieldvalue ) ) {
783
-            $set_clause .=  $fieldvalue;
784
-        } elseif ( is_array( $fieldvalue ) ) {
785
-            $set_clause .= $this->db->quoteString( implode( ',', $fieldvalue ) );
782
+        if (is_numeric($fieldvalue)) {
783
+            $set_clause .= $fieldvalue;
784
+        } elseif (is_array($fieldvalue)) {
785
+            $set_clause .= $this->db->quoteString(implode(',', $fieldvalue));
786 786
         } else {
787
-            $set_clause .= $this->db->quoteString( $fieldvalue );
787
+            $set_clause .= $this->db->quoteString($fieldvalue);
788 788
         }
789
-        $sql = 'UPDATE '.$this->table.' SET '.$set_clause;
789
+        $sql = 'UPDATE ' . $this->table . ' SET ' . $set_clause;
790 790
         if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
791
-            $sql .= ' '.$criteria->renderWhere();
791
+            $sql .= ' ' . $criteria->renderWhere();
792 792
         }
793 793
         if (false != $force) {
794 794
             $result = $this->db->queryF($sql);
@@ -811,8 +811,8 @@  discard block
 block discarded – undo
811 811
     function deleteAll($criteria = null)
812 812
     {
813 813
         if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
814
-            $sql = 'DELETE FROM '.$this->table;
815
-            $sql .= ' '.$criteria->renderWhere();
814
+            $sql = 'DELETE FROM ' . $this->table;
815
+            $sql .= ' ' . $criteria->renderWhere();
816 816
             if (!$this->db->query($sql)) {
817 817
                 return false;
818 818
             }
@@ -872,7 +872,7 @@  discard block
 block discarded – undo
872 872
         return true;
873 873
     }
874 874
 
875
-    function getIdentifierName($withprefix=true) {
875
+    function getIdentifierName($withprefix = true) {
876 876
         if ($withprefix) {
877 877
             return $this->_itemname . "." . $this->identifierName;
878 878
         } else {
Please login to merge, or discard this patch.
Braces   +7 added lines, -13 removed lines patch added patch discarded remove patch
@@ -255,8 +255,7 @@  discard block
 block discarded – undo
255 255
                 //$criteria->add(new Criteria($this->keyName[$i], ($id[$i]), '=', $this->_itemname));
256 256
                 $criteria->add(new Criteria($this->keyName[$i], $id[$i], '=', $this->_itemname));
257 257
             }
258
-        }
259
-        else {
258
+        } else {
260 259
             //$criteria = new Criteria($this->keyName, intval($id), '=', $this->_itemname);
261 260
             /**
262 261
             * In some situations, the $id is not an INTEGER. SmartObjectTag is an example.
@@ -414,15 +413,13 @@  discard block
 block discarded – undo
414 413
             if (!$id_as_key) {
415 414
                 if ($as_object) {
416 415
                     $ret[] =& $obj;
417
-                }
418
-                else {
416
+                } else {
419 417
                     $ret[] = $obj->toArray();
420 418
                 }
421 419
             } else {
422 420
                 if ($as_object) {
423 421
                     $value =& $obj;
424
-                }
425
-                else {
422
+                } else {
426 423
                     $value = $obj->toArray();
427 424
                 }
428 425
                 if ($id_as_key === 'parentid') {
@@ -531,8 +528,7 @@  discard block
 block discarded – undo
531 528
         if ($groupby == false) {
532 529
             list($count) = $this->db->fetchRow($result);
533 530
             return $count;
534
-        }
535
-        else {
531
+        } else {
536 532
             $ret = array();
537 533
             while (list($id, $count) = $this->db->fetchRow($result)) {
538 534
                 $ret[$id] = $count;
@@ -562,8 +558,7 @@  discard block
 block discarded – undo
562 558
                 $clause[] = $this->keyName[$i]." = ".$obj->getVar($this->keyName[$i]);
563 559
             }
564 560
             $whereclause = implode(" AND ", $clause);
565
-        }
566
-        else {
561
+        } else {
567 562
             $whereclause = $this->keyName." = ".$obj->getVar($this->keyName);
568 563
         }
569 564
         $sql = "DELETE FROM ".$this->table . " WHERE ".$whereclause;
@@ -659,7 +654,7 @@  discard block
 block discarded – undo
659 654
                 return false;
660 655
             }
661 656
 
662
-        }	else {
657
+        } else {
663 658
             $eventResult = $this->executeEvent('beforeUpdate', $obj);
664 659
             if (!$eventResult) {
665 660
                 $obj->setErrors("An error occured during the BeforeUpdate event");
@@ -714,8 +709,7 @@  discard block
 block discarded – undo
714 709
                     }
715 710
                     $whereclause .= $this->keyName[$i]." = ".$obj->getVar($this->keyName[$i]);
716 711
                 }
717
-            }
718
-            else {
712
+            } else {
719 713
                 $whereclause = $this->keyName." = ".$obj->getVar($this->keyName);
720 714
             }
721 715
             $sql .= " WHERE ".$whereclause;
Please login to merge, or discard this patch.
class/smartobjectlink.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@
 block discarded – undo
56 56
     * @access public
57 57
     * @param string $key key of the object's variable to be returned
58 58
     * @param string $format format to use for the output
59
-    * @return mixed formatted value of the variable
59
+    * @return integer formatted value of the variable
60 60
     */
61 61
     function getVar($key, $format = 's') {
62 62
         if ($format == 's' && in_array($key, array('from_uid', 'to_uid', 'date', 'link'))) {
Please login to merge, or discard this patch.
Indentation   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -28,120 +28,120 @@
 block discarded – undo
28 28
 // -------------------------------------------------------------------------//
29 29
 
30 30
 if (!defined("XOOPS_ROOT_PATH")) {
31
-    die("XOOPS root path not defined");
31
+	die("XOOPS root path not defined");
32 32
 }
33 33
 include_once XOOPS_ROOT_PATH."/modules/smartobject/class/smartobject.php";
34 34
 class SmartobjectLink extends SmartObject {
35 35
 
36
-    function SmartobjectLink() {
37
-        $this->initVar('linkid', XOBJ_DTYPE_INT, '', true);
38
-        $this->initVar('date', XOBJ_DTYPE_INT, 0, false, null,'', false, _CO_SOBJECT_LINK_DATE, '', true, true, false);
39
-        $this->initVar('from_uid', XOBJ_DTYPE_INT, '', false, null, '', false, _CO_SOBJECT_LINK_FROM_UID, _CO_SOBJECT_LINK_FROM_UID_DSC);
40
-        $this->initVar('from_email', XOBJ_DTYPE_TXTBOX, '', true, 255, '', false, _CO_SOBJECT_LINK_FROM_EMAIL, _CO_SOBJECT_LINK_FROM_EMAIL_DSC, true);
41
-        $this->initVar('from_name', XOBJ_DTYPE_TXTBOX, '', true, 255, '', false, _CO_SOBJECT_LINK_FROM_NAME, _CO_SOBJECT_LINK_FROM_NAME_DSC, true);
42
-        $this->initVar('to_uid', XOBJ_DTYPE_INT, '', false, null, '', false, _CO_SOBJECT_LINK_TO_UID, _CO_SOBJECT_LINK_TO_UID_DSC);
43
-        $this->initVar('to_email', XOBJ_DTYPE_TXTBOX, '', true, 255, '', false, _CO_SOBJECT_LINK_TO_EMAIL, _CO_SOBJECT_LINK_TO_EMAIL_DSC, true);
44
-        $this->initVar('to_name', XOBJ_DTYPE_TXTBOX, '', true, 255, '', false, _CO_SOBJECT_LINK_TO_NAME, _CO_SOBJECT_LINK_TO_NAME_DSC, true);
45
-        $this->initVar('link', XOBJ_DTYPE_TXTBOX, '', false, 255, '', false, _CO_SOBJECT_LINK_LINK, _CO_SOBJECT_LINK_LINK_DSC, true);
36
+	function SmartobjectLink() {
37
+		$this->initVar('linkid', XOBJ_DTYPE_INT, '', true);
38
+		$this->initVar('date', XOBJ_DTYPE_INT, 0, false, null,'', false, _CO_SOBJECT_LINK_DATE, '', true, true, false);
39
+		$this->initVar('from_uid', XOBJ_DTYPE_INT, '', false, null, '', false, _CO_SOBJECT_LINK_FROM_UID, _CO_SOBJECT_LINK_FROM_UID_DSC);
40
+		$this->initVar('from_email', XOBJ_DTYPE_TXTBOX, '', true, 255, '', false, _CO_SOBJECT_LINK_FROM_EMAIL, _CO_SOBJECT_LINK_FROM_EMAIL_DSC, true);
41
+		$this->initVar('from_name', XOBJ_DTYPE_TXTBOX, '', true, 255, '', false, _CO_SOBJECT_LINK_FROM_NAME, _CO_SOBJECT_LINK_FROM_NAME_DSC, true);
42
+		$this->initVar('to_uid', XOBJ_DTYPE_INT, '', false, null, '', false, _CO_SOBJECT_LINK_TO_UID, _CO_SOBJECT_LINK_TO_UID_DSC);
43
+		$this->initVar('to_email', XOBJ_DTYPE_TXTBOX, '', true, 255, '', false, _CO_SOBJECT_LINK_TO_EMAIL, _CO_SOBJECT_LINK_TO_EMAIL_DSC, true);
44
+		$this->initVar('to_name', XOBJ_DTYPE_TXTBOX, '', true, 255, '', false, _CO_SOBJECT_LINK_TO_NAME, _CO_SOBJECT_LINK_TO_NAME_DSC, true);
45
+		$this->initVar('link', XOBJ_DTYPE_TXTBOX, '', false, 255, '', false, _CO_SOBJECT_LINK_LINK, _CO_SOBJECT_LINK_LINK_DSC, true);
46 46
 		$this->initVar('subject', XOBJ_DTYPE_TXTBOX, '', true, 255, '', false, _CO_SOBJECT_LINK_SUBJECT, _CO_SOBJECT_LINK_SUBJECT_DSC, true);
47 47
 		$this->initVar('body', XOBJ_DTYPE_TXTAREA, '', true, null, '', false, _CO_SOBJECT_LINK_BODY, _CO_SOBJECT_LINK_BODY_DSC);
48
-        $this->initVar('mid', XOBJ_DTYPE_INT, '', false, null, '', false, _CO_SOBJECT_LINK_MID, _CO_SOBJECT_LINK_MID_DSC);
49
-        $this->initVar('mid_name', XOBJ_DTYPE_TXTBOX, '', false, 255, '', false, _CO_SOBJECT_LINK_MID_NAME, _CO_SOBJECT_LINK_MID_NAME_DSC, true);
50
-    }
51
-
52
-
53
-    /**
54
-    * returns a specific variable for the object in a proper format
55
-    *
56
-    * @access public
57
-    * @param string $key key of the object's variable to be returned
58
-    * @param string $format format to use for the output
59
-    * @return mixed formatted value of the variable
60
-    */
61
-    function getVar($key, $format = 's') {
62
-        if ($format == 's' && in_array($key, array('from_uid', 'to_uid', 'date', 'link'))) {
63
-            return call_user_func(array($this,$key));
64
-        }
65
-        return parent::getVar($key, $format);
66
-    }
67
-
68
-    function from_uid() {
69
-        $ret = smart_getLinkedUnameFromId($this->getVar('from_uid', 'e'), 1, null, true);
70
-        return $ret;
71
-    }
72
-
73
-    function to_uid($withContact=false) {
74
-  	    $ret = smart_getLinkedUnameFromId($this->getVar('to_uid', 'e'), 1, null, true);
75
-        return $ret;
76
-    }
77
-
78
-    function date() {
79
-        $ret = formatTimestamp($this->getVar('date','e'));
80
-        return $ret;
81
-    }
82
-
83
-    function link($full=false) {
84
-        $ret = $this->getVar('link','e');
85
-        if ($full) {
86
-        	$myts = MyTextSanitizer::getInstance();
87
-        	$ret = $myts->displayTarea($ret);
88
-        	return $ret;
89
-        } else {
90
-        	$ret = '<a href="' . $ret . '" alt="' . $this->getVar('link','e') . '" title="' . $this->getVar('link','e') . '">' .  _AM_SOBJECT_SENT_LINKS_GOTO . '</a>';
91
-        	return $ret;
92
-        }
93
-    }
94
-
95
-    function getViewItemLink() {
48
+		$this->initVar('mid', XOBJ_DTYPE_INT, '', false, null, '', false, _CO_SOBJECT_LINK_MID, _CO_SOBJECT_LINK_MID_DSC);
49
+		$this->initVar('mid_name', XOBJ_DTYPE_TXTBOX, '', false, 255, '', false, _CO_SOBJECT_LINK_MID_NAME, _CO_SOBJECT_LINK_MID_NAME_DSC, true);
50
+	}
51
+
52
+
53
+	/**
54
+	 * returns a specific variable for the object in a proper format
55
+	 *
56
+	 * @access public
57
+	 * @param string $key key of the object's variable to be returned
58
+	 * @param string $format format to use for the output
59
+	 * @return mixed formatted value of the variable
60
+	 */
61
+	function getVar($key, $format = 's') {
62
+		if ($format == 's' && in_array($key, array('from_uid', 'to_uid', 'date', 'link'))) {
63
+			return call_user_func(array($this,$key));
64
+		}
65
+		return parent::getVar($key, $format);
66
+	}
67
+
68
+	function from_uid() {
69
+		$ret = smart_getLinkedUnameFromId($this->getVar('from_uid', 'e'), 1, null, true);
70
+		return $ret;
71
+	}
72
+
73
+	function to_uid($withContact=false) {
74
+  		$ret = smart_getLinkedUnameFromId($this->getVar('to_uid', 'e'), 1, null, true);
75
+		return $ret;
76
+	}
77
+
78
+	function date() {
79
+		$ret = formatTimestamp($this->getVar('date','e'));
80
+		return $ret;
81
+	}
82
+
83
+	function link($full=false) {
84
+		$ret = $this->getVar('link','e');
85
+		if ($full) {
86
+			$myts = MyTextSanitizer::getInstance();
87
+			$ret = $myts->displayTarea($ret);
88
+			return $ret;
89
+		} else {
90
+			$ret = '<a href="' . $ret . '" alt="' . $this->getVar('link','e') . '" title="' . $this->getVar('link','e') . '">' .  _AM_SOBJECT_SENT_LINKS_GOTO . '</a>';
91
+			return $ret;
92
+		}
93
+	}
94
+
95
+	function getViewItemLink() {
96 96
 		$ret = '<a href="' . SMARTOBJECT_URL . 'admin/link.php?op=view&linkid=' . $this->getVar('linkid') . '"><img src="' . SMARTOBJECT_IMAGES_ACTIONS_URL . 'mail_find.png" alt="' . _AM_SOBJECT_SENT_LINK_VIEW . '" title="' . _AM_SOBJECT_SENT_LINK_VIEW . '" /></a>';
97 97
 		return $ret;
98
-    }
98
+	}
99 99
 
100
-    function getFromInfo() {
101
-    	// check if from_uid represent a user
100
+	function getFromInfo() {
101
+		// check if from_uid represent a user
102 102
 
103
-    	if ($this->getVar('from_uid')) {
103
+		if ($this->getVar('from_uid')) {
104 104
 			$user = smart_getLinkedUnameFromId($this->getVar('from_uid'));
105 105
 			if ($user == $GLOBALS['xoopsConfig']['anonymous']) {
106 106
 				$user = '<a href="mailto:' . $this->getVar('from_email') . '">' . $this->getVar('from_email') . '</a>';
107 107
 			}
108
-    	} else {
109
-    		$user = '<a href="mailto:' . $this->getVar('from_email') . '">' . $this->getVar('from_email') . '</a>';
110
-    	}
108
+		} else {
109
+			$user = '<a href="mailto:' . $this->getVar('from_email') . '">' . $this->getVar('from_email') . '</a>';
110
+		}
111 111
 
112
-    	return $user;
112
+		return $user;
113 113
 
114
-    }
114
+	}
115 115
 
116
-    function toArray() {
117
-    	$ret = parent::toArray();
118
-    	$ret['fromInfo'] = $this->getFromInfo();
119
-    	$ret['toInfo'] = $this->getToInfo();
120
-    	$ret['fullLink'] = $this->link(true);
121
-    	return $ret;
122
-    }
116
+	function toArray() {
117
+		$ret = parent::toArray();
118
+		$ret['fromInfo'] = $this->getFromInfo();
119
+		$ret['toInfo'] = $this->getToInfo();
120
+		$ret['fullLink'] = $this->link(true);
121
+		return $ret;
122
+	}
123 123
 
124
-    function getToInfo() {
125
-    	// check if from_uid represent a user
124
+	function getToInfo() {
125
+		// check if from_uid represent a user
126 126
 
127
-    	if ($this->getVar('to_uid')) {
127
+		if ($this->getVar('to_uid')) {
128 128
 			$user = smart_getLinkedUnameFromId($this->getVar('to_uid'));
129 129
 			if ($user == $GLOBALS['xoopsConfig']['anonymous']) {
130 130
 				$user = '<a href="mailto:' . $this->getVar('to_email') . '">' . $this->getVar('to_email') . '</a>';
131 131
 			}
132
-    	} else {
133
-    		$user = '<a href="mailto:' . $this->getVar('to_email') . '">' . $this->getVar('to_email') . '</a>';
134
-    	}
132
+		} else {
133
+			$user = '<a href="mailto:' . $this->getVar('to_email') . '">' . $this->getVar('to_email') . '</a>';
134
+		}
135 135
 
136
-    	return $user;
136
+		return $user;
137 137
 
138
-    }
138
+	}
139 139
 }
140 140
 class SmartobjectLinkHandler extends SmartPersistableObjectHandler {
141
-    function SmartobjectLinkHandler($db) {
141
+	function SmartobjectLinkHandler($db) {
142 142
 
143
-        $this->SmartPersistableObjectHandler($db, 'link', 'linkid', 'subject', 'body', 'smartobject');
144
-    }
143
+		$this->SmartPersistableObjectHandler($db, 'link', 'linkid', 'subject', 'body', 'smartobject');
144
+	}
145 145
 
146 146
 }
147 147
 ?>
148 148
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -30,12 +30,12 @@  discard block
 block discarded – undo
30 30
 if (!defined("XOOPS_ROOT_PATH")) {
31 31
     die("XOOPS root path not defined");
32 32
 }
33
-include_once XOOPS_ROOT_PATH."/modules/smartobject/class/smartobject.php";
33
+include_once XOOPS_ROOT_PATH . "/modules/smartobject/class/smartobject.php";
34 34
 class SmartobjectLink extends SmartObject {
35 35
 
36 36
     function SmartobjectLink() {
37 37
         $this->initVar('linkid', XOBJ_DTYPE_INT, '', true);
38
-        $this->initVar('date', XOBJ_DTYPE_INT, 0, false, null,'', false, _CO_SOBJECT_LINK_DATE, '', true, true, false);
38
+        $this->initVar('date', XOBJ_DTYPE_INT, 0, false, null, '', false, _CO_SOBJECT_LINK_DATE, '', true, true, false);
39 39
         $this->initVar('from_uid', XOBJ_DTYPE_INT, '', false, null, '', false, _CO_SOBJECT_LINK_FROM_UID, _CO_SOBJECT_LINK_FROM_UID_DSC);
40 40
         $this->initVar('from_email', XOBJ_DTYPE_TXTBOX, '', true, 255, '', false, _CO_SOBJECT_LINK_FROM_EMAIL, _CO_SOBJECT_LINK_FROM_EMAIL_DSC, true);
41 41
         $this->initVar('from_name', XOBJ_DTYPE_TXTBOX, '', true, 255, '', false, _CO_SOBJECT_LINK_FROM_NAME, _CO_SOBJECT_LINK_FROM_NAME_DSC, true);
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
     */
61 61
     function getVar($key, $format = 's') {
62 62
         if ($format == 's' && in_array($key, array('from_uid', 'to_uid', 'date', 'link'))) {
63
-            return call_user_func(array($this,$key));
63
+            return call_user_func(array($this, $key));
64 64
         }
65 65
         return parent::getVar($key, $format);
66 66
     }
@@ -70,24 +70,24 @@  discard block
 block discarded – undo
70 70
         return $ret;
71 71
     }
72 72
 
73
-    function to_uid($withContact=false) {
73
+    function to_uid($withContact = false) {
74 74
   	    $ret = smart_getLinkedUnameFromId($this->getVar('to_uid', 'e'), 1, null, true);
75 75
         return $ret;
76 76
     }
77 77
 
78 78
     function date() {
79
-        $ret = formatTimestamp($this->getVar('date','e'));
79
+        $ret = formatTimestamp($this->getVar('date', 'e'));
80 80
         return $ret;
81 81
     }
82 82
 
83
-    function link($full=false) {
84
-        $ret = $this->getVar('link','e');
83
+    function link($full = false) {
84
+        $ret = $this->getVar('link', 'e');
85 85
         if ($full) {
86 86
         	$myts = MyTextSanitizer::getInstance();
87 87
         	$ret = $myts->displayTarea($ret);
88 88
         	return $ret;
89 89
         } else {
90
-        	$ret = '<a href="' . $ret . '" alt="' . $this->getVar('link','e') . '" title="' . $this->getVar('link','e') . '">' .  _AM_SOBJECT_SENT_LINKS_GOTO . '</a>';
90
+        	$ret = '<a href="' . $ret . '" alt="' . $this->getVar('link', 'e') . '" title="' . $this->getVar('link', 'e') . '">' . _AM_SOBJECT_SENT_LINKS_GOTO . '</a>';
91 91
         	return $ret;
92 92
         }
93 93
     }
Please login to merge, or discard this patch.
class/smartobjectpermission.php 3 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -126,7 +126,6 @@
 block discarded – undo
126 126
      *  saveCategory_Permissions()
127 127
      *
128 128
      * @param array $groups : group with granted permission
129
-     * @param integer $categoryID : categoryID on which we are setting permissions for Categories and Forums
130 129
      * @param string $perm_name : name of the permission
131 130
      * @return boolean : TRUE if the no errors occured
132 131
      **/
Please login to merge, or discard this patch.
Indentation   +169 added lines, -169 removed lines patch added patch discarded remove patch
@@ -8,17 +8,17 @@  discard block
 block discarded – undo
8 8
  * Licence: GNU
9 9
  */
10 10
 if (!defined("XOOPS_ROOT_PATH")) {
11
-    die("XOOPS root path not defined");
11
+	die("XOOPS root path not defined");
12 12
 }
13 13
 
14 14
 class SmartobjectPermissionHandler extends XoopsObjectHandler
15 15
 {
16
-    var $handler;
17
-    function SmartObjectPermissionHandler($handler) {
18
-        $this->handler=$handler;
19
-    }
16
+	var $handler;
17
+	function SmartObjectPermissionHandler($handler) {
18
+		$this->handler=$handler;
19
+	}
20 20
 
21
-    /*
21
+	/*
22 22
      * Returns permissions for a certain type
23 23
      *
24 24
      * @param string $type "global", "forum" or "topic" (should perhaps have "post" as well - but I don't know)
@@ -26,62 +26,62 @@  discard block
 block discarded – undo
26 26
      *
27 27
      * @return array
28 28
      */
29
-    function getGrantedGroups($gperm_name, $id = null) {
30
-        static $groups;
31
-
32
-        if (!isset($groups[$gperm_name]) || ($id != null && !isset($groups[$gperm_name][$id]))) {
33
-            $smartModule =& $this->handler->getModuleInfo();
34
-            //Get group permissions handler
35
-            $gperm_handler =& xoops_gethandler('groupperm');
36
-
37
-            //Get groups allowed for an item id
38
-            $allowedgroups = $gperm_handler->getGroupIds($gperm_name, $id, $smartModule->getVar('mid'));
39
-            $groups[$gperm_name][$id] = $allowedgroups;
40
-        }
41
-        //Return the permission array
42
-        return isset($groups[$gperm_name][$id]) ? $groups[$gperm_name][$id] : array();
43
-    }
44
-
45
-    function getGrantedGroupsForIds($item_ids_array, $gperm_name=false) {
46
-
47
-        static $groups;
48
-
49
-        if ($gperm_name){
50
-            if (isset($groups[$gperm_name])) {
51
-                return $groups[$gperm_name];
52
-            }
53
-        } else {
54
-            // if !$gperm_name then we will fetch all permissions in the module so we don't need them again
55
-            return $groups;
56
-        }
57
-
58
-        $smartModule =& $this->handler->getModuleInfo();
59
-
60
-        $criteria = new CriteriaCompo();
61
-        $criteria->add(new Criteria('gperm_modid', $smartModule->getVar('mid')));
62
-
63
-        if ($gperm_name) {
64
-            $criteria->add(new Criteria('gperm_name', $gperm_name));
65
-        }
66
-
67
-        //Get group permissions handler
68
-        $gperm_handler =& xoops_gethandler('groupperm');
69
-
70
-        $permissionsObj = $gperm_handler->getObjects($criteria);
71
-
72
-        foreach ($permissionsObj as $permissionObj) {
73
-            $groups[$permissionObj->getVar('gperm_name')][$permissionObj->getVar('gperm_itemid')][] = $permissionObj->getVar('gperm_groupid');
74
-        }
75
-
76
-        //Return the permission array
77
-        if ($gperm_name) {
78
-            return isset($groups[$gperm_name]) ? $groups[$gperm_name] : array();
79
-        } else {
80
-            return isset($groups) ? $groups : array();
81
-        }
82
-    }
83
-
84
-    /*
29
+	function getGrantedGroups($gperm_name, $id = null) {
30
+		static $groups;
31
+
32
+		if (!isset($groups[$gperm_name]) || ($id != null && !isset($groups[$gperm_name][$id]))) {
33
+			$smartModule =& $this->handler->getModuleInfo();
34
+			//Get group permissions handler
35
+			$gperm_handler =& xoops_gethandler('groupperm');
36
+
37
+			//Get groups allowed for an item id
38
+			$allowedgroups = $gperm_handler->getGroupIds($gperm_name, $id, $smartModule->getVar('mid'));
39
+			$groups[$gperm_name][$id] = $allowedgroups;
40
+		}
41
+		//Return the permission array
42
+		return isset($groups[$gperm_name][$id]) ? $groups[$gperm_name][$id] : array();
43
+	}
44
+
45
+	function getGrantedGroupsForIds($item_ids_array, $gperm_name=false) {
46
+
47
+		static $groups;
48
+
49
+		if ($gperm_name){
50
+			if (isset($groups[$gperm_name])) {
51
+				return $groups[$gperm_name];
52
+			}
53
+		} else {
54
+			// if !$gperm_name then we will fetch all permissions in the module so we don't need them again
55
+			return $groups;
56
+		}
57
+
58
+		$smartModule =& $this->handler->getModuleInfo();
59
+
60
+		$criteria = new CriteriaCompo();
61
+		$criteria->add(new Criteria('gperm_modid', $smartModule->getVar('mid')));
62
+
63
+		if ($gperm_name) {
64
+			$criteria->add(new Criteria('gperm_name', $gperm_name));
65
+		}
66
+
67
+		//Get group permissions handler
68
+		$gperm_handler =& xoops_gethandler('groupperm');
69
+
70
+		$permissionsObj = $gperm_handler->getObjects($criteria);
71
+
72
+		foreach ($permissionsObj as $permissionObj) {
73
+			$groups[$permissionObj->getVar('gperm_name')][$permissionObj->getVar('gperm_itemid')][] = $permissionObj->getVar('gperm_groupid');
74
+		}
75
+
76
+		//Return the permission array
77
+		if ($gperm_name) {
78
+			return isset($groups[$gperm_name]) ? $groups[$gperm_name] : array();
79
+		} else {
80
+			return isset($groups) ? $groups : array();
81
+		}
82
+	}
83
+
84
+	/*
85 85
      * Returns permissions for a certain type
86 86
      *
87 87
      * @param string $type "global", "forum" or "topic" (should perhaps have "post" as well - but I don't know)
@@ -89,112 +89,112 @@  discard block
 block discarded – undo
89 89
      *
90 90
      * @return array
91 91
      */
92
-    function getGrantedItems($gperm_name, $id = null) {
93
-        global $xoopsUser;
94
-        static $permissions;
95
-
96
-        if (!isset($permissions[$gperm_name]) || ($id != null && !isset($permissions[$gperm_name][$id]))) {
97
-
98
-            $smartModule =& $this->handler->getModuleInfo();
99
-
100
-            if (is_object($smartModule)) {
101
-
102
-                //Get group permissions handler
103
-                $gperm_handler =& xoops_gethandler('groupperm');
104
-
105
-                //Get user's groups
106
-                $groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : array(XOOPS_GROUP_ANONYMOUS);
107
-
108
-                //Get all allowed item ids in this module and for this user's groups
109
-                $userpermissions =& $gperm_handler->getItemIds($gperm_name, $groups, $smartModule->getVar('mid'));
110
-                $permissions[$gperm_name] = $userpermissions;
111
-            }
112
-        }
113
-        //Return the permission array
114
-        return isset($permissions[$gperm_name]) ? $permissions[$gperm_name] : array();
115
-    }
116
-
117
-    function storeAllPermissionsForId($id) {
118
-        foreach ($this->handler->getPermissions() as $permission) {
119
-            $this->saveItem_Permissions($_POST[$permission['perm_name']], $id, $permission['perm_name']);
120
-        }
121
-    }
122
-
123
-    /**
124
-     * Saves permissions for the selected category
125
-     *
126
-     *  saveCategory_Permissions()
127
-     *
128
-     * @param array $groups : group with granted permission
129
-     * @param integer $categoryID : categoryID on which we are setting permissions for Categories and Forums
130
-     * @param string $perm_name : name of the permission
131
-     * @return boolean : TRUE if the no errors occured
132
-     **/
133
-
134
-    function saveItem_Permissions($groups, $itemid, $perm_name)
135
-    {
136
-        $smartModule =& $this->handler->getModuleInfo();
137
-
138
-        $result = true;
139
-        $module_id = $smartModule->getVar('mid');
140
-        $gperm_handler =& xoops_gethandler('groupperm');
141
-
142
-        // First, if the permissions are already there, delete them
143
-        $gperm_handler->deleteByModule($module_id, $perm_name, $itemid);
144
-        //echo "itemid : $itemid - perm : $perm_name - modid : $module_id";
145
-        //exit;
146
-        // Save the new permissions
147
-
148
-        if (count($groups) > 0) {
149
-            foreach ($groups as $group_id) {
150
-                $gperm_handler->addRight($perm_name, $itemid, $group_id, $module_id);
151
-            }
152
-        }
153
-        return $result;
154
-    }
155
-
156
-    /**
157
-     * Delete all permission for a specific item
158
-     *
159
-     *  deletePermissions()
160
-     *
161
-     * @param integer $itemid : id of the item for which to delete the permissions
162
-     * @return boolean : TRUE if the no errors occured
163
-     **/
164
-    function deletePermissions($itemid, $gperm_name)
165
-    {
166
-        global $xoopsModule;
167
-
168
-        $smartModule =& smartsection_getModuleInfo();
169
-
170
-        $result = true;
171
-        $module_id = $smartModule->getVar('mid')   ;
172
-        $gperm_handler =& xoops_gethandler('groupperm');
173
-
174
-
175
-        $gperm_handler->deleteByModule($module_id, $gperm_name, $itemid);
176
-
177
-        return $result;
178
-    }
179
-
180
-    /**
181
-     * Checks if the user has access to a specific permission on a given object
182
-     *
183
-     * @param string $gperm_name name of the permission to test
184
-     * @param int $gperm_itemid id of the object to check
185
-     * @return boolean : TRUE if user has access, FALSE if not
186
-     **/
187
-    function accessGranted($gperm_name, $gperm_itemid) {
188
-        global $xoopsUser;
189
-
190
-        $gperm_groupid = is_object($xoopsUser) ? $xoopsUser->getGroups() : array(XOOPS_GROUP_ANONYMOUS);
191
-        $smartModule =& $this->handler->getModuleInfo();
192
-        $gperm_modid = $smartModule->getVar('mid')   ;
193
-
194
-        //Get group permissions handler
195
-        $gperm_handler =& xoops_gethandler('groupperm');
196
-
197
-        return $gperm_handler->checkRight($gperm_name, $gperm_itemid, $gperm_groupid, $gperm_modid);
198
-    }
92
+	function getGrantedItems($gperm_name, $id = null) {
93
+		global $xoopsUser;
94
+		static $permissions;
95
+
96
+		if (!isset($permissions[$gperm_name]) || ($id != null && !isset($permissions[$gperm_name][$id]))) {
97
+
98
+			$smartModule =& $this->handler->getModuleInfo();
99
+
100
+			if (is_object($smartModule)) {
101
+
102
+				//Get group permissions handler
103
+				$gperm_handler =& xoops_gethandler('groupperm');
104
+
105
+				//Get user's groups
106
+				$groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : array(XOOPS_GROUP_ANONYMOUS);
107
+
108
+				//Get all allowed item ids in this module and for this user's groups
109
+				$userpermissions =& $gperm_handler->getItemIds($gperm_name, $groups, $smartModule->getVar('mid'));
110
+				$permissions[$gperm_name] = $userpermissions;
111
+			}
112
+		}
113
+		//Return the permission array
114
+		return isset($permissions[$gperm_name]) ? $permissions[$gperm_name] : array();
115
+	}
116
+
117
+	function storeAllPermissionsForId($id) {
118
+		foreach ($this->handler->getPermissions() as $permission) {
119
+			$this->saveItem_Permissions($_POST[$permission['perm_name']], $id, $permission['perm_name']);
120
+		}
121
+	}
122
+
123
+	/**
124
+	 * Saves permissions for the selected category
125
+	 *
126
+	 *  saveCategory_Permissions()
127
+	 *
128
+	 * @param array $groups : group with granted permission
129
+	 * @param integer $categoryID : categoryID on which we are setting permissions for Categories and Forums
130
+	 * @param string $perm_name : name of the permission
131
+	 * @return boolean : TRUE if the no errors occured
132
+	 **/
133
+
134
+	function saveItem_Permissions($groups, $itemid, $perm_name)
135
+	{
136
+		$smartModule =& $this->handler->getModuleInfo();
137
+
138
+		$result = true;
139
+		$module_id = $smartModule->getVar('mid');
140
+		$gperm_handler =& xoops_gethandler('groupperm');
141
+
142
+		// First, if the permissions are already there, delete them
143
+		$gperm_handler->deleteByModule($module_id, $perm_name, $itemid);
144
+		//echo "itemid : $itemid - perm : $perm_name - modid : $module_id";
145
+		//exit;
146
+		// Save the new permissions
147
+
148
+		if (count($groups) > 0) {
149
+			foreach ($groups as $group_id) {
150
+				$gperm_handler->addRight($perm_name, $itemid, $group_id, $module_id);
151
+			}
152
+		}
153
+		return $result;
154
+	}
155
+
156
+	/**
157
+	 * Delete all permission for a specific item
158
+	 *
159
+	 *  deletePermissions()
160
+	 *
161
+	 * @param integer $itemid : id of the item for which to delete the permissions
162
+	 * @return boolean : TRUE if the no errors occured
163
+	 **/
164
+	function deletePermissions($itemid, $gperm_name)
165
+	{
166
+		global $xoopsModule;
167
+
168
+		$smartModule =& smartsection_getModuleInfo();
169
+
170
+		$result = true;
171
+		$module_id = $smartModule->getVar('mid')   ;
172
+		$gperm_handler =& xoops_gethandler('groupperm');
173
+
174
+
175
+		$gperm_handler->deleteByModule($module_id, $gperm_name, $itemid);
176
+
177
+		return $result;
178
+	}
179
+
180
+	/**
181
+	 * Checks if the user has access to a specific permission on a given object
182
+	 *
183
+	 * @param string $gperm_name name of the permission to test
184
+	 * @param int $gperm_itemid id of the object to check
185
+	 * @return boolean : TRUE if user has access, FALSE if not
186
+	 **/
187
+	function accessGranted($gperm_name, $gperm_itemid) {
188
+		global $xoopsUser;
189
+
190
+		$gperm_groupid = is_object($xoopsUser) ? $xoopsUser->getGroups() : array(XOOPS_GROUP_ANONYMOUS);
191
+		$smartModule =& $this->handler->getModuleInfo();
192
+		$gperm_modid = $smartModule->getVar('mid')   ;
193
+
194
+		//Get group permissions handler
195
+		$gperm_handler =& xoops_gethandler('groupperm');
196
+
197
+		return $gperm_handler->checkRight($gperm_name, $gperm_itemid, $gperm_groupid, $gperm_modid);
198
+	}
199 199
 }
200 200
 ?>
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 {
16 16
     var $handler;
17 17
     function SmartObjectPermissionHandler($handler) {
18
-        $this->handler=$handler;
18
+        $this->handler = $handler;
19 19
     }
20 20
 
21 21
     /*
@@ -30,9 +30,9 @@  discard block
 block discarded – undo
30 30
         static $groups;
31 31
 
32 32
         if (!isset($groups[$gperm_name]) || ($id != null && !isset($groups[$gperm_name][$id]))) {
33
-            $smartModule =& $this->handler->getModuleInfo();
33
+            $smartModule = & $this->handler->getModuleInfo();
34 34
             //Get group permissions handler
35
-            $gperm_handler =& xoops_gethandler('groupperm');
35
+            $gperm_handler = & xoops_gethandler('groupperm');
36 36
 
37 37
             //Get groups allowed for an item id
38 38
             $allowedgroups = $gperm_handler->getGroupIds($gperm_name, $id, $smartModule->getVar('mid'));
@@ -42,11 +42,11 @@  discard block
 block discarded – undo
42 42
         return isset($groups[$gperm_name][$id]) ? $groups[$gperm_name][$id] : array();
43 43
     }
44 44
 
45
-    function getGrantedGroupsForIds($item_ids_array, $gperm_name=false) {
45
+    function getGrantedGroupsForIds($item_ids_array, $gperm_name = false) {
46 46
 
47 47
         static $groups;
48 48
 
49
-        if ($gperm_name){
49
+        if ($gperm_name) {
50 50
             if (isset($groups[$gperm_name])) {
51 51
                 return $groups[$gperm_name];
52 52
             }
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
             return $groups;
56 56
         }
57 57
 
58
-        $smartModule =& $this->handler->getModuleInfo();
58
+        $smartModule = & $this->handler->getModuleInfo();
59 59
 
60 60
         $criteria = new CriteriaCompo();
61 61
         $criteria->add(new Criteria('gperm_modid', $smartModule->getVar('mid')));
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
         }
66 66
 
67 67
         //Get group permissions handler
68
-        $gperm_handler =& xoops_gethandler('groupperm');
68
+        $gperm_handler = & xoops_gethandler('groupperm');
69 69
 
70 70
         $permissionsObj = $gperm_handler->getObjects($criteria);
71 71
 
@@ -95,18 +95,18 @@  discard block
 block discarded – undo
95 95
 
96 96
         if (!isset($permissions[$gperm_name]) || ($id != null && !isset($permissions[$gperm_name][$id]))) {
97 97
 
98
-            $smartModule =& $this->handler->getModuleInfo();
98
+            $smartModule = & $this->handler->getModuleInfo();
99 99
 
100 100
             if (is_object($smartModule)) {
101 101
 
102 102
                 //Get group permissions handler
103
-                $gperm_handler =& xoops_gethandler('groupperm');
103
+                $gperm_handler = & xoops_gethandler('groupperm');
104 104
 
105 105
                 //Get user's groups
106 106
                 $groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : array(XOOPS_GROUP_ANONYMOUS);
107 107
 
108 108
                 //Get all allowed item ids in this module and for this user's groups
109
-                $userpermissions =& $gperm_handler->getItemIds($gperm_name, $groups, $smartModule->getVar('mid'));
109
+                $userpermissions = & $gperm_handler->getItemIds($gperm_name, $groups, $smartModule->getVar('mid'));
110 110
                 $permissions[$gperm_name] = $userpermissions;
111 111
             }
112 112
         }
@@ -133,11 +133,11 @@  discard block
 block discarded – undo
133 133
 
134 134
     function saveItem_Permissions($groups, $itemid, $perm_name)
135 135
     {
136
-        $smartModule =& $this->handler->getModuleInfo();
136
+        $smartModule = & $this->handler->getModuleInfo();
137 137
 
138 138
         $result = true;
139 139
         $module_id = $smartModule->getVar('mid');
140
-        $gperm_handler =& xoops_gethandler('groupperm');
140
+        $gperm_handler = & xoops_gethandler('groupperm');
141 141
 
142 142
         // First, if the permissions are already there, delete them
143 143
         $gperm_handler->deleteByModule($module_id, $perm_name, $itemid);
@@ -165,11 +165,11 @@  discard block
 block discarded – undo
165 165
     {
166 166
         global $xoopsModule;
167 167
 
168
-        $smartModule =& smartsection_getModuleInfo();
168
+        $smartModule = & smartsection_getModuleInfo();
169 169
 
170 170
         $result = true;
171
-        $module_id = $smartModule->getVar('mid')   ;
172
-        $gperm_handler =& xoops_gethandler('groupperm');
171
+        $module_id = $smartModule->getVar('mid');
172
+        $gperm_handler = & xoops_gethandler('groupperm');
173 173
 
174 174
 
175 175
         $gperm_handler->deleteByModule($module_id, $gperm_name, $itemid);
@@ -188,11 +188,11 @@  discard block
 block discarded – undo
188 188
         global $xoopsUser;
189 189
 
190 190
         $gperm_groupid = is_object($xoopsUser) ? $xoopsUser->getGroups() : array(XOOPS_GROUP_ANONYMOUS);
191
-        $smartModule =& $this->handler->getModuleInfo();
192
-        $gperm_modid = $smartModule->getVar('mid')   ;
191
+        $smartModule = & $this->handler->getModuleInfo();
192
+        $gperm_modid = $smartModule->getVar('mid');
193 193
 
194 194
         //Get group permissions handler
195
-        $gperm_handler =& xoops_gethandler('groupperm');
195
+        $gperm_handler = & xoops_gethandler('groupperm');
196 196
 
197 197
         return $gperm_handler->checkRight($gperm_name, $gperm_itemid, $gperm_groupid, $gperm_modid);
198 198
     }
Please login to merge, or discard this patch.
class/smartobjectsingleview.php 3 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -66,6 +66,7 @@  discard block
 block discarded – undo
66 66
 
67 67
     /**
68 68
      * Constructor
69
+     * @param SmartObject $object
69 70
      */
70 71
     function SmartObjectSingleView(&$object, $userSide=false, $actions=array(), $headerAsRow=true)
71 72
     {
@@ -75,6 +76,9 @@  discard block
 block discarded – undo
75 76
         $this->_headerAsRow = $headerAsRow;
76 77
     }
77 78
 
79
+    /**
80
+     * @param SmartObjectRow $rowObj
81
+     */
78 82
     function addRow($rowObj) {
79 83
         $this->_rows[] = $rowObj;
80 84
     }
Please login to merge, or discard this patch.
Indentation   +92 added lines, -94 removed lines patch added patch discarded remove patch
@@ -5,9 +5,7 @@  discard block
 block discarded – undo
5 5
  *
6 6
  * @license GNU
7 7
  * @author marcan <[email protected]>
8
-
9 8
  * @version $Id: smartobjectsingleview.php 839 2008-02-10 02:40:13Z malanciault $
10
-
11 9
  * @link http://smartfactory.ca The SmartFactory
12 10
  * @package SmartObject
13 11
  */
@@ -24,26 +22,26 @@  discard block
 block discarded – undo
24 22
  */
25 23
 class SmartObjectRow {
26 24
 
27
-    var $_keyname;
28
-    var $_align;
29
-    var $_customMethodForValue;
30
-    var $_header;
31
-    var $_class;
32
-
33
-    function SmartObjectRow($keyname, $customMethodForValue=false, $header=false, $class=false) {
34
-        $this->_keyname = $keyname;
35
-        $this->_customMethodForValue = $customMethodForValue;
36
-        $this->_header = $header;
37
-        $this->_class = $class;
38
-    }
39
-
40
-    function getKeyName() {
41
-        return $this->_keyname;
42
-    }
43
-
44
-    function isHeader() {
45
-        return $this->_header;
46
-    }
25
+	var $_keyname;
26
+	var $_align;
27
+	var $_customMethodForValue;
28
+	var $_header;
29
+	var $_class;
30
+
31
+	function SmartObjectRow($keyname, $customMethodForValue=false, $header=false, $class=false) {
32
+		$this->_keyname = $keyname;
33
+		$this->_customMethodForValue = $customMethodForValue;
34
+		$this->_header = $header;
35
+		$this->_class = $class;
36
+	}
37
+
38
+	function getKeyName() {
39
+		return $this->_keyname;
40
+	}
41
+
42
+	function isHeader() {
43
+		return $this->_header;
44
+	}
47 45
 }
48 46
 
49 47
 /**
@@ -57,78 +55,78 @@  discard block
 block discarded – undo
57 55
  */
58 56
 class SmartObjectSingleView {
59 57
 
60
-    var $_object;
61
-    var $_userSide;
62
-    var $_tpl;
63
-    var $_rows;
64
-    var $_actions;
65
-    var $_headerAsRow=true;
66
-
67
-    /**
68
-     * Constructor
69
-     */
70
-    function SmartObjectSingleView(&$object, $userSide=false, $actions=array(), $headerAsRow=true)
71
-    {
72
-        $this->_object = $object;
73
-        $this->_userSide = $userSide;
74
-        $this->_actions = $actions;
75
-        $this->_headerAsRow = $headerAsRow;
76
-    }
77
-
78
-    function addRow($rowObj) {
79
-        $this->_rows[] = $rowObj;
80
-    }
81
-
82
-    function render($fetchOnly=false, $debug=false)
83
-    {
84
-        include_once XOOPS_ROOT_PATH . '/class/template.php';
85
-
86
-        $this->_tpl = new XoopsTpl();
87
-        $vars = $this->_object->vars;
88
-        $smartobject_object_array = array();
89
-
90
-        foreach ($this->_rows as $row) {
91
-            $key = $row->getKeyName();
92
-            if ($row->_customMethodForValue && method_exists($this->_object, $row->_customMethodForValue)) {
93
-                $method = $row->_customMethodForValue;
94
-                $value = $this->_object->$method();
95
-            } else {
96
-                $value = $this->_object->getVar($row->getKeyName());
97
-            }
98
-            if ($row->isHeader()) {
99
-                $this->_tpl->assign('smartobject_single_view_header_caption', $this->_object->vars[$key]['form_caption']);
100
-                $this->_tpl->assign('smartobject_single_view_header_value', $value);
101
-            } else {
102
-                $smartobject_object_array[$key]['value'] = $value;
103
-                $smartobject_object_array[$key]['header'] = $row->isHeader();
104
-                $smartobject_object_array[$key]['caption'] = $this->_object->vars[$key]['form_caption'];
105
-            }
106
-        }
107
-        $action_row = '';
108
-        if (in_array('edit', $this->_actions)) {
109
-            $action_row .= $this->_object->getEditItemLink(false, true, true);
110
-        }
111
-        if (in_array('delete', $this->_actions)) {
112
-            $action_row .= $this->_object->getDeleteItemLink(false, true, true);
113
-        }
114
-        if ($action_row) {
115
-            $smartobject_object_array['zaction']['value'] = $action_row;
116
-            $smartobject_object_array['zaction']['caption'] = _CO_SOBJECT_ACTIONS;
117
-        }
118
-
119
-        $this->_tpl->assign('smartobject_header_as_row', $this->_headerAsRow);
120
-        $this->_tpl->assign('smartobject_object_array', $smartobject_object_array);
121
-
122
-        if ($fetchOnly) {
123
-            return $this->_tpl->fetch( 'db:smartobject_singleview_display.html' );
124
-        } else {
125
-            $this->_tpl->display( 'db:smartobject_singleview_display.html' );
126
-        }
127
-    }
128
-
129
-    function fetch($debug=false) {
130
-        return $this->render(true, $debug);
131
-    }
58
+	var $_object;
59
+	var $_userSide;
60
+	var $_tpl;
61
+	var $_rows;
62
+	var $_actions;
63
+	var $_headerAsRow=true;
64
+
65
+	/**
66
+	 * Constructor
67
+	 */
68
+	function SmartObjectSingleView(&$object, $userSide=false, $actions=array(), $headerAsRow=true)
69
+	{
70
+		$this->_object = $object;
71
+		$this->_userSide = $userSide;
72
+		$this->_actions = $actions;
73
+		$this->_headerAsRow = $headerAsRow;
74
+	}
75
+
76
+	function addRow($rowObj) {
77
+		$this->_rows[] = $rowObj;
78
+	}
79
+
80
+	function render($fetchOnly=false, $debug=false)
81
+	{
82
+		include_once XOOPS_ROOT_PATH . '/class/template.php';
83
+
84
+		$this->_tpl = new XoopsTpl();
85
+		$vars = $this->_object->vars;
86
+		$smartobject_object_array = array();
87
+
88
+		foreach ($this->_rows as $row) {
89
+			$key = $row->getKeyName();
90
+			if ($row->_customMethodForValue && method_exists($this->_object, $row->_customMethodForValue)) {
91
+				$method = $row->_customMethodForValue;
92
+				$value = $this->_object->$method();
93
+			} else {
94
+				$value = $this->_object->getVar($row->getKeyName());
95
+			}
96
+			if ($row->isHeader()) {
97
+				$this->_tpl->assign('smartobject_single_view_header_caption', $this->_object->vars[$key]['form_caption']);
98
+				$this->_tpl->assign('smartobject_single_view_header_value', $value);
99
+			} else {
100
+				$smartobject_object_array[$key]['value'] = $value;
101
+				$smartobject_object_array[$key]['header'] = $row->isHeader();
102
+				$smartobject_object_array[$key]['caption'] = $this->_object->vars[$key]['form_caption'];
103
+			}
104
+		}
105
+		$action_row = '';
106
+		if (in_array('edit', $this->_actions)) {
107
+			$action_row .= $this->_object->getEditItemLink(false, true, true);
108
+		}
109
+		if (in_array('delete', $this->_actions)) {
110
+			$action_row .= $this->_object->getDeleteItemLink(false, true, true);
111
+		}
112
+		if ($action_row) {
113
+			$smartobject_object_array['zaction']['value'] = $action_row;
114
+			$smartobject_object_array['zaction']['caption'] = _CO_SOBJECT_ACTIONS;
115
+		}
116
+
117
+		$this->_tpl->assign('smartobject_header_as_row', $this->_headerAsRow);
118
+		$this->_tpl->assign('smartobject_object_array', $smartobject_object_array);
119
+
120
+		if ($fetchOnly) {
121
+			return $this->_tpl->fetch( 'db:smartobject_singleview_display.html' );
122
+		} else {
123
+			$this->_tpl->display( 'db:smartobject_singleview_display.html' );
124
+		}
125
+	}
126
+
127
+	function fetch($debug=false) {
128
+		return $this->render(true, $debug);
129
+	}
132 130
 }
133 131
 
134 132
 ?>
135 133
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
     var $_header;
31 31
     var $_class;
32 32
 
33
-    function SmartObjectRow($keyname, $customMethodForValue=false, $header=false, $class=false) {
33
+    function SmartObjectRow($keyname, $customMethodForValue = false, $header = false, $class = false) {
34 34
         $this->_keyname = $keyname;
35 35
         $this->_customMethodForValue = $customMethodForValue;
36 36
         $this->_header = $header;
@@ -62,12 +62,12 @@  discard block
 block discarded – undo
62 62
     var $_tpl;
63 63
     var $_rows;
64 64
     var $_actions;
65
-    var $_headerAsRow=true;
65
+    var $_headerAsRow = true;
66 66
 
67 67
     /**
68 68
      * Constructor
69 69
      */
70
-    function SmartObjectSingleView(&$object, $userSide=false, $actions=array(), $headerAsRow=true)
70
+    function SmartObjectSingleView(&$object, $userSide = false, $actions = array(), $headerAsRow = true)
71 71
     {
72 72
         $this->_object = $object;
73 73
         $this->_userSide = $userSide;
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
         $this->_rows[] = $rowObj;
80 80
     }
81 81
 
82
-    function render($fetchOnly=false, $debug=false)
82
+    function render($fetchOnly = false, $debug = false)
83 83
     {
84 84
         include_once XOOPS_ROOT_PATH . '/class/template.php';
85 85
 
@@ -120,13 +120,13 @@  discard block
 block discarded – undo
120 120
         $this->_tpl->assign('smartobject_object_array', $smartobject_object_array);
121 121
 
122 122
         if ($fetchOnly) {
123
-            return $this->_tpl->fetch( 'db:smartobject_singleview_display.html' );
123
+            return $this->_tpl->fetch('db:smartobject_singleview_display.html');
124 124
         } else {
125
-            $this->_tpl->display( 'db:smartobject_singleview_display.html' );
125
+            $this->_tpl->display('db:smartobject_singleview_display.html');
126 126
         }
127 127
     }
128 128
 
129
-    function fetch($debug=false) {
129
+    function fetch($debug = false) {
130 130
         return $this->render(true, $debug);
131 131
     }
132 132
 }
Please login to merge, or discard this patch.
class/smartobjectsregistry.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
 	/**
21 21
 	 * Access the only instance of this class
22 22
      *
23
-     * @return	object
23
+     * @return	SmartObjectsRegistry
24 24
      *
25 25
      * @static
26 26
      * @staticvar   object
Please login to merge, or discard this patch.
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -19,11 +19,11 @@  discard block
 block discarded – undo
19 19
 
20 20
 	/**
21 21
 	 * Access the only instance of this class
22
-     *
23
-     * @return	object
24
-     *
25
-     * @static
26
-     * @staticvar   object
22
+	 *
23
+	 * @return	object
24
+	 *
25
+	 * @static
26
+	 * @staticvar   object
27 27
 	 */
28 28
 	function &getInstance()
29 29
 	{
@@ -35,13 +35,13 @@  discard block
 block discarded – undo
35 35
 	}
36 36
 
37 37
 	/**
38
-    * Adding objects to the registry
39
-    *
40
-    * @param SmartPersistableObjectHandler $handler of the objects to add
41
-    * @param CriteriaCompo $criteria to pass to the getObjects method of the handler (with id_as_key)
42
-    *
43
-    * @return FALSE if an error occured
44
-    */
38
+	 * Adding objects to the registry
39
+	 *
40
+	 * @param SmartPersistableObjectHandler $handler of the objects to add
41
+	 * @param CriteriaCompo $criteria to pass to the getObjects method of the handler (with id_as_key)
42
+	 *
43
+	 * @return FALSE if an error occured
44
+	 */
45 45
 	function addObjectsFromHandler(&$handler, $criteria=false) {
46 46
 		if (method_exists($handler, 'getObjects')) {
47 47
 			$objects = $handler->getObjects($criteria, true);
@@ -53,15 +53,15 @@  discard block
 block discarded – undo
53 53
 	}
54 54
 
55 55
 	/**
56
-    * Adding objects to the registry from an item name
57
-    * This method will fetch the handler of the item / module and call the addObjectsFromHandler
58
-    *
59
-    * @param string $item name of the item
60
-    * @param string $modulename name of the module
61
-    * @param CriteriaCompo $criteria to pass to the getObjects method of the handler (with id_as_key)
62
-    *
63
-    * @return FALSE if an error occured
64
-    */
56
+	 * Adding objects to the registry from an item name
57
+	 * This method will fetch the handler of the item / module and call the addObjectsFromHandler
58
+	 *
59
+	 * @param string $item name of the item
60
+	 * @param string $modulename name of the module
61
+	 * @param CriteriaCompo $criteria to pass to the getObjects method of the handler (with id_as_key)
62
+	 *
63
+	 * @return FALSE if an error occured
64
+	 */
65 65
 	function addObjectsFromItemName($item, $modulename=false, $criteria=false) {
66 66
 		if (!$modulename) {
67 67
 			global $xoopsModule;
@@ -83,13 +83,13 @@  discard block
 block discarded – undo
83 83
 	}
84 84
 
85 85
 	/**
86
-    * Fetching objects from the registry
87
-    *
88
-    * @param string $itemname
89
-    * @param string $modulename
90
-    *
91
-    * @return the requested objects or FALSE if they don't exists in the registry
92
-    */
86
+	 * Fetching objects from the registry
87
+	 *
88
+	 * @param string $itemname
89
+	 * @param string $modulename
90
+	 *
91
+	 * @return the requested objects or FALSE if they don't exists in the registry
92
+	 */
93 93
 	function getObjects($itemname, $modulename) {
94 94
 		if (!$modulename) {
95 95
 			global $xoopsModule;
@@ -113,13 +113,13 @@  discard block
 block discarded – undo
113 113
 	}
114 114
 
115 115
 	/**
116
-    * Fetching objects from the registry, as a list : objectid => identifier
117
-    *
118
-    * @param string $itemname
119
-    * @param string $modulename
120
-    *
121
-    * @return the requested objects or FALSE if they don't exists in the registry
122
-    */
116
+	 * Fetching objects from the registry, as a list : objectid => identifier
117
+	 *
118
+	 * @param string $itemname
119
+	 * @param string $modulename
120
+	 *
121
+	 * @return the requested objects or FALSE if they don't exists in the registry
122
+	 */
123 123
 	function getList($itemname, $modulename) {
124 124
 		if (!$modulename) {
125 125
 			global $xoopsModule;
@@ -143,13 +143,13 @@  discard block
 block discarded – undo
143 143
 	}
144 144
 
145 145
 	/**
146
-    * Retreive a single object
147
-    *
148
-    * @param string $itemname
149
-    * @param string $key
150
-    *
151
-    * @return the requestd object or FALSE if they don't exists in the registry
152
-    */
146
+	 * Retreive a single object
147
+	 *
148
+	 * @param string $itemname
149
+	 * @param string $key
150
+	 *
151
+	 * @return the requestd object or FALSE if they don't exists in the registry
152
+	 */
153 153
 	function getSingleObject($itemname, $key, $modulename=false) {
154 154
 		if (!$modulename) {
155 155
 			global $xoopsModule;
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
     *
43 43
     * @return FALSE if an error occured
44 44
     */
45
-	function addObjectsFromHandler(&$handler, $criteria=false) {
45
+	function addObjectsFromHandler(&$handler, $criteria = false) {
46 46
 		if (method_exists($handler, 'getObjects')) {
47 47
 			$objects = $handler->getObjects($criteria, true);
48 48
 			$this->_registryArray['objects'][$handler->_moduleName][$handler->_itemname] = $objects;
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
     *
63 63
     * @return FALSE if an error occured
64 64
     */
65
-	function addObjectsFromItemName($item, $modulename=false, $criteria=false) {
65
+	function addObjectsFromItemName($item, $modulename = false, $criteria = false) {
66 66
 		if (!$modulename) {
67 67
 			global $xoopsModule;
68 68
 			if (!is_object($xoopsModule)) {
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
     *
151 151
     * @return the requestd object or FALSE if they don't exists in the registry
152 152
     */
153
-	function getSingleObject($itemname, $key, $modulename=false) {
153
+	function getSingleObject($itemname, $key, $modulename = false) {
154 154
 		if (!$modulename) {
155 155
 			global $xoopsModule;
156 156
 			if (!is_object($xoopsModule)) {
Please login to merge, or discard this patch.