Skip to content

Commit

Permalink
Moved dw_edit_displayed() from edit.php to helper to make it accessib…
Browse files Browse the repository at this point in the history
…le from dwedit plugin
  • Loading branch information
turnermm committed Sep 30, 2020
1 parent 1aca791 commit b42643a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 27 deletions.
28 changes: 1 addition & 27 deletions action/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -524,32 +524,6 @@ function($matches) {
return true;
}

/**
* function dw_edit_displayed
* @author Myron Turner
* determines whether or not to show or hide the
* 'DW Edit' button
*/

function dw_edit_displayed()
{
global $INFO;

$dw_edit_display = @$this->getConf('dw_edit_display');
if(!isset($dw_edit_display))return ""; //version 0.
if($dw_edit_display != 'all') {
$admin_exclusion = false;
if($dw_edit_display == 'admin' && ($INFO['isadmin'] || $INFO['ismanager']) ) {
$admin_exclusion = true;
}
if($dw_edit_display == 'none' || $admin_exclusion === false) {
return ' style = "display:none"; ';
}
return "";
}
return "";

}

/**
Check for for alternate style sheet
Expand Down Expand Up @@ -768,7 +742,7 @@ function _print()

if(($guest_user || $guest_group) && $guest_perm <= 2) $DW_EDIT_disabled = 'disabled';
global $USERINFO;
$DW_EDIT_hide = $this->dw_edit_displayed();
$DW_EDIT_hide = $this->helper->dw_edit_displayed();
$is_ckgeditChrome = false;
if(stripos($_SERVER['HTTP_USER_AGENT'],'Chrome') !== false) {
preg_match("/Chrome\/(\d+)/", $_SERVER['HTTP_USER_AGENT'],$cmatch);
Expand Down
27 changes: 27 additions & 0 deletions helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,33 @@ function has_plugin($plugin) {
return in_array($plugin, $plugins_list);
}

/**
* function dw_edit_displayed
* @author Myron Turner
* determines whether or not to show or hide the
* 'DW Edit' button
*/

function dw_edit_displayed()
{
global $INFO;

$dw_edit_display = @$this->getConf('dw_edit_display');
if(!isset($dw_edit_display))return ""; //version 0.
if($dw_edit_display != 'all') {
$admin_exclusion = false;
if($dw_edit_display == 'admin' && ($INFO['isadmin'] || $INFO['ismanager']) ) {
$admin_exclusion = true;
}
if($dw_edit_display == 'none' || $admin_exclusion === false) {
return ' style = "display:none"; ';
}
return "";
}
return "";

}

function registerOnLoad($js){
global $ID;
global $lang;
Expand Down

0 comments on commit b42643a

Please sign in to comment.