News Module: Missing Delete Icon for Field Definitions Tab
Posted: Thu Dec 06, 2007 12:26 am
I just installed/upgraded to CMS 1.2.2 and its News module version 2.6.1 to take advantage of the new "Field Definitions" feature. To understand how it works I added my first field to play with and than I started adding few more. I soon realized that I will not need all the fields I just defined so I wanted to delete some but ... there was no "Delete" icon available! After checking the HTML source of the admin page, I noticed the space for it but no link.
Checking deeper into the News module code, I found some potential errors in "function.admin_customfieldstab.php".
The code:
says that if the current row id IS NOT in the list than create and the "delete" icon code.
My opinion is that the negation "!" is an error.
After I removed the above negation, another error appeared. The following code from the beginning of the file:
should use the "module_news_fielddefs" and NOT "module_news_fieldvals" since one can have more fields defined than fields with data used in articles.
I changed the code like this:
Now I can delete any of my Field Definitions.
Checking deeper into the News module code, I found some potential errors in "function.admin_customfieldstab.php".
The code:
Code: Select all
if( !in_array($row['id'],$usedfields) )
{
$onerow->deletelink = $this->CreateLink($id, 'admin_deletefielddef', $returnid, $gCms->variables['admintheme']->DisplayImage('icons/system/delete.gif', $this->Lang('delete'),'','','systemicon'), array('fdid'=>$row['id']), $this->Lang('areyousure'));
}
My opinion is that the negation "!" is an error.
After I removed the above negation, another error appeared. The following code from the beginning of the file:
Code: Select all
$tmp = $db->GetArray('SELECT DISTINCT fielddef_id FROM '.cms_db_prefix().'module_news_fieldvals');
$usedfields = array();
foreach( $tmp as $row )
{
$usedfields[] = $row['fielddef_id'];
}
I changed the code like this:
Code: Select all
$tmp = $db->GetArray('SELECT DISTINCT id FROM '.cms_db_prefix().'module_news_fielddefs');
$usedfields = array();
foreach( $tmp as $row )
{
$usedfields[] = $row['id'];
}