Esempio n. 1
0
 /**
  * The UI to view an author.
  *
  * @return tempcode		The UI
  */
 function show_author()
 {
     $author = get_param('id', NULL);
     if (is_null($author)) {
         if (is_guest()) {
             global $EXTRA_HEAD;
             $EXTRA_HEAD->attach('<meta name="robots" content="noindex" />');
             // XHTMLXHTML
             warn_exit(do_lang_tempcode('USER_NO_EXIST'));
         }
         $author = $GLOBALS['FORUM_DRIVER']->get_username(get_member());
     }
     if (is_null($author) || $author == '') {
         warn_exit(do_lang_tempcode('INTERNAL_ERROR'));
     }
     // Really don't want to have to search on this
     if (addon_installed('awards')) {
         require_code('awards');
         $awards = find_awards_for('author', $author);
     } else {
         $awards = array();
     }
     $title = get_page_title('_AUTHOR', true, array(escape_html($author)), NULL, $awards);
     seo_meta_load_for('authors', $author);
     $rows = $GLOBALS['SITE_DB']->query_select('authors', array('url', 'description', 'skills'), array('author' => $author), '', 1);
     if (!array_key_exists(0, $rows)) {
         if (has_actual_page_access(get_member(), 'cms_authors') && has_edit_author_permission(get_member(), $author)) {
             $GLOBALS['HTTP_STATUS_CODE'] = '404';
             if (!headers_sent()) {
                 if (!browser_matches('ie') && strpos(ocp_srv('SERVER_SOFTWARE'), 'IIS') === false) {
                     header('HTTP/1.0 404 Not Found');
                 }
             }
             $_author_add_url = build_url(array('page' => 'cms_authors', 'type' => '_ad', 'author' => $author), get_module_zone('cms_authors'));
             $author_add_url = $_author_add_url->evaluate();
             $message = do_lang_tempcode('NO_SUCH_AUTHOR_CONFIGURE_ONE', escape_html($author), escape_html($author_add_url));
             attach_message($message, 'inform');
         } else {
             $message = do_lang_tempcode('NO_SUCH_AUTHOR', escape_html($author));
         }
         $details = array('author' => $author, 'url' => '', 'forum_handle' => $GLOBALS['FORUM_DRIVER']->get_member_from_username($author), 'description' => NULL, 'skills' => NULL);
         //return inform_screen($title,$message);
     } else {
         $details = $rows[0];
     }
     // Links associated with the mapping between the author and a forum member
     $handle = get_author_id_from_name($author);
     if (!is_null($handle)) {
         $forum_details = do_template('AUTHOR_SCREEN_POTENTIAL_ACTION_ENTRY', array('ACTION' => hyperlink($GLOBALS['FORUM_DRIVER']->member_profile_url($handle, true, true), do_lang_tempcode('AUTHOR_PROFILE'), false, false, '', NULL, NULL, 'me')));
         if (addon_installed('points')) {
             $give_points_url = build_url(array('page' => 'points', 'type' => 'member', 'id' => $handle), get_module_zone('points'));
             $point_details = do_template('AUTHOR_SCREEN_POTENTIAL_ACTION_ENTRY', array('ACTION' => hyperlink($give_points_url, do_lang_tempcode('AUTHOR_POINTS'))));
         } else {
             $point_details = new ocp_tempcode();
         }
     } else {
         $forum_details = new ocp_tempcode();
         $point_details = new ocp_tempcode();
     }
     // Homepage
     $url = $details['url'];
     if (strlen($url) > 0) {
         $url_details = do_template('AUTHOR_SCREEN_POTENTIAL_ACTION_ENTRY', array('ACTION' => hyperlink($url, do_lang_tempcode('AUTHOR_HOMEPAGE'), false, false, '', NULL, NULL, 'me')));
     } else {
         $url_details = new ocp_tempcode();
     }
     // (Self?) description
     $description = is_null($details['description']) ? new ocp_tempcode() : get_translated_tempcode($details['description']);
     // Skills
     $skills = is_null($details['skills']) ? new ocp_tempcode() : get_translated_tempcode($details['skills']);
     // Edit link, for staff
     if (has_edit_author_permission(get_member(), $author)) {
         $edit_author_url = build_url(array('page' => 'cms_authors', 'type' => '_ad', 'author' => $author), get_module_zone('cms_authors'));
         $staff_details = do_template('AUTHOR_SCREEN_POTENTIAL_ACTION_ENTRY', array('ACTION' => hyperlink($edit_author_url, do_lang_tempcode('DEFINE_AUTHOR'), false)));
     } else {
         $staff_details = new ocp_tempcode();
     }
     // Search link
     if (addon_installed('search')) {
         $search_url = build_url(array('page' => 'search', 'author' => $author), get_module_zone('search'));
         $search_details = do_template('AUTHOR_SCREEN_POTENTIAL_ACTION_ENTRY', array('ACTION' => hyperlink($search_url, do_lang_tempcode('SEARCH'), false)));
     } else {
         $search_details = new ocp_tempcode();
     }
     // Downloads
     $downloads_released = new ocp_tempcode();
     if (addon_installed('downloads')) {
         require_code('downloads');
         require_lang('downloads');
         $count = $GLOBALS['SITE_DB']->query_value('download_downloads', 'COUNT(*)', array('author' => $author, 'validated' => 1));
         if ($count > 50) {
             $downloads_released = paragraph(do_lang_tempcode('TOO_MANY_TO_CHOOSE_FROM'));
         } else {
             $rows = $GLOBALS['SITE_DB']->query_select('download_downloads', array('*'), array('author' => $author, 'validated' => 1));
             require_code('downloads');
             foreach ($rows as $i => $myrow) {
                 if ($i != 0) {
                     $downloads_released->attach(do_template('BLOCK_SEPARATOR', array('_GUID' => 'ea789367b15bsddsdsdsc586e6e6536')));
                 }
                 if (has_category_access(get_member(), 'downloads', strval($myrow['category_id']))) {
                     $downloads_released->attach(get_download_html($myrow));
                 }
             }
         }
     }
     // News
     $news_released = new ocp_tempcode();
     if (addon_installed('news')) {
         require_lang('news');
         $count = $GLOBALS['SITE_DB']->query_value('news', 'COUNT(*)', array('author' => $author, 'validated' => 1));
         if ($count > 50) {
             $news_released = paragraph(do_lang_tempcode('TOO_MANY_TO_CHOOSE_FROM'));
         } else {
             $rows = $GLOBALS['SITE_DB']->query_select('news', array('*'), array('author' => $author, 'validated' => 1));
             foreach ($rows as $i => $row) {
                 if (has_category_access(get_member(), 'news', strval($row['news_category']))) {
                     $url = build_url(array('page' => 'news', 'type' => 'view', 'id' => $row['id']), get_module_zone('news'));
                     $_title = get_translated_tempcode($row['title']);
                     $title_plain = get_translated_text($row['title']);
                     $seo_bits = seo_meta_get_for('news', strval($row['id']));
                     $map = array('ID' => strval($row['id']), 'TAGS' => get_loaded_tags('news', explode(',', $seo_bits[0])), 'SUBMITTER' => strval($row['submitter']), 'DATE' => get_timezoned_date($row['date_and_time']), 'DATE_RAW' => strval($row['date_and_time']), 'URL' => $url, 'TITLE_PLAIN' => $title_plain, 'TITLE' => $_title);
                     if (get_option('is_on_comments') == '1' && !has_no_forum() && $row['allow_comments'] >= 1) {
                         $map['COMMENT_COUNT'] = '1';
                     }
                     $tpl = do_template('NEWS_BRIEF', $map);
                     $news_released->attach($tpl);
                 }
             }
         }
     }
     // Edit link
     $edit_url = new ocp_tempcode();
     if (has_edit_author_permission(get_member(), $author)) {
         $edit_url = build_url(array('page' => 'cms_authors', 'type' => '_ad', 'id' => $author), 'cms');
     }
     return do_template('AUTHOR_SCREEN', array('_GUID' => 'ea789367b15bc90fc28d1c586e6e6536', 'TAGS' => get_loaded_tags(), 'TITLE' => $title, 'EDIT_URL' => $edit_url, 'AUTHOR' => $author, 'NEWS_RELEASED' => $news_released, 'DOWNLOADS_RELEASED' => $downloads_released, 'STAFF_DETAILS' => $staff_details, 'POINT_DETAILS' => $point_details, 'SEARCH_DETAILS' => $search_details, 'URL_DETAILS' => $url_details, 'FORUM_DETAILS' => $forum_details, 'SKILLS' => $skills, 'DESCRIPTION' => $description));
 }
Esempio n. 2
0
 /**
  * The UI to add an author.
  *
  * @return tempcode		The UI
  */
 function _ad()
 {
     global $NON_CANONICAL_PARAMS;
     $NON_CANONICAL_PARAMS[] = 'author';
     $author = get_param('author', $GLOBALS['FORUM_DRIVER']->get_username(get_member()));
     if (!has_edit_author_permission(get_member(), $author)) {
         if (get_author_id_from_name($author) == get_member()) {
             access_denied('SPECIFIC_PERMISSION', 'set_own_author_profile');
         }
         access_denied('SPECIFIC_PERMISSION', 'edit_midrange_content');
     }
     $rows = $GLOBALS['SITE_DB']->query_select('authors', array('description', 'url', 'skills', 'forum_handle'), array('author' => $author), '', 1);
     if (array_key_exists(0, $rows)) {
         $myrow = $rows[0];
         $description = get_translated_text($myrow['description']);
         $url = $myrow['url'];
         $skills = get_translated_text($myrow['skills']);
         $handle = $myrow['forum_handle'];
         $may_delete = true;
     } else {
         $description = '';
         if (get_forum_type() == 'ocf') {
             require_code('ocf_members');
             require_lang('ocf');
             $info = ocf_get_all_custom_fields_match_member(get_member());
             if (array_key_exists(do_lang('DEFAULT_CPF_SELF_DESCRIPTION_NAME'), $info)) {
                 $description = $info[do_lang('DEFAULT_CPF_SELF_DESCRIPTION_NAME')]['RENDERED'];
                 if (is_object($description)) {
                     $description = $description->evaluate();
                 }
             }
         }
         $url = '';
         $skills = '';
         $handle = NULL;
         $may_delete = false;
     }
     if (is_null($handle)) {
         $handle = $GLOBALS['FORUM_DRIVER']->get_member_from_username($author);
         if (!is_null($handle)) {
             $handle = strval($handle);
         }
     }
     if ($author == '' || is_null($handle)) {
         $title = get_page_title('DEFINE_AUTHOR');
     } else {
         $title = get_page_title('_DEFINE_AUTHOR', true, array(escape_html($author)));
     }
     $post_url = build_url(array('page' => '_SELF', 'type' => '__ad', 'author' => $author), '_SELF');
     $submit_name = do_lang_tempcode('SAVE');
     $fields = new ocp_tempcode();
     $hidden = new ocp_tempcode();
     require_code('form_templates');
     if (is_null($handle)) {
         $fields->attach(form_input_line(do_lang_tempcode('AUTHOR'), do_lang_tempcode('DESCRIPTION_NAME'), 'author', $author, true));
     }
     $fields->attach(form_input_line(do_lang_tempcode('AUTHOR_URL'), do_lang_tempcode('DESCRIPTION_AUTHOR_URL'), 'url', $url, false));
     $fields->attach(form_input_line_comcode(do_lang_tempcode('SKILLS'), do_lang_tempcode('DESCRIPTION_SKILLS'), 'skills', $skills, false));
     $fields->attach(form_input_text_comcode(do_lang_tempcode('DESCRIPTION'), do_lang_tempcode('DESCRIPTION_MEMBER_DESCRIPTION'), 'description', $description, false));
     if (has_specific_permission(get_member(), 'edit_midrange_content', 'cms_authors')) {
         $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => !is_null($handle), 'TITLE' => do_lang_tempcode('ADVANCED'))));
         $fields->attach(form_input_username(do_lang_tempcode('MEMBER_ID'), do_lang_tempcode('DESCRIPTION_MEMBER_ID'), 'forum_handle', is_null($handle) ? '' : $GLOBALS['FORUM_DRIVER']->get_username(intval($handle)), false));
     } else {
         $hidden->attach(form_input_hidden('forum_handle', $handle));
     }
     require_code('fields');
     if (has_tied_catalogue('author')) {
         append_form_custom_fields('author', $author, $fields, $hidden);
     }
     require_code('seo2');
     $fields->attach(seo_get_fields('authors', $author));
     // Awards?
     if (addon_installed('awards')) {
         require_code('awards');
         $fields->attach(get_award_fields('author', $author));
     }
     if ($may_delete) {
         $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('ACTIONS'))));
         $fields->attach(form_input_tick(do_lang_tempcode('DELETE'), do_lang_tempcode('DESCRIPTION_DELETE'), 'delete', false));
     }
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('AUTHOR_MANAGE'))));
     return do_template('FORM_SCREEN', array('_GUID' => '1d71c934e3e23fe394f5611191089630', 'PREVIEW' => true, 'HIDDEN' => $hidden, 'TITLE' => $title, 'TEXT' => '', 'FIELDS' => $fields, 'URL' => $post_url, 'SUBMIT_NAME' => $submit_name));
 }
Esempio n. 3
0
/**
 * Find if a member's usergroup has permission to delete an author
 *
 * @param  MEMBER			The member being checked whether to have the access
 * @param  ID_TEXT		An author
 * @return boolean		Whether the member can edit this author
 */
function has_delete_author_permission($member, $author)
{
    if (is_guest($member)) {
        return false;
    }
    if (get_author_id_from_name($author) == $member && has_specific_permission($member, 'delete_own_midrange_content')) {
        return true;
    }
    if (has_specific_permission($member, 'delete_midrange_content', 'cms_authors')) {
        return true;
    }
    return false;
}