|
1
|
|
|
<?php namespace XoopsModules\Smartobject\Form\Elements; |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Contains the SmartObjectControl class |
|
5
|
|
|
* |
|
6
|
|
|
* @license GNU |
|
7
|
|
|
* @author marcan <[email protected]> |
|
8
|
|
|
* @link http://smartfactory.ca The SmartFactory |
|
9
|
|
|
* @package SmartObject |
|
10
|
|
|
* @subpackage SmartObjectForm |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
use XoopsModules\Smartobject; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Class SmartFormUserElement |
|
17
|
|
|
* @package XoopsModules\Smartobject\Form\Elements |
|
18
|
|
|
*/ |
|
19
|
|
|
class SmartFormUserElement extends \XoopsFormSelect |
|
20
|
|
|
{ |
|
21
|
|
|
public $multiple = false; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* SmartFormUserElement constructor. |
|
25
|
|
|
* @param string $object |
|
26
|
|
|
* @param string $key |
|
27
|
|
|
*/ |
|
28
|
|
|
public function __construct($object, $key) |
|
29
|
|
|
{ |
|
30
|
|
|
$var = $object->vars[$key]; |
|
31
|
|
|
$size = isset($var['size']) ? $var['size'] : ($this->multiple ? 5 : 1); |
|
32
|
|
|
|
|
33
|
|
|
parent::__construct($var['form_caption'], $key, $object->getVar($key, 'e'), $size, $this->multiple); |
|
|
|
|
|
|
34
|
|
|
|
|
35
|
|
|
// Adding the options inside this SelectBox |
|
36
|
|
|
// If the custom method is not from a module, than it's from the core |
|
37
|
|
|
$control = $object->getControl($key); |
|
|
|
|
|
|
38
|
|
|
|
|
39
|
|
|
global $xoopsDB; |
|
40
|
|
|
$ret = []; |
|
|
|
|
|
|
41
|
|
|
$limit = $start = 0; |
|
|
|
|
|
|
42
|
|
|
$sql = 'SELECT uid, uname FROM ' . $xoopsDB->prefix('users'); |
|
43
|
|
|
$sql .= ' ORDER BY uname ASC'; |
|
44
|
|
|
|
|
45
|
|
|
$result = $xoopsDB->query($sql); |
|
46
|
|
|
if ($result) { |
|
47
|
|
|
while (false !== ($myrow = $xoopsDB->fetchArray($result))) { |
|
48
|
|
|
$uArray[$myrow['uid']] = $myrow['uname']; |
|
|
|
|
|
|
49
|
|
|
} |
|
50
|
|
|
} |
|
51
|
|
|
$this->addOptionArray($uArray); |
|
|
|
|
|
|
52
|
|
|
} |
|
53
|
|
|
} |
|
54
|
|
|
|
Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.