| 1 | <?php |
|---|
| 2 | /*
|
|---|
| 3 |
|
|---|
| 4 | This file is part of omCollab.
|
|---|
| 5 |
|
|---|
| 6 | Copyright (c) 2008 omCollab (Openmethodology Project)
|
|---|
| 7 | http://www.openmethodology.org
|
|---|
| 8 | http://mike2.openmethodology.org/wiki/OmCollab
|
|---|
| 9 |
|
|---|
| 10 | And parts copyright of Scuttle project
|
|---|
| 11 | (http://sourceforge.net/projects/scuttle/, http://scuttle.org/)
|
|---|
| 12 |
|
|---|
| 13 | omCollab is free software: you can redistribute it and/or modify
|
|---|
| 14 | it under the terms of the GNU General Public License as published by
|
|---|
| 15 | the Free Software Foundation, either version 3 of the License, or
|
|---|
| 16 | (at your option) any later version.
|
|---|
| 17 |
|
|---|
| 18 | omCollab is distributed in the hope that it will be useful,
|
|---|
| 19 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 20 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 21 | GNU General Public License for more details.
|
|---|
| 22 |
|
|---|
| 23 | */
|
|---|
| 24 |
|
|---|
| 25 | require_once('header.inc.php'); |
|---|
| 26 | $userservice =& ServiceFactory::getServiceInstance('UserService'); |
|---|
| 27 | |
|---|
| 28 | @list($url, $user) = isset($_SERVER['PATH_INFO']) ? explode('/', $_SERVER['PATH_INFO']) : NULL; |
|---|
| 29 | if ($userservice->isLoggedOn() && $user) { |
|---|
| 30 | $tplVars = array(); |
|---|
| 31 | $pagetitle = ''; |
|---|
| 32 | |
|---|
| 33 | if (is_int($user)) { |
|---|
| 34 | $userid = intval($user); |
|---|
| 35 | } else { |
|---|
| 36 | if (!($userinfo = $userservice->getUserByUsername($user))) { |
|---|
| 37 | $tplVars['error'] = sprintf(T_('User with username %s was not found'), $user); |
|---|
| 38 | $templateservice->loadTemplate('error.404.tpl', $tplVars); |
|---|
| 39 | exit(); |
|---|
| 40 | } else { |
|---|
| 41 | $userid =& $userinfo['uId']; |
|---|
| 42 | } |
|---|
| 43 | } |
|---|
| 44 | |
|---|
| 45 | $watched = $userservice->getWatchStatus($userid, $userservice->getCurrentUserId()); |
|---|
| 46 | $changed = $userservice->setWatchStatus($userid); |
|---|
| 47 | |
|---|
| 48 | if ($watched) { |
|---|
| 49 | $tplVars['msg'] = T_('User removed from your watchlist'); |
|---|
| 50 | } else { |
|---|
| 51 | $tplVars['msg'] = T_('User added to your watchlist'); |
|---|
| 52 | } |
|---|
| 53 | |
|---|
| 54 | $currentUser = $userservice->getCurrentUser(); |
|---|
| 55 | $currentUsername = $currentUser[$userservice->getFieldName('username')]; |
|---|
| 56 | |
|---|
| 57 | header('Location: '. createURL('watchlist', $currentUsername)); |
|---|
| 58 | } |
|---|
| 59 | ?> |
|---|