I'm trying to modify a web script.
Currently, upon uploading a video, in the upload Form, among other things, the uploader chooses a sub-category and enters tags
and then submits/uploads. I'd like the sub-category that is selected, to also be searchable as a keyword.
Presently, the 'videos' table has a 'sub-category' column, but only the 'sub_category' ID is stored there (upon a video being uploaded), not the actual searchable name of the 'sub_category'. (All of the sub-category names and related sub_category ID's are stored in another table).
I'd like to modify the script code so that when the sub_category ID gets stored in the VIDEOS table, the corresponding sub_category name also populates in that table, upon a video being uploaded (so that I can add the 'sub_category' name as a searchable keyword).
I believe this code from the script's submit.php file is where the VIDEOS table gets populated (in the data_insert = array):
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']);
}
}
$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']);
}
}
$publication_date = 0;
if (!empty($_POST['date']) && !empty($_POST['hour'])) {
$publication_date = strtotime($_POST['date']." ".$pt->config->hours[$_POST['hour']]);
$video_privacy = 1;
}
$data_insert = array(
'video_id' => $video_id,
'user_id' => $user->id,
'title' => PT_Secure($_POST['title']),
'description' => PT_Secure($_POST['description']),
'tags' => PT_Secure($_POST['tags']),
'video_location' => '',
'category_id' => $category_id,
'thumbnail' => $thumbnail,
'time' => time(),
'registered' => date('Y') . '/' . intval(date('m')),
'converted' => '2',
'size' => $filesize,
'privacy' => $video_privacy,
'age_restriction' => $age_restriction,
'sub_category' => $sub_category,
'embedding' => $embedding,
'publication_date' => $publication_date
);
Can you provide some insight/guidance as to when the video title, description, tags and sub_category ID, etc. gets added to VIDEOS table
how I can also add sub_cat name that corresponds with the populated sub_category ID?
As stated above, all of the sub-category ID's and related sub_category names are stored in another table.
I look forward to any assistance.