24 public function __construct($words)
26 $this->setKeywords($words);
29 public function setKeywords($words)
31 foreach (explode(
' ', $words) as $word) {
33 $this->mKeywords[] = $word;
38 public function getKeywords()
40 return $this->mKeywords;
43 public function addRecord($moduleName, $url, $title, $desc =
null)
48 public function &getRecords()
50 return $this->mRecords;
58 if(is_countable($this->mRecords)) {
59 return count($this->mRecords) > 0;
96 public $mModules = [];
97 public $mModuleRecords =
null;
98 public $mRecords =
null;
99 public $mActionForm =
null;
101 public $mSearchAction =
null;
103 public function __construct($flag)
105 parent::__construct($flag);
108 $this->mSearchAction->add([&$this,
'defaultSearch']);
109 $this->mSearchAction->register(
'Legacy_ActSearchAction.SearchAction');
112 public function prepare(&$controller, &$xoopsUser)
114 parent::prepare($controller, $xoopsUser);
116 $db=&$controller->getDB();
118 $mod = $db->prefix(
'modules');
119 $perm = $db->prefix(
'group_permission');
120 $groups = implode(
',', $xoopsUser->getGroups());
122 $sql =
"SELECT DISTINCT {$mod}.weight, {$mod}.mid FROM {$mod},{$perm} " .
123 "WHERE {$mod}.isactive=1 AND {$mod}.mid={$perm}.gperm_itemid AND {$perm}.gperm_name='module_admin' AND {$perm}.gperm_groupid IN ({$groups}) " .
124 "ORDER BY {$mod}.weight, {$mod}.mid";
126 $result=$db->query($sql);
128 $handler =& xoops_gethandler(
'module');
129 while ($row = $db->fetchArray($result)) {
130 $module =& $handler->get($row[
'mid']);
133 $this->mModules[] =& $adapter;
135 unset($module, $adapter);
139 public function hasPermission(&$controller, &$xoopsUser)
141 $permHandler =& xoops_gethandler(
'groupperm');
142 return $permHandler->checkRight(
'module_admin', -1, $xoopsUser->getGroups());
145 public function getDefaultView(&$controller, &$xoopsUser)
147 $this->_processActionForm();
149 $this->mActionForm->fetch();
150 $this->mActionForm->validate();
152 if ($this->mActionForm->hasError()) {
153 return LEGACY_FRAME_VIEW_INPUT;
157 $this->mSearchAction->call(
new XCube_Ref($searchArgs));
159 if ($searchArgs->hasRecord()) {
160 $this->mRecords =& $searchArgs->getRecords();
161 return LEGACY_FRAME_VIEW_SUCCESS;
164 return LEGACY_FRAME_VIEW_ERROR;
167 public function defaultSearch(&$searchArgs)
169 foreach (array_keys($this->mModules) as $key) {
170 $this->mModules[$key]->doActionSearch($searchArgs);
174 public function execute(&$controller, &$xoopsUser)
176 return $this->getDefaultView($controller, $xoopsUser);
179 public function _processActionForm()
182 $this->mActionForm->prepare();
185 public function executeViewSuccess(&$controller, &$xoopsUser, &$render)
187 $render->setTemplateName(
'legacy_admin_actionsearch_success.html');
188 $render->setAttribute(
'records', $this->mRecords);
189 $render->setAttribute(
'actionForm', $this->mActionForm);
192 public function executeViewInput(&$controller, &$xoopsUser, &$render)
194 $render->setTemplateName(
'legacy_admin_actionsearch_input.html');
195 $render->setAttribute(
'actionForm', $this->mActionForm);
198 public function executeViewError(&$controller, &$xoopsUser, &$render)
200 $render->setTemplateName(
'legacy_admin_actionsearch_error.html');
201 $render->setAttribute(
'actionForm', $this->mActionForm);