| 1 | <?php
|
|---|
| 2 | require_once('header.inc.php');
|
|---|
| 3 | $tagservice = & ServiceFactory :: getServiceInstance('TagService');
|
|---|
| 4 | $templateservice = & ServiceFactory :: getServiceInstance('TemplateService');
|
|---|
| 5 | $userservice = & ServiceFactory :: getServiceInstance('UserService');
|
|---|
| 6 |
|
|---|
| 7 | list ($url, $tag) = explode('/', $_SERVER['PATH_INFO']);
|
|---|
| 8 |
|
|---|
| 9 | if ($_POST['confirm']) {
|
|---|
| 10 | if (isset($_POST['old']) && (trim($_POST['old']) != ''))
|
|---|
| 11 | $old = trim($_REQUEST['old']);
|
|---|
| 12 | else
|
|---|
| 13 | $old = NULL;
|
|---|
| 14 |
|
|---|
| 15 | if (isset($_POST['new']) && (trim($_POST['new']) != ''))
|
|---|
| 16 | $new = trim($_POST['new']);
|
|---|
| 17 | else
|
|---|
| 18 | $new = NULL;
|
|---|
| 19 |
|
|---|
| 20 | if (is_null($old) || is_null($new)) {
|
|---|
| 21 | $tplVars['error'] = T_('Failed to rename the tag');
|
|---|
| 22 | $templateservice->loadTemplate('error.500.tpl', $tplVars);
|
|---|
| 23 | exit();
|
|---|
| 24 | } else {
|
|---|
| 25 | // Rename the tag.
|
|---|
| 26 | if($tagservice->renameTag($userservice->getCurrentUserId(), $old, $new, false)) {
|
|---|
| 27 | $tplVars['msg'] = T_('Tag renamed');
|
|---|
| 28 | $logged_on_user = $userservice->getCurrentUser();
|
|---|
| 29 | header('Location: '. createURL('bookmarks', $logged_on_user[$userservice->getFieldName('username')]));
|
|---|
| 30 | } else {
|
|---|
| 31 | $tplVars['error'] = T_('Failed to rename the tag');
|
|---|
| 32 | $templateservice->loadTemplate('error.500.tpl', $tplVars);
|
|---|
| 33 | exit();
|
|---|
| 34 | }
|
|---|
| 35 | }
|
|---|
| 36 | } elseif ($_POST['cancel']) {
|
|---|
| 37 | $logged_on_user = $userservice->getCurrentUser();
|
|---|
| 38 | header('Location: '. createURL('bookmarks', $logged_on_user[$userservice->getFieldName('username')] .'/'. $tags));
|
|---|
| 39 | }
|
|---|
| 40 |
|
|---|
| 41 | $tplVars['sidebar_blocks'] = array('profile','recent-tags','partners');
|
|---|
| 42 | $tplVars['subtitle'] = T_('Rename Tag') .': '. $tag;
|
|---|
| 43 | $tplVars['formaction'] = $_SERVER['SCRIPT_NAME'] .'/'. $tag;
|
|---|
| 44 | $tplVars['referrer'] = $_SERVER['HTTP_REFERER'];
|
|---|
| 45 | $tplVars['old'] = $tag;
|
|---|
| 46 | $templateservice->loadTemplate('tagrename.tpl', $tplVars);
|
|---|
| 47 | ?>
|
|---|
| 48 |
|
|---|