From be201b2250a31c749525a9e2a34368445eac1bcb Mon Sep 17 00:00:00 2001 From: clement-sanz Date: Mon, 30 Sep 2024 22:32:57 +0200 Subject: [PATCH 01/59] 307 first commit --- upload/actions/admin_delete_membership.php | 23 ++ upload/admin_area/edit_membership.php | 46 +++ upload/admin_area/edit_video.php | 4 +- upload/admin_area/main.php | 4 +- upload/admin_area/manage_playlist.php | 2 +- upload/admin_area/memberships.php | 47 ++++ .../cb_2014/layout/edit_membership.html | 89 ++++++ .../styles/cb_2014/layout/main.html | 7 + .../styles/cb_2014/layout/memberships.html | 50 ++++ .../js/pages/membership/edit_membership.js | 35 +++ .../theme/js/pages/membership/memberships.js | 41 +++ upload/cb_install/sql/5.5.1/MWIP.php | 143 ++++++++++ upload/cb_install/sql/structure.sql | 31 +++ upload/includes/classes/ClipBucket.class.php | 13 + upload/includes/classes/membership.class.php | 263 ++++++++++++++++++ .../classes/session_message_handler.class.php | 2 +- upload/includes/classes/video.class.php | 12 +- upload/includes/common.php | 3 +- 18 files changed, 804 insertions(+), 11 deletions(-) create mode 100644 upload/actions/admin_delete_membership.php create mode 100644 upload/admin_area/edit_membership.php create mode 100644 upload/admin_area/memberships.php create mode 100644 upload/admin_area/styles/cb_2014/layout/edit_membership.html create mode 100644 upload/admin_area/styles/cb_2014/layout/memberships.html create mode 100644 upload/admin_area/styles/cb_2014/theme/js/pages/membership/edit_membership.js create mode 100644 upload/admin_area/styles/cb_2014/theme/js/pages/membership/memberships.js create mode 100644 upload/cb_install/sql/5.5.1/MWIP.php create mode 100644 upload/includes/classes/membership.class.php diff --git a/upload/actions/admin_delete_membership.php b/upload/actions/admin_delete_membership.php new file mode 100644 index 000000000..a2cf479a1 --- /dev/null +++ b/upload/actions/admin_delete_membership.php @@ -0,0 +1,23 @@ +admin_login_check(); + +$id_membership = $_POST['id_membership']; +$membership = Membership::getInstance()->getOne(['id_membership'=>$id_membership]); +if (!empty($membership['id_user_membership'])) { + e(lang('cant_delete_membership_at_least_one_user')); + $success = false; +} else { + $success = Membership::getInstance()->delete($id_membership); +} +if ($success) { + e(lang('membership_deleted'), 'm'); +} +$url=''; +if (!empty($_POST['redirect'])) { + SessionMessageHandler::add_message(lang('membership_deleted')); + $url = BASEURL . DirPath::getUrl('admin_area') .'memberships.php'; +} +echo json_encode(['msg'=>getTemplateMsg(), 'success'=>$success, 'url'=>$url]); diff --git a/upload/admin_area/edit_membership.php b/upload/admin_area/edit_membership.php new file mode 100644 index 000000000..ca4e58579 --- /dev/null +++ b/upload/admin_area/edit_membership.php @@ -0,0 +1,46 @@ +admin_login_check(); +$pages->page_redir(); + +/* Generating breadcrumb */ + + +//TODO check inputs required etc. +if (!empty($_POST['id_membership'])) { + Membership::getInstance()->update($_POST); +} elseif (!empty($_POST)) { + $inserted_id = Membership::getInstance()->insert($_POST); + $_REQUEST['id_membership'] = $inserted_id; +} + +$membership = Membership::getInstance()->getOne(['id_membership' => $_REQUEST['id_membership'] ?? 0]); +assign('membership', $membership); +assign('frequencies', Membership::getInstance()->getFrequencies()); +assign('user_levels', userquery::getInstance()->get_levels() ?: []); + +global $breadcrumb; +$breadcrumb[0] = [ + 'title' => lang('memberships'), + 'url' => '' +]; +$breadcrumb[1] = [ + 'title' => lang('user_levels'), + 'url' => DirPath::getUrl('admin_area') . 'memberships.php' +]; +$titre = lang((!empty($membership) ? 'edit_' : 'add_') . 'membership'); +$breadcrumb[2] = [ + 'title' => $titre, + 'url' => DirPath::getUrl('admin_area') . 'edit_membership.php' . (!empty($membership) ? '?id_membership=' . $membership['id_membership'] : '') +]; + +$min_suffixe = in_dev() ? '' : '.min'; +ClipBucket::getInstance()->addAdminJS([ + 'pages/membership/edit_membership' . $min_suffixe . '.js' => 'admin', +]); +subtitle($titre); +template_files('edit_membership.html'); +display_it(); diff --git a/upload/admin_area/edit_video.php b/upload/admin_area/edit_video.php index ed76f3958..1b6620b6a 100644 --- a/upload/admin_area/edit_video.php +++ b/upload/admin_area/edit_video.php @@ -78,9 +78,9 @@ } else { //add parameter to display message after redirect if ($_GET['mode'] == 'delete') { - sessionMessageHandler::add_message(lang('video_deleted'), 'm', BASEURL . DirPath::getUrl('admin_area') . 'video_manager.php'); + SessionMessageHandler::add_message(lang('video_deleted'), 'm', BASEURL . DirPath::getUrl('admin_area') . 'video_manager.php'); } - sessionMessageHandler::add_message(lang('class_vdo_del_err'), 'e', BASEURL . DirPath::getUrl('admin_area') . 'video_manager.php'); + SessionMessageHandler::add_message(lang('class_vdo_del_err'), 'e', BASEURL . DirPath::getUrl('admin_area') . 'video_manager.php'); } $resolution_list = getResolution_list($data); diff --git a/upload/admin_area/main.php b/upload/admin_area/main.php index eeb32aa1a..e070226a7 100644 --- a/upload/admin_area/main.php +++ b/upload/admin_area/main.php @@ -133,6 +133,7 @@ , 'home_display_featured_collections' , 'home_display_recent_videos' , 'enable_access_view_video_history' + , 'enable_membership' ]; $config_booleans_to_refactor = [ @@ -458,7 +459,8 @@ 'enable_video_view_history', 'enable_video_view_history', 'enable_access_view_video_history', - 'video_list_view_video_history' + 'video_list_view_video_history', + 'enable_membership' ]; foreach ($opt_list as $optl) { diff --git a/upload/admin_area/manage_playlist.php b/upload/admin_area/manage_playlist.php index a9016a085..1fdd06988 100644 --- a/upload/admin_area/manage_playlist.php +++ b/upload/admin_area/manage_playlist.php @@ -152,7 +152,7 @@ 'url' => DirPath::getUrl('admin_area') . 'manage_playlist.php?mode=edit_playlist&pid=' . display_clean($pid) ]; } else { - sessionMessageHandler::add_message(lang('playlist_not_exist'), 'e', BASEURL . DirPath::getUrl('admin_area') . 'manage_playlist.php'); + SessionMessageHandler::add_message(lang('playlist_not_exist'), 'e', BASEURL . DirPath::getUrl('admin_area') . 'manage_playlist.php'); } break; } diff --git a/upload/admin_area/memberships.php b/upload/admin_area/memberships.php new file mode 100644 index 000000000..230116717 --- /dev/null +++ b/upload/admin_area/memberships.php @@ -0,0 +1,47 @@ +admin_login_check(); + +/* Generating breadcrumb */ +global $breadcrumb; +$breadcrumb[0] = [ + 'title' => lang('memberships'), + 'url' => '' +]; +$breadcrumb[1] = [ + 'title' => lang('user_levels'), + 'url' => DirPath::getUrl('admin_area') . 'memberships.php' +]; + + +$page = mysql_clean($_GET['page']); +$params['limit'] = create_query_limit($page, config('admin_pages')); +$params['group'] = Membership::getInstance()->getTablename() .'.id_membership'; +$memberships = Membership::getInstance()->getAll($params); +assign('memberships', $memberships); +if (empty($memberships)) { + $total_rows = 0; +} else { + if (count($memberships) < config('admin_pages') && ($page == 1 || empty($page))) { + $total_rows = count($memberships); + } else { + $params['count'] = true; + unset($params['limit']); + unset($params['order']); + $total_rows = Membership::getInstance()->getAll($params); + } +} +$total_pages = count_pages($total_rows, config('admin_pages')); +$pages->paginate($total_pages, $page); + +$min_suffixe = in_dev() ? '' : '.min'; +ClipBucket::getInstance()->addAdminJS([ + 'pages/membership/memberships' . $min_suffixe . '.js' => 'admin', +]); + +subtitle(lang('user_levels')); +template_files('memberships.html'); +display_it(); diff --git a/upload/admin_area/styles/cb_2014/layout/edit_membership.html b/upload/admin_area/styles/cb_2014/layout/edit_membership.html new file mode 100644 index 000000000..77e10f8c9 --- /dev/null +++ b/upload/admin_area/styles/cb_2014/layout/edit_membership.html @@ -0,0 +1,89 @@ +
+
+ {if !empty($membership.id_membership)} +

{lang('editing')} +
+ + +
+

+ {else} +

{lang('creation')} + {/if} +

+
+ +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ +
+ +
+ +
+ +
+
+
+
+
+ +
+
+
\ No newline at end of file diff --git a/upload/admin_area/styles/cb_2014/layout/main.html b/upload/admin_area/styles/cb_2014/layout/main.html index c6a221252..b9a636103 100644 --- a/upload/admin_area/styles/cb_2014/layout/main.html +++ b/upload/admin_area/styles/cb_2014/layout/main.html @@ -267,6 +267,13 @@

Website Configurations

+
+ +
+
+ + +

diff --git a/upload/admin_area/styles/cb_2014/layout/memberships.html b/upload/admin_area/styles/cb_2014/layout/memberships.html new file mode 100644 index 000000000..3d9cd58e4 --- /dev/null +++ b/upload/admin_area/styles/cb_2014/layout/memberships.html @@ -0,0 +1,50 @@ +
+

{lang('user_levels')}

+ {lang('add')} +
+ +
+ + + {**} + + + + + + + + {foreach from=$memberships item=membership} + + {**} + + + + + + + + {/foreach} +
+ + {lang('user_levels')}{lang('frequency')}{lang('base_price')}{lang('storage_quota')}{lang('storage_price')} 
+ + {$membership.user_level_name}{lang('frequency_'|cat:$membership.frequency)}{$membership.base_price}{$membership.storage_quota_included}{$membership.storage_price_per_go} + +
+
+ +{include file="$style_dir/blocks/pagination.html"} +
diff --git a/upload/admin_area/styles/cb_2014/theme/js/pages/membership/edit_membership.js b/upload/admin_area/styles/cb_2014/theme/js/pages/membership/edit_membership.js new file mode 100644 index 000000000..9262032b5 --- /dev/null +++ b/upload/admin_area/styles/cb_2014/theme/js/pages/membership/edit_membership.js @@ -0,0 +1,35 @@ +$(function () { + $('.delete').on('click', function () { + if (_cb.confirm_it('Are you sure you want to delete')) { + var id = $(this).data('id'); + var tr = $(this).parents('tr'); + $.post({ + url: '/actions/admin_delete_membership.php', + data: {id_membership: id, redirect: true}, + dataType: "json", + }); + } + }); + $('.activate').on('click', function () { + var id = $(this).data('id'); + $.post({ + url: 'actions/admin_membership_activate.php', + data: {id_membership: id, disabled: false}, + dataType: "json", + success: response => { + + } + }) + }); + $('.deactivate').on('click', function () { + var id = $(this).data('id'); + $.post({ + url: 'actions/admin_membership_activate.php', + data: {id_membership: id, disabled: true}, + dataType: "json", + success: response => { + + } + }) + }); +}); \ No newline at end of file diff --git a/upload/admin_area/styles/cb_2014/theme/js/pages/membership/memberships.js b/upload/admin_area/styles/cb_2014/theme/js/pages/membership/memberships.js new file mode 100644 index 000000000..c84f499f5 --- /dev/null +++ b/upload/admin_area/styles/cb_2014/theme/js/pages/membership/memberships.js @@ -0,0 +1,41 @@ +$(function () { + $('.delete').on('click', function () { + if (_cb.confirm_it('Are you sure you want to delete)')) { + var id = $(this).data('id'); + var tr = $(this).parents('tr'); + $.post({ + url: '/actions/admin_delete_membership.php', + data: {id_membership: id, redirect: false}, + dataType: "json", + success: response => { + $('.page-content').prepend(response['msg']); + if (response['success']) { + tr.remove(); + } + } + }); + } + }); + $('.activate').on('click', function () { + var id = $(this).data('id'); + $.post({ + url: 'actions/admin_membership_activate.php', + data: {id_membership: id, disabled: false}, + dataType: "json", + success: response => { + + } + }) + }); + $('.deactivate').on('click', function () { + var id = $(this).data('id'); + $.post({ + url: 'actions/admin_membership_activate.php', + data: {id_membership: id, disabled: true}, + dataType: "json", + success: response => { + + } + }) + }); +}); \ No newline at end of file diff --git a/upload/cb_install/sql/5.5.1/MWIP.php b/upload/cb_install/sql/5.5.1/MWIP.php new file mode 100644 index 000000000..5415558ed --- /dev/null +++ b/upload/cb_install/sql/5.5.1/MWIP.php @@ -0,0 +1,143 @@ + 'memberships' + ], [ + 'table' => 'memberships', + 'constraint_name' => 'user_frequency' + ]); + self::alterTable('ALTER TABLE `' . tbl('memberships') . '` ADD CONSTRAINT `user_level_membership` FOREIGN KEY (`user_level_id`) REFERENCES `' . tbl('user_levels') . '` (`user_level_id`) ON DELETE RESTRICT ON UPDATE RESTRICT;', [ + 'table' => 'memberships' + ], [ + 'table' => 'memberships', + 'constraint_name' => 'user_level_membership' + ]); + $sql = 'CREATE TABLE IF NOT EXISTS `' . tbl('user_memberships') . '` ( + `id_user_membership` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + `userid` BIGINT NOT NULL, + `id_membership` INT NOT NULL, + `date_start` datetime NOT NULL, + `date_end` datetime NULL, + `price` DECIMAL NOT NULL + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_unicode_520_ci;'; + self::query($sql); + self::alterTable('ALTER TABLE `' . tbl('user_memberships') . '` ADD CONSTRAINT `user_membership_user` FOREIGN KEY (`userid`) REFERENCES `' . tbl('users') . '` (`userid`) ON DELETE RESTRICT ON UPDATE RESTRICT;',[ + 'table' => 'user_memberships' + ], [ + 'table' => 'user_memberships', + 'constraint_name' => 'user_membership_user' + ]); + self::alterTable('ALTER TABLE `' . tbl('user_memberships') . '` ADD CONSTRAINT `user_membership_membership` FOREIGN KEY (`id_membership`) REFERENCES `' . tbl('memberships') . '` (`id_membership`) ON DELETE RESTRICT ON UPDATE RESTRICT;', [ + 'table' => 'user_memberships' + ], [ + 'table' => 'user_memberships', + 'constraint_name' => 'user_membership_membership' + ]); + + self::generateConfig('enable_membership', 'no'); + self::generateTranslation('enable_membership', [ + 'fr'=>'Activer les abonnements', + 'en'=>'Enable membership' + ]); + + self::generateTranslation('memberships', [ + 'fr'=>'Abonnements', + 'en'=>'Membership' + ]); + + self::generateTranslation('storage_price', [ + 'fr'=>'Prix de stockage', + 'en'=>'Storage price' + ]); + + self::generateTranslation('storage_quota', [ + 'fr'=>'Quota de stockage', + 'en'=>'Storage quota' + ]); + self::generateTranslation('storage_quota_included', [ + 'fr'=>'Quota de stockage inclus', + 'en'=>'Storage quota included' + ]); + self::generateTranslation('base_price', [ + 'fr'=>'Prix initial', + 'en'=>'Base price' + ]); + + self::generateTranslation('frequency', [ + 'fr'=>'Fréquence', + 'en'=>'Frequency' + ]); + + self::generateTranslation('frequency_daily', [ + 'fr'=>'Journalier', + 'en'=>'Daily' + ]); + + self::generateTranslation('frequency_weekly', [ + 'fr'=>'Hebdomadaire', + 'en'=>'Weekly' + ]); + + self::generateTranslation('frequency_monthly', [ + 'fr'=>'Mensuel', + 'en'=>'Monthly' + ]); + + self::generateTranslation('frequency_yearly', [ + 'fr'=>'Annuel', + 'en'=>'Yearly' + ]); + + self::generateTranslation('editing', [ + 'fr'=>'Edition', + 'en'=>'Editing' + ]); + + self::generateTranslation('add_membership', [ + 'fr'=>'Ajouter un niveau d\'abonnement', + 'en'=>'Add membership level' + ]); + self::generateTranslation('edit_membership', [ + 'fr'=>'Editer un niveau d\'abonnement', + 'en'=>'Edit membership level' + ]); + + self::generateTranslation('membership_deleted', [ + 'fr'=>'L\'abonnement a été supprimé', + 'en'=>'Membership has been deleted' + ]); + + self::generateTranslation('cant_delete_membership_at_least_one_user', [ + 'fr'=>'Impossible de supprimer l\'abonnement car au moins un utilisateur y est attaché', + 'en'=>'Cannot delete this membership, at least one user subscribe to it' + ]); + + self::generateTranslation('creation', [ + 'fr'=>'Création', + 'en'=>'Creation' + ]); + } +} diff --git a/upload/cb_install/sql/structure.sql b/upload/cb_install/sql/structure.sql index 7b246f80d..6d8d72985 100644 --- a/upload/cb_install/sql/structure.sql +++ b/upload/cb_install/sql/structure.sql @@ -1181,3 +1181,34 @@ ALTER TABLE `{tbl_prefix}social_networks_links` ALTER TABLE `{tbl_prefix}sessions` ADD INDEX(`session_date`); + +CREATE TABLE `{tbl_prefix}memberships` +( + `id_membership` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , + `user_level_id` INT(20) NOT NULL, + `frequency` ENUM ('daily', 'weekly', 'monthly', 'yearly'), + `base_price` DECIMAL, + `description` VARCHAR(512), + `storage_quota_included` INT DEFAULT NULL, + `storage_price_per_go` DECIMAL, + `disabled` BOOLEAN DEFAULT FALSE +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE utf8mb4_unicode_520_ci; + +ALTER TABLE `{tbl_prefix}memberships` + ADD UNIQUE KEY `user_frequency` (`frequency`, `user_level_id`); +ALTER TABLE `{tbl_prefix}memberships` + ADD CONSTRAINT `user_level_membership` FOREIGN KEY (`user_level_id`) REFERENCES `{tbl_prefix}user_levels` (`user_level_id`) ON DELETE RESTRICT ON UPDATE RESTRICT; + +CREATE TABLE `{tbl_prefix}user_memberships` +( + `id_user_membership` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + `userid` BIGINT NOT NULL, + `id_membership` INT NOT NULL, + `date_start` DATETIME NOT NULL, + `date_end` DATETIME NULL, + `price` DECIMAL NOT NULL +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE utf8mb4_unicode_520_ci; +ALTER TABLE `{tbl_prefix}user_memberships` + ADD CONSTRAINT `user_membership_user` FOREIGN KEY (`userid`) REFERENCES `{tbl_prefix}users` (`userid`) ON DELETE RESTRICT ON UPDATE RESTRICT; +ALTER TABLE `{tbl_prefix}user_memberships` + ADD CONSTRAINT `user_membership_membership` FOREIGN KEY (`id_membership`) REFERENCES `{tbl_prefix}memberships` (`id_membership`) ON DELETE RESTRICT ON UPDATE RESTRICT; diff --git a/upload/includes/classes/ClipBucket.class.php b/upload/includes/classes/ClipBucket.class.php index f83c0e59d..b4e5e1fea 100644 --- a/upload/includes/classes/ClipBucket.class.php +++ b/upload/includes/classes/ClipBucket.class.php @@ -407,6 +407,19 @@ function initAdminMenu() $this->addMenuAdmin($menu_configuration, 2); + if (config('enable_membership') == 'yes') { + $menu_subscriptions = [ + 'title' => lang('memberships'), + 'class' => 'icon- fa fa-credit-card-alt', + 'sub' => [ + [ + 'title'=>lang('user_levels'), + 'url' =>DirPath::getUrl('admin_area') . 'memberships.php' + ] + ] + ]; + $this->addMenuAdmin($menu_subscriptions, 3); + } if (NEED_UPDATE) { return; } diff --git a/upload/includes/classes/membership.class.php b/upload/includes/classes/membership.class.php new file mode 100644 index 000000000..3d5d1f3b4 --- /dev/null +++ b/upload/includes/classes/membership.class.php @@ -0,0 +1,263 @@ +tablename = 'memberships'; + $this->tablename_user_membership = 'user_memberships'; + + $this->fields = [ + 'id_membership', + 'user_level_id', + 'frequency', + 'base_price', + 'description', + 'storage_quota_included', + 'storage_price_per_go', + 'disabled', + ]; + + $this->fields_user_membership = [ + 'id_user_membership', + 'userid', + 'id_membership', + 'date_start', + 'date_end', + 'price' + ]; + + $this->frequencies = [ + 'daily', + 'weekly', + 'monthly', + 'yearly', + ]; + } + + /** + * @return string[] + */ + public function getFrequencies(): array + { + return $this->frequencies; + } + public function getTablename(): string + { + return $this->tablename; + } + + /** + * @param array $params + * @return array|int|mixed + * @throws Exception + */ + public function getOne(array $params) + { + $params['first_only'] = true; + return $this->getAll($params); + } + + /** + * @throws Exception + */ + public function getAll(array $params) + { + $param_group = $params['group'] ?? false; + $param_having = $params['having'] ?? false; + $param_order = $params['order'] ?? false; + $param_count = $params['count'] ?? false; + $param_limit = $params['limit'] ?? false; + $param_user_level_id = $params['user_level_id'] ?? false; + $param_id_membership = $params['id_membership'] ?? false; + $param_userid = $params['userid'] ?? false; + $param_first_only = $params['first_only'] ?? false; + + $conditions = []; + if ($param_id_membership !== false) { + $conditions[] = $this->tablename . '.id_membership = \'' . mysql_clean($param_id_membership) . '\''; + } + if ($param_user_level_id !== false) { + $conditions[] = $this->tablename . '.user_level_id = \'' . mysql_clean($param_user_level_id) . '\''; + } + if ($param_userid !== false) { + $conditions[] = $this->tablename_user_membership . '.userid = \'' . mysql_clean($param_userid) . '\''; + } + + if ($param_group) { + $group[] = $param_group; + } + + $having = ''; + if ($param_having) { + $having = ' HAVING ' . $param_having; + } + + $order = ''; + if ($param_order && !$param_count) { + $group[] = str_replace([ + 'asc', + 'desc' + ], '', strtolower($param_order)); + $order = ' ORDER BY ' . $param_order; + } + + $limit = ''; + if ($param_limit) { + $limit = ' LIMIT ' . $param_limit; + } + + if ($param_count) { + $select = ['COUNT(DISTINCT ' . $this->tablename . '.id_membership) AS count']; + } else { + $select = $this->getSQLFields('membership'); + $select[] = 'user_levels.user_level_name'; + $select[] = $this->tablename_user_membership.'.id_user_membership'; + } + + $join = []; + + $join[] = ' LEFT JOIN ' . cb_sql_table('user_levels') . ' ON user_levels.user_level_id = ' . $this->tablename . '.user_level_id'; + $join[] = ' LEFT JOIN ' . cb_sql_table($this->tablename_user_membership) . ' ON '.$this->tablename_user_membership.'.id_membership = ' . $this->tablename . '.id_membership'; + + $sql = 'SELECT ' . implode(', ', $select) . ' + FROM ' . cb_sql_table($this->tablename) + . implode(' ', $join) + . (empty($conditions) ? '' : ' WHERE ' . implode(' AND ', $conditions)) + . (empty($group) ? '' : ' GROUP BY ' . implode(',', $group)) + . $having + . $order + . $limit; + + $result = Clipbucket_db::getInstance()->_select($sql); + + if ($param_count) { + if (empty($result)) { + return 0; + } + return $result[0]['count']; + } + + if (!$result) { + return []; + } + + if ($param_first_only) { + return $result[0]; + } + + return $result; + + } + + private function getSQLFields($type = '', $prefix = false): array + { + switch ($type) { + case 'membership': + default: + $fields = $this->fields; + $tablename = $this->tablename; + break; + + case 'user_membership': + $fields = $this->fields_user_membership; + $tablename = $this->tablename_user_membership; + break; + } + + return array_map(function ($field) use ($prefix, $tablename) { + $field_name = $tablename . '.' . $field; + if ($prefix) { + $field_name .= ' AS `' . $tablename . '.' . $field . '`'; + } + return $field_name; + }, $fields); + } + + public static function getInstance(): self + { + if (empty(self::$membership)) { + self::$membership = new self(); + } + return self::$membership; + } + + /** + * @param array $membership + * @return bool|mysqli_result + * @throws Exception + */ + public function update(array $membership) + { + $sql = 'UPDATE ' . tbl($this->tablename) . ' SET '; + $updated_fields = []; + foreach ($this->fields as $field) { + if ($field == 'id_membership') { + continue; + } + if (isset($membership[$field])) { + if ((int)$membership[$field] == $membership[$field]) { + $value = mysql_clean($membership[$field]); + } else { + $value = '\'' . mysql_clean($membership[$field]) . '\''; + } + $updated_fields[] = $field . ' = ' . $value; + } + } + $sql .= implode(', ', $updated_fields) . ' WHERE id_membership = ' . mysql_clean($membership['id_membership']); + return Clipbucket_db::getInstance()->execute($sql); + } + + /** + * @param array $membership + * @return bool|mysqli_result + * @throws Exception + */ + public function insert(array $membership) + { + $sql = 'INSERT INTO ' . tbl($this->tablename) . ' '; + $fields = []; + $values = []; + foreach ($this->fields as $field) { + if ($field == 'id_membership') { + continue; + } + if (isset($membership[$field])) { + $fields[] = $field; + if ((int)$membership[$field] == $membership[$field]) { + $value = mysql_clean($membership[$field]); + } else { + $value = '\'' . mysql_clean($membership[$field]) . '\''; + } + $values[] = $value; + } + } + $sql .= ' (' . implode(', ', $fields) . ') VALUES (' . implode(', ', $values) . ') '; + Clipbucket_db::getInstance()->execute($sql); + return Clipbucket_db::getInstance()->insert_id(); + } + + + + public function delete(int $id_membership): bool + { + if (empty($id_membership)) { + e(lang('missing_param')); + return false; + } + return Clipbucket_db::getInstance()->execute('DELETE FROM ' . tbl($this->tablename) . ' WHERE id_membership = ' . mysql_clean($id_membership)); + } + +} \ No newline at end of file diff --git a/upload/includes/classes/session_message_handler.class.php b/upload/includes/classes/session_message_handler.class.php index 35ee815be..6cbf47289 100644 --- a/upload/includes/classes/session_message_handler.class.php +++ b/upload/includes/classes/session_message_handler.class.php @@ -1,6 +1,6 @@ getFields(); + $tablename = $this->getTableName(); break; case 'categories': $fields = $this->getFieldsCategories(); + $tablename = $this->getTableNameCategories(); break; } - return array_map(function($field) use ($prefix) { - $field_name = $this->getTableName() . '.' . $field; - if( $prefix ){ - $field_name .= ' AS `'.$this->getTableName() . '.' . $field.'`'; + return array_map(function ($field) use ($prefix, $tablename) { + $field_name = $tablename . '.' . $field; + if ($prefix) { + $field_name .= ' AS `' . $tablename . '.' . $field . '`'; } return $field_name; }, $fields); diff --git a/upload/includes/common.php b/upload/includes/common.php index 2f3cb8648..d3775ede9 100644 --- a/upload/includes/common.php +++ b/upload/includes/common.php @@ -92,6 +92,7 @@ require_once DirPath::get('classes') . 'system.class.php'; require_once DirPath::get('classes') . 'network.class.php'; require_once DirPath::get('classes') . 'social_networks.class.php'; +require_once DirPath::get('classes') . 'membership.class.php'; $cb_columns = new cb_columns(); $myquery = new myquery(); @@ -124,7 +125,7 @@ $pages = new pages(); $eh = new errorhandler(); -foreach (sessionMessageHandler::get_messages() as $message) { +foreach (SessionMessageHandler::get_messages() as $message) { $eh->e($message['message'], $message['type']); } From 9224613d3a52dc5d9ca9d690b9c5744dab69199f Mon Sep 17 00:00:00 2001 From: clement-sanz Date: Tue, 1 Oct 2024 12:02:40 +0200 Subject: [PATCH 02/59] 307 update install sql disabled storage vals if config is disabled --- .../cb_2014/layout/edit_membership.html | 65 +++++++++++++------ upload/cb_install/sql/5.5.1/MWIP.php | 5 ++ upload/cb_install/sql/configs.sql | 3 +- upload/cb_install/sql/language_ENG.sql | 36 ++++++++++ upload/cb_install/sql/language_FRA.sql | 38 ++++++++++- upload/cb_install/sql/languages.sql | 20 +++++- 6 files changed, 144 insertions(+), 23 deletions(-) diff --git a/upload/admin_area/styles/cb_2014/layout/edit_membership.html b/upload/admin_area/styles/cb_2014/layout/edit_membership.html index 77e10f8c9..98af67dae 100644 --- a/upload/admin_area/styles/cb_2014/layout/edit_membership.html +++ b/upload/admin_area/styles/cb_2014/layout/edit_membership.html @@ -19,8 +19,8 @@

{lang('editing')}

{else} -

{lang('creation')} - {/if} +

{lang('creation')} + {/if}
@@ -33,49 +33,74 @@

{lang('creation')} - +
+ +
- +
+ +
- +
+
- +
+
- +
+ +
+ + {if config('enable_storage_history')=='no'} + Tips + {/if} - +
+
+ +
+ {if config('enable_storage_history')=='no'} + Tips + {/if} +
diff --git a/upload/cb_install/sql/5.5.1/MWIP.php b/upload/cb_install/sql/5.5.1/MWIP.php index 5415558ed..b49b86e17 100644 --- a/upload/cb_install/sql/5.5.1/MWIP.php +++ b/upload/cb_install/sql/5.5.1/MWIP.php @@ -139,5 +139,10 @@ public function start() 'fr'=>'Création', 'en'=>'Creation' ]); + + self::generateTranslation('must_activate_storage_history', [ + 'fr'=>'Vous devez activer l\'option "Activer l\'historique de stockage" pour éditer ce champs', + 'en'=>'You must activate option "Activate storage history" to edit this field' + ]); } } diff --git a/upload/cb_install/sql/configs.sql b/upload/cb_install/sql/configs.sql index 9decb279d..987cc2565 100644 --- a/upload/cb_install/sql/configs.sql +++ b/upload/cb_install/sql/configs.sql @@ -304,7 +304,8 @@ INSERT INTO `{tbl_prefix}config` (`configid`, `name`, `value`) VALUES (NULL, 'home_display_recent_videos', 'yes'), (NULL, 'enable_video_view_history', 'no'), (NULL, 'enable_access_view_video_history', 'no'), - (NULL, 'video_list_view_video_history', 30); + (NULL, 'video_list_view_video_history', 30), + (NULL, 'enable_membership', 'no'); INSERT INTO `{tbl_prefix}video_resolution` (`title`, `ratio`, `enabled`, `width`, `height`, `video_bitrate`) VALUES ('240p', '16/9', 1, 428, 240, 240000), diff --git a/upload/cb_install/sql/language_ENG.sql b/upload/cb_install/sql/language_ENG.sql index 9c7b24bac..b4a024fd5 100644 --- a/upload/cb_install/sql/language_ENG.sql +++ b/upload/cb_install/sql/language_ENG.sql @@ -2577,3 +2577,39 @@ INSERT INTO `{tbl_prefix}languages_translations` (`id_language_key`, `translatio VALUES ((SELECT id_language_key FROM `{tbl_prefix}languages_keys` WHERE `language_key` = 'writeable'), 'Writeable', @language_id); INSERT INTO `{tbl_prefix}languages_translations` (`id_language_key`, `translation`, `language_id`) VALUES ((SELECT id_language_key FROM `{tbl_prefix}languages_keys` WHERE `language_key` = 'chmod_file'), 'Please chmod this file/directory to 755', @language_id); +INSERT INTO `{tbl_prefix}languages_translations` (`id_language_key`, `translation`, `language_id`) +VALUES ((SELECT id_language_key FROM `{tbl_prefix}languages_keys` WHERE `language_key` = 'enable_membership'), 'Enable membership', @language_id); +INSERT INTO `{tbl_prefix}languages_translations` (`id_language_key`, `translation`, `language_id`) +VALUES ((SELECT id_language_key FROM `{tbl_prefix}languages_keys` WHERE `language_key` = 'memberships'), 'Membership', @language_id); +INSERT INTO `{tbl_prefix}languages_translations` (`id_language_key`, `translation`, `language_id`) +VALUES ((SELECT id_language_key FROM `{tbl_prefix}languages_keys` WHERE `language_key` = 'storage_price'), 'Storage price', @language_id); +INSERT INTO `{tbl_prefix}languages_translations` (`id_language_key`, `translation`, `language_id`) +VALUES ((SELECT id_language_key FROM `{tbl_prefix}languages_keys` WHERE `language_key` = 'storage_quota'), 'Storage quota', @language_id); +INSERT INTO `{tbl_prefix}languages_translations` (`id_language_key`, `translation`, `language_id`) +VALUES ((SELECT id_language_key FROM `{tbl_prefix}languages_keys` WHERE `language_key` = 'storage_quota_included'), 'Storage quota included', @language_id); +INSERT INTO `{tbl_prefix}languages_translations` (`id_language_key`, `translation`, `language_id`) +VALUES ((SELECT id_language_key FROM `{tbl_prefix}languages_keys` WHERE `language_key` = 'base_price'), 'Base price', @language_id); +INSERT INTO `{tbl_prefix}languages_translations` (`id_language_key`, `translation`, `language_id`) +VALUES ((SELECT id_language_key FROM `{tbl_prefix}languages_keys` WHERE `language_key` = 'frequency'), 'Frequency', @language_id); +INSERT INTO `{tbl_prefix}languages_translations` (`id_language_key`, `translation`, `language_id`) +VALUES ((SELECT id_language_key FROM `{tbl_prefix}languages_keys` WHERE `language_key` = 'frequency_daily'), 'Daily', @language_id); +INSERT INTO `{tbl_prefix}languages_translations` (`id_language_key`, `translation`, `language_id`) +VALUES ((SELECT id_language_key FROM `{tbl_prefix}languages_keys` WHERE `language_key` = 'frequency_weekly'), 'Weekly', @language_id); +INSERT INTO `{tbl_prefix}languages_translations` (`id_language_key`, `translation`, `language_id`) +VALUES ((SELECT id_language_key FROM `{tbl_prefix}languages_keys` WHERE `language_key` = 'frequency_monthly'), 'Monthly', @language_id); +INSERT INTO `{tbl_prefix}languages_translations` (`id_language_key`, `translation`, `language_id`) +VALUES ((SELECT id_language_key FROM `{tbl_prefix}languages_keys` WHERE `language_key` = 'frequency_yearly'), 'Yearly', @language_id); +INSERT INTO `{tbl_prefix}languages_translations` (`id_language_key`, `translation`, `language_id`) +VALUES ((SELECT id_language_key FROM `{tbl_prefix}languages_keys` WHERE `language_key` = 'editing'), 'Editing', @language_id); +INSERT INTO `{tbl_prefix}languages_translations` (`id_language_key`, `translation`, `language_id`) +VALUES ((SELECT id_language_key FROM `{tbl_prefix}languages_keys` WHERE `language_key` = 'add_membership'), 'Add membership level', @language_id); +INSERT INTO `{tbl_prefix}languages_translations` (`id_language_key`, `translation`, `language_id`) +VALUES ((SELECT id_language_key FROM `{tbl_prefix}languages_keys` WHERE `language_key` = 'edit_membership'), 'Edit membership level', @language_id); +INSERT INTO `{tbl_prefix}languages_translations` (`id_language_key`, `translation`, `language_id`) +VALUES ((SELECT id_language_key FROM `{tbl_prefix}languages_keys` WHERE `language_key` = 'membership_deleted'), 'Membership has been deleted', @language_id); +INSERT INTO `{tbl_prefix}languages_translations` (`id_language_key`, `translation`, `language_id`) +VALUES ((SELECT id_language_key FROM `{tbl_prefix}languages_keys` WHERE `language_key` = 'cant_delete_membership_at_least_one_user'), 'Cannot delete this membership, at least one user subscribe to it', @language_id); +INSERT INTO `{tbl_prefix}languages_translations` (`id_language_key`, `translation`, `language_id`) +VALUES ((SELECT id_language_key FROM `{tbl_prefix}languages_keys` WHERE `language_key` = 'creation'), 'Creation', @language_id); +INSERT INTO `{tbl_prefix}languages_translations` (`id_language_key`, `translation`, `language_id`) +VALUES ((SELECT id_language_key FROM `{tbl_prefix}languages_keys` WHERE `language_key` = 'must_activate_storage_history'), 'You must activate option "Activate storage history" to edit this field', @language_id); diff --git a/upload/cb_install/sql/language_FRA.sql b/upload/cb_install/sql/language_FRA.sql index ab16f9ee5..fd1157c12 100644 --- a/upload/cb_install/sql/language_FRA.sql +++ b/upload/cb_install/sql/language_FRA.sql @@ -1758,7 +1758,7 @@ VALUES ((SELECT id_language_key FROM `{tbl_prefix}languages_keys` WHERE `languag INSERT INTO `{tbl_prefix}languages_translations` (`id_language_key`, `translation`, `language_id`) VALUES ((SELECT id_language_key FROM `{tbl_prefix}languages_keys` WHERE `language_key` = 'assign_default_thumb_label'), 'Assigner la vignette par défaut des collections', @language_id); INSERT INTO `{tbl_prefix}languages_translations` (`id_language_key`, `translation`, `language_id`) -VALUES ((SELECT id_language_key FROM `{tbl_prefix}languages_keys` WHERE `language_key` = 'assign_default_thumb_description'), 'ssigne aux collection la vignette par défaut du premier élément de la collection', @language_id); +VALUES ((SELECT id_language_key FROM `{tbl_prefix}languages_keys` WHERE `language_key` = 'assign_default_thumb_description'), 'Assigne aux collection la vignette par défaut du premier élément de la collection', @language_id); INSERT INTO `{tbl_prefix}languages_translations` (`id_language_key`, `translation`, `language_id`) VALUES ((SELECT id_language_key FROM `{tbl_prefix}languages_keys` WHERE `language_key` = 'default_thumb'), 'Vignette par défaut', @language_id); INSERT INTO `{tbl_prefix}languages_translations` (`id_language_key`, `translation`, `language_id`) @@ -1771,3 +1771,39 @@ INSERT INTO `{tbl_prefix}languages_translations` (`id_language_key`, `translatio VALUES ((SELECT id_language_key FROM `{tbl_prefix}languages_keys` WHERE `language_key` = 'writeable'), 'Accessible en écriture', @language_id); INSERT INTO `{tbl_prefix}languages_translations` (`id_language_key`, `translation`, `language_id`) VALUES ((SELECT id_language_key FROM `{tbl_prefix}languages_keys` WHERE `language_key` = 'chmod_file'), 'Veuillez exécuter la commande chmod 755 sur ce fichier/dossier', @language_id); +INSERT INTO `{tbl_prefix}languages_translations` (`id_language_key`, `translation`, `language_id`) +VALUES ((SELECT id_language_key FROM `{tbl_prefix}languages_keys` WHERE `language_key` = 'enable_membership'), 'Activer les abonnements', @language_id); +INSERT INTO `{tbl_prefix}languages_translations` (`id_language_key`, `translation`, `language_id`) +VALUES ((SELECT id_language_key FROM `{tbl_prefix}languages_keys` WHERE `language_key` = 'memberships'), 'Abonnements', @language_id); +INSERT INTO `{tbl_prefix}languages_translations` (`id_language_key`, `translation`, `language_id`) +VALUES ((SELECT id_language_key FROM `{tbl_prefix}languages_keys` WHERE `language_key` = 'storage_price'), 'Prix de stockage', @language_id); +INSERT INTO `{tbl_prefix}languages_translations` (`id_language_key`, `translation`, `language_id`) +VALUES ((SELECT id_language_key FROM `{tbl_prefix}languages_keys` WHERE `language_key` = 'storage_quota'), 'Quota de stockage', @language_id); +INSERT INTO `{tbl_prefix}languages_translations` (`id_language_key`, `translation`, `language_id`) +VALUES ((SELECT id_language_key FROM `{tbl_prefix}languages_keys` WHERE `language_key` = 'storage_quota_included'), 'Quota de stockage inclus', @language_id); +INSERT INTO `{tbl_prefix}languages_translations` (`id_language_key`, `translation`, `language_id`) +VALUES ((SELECT id_language_key FROM `{tbl_prefix}languages_keys` WHERE `language_key` = 'base_price'), 'Prix initial', @language_id); +INSERT INTO `{tbl_prefix}languages_translations` (`id_language_key`, `translation`, `language_id`) +VALUES ((SELECT id_language_key FROM `{tbl_prefix}languages_keys` WHERE `language_key` = 'frequency'), 'Fréquence', @language_id); +INSERT INTO `{tbl_prefix}languages_translations` (`id_language_key`, `translation`, `language_id`) +VALUES ((SELECT id_language_key FROM `{tbl_prefix}languages_keys` WHERE `language_key` = 'frequency_daily'), 'Journalier', @language_id); +INSERT INTO `{tbl_prefix}languages_translations` (`id_language_key`, `translation`, `language_id`) +VALUES ((SELECT id_language_key FROM `{tbl_prefix}languages_keys` WHERE `language_key` = 'frequency_weekly'), 'Hebdomadaire', @language_id); +INSERT INTO `{tbl_prefix}languages_translations` (`id_language_key`, `translation`, `language_id`) +VALUES ((SELECT id_language_key FROM `{tbl_prefix}languages_keys` WHERE `language_key` = 'frequency_monthly'), 'Mensuel', @language_id); +INSERT INTO `{tbl_prefix}languages_translations` (`id_language_key`, `translation`, `language_id`) +VALUES ((SELECT id_language_key FROM `{tbl_prefix}languages_keys` WHERE `language_key` = 'frequency_yearly'), 'Annuel', @language_id); +INSERT INTO `{tbl_prefix}languages_translations` (`id_language_key`, `translation`, `language_id`) +VALUES ((SELECT id_language_key FROM `{tbl_prefix}languages_keys` WHERE `language_key` = 'editing'), 'Edition', @language_id); +INSERT INTO `{tbl_prefix}languages_translations` (`id_language_key`, `translation`, `language_id`) +VALUES ((SELECT id_language_key FROM `{tbl_prefix}languages_keys` WHERE `language_key` = 'add_membership'), 'Ajouter un niveau d''abonnement', @language_id); +INSERT INTO `{tbl_prefix}languages_translations` (`id_language_key`, `translation`, `language_id`) +VALUES ((SELECT id_language_key FROM `{tbl_prefix}languages_keys` WHERE `language_key` = 'edit_membership'), 'Editer un niveau d''abonnement', @language_id); +INSERT INTO `{tbl_prefix}languages_translations` (`id_language_key`, `translation`, `language_id`) +VALUES ((SELECT id_language_key FROM `{tbl_prefix}languages_keys` WHERE `language_key` = 'membership_deleted'), 'L''abonnement a été supprimé', @language_id); +INSERT INTO `{tbl_prefix}languages_translations` (`id_language_key`, `translation`, `language_id`) +VALUES ((SELECT id_language_key FROM `{tbl_prefix}languages_keys` WHERE `language_key` = 'cant_delete_membership_at_least_one_user'), 'Impossible de supprimer l''abonnement car au moins un utilisateur y est attaché', @language_id); +INSERT INTO `{tbl_prefix}languages_translations` (`id_language_key`, `translation`, `language_id`) +VALUES ((SELECT id_language_key FROM `{tbl_prefix}languages_keys` WHERE `language_key` = 'creation'), 'Création', @language_id); +INSERT INTO `{tbl_prefix}languages_translations` (`id_language_key`, `translation`, `language_id`) +VALUES ((SELECT id_language_key FROM `{tbl_prefix}languages_keys` WHERE `language_key` = 'must_activate_storage_history'), 'Vous devez activer l''option "Activer l''historique de stockage" pour éditer ce champs', @language_id); diff --git a/upload/cb_install/sql/languages.sql b/upload/cb_install/sql/languages.sql index bff16a08e..d983bbfc3 100644 --- a/upload/cb_install/sql/languages.sql +++ b/upload/cb_install/sql/languages.sql @@ -1288,4 +1288,22 @@ VALUES ('admin_setting'), ('add_collection'), ('permissions'), ('writeable'), - ('chmod_file'); \ No newline at end of file + ('chmod_file'), + ('enable_membership'), + ('memberships'), + ('storage_price'), + ('storage_quota'), + ('storage_quota_included'), + ('base_price'), + ('frequency'), + ('frequency_daily'), + ('frequency_weekly'), + ('frequency_monthly'), + ('frequency_yearly'), + ('creation'), + ('editing'), + ('add_membership'), + ('edit_membership'), + ('membership_deleted'), + ('cant_delete_membership_at_least_one_user'), + ('must_activate_storage_history'); \ No newline at end of file From 1661081a047cb72a63dee54417abbb5f71e23d10 Mon Sep 17 00:00:00 2001 From: clement-sanz Date: Wed, 2 Oct 2024 14:40:42 +0200 Subject: [PATCH 03/59] 307 display memberships users --- upload/actions/admin_activate_membership.php | 23 +++++ .../actions/admin_get_membership_history.php | 24 ++++++ upload/actions/video_view_history.php | 2 +- .../layout/blocks/membership_search.html | 38 ++++++++ .../blocks/membership_view_history.html | 48 +++++++++++ .../cb_2014/layout/edit_membership.html | 7 +- .../styles/cb_2014/layout/memberships.html | 4 +- .../cb_2014/layout/users_memberships.html | 56 ++++++++++++ .../styles/cb_2014/theme/css/styles.css | 4 + .../styles/cb_2014/theme/css/styles.min.css | 2 +- .../pages/membership/edit_membership.min.js | 1 + .../js/pages/membership/memberships.min.js | 1 + .../js/pages/membership/users_memberships.js | 42 +++++++++ .../pages/membership/users_memberships.min.js | 1 + upload/admin_area/users_memberships.php | 63 ++++++++++++++ upload/cb_install/sql/5.5.1/MWIP.php | 42 +++++++++ upload/cb_install/sql/language_ENG.sql | 18 ++++ upload/cb_install/sql/language_FRA.sql | 18 ++++ upload/cb_install/sql/languages.sql | 11 ++- upload/includes/classes/ClipBucket.class.php | 4 + upload/includes/classes/membership.class.php | 86 ++++++++++++++++--- upload/includes/classes/user.class.php | 19 +++- upload/includes/functions_template.php | 12 +++ 23 files changed, 501 insertions(+), 25 deletions(-) create mode 100644 upload/actions/admin_activate_membership.php create mode 100644 upload/actions/admin_get_membership_history.php create mode 100644 upload/admin_area/styles/cb_2014/layout/blocks/membership_search.html create mode 100644 upload/admin_area/styles/cb_2014/layout/blocks/membership_view_history.html create mode 100644 upload/admin_area/styles/cb_2014/layout/users_memberships.html create mode 100644 upload/admin_area/styles/cb_2014/theme/js/pages/membership/edit_membership.min.js create mode 100644 upload/admin_area/styles/cb_2014/theme/js/pages/membership/memberships.min.js create mode 100644 upload/admin_area/styles/cb_2014/theme/js/pages/membership/users_memberships.js create mode 100644 upload/admin_area/styles/cb_2014/theme/js/pages/membership/users_memberships.min.js create mode 100644 upload/admin_area/users_memberships.php diff --git a/upload/actions/admin_activate_membership.php b/upload/actions/admin_activate_membership.php new file mode 100644 index 000000000..a2cf479a1 --- /dev/null +++ b/upload/actions/admin_activate_membership.php @@ -0,0 +1,23 @@ +admin_login_check(); + +$id_membership = $_POST['id_membership']; +$membership = Membership::getInstance()->getOne(['id_membership'=>$id_membership]); +if (!empty($membership['id_user_membership'])) { + e(lang('cant_delete_membership_at_least_one_user')); + $success = false; +} else { + $success = Membership::getInstance()->delete($id_membership); +} +if ($success) { + e(lang('membership_deleted'), 'm'); +} +$url=''; +if (!empty($_POST['redirect'])) { + SessionMessageHandler::add_message(lang('membership_deleted')); + $url = BASEURL . DirPath::getUrl('admin_area') .'memberships.php'; +} +echo json_encode(['msg'=>getTemplateMsg(), 'success'=>$success, 'url'=>$url]); diff --git a/upload/actions/admin_get_membership_history.php b/upload/actions/admin_get_membership_history.php new file mode 100644 index 000000000..e956dd357 --- /dev/null +++ b/upload/actions/admin_get_membership_history.php @@ -0,0 +1,24 @@ +admin_login_check(); + +if (!empty($_POST['page'])) { + $sql_limit = create_query_limit($_POST['page'], config('video_list_view_video_history')); +} +$params = [ + 'userid' => $_POST['userid'], + 'limit' => $sql_limit ?? '', + 'order' => ' date_start DESC ' +]; +$results = Membership::getInstance()->getAllHistoMembershipForUser($params); +$params['count'] = true; +unset($params['limit']); +$totals_pages = count_pages(Membership::getInstance()->getAllHistoMembershipForUser($params), config('video_list_view_video_history')) ; +pages::getInstance()->paginate($totals_pages, $_POST['page'], 'javascript:pageViewHistory(#page#, ' . $_POST['userid'] . ');'); + +display_user_membership_history([ + 'results' => $results, + 'modal' => ($_POST['modal'] ?? true) +], $_POST['userid']); diff --git a/upload/actions/video_view_history.php b/upload/actions/video_view_history.php index 903542f1c..006ab9746 100644 --- a/upload/actions/video_view_history.php +++ b/upload/actions/video_view_history.php @@ -1,5 +1,5 @@ + + {lang code="com_advance_results"} + + + + + + \ No newline at end of file diff --git a/upload/admin_area/styles/cb_2014/layout/blocks/membership_view_history.html b/upload/admin_area/styles/cb_2014/layout/blocks/membership_view_history.html new file mode 100644 index 000000000..bc7849e8d --- /dev/null +++ b/upload/admin_area/styles/cb_2014/layout/blocks/membership_view_history.html @@ -0,0 +1,48 @@ +{if $modal === true} + + +{/if} diff --git a/upload/admin_area/styles/cb_2014/layout/edit_membership.html b/upload/admin_area/styles/cb_2014/layout/edit_membership.html index 98af67dae..dda7dc740 100644 --- a/upload/admin_area/styles/cb_2014/layout/edit_membership.html +++ b/upload/admin_area/styles/cb_2014/layout/edit_membership.html @@ -7,11 +7,8 @@

{lang('editing')} Actions