function clone_tab($data)
{
    $panel = $data['panel'];
    ossim_valid($panel, OSS_DIGIT, 'illegal:' . _("Tab ID"));
    if (ossim_error()) {
        $info_error = "Error: " . ossim_get_error();
        ossim_clean_error();
        $return['error'] = TRUE;
        $return['msg'] = $info_error;
        return $return;
    }
    list($user, $edit) = get_tabs_data_aux();
    if (!$edit) {
        $return['error'] = TRUE;
        $return['msg'] = _("You have to be in edit mode to achieve this action");
        return $return;
    }
    try {
        $tab = new Dashboard_tab($panel);
        $_cloned = $tab->clone_tab();
    } catch (Exception $e) {
        $return['error'] = TRUE;
        $return['msg'] = $e->getMessage();
        return $return;
    }
    $data = array();
    $data['msg'] = _("Tab Cloned Successfully");
    $data['new_id'] = $_cloned->get_id();
    $data['title'] = $_cloned->get_title();
    $return['error'] = FALSE;
    $return['data'] = $data;
    return $return;
}
function clone_tab_all($conn, $data)
{
    $panel = $data['panel'];
    $from = $data['user'];
    ossim_valid($from, OSS_USER, 'illegal:' . _("User Origin"));
    ossim_valid($panel, OSS_DIGIT, 'illegal:' . _("Tab ID"));
    if (ossim_error()) {
        $info_error = "Error: " . ossim_get_error();
        ossim_clean_error();
        $return['error'] = TRUE;
        $return['msg'] = $info_error;
        return $return;
    }
    if (!get_user_valid($from)) {
        $return['error'] = TRUE;
        $return['msg'] = _('You do not have permission to clone this tab');
        return $return;
    }
    try {
        $tab = new Dashboard_tab($panel, $from);
    } catch (Exception $e) {
        $return['error'] = TRUE;
        $return['msg'] = $e->getMessage();
        return $return;
    }
    $users = Session::get_users_to_assign($conn);
    if (count($users) == 1 && $users[0]->login == $from) {
        $return['error'] = TRUE;
        $return['msg'] = 'unique_user';
        return $return;
    }
    foreach ($users as $user) {
        if ($from == $user->login) {
            continue;
        }
        try {
            $tab->clone_tab($user->login);
        } catch (Exception $e) {
            $return['error'] = TRUE;
            $return['msg'] = $e->getMessage();
            return $return;
        }
    }
    $_SESSION['_db_perms_msg_index'] = 1;
    $return['error'] = FALSE;
    $return['msg'] = _("Tab Cloned Successfully");
    return $return;
}