/** * Find whether this content type has a tied catalogue. * * @return boolean Whether it has */ function has_tied_catalogue() { if (!is_null($this->award_type)) { require_code('fields'); return has_tied_catalogue($this->award_type); } return false; }
/** * The actualiser to delete a topic. * * @return tempcode The UI */ function _delete_topic() { $topic_id = get_param_integer('id'); $post_target_topic_id = post_param_integer('select_topic_id', -1); if ($post_target_topic_id == -1) { $post_target_topic_id = post_param_integer('manual_topic_id', -1); } if ($post_target_topic_id == -1) { $post_target_topic_id = NULL; } require_code('ocf_topics_action'); require_code('ocf_topics_action2'); $forum_id = ocf_delete_topic($topic_id, post_param('reason'), $post_target_topic_id); require_code('fields'); if (has_tied_catalogue('topic')) { delete_form_custom_fields('topic', strval($topic_id)); } return $this->redirect_to_forum('DELETE_TOPIC', $forum_id); }
/** * Save meta data into content type's custom fields, by looking for fields named after the EXIF/EXIF-emulated meta data (specifically in English). * Spaces may be added to the names to make them prettier, but otherwise they must be the same. * Designed to be used by headless-importers, e.g. bulk importing of media files, to make the process a bit smarter. * * @param ID_TEXT The content type * @param ID_TEXT The content ID * @param array The EXIF data * @param ?array Extra meta data to store, against explicit field IDs (NULL: none) */ function store_exif($content_type, $content_id, $exif, $map = NULL) { require_code('fields'); if (!has_tied_catalogue($content_type)) { return; } // Get field values $fields = $GLOBALS['SITE_DB']->query_select('catalogue_fields', array('id', 'cf_name'), array('c_name' => '_' . $content_type), 'ORDER BY cf_order'); if (is_null($map)) { $map = array(); } foreach ($fields as $field) { $name = get_translated_text($field['cf_name'], NULL, 'EN'); if (isset($exif[$name])) { $map[$field['id']] = $exif[$name]; } elseif (isset($exif[str_replace(' ', '', $name)])) { $map[$field['id']] = $exif[str_replace(' ', '', $name)]; } elseif (!isset($map[$field['id']])) { $map[$field['id']] = ''; } if (isset($map[$field['id']])) { if (!is_string($map[$field['id']])) { $map[$field['id']] = strval($map[$field['id']]); } } } if (count($map) == 0) { return; } $first_cat = $GLOBALS['SITE_DB']->query_value_null_ok('catalogue_categories', 'MIN(id)', array('c_name' => '_' . $content_type)); require_code('catalogues2'); $test = $GLOBALS['SITE_DB']->query_value_null_ok('catalogue_entry_linkage', 'catalogue_entry_id', array('content_type' => $content_type, 'content_id' => $content_id)); if (is_null($test)) { $catalogue_entry_id = actual_add_catalogue_entry($first_cat, 1, '', 0, 0, 0, $map); $GLOBALS['SITE_DB']->query_insert('catalogue_entry_linkage', array('catalogue_entry_id' => $catalogue_entry_id, 'content_type' => $content_type, 'content_id' => $content_id)); } else { // Cannot handle this } }
/** * The actualiser to add an author. * * @return tempcode The UI */ function __ad() { $title = get_page_title('DEFINE_AUTHOR'); $author = post_param('author', get_param('author')); if (!has_edit_author_permission(get_member(), $author)) { access_denied('SPECIFIC_PERMISSION', 'edit_midrange_content'); } if ($author == '') { $forum_handle_string = post_param('forum_handle', strval(get_member())); $author = is_numeric($forum_handle_string) ? $GLOBALS['FORUM_DRIVER']->get_username(intval($forum_handle_string)) : $forum_handle_string; if (is_null($author)) { $author = do_lang('UNKNOWN'); } } $_forum_handle = post_param('forum_handle', NULL); if ($_forum_handle == '') { $_forum_handle = NULL; } if (!is_null($_forum_handle)) { $forum_handle = is_numeric($_forum_handle) ? intval($_forum_handle) : $GLOBALS['FORUM_DRIVER']->get_member_from_username($_forum_handle); } else { $forum_handle = NULL; } if (post_param_integer('delete', 0) == 1) { if (!has_delete_author_permission(get_member(), $author)) { access_denied('SPECIFIC_PERMISSION', 'delete_midrange_content'); } delete_author($author); $author = NULL; require_code('fields'); if (has_tied_catalogue('author')) { delete_form_custom_fields('author', $author); } } else { $_url = post_param('url'); if (strpos($_url, '@') !== false && strpos($_url, 'mailto:') === false) { $_url = 'mailto:' . $_url; } $url = strpos($_url, 'mailto:') === false ? fixup_protocolless_urls($_url) : $_url; add_author($author, $url, $forum_handle, post_param('description'), post_param('skills'), post_param('meta_keywords', ''), post_param('meta_description', '')); require_code('fields'); if (has_tied_catalogue('author')) { save_form_custom_fields('author', $author); } if (addon_installed('awards')) { require_code('awards'); handle_award_setting('author', $author); } } breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('AUTHOR_MANAGE')))); return $this->do_next_manager($title, do_lang_tempcode('SUCCESS'), $author); }
/** * The actualiser for editing a CEDI page. * * @return tempcode The UI. */ function _edit_page() { $_id = get_param_cedi_chain('id'); $id = intval($_id[0]); if (!has_category_access(get_member(), 'seedy_page', strval($id))) { access_denied('CATEGORY_ACCESS'); } if (post_param_integer('delete', 0) == 1) { $title = get_page_title('CEDI_DELETE_PAGE'); check_delete_permission('cat_low', NULL, array('seedy_page', $id)); cedi_delete_page($id); require_code('fields'); if (has_tied_catalogue('seedy_page')) { delete_form_custom_fields('seedy_page', strval($id)); } require_code('autosave'); clear_ocp_autosave(); $_url = build_url(array('page' => '_SELF', 'type' => 'misc'), '_SELF'); $url = $_url->evaluate(); } else { $title = get_page_title('CEDI_EDIT_PAGE'); check_edit_permission('cat_low', NULL, array('seedy_page', $id)); require_code('permissions2'); set_category_permissions_from_environment('seedy_page', strval($id), 'cms_cedi'); cedi_edit_page($id, post_param('title'), post_param('post'), post_param('notes', ''), post_param_integer('hide_posts', 0), post_param('meta_keywords', ''), post_param('meta_description', '')); require_code('fields'); if (has_tied_catalogue('seedy_page')) { save_form_custom_fields('seedy_page', strval($id)); } require_code('autosave'); clear_ocp_autosave(); if (addon_installed('awards')) { require_code('awards'); handle_award_setting('seedy_page', strval($id)); } $url = get_param('redirect'); } // Show it worked / Refresh return redirect_screen($title, $url, do_lang_tempcode('SUCCESS')); }