Skip to content

Commit

Permalink
Added an edit button for Admins when viewing a Topic
Browse files Browse the repository at this point in the history
For feature #1070
  • Loading branch information
eSilverStrike committed Jan 12, 2022
1 parent fdced6c commit e57d28c
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 12 deletions.
1 change: 1 addition & 0 deletions public_html/docs/english/theme.html
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ <h2><a name="changes222">Theme changes in Geeklog 2.2.2</a></h2>
<ul>
<li>New Block Header Child template called <span class="tt">blockheader-child.thtml</span>. This is used by User Profile page and allows for nesting blocks within the main block. This change required bumping Geeklog minimum version for themes to 2.2.2.</li>
<li>For the <span class="tt">users\profile.thtml</span> file, all {end_block} template variables updated with unique names.</li>
<li>Edit link for topics added to <span class="tt">topic.thtml</li>
</ul>

<h2><a name="changes221">Theme changes in Geeklog 2.2.1</a></h2>
Expand Down
1 change: 1 addition & 0 deletions public_html/docs/japanese/theme.html
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ <h2><a name="changes222">Theme changes in Geeklog 2.2.2</a></h2>
<ul>
<li>New Block Header Child template called <span class="tt">blockheader-child.thtml</span>. This is used by User Profile page and allows for nesting blocks within the main block. This change required bumping Geeklog minimum version for themes to 2.2.2.</li>
<li>For the <span class="tt">users\profile.thtml</span> file, all {end_block} template variables updated with unique names.</li>
<li>Edit link for topics added to <span class="tt">topic.thtml</li>
</ul>

<h2><a name="changes221">Geeklog 2.2.1におけるテーマの変更点</a></h2>
Expand Down
26 changes: 26 additions & 0 deletions public_html/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,32 @@ function fixTopic(&$A, $tid_list)
if ($page == 1) {
$tt->set_var('first_page', true);
}

if (!empty($current_topic) && SEC_hasRights('topic.edit') &&
(TOPIC_hasMultiTopicAccess('topic', $current_topic) == 3)) {
$editUrl = $_CONF['site_admin_url'] . '/topic.php?mode=edit&amp;tid=' . $current_topic;
$linkIcon = rtrim($_CONF['path_layout'], '/') . '/images/edit.' . $_IMAGE_TYPE;
$sizeAttributes = COM_getImgSizeAttributes($linkIcon);
$editiconhtml = '<img ' . $sizeAttributes . 'src="' . $_CONF['layout_url']
. '/images/edit.' . $_IMAGE_TYPE . '" alt="' . $LANG01[4]
. '" title="' . $LANG01[4] . '"' . XHTML . '>';
$tt->set_var('edit_link', COM_createLink($LANG01[4], $editUrl));
$tt->set_var('edit_url', $editUrl);
$tt->set_var('lang_edit_text', $LANG01[4]);
$tt->set_var(
'edit_icon',
COM_createLink(
$editiconhtml,
$editUrl,
array(
'class' => 'editlink',
'rel' => 'nofollow',
)
)
);
$tt->set_var('edit_image', $editiconhtml);
}

$tt->parse('output', 'topic');
$display = $tt->finish($tt->get_var('output'));

Expand Down
10 changes: 7 additions & 3 deletions public_html/layout/denim/topic.thtml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@
{# variables - index_page (first page) are available as well to use #}

{!if topic_id}
{!if topic_title}
<h1>{topic_title}</h1>
{!endif}
<h1>{topic_title}
{!if edit_icon}
<span class="story_icon">
<a title="{lang_edit_text}" href="{edit_url}" class="uk-icon-hover uk-icon-pencil" rel="nofollow" aria-label="{lang_edit_text}"></a>
</span>
{!endif}
</h1>
{!else}
{# If topic id does not exist then on homepage #}

Expand Down
10 changes: 7 additions & 3 deletions public_html/layout/denim_three/topic.thtml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@
{# variables - index_page (first page) are available as well to use #}

{!if topic_id}
{!if topic_title}
<h1>{topic_title}</h1>
{!endif}
<h1>{topic_title}
{!if edit_icon}
<span class="story_icon">
<a title="{lang_edit_text}" href="{edit_url}" class="uk-icon-link" rel="nofollow" uk-tooltip="{lang_edit_text}" uk-icon="pencil" aria-label="{lang_edit_text}"></a>
</span>
{!endif}
</h1>
{!else}
{# If topic id does not exist then on homepage #}

Expand Down
10 changes: 7 additions & 3 deletions public_html/layout/modern_curve/topic.thtml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@
{# variables - index_page (first page) are available as well to use #}

{!if topic_id}
{!if topic_title}
<h1>{topic_title}</h1>
{!endif}
<h1>{topic_title}
{!if edit_icon}
<span style="float:right;">
{edit_icon}
</span>
{!endif}
</h1>
{!else}
{# If topic id does not exist then on homepage #}

Expand Down
6 changes: 3 additions & 3 deletions system/lib-topic.php
Original file line number Diff line number Diff line change
Expand Up @@ -617,11 +617,11 @@ function TOPIC_getList($sortcol = 0, $ignorelang = true, $title = true, $access
*
* @param string $type Type of object to find topic access about. If 'topic' then
* will check post array for topic selection control
* @param string/array $id ID of object to check topic access for (not requried
* @param string/array $id ID of object to check topic access for (not required
* if $type is 'topic')
* @param string/array $tid ID of topic to check topic access for (not requried
* @param string/array $tid ID of topic to check topic access for (not required
* and not used if $type is 'topic'). Also can just specify this
* @param string $sub_type Sub type of plugin to allow plugins to have topic assigments for more than one type of item.
* @param string $sub_type Sub type of plugin to allow plugins to have topic assignments for more than one type of item.
* @return int returns 3 for read/edit 2 for read only 0 for no access
*/
function TOPIC_hasMultiTopicAccess($type, $id = '', $tid = '', $sub_type = '')
Expand Down

0 comments on commit e57d28c

Please sign in to comment.