/** * Update all the watchers for a given item */ public function setwatchersAction() { $itemType = ucfirst($this->_getParam('attachedtotype')); $itemId = $this->_getParam('attachedtoid'); if ($itemType == null || $itemId == null) { $this->flash("Could not update subscribers, null request passed"); $this->redirect('error'); return; } // get all watchers and then remove $subscribers = $this->notificationService->deleteAllSubscribers($itemId, $itemType); foreach ($this->_getParam('watchusers') as $username) { $user = $this->userService->getUserByField('username', $username); $this->notificationService->createWatch($user, $itemId, $itemType); } $caller = $this->getCallingUrl(); if ($this->_getParam('_ajax')) { } else { if (mb_strlen($caller)) { $this->_redirect($caller); } } }