3 Replies - 269 Views - Last Post: 09 May 2019 - 11:11 AM Rate Topic: -----

#1 chrisjchrisj   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 64
  • Joined: 04-February 19

Help with allowing User to change set pricing

Posted 08 May 2019 - 03:50 PM

The web video script that I'm using works successfully where Users can edit the price of their uploaded video (the minimum price is set in the admin panel for all uploaded videos). But, I am looking for assistance with modifying so that just one user/uploader (named “Admin”) can set a price lower than the minimum. Here is the edit-video.php file code:

<?php
if (IS_LOGGED == false) {
    header("Location: " . PT_Link('login'));
    exit();
}
if (empty($_GET['id'])) {
    header("Location: " . PT_Link('login'));
    exit();
}
$id    = PT_Secure($_GET['id']);
$video = $db->where('id', $id)->getOne(T_VIDEOS);
if (empty($video)) {
    header("Location: " . PT_Link('login'));
    exit();
}
if (!PT_IsAdmin()) {
    if (empty($db->where('id', $id)->where('user_id', $user->id)->getValue(T_VIDEOS, 'count(*)'))) {
        header("Location: " . PT_Link('login'));
        exit();
    }
}
$video           = PT_GetVideoByID($video, 0, 0, 0);
$pt->video       = $video;
$pt->page        = 'edit-video';
$pt->title       = $lang->edit_video . ' | ' . $pt->config->title;
$pt->description = $pt->config->description;
$pt->keyword     = $pt->config->keyword;


$min_price=$config[‘video_play_price’];
$temp_price = $videos[‘video_play_price’];
if ($temp_price<$min_price) { $temp_price = $min_price;}


$pt->content     = PT_LoadPage('edit-video/content', array(
    'ID' => $video->id,
    'USER_DATA' => $video->owner,
    'THUMBNAIL' => $video->thumbnail,
    'URL' => $video->url,
    'TITLE' => $video->title,
    'DESC' => br2nl($video->edit_description),
    'DESC_2' => $video->markup_description,
    'VIEWS' => $video->views,
    'TIME' => $video->time_ago,
    'TAGS' => $video->tags,
	'video_play_price_user' => number_format( $video->video_play_price < $config['video_play_price'] ? $config['video_play_price'] : $video->video_play_price)
));




any assistance with this modification is appreciated

Is This A Good Question/Topic? 0
  • +

Replies To: Help with allowing User to change set pricing

#2 ArtificialSoldier   User is online

  • D.I.C Lover
  • member icon

Reputation: 2282
  • View blog
  • Posts: 6,971
  • Joined: 15-January 14

Re: Help with allowing User to change set pricing

Posted 08 May 2019 - 04:09 PM

How do you check who the current user is?
Was This Post Helpful? 0
  • +
  • -

#3 chrisjchrisj   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 64
  • Joined: 04-February 19

Re: Help with allowing User to change set pricing

Posted 08 May 2019 - 04:20 PM

Thanks so much for your reply.

I don't know the answer to your question. Once any user is logged in they can upload and optionally change the video
price, if they choose to, but not change it to lower than the set minimum. Here's the ajax/edit_video.php file code, it that helps you help me:

<?php
if (IS_LOGGED == false) {
    $data = array('status' => 400, 'error' => 'Not logged in');
    echo json_encode($data);
    exit();
}


if (empty($_POST['title']) || empty($_POST['description']) || empty($_POST['tags']) || empty($_POST['video-id'])) {
    $error = $lang->please_check_details;
}

if (($pt->config->sell_videos_system == 'on' && $pt->config->who_sell == 'pro_users' && $pt->user->is_pro) || ($pt->config->sell_videos_system == 'on' && $pt->config->who_sell == 'users') || ($pt->config->sell_videos_system == 'on' && $pt->user->admin)) {
    if (!empty($_POST['set_p_v']) || $_POST['set_p_v'] < 0) {
        if (!is_numeric($_POST['set_p_v']) || $_POST['set_p_v'] < 0 || (($pt->config->com_type == 0 && $_POST['set_p_v'] <= $pt->config->admin_com_sell_videos)) ) {
            $error = $lang->video_price_error." ".($pt->config->com_type == 0 ? $pt->config->admin_com_sell_videos : 0);
        }
    }
}

if (PT_IsAdmin()) {
	if (!empty($_POST['assign_to_user'])) {
		$id = PT_Secure($_POST['video-id']);
		$username_ = PT_Secure($_POST['assign_to_user']);
		$user_  = $db->where('username', $username_)->getOne(T_USERS);
		if (!empty($user_)) {
			$db->where('id', $id)->update(T_VIDEOS, array('user_id' => $user_->id));
		}
		else{
			$error = $lang->user_not_exists;
		}
	}
}

if (empty($error)) {
    $id = PT_Secure($_POST['video-id']);
    $video = $db->where('id', $id)->getOne(T_VIDEOS);
    $can_update = false;
    if (PT_IsAdmin() == false) {
    	if ($db->where('user_id', $user->id)->where('id', $id)->getValue(T_VIDEOS, 'count(*)') > 0) {
    		$can_update = true;
    	}
    } else {
    	$can_update = true;
    }
    if (!empty($_POST['set_p_v']) && $video->sell_video == 0) {
    	$can_update = false;
    }
    if ($can_update == true && !empty($video)) {
    	$video = PT_GetVideoByID($video, 0, 0, 0);
    	$thumbnail = $video->org_thumbnail;
    	if (!empty($_FILES['thumbnail']['tmp_name'])) {
	        $file_info   = array(
	            'file' => $_FILES['thumbnail']['tmp_name'],
	            'size' => $_FILES['thumbnail']['size'],
	            'name' => $_FILES['thumbnail']['name'],
	            'type' => $_FILES['thumbnail']['type'],
	            'allowed' => 'jpg,png,jpeg,gif',
	            'crop' => array(
	                'width' => 1076,
	                'height' => 604
	            )
	        );
	        $file_upload = PT_ShareFile($file_info);
	        if (!empty($file_upload['filename'])) {
	            $thumbnail = PT_Secure($file_upload['filename']);
	        }
	    }
	    $category_id = 0;
	    if (!empty($_POST['category_id'])) {
	        if (in_array($_POST['category_id'], array_keys(get_object_vars($pt->categories)))) {
	            $category_id = PT_Secure($_POST['category_id']);
	        }
	    }
	    $link_regex = '/(http\:\/\/|https\:\/\/|www\.)([^\ ]+)/i';
	    $i          = 0;
	    preg_match_all($link_regex, PT_Secure($_POST['description']), $matches);
	    foreach ($matches[0] as $match) {
	        $match_url           = strip_tags($match);
	        $syntax              = '[a]' . urlencode($match_url) . '[/a]';
	        $_POST['description'] = str_replace($match, $syntax, $_POST['description']);
	    }
	    $featured = $video->featured;
	    if (isset($_POST['featured']) && PT_IsAdmin()) {
	    	$featured = PT_Secure($_POST['featured']);
	    }
	    $video_privacy = 0;
	    if (!empty($_POST['privacy'])) {
	        if (in_array($_POST['privacy'], array(0, 1, 2))) {
	            $video_privacy = PT_Secure($_POST['privacy']);
	        }
	    }
	    $age_restriction = 1;
        if (!empty($_POST['age_restriction'])) {
            if (in_array($_POST['age_restriction'], array(1, 2))) {
                $age_restriction = PT_Secure($_POST['age_restriction']);
            }
        }
        $sub_category = 0;

	    if (!empty($_POST['sub_category_id'])) {
	        $is_found = $db->where('type',PT_Secure($_POST['category_id']))->where('lang_key',PT_Secure($_POST['sub_category_id']))->getValue(T_LANGS,'COUNT(*)');
	        if ($is_found > 0) {
	            $sub_category = PT_Secure($_POST['sub_category_id']);
	        }
	    }
	    $continents_list = array();
	    if (!empty($_POST['continents-list'])) {
	        foreach ($_POST['continents-list'] as $key => $value) {
	            if (in_array($value, $pt->continents)) {
	                $continents_list[] = $value;
	            }
	        }
	    }

	    $video_play_price = floatval(PT_Secure($_POST['video_play_price']));
		if ( $video_play_price < $config['video_play_price'] ) {
 	$video_play_price = $config['video_play_price'];
	}

	    $data_update = array(
	        'title' => PT_Secure($_POST['title']),
	        'description' => PT_Secure($_POST['description']),
	        'tags' => PT_Secure($_POST['tags']),
	        'category_id' => $category_id,
	        'featured' => $featured,
	        'thumbnail' => $thumbnail,
	        'privacy' => $video_privacy,
	        'age_restriction' => $age_restriction,
	        'sub_category' => $sub_category,
	        'geo_blocking' => json_encode($continents_list),
	        'video_play_price' => $video_play_price,
	    );
	    if (!empty($_POST['set_p_v']) && is_numeric($_POST['set_p_v']) && $_POST['set_p_v'] > 0) {
            $data_update['sell_video'] = PT_Secure($_POST['set_p_v']);
        }
	    $update  = $db->where('id', $id)->update(T_VIDEOS, $data_update);

	    if ($update) {
	        $data = array(
	            'status' => 200,
	            'message' => $success_icon . $lang->video_saved
	        );
	    }
    }
} else {
    $data = array(
        'status' => 400,
        'message' => $error_icon . $error
    );
}
?>




I look forward to additional assistance
Was This Post Helpful? 0
  • +
  • -

#4 ArtificialSoldier   User is online

  • D.I.C Lover
  • member icon

Reputation: 2282
  • View blog
  • Posts: 6,971
  • Joined: 15-January 14

Re: Help with allowing User to change set pricing

Posted 09 May 2019 - 11:11 AM

Well, if you want to do anything based on who the specific user is, then the first step is figuring out who the user is. If the code that you're using has any associated documentation, I would go through that to see what's available to you. Otherwise, you need to look through all of the files to find out what's available, which is a bit slower. You can also look at the login process to point you in the right direction.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1