Skip to content

Commit

Permalink
FIX #7146
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Jul 13, 2017
1 parent c434f72 commit 43f6eab
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion htdocs/categories/admin/categorie_extrafields.php
Expand Up @@ -41,7 +41,7 @@

$action=GETPOST('action', 'alpha');
$attrname=GETPOST('attrname', 'alpha');
$elementtype='categories'; //Must be the $element of the class that manage extrafield
$elementtype='categorie'; //Must be the $element of the class that manage extrafield

if (!$user->admin) accessforbidden();

Expand Down
2 changes: 1 addition & 1 deletion htdocs/categories/class/categorie.class.php
Expand Up @@ -51,7 +51,7 @@ class Categorie extends CommonObject
const TYPE_USER = 4; // categorie contact and user are same ! TODO Replace this value with 'user'

const TYPE_ACCOUNT = 5; // TODO Replace this value with 'bank_account'
const TYPE_PROJECT = 6;
const TYPE_PROJECT = 6; // TODO Replace this value with 'project'
const TYPE_BANK_LINE = 'bank_line';
public $picto = 'category';

Expand Down
12 changes: 9 additions & 3 deletions htdocs/core/class/commonobject.class.php
Expand Up @@ -4169,6 +4169,9 @@ function fetch_optionals($rowid=null,$optionsArray=null)
$optionsArray = $extrafields->attributes[$this->table_element]['label'];
}

$table_element = $this->table_element;
if ($table_element == 'categorie') $table_element = 'categories'; // For compatibility

// Request to get complementary values
if (count($optionsArray) > 0)
{
Expand All @@ -4180,7 +4183,7 @@ function fetch_optionals($rowid=null,$optionsArray=null)
$sql.= ", ".$name;
}
}
$sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element."_extrafields";
$sql.= " FROM ".MAIN_DB_PREFIX.$table_element."_extrafields";
$sql.= " WHERE fk_object = ".$rowid;

dol_syslog(get_class($this)."::fetch_optionals get extrafields data for ".$this->table_element, LOG_DEBUG);
Expand Down Expand Up @@ -4335,11 +4338,14 @@ function insertExtraFields()
}
$this->db->begin();

$sql_del = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element."_extrafields WHERE fk_object = ".$this->id;
$table_element = $this->table_element;
if ($table_element == 'categorie') $table_element = 'categories'; // For compatibility

$sql_del = "DELETE FROM ".MAIN_DB_PREFIX.$table_element."_extrafields WHERE fk_object = ".$this->id;
dol_syslog(get_class($this)."::insertExtraFields delete", LOG_DEBUG);
$this->db->query($sql_del);

$sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element."_extrafields (fk_object";
$sql = "INSERT INTO ".MAIN_DB_PREFIX.$table_element."_extrafields (fk_object";
foreach($new_array_options as $key => $value)
{
$attributeKey = substr($key,8); // Remove 'options_' prefix
Expand Down
3 changes: 3 additions & 0 deletions htdocs/core/class/extrafields.class.php
Expand Up @@ -197,6 +197,7 @@ private function create($attrname, $type='varchar', $length=255, $elementtype='m
if ($elementtype == 'contact') $elementtype='socpeople';

$table=$elementtype.'_extrafields';
if ($elementtype == 'categorie') $table='categories_extrafields';

if (! empty($attrname) && preg_match("/^\w[a-zA-Z0-9_]*$/",$attrname) && ! is_numeric($attrname))
{
Expand Down Expand Up @@ -350,6 +351,7 @@ function delete($attrname, $elementtype='member')
if ($elementtype == 'contact') $elementtype='socpeople';

$table=$elementtype.'_extrafields';
if ($elementtype == 'categorie') $table='categories_extrafields';

$error=0;

Expand Down Expand Up @@ -460,6 +462,7 @@ function update($attrname,$label,$type,$length,$elementtype,$unique=0,$required=
if ($elementtype == 'contact') $elementtype='socpeople';

$table=$elementtype.'_extrafields';
if ($elementtype == 'categorie') $table='categories_extrafields';

if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname))
{
Expand Down
3 changes: 3 additions & 0 deletions htdocs/install/mysql/migration/5.0.0-6.0.0.sql
Expand Up @@ -519,6 +519,9 @@ ALTER TABLE llx_website_page ADD UNIQUE INDEX uk_website_page_url (fk_website,pa
ALTER TABLE llx_website_page ADD CONSTRAINT fk_website_page_website FOREIGN KEY (fk_website) REFERENCES llx_website (rowid);


UPDATE llx_extrafields set elementtype='categorie' where elementtype='categories';


-- For new module blockedlog

CREATE TABLE llx_blockedlog
Expand Down

0 comments on commit 43f6eab

Please sign in to comment.