22 public function __construct()
24 parent::__construct();
25 $this->mService = $this->root->mServiceManager->getService(
'UserSearch');
26 $this->setUrl(
'index.php?action=favorites');
29 private function addFavorites()
32 $adduid = $this->root->mContext->mRequest->getRequest(
'adduid');
33 if (!is_array($adduid) || 0 == count($adduid)) {
34 $this->setErr(_MD_MESSAGE_FAVORITES0);
37 $mid = $this->root->mContext->mXoopsModule->get(
'mid');
38 $client = $this->root->mServiceManager->createClient($this->mService);
39 foreach ($adduid as $fuid) {
40 $ret[] = $client->call(
'addFavorites', [
'mid' => $mid,
'fuid' => $fuid,
'weight' => 0]);
42 if (in_array(
false, $ret,
true)) {
43 $this->setErr(_MD_MESSAGE_FAVORITES1);
45 $this->setErr(_MD_MESSAGE_FAVORITES2);
49 private function edtFavorites()
51 $weight = $this->root->mContext->mRequest->getRequest(
'weight');
52 if (!is_array($weight) || 0 == count($weight)) {
55 $client = $this->root->mServiceManager->createClient($this->mService);
56 foreach ($weight as $id => $w) {
57 $ret[] = $client->call(
'edtFavorites', [
'id' => $id,
'weight' => $w]);
59 if (in_array(
false, $ret,
true)) {
60 $this->setErr(_MD_MESSAGE_FAVORITES3);
64 $this->setErr(_MD_MESSAGE_FAVORITES4);
68 private function delFavorites()
70 $delid = $this->root->mContext->mRequest->getRequest(
'delid');
71 if (!is_array($delid) || 0 == count($delid)) {
74 $client = $this->root->mServiceManager->createClient($this->mService);
75 foreach ($delid as $id) {
76 $ret[] = $client->call(
'delFavorites', [
'id' => $id]);
78 if (in_array(
false, $ret,
true)) {
79 $this->setErr(_MD_MESSAGE_FAVORITES3);
81 $this->setErr(_MD_MESSAGE_FAVORITES5);
85 private function getFavorites()
87 $mid = $this->root->mContext->mXoopsModule->get(
'mid');
88 $client = $this->root->mServiceManager->createClient($this->mService);
89 $this->favorites = $client->call(
'getFavoritesUsers', [
'mid' => $mid]);
92 public function execute()
94 if (!$this->chk_use()) {
95 $this->setUrl(
'index.php?action=settings');
96 $this->setErr(_MD_MESSAGE_SETTINGS_MSG5);
98 if (
null == $this->mService) {
99 $this->setErr(
'Service Not loaded.');
103 $this->root->mLanguageManager->loadModuleMessageCatalog(
'usersearch');
104 $cmd = $this->root->mContext->mRequest->getRequest(
'cmd');
106 $this->getFavorites();
110 $this->addFavorites();
113 if ($this->edtFavorites()) {
114 $this->delFavorites();
122 public function executeView(&$render)
124 $render->setTemplateName(
'message_favorites.html');
125 $render->setAttribute(
'fuser', $this->favorites);