1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-03 13:17:24 +02:00

Don't display 'delete' icon for user classes that can't be deleted. Tidy up a bit.

This commit is contained in:
SteveD
2012-12-18 22:43:10 +00:00
parent d5184fef33
commit f507aa57b6
2 changed files with 14 additions and 14 deletions

View File

@@ -48,10 +48,11 @@ $mes = e107::getMessage();
$message = '';
/**
* @todo user_class::isEditableClass() thinks public (0) is editable?!
* See whether a user class is fully editable.
*
* @param integer $class_id
* @param boolean $redirect
* @return boolean
* @param boolean $redirect - if TRUE, will redirect to site home page if class not fully editable.
* @return boolean - TRUE if class fully editable, FALSE if not.
*/
function check_allowed($class_id, $redirect = true)
{
@@ -63,8 +64,8 @@ function check_allowed($class_id, $redirect = true)
exit;
}
// fix public (0) case here for now
if(!$class_id || !$uc->isEditableClass($class_id))
if(!$uc->isEditableClass($class_id))
{
if(!$redirect) return false;
e107::getMessage()->addSession('You can\'t edit system user classes!', E_MESSAGE_ERROR);
@@ -82,7 +83,7 @@ if (e_QUERY)
{
$uc_qs = array($_GET['action'], $_GET['id']);
}
else $uc_qs = explode(".", e_QUERY);
else $uc_qs = explode('.', e_QUERY);
}
$action = varset($uc_qs[0]);
$params = varset($uc_qs[1],'');
@@ -259,15 +260,13 @@ if (isset($_POST['createclass'])) // Add or edit
$tempID = intval(varset($_POST['userclass_id'], -1));
if (($tempID < 0) && $e_userclass->ucGetClassIDFromName($class_record['userclass_name']))
{ // Duplicate name
//$message = UCSLAN_63;
$emessage->add(UCSLAN_63, E_MESSAGE_WARNING);
{
$emessage->add(UCSLAN_63, E_MESSAGE_WARNING); // Duplicate name
$forwardVals = TRUE;
}
elseif ($e_userclass->checkAdminInfo($class_record, $tempID) === FALSE)
{
//$message = UCSLAN_86;
$emessage->add(UCSLAN_86);
$emessage->add(UCSLAN_86); // Some fixed values changed
}
if (!$forwardVals)
@@ -909,7 +908,7 @@ class uclass_manager
'userclass_parent' => array('title'=> UCSLAN_35, 'type' => 'userclass', 'width' => 'auto', 'thclass' => 'left'),
'userclass_visibility' => array('title'=> UCSLAN_34, 'type' => 'userclass', 'width' => 'auto', 'thclass' => 'left'),
'userclass_type' => array('title'=> UCSLAN_79, 'type' => 'method', 'width' => '10%', 'thclass' => 'left', 'class'=>'left' ),
'options' => array('title'=> LAN_OPTIONS, 'type' => null, 'width' => '10%', 'thclass' => 'center last', 'forced'=>TRUE, 'class'=>'center')
'options' => array('title'=> LAN_OPTIONS, 'type' => null, 'width' => '10%', 'thclass' => 'center last', 'forced'=>TRUE, 'class'=>'center', 'readParms' => array('deleteClass' => e_UC_NOBODY))
);
}
@@ -949,7 +948,8 @@ class uclass_manager
foreach($classes as $row)
{
$text .= $frm->renderTableRow($this->fields, $this->fieldpref, $row, 'userclass_id');
$this->fields['options']['readParms']['deleteClass'] = $e_userclass->isEditableClass($row['userclass_id']) ? '' : e_UC_NOBODY;
$text .= $frm->renderTableRow($this->fields, $this->fieldpref, $row, 'userclass_id'); // @TODO: Suppress delete icon on fixed classes.
}
$text .= "</tbody></table></fieldset></form>";

View File

@@ -928,7 +928,7 @@ class user_class
public function isEditableClass($classID)
{
if (($classID >= e_UC_SPECIAL_BASE) && ($classID <= e_UC_SPECIAL_END)) return FALSE; // Don't allow deletion of fixed classes
if (isset($this->fixed_classes[vartrue($class_id)])) return FALSE; // This picks up classes such as e_UC_PUBLIC outside the main range which can't be deleted
if (isset($this->fixed_classes[$classID])) return FALSE; // This picks up classes such as e_UC_PUBLIC outside the main range which can't be deleted
return TRUE;
}