예제 #1
0
/**
 * Function to update playlist name
 * This function is used to update playlist name of current user
 * This function has watchUserId to hold current user id
 * This function has $playlistName to hold playlist name
 * This function has $existingName to hold existing playlist name to check
 * This function include playlistcontroller file
 * This function has controllerObj variable to hold PlaylistController object
 * This function call updatePlaylistNameController method to update playlist name of current user
 * wp_ajax hook is used to call update_playlist_name
 * @return void
 */
function update_playlist_name()
{
    global $frontControllerPath, $frontModelPath, $frontViewPath;
    $userId = get_current_user_id();
    $playlistName = isset($_POST['pname']) && $_POST['pname'] != '' ? strip_tags($_POST['pname']) : '';
    $existingName = isset($_POST['ename']) && $_POST['ename'] != '' ? strip_tags($_POST['ename']) : '';
    if (is_user_logged_in() && !empty($playlistName)) {
        include_once $frontControllerPath . 'playlistcontroller.php';
        $controllerObj = new PlaylistController();
        $controllerObj->updatePlaylistNameController($userId, $playlistName, $existingName);
    } else {
        echo json_encode(array());
        exitAction('');
    }
}