Passed
Push — master ( 2ecc51...c1b656 )
by Michael
04:26 queued 02:02
created
header.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
  * @author       XOOPS Development Team,
19 19
  */
20 20
 
21
-include __DIR__ . '/../../mainfile.php';
21
+include __DIR__.'/../../mainfile.php';
22 22
 $moduleDirName = basename(__DIR__);
23
-include __DIR__ . '/include/functions.php';
24
-$xoops_module_header = '<link rel="stylesheet" type="text/css" href="' . XOOPS_URL . '/modules/' . $moduleDirName . '/assets/css/efqdirectory.css">';
23
+include __DIR__.'/include/functions.php';
24
+$xoops_module_header = '<link rel="stylesheet" type="text/css" href="'.XOOPS_URL.'/modules/'.$moduleDirName.'/assets/css/efqdirectory.css">';
Please login to merge, or discard this patch.
class/class.couponhandler.php 2 patches
Indentation   +148 added lines, -148 removed lines patch added patch discarded remove patch
@@ -15,168 +15,168 @@
 block discarded – undo
15 15
 
16 16
 class efqCouponHandler
17 17
 {
18
-    public $db;
19
-    public $coupon = array();
20
-    public $couponid;
21
-    public $descr;
22
-    public $itemid;
23
-    public $publish;
24
-    public $expire;
25
-    public $heading;
26
-    public $message;
27
-    public $lbr;
28
-    public $_new   = false;
29
-
30
-    public function __construct()
31
-    {
32
-        $this->db = XoopsDatabaseFactory::getDatabaseConnection();
33
-    }
34
-
35
-    public function create()
36
-    {
37
-        global $myts;
38
-        $this->descr   = $myts->makeTareaData4Save($_POST['description']);
39
-        $this->image   = $myts->makeTboxData4Save($_POST['image']);
40
-        $this->itemid  = (int)$_POST['itemid'];
41
-        $this->publish = strtotime($_POST['publish']['date']) + $_POST['publish']['time'];
42
-        if (isset($_POST['expire_enable']) && ($_POST['expire_enable'] == 1)) {
43
-            $this->expire = strtotime($_POST['expire']['date']) + $_POST['expire']['time'];
44
-        } else {
45
-            $this->expire = 0;
46
-        }
47
-        $this->lbr     = $_POST['lbr'];
48
-        $this->heading = $myts->makeTboxData4Save($_POST['heading']);
49
-        if (!isset($_POST['couponid'])) {
50
-            $this->_new    = true;
51
-            $this->message = _MD_COUPONADDED;
52
-            if ($this->insert()) {
53
-                return true;
54
-            } else {
55
-                return false;
56
-            }
57
-        } else {
58
-            $this->message  = _MD_COUPONUPDATED;
59
-            $this->couponid = (int)$_POST['couponid'];
60
-            if ($this->update()) {
61
-                return true;
62
-            } else {
63
-                return false;
64
-            }
65
-        }
66
-    }
67
-
68
-    public function insert()
69
-    {
70
-        $sql = 'INSERT INTO ' . $this->db->prefix($module->getVar('dirname', 'n') . '_coupon') . '
18
+	public $db;
19
+	public $coupon = array();
20
+	public $couponid;
21
+	public $descr;
22
+	public $itemid;
23
+	public $publish;
24
+	public $expire;
25
+	public $heading;
26
+	public $message;
27
+	public $lbr;
28
+	public $_new   = false;
29
+
30
+	public function __construct()
31
+	{
32
+		$this->db = XoopsDatabaseFactory::getDatabaseConnection();
33
+	}
34
+
35
+	public function create()
36
+	{
37
+		global $myts;
38
+		$this->descr   = $myts->makeTareaData4Save($_POST['description']);
39
+		$this->image   = $myts->makeTboxData4Save($_POST['image']);
40
+		$this->itemid  = (int)$_POST['itemid'];
41
+		$this->publish = strtotime($_POST['publish']['date']) + $_POST['publish']['time'];
42
+		if (isset($_POST['expire_enable']) && ($_POST['expire_enable'] == 1)) {
43
+			$this->expire = strtotime($_POST['expire']['date']) + $_POST['expire']['time'];
44
+		} else {
45
+			$this->expire = 0;
46
+		}
47
+		$this->lbr     = $_POST['lbr'];
48
+		$this->heading = $myts->makeTboxData4Save($_POST['heading']);
49
+		if (!isset($_POST['couponid'])) {
50
+			$this->_new    = true;
51
+			$this->message = _MD_COUPONADDED;
52
+			if ($this->insert()) {
53
+				return true;
54
+			} else {
55
+				return false;
56
+			}
57
+		} else {
58
+			$this->message  = _MD_COUPONUPDATED;
59
+			$this->couponid = (int)$_POST['couponid'];
60
+			if ($this->update()) {
61
+				return true;
62
+			} else {
63
+				return false;
64
+			}
65
+		}
66
+	}
67
+
68
+	public function insert()
69
+	{
70
+		$sql = 'INSERT INTO ' . $this->db->prefix($module->getVar('dirname', 'n') . '_coupon') . '
71 71
             (itemid, description, image, publish, expire, heading, lbr) VALUES
72 72
             (' . $this->itemid . ', ' . $this->db->quoteString($this->descr) . ', ' . $this->db->quoteString($this->image) . ', ' . $this->publish . ', ' . $this->expire . ', ' . $this->db->quoteString($this->heading) . ', ' . $this->lbr . ')';
73
-        if ($this->db->query($sql)) {
74
-            $this->couponid = $this->db->getInsertId();
73
+		if ($this->db->query($sql)) {
74
+			$this->couponid = $this->db->getInsertId();
75 75
 
76
-            return true;
77
-        }
76
+			return true;
77
+		}
78 78
 
79
-        return false;
80
-    }
79
+		return false;
80
+	}
81 81
 
82
-    public function update()
83
-    {
84
-        $sql = 'UPDATE ' . $this->db->prefix($module->getVar('dirname', 'n') . '_coupon') . ' SET
82
+	public function update()
83
+	{
84
+		$sql = 'UPDATE ' . $this->db->prefix($module->getVar('dirname', 'n') . '_coupon') . ' SET
85 85
             description = ' . $this->db->quoteString($this->descr) . ',
86 86
             image = ' . $this->db->quoteString($this->image) . ',
87 87
             publish = ' . $this->publish . ',
88 88
             lbr = ' . $this->lbr . ',
89 89
             heading = ' . $this->db->quoteString($this->heading) . ",
90 90
             expire = $this->expire WHERE couponid = $this->couponid";
91
-        $this->db->query($sql);
92
-
93
-        return true;
94
-    }
95
-
96
-    public function get($couponid = false)
97
-    {
98
-        if ($couponid === false) {
99
-            //echo 'couponid is false';
100
-            return false;
101
-        }
102
-        //$couponid = (int)($couponid);
103
-        if ($couponid > 0) {
104
-            $sql = 'SELECT itemid, description, image, publish, expire, heading, lbr FROM ' . $this->db->prefix($module->getVar('dirname', 'n') . '_coupon') . ' WHERE couponid=' . $couponid;
105
-            //echo $sql;
106
-            if (!$result = $this->db->query($sql)) {
107
-                return false;
108
-            }
109
-            while (list($itemid, $descr, $image, $publish, $expire, $heading, $lbr) = $this->db->fetchRow($result)) {
110
-                $this->itemid  = $itemid;
111
-                $this->descr   = $descr;
112
-                $this->image   = $image;
113
-                $this->publish = $publish;
114
-                $this->expire  = $expire;
115
-                $this->heading = $heading;
116
-                $this->lbr     = $lbr;
117
-            }
118
-
119
-            return true;
120
-        }
121
-
122
-        return false;
123
-    }
124
-
125
-    public function delete($couponid)
126
-    {
127
-        $sql = 'DELETE FROM ' . $this->db->prefix($module->getVar('dirname', 'n') . '_coupon') . ' WHERE couponid=' . (int)$couponid;
128
-        $this->db->query($sql);
129
-
130
-        return true;
131
-    }
132
-
133
-    /* Returns number of coupons for a listing
91
+		$this->db->query($sql);
92
+
93
+		return true;
94
+	}
95
+
96
+	public function get($couponid = false)
97
+	{
98
+		if ($couponid === false) {
99
+			//echo 'couponid is false';
100
+			return false;
101
+		}
102
+		//$couponid = (int)($couponid);
103
+		if ($couponid > 0) {
104
+			$sql = 'SELECT itemid, description, image, publish, expire, heading, lbr FROM ' . $this->db->prefix($module->getVar('dirname', 'n') . '_coupon') . ' WHERE couponid=' . $couponid;
105
+			//echo $sql;
106
+			if (!$result = $this->db->query($sql)) {
107
+				return false;
108
+			}
109
+			while (list($itemid, $descr, $image, $publish, $expire, $heading, $lbr) = $this->db->fetchRow($result)) {
110
+				$this->itemid  = $itemid;
111
+				$this->descr   = $descr;
112
+				$this->image   = $image;
113
+				$this->publish = $publish;
114
+				$this->expire  = $expire;
115
+				$this->heading = $heading;
116
+				$this->lbr     = $lbr;
117
+			}
118
+
119
+			return true;
120
+		}
121
+
122
+		return false;
123
+	}
124
+
125
+	public function delete($couponid)
126
+	{
127
+		$sql = 'DELETE FROM ' . $this->db->prefix($module->getVar('dirname', 'n') . '_coupon') . ' WHERE couponid=' . (int)$couponid;
128
+		$this->db->query($sql);
129
+
130
+		return true;
131
+	}
132
+
133
+	/* Returns number of coupons for a listing
134 134
     *
135 135
     * @param int $itemid listing id
136 136
     *
137 137
     * @return
138 138
     */
139
-    public function getCountByLink($itemid = 0)
140
-    {
141
-        $ret = 0;
142
-        $now = time();
143
-        $sql = 'SELECT count(*) FROM ' . $this->db->prefix($module->getVar('dirname', 'n') . '_coupon') . ' WHERE itemid=' . $itemid . ' AND publish < ' . $now . ' AND (expire = 0 OR expire > ' . $now . ')';
144
-        //echo $sql;
145
-        if (!$result = $this->db->query($sql)) {
146
-            return false;
147
-        }
148
-        list($ret) = $this->db->fetchRow($result);
149
-
150
-        return $ret;
151
-    }
152
-
153
-    public function getByItem($itemid = 0)
154
-    {
155
-        if ($itemid === false) {
156
-            //echo 'couponid is false';
157
-            return false;
158
-        }
159
-        //$couponid = (int)($couponid);
160
-        if ($itemid > 0) {
161
-            $sql = 'SELECT couponid, itemid, description, image, publish, expire, heading, lbr FROM ' . $this->db->prefix($module->getVar('dirname', 'n') . '_coupon') . ' WHERE itemid=' . $itemid;
162
-            //echo $sql;
163
-            if (!$result = $this->db->query($sql)) {
164
-                return false;
165
-            }
166
-            while (list($couponid, $itemid, $descr, $image, $publish, $expire, $heading, $lbr) = $this->db->fetchRow($result)) {
167
-                if ($publish == 0) {
168
-                    $publish = time();
169
-                }
170
-                if ($expire > 0) {
171
-                    $expire = formatTimestamp($expire, 's');
172
-                }
173
-                $publish = formatTimestamp($publish, 's');
174
-                $ret[]   = array('couponid' => $couponid, 'itemid' => $itemid, 'descr' => $descr, 'image' => $image, 'publish' => $publish, 'expire' => $expire, 'heading' => $heading, 'lbr' => $lbr);
175
-            }
176
-
177
-            return $ret;
178
-        }
179
-
180
-        return false;
181
-    }
139
+	public function getCountByLink($itemid = 0)
140
+	{
141
+		$ret = 0;
142
+		$now = time();
143
+		$sql = 'SELECT count(*) FROM ' . $this->db->prefix($module->getVar('dirname', 'n') . '_coupon') . ' WHERE itemid=' . $itemid . ' AND publish < ' . $now . ' AND (expire = 0 OR expire > ' . $now . ')';
144
+		//echo $sql;
145
+		if (!$result = $this->db->query($sql)) {
146
+			return false;
147
+		}
148
+		list($ret) = $this->db->fetchRow($result);
149
+
150
+		return $ret;
151
+	}
152
+
153
+	public function getByItem($itemid = 0)
154
+	{
155
+		if ($itemid === false) {
156
+			//echo 'couponid is false';
157
+			return false;
158
+		}
159
+		//$couponid = (int)($couponid);
160
+		if ($itemid > 0) {
161
+			$sql = 'SELECT couponid, itemid, description, image, publish, expire, heading, lbr FROM ' . $this->db->prefix($module->getVar('dirname', 'n') . '_coupon') . ' WHERE itemid=' . $itemid;
162
+			//echo $sql;
163
+			if (!$result = $this->db->query($sql)) {
164
+				return false;
165
+			}
166
+			while (list($couponid, $itemid, $descr, $image, $publish, $expire, $heading, $lbr) = $this->db->fetchRow($result)) {
167
+				if ($publish == 0) {
168
+					$publish = time();
169
+				}
170
+				if ($expire > 0) {
171
+					$expire = formatTimestamp($expire, 's');
172
+				}
173
+				$publish = formatTimestamp($publish, 's');
174
+				$ret[]   = array('couponid' => $couponid, 'itemid' => $itemid, 'descr' => $descr, 'image' => $image, 'publish' => $publish, 'expire' => $expire, 'heading' => $heading, 'lbr' => $lbr);
175
+			}
176
+
177
+			return $ret;
178
+		}
179
+
180
+		return false;
181
+	}
182 182
 }
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
     public $heading;
26 26
     public $message;
27 27
     public $lbr;
28
-    public $_new   = false;
28
+    public $_new = false;
29 29
 
30 30
     public function __construct()
31 31
     {
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
         global $myts;
38 38
         $this->descr   = $myts->makeTareaData4Save($_POST['description']);
39 39
         $this->image   = $myts->makeTboxData4Save($_POST['image']);
40
-        $this->itemid  = (int)$_POST['itemid'];
40
+        $this->itemid  = (int) $_POST['itemid'];
41 41
         $this->publish = strtotime($_POST['publish']['date']) + $_POST['publish']['time'];
42 42
         if (isset($_POST['expire_enable']) && ($_POST['expire_enable'] == 1)) {
43 43
             $this->expire = strtotime($_POST['expire']['date']) + $_POST['expire']['time'];
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
             }
57 57
         } else {
58 58
             $this->message  = _MD_COUPONUPDATED;
59
-            $this->couponid = (int)$_POST['couponid'];
59
+            $this->couponid = (int) $_POST['couponid'];
60 60
             if ($this->update()) {
61 61
                 return true;
62 62
             } else {
@@ -67,9 +67,9 @@  discard block
 block discarded – undo
67 67
 
68 68
     public function insert()
69 69
     {
70
-        $sql = 'INSERT INTO ' . $this->db->prefix($module->getVar('dirname', 'n') . '_coupon') . '
70
+        $sql = 'INSERT INTO '.$this->db->prefix($module->getVar('dirname', 'n').'_coupon').'
71 71
             (itemid, description, image, publish, expire, heading, lbr) VALUES
72
-            (' . $this->itemid . ', ' . $this->db->quoteString($this->descr) . ', ' . $this->db->quoteString($this->image) . ', ' . $this->publish . ', ' . $this->expire . ', ' . $this->db->quoteString($this->heading) . ', ' . $this->lbr . ')';
72
+            (' . $this->itemid.', '.$this->db->quoteString($this->descr).', '.$this->db->quoteString($this->image).', '.$this->publish.', '.$this->expire.', '.$this->db->quoteString($this->heading).', '.$this->lbr.')';
73 73
         if ($this->db->query($sql)) {
74 74
             $this->couponid = $this->db->getInsertId();
75 75
 
@@ -81,12 +81,12 @@  discard block
 block discarded – undo
81 81
 
82 82
     public function update()
83 83
     {
84
-        $sql = 'UPDATE ' . $this->db->prefix($module->getVar('dirname', 'n') . '_coupon') . ' SET
85
-            description = ' . $this->db->quoteString($this->descr) . ',
86
-            image = ' . $this->db->quoteString($this->image) . ',
87
-            publish = ' . $this->publish . ',
88
-            lbr = ' . $this->lbr . ',
89
-            heading = ' . $this->db->quoteString($this->heading) . ",
84
+        $sql = 'UPDATE '.$this->db->prefix($module->getVar('dirname', 'n').'_coupon').' SET
85
+            description = ' . $this->db->quoteString($this->descr).',
86
+            image = ' . $this->db->quoteString($this->image).',
87
+            publish = ' . $this->publish.',
88
+            lbr = ' . $this->lbr.',
89
+            heading = ' . $this->db->quoteString($this->heading).",
90 90
             expire = $this->expire WHERE couponid = $this->couponid";
91 91
         $this->db->query($sql);
92 92
 
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
         }
102 102
         //$couponid = (int)($couponid);
103 103
         if ($couponid > 0) {
104
-            $sql = 'SELECT itemid, description, image, publish, expire, heading, lbr FROM ' . $this->db->prefix($module->getVar('dirname', 'n') . '_coupon') . ' WHERE couponid=' . $couponid;
104
+            $sql = 'SELECT itemid, description, image, publish, expire, heading, lbr FROM '.$this->db->prefix($module->getVar('dirname', 'n').'_coupon').' WHERE couponid='.$couponid;
105 105
             //echo $sql;
106 106
             if (!$result = $this->db->query($sql)) {
107 107
                 return false;
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 
125 125
     public function delete($couponid)
126 126
     {
127
-        $sql = 'DELETE FROM ' . $this->db->prefix($module->getVar('dirname', 'n') . '_coupon') . ' WHERE couponid=' . (int)$couponid;
127
+        $sql = 'DELETE FROM '.$this->db->prefix($module->getVar('dirname', 'n').'_coupon').' WHERE couponid='.(int) $couponid;
128 128
         $this->db->query($sql);
129 129
 
130 130
         return true;
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
     {
141 141
         $ret = 0;
142 142
         $now = time();
143
-        $sql = 'SELECT count(*) FROM ' . $this->db->prefix($module->getVar('dirname', 'n') . '_coupon') . ' WHERE itemid=' . $itemid . ' AND publish < ' . $now . ' AND (expire = 0 OR expire > ' . $now . ')';
143
+        $sql = 'SELECT count(*) FROM '.$this->db->prefix($module->getVar('dirname', 'n').'_coupon').' WHERE itemid='.$itemid.' AND publish < '.$now.' AND (expire = 0 OR expire > '.$now.')';
144 144
         //echo $sql;
145 145
         if (!$result = $this->db->query($sql)) {
146 146
             return false;
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
         }
159 159
         //$couponid = (int)($couponid);
160 160
         if ($itemid > 0) {
161
-            $sql = 'SELECT couponid, itemid, description, image, publish, expire, heading, lbr FROM ' . $this->db->prefix($module->getVar('dirname', 'n') . '_coupon') . ' WHERE itemid=' . $itemid;
161
+            $sql = 'SELECT couponid, itemid, description, image, publish, expire, heading, lbr FROM '.$this->db->prefix($module->getVar('dirname', 'n').'_coupon').' WHERE itemid='.$itemid;
162 162
             //echo $sql;
163 163
             if (!$result = $this->db->query($sql)) {
164 164
                 return false;
Please login to merge, or discard this patch.
class/class.datafield.php 2 patches
Indentation   +132 added lines, -132 removed lines patch added patch discarded remove patch
@@ -42,13 +42,13 @@  discard block
 block discarded – undo
42 42
 class efqDataField extends XoopsObject
43 43
 {
44 44
 
45
-    /**
46
-     * Constructor
47
-     */
48
-    public function efqDataField()
49
-    {
50
-        // class constructor;
51
-    }
45
+	/**
46
+	 * Constructor
47
+	 */
48
+	public function efqDataField()
49
+	{
50
+		// class constructor;
51
+	}
52 52
 }
53 53
 
54 54
 /**
@@ -62,135 +62,135 @@  discard block
 block discarded – undo
62 62
  */
63 63
 class efqDataFieldHandler extends XoopsObjectHandler
64 64
 {
65
-    public $errorhandler;
65
+	public $errorhandler;
66 66
 
67
-    public function efqDataFieldHandler()
68
-    {
69
-        //Instantiate class
70
-        global $eh;
71
-        $this->db           = XoopsDatabaseFactory::getDatabaseConnection();
72
-        $this->errorhandler = $eh;
73
-    }
67
+	public function efqDataFieldHandler()
68
+	{
69
+		//Instantiate class
70
+		global $eh;
71
+		$this->db           = XoopsDatabaseFactory::getDatabaseConnection();
72
+		$this->errorhandler = $eh;
73
+	}
74 74
 
75
-    public function getDataFields($itemid, $show = 10, $min = 0)
76
-    {
77
-        $sql = "SELECT DISTINCT t.dtypeid, t.title, t.section, t.icon, f.typeid, f.fieldtype, f.ext, t.options, d.itemid, d.value, d.customtitle, t.custom ";
78
-        $sql .= "FROM " . $this->db->prefix("efqdiralpha1_item_x_cat") . " ic, " . $this->db->prefix("efqdiralpha1_dtypes_x_cat") . " xc, " . $this->db->prefix("efqdiralpha1_fieldtypes") . " f, " . $this->db->prefix("efqdiralpha1_dtypes") . " t ";
79
-        $sql .= "LEFT JOIN " . $this->db->prefix("efqdiralpha1_data") . " d ON (t.dtypeid=d.dtypeid AND d.itemid=" . $itemid . ") ";
80
-        $sql .= "WHERE ic.cid=xc.cid AND ic.active='1' AND xc.dtypeid=t.dtypeid AND t.fieldtypeid=f.typeid AND t.activeyn='1' AND ic.itemid=" . $itemid . "";
81
-        $data_result = $this->db->query($sql) or $this->errorhandler->show("0013");
82
-        //$numrows = $this->db->getRowsNum($data_result);
83
-        $arr = array();
84
-        while (list($dtypeid, $title, $section, $icon, $ftypeid, $fieldtype, $ext, $options, $itemid, $value, $customtitle, $custom) = $this->db->fetchRow($data_result)) {
85
-            $fieldvalue = $this->getFieldValue($fieldtype, $options, $value);
86
-            if ($icon != '') {
87
-                $iconurl = "<img src=\"uploads/$icon\" />";
88
-            } else {
89
-                $iconurl = "";
90
-            }
91
-            if ($custom != '0' && $customtitle != "") {
92
-                $title = $customtitle;
93
-            }
94
-            $arr[] = array(
95
-                'dtypeid'     => $dtypeid,
96
-                'title'       => $title,
97
-                'section'     => $section,
98
-                'icon'        => $iconurl,
99
-                'ftypeid'     => $ftypeid,
100
-                'fieldtype'   => $fieldtype,
101
-                'ext'         => $ext,
102
-                'options'     => $options,
103
-                'custom'      => $custom,
104
-                'itemid'      => $itemid,
105
-                'value'       => $fieldvalue,
106
-                'customtitle' => $customtitle
107
-            );
108
-        }
75
+	public function getDataFields($itemid, $show = 10, $min = 0)
76
+	{
77
+		$sql = "SELECT DISTINCT t.dtypeid, t.title, t.section, t.icon, f.typeid, f.fieldtype, f.ext, t.options, d.itemid, d.value, d.customtitle, t.custom ";
78
+		$sql .= "FROM " . $this->db->prefix("efqdiralpha1_item_x_cat") . " ic, " . $this->db->prefix("efqdiralpha1_dtypes_x_cat") . " xc, " . $this->db->prefix("efqdiralpha1_fieldtypes") . " f, " . $this->db->prefix("efqdiralpha1_dtypes") . " t ";
79
+		$sql .= "LEFT JOIN " . $this->db->prefix("efqdiralpha1_data") . " d ON (t.dtypeid=d.dtypeid AND d.itemid=" . $itemid . ") ";
80
+		$sql .= "WHERE ic.cid=xc.cid AND ic.active='1' AND xc.dtypeid=t.dtypeid AND t.fieldtypeid=f.typeid AND t.activeyn='1' AND ic.itemid=" . $itemid . "";
81
+		$data_result = $this->db->query($sql) or $this->errorhandler->show("0013");
82
+		//$numrows = $this->db->getRowsNum($data_result);
83
+		$arr = array();
84
+		while (list($dtypeid, $title, $section, $icon, $ftypeid, $fieldtype, $ext, $options, $itemid, $value, $customtitle, $custom) = $this->db->fetchRow($data_result)) {
85
+			$fieldvalue = $this->getFieldValue($fieldtype, $options, $value);
86
+			if ($icon != '') {
87
+				$iconurl = "<img src=\"uploads/$icon\" />";
88
+			} else {
89
+				$iconurl = "";
90
+			}
91
+			if ($custom != '0' && $customtitle != "") {
92
+				$title = $customtitle;
93
+			}
94
+			$arr[] = array(
95
+				'dtypeid'     => $dtypeid,
96
+				'title'       => $title,
97
+				'section'     => $section,
98
+				'icon'        => $iconurl,
99
+				'ftypeid'     => $ftypeid,
100
+				'fieldtype'   => $fieldtype,
101
+				'ext'         => $ext,
102
+				'options'     => $options,
103
+				'custom'      => $custom,
104
+				'itemid'      => $itemid,
105
+				'value'       => $fieldvalue,
106
+				'customtitle' => $customtitle
107
+			);
108
+		}
109 109
 
110
-        return $arr;
111
-    }
110
+		return $arr;
111
+	}
112 112
 
113
-    public function getFieldValue($fieldtype = "", $options = "", $value = 0)
114
-    {
115
-        global $myts, $moddir;
116
-        switch ($fieldtype) {
117
-            case "dhtml":
118
-                return $myts->displayTarea($value);
119
-                break;
120
-            //case "gmap":
121
-            //			$gmapHandler = new efqGmapHandler();
122
-            //			$gmap = new efqGmap();
123
-            //			$gmap->setPointsJS($gmapHandler->getPointsJS($gmap));
124
-            //			$gmap->generateMap();
125
-            //			$ret = $gmap->showMap();
126
-            //			unset($gmap);
127
-            //			unset($gmapHandler);
128
-            //return $myts->makeTboxData4Show($value);
129
-            //break;
130
-            case "radio":
131
-                return $myts->makeTboxData4Show($value);
132
-                break;
133
-            case "rating":
134
-                $xoops_url = XOOPS_URL;
135
-                switch ($value) {
136
-                    case 1:
137
-                        $src = "$xoops_url/modules/$moddir/assets/images/rating_1.gif";
138
-                        break;
139
-                    case 2:
140
-                        $src = "$xoops_url/modules/$moddir/assets/images/rating_2.gif";
141
-                        break;
142
-                    case 3:
143
-                        $src = "$xoops_url/modules/$moddir/assets/images/rating_3.gif";
144
-                        break;
145
-                    case 4:
146
-                        $src = "$xoops_url/modules/$moddir/assets/images/rating_4.gif";
147
-                        break;
148
-                    case 5:
149
-                        $src = "$xoops_url/modules/$moddir/assets/images/rating_5.gif";
150
-                        break;
151
-                    case 6:
152
-                        $src = "$xoops_url/modules/$moddir/assets/images/rating_6.gif";
153
-                        break;
154
-                    case 7:
155
-                        $src = "$xoops_url/modules/$moddir/assets/images/rating_7.gif";
156
-                        break;
157
-                    case 8:
158
-                        $src = "$xoops_url/modules/$moddir/assets/images/rating_8.gif";
159
-                        break;
160
-                    case 9:
161
-                        $src = "$xoops_url/modules/$moddir/assets/images/rating_9.gif";
162
-                        break;
163
-                    case 10:
164
-                        $src = "$xoops_url/modules/$moddir/assets/images/rating_10.gif";
165
-                        break;
166
-                    default:
167
-                        $src = "";
168
-                }
169
-                $rating = "<img src=\"$src\" />";
113
+	public function getFieldValue($fieldtype = "", $options = "", $value = 0)
114
+	{
115
+		global $myts, $moddir;
116
+		switch ($fieldtype) {
117
+			case "dhtml":
118
+				return $myts->displayTarea($value);
119
+				break;
120
+			//case "gmap":
121
+			//			$gmapHandler = new efqGmapHandler();
122
+			//			$gmap = new efqGmap();
123
+			//			$gmap->setPointsJS($gmapHandler->getPointsJS($gmap));
124
+			//			$gmap->generateMap();
125
+			//			$ret = $gmap->showMap();
126
+			//			unset($gmap);
127
+			//			unset($gmapHandler);
128
+			//return $myts->makeTboxData4Show($value);
129
+			//break;
130
+			case "radio":
131
+				return $myts->makeTboxData4Show($value);
132
+				break;
133
+			case "rating":
134
+				$xoops_url = XOOPS_URL;
135
+				switch ($value) {
136
+					case 1:
137
+						$src = "$xoops_url/modules/$moddir/assets/images/rating_1.gif";
138
+						break;
139
+					case 2:
140
+						$src = "$xoops_url/modules/$moddir/assets/images/rating_2.gif";
141
+						break;
142
+					case 3:
143
+						$src = "$xoops_url/modules/$moddir/assets/images/rating_3.gif";
144
+						break;
145
+					case 4:
146
+						$src = "$xoops_url/modules/$moddir/assets/images/rating_4.gif";
147
+						break;
148
+					case 5:
149
+						$src = "$xoops_url/modules/$moddir/assets/images/rating_5.gif";
150
+						break;
151
+					case 6:
152
+						$src = "$xoops_url/modules/$moddir/assets/images/rating_6.gif";
153
+						break;
154
+					case 7:
155
+						$src = "$xoops_url/modules/$moddir/assets/images/rating_7.gif";
156
+						break;
157
+					case 8:
158
+						$src = "$xoops_url/modules/$moddir/assets/images/rating_8.gif";
159
+						break;
160
+					case 9:
161
+						$src = "$xoops_url/modules/$moddir/assets/images/rating_9.gif";
162
+						break;
163
+					case 10:
164
+						$src = "$xoops_url/modules/$moddir/assets/images/rating_10.gif";
165
+						break;
166
+					default:
167
+						$src = "";
168
+				}
169
+				$rating = "<img src=\"$src\" />";
170 170
 
171
-                return $rating;
172
-                break;
173
-            case "select":
174
-                return $myts->makeTboxData4Show($value);
175
-                break;
176
-            case "textbox":
177
-                return $myts->makeTboxData4Show($value);
178
-                break;
179
-            case "url":
180
-                $link = explode('|', $value);
171
+				return $rating;
172
+				break;
173
+			case "select":
174
+				return $myts->makeTboxData4Show($value);
175
+				break;
176
+			case "textbox":
177
+				return $myts->makeTboxData4Show($value);
178
+				break;
179
+			case "url":
180
+				$link = explode('|', $value);
181 181
 
182
-                return '<a href="' . $myts->makeTboxData4Show($link[0]) . '" title="' . $myts->makeTboxData4Show($link[1]) . '">' . $myts->makeTboxData4Show($link[0]) . '</a>';
183
-                break;
184
-            case "yesno":
185
-                if ($value == '1') {
186
-                    return _YES;
187
-                } else {
188
-                    return _NO;
189
-                }
190
-                break;
191
-            default:
192
-                return $myts->makeTboxData4Show($value);
193
-                break;
194
-        }
195
-    }
182
+				return '<a href="' . $myts->makeTboxData4Show($link[0]) . '" title="' . $myts->makeTboxData4Show($link[1]) . '">' . $myts->makeTboxData4Show($link[0]) . '</a>';
183
+				break;
184
+			case "yesno":
185
+				if ($value == '1') {
186
+					return _YES;
187
+				} else {
188
+					return _NO;
189
+				}
190
+				break;
191
+			default:
192
+				return $myts->makeTboxData4Show($value);
193
+				break;
194
+		}
195
+	}
196 196
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -75,9 +75,9 @@  discard block
 block discarded – undo
75 75
     public function getDataFields($itemid, $show = 10, $min = 0)
76 76
     {
77 77
         $sql = "SELECT DISTINCT t.dtypeid, t.title, t.section, t.icon, f.typeid, f.fieldtype, f.ext, t.options, d.itemid, d.value, d.customtitle, t.custom ";
78
-        $sql .= "FROM " . $this->db->prefix("efqdiralpha1_item_x_cat") . " ic, " . $this->db->prefix("efqdiralpha1_dtypes_x_cat") . " xc, " . $this->db->prefix("efqdiralpha1_fieldtypes") . " f, " . $this->db->prefix("efqdiralpha1_dtypes") . " t ";
79
-        $sql .= "LEFT JOIN " . $this->db->prefix("efqdiralpha1_data") . " d ON (t.dtypeid=d.dtypeid AND d.itemid=" . $itemid . ") ";
80
-        $sql .= "WHERE ic.cid=xc.cid AND ic.active='1' AND xc.dtypeid=t.dtypeid AND t.fieldtypeid=f.typeid AND t.activeyn='1' AND ic.itemid=" . $itemid . "";
78
+        $sql .= "FROM ".$this->db->prefix("efqdiralpha1_item_x_cat")." ic, ".$this->db->prefix("efqdiralpha1_dtypes_x_cat")." xc, ".$this->db->prefix("efqdiralpha1_fieldtypes")." f, ".$this->db->prefix("efqdiralpha1_dtypes")." t ";
79
+        $sql .= "LEFT JOIN ".$this->db->prefix("efqdiralpha1_data")." d ON (t.dtypeid=d.dtypeid AND d.itemid=".$itemid.") ";
80
+        $sql .= "WHERE ic.cid=xc.cid AND ic.active='1' AND xc.dtypeid=t.dtypeid AND t.fieldtypeid=f.typeid AND t.activeyn='1' AND ic.itemid=".$itemid."";
81 81
         $data_result = $this->db->query($sql) or $this->errorhandler->show("0013");
82 82
         //$numrows = $this->db->getRowsNum($data_result);
83 83
         $arr = array();
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
             case "url":
180 180
                 $link = explode('|', $value);
181 181
 
182
-                return '<a href="' . $myts->makeTboxData4Show($link[0]) . '" title="' . $myts->makeTboxData4Show($link[1]) . '">' . $myts->makeTboxData4Show($link[0]) . '</a>';
182
+                return '<a href="'.$myts->makeTboxData4Show($link[0]).'" title="'.$myts->makeTboxData4Show($link[1]).'">'.$myts->makeTboxData4Show($link[0]).'</a>';
183 183
                 break;
184 184
             case "yesno":
185 185
                 if ($value == '1') {
Please login to merge, or discard this patch.
class/class.efqtree.php 2 patches
Indentation   +361 added lines, -361 removed lines patch added patch discarded remove patch
@@ -23,365 +23,365 @@
 block discarded – undo
23 23
 
24 24
 class efqTree
25 25
 {
26
-    public $table;
27
-    //table with parent-child structure
28
-    public $id;
29
-    //name of unique id for records in table $table
30
-    public $pid;
31
-    // name of parent id used in table $table
32
-    public $order;
33
-    //specifies the order of query results
34
-    public $title;
35
-    // name of a field in table $table which will be used when  selection box and paths are generated
36
-    public $db;
37
-    public $dirid;
38
-
39
-    //constructor of class XoopsTree
40
-    //sets the names of table, unique id, and parend id
41
-    /**
42
-     * efqTree constructor.
43
-     * @param $table_name
44
-     * @param $id_name
45
-     * @param $pid_name
46
-     */
47
-    public function __construct($table_name, $id_name, $pid_name)
48
-    {
49
-        $this->db    = XoopsDatabaseFactory::getDatabaseConnection();
50
-        $this->table = $table_name;
51
-        $this->id    = $id_name;
52
-        $this->pid   = $pid_name;
53
-        $this->dirid = 0;
54
-    }
55
-
56
-    /**
57
-     * @param int $dirid
58
-     */
59
-    public function setDir($dirid = 0)
60
-    {
61
-        $this->dirid = $dirid;
62
-    }
63
-
64
-    // returns an array of first child objects for a given id($sel_id)
65
-
66
-    /**
67
-     * @param        $sel_id
68
-     * @param string $order
69
-     * @return array
70
-     */
71
-    public function getFirstChild($sel_id, $order = '')
72
-    {
73
-        $arr = array();
74
-        $sql = 'SELECT * FROM ' . $this->table . ' WHERE ' . $this->pid . '=' . $sel_id . '';
75
-        if ($order !== '') {
76
-            $sql .= " ORDER BY $order";
77
-        }
78
-        $result = $this->db->query($sql);
79
-        $count  = $this->db->getRowsNum($result);
80
-        if ($count == 0) {
81
-            return $arr;
82
-        }
83
-        while ($myrow = $this->db->fetchArray($result)) {
84
-            array_push($arr, $myrow);
85
-        }
86
-
87
-        return $arr;
88
-    }
89
-
90
-    // returns an array of all FIRST child ids of a given id($sel_id)
91
-
92
-    /**
93
-     * @param $sel_id
94
-     * @return array
95
-     */
96
-    public function getFirstChildId($sel_id)
97
-    {
98
-        $idarray = array();
99
-        $result  = $this->db->query('SELECT ' . $this->id . ' FROM ' . $this->table . ' WHERE ' . $this->pid . '=' . $sel_id . '');
100
-        $count   = $this->db->getRowsNum($result);
101
-        if ($count == 0) {
102
-            return $idarray;
103
-        }
104
-        while (list($id) = $this->db->fetchRow($result)) {
105
-            array_push($idarray, $id);
106
-        }
107
-
108
-        return $idarray;
109
-    }
110
-
111
-    //returns an array of ALL child ids for a given id($sel_id)
112
-
113
-    /**
114
-     * @param        $sel_id
115
-     * @param string $order
116
-     * @param array  $idarray
117
-     * @return array
118
-     */
119
-    public function getAllChildId($sel_id, $order = '', $idarray = array())
120
-    {
121
-        $sql = 'SELECT ' . $this->id . ' FROM ' . $this->table . ' WHERE ' . $this->pid . '=' . $sel_id . '';
122
-        if ($order !== '') {
123
-            $sql .= " ORDER BY $order";
124
-        }
125
-        $result = $this->db->query($sql);
126
-        $count  = $this->db->getRowsNum($result);
127
-        if ($count == 0) {
128
-            return $idarray;
129
-        }
130
-        while (list($r_id) = $this->db->fetchRow($result)) {
131
-            array_push($idarray, $r_id);
132
-            $idarray = $this->getAllChildId($r_id, $order, $idarray);
133
-        }
134
-
135
-        return $idarray;
136
-    }
137
-
138
-    //returns an array of ALL parent ids for a given id($sel_id)
139
-
140
-    /**
141
-     * @param        $sel_id
142
-     * @param string $order
143
-     * @param array  $idarray
144
-     * @return array
145
-     */
146
-    public function getAllParentId($sel_id, $order = '', $idarray = array())
147
-    {
148
-        $sql = 'SELECT ' . $this->pid . ' FROM ' . $this->table . ' WHERE ' . $this->id . '=' . $sel_id . '';
149
-        if ($order !== '') {
150
-            $sql .= " ORDER BY $order";
151
-        }
152
-        $result = $this->db->query($sql);
153
-        list($r_id) = $this->db->fetchRow($result);
154
-        if ($r_id == 0) {
155
-            return $idarray;
156
-        }
157
-        array_push($idarray, $r_id);
158
-        $idarray = $this->getAllParentId($r_id, $order, $idarray);
159
-
160
-        return $idarray;
161
-    }
162
-
163
-    //generates path from the root id to a given id($sel_id)
164
-    // the path is delimetered with "/"
165
-    /**
166
-     * @param        $sel_id
167
-     * @param        $title
168
-     * @param string $path
169
-     * @return string
170
-     */
171
-    public function getPathFromId($sel_id, $title, $path = '')
172
-    {
173
-        $result = $this->db->query('SELECT ' . $this->pid . ', ' . $title . ' FROM ' . $this->table . ' WHERE ' . $this->id . "=$sel_id");
174
-        if ($this->db->getRowsNum($result) == 0) {
175
-            return $path;
176
-        }
177
-        list($parentid, $name) = $this->db->fetchRow($result);
178
-        $myts = MyTextSanitizer::getInstance();
179
-        $name = $myts->htmlSpecialChars($name);
180
-        $path = '/' . $name . $path . '';
181
-        if ($parentid == 0) {
182
-            return $path;
183
-        }
184
-        $path = $this->getPathFromId($parentid, $title, $path);
185
-
186
-        return $path;
187
-    }
188
-
189
-    //makes a nicely ordered selection box
190
-    //$preset_id is used to specify a preselected item
191
-    //set $none to 1 to add a option with value 0
192
-    /**
193
-     * @param        $title
194
-     * @param string $order
195
-     * @param int    $preset_id
196
-     * @param int    $none
197
-     * @param string $sel_name
198
-     * @param string $onchange
199
-     * @param int    $multiple
200
-     */
201
-    public function makeMySelBox($title, $order = '', $preset_id = 0, $none = 0, $sel_name = '', $onchange = '', $multiple = 0)
202
-    {
203
-        if ($sel_name === '') {
204
-            $sel_name = $this->id;
205
-        }
206
-        $myts = MyTextSanitizer::getInstance();
207
-
208
-        $sql = 'SELECT ' . $this->id . ', ' . $title . ' FROM ' . $this->table . ' WHERE ' . $this->pid . '=0';
209
-        if ($this->dirid != 0) {
210
-            $sql .= " AND dirid=$this->dirid";
211
-        }
212
-        if ($order !== '') {
213
-            $sql .= " ORDER BY $order";
214
-        }
215
-        //echo 'test';
216
-        //echo $sql;
217
-        $result = $this->db->query($sql);
218
-
219
-        echo "<select name='" . $sel_name . '\'';
220
-        if ($onchange !== '') {
221
-            echo " onchange='" . $onchange . '\'';
222
-        }
223
-        if ($multiple != 0) {
224
-            echo ' multiple="multiple"';
225
-        }
226
-        echo ">\n";
227
-
228
-        if ($none) {
229
-            echo "<option value='0'>----</option>\n";
230
-        }
231
-        while (list($catid, $name) = $this->db->fetchRow($result)) {
232
-            $sel = '';
233
-            if ($catid == $preset_id) {
234
-                $sel = " selected='selected'";
235
-            }
236
-            echo "<option value='$catid'$sel>$name</option>\n";
237
-            $sel = '';
238
-            $arr = $this->getChildTreeArray($catid, $order);
239
-            foreach ($arr as $option) {
240
-                $option['prefix'] = str_replace('.', '--', $option['prefix']);
241
-                $catpath          = $option['prefix'] . '&nbsp;' . $myts->htmlSpecialChars($option[$title]);
242
-                if ($option[$this->id] == $preset_id) {
243
-                    $sel = " selected='selected'";
244
-                }
245
-                echo "<option value='" . $option[$this->id] . "'$sel>$catpath</option>\n";
246
-                $sel = '';
247
-            }
248
-        }
249
-        echo "</select>\n";
250
-    }
251
-
252
-    //generates nicely formatted linked path from the root id to a given id
253
-
254
-    /**
255
-     * @param        $sel_id
256
-     * @param        $title
257
-     * @param        $funcURL
258
-     * @param string $path
259
-     * @param string $outputvar
260
-     * @return string
261
-     */
262
-    public function getNicePathFromId($sel_id, $title, $funcURL, $path = '', $outputvar = 'catid')
263
-    {
264
-        $sql    = 'SELECT ' . $this->pid . ', ' . $title . ' FROM ' . $this->table . ' WHERE ' . $this->id . "=$sel_id";
265
-        $result = $this->db->query($sql);
266
-        if ($this->db->getRowsNum($result) == 0) {
267
-            return $path;
268
-        }
269
-        list($parentid, $name) = $this->db->fetchRow($result);
270
-        $myts = MyTextSanitizer::getInstance();
271
-        $name = $myts->htmlSpecialChars($name);
272
-        $path = "<a href='" . $funcURL . '&' . $outputvar . '=' . $sel_id . '\'>' . $name . '</a>&nbsp;:&nbsp;' . $path . '';
273
-        if ($parentid == 0) {
274
-            return $path;
275
-        }
276
-        $path = $this->getNicePathFromId($parentid, $title, $funcURL, $path, $outputvar);
277
-
278
-        return $path;
279
-    }
280
-
281
-    //generates nicely formatted path from the root id to a given id
282
-
283
-    /**
284
-     * @param        $sel_id
285
-     * @param        $title
286
-     * @param string $path
287
-     * @return string
288
-     */
289
-    public function getUnformattedPathFromId($sel_id, $title, $path = '')
290
-    {
291
-        $sql    = 'SELECT ' . $this->pid . ', ' . $title . ' FROM ' . $this->table . ' WHERE ' . $this->id . "=$sel_id";
292
-        $result = $this->db->query($sql);
293
-        if ($this->db->getRowsNum($result) == 0) {
294
-            return $path;
295
-        }
296
-        list($parentid, $name) = $this->db->fetchRow($result);
297
-        $myts = MyTextSanitizer::getInstance();
298
-        $name = $myts->htmlSpecialChars($name);
299
-        if ($path !== '') {
300
-            $path = '' . $name . '&nbsp;:&nbsp;' . $path . '';
301
-        } else {
302
-            $path = '' . $name . '';
303
-        }
304
-
305
-        if ($parentid == 0) {
306
-            return $path;
307
-        }
308
-        $path = $this->getUnformattedPathFromId($parentid, $title, $path);
309
-
310
-        return $path;
311
-    }
312
-
313
-    //generates id path from the root id to a given id
314
-    // the path is delimetered with "/"
315
-    /**
316
-     * @param        $sel_id
317
-     * @param string $path
318
-     * @return string
319
-     */
320
-    public function getIdPathFromId($sel_id, $path = '')
321
-    {
322
-        $result = $this->db->query('SELECT ' . $this->pid . ' FROM ' . $this->table . ' WHERE ' . $this->id . "=$sel_id");
323
-        if ($this->db->getRowsNum($result) == 0) {
324
-            return $path;
325
-        }
326
-        list($parentid) = $this->db->fetchRow($result);
327
-        $path = '/' . $sel_id . $path . '';
328
-        if ($parentid == 0) {
329
-            return $path;
330
-        }
331
-        $path = $this->getIdPathFromId($parentid, $path);
332
-
333
-        return $path;
334
-    }
335
-
336
-    /**
337
-     * @param int    $sel_id
338
-     * @param string $order
339
-     * @param array  $parray
340
-     * @return array
341
-     */
342
-    public function getAllChild($sel_id = 0, $order = '', $parray = array())
343
-    {
344
-        $sql = 'SELECT * FROM ' . $this->table . ' WHERE ' . $this->pid . '=' . $sel_id . '';
345
-        if ($order !== '') {
346
-            $sql .= " ORDER BY $order";
347
-        }
348
-        $result = $this->db->query($sql);
349
-        $count  = $this->db->getRowsNum($result);
350
-        if ($count == 0) {
351
-            return $parray;
352
-        }
353
-        while ($row = $this->db->fetchArray($result)) {
354
-            array_push($parray, $row);
355
-            $parray = $this->getAllChild($row[$this->id], $order, $parray);
356
-        }
357
-
358
-        return $parray;
359
-    }
360
-
361
-    /**
362
-     * @param int    $sel_id
363
-     * @param string $order
364
-     * @param array  $parray
365
-     * @param string $r_prefix
366
-     * @return array
367
-     */
368
-    public function getChildTreeArray($sel_id = 0, $order = '', $parray = array(), $r_prefix = '')
369
-    {
370
-        $sql = 'SELECT * FROM ' . $this->table . ' WHERE ' . $this->pid . '=' . $sel_id . '';
371
-        if ($order !== '') {
372
-            $sql .= " ORDER BY $order";
373
-        }
374
-        $result = $this->db->query($sql);
375
-        $count  = $this->db->getRowsNum($result);
376
-        if ($count == 0) {
377
-            return $parray;
378
-        }
379
-        while ($row = $this->db->fetchArray($result)) {
380
-            $row['prefix'] = $r_prefix . '.';
381
-            array_push($parray, $row);
382
-            $parray = $this->getChildTreeArray($row[$this->id], $order, $parray, $row['prefix']);
383
-        }
384
-
385
-        return $parray;
386
-    }
26
+	public $table;
27
+	//table with parent-child structure
28
+	public $id;
29
+	//name of unique id for records in table $table
30
+	public $pid;
31
+	// name of parent id used in table $table
32
+	public $order;
33
+	//specifies the order of query results
34
+	public $title;
35
+	// name of a field in table $table which will be used when  selection box and paths are generated
36
+	public $db;
37
+	public $dirid;
38
+
39
+	//constructor of class XoopsTree
40
+	//sets the names of table, unique id, and parend id
41
+	/**
42
+	 * efqTree constructor.
43
+	 * @param $table_name
44
+	 * @param $id_name
45
+	 * @param $pid_name
46
+	 */
47
+	public function __construct($table_name, $id_name, $pid_name)
48
+	{
49
+		$this->db    = XoopsDatabaseFactory::getDatabaseConnection();
50
+		$this->table = $table_name;
51
+		$this->id    = $id_name;
52
+		$this->pid   = $pid_name;
53
+		$this->dirid = 0;
54
+	}
55
+
56
+	/**
57
+	 * @param int $dirid
58
+	 */
59
+	public function setDir($dirid = 0)
60
+	{
61
+		$this->dirid = $dirid;
62
+	}
63
+
64
+	// returns an array of first child objects for a given id($sel_id)
65
+
66
+	/**
67
+	 * @param        $sel_id
68
+	 * @param string $order
69
+	 * @return array
70
+	 */
71
+	public function getFirstChild($sel_id, $order = '')
72
+	{
73
+		$arr = array();
74
+		$sql = 'SELECT * FROM ' . $this->table . ' WHERE ' . $this->pid . '=' . $sel_id . '';
75
+		if ($order !== '') {
76
+			$sql .= " ORDER BY $order";
77
+		}
78
+		$result = $this->db->query($sql);
79
+		$count  = $this->db->getRowsNum($result);
80
+		if ($count == 0) {
81
+			return $arr;
82
+		}
83
+		while ($myrow = $this->db->fetchArray($result)) {
84
+			array_push($arr, $myrow);
85
+		}
86
+
87
+		return $arr;
88
+	}
89
+
90
+	// returns an array of all FIRST child ids of a given id($sel_id)
91
+
92
+	/**
93
+	 * @param $sel_id
94
+	 * @return array
95
+	 */
96
+	public function getFirstChildId($sel_id)
97
+	{
98
+		$idarray = array();
99
+		$result  = $this->db->query('SELECT ' . $this->id . ' FROM ' . $this->table . ' WHERE ' . $this->pid . '=' . $sel_id . '');
100
+		$count   = $this->db->getRowsNum($result);
101
+		if ($count == 0) {
102
+			return $idarray;
103
+		}
104
+		while (list($id) = $this->db->fetchRow($result)) {
105
+			array_push($idarray, $id);
106
+		}
107
+
108
+		return $idarray;
109
+	}
110
+
111
+	//returns an array of ALL child ids for a given id($sel_id)
112
+
113
+	/**
114
+	 * @param        $sel_id
115
+	 * @param string $order
116
+	 * @param array  $idarray
117
+	 * @return array
118
+	 */
119
+	public function getAllChildId($sel_id, $order = '', $idarray = array())
120
+	{
121
+		$sql = 'SELECT ' . $this->id . ' FROM ' . $this->table . ' WHERE ' . $this->pid . '=' . $sel_id . '';
122
+		if ($order !== '') {
123
+			$sql .= " ORDER BY $order";
124
+		}
125
+		$result = $this->db->query($sql);
126
+		$count  = $this->db->getRowsNum($result);
127
+		if ($count == 0) {
128
+			return $idarray;
129
+		}
130
+		while (list($r_id) = $this->db->fetchRow($result)) {
131
+			array_push($idarray, $r_id);
132
+			$idarray = $this->getAllChildId($r_id, $order, $idarray);
133
+		}
134
+
135
+		return $idarray;
136
+	}
137
+
138
+	//returns an array of ALL parent ids for a given id($sel_id)
139
+
140
+	/**
141
+	 * @param        $sel_id
142
+	 * @param string $order
143
+	 * @param array  $idarray
144
+	 * @return array
145
+	 */
146
+	public function getAllParentId($sel_id, $order = '', $idarray = array())
147
+	{
148
+		$sql = 'SELECT ' . $this->pid . ' FROM ' . $this->table . ' WHERE ' . $this->id . '=' . $sel_id . '';
149
+		if ($order !== '') {
150
+			$sql .= " ORDER BY $order";
151
+		}
152
+		$result = $this->db->query($sql);
153
+		list($r_id) = $this->db->fetchRow($result);
154
+		if ($r_id == 0) {
155
+			return $idarray;
156
+		}
157
+		array_push($idarray, $r_id);
158
+		$idarray = $this->getAllParentId($r_id, $order, $idarray);
159
+
160
+		return $idarray;
161
+	}
162
+
163
+	//generates path from the root id to a given id($sel_id)
164
+	// the path is delimetered with "/"
165
+	/**
166
+	 * @param        $sel_id
167
+	 * @param        $title
168
+	 * @param string $path
169
+	 * @return string
170
+	 */
171
+	public function getPathFromId($sel_id, $title, $path = '')
172
+	{
173
+		$result = $this->db->query('SELECT ' . $this->pid . ', ' . $title . ' FROM ' . $this->table . ' WHERE ' . $this->id . "=$sel_id");
174
+		if ($this->db->getRowsNum($result) == 0) {
175
+			return $path;
176
+		}
177
+		list($parentid, $name) = $this->db->fetchRow($result);
178
+		$myts = MyTextSanitizer::getInstance();
179
+		$name = $myts->htmlSpecialChars($name);
180
+		$path = '/' . $name . $path . '';
181
+		if ($parentid == 0) {
182
+			return $path;
183
+		}
184
+		$path = $this->getPathFromId($parentid, $title, $path);
185
+
186
+		return $path;
187
+	}
188
+
189
+	//makes a nicely ordered selection box
190
+	//$preset_id is used to specify a preselected item
191
+	//set $none to 1 to add a option with value 0
192
+	/**
193
+	 * @param        $title
194
+	 * @param string $order
195
+	 * @param int    $preset_id
196
+	 * @param int    $none
197
+	 * @param string $sel_name
198
+	 * @param string $onchange
199
+	 * @param int    $multiple
200
+	 */
201
+	public function makeMySelBox($title, $order = '', $preset_id = 0, $none = 0, $sel_name = '', $onchange = '', $multiple = 0)
202
+	{
203
+		if ($sel_name === '') {
204
+			$sel_name = $this->id;
205
+		}
206
+		$myts = MyTextSanitizer::getInstance();
207
+
208
+		$sql = 'SELECT ' . $this->id . ', ' . $title . ' FROM ' . $this->table . ' WHERE ' . $this->pid . '=0';
209
+		if ($this->dirid != 0) {
210
+			$sql .= " AND dirid=$this->dirid";
211
+		}
212
+		if ($order !== '') {
213
+			$sql .= " ORDER BY $order";
214
+		}
215
+		//echo 'test';
216
+		//echo $sql;
217
+		$result = $this->db->query($sql);
218
+
219
+		echo "<select name='" . $sel_name . '\'';
220
+		if ($onchange !== '') {
221
+			echo " onchange='" . $onchange . '\'';
222
+		}
223
+		if ($multiple != 0) {
224
+			echo ' multiple="multiple"';
225
+		}
226
+		echo ">\n";
227
+
228
+		if ($none) {
229
+			echo "<option value='0'>----</option>\n";
230
+		}
231
+		while (list($catid, $name) = $this->db->fetchRow($result)) {
232
+			$sel = '';
233
+			if ($catid == $preset_id) {
234
+				$sel = " selected='selected'";
235
+			}
236
+			echo "<option value='$catid'$sel>$name</option>\n";
237
+			$sel = '';
238
+			$arr = $this->getChildTreeArray($catid, $order);
239
+			foreach ($arr as $option) {
240
+				$option['prefix'] = str_replace('.', '--', $option['prefix']);
241
+				$catpath          = $option['prefix'] . '&nbsp;' . $myts->htmlSpecialChars($option[$title]);
242
+				if ($option[$this->id] == $preset_id) {
243
+					$sel = " selected='selected'";
244
+				}
245
+				echo "<option value='" . $option[$this->id] . "'$sel>$catpath</option>\n";
246
+				$sel = '';
247
+			}
248
+		}
249
+		echo "</select>\n";
250
+	}
251
+
252
+	//generates nicely formatted linked path from the root id to a given id
253
+
254
+	/**
255
+	 * @param        $sel_id
256
+	 * @param        $title
257
+	 * @param        $funcURL
258
+	 * @param string $path
259
+	 * @param string $outputvar
260
+	 * @return string
261
+	 */
262
+	public function getNicePathFromId($sel_id, $title, $funcURL, $path = '', $outputvar = 'catid')
263
+	{
264
+		$sql    = 'SELECT ' . $this->pid . ', ' . $title . ' FROM ' . $this->table . ' WHERE ' . $this->id . "=$sel_id";
265
+		$result = $this->db->query($sql);
266
+		if ($this->db->getRowsNum($result) == 0) {
267
+			return $path;
268
+		}
269
+		list($parentid, $name) = $this->db->fetchRow($result);
270
+		$myts = MyTextSanitizer::getInstance();
271
+		$name = $myts->htmlSpecialChars($name);
272
+		$path = "<a href='" . $funcURL . '&' . $outputvar . '=' . $sel_id . '\'>' . $name . '</a>&nbsp;:&nbsp;' . $path . '';
273
+		if ($parentid == 0) {
274
+			return $path;
275
+		}
276
+		$path = $this->getNicePathFromId($parentid, $title, $funcURL, $path, $outputvar);
277
+
278
+		return $path;
279
+	}
280
+
281
+	//generates nicely formatted path from the root id to a given id
282
+
283
+	/**
284
+	 * @param        $sel_id
285
+	 * @param        $title
286
+	 * @param string $path
287
+	 * @return string
288
+	 */
289
+	public function getUnformattedPathFromId($sel_id, $title, $path = '')
290
+	{
291
+		$sql    = 'SELECT ' . $this->pid . ', ' . $title . ' FROM ' . $this->table . ' WHERE ' . $this->id . "=$sel_id";
292
+		$result = $this->db->query($sql);
293
+		if ($this->db->getRowsNum($result) == 0) {
294
+			return $path;
295
+		}
296
+		list($parentid, $name) = $this->db->fetchRow($result);
297
+		$myts = MyTextSanitizer::getInstance();
298
+		$name = $myts->htmlSpecialChars($name);
299
+		if ($path !== '') {
300
+			$path = '' . $name . '&nbsp;:&nbsp;' . $path . '';
301
+		} else {
302
+			$path = '' . $name . '';
303
+		}
304
+
305
+		if ($parentid == 0) {
306
+			return $path;
307
+		}
308
+		$path = $this->getUnformattedPathFromId($parentid, $title, $path);
309
+
310
+		return $path;
311
+	}
312
+
313
+	//generates id path from the root id to a given id
314
+	// the path is delimetered with "/"
315
+	/**
316
+	 * @param        $sel_id
317
+	 * @param string $path
318
+	 * @return string
319
+	 */
320
+	public function getIdPathFromId($sel_id, $path = '')
321
+	{
322
+		$result = $this->db->query('SELECT ' . $this->pid . ' FROM ' . $this->table . ' WHERE ' . $this->id . "=$sel_id");
323
+		if ($this->db->getRowsNum($result) == 0) {
324
+			return $path;
325
+		}
326
+		list($parentid) = $this->db->fetchRow($result);
327
+		$path = '/' . $sel_id . $path . '';
328
+		if ($parentid == 0) {
329
+			return $path;
330
+		}
331
+		$path = $this->getIdPathFromId($parentid, $path);
332
+
333
+		return $path;
334
+	}
335
+
336
+	/**
337
+	 * @param int    $sel_id
338
+	 * @param string $order
339
+	 * @param array  $parray
340
+	 * @return array
341
+	 */
342
+	public function getAllChild($sel_id = 0, $order = '', $parray = array())
343
+	{
344
+		$sql = 'SELECT * FROM ' . $this->table . ' WHERE ' . $this->pid . '=' . $sel_id . '';
345
+		if ($order !== '') {
346
+			$sql .= " ORDER BY $order";
347
+		}
348
+		$result = $this->db->query($sql);
349
+		$count  = $this->db->getRowsNum($result);
350
+		if ($count == 0) {
351
+			return $parray;
352
+		}
353
+		while ($row = $this->db->fetchArray($result)) {
354
+			array_push($parray, $row);
355
+			$parray = $this->getAllChild($row[$this->id], $order, $parray);
356
+		}
357
+
358
+		return $parray;
359
+	}
360
+
361
+	/**
362
+	 * @param int    $sel_id
363
+	 * @param string $order
364
+	 * @param array  $parray
365
+	 * @param string $r_prefix
366
+	 * @return array
367
+	 */
368
+	public function getChildTreeArray($sel_id = 0, $order = '', $parray = array(), $r_prefix = '')
369
+	{
370
+		$sql = 'SELECT * FROM ' . $this->table . ' WHERE ' . $this->pid . '=' . $sel_id . '';
371
+		if ($order !== '') {
372
+			$sql .= " ORDER BY $order";
373
+		}
374
+		$result = $this->db->query($sql);
375
+		$count  = $this->db->getRowsNum($result);
376
+		if ($count == 0) {
377
+			return $parray;
378
+		}
379
+		while ($row = $this->db->fetchArray($result)) {
380
+			$row['prefix'] = $r_prefix . '.';
381
+			array_push($parray, $row);
382
+			$parray = $this->getChildTreeArray($row[$this->id], $order, $parray, $row['prefix']);
383
+		}
384
+
385
+		return $parray;
386
+	}
387 387
 }
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
     public function getFirstChild($sel_id, $order = '')
72 72
     {
73 73
         $arr = array();
74
-        $sql = 'SELECT * FROM ' . $this->table . ' WHERE ' . $this->pid . '=' . $sel_id . '';
74
+        $sql = 'SELECT * FROM '.$this->table.' WHERE '.$this->pid.'='.$sel_id.'';
75 75
         if ($order !== '') {
76 76
             $sql .= " ORDER BY $order";
77 77
         }
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
     public function getFirstChildId($sel_id)
97 97
     {
98 98
         $idarray = array();
99
-        $result  = $this->db->query('SELECT ' . $this->id . ' FROM ' . $this->table . ' WHERE ' . $this->pid . '=' . $sel_id . '');
99
+        $result  = $this->db->query('SELECT '.$this->id.' FROM '.$this->table.' WHERE '.$this->pid.'='.$sel_id.'');
100 100
         $count   = $this->db->getRowsNum($result);
101 101
         if ($count == 0) {
102 102
             return $idarray;
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
      */
119 119
     public function getAllChildId($sel_id, $order = '', $idarray = array())
120 120
     {
121
-        $sql = 'SELECT ' . $this->id . ' FROM ' . $this->table . ' WHERE ' . $this->pid . '=' . $sel_id . '';
121
+        $sql = 'SELECT '.$this->id.' FROM '.$this->table.' WHERE '.$this->pid.'='.$sel_id.'';
122 122
         if ($order !== '') {
123 123
             $sql .= " ORDER BY $order";
124 124
         }
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
      */
146 146
     public function getAllParentId($sel_id, $order = '', $idarray = array())
147 147
     {
148
-        $sql = 'SELECT ' . $this->pid . ' FROM ' . $this->table . ' WHERE ' . $this->id . '=' . $sel_id . '';
148
+        $sql = 'SELECT '.$this->pid.' FROM '.$this->table.' WHERE '.$this->id.'='.$sel_id.'';
149 149
         if ($order !== '') {
150 150
             $sql .= " ORDER BY $order";
151 151
         }
@@ -170,14 +170,14 @@  discard block
 block discarded – undo
170 170
      */
171 171
     public function getPathFromId($sel_id, $title, $path = '')
172 172
     {
173
-        $result = $this->db->query('SELECT ' . $this->pid . ', ' . $title . ' FROM ' . $this->table . ' WHERE ' . $this->id . "=$sel_id");
173
+        $result = $this->db->query('SELECT '.$this->pid.', '.$title.' FROM '.$this->table.' WHERE '.$this->id."=$sel_id");
174 174
         if ($this->db->getRowsNum($result) == 0) {
175 175
             return $path;
176 176
         }
177 177
         list($parentid, $name) = $this->db->fetchRow($result);
178 178
         $myts = MyTextSanitizer::getInstance();
179 179
         $name = $myts->htmlSpecialChars($name);
180
-        $path = '/' . $name . $path . '';
180
+        $path = '/'.$name.$path.'';
181 181
         if ($parentid == 0) {
182 182
             return $path;
183 183
         }
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
         }
206 206
         $myts = MyTextSanitizer::getInstance();
207 207
 
208
-        $sql = 'SELECT ' . $this->id . ', ' . $title . ' FROM ' . $this->table . ' WHERE ' . $this->pid . '=0';
208
+        $sql = 'SELECT '.$this->id.', '.$title.' FROM '.$this->table.' WHERE '.$this->pid.'=0';
209 209
         if ($this->dirid != 0) {
210 210
             $sql .= " AND dirid=$this->dirid";
211 211
         }
@@ -216,9 +216,9 @@  discard block
 block discarded – undo
216 216
         //echo $sql;
217 217
         $result = $this->db->query($sql);
218 218
 
219
-        echo "<select name='" . $sel_name . '\'';
219
+        echo "<select name='".$sel_name.'\'';
220 220
         if ($onchange !== '') {
221
-            echo " onchange='" . $onchange . '\'';
221
+            echo " onchange='".$onchange.'\'';
222 222
         }
223 223
         if ($multiple != 0) {
224 224
             echo ' multiple="multiple"';
@@ -238,11 +238,11 @@  discard block
 block discarded – undo
238 238
             $arr = $this->getChildTreeArray($catid, $order);
239 239
             foreach ($arr as $option) {
240 240
                 $option['prefix'] = str_replace('.', '--', $option['prefix']);
241
-                $catpath          = $option['prefix'] . '&nbsp;' . $myts->htmlSpecialChars($option[$title]);
241
+                $catpath          = $option['prefix'].'&nbsp;'.$myts->htmlSpecialChars($option[$title]);
242 242
                 if ($option[$this->id] == $preset_id) {
243 243
                     $sel = " selected='selected'";
244 244
                 }
245
-                echo "<option value='" . $option[$this->id] . "'$sel>$catpath</option>\n";
245
+                echo "<option value='".$option[$this->id]."'$sel>$catpath</option>\n";
246 246
                 $sel = '';
247 247
             }
248 248
         }
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
      */
262 262
     public function getNicePathFromId($sel_id, $title, $funcURL, $path = '', $outputvar = 'catid')
263 263
     {
264
-        $sql    = 'SELECT ' . $this->pid . ', ' . $title . ' FROM ' . $this->table . ' WHERE ' . $this->id . "=$sel_id";
264
+        $sql    = 'SELECT '.$this->pid.', '.$title.' FROM '.$this->table.' WHERE '.$this->id."=$sel_id";
265 265
         $result = $this->db->query($sql);
266 266
         if ($this->db->getRowsNum($result) == 0) {
267 267
             return $path;
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
         list($parentid, $name) = $this->db->fetchRow($result);
270 270
         $myts = MyTextSanitizer::getInstance();
271 271
         $name = $myts->htmlSpecialChars($name);
272
-        $path = "<a href='" . $funcURL . '&' . $outputvar . '=' . $sel_id . '\'>' . $name . '</a>&nbsp;:&nbsp;' . $path . '';
272
+        $path = "<a href='".$funcURL.'&'.$outputvar.'='.$sel_id.'\'>'.$name.'</a>&nbsp;:&nbsp;'.$path.'';
273 273
         if ($parentid == 0) {
274 274
             return $path;
275 275
         }
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
      */
289 289
     public function getUnformattedPathFromId($sel_id, $title, $path = '')
290 290
     {
291
-        $sql    = 'SELECT ' . $this->pid . ', ' . $title . ' FROM ' . $this->table . ' WHERE ' . $this->id . "=$sel_id";
291
+        $sql    = 'SELECT '.$this->pid.', '.$title.' FROM '.$this->table.' WHERE '.$this->id."=$sel_id";
292 292
         $result = $this->db->query($sql);
293 293
         if ($this->db->getRowsNum($result) == 0) {
294 294
             return $path;
@@ -297,9 +297,9 @@  discard block
 block discarded – undo
297 297
         $myts = MyTextSanitizer::getInstance();
298 298
         $name = $myts->htmlSpecialChars($name);
299 299
         if ($path !== '') {
300
-            $path = '' . $name . '&nbsp;:&nbsp;' . $path . '';
300
+            $path = ''.$name.'&nbsp;:&nbsp;'.$path.'';
301 301
         } else {
302
-            $path = '' . $name . '';
302
+            $path = ''.$name.'';
303 303
         }
304 304
 
305 305
         if ($parentid == 0) {
@@ -319,12 +319,12 @@  discard block
 block discarded – undo
319 319
      */
320 320
     public function getIdPathFromId($sel_id, $path = '')
321 321
     {
322
-        $result = $this->db->query('SELECT ' . $this->pid . ' FROM ' . $this->table . ' WHERE ' . $this->id . "=$sel_id");
322
+        $result = $this->db->query('SELECT '.$this->pid.' FROM '.$this->table.' WHERE '.$this->id."=$sel_id");
323 323
         if ($this->db->getRowsNum($result) == 0) {
324 324
             return $path;
325 325
         }
326 326
         list($parentid) = $this->db->fetchRow($result);
327
-        $path = '/' . $sel_id . $path . '';
327
+        $path = '/'.$sel_id.$path.'';
328 328
         if ($parentid == 0) {
329 329
             return $path;
330 330
         }
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
      */
342 342
     public function getAllChild($sel_id = 0, $order = '', $parray = array())
343 343
     {
344
-        $sql = 'SELECT * FROM ' . $this->table . ' WHERE ' . $this->pid . '=' . $sel_id . '';
344
+        $sql = 'SELECT * FROM '.$this->table.' WHERE '.$this->pid.'='.$sel_id.'';
345 345
         if ($order !== '') {
346 346
             $sql .= " ORDER BY $order";
347 347
         }
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
      */
368 368
     public function getChildTreeArray($sel_id = 0, $order = '', $parray = array(), $r_prefix = '')
369 369
     {
370
-        $sql = 'SELECT * FROM ' . $this->table . ' WHERE ' . $this->pid . '=' . $sel_id . '';
370
+        $sql = 'SELECT * FROM '.$this->table.' WHERE '.$this->pid.'='.$sel_id.'';
371 371
         if ($order !== '') {
372 372
             $sql .= " ORDER BY $order";
373 373
         }
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
             return $parray;
378 378
         }
379 379
         while ($row = $this->db->fetchArray($result)) {
380
-            $row['prefix'] = $r_prefix . '.';
380
+            $row['prefix'] = $r_prefix.'.';
381 381
             array_push($parray, $row);
382 382
             $parray = $this->getChildTreeArray($row[$this->id], $order, $parray, $row['prefix']);
383 383
         }
Please login to merge, or discard this patch.
class/class.xdir.php 2 patches
Indentation   +166 added lines, -166 removed lines patch added patch discarded remove patch
@@ -44,181 +44,181 @@
 block discarded – undo
44 44
 class efqXdirHandler extends XoopsObjectHandler
45 45
 {
46 46
 //    public $db; //Database reference
47
-    public $objXdir;
48
-    public $errors; //array();
49
-    public $categories; //array();
50
-    public $listings; //array();
51
-    public $xdir_cats; //array();
52
-    public $efq_dirid;
53
-    public $fieldtypes; //array();
54
-    public $datatypes; //array();
47
+	public $objXdir;
48
+	public $errors; //array();
49
+	public $categories; //array();
50
+	public $listings; //array();
51
+	public $xdir_cats; //array();
52
+	public $efq_dirid;
53
+	public $fieldtypes; //array();
54
+	public $datatypes; //array();
55 55
 
56
-    /**
57
-     * efqSubscriptionOfferHandler::efqItemTypeHandler()
58
-     *
59
-     */
60
-    public function __construct()
61
-    {
62
-        $this->db = XoopsDatabaseFactory::getDatabaseConnection();
63
-    }
56
+	/**
57
+	 * efqSubscriptionOfferHandler::efqItemTypeHandler()
58
+	 *
59
+	 */
60
+	public function __construct()
61
+	{
62
+		$this->db = XoopsDatabaseFactory::getDatabaseConnection();
63
+	}
64 64
 
65
-    /**
66
-     * @param $arr
67
-     */
68
-    public function set_xdir_cats($arr)
69
-    {
70
-        if (is_array($arr)) {
71
-            $this->xdir_cats = $arr;
72
-        }
73
-    }
65
+	/**
66
+	 * @param $arr
67
+	 */
68
+	public function set_xdir_cats($arr)
69
+	{
70
+		if (is_array($arr)) {
71
+			$this->xdir_cats = $arr;
72
+		}
73
+	}
74 74
 
75
-    /**
76
-     * @return mixed
77
-     */
78
-    public function get_xdir_cats()
79
-    {
80
-        return $this->xdir_cats;
81
-    }
75
+	/**
76
+	 * @return mixed
77
+	 */
78
+	public function get_xdir_cats()
79
+	{
80
+		return $this->xdir_cats;
81
+	}
82 82
 
83
-    /**
84
-     * @return mixed
85
-     */
86
-    public function get_errors()
87
-    {
88
-        return $this->errors;
89
-    }
83
+	/**
84
+	 * @return mixed
85
+	 */
86
+	public function get_errors()
87
+	{
88
+		return $this->errors;
89
+	}
90 90
 
91
-    /**
92
-     * getCategories_xdir()
93
-     *
94
-     * Get xdir categories from database and return
95
-     *
96
-     * @return \arr|bool
97
-     */
98
-    public function setCategories_xdir()
99
-    {
100
-        $arr    = array();
101
-        $sql    = 'SELECT cid, pid, title, imgurl FROM ' . $this->db->prefix('efqdiralpha1_xdir_cat');
102
-        $result = $this->db->query($sql);
103
-        if (!$result) {
104
-            return false;
105
-        }
106
-        $numrows = $this->db->getRowsNum($result);
107
-        if ($numrows > 0) {
108
-            while (list($cid, $pid, $title, $imgurl) = $this->db->fetchRow($result)) {
109
-                $arr[] = array('cid' => $cid, 'pid' => $pid, 'title' => $title, 'imgurl' => $imgurl);
110
-            }
111
-        } else {
112
-            return false;
113
-        }
114
-        $this->set_xdir_cats($arr);
91
+	/**
92
+	 * getCategories_xdir()
93
+	 *
94
+	 * Get xdir categories from database and return
95
+	 *
96
+	 * @return \arr|bool
97
+	 */
98
+	public function setCategories_xdir()
99
+	{
100
+		$arr    = array();
101
+		$sql    = 'SELECT cid, pid, title, imgurl FROM ' . $this->db->prefix('efqdiralpha1_xdir_cat');
102
+		$result = $this->db->query($sql);
103
+		if (!$result) {
104
+			return false;
105
+		}
106
+		$numrows = $this->db->getRowsNum($result);
107
+		if ($numrows > 0) {
108
+			while (list($cid, $pid, $title, $imgurl) = $this->db->fetchRow($result)) {
109
+				$arr[] = array('cid' => $cid, 'pid' => $pid, 'title' => $title, 'imgurl' => $imgurl);
110
+			}
111
+		} else {
112
+			return false;
113
+		}
114
+		$this->set_xdir_cats($arr);
115 115
 
116
-        return true;
117
-    }
116
+		return true;
117
+	}
118 118
 
119
-    /**
120
-     * @param int $dirid
121
-     * @return bool
122
-     */
123
-    public function saveCategories($dirid = 0)
124
-    {
125
-        $tablename = 'efqdiralpha1_cat';
126
-        $xdir_cats = $this->get_xdir_cats();
127
-        foreach ($xdir_cats as $xdir_cat) {
128
-            $cid    = $xdir_cat['cid'];
129
-            $pid    = $xdir_cat['pid'];
130
-            $title  = $xdir_cat['title'];
131
-            $imgurl = $xdir_cat['imgurl'];
132
-            //Set fields and values
133
-            $strFields = 'cid,dirid,title,active,pid,img,allowlist';
134
-            $strValues = "$cid,$dirid,'$title',1,$pid,'$imgurl',1";
135
-            $sql       = sprintf('INSERT INTO %s (%s) VALUES (%s)', $this->db->prefix($tablename), $strFields, $strValues);
136
-            if ($this->db->queryF($sql)) {
137
-                $itemid = $this->db->getInsertId();
138
-                $obj->setVar($keyName, $itemid);
119
+	/**
120
+	 * @param int $dirid
121
+	 * @return bool
122
+	 */
123
+	public function saveCategories($dirid = 0)
124
+	{
125
+		$tablename = 'efqdiralpha1_cat';
126
+		$xdir_cats = $this->get_xdir_cats();
127
+		foreach ($xdir_cats as $xdir_cat) {
128
+			$cid    = $xdir_cat['cid'];
129
+			$pid    = $xdir_cat['pid'];
130
+			$title  = $xdir_cat['title'];
131
+			$imgurl = $xdir_cat['imgurl'];
132
+			//Set fields and values
133
+			$strFields = 'cid,dirid,title,active,pid,img,allowlist';
134
+			$strValues = "$cid,$dirid,'$title',1,$pid,'$imgurl',1";
135
+			$sql       = sprintf('INSERT INTO %s (%s) VALUES (%s)', $this->db->prefix($tablename), $strFields, $strValues);
136
+			if ($this->db->queryF($sql)) {
137
+				$itemid = $this->db->getInsertId();
138
+				$obj->setVar($keyName, $itemid);
139 139
 
140
-                return true;
141
-            }
142
-        }
143
-    }
140
+				return true;
141
+			}
142
+		}
143
+	}
144 144
 
145
-    /**
146
-     * Function createDataTypes inserts datatypes into DB
147
-     * @author    EFQ Consultancy <[email protected]>
148
-     * @copyright EFQ Consultancy (c) 2008
149
-     * @version   1.0.0
150
-     * @return bool true if insertion is succesful, false if unsuccesful
151
-     * @internal  param object $obj object
152
-     *
153
-     */
154
-    public function createDataTypes()
155
-    {
156
-        $datatypeHandler = new efqDataTypeHandler();
157
-        $arr[]            = array('title' => _MD_XDIR_DTYPE_ADDRESS, 'fieldtype' => _MD_XDIR_FIELDTYPE_TEXTBOX);
158
-        $arr[]            = array('title' => _MD_XDIR_DTYPE_ADDRESS2, 'fieldtype' => _MD_XDIR_FIELDTYPE_TEXTBOX);
159
-        $arr[]            = array('title' => _MD_XDIR_DTYPE_CITY, 'fieldtype' => _MD_XDIR_FIELDTYPE_TEXTBOX);
160
-        $arr[]            = array('title' => _MD_XDIR_DTYPE_STATE, 'fieldtype' => _MD_XDIR_FIELDTYPE_TEXTBOX);
161
-        $arr[]            = array('title' => _MD_XDIR_DTYPE_ZIP, 'fieldtype' => _MD_XDIR_FIELDTYPE_TEXTBOX);
162
-        $arr[]            = array('title' => _MD_XDIR_DTYPE_COUNTRY, 'fieldtype' => _MD_XDIR_FIELDTYPE_TEXTBOX);
163
-        $arr[]            = array('title' => _MD_XDIR_DTYPE_PHONE, 'fieldtype' => _MD_XDIR_FIELDTYPE_TEXTBOX);
164
-        $arr[]            = array('title' => _MD_XDIR_DTYPE_FAX, 'fieldtype' => _MD_XDIR_FIELDTYPE_TEXTBOX);
165
-        $arr[]            = array('title' => _MD_XDIR_DTYPE_EMAIL, 'fieldtype' => _MD_XDIR_FIELDTYPE_EMAIL);
166
-        $arr[]            = array('title' => _MD_XDIR_DTYPE_URL, 'fieldtype' => _MD_XDIR_FIELDTYPE_URL);
167
-        foreach ($arr as $datatype) {
168
-            $objDataType = new efqFieldType;
169
-            $objDataType->setVar('title', $datatype['title']);
170
-            $objDataType->setVar('section', 0);
171
-            $objDataType->setVar('uid', $xoopsUser->getVar('uid'));
172
-            $objDataType->setVar('defaultyn', 1);
173
-            $objDataType->setVar('created', time());
174
-            $objDataType->setVar('activeyn', 1);
175
-            $objDataType->setVar('fieldtypeid', $this->fieldtypes[$datatype['fieldtype']]);
176
-            $datatypeHandler->insertDataType($objDataType, true);
177
-            $datatypes[$datatype['title']] = $objDataType->getVar('dtypeid');
178
-        }
179
-    }
145
+	/**
146
+	 * Function createDataTypes inserts datatypes into DB
147
+	 * @author    EFQ Consultancy <[email protected]>
148
+	 * @copyright EFQ Consultancy (c) 2008
149
+	 * @version   1.0.0
150
+	 * @return bool true if insertion is succesful, false if unsuccesful
151
+	 * @internal  param object $obj object
152
+	 *
153
+	 */
154
+	public function createDataTypes()
155
+	{
156
+		$datatypeHandler = new efqDataTypeHandler();
157
+		$arr[]            = array('title' => _MD_XDIR_DTYPE_ADDRESS, 'fieldtype' => _MD_XDIR_FIELDTYPE_TEXTBOX);
158
+		$arr[]            = array('title' => _MD_XDIR_DTYPE_ADDRESS2, 'fieldtype' => _MD_XDIR_FIELDTYPE_TEXTBOX);
159
+		$arr[]            = array('title' => _MD_XDIR_DTYPE_CITY, 'fieldtype' => _MD_XDIR_FIELDTYPE_TEXTBOX);
160
+		$arr[]            = array('title' => _MD_XDIR_DTYPE_STATE, 'fieldtype' => _MD_XDIR_FIELDTYPE_TEXTBOX);
161
+		$arr[]            = array('title' => _MD_XDIR_DTYPE_ZIP, 'fieldtype' => _MD_XDIR_FIELDTYPE_TEXTBOX);
162
+		$arr[]            = array('title' => _MD_XDIR_DTYPE_COUNTRY, 'fieldtype' => _MD_XDIR_FIELDTYPE_TEXTBOX);
163
+		$arr[]            = array('title' => _MD_XDIR_DTYPE_PHONE, 'fieldtype' => _MD_XDIR_FIELDTYPE_TEXTBOX);
164
+		$arr[]            = array('title' => _MD_XDIR_DTYPE_FAX, 'fieldtype' => _MD_XDIR_FIELDTYPE_TEXTBOX);
165
+		$arr[]            = array('title' => _MD_XDIR_DTYPE_EMAIL, 'fieldtype' => _MD_XDIR_FIELDTYPE_EMAIL);
166
+		$arr[]            = array('title' => _MD_XDIR_DTYPE_URL, 'fieldtype' => _MD_XDIR_FIELDTYPE_URL);
167
+		foreach ($arr as $datatype) {
168
+			$objDataType = new efqFieldType;
169
+			$objDataType->setVar('title', $datatype['title']);
170
+			$objDataType->setVar('section', 0);
171
+			$objDataType->setVar('uid', $xoopsUser->getVar('uid'));
172
+			$objDataType->setVar('defaultyn', 1);
173
+			$objDataType->setVar('created', time());
174
+			$objDataType->setVar('activeyn', 1);
175
+			$objDataType->setVar('fieldtypeid', $this->fieldtypes[$datatype['fieldtype']]);
176
+			$datatypeHandler->insertDataType($objDataType, true);
177
+			$datatypes[$datatype['title']] = $objDataType->getVar('dtypeid');
178
+		}
179
+	}
180 180
 
181
-    /**
182
-     * Function createFieldTypes inserts field types into DB
183
-     * @author    EFQ Consultancy <[email protected]>
184
-     * @copyright EFQ Consultancy (c) 2008
185
-     * @version   1.0.0
186
-     * @return bool true if insertion is succesful, false if unsuccesful
187
-     * @internal  param object $obj object
188
-     *
189
-     */
190
-    public function createFieldTypes()
191
-    {
192
-        $fieldtypeHandler = new efqFieldTypeHandler();
193
-        $arr[]             = array('title' => _MD_XDIR_FIELDTYPE_TEXTBOX, 'fieldtype' => 'textbox');
194
-        $arr[]             = array('title' => _MD_XDIR_FIELDTYPE_EMAIL, 'fieldtype' => 'email');
195
-        $arr[]             = array('title' => _MD_XDIR_FIELDTYPE_URL, 'fieldtype' => 'url');
196
-        foreach ($arr as $fieldtype) {
197
-            $objFieldtype = new efqFieldType;
198
-            $objFieldtype->setVar('title', $fieldtype['title']);
199
-            $objFieldtype->setVar('fieldtype', $fieldtype['fieldtype']);
200
-            $objFieldtype->setVar('dirid', $this->efq_dirid);
201
-            $fieldtypeHandler->insertFieldType($objFieldtype, true);
202
-            $fieldtypes[$fieldtype['title']] = $objFieldtype->getVar('typeid');
203
-        }
204
-    }
181
+	/**
182
+	 * Function createFieldTypes inserts field types into DB
183
+	 * @author    EFQ Consultancy <[email protected]>
184
+	 * @copyright EFQ Consultancy (c) 2008
185
+	 * @version   1.0.0
186
+	 * @return bool true if insertion is succesful, false if unsuccesful
187
+	 * @internal  param object $obj object
188
+	 *
189
+	 */
190
+	public function createFieldTypes()
191
+	{
192
+		$fieldtypeHandler = new efqFieldTypeHandler();
193
+		$arr[]             = array('title' => _MD_XDIR_FIELDTYPE_TEXTBOX, 'fieldtype' => 'textbox');
194
+		$arr[]             = array('title' => _MD_XDIR_FIELDTYPE_EMAIL, 'fieldtype' => 'email');
195
+		$arr[]             = array('title' => _MD_XDIR_FIELDTYPE_URL, 'fieldtype' => 'url');
196
+		foreach ($arr as $fieldtype) {
197
+			$objFieldtype = new efqFieldType;
198
+			$objFieldtype->setVar('title', $fieldtype['title']);
199
+			$objFieldtype->setVar('fieldtype', $fieldtype['fieldtype']);
200
+			$objFieldtype->setVar('dirid', $this->efq_dirid);
201
+			$fieldtypeHandler->insertFieldType($objFieldtype, true);
202
+			$fieldtypes[$fieldtype['title']] = $objFieldtype->getVar('typeid');
203
+		}
204
+	}
205 205
 
206
-    /**
207
-     * Function doMigrate migrates xDirectory to EFQ Directory
208
-     * @author    EFQ Consultancy <[email protected]>
209
-     * @copyright EFQ Consultancy (c) 2008
210
-     * @version   1.0.0
211
-     *
212
-     * @param int $dirid
213
-     * @return bool true if insertion is succesful, false if unsuccesful
214
-     * @internal  param object $obj object
215
-     *
216
-     */
217
-    public function doMigrate($dirid = 0)
218
-    {
219
-        $this->setCategories_xdir();
220
-        $this->saveCategories($this->efq_dirid);
221
-        $this->createFieldTypes();
222
-        $this->createDataTypes();
223
-    }
206
+	/**
207
+	 * Function doMigrate migrates xDirectory to EFQ Directory
208
+	 * @author    EFQ Consultancy <[email protected]>
209
+	 * @copyright EFQ Consultancy (c) 2008
210
+	 * @version   1.0.0
211
+	 *
212
+	 * @param int $dirid
213
+	 * @return bool true if insertion is succesful, false if unsuccesful
214
+	 * @internal  param object $obj object
215
+	 *
216
+	 */
217
+	public function doMigrate($dirid = 0)
218
+	{
219
+		$this->setCategories_xdir();
220
+		$this->saveCategories($this->efq_dirid);
221
+		$this->createFieldTypes();
222
+		$this->createDataTypes();
223
+	}
224 224
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -98,7 +98,7 @@
 block discarded – undo
98 98
     public function setCategories_xdir()
99 99
     {
100 100
         $arr    = array();
101
-        $sql    = 'SELECT cid, pid, title, imgurl FROM ' . $this->db->prefix('efqdiralpha1_xdir_cat');
101
+        $sql    = 'SELECT cid, pid, title, imgurl FROM '.$this->db->prefix('efqdiralpha1_xdir_cat');
102 102
         $result = $this->db->query($sql);
103 103
         if (!$result) {
104 104
             return false;
Please login to merge, or discard this patch.
class/class.subscription.php 2 patches
Indentation   +387 added lines, -387 removed lines patch added patch discarded remove patch
@@ -19,95 +19,95 @@  discard block
 block discarded – undo
19 19
  */
20 20
 class efqSubscription extends XoopsObject
21 21
 {
22
-    /**
23
-     * Constructor
24
-     *
25
-     */
26
-    public function __construct()
27
-    {
28
-        //Constructor
29
-    }
30
-
31
-    /**
32
-     * Function durationArray: creates array of options for duration selbox:
33
-     * months, weeks, year, days etc.
34
-     *
35
-     * @author    EFQ Consultancy <[email protected]>
36
-     * @copyright EFQ Consultancy (c) 2007
37
-     * @version   1.0.0
38
-     *
39
-     * @return array $arr
40
-     */
41
-    public static function durationArray()
42
-    {
43
-        $arr = array('0' => '---', '1' => _MD_DAYS, '2' => _MD_WEEKS, '3' => _MD_MONTHS, '4' => _MD_QUARTERS, '5' => _MD_YEARS);
44
-
45
-        return $arr;
46
-    }
47
-
48
-    /**
49
-     * Function durationArray: creates array of options for duration selbox:
50
-     * single items like: month, week, year, day etc.
51
-     *
52
-     * @author    EFQ Consultancy <[email protected]>
53
-     * @copyright EFQ Consultancy (c) 2007
54
-     * @version   1.0.0
55
-     *
56
-     * @return array $arr
57
-     */
58
-    public function durationSingleArray()
59
-    {
60
-        $arr = array('0' => '---', '1' => _MD_DAY, '2' => _MD_WEEK, '3' => _MD_MONTH, '4' => _MD_QUARTER, '5' => _MD_YEAR);
61
-
62
-        return $arr;
63
-    }
64
-
65
-    /**
66
-     * Function currencyArray: creates array of options for currency selbox
67
-     *
68
-     * @author    EFQ Consultancy <[email protected]>
69
-     * @copyright EFQ Consultancy (c) 2007
70
-     * @version   1.0.0
71
-     *
72
-     * @return array $arr
73
-     */
74
-    public function currencyArray()
75
-    {
76
-        //create array of options for duration selbox: months, weeks, year, days etc.
77
-        $arr = array('0' => '---', 'USD' => _MD_CURR_USD, 'AUD' => _MD_CURR_AUD, 'EUR' => _MD_CURR_EUR, 'GBP' => _MD_CURR_GBP, 'YEN' => _MD_CURR_YEN);
78
-
79
-        return $arr;
80
-    }
81
-
82
-    /**
83
-     * Function notifyExpireWarning
84
-     * Notify user of a subscription order that is about to expire.
85
-     *
86
-     * @author    EFQ Consultancy <[email protected]>
87
-     * @copyright EFQ Consultancy (c) 2007
88
-     * @version   1.0.0
89
-     *
90
-     * @param int|string $orderid - Default: '0' - Order ID
91
-     * @param int|string $userid  - Default: '0' - User ID
92
-     */
93
-    public function notifyExpireWarning($orderid = '0', $userid = '0')
94
-    {
95
-        global $xoopsConfig, $moddir;
96
-        require_once XOOPS_ROOT_PATH . '/class/mail/xoopsmultimailer.php';
97
-
98
-        $xoopsMailer = new XoopsMailer();
99
-        $xoopsMailer->useMail();
100
-        $template_dir = XOOPS_URL . '/modules/' . $moddir . '/language/' . $xoopsConfig['language'] . '/mail_template/';
101
-        $template     = 'expirewarning.tpl';
102
-        $subject      = _MD_LANG_EXPIREWARNING_SUBJECT;
103
-        $xoopsMailer->setTemplateDir($template_dir);
104
-        $xoopsMailer->setTemplate($template);
105
-        $xoopsMailer->setToUsers($userid);
106
-        $xoopsMailer->setFromEmail($xoopsConfig['adminmail']);
107
-        $xoopsMailer->setFromName($xoopsConfig['sitename']);
108
-        $xoopsMailer->setSubject($subject);
109
-        $success = $xoopsMailer->send();
110
-    }
22
+	/**
23
+	 * Constructor
24
+	 *
25
+	 */
26
+	public function __construct()
27
+	{
28
+		//Constructor
29
+	}
30
+
31
+	/**
32
+	 * Function durationArray: creates array of options for duration selbox:
33
+	 * months, weeks, year, days etc.
34
+	 *
35
+	 * @author    EFQ Consultancy <[email protected]>
36
+	 * @copyright EFQ Consultancy (c) 2007
37
+	 * @version   1.0.0
38
+	 *
39
+	 * @return array $arr
40
+	 */
41
+	public static function durationArray()
42
+	{
43
+		$arr = array('0' => '---', '1' => _MD_DAYS, '2' => _MD_WEEKS, '3' => _MD_MONTHS, '4' => _MD_QUARTERS, '5' => _MD_YEARS);
44
+
45
+		return $arr;
46
+	}
47
+
48
+	/**
49
+	 * Function durationArray: creates array of options for duration selbox:
50
+	 * single items like: month, week, year, day etc.
51
+	 *
52
+	 * @author    EFQ Consultancy <[email protected]>
53
+	 * @copyright EFQ Consultancy (c) 2007
54
+	 * @version   1.0.0
55
+	 *
56
+	 * @return array $arr
57
+	 */
58
+	public function durationSingleArray()
59
+	{
60
+		$arr = array('0' => '---', '1' => _MD_DAY, '2' => _MD_WEEK, '3' => _MD_MONTH, '4' => _MD_QUARTER, '5' => _MD_YEAR);
61
+
62
+		return $arr;
63
+	}
64
+
65
+	/**
66
+	 * Function currencyArray: creates array of options for currency selbox
67
+	 *
68
+	 * @author    EFQ Consultancy <[email protected]>
69
+	 * @copyright EFQ Consultancy (c) 2007
70
+	 * @version   1.0.0
71
+	 *
72
+	 * @return array $arr
73
+	 */
74
+	public function currencyArray()
75
+	{
76
+		//create array of options for duration selbox: months, weeks, year, days etc.
77
+		$arr = array('0' => '---', 'USD' => _MD_CURR_USD, 'AUD' => _MD_CURR_AUD, 'EUR' => _MD_CURR_EUR, 'GBP' => _MD_CURR_GBP, 'YEN' => _MD_CURR_YEN);
78
+
79
+		return $arr;
80
+	}
81
+
82
+	/**
83
+	 * Function notifyExpireWarning
84
+	 * Notify user of a subscription order that is about to expire.
85
+	 *
86
+	 * @author    EFQ Consultancy <[email protected]>
87
+	 * @copyright EFQ Consultancy (c) 2007
88
+	 * @version   1.0.0
89
+	 *
90
+	 * @param int|string $orderid - Default: '0' - Order ID
91
+	 * @param int|string $userid  - Default: '0' - User ID
92
+	 */
93
+	public function notifyExpireWarning($orderid = '0', $userid = '0')
94
+	{
95
+		global $xoopsConfig, $moddir;
96
+		require_once XOOPS_ROOT_PATH . '/class/mail/xoopsmultimailer.php';
97
+
98
+		$xoopsMailer = new XoopsMailer();
99
+		$xoopsMailer->useMail();
100
+		$template_dir = XOOPS_URL . '/modules/' . $moddir . '/language/' . $xoopsConfig['language'] . '/mail_template/';
101
+		$template     = 'expirewarning.tpl';
102
+		$subject      = _MD_LANG_EXPIREWARNING_SUBJECT;
103
+		$xoopsMailer->setTemplateDir($template_dir);
104
+		$xoopsMailer->setTemplate($template);
105
+		$xoopsMailer->setToUsers($userid);
106
+		$xoopsMailer->setFromEmail($xoopsConfig['adminmail']);
107
+		$xoopsMailer->setFromName($xoopsConfig['sitename']);
108
+		$xoopsMailer->setSubject($subject);
109
+		$success = $xoopsMailer->send();
110
+	}
111 111
 }
112 112
 
113 113
 /**
@@ -115,77 +115,77 @@  discard block
 block discarded – undo
115 115
  */
116 116
 class efqSubscriptionHandler extends XoopsObjectHandler
117 117
 {
118
-    /**
119
-     * Constructor
120
-     *
121
-     */
122
-    public function __construct()
123
-    {
124
-        //Instantiate class
125
-        $this->db = XoopsDatabaseFactory::getDatabaseConnection();
126
-    }
127
-
128
-    /**
129
-     * Function delete: Delete subscription order
130
-     *
131
-     * @author    EFQ Consultancy <[email protected]>
132
-     * @copyright EFQ Consultancy (c) 2007
133
-     * @version   1.0.0
134
-     *
135
-     * @param int|string|XoopsObject $orderid - Default: '0' - Order ID
136
-     * @return array|bool
137
-     */
138
-    public function delete(XoopsObject $orderid = null)
139
-    {
140
-        if ($orderid !== null) {
141
-            $sql = 'DELETE FROM ' . $this->db->prefix($module->getVar('dirname', 'n') . '_subscr_orders') . ' WHERE orderid=' . (int)$orderid . '';
142
-            $this->db->query($sql);
143
-
144
-            return true;
145
-        } else {
146
-            return false;
147
-        }
148
-    }
149
-
150
-    /**
151
-     * Function createOrder: Create subscription order
152
-     *
153
-     * @author    EFQ Consultancy <[email protected]>
154
-     * @copyright EFQ Consultancy (c) 2007
155
-     * @version   1.0.0
156
-     *
157
-     * @param   int $itemid - Default: '0' - Item ID
158
-     * @return int $orderid - Newly created order id
159
-     */
160
-    public function createOrder($itemid = 0)
161
-    {
162
-        $orderid = 0;
163
-        if ($itemid != 0) {
164
-            if (isset($_POST['typeofferid'])) {
165
-                $typeofferid = explode('_', $_POST['typeofferid']);
166
-                $typeid      = $typeofferid[0];
167
-                $offerid     = $typeofferid[1];
168
-            } else {
169
-                return false;
170
-            }
171
-            $submitter = (int)$_POST['uid'];
172
-            $startdate = strtotime($_POST['startdate']);
173
-            //TO DO: Add Auto renew functionality.
174
-            //$autorenew = $_POST['autorenew'];
175
-            $newid = $this->db->genId($this->db->prefix($module->getVar('dirname', 'n') . '_subscr_orders') . '_orderid_seq');
176
-            $sql   = 'INSERT INTO ' . $this->db->prefix($module->getVar('dirname', 'n') . '_subscr_orders') . "
118
+	/**
119
+	 * Constructor
120
+	 *
121
+	 */
122
+	public function __construct()
123
+	{
124
+		//Instantiate class
125
+		$this->db = XoopsDatabaseFactory::getDatabaseConnection();
126
+	}
127
+
128
+	/**
129
+	 * Function delete: Delete subscription order
130
+	 *
131
+	 * @author    EFQ Consultancy <[email protected]>
132
+	 * @copyright EFQ Consultancy (c) 2007
133
+	 * @version   1.0.0
134
+	 *
135
+	 * @param int|string|XoopsObject $orderid - Default: '0' - Order ID
136
+	 * @return array|bool
137
+	 */
138
+	public function delete(XoopsObject $orderid = null)
139
+	{
140
+		if ($orderid !== null) {
141
+			$sql = 'DELETE FROM ' . $this->db->prefix($module->getVar('dirname', 'n') . '_subscr_orders') . ' WHERE orderid=' . (int)$orderid . '';
142
+			$this->db->query($sql);
143
+
144
+			return true;
145
+		} else {
146
+			return false;
147
+		}
148
+	}
149
+
150
+	/**
151
+	 * Function createOrder: Create subscription order
152
+	 *
153
+	 * @author    EFQ Consultancy <[email protected]>
154
+	 * @copyright EFQ Consultancy (c) 2007
155
+	 * @version   1.0.0
156
+	 *
157
+	 * @param   int $itemid - Default: '0' - Item ID
158
+	 * @return int $orderid - Newly created order id
159
+	 */
160
+	public function createOrder($itemid = 0)
161
+	{
162
+		$orderid = 0;
163
+		if ($itemid != 0) {
164
+			if (isset($_POST['typeofferid'])) {
165
+				$typeofferid = explode('_', $_POST['typeofferid']);
166
+				$typeid      = $typeofferid[0];
167
+				$offerid     = $typeofferid[1];
168
+			} else {
169
+				return false;
170
+			}
171
+			$submitter = (int)$_POST['uid'];
172
+			$startdate = strtotime($_POST['startdate']);
173
+			//TO DO: Add Auto renew functionality.
174
+			//$autorenew = $_POST['autorenew'];
175
+			$newid = $this->db->genId($this->db->prefix($module->getVar('dirname', 'n') . '_subscr_orders') . '_orderid_seq');
176
+			$sql   = 'INSERT INTO ' . $this->db->prefix($module->getVar('dirname', 'n') . '_subscr_orders') . "
177 177
                 (orderid, uid, offerid, typeid, startdate, status, itemid, autorenew) VALUES
178 178
                 ($newid, $submitter, $offerid, $typeid, '$startdate', '0' , $itemid, '0')";
179
-            $this->db->query($sql);
180
-            if ($newid == 0) {
181
-                $orderid = $this->db->getInsertId();
182
-            }
183
-        }
179
+			$this->db->query($sql);
180
+			if ($newid == 0) {
181
+				$orderid = $this->db->getInsertId();
182
+			}
183
+		}
184 184
 
185
-        return $orderid;
186
-    }
185
+		return $orderid;
186
+	}
187 187
 
188
-    /*function renewOrder($itemid = '0', $orderid='0') {
188
+	/*function renewOrder($itemid = '0', $orderid='0') {
189 189
     //Renew order
190 190
     global $xoopsDB, $eh;
191 191
     //$orderid = '0';
@@ -217,107 +217,107 @@  discard block
 block discarded – undo
217 217
     return $orderid;
218 218
     }*/
219 219
 
220
-    /**
221
-     * @param int $offerid
222
-     * @return string
223
-     */
224
-    public function getOrderItemName($offerid = 0)
225
-    {
226
-        $sql     = 'SELECT o.offerid, o.duration, o.count, o.price, o.currency, o.descr, t.typeid, t.typename FROM '
227
-                   . $this->db->prefix($module->getVar('dirname', 'n') . '_subscr_offers')
228
-                   . ' o, '
229
-                   . $this->db->prefix($module->getVar('dirname', 'n') . '_itemtypes')
230
-                   . " t WHERE o.typeid=t.typeid AND o.offerid='$offerid' ORDER BY t.typename ASC";
231
-        $result  = $this->db->query($sql);
232
-        $numrows = $this->db->getRowsNum($result);
233
-        $result  = $this->db->query($sql);
234
-        while (list($offerid, $duration, $count, $price, $currency, $descr, $typeid, $typename) = $this->db->fetchRow($result)) {
235
-            if ($count == '1') {
236
-                $duration_arr = $this->durationSingleArray();
237
-            } else {
238
-                $duration_arr = $this->durationArray();
239
-            }
240
-            $durationname = $duration_arr['' . $duration . ''];
241
-            $itemname     = $typename . ' - ' . $count . ' ' . $durationname . ' - ' . $price . ' ' . $currency;
242
-        }
243
-
244
-        return $itemname;
245
-    }
246
-
247
-    /**
248
-     * @param string $orderid
249
-     * @param string $status
250
-     * @param string $startdate
251
-     * @param string $billto
252
-     */
253
-    public function updateOrder($orderid = '0', $status = '1', $startdate = '0', $billto = '0')
254
-    {
255
-        $ordervars = $this->getOrderVars($orderid);
256
-        $typeid    = $ordervars['typeid'];
257
-        $itemid    = $ordervars['itemid'];
258
-        $sql       = 'UPDATE ' . $this->db->prefix($module->getVar('dirname', 'n') . '_subscr_orders') . " SET status='$status'";
259
-        if ($startdate != '0') {
260
-            $sql .= ", startdate='$startdate'";
261
-        }
262
-        if ($billto != '0') {
263
-            $sql .= ", billto='$billto'";
264
-        }
265
-        $sql .= ' WHERE orderid=' . (int)$orderid . '';
266
-        $this->db->queryF($sql);
267
-        if ($startdate > time()) {
268
-            $this->updateScheduler('add', $itemid, $typeid, $startdate);
269
-        } else {
270
-            $this->updateItem($itemid, $typeid);
271
-        }
272
-    }
273
-
274
-    /**
275
-     * @param string $orderid
276
-     * @return mixed
277
-     */
278
-    public function getOrderVars($orderid = '0')
279
-    {
280
-        $sql     = 'SELECT ord.uid, ord.billto, ord.startdate, ord.typeid, ord.status, ord.itemid, ord.offerid FROM ' . $this->db->prefix($module->getVar('dirname', 'n') . '_subscr_orders') . ' ord WHERE ord.orderid=' . (int)$orderid . '';
281
-        $result  = $this->db->query($sql);
282
-        $numrows = $this->db->getRowsNum($result);
283
-        $arr     = $this->db->fetchArray($result);
284
-        while (list($uid, $billto, $startdate, $typeid, $status, $itemid, $offerid) = $this->db->fetchRow($result)) {
285
-            $arr['uid']       = $uid;
286
-            $arr['billto']    = $billto;
287
-            $arr['startdate'] = $startdate;
288
-            $arr['typeid']    = $typeid;
289
-            $arr['status']    = $status;
290
-            $arr['itemid']    = $itemid;
291
-            $arr['offerid']   = $offerid;
292
-        }
293
-
294
-        return $arr;
295
-    }
296
-
297
-    /**
298
-     * @param string $offerid
299
-     * @param string $showactive
300
-     * @return array
301
-     */
302
-    public function getOfferVars($offerid = '0', $showactive = '1')
303
-    {
304
-        $sql = 'SELECT count, duration FROM ' . $this->db->prefix($module->getVar('dirname', 'n') . '_subscr_offers') . ' WHERE offerid=' . (int)$offerid . '';
305
-        if ($showactive == '1') {
306
-            $sql .= " AND activeyn='1'";
307
-        }
308
-        $result  = $this->db->query($sql);
309
-        $numrows = $this->db->getRowsNum($result);
310
-        $arr     = array();
311
-        $arr     = $this->db->fetchArray($result);
312
-        while (list($count, $duration) = $this->db->fetchRow($result)) {
313
-            $arr['count']    = $count;
314
-            $arr['duration'] = $duration;
315
-        }
316
-
317
-        return $arr;
318
-    }
319
-
320
-    /* function updateScheduler( $func='add', $itemid='0', $typeid='0', $startdate='0' ) {
220
+	/**
221
+	 * @param int $offerid
222
+	 * @return string
223
+	 */
224
+	public function getOrderItemName($offerid = 0)
225
+	{
226
+		$sql     = 'SELECT o.offerid, o.duration, o.count, o.price, o.currency, o.descr, t.typeid, t.typename FROM '
227
+				   . $this->db->prefix($module->getVar('dirname', 'n') . '_subscr_offers')
228
+				   . ' o, '
229
+				   . $this->db->prefix($module->getVar('dirname', 'n') . '_itemtypes')
230
+				   . " t WHERE o.typeid=t.typeid AND o.offerid='$offerid' ORDER BY t.typename ASC";
231
+		$result  = $this->db->query($sql);
232
+		$numrows = $this->db->getRowsNum($result);
233
+		$result  = $this->db->query($sql);
234
+		while (list($offerid, $duration, $count, $price, $currency, $descr, $typeid, $typename) = $this->db->fetchRow($result)) {
235
+			if ($count == '1') {
236
+				$duration_arr = $this->durationSingleArray();
237
+			} else {
238
+				$duration_arr = $this->durationArray();
239
+			}
240
+			$durationname = $duration_arr['' . $duration . ''];
241
+			$itemname     = $typename . ' - ' . $count . ' ' . $durationname . ' - ' . $price . ' ' . $currency;
242
+		}
243
+
244
+		return $itemname;
245
+	}
246
+
247
+	/**
248
+	 * @param string $orderid
249
+	 * @param string $status
250
+	 * @param string $startdate
251
+	 * @param string $billto
252
+	 */
253
+	public function updateOrder($orderid = '0', $status = '1', $startdate = '0', $billto = '0')
254
+	{
255
+		$ordervars = $this->getOrderVars($orderid);
256
+		$typeid    = $ordervars['typeid'];
257
+		$itemid    = $ordervars['itemid'];
258
+		$sql       = 'UPDATE ' . $this->db->prefix($module->getVar('dirname', 'n') . '_subscr_orders') . " SET status='$status'";
259
+		if ($startdate != '0') {
260
+			$sql .= ", startdate='$startdate'";
261
+		}
262
+		if ($billto != '0') {
263
+			$sql .= ", billto='$billto'";
264
+		}
265
+		$sql .= ' WHERE orderid=' . (int)$orderid . '';
266
+		$this->db->queryF($sql);
267
+		if ($startdate > time()) {
268
+			$this->updateScheduler('add', $itemid, $typeid, $startdate);
269
+		} else {
270
+			$this->updateItem($itemid, $typeid);
271
+		}
272
+	}
273
+
274
+	/**
275
+	 * @param string $orderid
276
+	 * @return mixed
277
+	 */
278
+	public function getOrderVars($orderid = '0')
279
+	{
280
+		$sql     = 'SELECT ord.uid, ord.billto, ord.startdate, ord.typeid, ord.status, ord.itemid, ord.offerid FROM ' . $this->db->prefix($module->getVar('dirname', 'n') . '_subscr_orders') . ' ord WHERE ord.orderid=' . (int)$orderid . '';
281
+		$result  = $this->db->query($sql);
282
+		$numrows = $this->db->getRowsNum($result);
283
+		$arr     = $this->db->fetchArray($result);
284
+		while (list($uid, $billto, $startdate, $typeid, $status, $itemid, $offerid) = $this->db->fetchRow($result)) {
285
+			$arr['uid']       = $uid;
286
+			$arr['billto']    = $billto;
287
+			$arr['startdate'] = $startdate;
288
+			$arr['typeid']    = $typeid;
289
+			$arr['status']    = $status;
290
+			$arr['itemid']    = $itemid;
291
+			$arr['offerid']   = $offerid;
292
+		}
293
+
294
+		return $arr;
295
+	}
296
+
297
+	/**
298
+	 * @param string $offerid
299
+	 * @param string $showactive
300
+	 * @return array
301
+	 */
302
+	public function getOfferVars($offerid = '0', $showactive = '1')
303
+	{
304
+		$sql = 'SELECT count, duration FROM ' . $this->db->prefix($module->getVar('dirname', 'n') . '_subscr_offers') . ' WHERE offerid=' . (int)$offerid . '';
305
+		if ($showactive == '1') {
306
+			$sql .= " AND activeyn='1'";
307
+		}
308
+		$result  = $this->db->query($sql);
309
+		$numrows = $this->db->getRowsNum($result);
310
+		$arr     = array();
311
+		$arr     = $this->db->fetchArray($result);
312
+		while (list($count, $duration) = $this->db->fetchRow($result)) {
313
+			$arr['count']    = $count;
314
+			$arr['duration'] = $duration;
315
+		}
316
+
317
+		return $arr;
318
+	}
319
+
320
+	/* function updateScheduler( $func='add', $itemid='0', $typeid='0', $startdate='0' ) {
321 321
     global $xoopsDB, $eh;
322 322
     if ($func='add') {
323 323
     $newid = $xoopsDB->genId($xoopsDB->prefix("efqdiralpha1_subscr_scheduler")."_id_seq");
@@ -328,134 +328,134 @@  discard block
 block discarded – undo
328 328
     }
329 329
     }*/
330 330
 
331
-    /**
332
-     * @param string $itemid
333
-     * @param string $typeid
334
-     * @return bool
335
-     */
336
-    public function updateItem($itemid = '0', $typeid = '0')
337
-    {
338
-        if ($itemid != '0' && $typeid != '0') {
339
-            $sql = 'UPDATE ' . $this->db->prefix($module->getVar('dirname', 'n') . '_items') . " SET typeid='" . (int)$typeid . '\' WHERE itemid=' . (int)$itemid . '';
340
-            $this->db->queryF($sql);
341
-
342
-            return true;
343
-        } else {
344
-            return false;
345
-        }
346
-    }
347
-
348
-    /**
349
-     * @param string $offerid
350
-     */
351
-    public function getNewBillto($offerid = '0')
352
-    {
353
-    }
354
-
355
-    /**
356
-     * @param int $itemid
357
-     * @param int $itemtype
358
-     * @return bool
359
-     */
360
-    public function changeItemType($itemid = 0, $itemtype = 0)
361
-    {
362
-        global $xoopsDB, $eh;
363
-        $sql = 'UPDATE ' . $this->db->prefix($module->getVar('dirname', 'n') . '_items') . " SET typeid=$itemtype WHERE itemid=(int)($itemid)";
364
-        $this->db->queryF($sql);
365
-
366
-        return true;
367
-    }
368
-
369
-    /**
370
-     * @param string $dashes
371
-     * @param string $showactive
372
-     * @return array
373
-     */
374
-    public function durationPriceArray($dashes = '0', $showactive = '1')
375
-    {
376
-        $sql = 'SELECT o.offerid, o.duration, o.count, o.price, o.currency, o.descr, t.typeid, t.typename FROM ' . $this->db->prefix($module->getVar('dirname', 'n') . '_subscr_offers') . ' o, ' . $this->db->prefix($module->getVar('dirname', 'n') . '_itemtypes') . ' t WHERE o.typeid=t.typeid';
377
-        if ($showactive == '1') {
378
-            $sql .= " AND activeyn='1'";
379
-        }
380
-        $sql     .= ' ORDER BY t.typelevel ASC, t.typename ASC';
381
-        $result  = $this->db->query($sql);
382
-        $numrows = $this->db->getRowsNum($result);
383
-        if ($dashes == '0') {
384
-            $arr = array('0' => '---');
385
-        }
386
-        while (list($offerid, $duration, $count, $price, $currency, $descr, $typeid, $typename) = $this->db->fetchRow($result)) {
387
-            if ($count == '1') {
388
-                $duration_arr = $this->durationSingleArray();
389
-            } else {
390
-                $duration_arr = $this->durationArray();
391
-            }
392
-            $durationname                  = $duration_arr['' . $duration . ''];
393
-            $arr[$typeid . '_' . $offerid] = $typename . '&nbsp;-&nbsp;' . $count . '&nbsp;' . $durationname . '&nbsp;-&nbsp;' . $price . '&nbsp;' . $currency;
394
-        }
395
-
396
-        return $arr;
397
-    }
398
-
399
-    /**
400
-     * @param string $selname
401
-     * @param bool   $none
402
-     * @param int    $preselected
403
-     */
404
-    public function itemsSelBox($selname = '', $none = false, $preselected = 0)
405
-    {
406
-        $sql     = 'SELECT typeid, typename FROM ' . $this->db->prefix($module->getVar('dirname', 'n') . '_itemtypes') . '';
407
-        $result  = $this->db->query($sql);
408
-        $numrows = $this->db->getRowsNum($result);
409
-        echo "<select name='" . $selname . '\'';
410
-        echo ">\n";
411
-        $result = $this->db->query($sql);
412
-        if ($none) {
413
-            echo "<option value='0'>----</option>\n";
414
-        }
415
-        while (list($typeid, $typename) = $this->db->fetchRow($result)) {
416
-            if ($preselected == $typeid) {
417
-                $sel = '&nbsp;selected';
418
-            } else {
419
-                $sel = '';
420
-            }
421
-            echo "<option value='$typeid'>$typename</option>\n";
422
-        }
423
-        echo "</select>\n";
424
-    }
425
-
426
-    /**
427
-     * @param string $dashes
428
-     * @return array
429
-     */
430
-    public function itemTypesArray($dashes = '0')
431
-    {
432
-        global $xoopsModule;
433
-        $sql     = 'SELECT typeid, typename FROM ' . $this->db->prefix($xoopsModule->getVar('dirname', 'n') . '_itemtypes') . ' ORDER BY typelevel ASC';
434
-        $result  = $this->db->query($sql) or $eh->show('0013');
435
-        $numrows = $this->db->getRowsNum($result);
436
-        $result  = $this->db->query($sql);
437
-        if ($dashes == '0') {
438
-            $arr = array('0' => '---');
439
-        }
440
-        while (list($typeid, $typename) = $this->db->fetchRow($result)) {
441
-            $arr[$typeid] = $typename;
442
-        }
443
-
444
-        return $arr;
445
-    }
446
-
447
-    /**
448
-     * @param int $typeid
449
-     * @return bool
450
-     */
451
-    public function countSubscriptionsForType($typeid = 0)
452
-    {
453
-        $sql = 'SELECT COUNT(itemid) FROM ' . $this->db->prefix($module->getVar('dirname', 'n') . '_items') . ' WHERE typeid=' . (int)$typeid . '';
454
-        if (!$result = $this->db->query($sql)) {
455
-            return false;
456
-        }
457
-        list($ret) = $this->db->fetchRow($result);
458
-
459
-        return $ret;
460
-    }
331
+	/**
332
+	 * @param string $itemid
333
+	 * @param string $typeid
334
+	 * @return bool
335
+	 */
336
+	public function updateItem($itemid = '0', $typeid = '0')
337
+	{
338
+		if ($itemid != '0' && $typeid != '0') {
339
+			$sql = 'UPDATE ' . $this->db->prefix($module->getVar('dirname', 'n') . '_items') . " SET typeid='" . (int)$typeid . '\' WHERE itemid=' . (int)$itemid . '';
340
+			$this->db->queryF($sql);
341
+
342
+			return true;
343
+		} else {
344
+			return false;
345
+		}
346
+	}
347
+
348
+	/**
349
+	 * @param string $offerid
350
+	 */
351
+	public function getNewBillto($offerid = '0')
352
+	{
353
+	}
354
+
355
+	/**
356
+	 * @param int $itemid
357
+	 * @param int $itemtype
358
+	 * @return bool
359
+	 */
360
+	public function changeItemType($itemid = 0, $itemtype = 0)
361
+	{
362
+		global $xoopsDB, $eh;
363
+		$sql = 'UPDATE ' . $this->db->prefix($module->getVar('dirname', 'n') . '_items') . " SET typeid=$itemtype WHERE itemid=(int)($itemid)";
364
+		$this->db->queryF($sql);
365
+
366
+		return true;
367
+	}
368
+
369
+	/**
370
+	 * @param string $dashes
371
+	 * @param string $showactive
372
+	 * @return array
373
+	 */
374
+	public function durationPriceArray($dashes = '0', $showactive = '1')
375
+	{
376
+		$sql = 'SELECT o.offerid, o.duration, o.count, o.price, o.currency, o.descr, t.typeid, t.typename FROM ' . $this->db->prefix($module->getVar('dirname', 'n') . '_subscr_offers') . ' o, ' . $this->db->prefix($module->getVar('dirname', 'n') . '_itemtypes') . ' t WHERE o.typeid=t.typeid';
377
+		if ($showactive == '1') {
378
+			$sql .= " AND activeyn='1'";
379
+		}
380
+		$sql     .= ' ORDER BY t.typelevel ASC, t.typename ASC';
381
+		$result  = $this->db->query($sql);
382
+		$numrows = $this->db->getRowsNum($result);
383
+		if ($dashes == '0') {
384
+			$arr = array('0' => '---');
385
+		}
386
+		while (list($offerid, $duration, $count, $price, $currency, $descr, $typeid, $typename) = $this->db->fetchRow($result)) {
387
+			if ($count == '1') {
388
+				$duration_arr = $this->durationSingleArray();
389
+			} else {
390
+				$duration_arr = $this->durationArray();
391
+			}
392
+			$durationname                  = $duration_arr['' . $duration . ''];
393
+			$arr[$typeid . '_' . $offerid] = $typename . '&nbsp;-&nbsp;' . $count . '&nbsp;' . $durationname . '&nbsp;-&nbsp;' . $price . '&nbsp;' . $currency;
394
+		}
395
+
396
+		return $arr;
397
+	}
398
+
399
+	/**
400
+	 * @param string $selname
401
+	 * @param bool   $none
402
+	 * @param int    $preselected
403
+	 */
404
+	public function itemsSelBox($selname = '', $none = false, $preselected = 0)
405
+	{
406
+		$sql     = 'SELECT typeid, typename FROM ' . $this->db->prefix($module->getVar('dirname', 'n') . '_itemtypes') . '';
407
+		$result  = $this->db->query($sql);
408
+		$numrows = $this->db->getRowsNum($result);
409
+		echo "<select name='" . $selname . '\'';
410
+		echo ">\n";
411
+		$result = $this->db->query($sql);
412
+		if ($none) {
413
+			echo "<option value='0'>----</option>\n";
414
+		}
415
+		while (list($typeid, $typename) = $this->db->fetchRow($result)) {
416
+			if ($preselected == $typeid) {
417
+				$sel = '&nbsp;selected';
418
+			} else {
419
+				$sel = '';
420
+			}
421
+			echo "<option value='$typeid'>$typename</option>\n";
422
+		}
423
+		echo "</select>\n";
424
+	}
425
+
426
+	/**
427
+	 * @param string $dashes
428
+	 * @return array
429
+	 */
430
+	public function itemTypesArray($dashes = '0')
431
+	{
432
+		global $xoopsModule;
433
+		$sql     = 'SELECT typeid, typename FROM ' . $this->db->prefix($xoopsModule->getVar('dirname', 'n') . '_itemtypes') . ' ORDER BY typelevel ASC';
434
+		$result  = $this->db->query($sql) or $eh->show('0013');
435
+		$numrows = $this->db->getRowsNum($result);
436
+		$result  = $this->db->query($sql);
437
+		if ($dashes == '0') {
438
+			$arr = array('0' => '---');
439
+		}
440
+		while (list($typeid, $typename) = $this->db->fetchRow($result)) {
441
+			$arr[$typeid] = $typename;
442
+		}
443
+
444
+		return $arr;
445
+	}
446
+
447
+	/**
448
+	 * @param int $typeid
449
+	 * @return bool
450
+	 */
451
+	public function countSubscriptionsForType($typeid = 0)
452
+	{
453
+		$sql = 'SELECT COUNT(itemid) FROM ' . $this->db->prefix($module->getVar('dirname', 'n') . '_items') . ' WHERE typeid=' . (int)$typeid . '';
454
+		if (!$result = $this->db->query($sql)) {
455
+			return false;
456
+		}
457
+		list($ret) = $this->db->fetchRow($result);
458
+
459
+		return $ret;
460
+	}
461 461
 }
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -93,11 +93,11 @@  discard block
 block discarded – undo
93 93
     public function notifyExpireWarning($orderid = '0', $userid = '0')
94 94
     {
95 95
         global $xoopsConfig, $moddir;
96
-        require_once XOOPS_ROOT_PATH . '/class/mail/xoopsmultimailer.php';
96
+        require_once XOOPS_ROOT_PATH.'/class/mail/xoopsmultimailer.php';
97 97
 
98 98
         $xoopsMailer = new XoopsMailer();
99 99
         $xoopsMailer->useMail();
100
-        $template_dir = XOOPS_URL . '/modules/' . $moddir . '/language/' . $xoopsConfig['language'] . '/mail_template/';
100
+        $template_dir = XOOPS_URL.'/modules/'.$moddir.'/language/'.$xoopsConfig['language'].'/mail_template/';
101 101
         $template     = 'expirewarning.tpl';
102 102
         $subject      = _MD_LANG_EXPIREWARNING_SUBJECT;
103 103
         $xoopsMailer->setTemplateDir($template_dir);
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
     public function delete(XoopsObject $orderid = null)
139 139
     {
140 140
         if ($orderid !== null) {
141
-            $sql = 'DELETE FROM ' . $this->db->prefix($module->getVar('dirname', 'n') . '_subscr_orders') . ' WHERE orderid=' . (int)$orderid . '';
141
+            $sql = 'DELETE FROM '.$this->db->prefix($module->getVar('dirname', 'n').'_subscr_orders').' WHERE orderid='.(int) $orderid.'';
142 142
             $this->db->query($sql);
143 143
 
144 144
             return true;
@@ -168,12 +168,12 @@  discard block
 block discarded – undo
168 168
             } else {
169 169
                 return false;
170 170
             }
171
-            $submitter = (int)$_POST['uid'];
171
+            $submitter = (int) $_POST['uid'];
172 172
             $startdate = strtotime($_POST['startdate']);
173 173
             //TO DO: Add Auto renew functionality.
174 174
             //$autorenew = $_POST['autorenew'];
175
-            $newid = $this->db->genId($this->db->prefix($module->getVar('dirname', 'n') . '_subscr_orders') . '_orderid_seq');
176
-            $sql   = 'INSERT INTO ' . $this->db->prefix($module->getVar('dirname', 'n') . '_subscr_orders') . "
175
+            $newid = $this->db->genId($this->db->prefix($module->getVar('dirname', 'n').'_subscr_orders').'_orderid_seq');
176
+            $sql   = 'INSERT INTO '.$this->db->prefix($module->getVar('dirname', 'n').'_subscr_orders')."
177 177
                 (orderid, uid, offerid, typeid, startdate, status, itemid, autorenew) VALUES
178 178
                 ($newid, $submitter, $offerid, $typeid, '$startdate', '0' , $itemid, '0')";
179 179
             $this->db->query($sql);
@@ -223,10 +223,10 @@  discard block
 block discarded – undo
223 223
      */
224 224
     public function getOrderItemName($offerid = 0)
225 225
     {
226
-        $sql     = 'SELECT o.offerid, o.duration, o.count, o.price, o.currency, o.descr, t.typeid, t.typename FROM '
227
-                   . $this->db->prefix($module->getVar('dirname', 'n') . '_subscr_offers')
226
+        $sql = 'SELECT o.offerid, o.duration, o.count, o.price, o.currency, o.descr, t.typeid, t.typename FROM '
227
+                   . $this->db->prefix($module->getVar('dirname', 'n').'_subscr_offers')
228 228
                    . ' o, '
229
-                   . $this->db->prefix($module->getVar('dirname', 'n') . '_itemtypes')
229
+                   . $this->db->prefix($module->getVar('dirname', 'n').'_itemtypes')
230 230
                    . " t WHERE o.typeid=t.typeid AND o.offerid='$offerid' ORDER BY t.typename ASC";
231 231
         $result  = $this->db->query($sql);
232 232
         $numrows = $this->db->getRowsNum($result);
@@ -237,8 +237,8 @@  discard block
 block discarded – undo
237 237
             } else {
238 238
                 $duration_arr = $this->durationArray();
239 239
             }
240
-            $durationname = $duration_arr['' . $duration . ''];
241
-            $itemname     = $typename . ' - ' . $count . ' ' . $durationname . ' - ' . $price . ' ' . $currency;
240
+            $durationname = $duration_arr[''.$duration.''];
241
+            $itemname     = $typename.' - '.$count.' '.$durationname.' - '.$price.' '.$currency;
242 242
         }
243 243
 
244 244
         return $itemname;
@@ -255,14 +255,14 @@  discard block
 block discarded – undo
255 255
         $ordervars = $this->getOrderVars($orderid);
256 256
         $typeid    = $ordervars['typeid'];
257 257
         $itemid    = $ordervars['itemid'];
258
-        $sql       = 'UPDATE ' . $this->db->prefix($module->getVar('dirname', 'n') . '_subscr_orders') . " SET status='$status'";
258
+        $sql       = 'UPDATE '.$this->db->prefix($module->getVar('dirname', 'n').'_subscr_orders')." SET status='$status'";
259 259
         if ($startdate != '0') {
260 260
             $sql .= ", startdate='$startdate'";
261 261
         }
262 262
         if ($billto != '0') {
263 263
             $sql .= ", billto='$billto'";
264 264
         }
265
-        $sql .= ' WHERE orderid=' . (int)$orderid . '';
265
+        $sql .= ' WHERE orderid='.(int) $orderid.'';
266 266
         $this->db->queryF($sql);
267 267
         if ($startdate > time()) {
268 268
             $this->updateScheduler('add', $itemid, $typeid, $startdate);
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
      */
278 278
     public function getOrderVars($orderid = '0')
279 279
     {
280
-        $sql     = 'SELECT ord.uid, ord.billto, ord.startdate, ord.typeid, ord.status, ord.itemid, ord.offerid FROM ' . $this->db->prefix($module->getVar('dirname', 'n') . '_subscr_orders') . ' ord WHERE ord.orderid=' . (int)$orderid . '';
280
+        $sql     = 'SELECT ord.uid, ord.billto, ord.startdate, ord.typeid, ord.status, ord.itemid, ord.offerid FROM '.$this->db->prefix($module->getVar('dirname', 'n').'_subscr_orders').' ord WHERE ord.orderid='.(int) $orderid.'';
281 281
         $result  = $this->db->query($sql);
282 282
         $numrows = $this->db->getRowsNum($result);
283 283
         $arr     = $this->db->fetchArray($result);
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
      */
302 302
     public function getOfferVars($offerid = '0', $showactive = '1')
303 303
     {
304
-        $sql = 'SELECT count, duration FROM ' . $this->db->prefix($module->getVar('dirname', 'n') . '_subscr_offers') . ' WHERE offerid=' . (int)$offerid . '';
304
+        $sql = 'SELECT count, duration FROM '.$this->db->prefix($module->getVar('dirname', 'n').'_subscr_offers').' WHERE offerid='.(int) $offerid.'';
305 305
         if ($showactive == '1') {
306 306
             $sql .= " AND activeyn='1'";
307 307
         }
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
     public function updateItem($itemid = '0', $typeid = '0')
337 337
     {
338 338
         if ($itemid != '0' && $typeid != '0') {
339
-            $sql = 'UPDATE ' . $this->db->prefix($module->getVar('dirname', 'n') . '_items') . " SET typeid='" . (int)$typeid . '\' WHERE itemid=' . (int)$itemid . '';
339
+            $sql = 'UPDATE '.$this->db->prefix($module->getVar('dirname', 'n').'_items')." SET typeid='".(int) $typeid.'\' WHERE itemid='.(int) $itemid.'';
340 340
             $this->db->queryF($sql);
341 341
 
342 342
             return true;
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
     public function changeItemType($itemid = 0, $itemtype = 0)
361 361
     {
362 362
         global $xoopsDB, $eh;
363
-        $sql = 'UPDATE ' . $this->db->prefix($module->getVar('dirname', 'n') . '_items') . " SET typeid=$itemtype WHERE itemid=(int)($itemid)";
363
+        $sql = 'UPDATE '.$this->db->prefix($module->getVar('dirname', 'n').'_items')." SET typeid=$itemtype WHERE itemid=(int)($itemid)";
364 364
         $this->db->queryF($sql);
365 365
 
366 366
         return true;
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
      */
374 374
     public function durationPriceArray($dashes = '0', $showactive = '1')
375 375
     {
376
-        $sql = 'SELECT o.offerid, o.duration, o.count, o.price, o.currency, o.descr, t.typeid, t.typename FROM ' . $this->db->prefix($module->getVar('dirname', 'n') . '_subscr_offers') . ' o, ' . $this->db->prefix($module->getVar('dirname', 'n') . '_itemtypes') . ' t WHERE o.typeid=t.typeid';
376
+        $sql = 'SELECT o.offerid, o.duration, o.count, o.price, o.currency, o.descr, t.typeid, t.typename FROM '.$this->db->prefix($module->getVar('dirname', 'n').'_subscr_offers').' o, '.$this->db->prefix($module->getVar('dirname', 'n').'_itemtypes').' t WHERE o.typeid=t.typeid';
377 377
         if ($showactive == '1') {
378 378
             $sql .= " AND activeyn='1'";
379 379
         }
@@ -389,8 +389,8 @@  discard block
 block discarded – undo
389 389
             } else {
390 390
                 $duration_arr = $this->durationArray();
391 391
             }
392
-            $durationname                  = $duration_arr['' . $duration . ''];
393
-            $arr[$typeid . '_' . $offerid] = $typename . '&nbsp;-&nbsp;' . $count . '&nbsp;' . $durationname . '&nbsp;-&nbsp;' . $price . '&nbsp;' . $currency;
392
+            $durationname                  = $duration_arr[''.$duration.''];
393
+            $arr[$typeid.'_'.$offerid] = $typename.'&nbsp;-&nbsp;'.$count.'&nbsp;'.$durationname.'&nbsp;-&nbsp;'.$price.'&nbsp;'.$currency;
394 394
         }
395 395
 
396 396
         return $arr;
@@ -403,10 +403,10 @@  discard block
 block discarded – undo
403 403
      */
404 404
     public function itemsSelBox($selname = '', $none = false, $preselected = 0)
405 405
     {
406
-        $sql     = 'SELECT typeid, typename FROM ' . $this->db->prefix($module->getVar('dirname', 'n') . '_itemtypes') . '';
406
+        $sql     = 'SELECT typeid, typename FROM '.$this->db->prefix($module->getVar('dirname', 'n').'_itemtypes').'';
407 407
         $result  = $this->db->query($sql);
408 408
         $numrows = $this->db->getRowsNum($result);
409
-        echo "<select name='" . $selname . '\'';
409
+        echo "<select name='".$selname.'\'';
410 410
         echo ">\n";
411 411
         $result = $this->db->query($sql);
412 412
         if ($none) {
@@ -430,7 +430,7 @@  discard block
 block discarded – undo
430 430
     public function itemTypesArray($dashes = '0')
431 431
     {
432 432
         global $xoopsModule;
433
-        $sql     = 'SELECT typeid, typename FROM ' . $this->db->prefix($xoopsModule->getVar('dirname', 'n') . '_itemtypes') . ' ORDER BY typelevel ASC';
433
+        $sql     = 'SELECT typeid, typename FROM '.$this->db->prefix($xoopsModule->getVar('dirname', 'n').'_itemtypes').' ORDER BY typelevel ASC';
434 434
         $result  = $this->db->query($sql) or $eh->show('0013');
435 435
         $numrows = $this->db->getRowsNum($result);
436 436
         $result  = $this->db->query($sql);
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
      */
451 451
     public function countSubscriptionsForType($typeid = 0)
452 452
     {
453
-        $sql = 'SELECT COUNT(itemid) FROM ' . $this->db->prefix($module->getVar('dirname', 'n') . '_items') . ' WHERE typeid=' . (int)$typeid . '';
453
+        $sql = 'SELECT COUNT(itemid) FROM '.$this->db->prefix($module->getVar('dirname', 'n').'_items').' WHERE typeid='.(int) $typeid.'';
454 454
         if (!$result = $this->db->query($sql)) {
455 455
             return false;
456 456
         }
Please login to merge, or discard this patch.
class/class.listingdata.php 2 patches
Indentation   +189 added lines, -189 removed lines patch added patch discarded remove patch
@@ -41,62 +41,62 @@  discard block
 block discarded – undo
41 41
  */
42 42
 class efqListingData extends XoopsObject
43 43
 {
44
-    public $_updated  = false;
45
-    public $_inserted = false;
44
+	public $_updated  = false;
45
+	public $_inserted = false;
46 46
 
47
-    /**
48
-     * Constructor
49
-     */
50
-    public function __construct()
51
-    {
52
-        // class constructor;
53
-        //$this->setCurrentUser();
54
-        $this->initVar('dataid', XOBJ_DTYPE_INT, 0, true);
55
-        $this->initVar('itemid', XOBJ_DTYPE_INT, 0, true);
56
-        $this->initVar('dtypeid', XOBJ_DTYPE_INT, 0, true);
57
-        $this->initVar('itemid', XOBJ_DTYPE_INT, 0, true);
58
-        $this->initVar('value', XOBJ_DTYPE_TXTAREA, null, false);
59
-        $this->initVar('created', XOBJ_DTYPE_INT, 0, true);
60
-        $this->initVar('customtitle', XOBJ_DTYPE_TXTBOX, null, false, 255);
61
-    }
47
+	/**
48
+	 * Constructor
49
+	 */
50
+	public function __construct()
51
+	{
52
+		// class constructor;
53
+		//$this->setCurrentUser();
54
+		$this->initVar('dataid', XOBJ_DTYPE_INT, 0, true);
55
+		$this->initVar('itemid', XOBJ_DTYPE_INT, 0, true);
56
+		$this->initVar('dtypeid', XOBJ_DTYPE_INT, 0, true);
57
+		$this->initVar('itemid', XOBJ_DTYPE_INT, 0, true);
58
+		$this->initVar('value', XOBJ_DTYPE_TXTAREA, null, false);
59
+		$this->initVar('created', XOBJ_DTYPE_INT, 0, true);
60
+		$this->initVar('customtitle', XOBJ_DTYPE_TXTBOX, null, false, 255);
61
+	}
62 62
 
63
-    //Set variable $_updated to true of false (default)
63
+	//Set variable $_updated to true of false (default)
64 64
 
65
-    /**
66
-     * @param bool $set
67
-     */
68
-    public function setUpdated($set = false)
69
-    {
70
-        $this->_updated = $set;
71
-    }
65
+	/**
66
+	 * @param bool $set
67
+	 */
68
+	public function setUpdated($set = false)
69
+	{
70
+		$this->_updated = $set;
71
+	}
72 72
 
73
-    //Set variable $_inserted to true of false (default)
73
+	//Set variable $_inserted to true of false (default)
74 74
 
75
-    /**
76
-     * @param bool $set
77
-     */
78
-    public function setInserted($set = false)
79
-    {
80
-        $this->_inserted = $set;
81
-    }
75
+	/**
76
+	 * @param bool $set
77
+	 */
78
+	public function setInserted($set = false)
79
+	{
80
+		$this->_inserted = $set;
81
+	}
82 82
 
83
-    /**
84
-     * @param $arr
85
-     * @return bool
86
-     */
87
-    public function setListingData($arr)
88
-    {
89
-        if (is_array($arr)) {
90
-            $vars = $this->getVars();
91
-            foreach ($vars as $k => $v) {
92
-                $this->setVar($k, $arr[$k]);
93
-            }
94
-        } else {
95
-            return false;
96
-        }
83
+	/**
84
+	 * @param $arr
85
+	 * @return bool
86
+	 */
87
+	public function setListingData($arr)
88
+	{
89
+		if (is_array($arr)) {
90
+			$vars = $this->getVars();
91
+			foreach ($vars as $k => $v) {
92
+				$this->setVar($k, $arr[$k]);
93
+			}
94
+		} else {
95
+			return false;
96
+		}
97 97
 
98
-        return true;
99
-    }
98
+		return true;
99
+	}
100 100
 }
101 101
 
102 102
 /**
@@ -110,153 +110,153 @@  discard block
 block discarded – undo
110 110
  */
111 111
 class efqListingDataHandler extends XoopsObjectHandler
112 112
 {
113
-    public $errorhandler;
113
+	public $errorhandler;
114 114
 
115
-    /**
116
-     * efqListingDataHandler constructor.
117
-     */
118
-    public function __construct()
119
-    {
120
-        //Instantiate class
121
-        global $eh;
122
-        $this->db           = XoopsDatabaseFactory::getDatabaseConnection();
123
-        $this->errorhandler = $eh;
124
-    }
115
+	/**
116
+	 * efqListingDataHandler constructor.
117
+	 */
118
+	public function __construct()
119
+	{
120
+		//Instantiate class
121
+		global $eh;
122
+		$this->db           = XoopsDatabaseFactory::getDatabaseConnection();
123
+		$this->errorhandler = $eh;
124
+	}
125 125
 
126
-    /**
127
-     * @param int $itemid
128
-     * @return array
129
-     */
130
-    public function getData($itemid = 0)
131
-    {
132
-        $arr = array();
133
-        $sql = 'SELECT DISTINCT t.dtypeid, t.title, t.section, f.typeid, f.fieldtype, f.ext, t.options, d.dataid, d.itemid, d.value, d.created, t.custom ';
134
-        $sql .= 'FROM ' . $this->db->prefix('efqdiralpha1_item_x_cat') . ' ic, ' . $this->db->prefix('efqdiralpha1_dtypes_x_cat') . ' xc, ' . $this->db->prefix('efqdiralpha1_fieldtypes') . ' f, ' . $this->db->prefix('efqdiralpha1_dtypes') . ' t ';
135
-        $sql .= 'LEFT JOIN ' . $this->db->prefix('efqdiralpha1_data') . ' d ON (t.dtypeid=d.dtypeid AND d.itemid=' . $itemid . ') ';
136
-        $sql .= "WHERE ic.cid=xc.cid AND ic.active='1' AND xc.dtypeid=t.dtypeid AND t.fieldtypeid=f.typeid AND t.activeyn='1' AND ic.itemid=" . $itemid . '';
137
-        $data_result = $this->db->query($sql) or $eh->show('0013');
138
-        while (list($dtypeid, $title, $section, $ftypeid, $fieldtype, $ext, $options, $dataid, $itemid, $value, $created, $custom) = $this->db->fetchRow($data_result)) {
139
-            $arr[] = array(
140
-                'dtypeid'     => $dtypeid,
141
-                'title'       => $title,
142
-                'section'     => $section,
143
-                'ftypeid'     => $ftypeid,
144
-                'fieldtype'   => $fieldtype,
145
-                'ext'         => $ext,
146
-                'options'     => $options,
147
-                'dataid'      => $dataid,
148
-                'itemid'      => $itemid,
149
-                'value'       => $value,
150
-                'created'     => $created,
151
-                'customtitle' => $custom
152
-            );
153
-        }
126
+	/**
127
+	 * @param int $itemid
128
+	 * @return array
129
+	 */
130
+	public function getData($itemid = 0)
131
+	{
132
+		$arr = array();
133
+		$sql = 'SELECT DISTINCT t.dtypeid, t.title, t.section, f.typeid, f.fieldtype, f.ext, t.options, d.dataid, d.itemid, d.value, d.created, t.custom ';
134
+		$sql .= 'FROM ' . $this->db->prefix('efqdiralpha1_item_x_cat') . ' ic, ' . $this->db->prefix('efqdiralpha1_dtypes_x_cat') . ' xc, ' . $this->db->prefix('efqdiralpha1_fieldtypes') . ' f, ' . $this->db->prefix('efqdiralpha1_dtypes') . ' t ';
135
+		$sql .= 'LEFT JOIN ' . $this->db->prefix('efqdiralpha1_data') . ' d ON (t.dtypeid=d.dtypeid AND d.itemid=' . $itemid . ') ';
136
+		$sql .= "WHERE ic.cid=xc.cid AND ic.active='1' AND xc.dtypeid=t.dtypeid AND t.fieldtypeid=f.typeid AND t.activeyn='1' AND ic.itemid=" . $itemid . '';
137
+		$data_result = $this->db->query($sql) or $eh->show('0013');
138
+		while (list($dtypeid, $title, $section, $ftypeid, $fieldtype, $ext, $options, $dataid, $itemid, $value, $created, $custom) = $this->db->fetchRow($data_result)) {
139
+			$arr[] = array(
140
+				'dtypeid'     => $dtypeid,
141
+				'title'       => $title,
142
+				'section'     => $section,
143
+				'ftypeid'     => $ftypeid,
144
+				'fieldtype'   => $fieldtype,
145
+				'ext'         => $ext,
146
+				'options'     => $options,
147
+				'dataid'      => $dataid,
148
+				'itemid'      => $itemid,
149
+				'value'       => $value,
150
+				'created'     => $created,
151
+				'customtitle' => $custom
152
+			);
153
+		}
154 154
 
155
-        return $arr;
156
-    }
155
+		return $arr;
156
+	}
157 157
 
158
-    /**
159
-     * Function updateListingData updates listing data
160
-     * @author    EFQ Consultancy <[email protected]>
161
-     * @copyright EFQ Consultancy (c) 2008
162
-     * @version   1.0.0
163
-     *
164
-     * @param   object $obj object of type listing
165
-     *
166
-     * @param bool     $forceQuery
167
-     * @return bool true if update is successful, false if unsuccessful
168
-     */
169
-    public function updateListingData($obj, $forceQuery = false)
170
-    {
171
-        $tablename = 'efqdiralpha1_data';
172
-        $keyName   = 'dataid';
173
-        if ($obj instanceof efqListingData) {
174
-            // Variable part of this function ends. From this line you can copy
175
-            // this function for similar object handling functions.
176
-            $obj->cleanVars();
177
-            $cleanvars = $obj->cleanVars;
178
-            $keyValue  = $obj->getVar($keyName);
179
-        } else {
180
-            return false;
181
-        }
182
-        $countVars = count($cleanvars);
183
-        $i         = 1;
184
-        $strSet    = '';
185
-        $strValues = '';
186
-        foreach ($cleanvars as $k => $v) {
187
-            $strSet .= $k . '=' . "'" . $v . "'";
188
-            if ($i < $countVars) {
189
-                $strSet .= ', ';
190
-            }
191
-            $i++;
192
-        }
193
-        $sql = sprintf('UPDATE %s SET %s WHERE %s = %u', $this->db->prefix($tablename), $strSet, $keyName, $keyValue);
194
-        if ($forceQuery) {
195
-            if ($this->db->queryF($sql)) {
196
-                return true;
197
-            }
198
-        } else {
199
-            if ($this->db->query($sql)) {
200
-                return true;
201
-            }
202
-        }
158
+	/**
159
+	 * Function updateListingData updates listing data
160
+	 * @author    EFQ Consultancy <[email protected]>
161
+	 * @copyright EFQ Consultancy (c) 2008
162
+	 * @version   1.0.0
163
+	 *
164
+	 * @param   object $obj object of type listing
165
+	 *
166
+	 * @param bool     $forceQuery
167
+	 * @return bool true if update is successful, false if unsuccessful
168
+	 */
169
+	public function updateListingData($obj, $forceQuery = false)
170
+	{
171
+		$tablename = 'efqdiralpha1_data';
172
+		$keyName   = 'dataid';
173
+		if ($obj instanceof efqListingData) {
174
+			// Variable part of this function ends. From this line you can copy
175
+			// this function for similar object handling functions.
176
+			$obj->cleanVars();
177
+			$cleanvars = $obj->cleanVars;
178
+			$keyValue  = $obj->getVar($keyName);
179
+		} else {
180
+			return false;
181
+		}
182
+		$countVars = count($cleanvars);
183
+		$i         = 1;
184
+		$strSet    = '';
185
+		$strValues = '';
186
+		foreach ($cleanvars as $k => $v) {
187
+			$strSet .= $k . '=' . "'" . $v . "'";
188
+			if ($i < $countVars) {
189
+				$strSet .= ', ';
190
+			}
191
+			$i++;
192
+		}
193
+		$sql = sprintf('UPDATE %s SET %s WHERE %s = %u', $this->db->prefix($tablename), $strSet, $keyName, $keyValue);
194
+		if ($forceQuery) {
195
+			if ($this->db->queryF($sql)) {
196
+				return true;
197
+			}
198
+		} else {
199
+			if ($this->db->query($sql)) {
200
+				return true;
201
+			}
202
+		}
203 203
 
204
-        return false;
205
-    }
204
+		return false;
205
+	}
206 206
 
207
-    /**
208
-     * Function insertListingData inserts listing data into DB
209
-     * @author    EFQ Consultancy <[email protected]>
210
-     * @copyright EFQ Consultancy (c) 2008
211
-     * @version   1.0.0
212
-     *
213
-     * @param      $obj
214
-     * @param bool $forceQuery
215
-     * @return bool true if insertion is succesful, false if unsuccesful
216
-     * @internal  param object $objListing object of type listing
217
-     */
218
-    public function insertListingData($obj, $forceQuery = false)
219
-    {
220
-        $tablename = 'efqdiralpha1_data';
221
-        $keyName   = 'dataid';
222
-        if ($obj instanceof efqListingData) {
223
-            // Variable part of this function ends. From this line you can copy
224
-            // this function for similar object handling functions.
225
-            $obj->cleanVars();
226
-            $cleanvars = $obj->cleanVars;
227
-        } else {
228
-            return false;
229
-        }
230
-        $countVars = count($cleanvars);
231
-        $i         = 1;
232
-        $strFields = '';
233
-        $strValues = '';
234
-        foreach ($cleanvars as $k => $v) {
235
-            $strFields .= $k;
236
-            $strValues .= "'" . $v . "'";
237
-            if ($i < $countVars) {
238
-                $strFields .= ', ';
239
-                $strValues .= ', ';
240
-            }
241
-            $i++;
242
-        }
243
-        $sql = sprintf('INSERT INTO %s (%s) VALUES (%s)', $this->db->prefix($tablename), $strFields, $strValues);
244
-        if ($forceQuery) {
245
-            if ($this->db->queryF($sql)) {
246
-                $itemid = $this->db->getInsertId();
247
-                $obj->setVar($keyName, $itemid);
207
+	/**
208
+	 * Function insertListingData inserts listing data into DB
209
+	 * @author    EFQ Consultancy <[email protected]>
210
+	 * @copyright EFQ Consultancy (c) 2008
211
+	 * @version   1.0.0
212
+	 *
213
+	 * @param      $obj
214
+	 * @param bool $forceQuery
215
+	 * @return bool true if insertion is succesful, false if unsuccesful
216
+	 * @internal  param object $objListing object of type listing
217
+	 */
218
+	public function insertListingData($obj, $forceQuery = false)
219
+	{
220
+		$tablename = 'efqdiralpha1_data';
221
+		$keyName   = 'dataid';
222
+		if ($obj instanceof efqListingData) {
223
+			// Variable part of this function ends. From this line you can copy
224
+			// this function for similar object handling functions.
225
+			$obj->cleanVars();
226
+			$cleanvars = $obj->cleanVars;
227
+		} else {
228
+			return false;
229
+		}
230
+		$countVars = count($cleanvars);
231
+		$i         = 1;
232
+		$strFields = '';
233
+		$strValues = '';
234
+		foreach ($cleanvars as $k => $v) {
235
+			$strFields .= $k;
236
+			$strValues .= "'" . $v . "'";
237
+			if ($i < $countVars) {
238
+				$strFields .= ', ';
239
+				$strValues .= ', ';
240
+			}
241
+			$i++;
242
+		}
243
+		$sql = sprintf('INSERT INTO %s (%s) VALUES (%s)', $this->db->prefix($tablename), $strFields, $strValues);
244
+		if ($forceQuery) {
245
+			if ($this->db->queryF($sql)) {
246
+				$itemid = $this->db->getInsertId();
247
+				$obj->setVar($keyName, $itemid);
248 248
 
249
-                return true;
250
-            }
251
-        } else {
252
-            if ($this->db->query($sql)) {
253
-                $itemid = $this->db->getInsertId();
254
-                $obj->setVar($keyName, $itemid);
249
+				return true;
250
+			}
251
+		} else {
252
+			if ($this->db->query($sql)) {
253
+				$itemid = $this->db->getInsertId();
254
+				$obj->setVar($keyName, $itemid);
255 255
 
256
-                return true;
257
-            }
258
-        }
256
+				return true;
257
+			}
258
+		}
259 259
 
260
-        return false;
261
-    }
260
+		return false;
261
+	}
262 262
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -131,9 +131,9 @@  discard block
 block discarded – undo
131 131
     {
132 132
         $arr = array();
133 133
         $sql = 'SELECT DISTINCT t.dtypeid, t.title, t.section, f.typeid, f.fieldtype, f.ext, t.options, d.dataid, d.itemid, d.value, d.created, t.custom ';
134
-        $sql .= 'FROM ' . $this->db->prefix('efqdiralpha1_item_x_cat') . ' ic, ' . $this->db->prefix('efqdiralpha1_dtypes_x_cat') . ' xc, ' . $this->db->prefix('efqdiralpha1_fieldtypes') . ' f, ' . $this->db->prefix('efqdiralpha1_dtypes') . ' t ';
135
-        $sql .= 'LEFT JOIN ' . $this->db->prefix('efqdiralpha1_data') . ' d ON (t.dtypeid=d.dtypeid AND d.itemid=' . $itemid . ') ';
136
-        $sql .= "WHERE ic.cid=xc.cid AND ic.active='1' AND xc.dtypeid=t.dtypeid AND t.fieldtypeid=f.typeid AND t.activeyn='1' AND ic.itemid=" . $itemid . '';
134
+        $sql .= 'FROM '.$this->db->prefix('efqdiralpha1_item_x_cat').' ic, '.$this->db->prefix('efqdiralpha1_dtypes_x_cat').' xc, '.$this->db->prefix('efqdiralpha1_fieldtypes').' f, '.$this->db->prefix('efqdiralpha1_dtypes').' t ';
135
+        $sql .= 'LEFT JOIN '.$this->db->prefix('efqdiralpha1_data').' d ON (t.dtypeid=d.dtypeid AND d.itemid='.$itemid.') ';
136
+        $sql .= "WHERE ic.cid=xc.cid AND ic.active='1' AND xc.dtypeid=t.dtypeid AND t.fieldtypeid=f.typeid AND t.activeyn='1' AND ic.itemid=".$itemid.'';
137 137
         $data_result = $this->db->query($sql) or $eh->show('0013');
138 138
         while (list($dtypeid, $title, $section, $ftypeid, $fieldtype, $ext, $options, $dataid, $itemid, $value, $created, $custom) = $this->db->fetchRow($data_result)) {
139 139
             $arr[] = array(
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
         $strSet    = '';
185 185
         $strValues = '';
186 186
         foreach ($cleanvars as $k => $v) {
187
-            $strSet .= $k . '=' . "'" . $v . "'";
187
+            $strSet .= $k.'='."'".$v."'";
188 188
             if ($i < $countVars) {
189 189
                 $strSet .= ', ';
190 190
             }
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
         $strValues = '';
234 234
         foreach ($cleanvars as $k => $v) {
235 235
             $strFields .= $k;
236
-            $strValues .= "'" . $v . "'";
236
+            $strValues .= "'".$v."'";
237 237
             if ($i < $countVars) {
238 238
                 $strFields .= ', ';
239 239
                 $strValues .= ', ';
Please login to merge, or discard this patch.
class/class.uploader.php 2 patches
Indentation   +434 added lines, -434 removed lines patch added patch discarded remove patch
@@ -72,438 +72,438 @@
 block discarded – undo
72 72
  */
73 73
 class XoopsMediaUploader
74 74
 {
75
-    /**
76
-     * Flag indicating if unrecognized mimetypes should be allowed (use with precaution ! may lead to security issues )
77
-     **/
78
-    public $allowUnknownTypes = false;
79
-
80
-    public $mediaName;
81
-    public $mediaType;
82
-    public $mediaSize;
83
-    public $mediaTmpName;
84
-    public $mediaError;
85
-    public $mediaRealType = '';
86
-
87
-    public $uploadDir = '';
88
-
89
-    public $allowedMimeTypes = array();
90
-
91
-    public $maxFileSize = 0;
92
-    public $maxWidth;
93
-    public $maxHeight;
94
-
95
-    public $targetFileName;
96
-
97
-    public $prefix;
98
-
99
-    public $errors = array();
100
-
101
-    public $savedDestination;
102
-
103
-    public $savedFileName;
104
-
105
-    public $extensionToMime = array();
106
-
107
-    /**
108
-     * Constructor
109
-     *
110
-     * @param   string $uploadDir
111
-     * @param   array  $allowedMimeTypes
112
-     * @param   int    $maxFileSize
113
-     * @param   int    $maxWidth
114
-     * @param   int    $maxHeight
115
-     * @internal param int $cmodvalue
116
-     */
117
-    public function __construct($uploadDir, $allowedMimeTypes, $maxFileSize = 0, $maxWidth = null, $maxHeight = null)
118
-    {
119
-        @$this->extensionToMime = include XOOPS_ROOT_PATH . '/class/mimetypes.inc.php';
120
-        if (!is_array($this->extensionToMime)) {
121
-            $this->extensionToMime = array();
122
-
123
-            return false;
124
-        }
125
-        if (is_array($allowedMimeTypes)) {
126
-            $this->allowedMimeTypes =& $allowedMimeTypes;
127
-        }
128
-        $this->uploadDir   = $uploadDir;
129
-        $this->maxFileSize = (int)$maxFileSize;
130
-        if (isset($maxWidth)) {
131
-            $this->maxWidth = (int)$maxWidth;
132
-        }
133
-        if (isset($maxHeight)) {
134
-            $this->maxHeight = (int)$maxHeight;
135
-        }
136
-    }
137
-
138
-    /**
139
-     * Fetch the uploaded file
140
-     *
141
-     * @param   string $media_name Name of the file field
142
-     * @param   int    $index      Index of the file (if more than one uploaded under that name)
143
-     * @return  bool
144
-     **/
145
-    public function fetchMedia($media_name, $index = null)
146
-    {
147
-        if (empty($this->extensionToMime)) {
148
-            $this->setErrors('Error loading mimetypes definition');
149
-
150
-            return false;
151
-        }
152
-        if (!isset($_FILES[$media_name])) {
153
-            $this->setErrors('File not found');
154
-
155
-            //echo " - no such file ";
156
-            return false;
157
-        } elseif (is_array($_FILES[$media_name]['name']) && isset($index)) {
158
-            $index              = (int)$index;
159
-            $this->mediaName    = get_magic_quotes_gpc() ? stripslashes($_FILES[$media_name]['name'][$index]) : $_FILES[$media_name]['name'][$index];
160
-            $this->mediaType    = $_FILES[$media_name]['type'][$index];
161
-            $this->mediaSize    = $_FILES[$media_name]['size'][$index];
162
-            $this->mediaTmpName = $_FILES[$media_name]['tmp_name'][$index];
163
-            $this->mediaError   = !empty($_FILES[$media_name]['error'][$index]) ? $_FILES[$media_name]['errir'][$index] : 0;
164
-        } else {
165
-            $media_name         =& $_FILES[$media_name];
166
-            $this->mediaName    = get_magic_quotes_gpc() ? stripslashes($media_name['name']) : $media_name['name'];
167
-            $this->mediaName    = $media_name['name'];
168
-            $this->mediaType    = $media_name['type'];
169
-            $this->mediaSize    = $media_name['size'];
170
-            $this->mediaTmpName = $media_name['tmp_name'];
171
-            $this->mediaError   = !empty($media_name['error']) ? $media_name['error'] : 0;
172
-        }
173
-        if (($ext = strrpos($this->mediaName, '.')) !== false) {
174
-            $ext = substr($this->mediaName, $ext + 1);
175
-            if (isset($this->extensionToMime[$ext])) {
176
-                $this->mediaRealType = $this->extensionToMime[$ext];
177
-                //trigger_error( "XoopsMediaUploader: Set mediaRealType to {$this->mediaRealType} (file extension is $ext)", E_USER_NOTICE );
178
-            }
179
-        }
180
-        $this->errors = array();
181
-        if ($ext && in_array($ext, array('gif', 'jpg', 'jpeg', 'png', 'bmp', 'xbm'))) {
182
-            // Prevent sending of invalid images that would crash IE
183
-            if (!($info = getimagesize($this->mediaTmpName))) {
184
-                $this->setErrors('Invalid file content');
185
-
186
-                return false;
187
-            }
188
-        }
189
-        if ((int)$this->mediaSize < 0) {
190
-            $this->setErrors('Invalid File Size');
191
-
192
-            return false;
193
-        }
194
-        if ($this->mediaName === '') {
195
-            $this->setErrors('Filename Is Empty');
196
-
197
-            return false;
198
-        }
199
-        if ($this->mediaTmpName === 'none' || !is_uploaded_file($this->mediaTmpName)) {
200
-            $this->setErrors('No file uploaded');
201
-
202
-            return false;
203
-        }
204
-        if ($this->mediaError > 0) {
205
-            $this->setErrors('Error occurred: Error #' . $this->mediaError);
206
-
207
-            return false;
208
-        }
209
-
210
-        return true;
211
-    }
212
-
213
-    /**
214
-     * Set the target filename
215
-     *
216
-     * @param   string $value
217
-     **/
218
-    public function setTargetFileName($value)
219
-    {
220
-        $this->targetFileName = (string)trim($value);
221
-    }
222
-
223
-    /**
224
-     * Set the prefix
225
-     *
226
-     * @param   string $value
227
-     **/
228
-    public function setPrefix($value)
229
-    {
230
-        $this->prefix = (string)trim($value);
231
-    }
232
-
233
-    /**
234
-     * Get the uploaded filename
235
-     *
236
-     * @return  string
237
-     **/
238
-    public function getMediaName()
239
-    {
240
-        return $this->mediaName;
241
-    }
242
-
243
-    /**
244
-     * Get the type of the uploaded file
245
-     *
246
-     * @return  string
247
-     **/
248
-    public function getMediaType()
249
-    {
250
-        return $this->mediaType;
251
-    }
252
-
253
-    /**
254
-     * Get the size of the uploaded file
255
-     *
256
-     * @return  int
257
-     **/
258
-    public function getMediaSize()
259
-    {
260
-        return $this->mediaSize;
261
-    }
262
-
263
-    /**
264
-     * Get the temporary name that the uploaded file was stored under
265
-     *
266
-     * @return  string
267
-     **/
268
-    public function getMediaTmpName()
269
-    {
270
-        return $this->mediaTmpName;
271
-    }
272
-
273
-    /**
274
-     * Get the saved filename
275
-     *
276
-     * @return  string
277
-     **/
278
-    public function getSavedFileName()
279
-    {
280
-        return $this->savedFileName;
281
-    }
282
-
283
-    /**
284
-     * Get the destination the file is saved to
285
-     *
286
-     * @return  string
287
-     **/
288
-    public function getSavedDestination()
289
-    {
290
-        return $this->savedDestination;
291
-    }
292
-
293
-    /**
294
-     * Check the file and copy it to the destination
295
-     *
296
-     * @param int $chmod
297
-     * @return bool
298
-     */
299
-    public function upload($chmod = 0644)
300
-    {
301
-        if ($this->uploadDir === '') {
302
-            $this->setErrors('Upload directory not set');
303
-
304
-            return false;
305
-        }
306
-        if (!is_dir($this->uploadDir)) {
307
-            $this->setErrors('Failed opening directory: ' . $this->uploadDir);
308
-        }
309
-        if (!is_writable($this->uploadDir)) {
310
-            $this->setErrors('Failed opening directory with write permission: ' . $this->uploadDir);
311
-        }
312
-        if (!$this->checkMaxFileSize()) {
313
-            $this->setErrors('File size too large: ' . $this->mediaSize);
314
-        }
315
-        if (!$this->checkMaxWidth()) {
316
-            $this->setErrors(sprintf('File width must be smaller than %u', $this->maxWidth));
317
-        }
318
-        if (!$this->checkMaxHeight()) {
319
-            $this->setErrors(sprintf('File height must be smaller than %u', $this->maxHeight));
320
-        }
321
-        if (!$this->checkMimeType()) {
322
-            $this->setErrors('MIME type not allowed: ' . $this->mediaType);
323
-        }
324
-        if (count($this->errors) > 0) {
325
-            return false;
326
-        }
327
-        if (!$this->_copyFile($chmod)) {
328
-            $this->setErrors('Failed uploading file: ' . $this->mediaName);
329
-
330
-            return false;
331
-        }
332
-
333
-        return true;
334
-    }
335
-
336
-    /**
337
-     * Copy the file to its destination
338
-     *
339
-     * @param $chmod
340
-     * @return bool
341
-     */
342
-    public function _copyFile($chmod)
343
-    {
344
-        $matched = array();
345
-        if (!preg_match("/\.([a-zA-Z0-9]+)$/", $this->mediaName, $matched)) {
346
-            return false;
347
-        }
348
-        if (isset($this->targetFileName)) {
349
-            $this->savedFileName = $this->targetFileName;
350
-        } elseif (isset($this->prefix)) {
351
-            $this->savedFileName = uniqid($this->prefix, true) . '.' . strtolower($matched[1]);
352
-        } else {
353
-            $this->savedFileName = strtolower($this->mediaName);
354
-        }
355
-        $this->savedDestination = $this->uploadDir . '/' . $this->savedFileName;
356
-        if (!move_uploaded_file($this->mediaTmpName, $this->savedDestination)) {
357
-            return false;
358
-        }
359
-        @chmod($this->savedDestination, $chmod);
360
-
361
-        return true;
362
-    }
363
-
364
-    /**
365
-     * Is the file the right size?
366
-     *
367
-     * @return  bool
368
-     **/
369
-    public function checkMaxFileSize()
370
-    {
371
-        if ($this->mediaSize > $this->maxFileSize) {
372
-            return false;
373
-        }
374
-
375
-        return true;
376
-    }
377
-
378
-    /**
379
-     * Is the picture the right width?
380
-     *
381
-     * @return  bool
382
-     **/
383
-    public function checkMaxWidth()
384
-    {
385
-        if (!isset($this->maxWidth)) {
386
-            return true;
387
-        }
388
-        if (false !== $dimension = getimagesize($this->mediaTmpName)) {
389
-            if ($dimension[0] > $this->maxWidth) {
390
-                return false;
391
-            }
392
-            //$result = $dimension[0];
393
-            //$this->width = $result;
394
-        } else {
395
-            trigger_error(sprintf('Failed fetching image size of %s, skipping max width check..', $this->mediaTmpName), E_USER_WARNING);
396
-        }
397
-
398
-        return true;
399
-    }
400
-
401
-    /**
402
-     * @return mixed
403
-     */
404
-    public function getWidth()
405
-    {
406
-        //$filename = $imgloc."/";
407
-        $filename = $this->uploadDir . '/';
408
-        $filename .= $this->savedFileName;
409
-        if (false !== $dimension = getimagesize($filename)) {
410
-            if ($dimension[0] > 0) {
411
-                $result = $dimension[0];
412
-            }
413
-        } else {
414
-            trigger_error(sprintf('Failed fetching image size of %s, image width unknown..', $this->mediaTmpName), E_USER_WARNING);
415
-        }
416
-
417
-        return $result;
418
-    }
419
-
420
-    /**
421
-     * @return mixed
422
-     */
423
-    public function getHeight()
424
-    {
425
-        //$filename = $imgloc."/";
426
-        $filename = $this->uploadDir . '/';
427
-        $filename .= $this->savedFileName;
428
-        if (false !== $dimension = getimagesize($filename)) {
429
-            if ($dimension[1] > 0) {
430
-                $result = $dimension[1];
431
-            }
432
-        } else {
433
-            trigger_error(sprintf('Failed fetching image size of %s, image height unknown..', $this->mediaTmpName), E_USER_WARNING);
434
-        }
435
-
436
-        return $result;
437
-    }
438
-
439
-    /**
440
-     * Is the picture the right height?
441
-     *
442
-     * @return  bool
443
-     **/
444
-    public function checkMaxHeight()
445
-    {
446
-        if (!isset($this->maxHeight)) {
447
-            return true;
448
-        }
449
-        if (false !== $dimension = getimagesize($this->mediaTmpName)) {
450
-            if ($dimension[1] > $this->maxHeight) {
451
-                return false;
452
-            }
453
-        } else {
454
-            trigger_error(sprintf('Failed fetching image size of %s, skipping max height check..', $this->mediaTmpName), E_USER_WARNING);
455
-        }
456
-
457
-        return true;
458
-    }
459
-
460
-    /**
461
-     * Check whether or not the uploaded file type is allowed
462
-     *
463
-     * @return  bool
464
-     **/
465
-    public function checkMimeType()
466
-    {
467
-        if (empty($this->mediaRealType) && !$this->allowUnknownTypes) {
468
-            $this->setErrors('Unknown filetype rejected');
469
-
470
-            return false;
471
-        }
472
-
473
-        return (empty($this->allowedMimeTypes) || in_array($this->mediaRealType, $this->allowedMimeTypes));
474
-    }
475
-
476
-    /**
477
-     * Add an error
478
-     *
479
-     * @param   string $error
480
-     **/
481
-    public function setErrors($error)
482
-    {
483
-        $this->errors[] = trim($error);
484
-    }
485
-
486
-    /**
487
-     * Get generated errors
488
-     *
489
-     * @param    bool $ashtml Format using HTML?
490
-     *
491
-     * @return    array|string    Array of array messages OR HTML string
492
-     */
493
-    public function &getErrors($ashtml = true)
494
-    {
495
-        if (!$ashtml) {
496
-            return $this->errors;
497
-        } else {
498
-            $ret = '';
499
-            if (count($this->errors) > 0) {
500
-                $ret = '<h4>Errors Returned While Uploading</h4>';
501
-                foreach ($this->errors as $error) {
502
-                    $ret .= $error . '<br>';
503
-                }
504
-            }
505
-
506
-            return $ret;
507
-        }
508
-    }
75
+	/**
76
+	 * Flag indicating if unrecognized mimetypes should be allowed (use with precaution ! may lead to security issues )
77
+	 **/
78
+	public $allowUnknownTypes = false;
79
+
80
+	public $mediaName;
81
+	public $mediaType;
82
+	public $mediaSize;
83
+	public $mediaTmpName;
84
+	public $mediaError;
85
+	public $mediaRealType = '';
86
+
87
+	public $uploadDir = '';
88
+
89
+	public $allowedMimeTypes = array();
90
+
91
+	public $maxFileSize = 0;
92
+	public $maxWidth;
93
+	public $maxHeight;
94
+
95
+	public $targetFileName;
96
+
97
+	public $prefix;
98
+
99
+	public $errors = array();
100
+
101
+	public $savedDestination;
102
+
103
+	public $savedFileName;
104
+
105
+	public $extensionToMime = array();
106
+
107
+	/**
108
+	 * Constructor
109
+	 *
110
+	 * @param   string $uploadDir
111
+	 * @param   array  $allowedMimeTypes
112
+	 * @param   int    $maxFileSize
113
+	 * @param   int    $maxWidth
114
+	 * @param   int    $maxHeight
115
+	 * @internal param int $cmodvalue
116
+	 */
117
+	public function __construct($uploadDir, $allowedMimeTypes, $maxFileSize = 0, $maxWidth = null, $maxHeight = null)
118
+	{
119
+		@$this->extensionToMime = include XOOPS_ROOT_PATH . '/class/mimetypes.inc.php';
120
+		if (!is_array($this->extensionToMime)) {
121
+			$this->extensionToMime = array();
122
+
123
+			return false;
124
+		}
125
+		if (is_array($allowedMimeTypes)) {
126
+			$this->allowedMimeTypes =& $allowedMimeTypes;
127
+		}
128
+		$this->uploadDir   = $uploadDir;
129
+		$this->maxFileSize = (int)$maxFileSize;
130
+		if (isset($maxWidth)) {
131
+			$this->maxWidth = (int)$maxWidth;
132
+		}
133
+		if (isset($maxHeight)) {
134
+			$this->maxHeight = (int)$maxHeight;
135
+		}
136
+	}
137
+
138
+	/**
139
+	 * Fetch the uploaded file
140
+	 *
141
+	 * @param   string $media_name Name of the file field
142
+	 * @param   int    $index      Index of the file (if more than one uploaded under that name)
143
+	 * @return  bool
144
+	 **/
145
+	public function fetchMedia($media_name, $index = null)
146
+	{
147
+		if (empty($this->extensionToMime)) {
148
+			$this->setErrors('Error loading mimetypes definition');
149
+
150
+			return false;
151
+		}
152
+		if (!isset($_FILES[$media_name])) {
153
+			$this->setErrors('File not found');
154
+
155
+			//echo " - no such file ";
156
+			return false;
157
+		} elseif (is_array($_FILES[$media_name]['name']) && isset($index)) {
158
+			$index              = (int)$index;
159
+			$this->mediaName    = get_magic_quotes_gpc() ? stripslashes($_FILES[$media_name]['name'][$index]) : $_FILES[$media_name]['name'][$index];
160
+			$this->mediaType    = $_FILES[$media_name]['type'][$index];
161
+			$this->mediaSize    = $_FILES[$media_name]['size'][$index];
162
+			$this->mediaTmpName = $_FILES[$media_name]['tmp_name'][$index];
163
+			$this->mediaError   = !empty($_FILES[$media_name]['error'][$index]) ? $_FILES[$media_name]['errir'][$index] : 0;
164
+		} else {
165
+			$media_name         =& $_FILES[$media_name];
166
+			$this->mediaName    = get_magic_quotes_gpc() ? stripslashes($media_name['name']) : $media_name['name'];
167
+			$this->mediaName    = $media_name['name'];
168
+			$this->mediaType    = $media_name['type'];
169
+			$this->mediaSize    = $media_name['size'];
170
+			$this->mediaTmpName = $media_name['tmp_name'];
171
+			$this->mediaError   = !empty($media_name['error']) ? $media_name['error'] : 0;
172
+		}
173
+		if (($ext = strrpos($this->mediaName, '.')) !== false) {
174
+			$ext = substr($this->mediaName, $ext + 1);
175
+			if (isset($this->extensionToMime[$ext])) {
176
+				$this->mediaRealType = $this->extensionToMime[$ext];
177
+				//trigger_error( "XoopsMediaUploader: Set mediaRealType to {$this->mediaRealType} (file extension is $ext)", E_USER_NOTICE );
178
+			}
179
+		}
180
+		$this->errors = array();
181
+		if ($ext && in_array($ext, array('gif', 'jpg', 'jpeg', 'png', 'bmp', 'xbm'))) {
182
+			// Prevent sending of invalid images that would crash IE
183
+			if (!($info = getimagesize($this->mediaTmpName))) {
184
+				$this->setErrors('Invalid file content');
185
+
186
+				return false;
187
+			}
188
+		}
189
+		if ((int)$this->mediaSize < 0) {
190
+			$this->setErrors('Invalid File Size');
191
+
192
+			return false;
193
+		}
194
+		if ($this->mediaName === '') {
195
+			$this->setErrors('Filename Is Empty');
196
+
197
+			return false;
198
+		}
199
+		if ($this->mediaTmpName === 'none' || !is_uploaded_file($this->mediaTmpName)) {
200
+			$this->setErrors('No file uploaded');
201
+
202
+			return false;
203
+		}
204
+		if ($this->mediaError > 0) {
205
+			$this->setErrors('Error occurred: Error #' . $this->mediaError);
206
+
207
+			return false;
208
+		}
209
+
210
+		return true;
211
+	}
212
+
213
+	/**
214
+	 * Set the target filename
215
+	 *
216
+	 * @param   string $value
217
+	 **/
218
+	public function setTargetFileName($value)
219
+	{
220
+		$this->targetFileName = (string)trim($value);
221
+	}
222
+
223
+	/**
224
+	 * Set the prefix
225
+	 *
226
+	 * @param   string $value
227
+	 **/
228
+	public function setPrefix($value)
229
+	{
230
+		$this->prefix = (string)trim($value);
231
+	}
232
+
233
+	/**
234
+	 * Get the uploaded filename
235
+	 *
236
+	 * @return  string
237
+	 **/
238
+	public function getMediaName()
239
+	{
240
+		return $this->mediaName;
241
+	}
242
+
243
+	/**
244
+	 * Get the type of the uploaded file
245
+	 *
246
+	 * @return  string
247
+	 **/
248
+	public function getMediaType()
249
+	{
250
+		return $this->mediaType;
251
+	}
252
+
253
+	/**
254
+	 * Get the size of the uploaded file
255
+	 *
256
+	 * @return  int
257
+	 **/
258
+	public function getMediaSize()
259
+	{
260
+		return $this->mediaSize;
261
+	}
262
+
263
+	/**
264
+	 * Get the temporary name that the uploaded file was stored under
265
+	 *
266
+	 * @return  string
267
+	 **/
268
+	public function getMediaTmpName()
269
+	{
270
+		return $this->mediaTmpName;
271
+	}
272
+
273
+	/**
274
+	 * Get the saved filename
275
+	 *
276
+	 * @return  string
277
+	 **/
278
+	public function getSavedFileName()
279
+	{
280
+		return $this->savedFileName;
281
+	}
282
+
283
+	/**
284
+	 * Get the destination the file is saved to
285
+	 *
286
+	 * @return  string
287
+	 **/
288
+	public function getSavedDestination()
289
+	{
290
+		return $this->savedDestination;
291
+	}
292
+
293
+	/**
294
+	 * Check the file and copy it to the destination
295
+	 *
296
+	 * @param int $chmod
297
+	 * @return bool
298
+	 */
299
+	public function upload($chmod = 0644)
300
+	{
301
+		if ($this->uploadDir === '') {
302
+			$this->setErrors('Upload directory not set');
303
+
304
+			return false;
305
+		}
306
+		if (!is_dir($this->uploadDir)) {
307
+			$this->setErrors('Failed opening directory: ' . $this->uploadDir);
308
+		}
309
+		if (!is_writable($this->uploadDir)) {
310
+			$this->setErrors('Failed opening directory with write permission: ' . $this->uploadDir);
311
+		}
312
+		if (!$this->checkMaxFileSize()) {
313
+			$this->setErrors('File size too large: ' . $this->mediaSize);
314
+		}
315
+		if (!$this->checkMaxWidth()) {
316
+			$this->setErrors(sprintf('File width must be smaller than %u', $this->maxWidth));
317
+		}
318
+		if (!$this->checkMaxHeight()) {
319
+			$this->setErrors(sprintf('File height must be smaller than %u', $this->maxHeight));
320
+		}
321
+		if (!$this->checkMimeType()) {
322
+			$this->setErrors('MIME type not allowed: ' . $this->mediaType);
323
+		}
324
+		if (count($this->errors) > 0) {
325
+			return false;
326
+		}
327
+		if (!$this->_copyFile($chmod)) {
328
+			$this->setErrors('Failed uploading file: ' . $this->mediaName);
329
+
330
+			return false;
331
+		}
332
+
333
+		return true;
334
+	}
335
+
336
+	/**
337
+	 * Copy the file to its destination
338
+	 *
339
+	 * @param $chmod
340
+	 * @return bool
341
+	 */
342
+	public function _copyFile($chmod)
343
+	{
344
+		$matched = array();
345
+		if (!preg_match("/\.([a-zA-Z0-9]+)$/", $this->mediaName, $matched)) {
346
+			return false;
347
+		}
348
+		if (isset($this->targetFileName)) {
349
+			$this->savedFileName = $this->targetFileName;
350
+		} elseif (isset($this->prefix)) {
351
+			$this->savedFileName = uniqid($this->prefix, true) . '.' . strtolower($matched[1]);
352
+		} else {
353
+			$this->savedFileName = strtolower($this->mediaName);
354
+		}
355
+		$this->savedDestination = $this->uploadDir . '/' . $this->savedFileName;
356
+		if (!move_uploaded_file($this->mediaTmpName, $this->savedDestination)) {
357
+			return false;
358
+		}
359
+		@chmod($this->savedDestination, $chmod);
360
+
361
+		return true;
362
+	}
363
+
364
+	/**
365
+	 * Is the file the right size?
366
+	 *
367
+	 * @return  bool
368
+	 **/
369
+	public function checkMaxFileSize()
370
+	{
371
+		if ($this->mediaSize > $this->maxFileSize) {
372
+			return false;
373
+		}
374
+
375
+		return true;
376
+	}
377
+
378
+	/**
379
+	 * Is the picture the right width?
380
+	 *
381
+	 * @return  bool
382
+	 **/
383
+	public function checkMaxWidth()
384
+	{
385
+		if (!isset($this->maxWidth)) {
386
+			return true;
387
+		}
388
+		if (false !== $dimension = getimagesize($this->mediaTmpName)) {
389
+			if ($dimension[0] > $this->maxWidth) {
390
+				return false;
391
+			}
392
+			//$result = $dimension[0];
393
+			//$this->width = $result;
394
+		} else {
395
+			trigger_error(sprintf('Failed fetching image size of %s, skipping max width check..', $this->mediaTmpName), E_USER_WARNING);
396
+		}
397
+
398
+		return true;
399
+	}
400
+
401
+	/**
402
+	 * @return mixed
403
+	 */
404
+	public function getWidth()
405
+	{
406
+		//$filename = $imgloc."/";
407
+		$filename = $this->uploadDir . '/';
408
+		$filename .= $this->savedFileName;
409
+		if (false !== $dimension = getimagesize($filename)) {
410
+			if ($dimension[0] > 0) {
411
+				$result = $dimension[0];
412
+			}
413
+		} else {
414
+			trigger_error(sprintf('Failed fetching image size of %s, image width unknown..', $this->mediaTmpName), E_USER_WARNING);
415
+		}
416
+
417
+		return $result;
418
+	}
419
+
420
+	/**
421
+	 * @return mixed
422
+	 */
423
+	public function getHeight()
424
+	{
425
+		//$filename = $imgloc."/";
426
+		$filename = $this->uploadDir . '/';
427
+		$filename .= $this->savedFileName;
428
+		if (false !== $dimension = getimagesize($filename)) {
429
+			if ($dimension[1] > 0) {
430
+				$result = $dimension[1];
431
+			}
432
+		} else {
433
+			trigger_error(sprintf('Failed fetching image size of %s, image height unknown..', $this->mediaTmpName), E_USER_WARNING);
434
+		}
435
+
436
+		return $result;
437
+	}
438
+
439
+	/**
440
+	 * Is the picture the right height?
441
+	 *
442
+	 * @return  bool
443
+	 **/
444
+	public function checkMaxHeight()
445
+	{
446
+		if (!isset($this->maxHeight)) {
447
+			return true;
448
+		}
449
+		if (false !== $dimension = getimagesize($this->mediaTmpName)) {
450
+			if ($dimension[1] > $this->maxHeight) {
451
+				return false;
452
+			}
453
+		} else {
454
+			trigger_error(sprintf('Failed fetching image size of %s, skipping max height check..', $this->mediaTmpName), E_USER_WARNING);
455
+		}
456
+
457
+		return true;
458
+	}
459
+
460
+	/**
461
+	 * Check whether or not the uploaded file type is allowed
462
+	 *
463
+	 * @return  bool
464
+	 **/
465
+	public function checkMimeType()
466
+	{
467
+		if (empty($this->mediaRealType) && !$this->allowUnknownTypes) {
468
+			$this->setErrors('Unknown filetype rejected');
469
+
470
+			return false;
471
+		}
472
+
473
+		return (empty($this->allowedMimeTypes) || in_array($this->mediaRealType, $this->allowedMimeTypes));
474
+	}
475
+
476
+	/**
477
+	 * Add an error
478
+	 *
479
+	 * @param   string $error
480
+	 **/
481
+	public function setErrors($error)
482
+	{
483
+		$this->errors[] = trim($error);
484
+	}
485
+
486
+	/**
487
+	 * Get generated errors
488
+	 *
489
+	 * @param    bool $ashtml Format using HTML?
490
+	 *
491
+	 * @return    array|string    Array of array messages OR HTML string
492
+	 */
493
+	public function &getErrors($ashtml = true)
494
+	{
495
+		if (!$ashtml) {
496
+			return $this->errors;
497
+		} else {
498
+			$ret = '';
499
+			if (count($this->errors) > 0) {
500
+				$ret = '<h4>Errors Returned While Uploading</h4>';
501
+				foreach ($this->errors as $error) {
502
+					$ret .= $error . '<br>';
503
+				}
504
+			}
505
+
506
+			return $ret;
507
+		}
508
+	}
509 509
 }
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -116,22 +116,22 @@  discard block
 block discarded – undo
116 116
      */
117 117
     public function __construct($uploadDir, $allowedMimeTypes, $maxFileSize = 0, $maxWidth = null, $maxHeight = null)
118 118
     {
119
-        @$this->extensionToMime = include XOOPS_ROOT_PATH . '/class/mimetypes.inc.php';
119
+        @$this->extensionToMime = include XOOPS_ROOT_PATH.'/class/mimetypes.inc.php';
120 120
         if (!is_array($this->extensionToMime)) {
121 121
             $this->extensionToMime = array();
122 122
 
123 123
             return false;
124 124
         }
125 125
         if (is_array($allowedMimeTypes)) {
126
-            $this->allowedMimeTypes =& $allowedMimeTypes;
126
+            $this->allowedMimeTypes = & $allowedMimeTypes;
127 127
         }
128 128
         $this->uploadDir   = $uploadDir;
129
-        $this->maxFileSize = (int)$maxFileSize;
129
+        $this->maxFileSize = (int) $maxFileSize;
130 130
         if (isset($maxWidth)) {
131
-            $this->maxWidth = (int)$maxWidth;
131
+            $this->maxWidth = (int) $maxWidth;
132 132
         }
133 133
         if (isset($maxHeight)) {
134
-            $this->maxHeight = (int)$maxHeight;
134
+            $this->maxHeight = (int) $maxHeight;
135 135
         }
136 136
     }
137 137
 
@@ -155,14 +155,14 @@  discard block
 block discarded – undo
155 155
             //echo " - no such file ";
156 156
             return false;
157 157
         } elseif (is_array($_FILES[$media_name]['name']) && isset($index)) {
158
-            $index              = (int)$index;
158
+            $index              = (int) $index;
159 159
             $this->mediaName    = get_magic_quotes_gpc() ? stripslashes($_FILES[$media_name]['name'][$index]) : $_FILES[$media_name]['name'][$index];
160 160
             $this->mediaType    = $_FILES[$media_name]['type'][$index];
161 161
             $this->mediaSize    = $_FILES[$media_name]['size'][$index];
162 162
             $this->mediaTmpName = $_FILES[$media_name]['tmp_name'][$index];
163 163
             $this->mediaError   = !empty($_FILES[$media_name]['error'][$index]) ? $_FILES[$media_name]['errir'][$index] : 0;
164 164
         } else {
165
-            $media_name         =& $_FILES[$media_name];
165
+            $media_name         = & $_FILES[$media_name];
166 166
             $this->mediaName    = get_magic_quotes_gpc() ? stripslashes($media_name['name']) : $media_name['name'];
167 167
             $this->mediaName    = $media_name['name'];
168 168
             $this->mediaType    = $media_name['type'];
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
                 return false;
187 187
             }
188 188
         }
189
-        if ((int)$this->mediaSize < 0) {
189
+        if ((int) $this->mediaSize < 0) {
190 190
             $this->setErrors('Invalid File Size');
191 191
 
192 192
             return false;
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
             return false;
203 203
         }
204 204
         if ($this->mediaError > 0) {
205
-            $this->setErrors('Error occurred: Error #' . $this->mediaError);
205
+            $this->setErrors('Error occurred: Error #'.$this->mediaError);
206 206
 
207 207
             return false;
208 208
         }
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
      **/
218 218
     public function setTargetFileName($value)
219 219
     {
220
-        $this->targetFileName = (string)trim($value);
220
+        $this->targetFileName = (string) trim($value);
221 221
     }
222 222
 
223 223
     /**
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
      **/
228 228
     public function setPrefix($value)
229 229
     {
230
-        $this->prefix = (string)trim($value);
230
+        $this->prefix = (string) trim($value);
231 231
     }
232 232
 
233 233
     /**
@@ -304,13 +304,13 @@  discard block
 block discarded – undo
304 304
             return false;
305 305
         }
306 306
         if (!is_dir($this->uploadDir)) {
307
-            $this->setErrors('Failed opening directory: ' . $this->uploadDir);
307
+            $this->setErrors('Failed opening directory: '.$this->uploadDir);
308 308
         }
309 309
         if (!is_writable($this->uploadDir)) {
310
-            $this->setErrors('Failed opening directory with write permission: ' . $this->uploadDir);
310
+            $this->setErrors('Failed opening directory with write permission: '.$this->uploadDir);
311 311
         }
312 312
         if (!$this->checkMaxFileSize()) {
313
-            $this->setErrors('File size too large: ' . $this->mediaSize);
313
+            $this->setErrors('File size too large: '.$this->mediaSize);
314 314
         }
315 315
         if (!$this->checkMaxWidth()) {
316 316
             $this->setErrors(sprintf('File width must be smaller than %u', $this->maxWidth));
@@ -319,13 +319,13 @@  discard block
 block discarded – undo
319 319
             $this->setErrors(sprintf('File height must be smaller than %u', $this->maxHeight));
320 320
         }
321 321
         if (!$this->checkMimeType()) {
322
-            $this->setErrors('MIME type not allowed: ' . $this->mediaType);
322
+            $this->setErrors('MIME type not allowed: '.$this->mediaType);
323 323
         }
324 324
         if (count($this->errors) > 0) {
325 325
             return false;
326 326
         }
327 327
         if (!$this->_copyFile($chmod)) {
328
-            $this->setErrors('Failed uploading file: ' . $this->mediaName);
328
+            $this->setErrors('Failed uploading file: '.$this->mediaName);
329 329
 
330 330
             return false;
331 331
         }
@@ -348,11 +348,11 @@  discard block
 block discarded – undo
348 348
         if (isset($this->targetFileName)) {
349 349
             $this->savedFileName = $this->targetFileName;
350 350
         } elseif (isset($this->prefix)) {
351
-            $this->savedFileName = uniqid($this->prefix, true) . '.' . strtolower($matched[1]);
351
+            $this->savedFileName = uniqid($this->prefix, true).'.'.strtolower($matched[1]);
352 352
         } else {
353 353
             $this->savedFileName = strtolower($this->mediaName);
354 354
         }
355
-        $this->savedDestination = $this->uploadDir . '/' . $this->savedFileName;
355
+        $this->savedDestination = $this->uploadDir.'/'.$this->savedFileName;
356 356
         if (!move_uploaded_file($this->mediaTmpName, $this->savedDestination)) {
357 357
             return false;
358 358
         }
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
     public function getWidth()
405 405
     {
406 406
         //$filename = $imgloc."/";
407
-        $filename = $this->uploadDir . '/';
407
+        $filename = $this->uploadDir.'/';
408 408
         $filename .= $this->savedFileName;
409 409
         if (false !== $dimension = getimagesize($filename)) {
410 410
             if ($dimension[0] > 0) {
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
     public function getHeight()
424 424
     {
425 425
         //$filename = $imgloc."/";
426
-        $filename = $this->uploadDir . '/';
426
+        $filename = $this->uploadDir.'/';
427 427
         $filename .= $this->savedFileName;
428 428
         if (false !== $dimension = getimagesize($filename)) {
429 429
             if ($dimension[1] > 0) {
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
             if (count($this->errors) > 0) {
500 500
                 $ret = '<h4>Errors Returned While Uploading</h4>';
501 501
                 foreach ($this->errors as $error) {
502
-                    $ret .= $error . '<br>';
502
+                    $ret .= $error.'<br>';
503 503
                 }
504 504
             }
505 505
 
Please login to merge, or discard this patch.
class/class.formradio.php 2 patches
Indentation   +130 added lines, -130 removed lines patch added patch discarded remove patch
@@ -39,146 +39,146 @@
 block discarded – undo
39 39
  */
40 40
 class efqFormRadio extends XoopsFormElement
41 41
 {
42
-    /**
43
-     * Array of Options
44
-     * @var array
45
-     * @access private
46
-     */
47
-    public $_options = array();
42
+	/**
43
+	 * Array of Options
44
+	 * @var array
45
+	 * @access private
46
+	 */
47
+	public $_options = array();
48 48
 
49
-    /**
50
-     * Pre-selected value
51
-     * @var string
52
-     * @access private
53
-     */
54
-    public $_value;
49
+	/**
50
+	 * Pre-selected value
51
+	 * @var string
52
+	 * @access private
53
+	 */
54
+	public $_value;
55 55
 
56
-    /**
57
-     * Pre-selected value
58
-     * @var string
59
-     * @access private
60
-     */
61
-    public $_linebreak;
56
+	/**
57
+	 * Pre-selected value
58
+	 * @var string
59
+	 * @access private
60
+	 */
61
+	public $_linebreak;
62 62
 
63
-    /**
64
-     * Constructor
65
-     *
66
-     * @param string $caption Caption
67
-     * @param string $name    "name" attribute
68
-     * @param string $value   Pre-selected value
69
-     * @param null   $linebreak
70
-     */
71
-    public function __construct($caption, $name, $value = null, $linebreak = null)
72
-    {
73
-        $this->setCaption($caption);
74
-        $this->setName($name);
75
-        if (isset($value)) {
76
-            $this->setValue($value);
77
-        }
78
-        if (isset($linebreak)) {
79
-            $this->setLineBreak($linebreak);
80
-        } else {
81
-            $this->setLineBreak('');
82
-        }
83
-    }
63
+	/**
64
+	 * Constructor
65
+	 *
66
+	 * @param string $caption Caption
67
+	 * @param string $name    "name" attribute
68
+	 * @param string $value   Pre-selected value
69
+	 * @param null   $linebreak
70
+	 */
71
+	public function __construct($caption, $name, $value = null, $linebreak = null)
72
+	{
73
+		$this->setCaption($caption);
74
+		$this->setName($name);
75
+		if (isset($value)) {
76
+			$this->setValue($value);
77
+		}
78
+		if (isset($linebreak)) {
79
+			$this->setLineBreak($linebreak);
80
+		} else {
81
+			$this->setLineBreak('');
82
+		}
83
+	}
84 84
 
85
-    /**
86
-     * Get the pre-selected value
87
-     *
88
-     * @return string
89
-     */
90
-    public function getValue()
91
-    {
92
-        return $this->_value;
93
-    }
85
+	/**
86
+	 * Get the pre-selected value
87
+	 *
88
+	 * @return string
89
+	 */
90
+	public function getValue()
91
+	{
92
+		return $this->_value;
93
+	}
94 94
 
95
-    /**
96
-     * Get the pre-selected value
97
-     *
98
-     * @return string
99
-     */
100
-    public function getLineBreak()
101
-    {
102
-        return $this->_linebreak;
103
-    }
95
+	/**
96
+	 * Get the pre-selected value
97
+	 *
98
+	 * @return string
99
+	 */
100
+	public function getLineBreak()
101
+	{
102
+		return $this->_linebreak;
103
+	}
104 104
 
105
-    /**
106
-     * Set the pre-selected value
107
-     *
108
-     * @param $value string
109
-     */
110
-    public function setValue($value)
111
-    {
112
-        $this->_value = $value;
113
-    }
105
+	/**
106
+	 * Set the pre-selected value
107
+	 *
108
+	 * @param $value string
109
+	 */
110
+	public function setValue($value)
111
+	{
112
+		$this->_value = $value;
113
+	}
114 114
 
115
-    /**
116
-     * Set the pre-selected value
117
-     *
118
-     * @param $linebreak
119
-     * @internal param string $value
120
-     */
121
-    public function setLineBreak($linebreak)
122
-    {
123
-        $this->_linebreak = $linebreak;
124
-    }
115
+	/**
116
+	 * Set the pre-selected value
117
+	 *
118
+	 * @param $linebreak
119
+	 * @internal param string $value
120
+	 */
121
+	public function setLineBreak($linebreak)
122
+	{
123
+		$this->_linebreak = $linebreak;
124
+	}
125 125
 
126
-    /**
127
-     * Add an option
128
-     *
129
-     * @param string $value "value" attribute - This gets submitted as form-data.
130
-     * @param string $name  "name" attribute - This is displayed. If empty, we use the "value" instead.
131
-     */
132
-    public function addOption($value, $name = '')
133
-    {
134
-        if ($name !== '') {
135
-            $this->_options[$value] = $name;
136
-        } else {
137
-            $this->_options[$value] = $value;
138
-        }
139
-    }
126
+	/**
127
+	 * Add an option
128
+	 *
129
+	 * @param string $value "value" attribute - This gets submitted as form-data.
130
+	 * @param string $name  "name" attribute - This is displayed. If empty, we use the "value" instead.
131
+	 */
132
+	public function addOption($value, $name = '')
133
+	{
134
+		if ($name !== '') {
135
+			$this->_options[$value] = $name;
136
+		} else {
137
+			$this->_options[$value] = $value;
138
+		}
139
+	}
140 140
 
141
-    /**
142
-     * Adds multiple options
143
-     *
144
-     * @param array $options Associative array of value->name pairs.
145
-     */
146
-    public function addOptionArray($options)
147
-    {
148
-        if (is_array($options)) {
149
-            foreach ($options as $k => $v) {
150
-                $this->addOption($k, $v);
151
-            }
152
-        }
153
-    }
141
+	/**
142
+	 * Adds multiple options
143
+	 *
144
+	 * @param array $options Associative array of value->name pairs.
145
+	 */
146
+	public function addOptionArray($options)
147
+	{
148
+		if (is_array($options)) {
149
+			foreach ($options as $k => $v) {
150
+				$this->addOption($k, $v);
151
+			}
152
+		}
153
+	}
154 154
 
155
-    /**
156
-     * Gets the options
157
-     *
158
-     * @return array Associative array of value->name pairs.
159
-     */
160
-    public function getOptions()
161
-    {
162
-        return $this->_options;
163
-    }
155
+	/**
156
+	 * Gets the options
157
+	 *
158
+	 * @return array Associative array of value->name pairs.
159
+	 */
160
+	public function getOptions()
161
+	{
162
+		return $this->_options;
163
+	}
164 164
 
165
-    /**
166
-     * Prepare HTML for output
167
-     *
168
-     * @return string HTML
169
-     */
170
-    public function render()
171
-    {
172
-        $ret = '';
173
-        foreach ($this->getOptions() as $value => $name) {
174
-            $ret      .= "<input type='radio' name='" . $this->getName() . '\' value=\'' . $value . '\'';
175
-            $selected = $this->getValue();
176
-            if (isset($selected) && ($value == $selected)) {
177
-                $ret .= ' checked';
178
-            }
179
-            $ret .= $this->getExtra() . '>' . $name . '' . $this->getLineBreak() . "\n";
180
-        }
165
+	/**
166
+	 * Prepare HTML for output
167
+	 *
168
+	 * @return string HTML
169
+	 */
170
+	public function render()
171
+	{
172
+		$ret = '';
173
+		foreach ($this->getOptions() as $value => $name) {
174
+			$ret      .= "<input type='radio' name='" . $this->getName() . '\' value=\'' . $value . '\'';
175
+			$selected = $this->getValue();
176
+			if (isset($selected) && ($value == $selected)) {
177
+				$ret .= ' checked';
178
+			}
179
+			$ret .= $this->getExtra() . '>' . $name . '' . $this->getLineBreak() . "\n";
180
+		}
181 181
 
182
-        return $ret;
183
-    }
182
+		return $ret;
183
+	}
184 184
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -171,12 +171,12 @@
 block discarded – undo
171 171
     {
172 172
         $ret = '';
173 173
         foreach ($this->getOptions() as $value => $name) {
174
-            $ret      .= "<input type='radio' name='" . $this->getName() . '\' value=\'' . $value . '\'';
174
+            $ret .= "<input type='radio' name='".$this->getName().'\' value=\''.$value.'\'';
175 175
             $selected = $this->getValue();
176 176
             if (isset($selected) && ($value == $selected)) {
177 177
                 $ret .= ' checked';
178 178
             }
179
-            $ret .= $this->getExtra() . '>' . $name . '' . $this->getLineBreak() . "\n";
179
+            $ret .= $this->getExtra().'>'.$name.''.$this->getLineBreak()."\n";
180 180
         }
181 181
 
182 182
         return $ret;
Please login to merge, or discard this patch.