예제 #1
0
 $allow_name = exists_tag_name($name);
 // Check if the new name is the same as the old
 if (!$allow_name) {
     // Get the old name. This function returns an array of names for the matched filter
     $old_names = get_available_tag_names(array(TAGS_TABLE_ID_COL => $id));
     if (!empty($old_names)) {
         $old_name = array_shift($old_names);
         if (!empty($old_name) && $old_name != $name) {
             $allow_name = true;
         }
     }
 }
 if ($allow_name) {
     try {
         $values = array(TAGS_TABLE_NAME_COL => $name, TAGS_TABLE_COLOUR_COL => $colour);
         $result = update_tag($id, $values);
         $crud_operation['result'] = $result;
         // Result can be 0 if the target has the same values as the source
         if ($result !== false) {
             $result = true;
             // Prepare the values for another creation
             $id = 0;
             $name = '';
             $colour = '';
         }
         $crud_operation['message'] .= ui_print_result_message($result, __('Tag updated successsfully'), __('There was an error updating the tag'), '', true);
     } catch (Exception $e) {
         $crud_operation['message'] .= ui_print_error_message($e->getMessage(), '', true);
     }
 } else {
     $crud_operation['message'] .= ui_print_error_message(__('The name already exists'), '', true);
예제 #2
0
    }
    foreach ($tags as $id) {
        $tag = new MWTag($id);
        if ($tag->isNew()) {
            continue;
        }
        $tag->update_posts();
    }
    redirectMsg('tags.php?page=' . $page, __('Tags updated!', 'mywords'), 0);
}
$action = rmc_server_var($_REQUEST, 'action', '');
switch ($action) {
    case 'new':
        save_tag(false);
        break;
    case 'saveedit':
        save_tag(true);
        break;
    case 'edit':
        edit_form();
        break;
    case 'delete':
        delete_tag();
        break;
    case 'update':
        update_tag();
        break;
    default:
        show_tags();
        break;
}
예제 #3
0
파일: tags.php 프로젝트: pthdnq/ivalley-svn
simple_page_mode(true);
//-----------------------------------------------------------------------------------
function can_process()
{
    if (strlen($_POST['name']) == 0) {
        display_error(_("The tag name cannot be empty."));
        set_focus('name');
        return false;
    }
    return true;
}
//-----------------------------------------------------------------------------------
if ($Mode == 'ADD_ITEM' || $Mode == 'UPDATE_ITEM') {
    if (can_process()) {
        if ($selected_id != -1) {
            if ($ret = update_tag($selected_id, $_POST['name'], $_POST['description'])) {
                display_notification(_('Selected tag settings have been updated'));
            }
        } else {
            if ($ret = add_tag($_POST['type'], $_POST['name'], $_POST['description'])) {
                display_notification(_('New tag has been added'));
            }
        }
        if ($ret) {
            $Mode = 'RESET';
        }
    }
}
//-----------------------------------------------------------------------------------
function can_delete($selected_id)
{
예제 #4
0
function list_tags_action($uid)
{
    // needed to set the tab active
    $tags_active = true;
    //check if the user is admin
    if (user_is_admin($uid)) {
        // dealing with tag add form
        if (isset($_POST['owner'])) {
            $tag_added = get_tag_by_uid($_POST['uid']);
            // tag exists
            if ($tag_added) {
                update_tag($_POST['uid'], $_POST);
            } else {
                add_tag($_POST);
            }
        }
        // list all the users
        $tags = get_all_tags();
        $types = get_tag_types();
        $uids = get_all_uids();
        require 'templates/tags.php';
    } else {
        require 'templates/login.php';
    }
}
예제 #5
0
// page title - if undefined the site title is displayed by default
$page_title = 'Tags';
// process post actions
// insert tag
if (isset($_POST['insert_tag']) && $_POST['insert_tag'] == 'add') {
    $insert_status = insert_tag();
    if (is_int($insert_status)) {
        header('Location: ' . $_SERVER["PHP_SELF"] . '?page_name=tags&tag_id=' . $insert_status);
    } else {
        $insert_error = $insert_status;
    }
}
// update tag
if (isset($_POST['update_tag']) && $_POST['update_tag'] == 'update') {
    $tag_id = (int) $_GET['tag_id'];
    $update_status = update_tag($tag_id);
    if ($update_status === true) {
        header('Location: ' . $url);
    } else {
        $error = $update_status;
    }
}
// delete tag
if (isset($_POST['confirm_delete_tag']) && $_POST['confirm_delete_tag'] == 'Yes') {
    $tag_id = (int) $_GET['tag_id'];
    $delete_status = delete_tag($tag_id);
    if ($delete_status === true) {
        header('Location: ' . $_SERVER["PHP_SELF"] . '?page_name=tags');
    } else {
        $error = $delete_status;
    }