diff --git a/cms/pages/modules/cms_galleries.php b/cms/pages/modules/cms_galleries.php index 1cbe9e6ea..c071dec96 100644 --- a/cms/pages/modules/cms_galleries.php +++ b/cms/pages/modules/cms_galleries.php @@ -290,6 +290,13 @@ class Module_cms_galleries extends Standard_crud_module $allow_images = ($GLOBALS['SITE_DB']->query_select_value('galleries', 'COUNT(*)', array('accept_images' => 1)) > 0); $allow_videos = ($GLOBALS['SITE_DB']->query_select_value('galleries', 'COUNT(*)', array('accept_videos' => 1)) > 0); + if (!$this->has_enough_points('points_ADD_IMAGE')) { + $allow_images = false; + } + if (!$this->has_enough_points('points_ADD_VIDEO')) { + $allow_videos = false; + } + require_code('templates_donext'); require_code('fields'); return do_next_manager(get_screen_title('MANAGE_GALLERIES'), comcode_lang_string('DOC_GALLERIES'), @@ -1093,6 +1100,29 @@ class Module_cms_galleries extends Standard_crud_module return array($tree, $search_url, $archive_url); } + protected function has_enough_points($config_option) + { + $points = intval(get_option($config_option)); + + if ($points < 0) { + require_code('points'); + + if ((!has_privilege(get_member(), 'have_negative_gift_points')) && (available_points(get_member()) < -$points)) { + return false; + } + } + + return true; + } + + protected function check_available_points($config_option) + { + if (!$this->has_enough_points($config_option)) { + $points = intval(get_option($config_option)); + warn_exit('You do not have the ' . integer_format(-$points) . ' points needed to add this.'); + } + } + /** * Get Tempcode for an image adding/editing form. * @@ -1112,6 +1142,15 @@ class Module_cms_galleries extends Standard_crud_module */ public function get_form_fields($id = null, $title = '', $cat = '', $description = '', $url = '', $thumb_url = '', $validated = 1, $allow_rating = null, $allow_comments = null, $allow_trackbacks = null, $notes = '', $regions = null) { + if ($id === null) { + $this->check_available_points('points_ADD_IMAGE'); + + $points = intval(get_option('points_ADD_IMAGE')); + if ($points < 0) { + attach_message('Adding this will cost you ' . integer_format(-$points) . ' points.'); + } + } + list($allow_rating, $allow_comments, $allow_trackbacks) = $this->choose_feedback_fields_statistically($allow_rating, $allow_comments, $allow_trackbacks); $num_galleries = $GLOBALS['SITE_DB']->query_select_value('galleries', 'COUNT(*)', array('accept_images' => 1)); @@ -1322,6 +1361,8 @@ class Module_cms_galleries extends Standard_crud_module */ public function add_actualisation() { + $this->check_available_points('points_ADD_IMAGE'); + $title = post_param_string('title', ''); $description = post_param_string('description', ''); @@ -1719,6 +1760,15 @@ class Module_cms_galleries_alt extends Standard_crud_module */ public function get_form_fields($id = null, $title = '', $cat = '', $description = '', $url = '', $thumb_url = '', $validated = 1, $allow_rating = null, $allow_comments = null, $allow_trackbacks = null, $notes = '', $video_length = null, $video_width = null, $video_height = null, $regions = null) { + if ($id === null) { + $this->check_available_points('points_ADD_VIDEO'); + + $points = intval(get_option('points_ADD_VIDEO')); + if ($points < 0) { + attach_message('Adding this will cost you ' . integer_format(-$points) . ' points.'); + } + } + list($allow_rating, $allow_comments, $allow_trackbacks) = $this->choose_feedback_fields_statistically($allow_rating, $allow_comments, $allow_trackbacks); $no_thumb_needed = (get_option('ffmpeg_path') != '') || (class_exists('ffmpeg_movie')); @@ -1933,6 +1983,8 @@ class Module_cms_galleries_alt extends Standard_crud_module */ public function add_actualisation() { + $this->check_available_points('points_ADD_VIDEO'); + $title = post_param_string('title'); $description = post_param_string('description', '');