1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-08 07:36:32 +02:00

Custom user-extended fields - work-in-progress. (experimental)

This commit is contained in:
Cameron
2016-05-05 18:51:30 -07:00
parent 01ec33cc8e
commit 1e44928e1f
4 changed files with 27 additions and 3 deletions

View File

@@ -856,6 +856,10 @@ class e107plugin
// FIXME - use sql parse handler // FIXME - use sql parse handler
$error = FALSE; $error = FALSE;
$count = 0; $count = 0;
$sql = e107::getDb();
if($action == 'add') if($action == 'add')
{ {
$sql_data = file_get_contents($f); $sql_data = file_get_contents($f);
@@ -867,7 +871,7 @@ class e107plugin
foreach($creation[0] as $tab) foreach($creation[0] as $tab)
{ {
$query = str_replace($search,$replace,$tab); $query = str_replace($search,$replace,$tab);
if(!mysql_query($query)) if(!$sql->gen($query))
{ {
$error = TRUE; $error = TRUE;
} }
@@ -878,7 +882,7 @@ class e107plugin
foreach($inserts[0] as $ins) foreach($inserts[0] as $ins)
{ {
$qry = str_replace($search,$replace,$ins); $qry = str_replace($search,$replace,$ins);
if(!mysql_query($qry)) if(!$sql->gen($qry))
{ {
$error = TRUE; $error = TRUE;
} }
@@ -894,7 +898,7 @@ class e107plugin
if($action == 'remove') if($action == 'remove')
{ {
// executed only if the sql file exists! // executed only if the sql file exists!
return mysql_query("DROP TABLE ".MPREFIX."user_extended_".$field_name) ? true : false; return $sql->gen("DROP TABLE ".MPREFIX."user_extended_".$field_name) ? true : false;
} }
} }

View File

@@ -66,6 +66,7 @@ class e107_user_extended
define('EUF_PREDEFINED',9); // should be EUF_LIST IMO define('EUF_PREDEFINED',9); // should be EUF_LIST IMO
define('EUF_CHECKBOX',10); define('EUF_CHECKBOX',10);
define('EUF_PREFIELD',11); // should be EUF_PREDEFINED, useful when creating fields from e.g. plugin XML define('EUF_PREFIELD',11); // should be EUF_PREDEFINED, useful when creating fields from e.g. plugin XML
define('EUF_ADDON', 12); // defined within e_user.php addon
$this->typeArray = array( $this->typeArray = array(
'text' => 1, 'text' => 1,
@@ -79,6 +80,7 @@ class e107_user_extended
'list' => 9, 'list' => 9,
'checkbox' => 10, 'checkbox' => 10,
'predefined' => 11, // DON'T USE IT IN PREDEFINED FIELD XML!!! Used in plugin installation routine. 'predefined' => 11, // DON'T USE IT IN PREDEFINED FIELD XML!!! Used in plugin installation routine.
'addon' => 12
); );
$this->user_extended_types = array( $this->user_extended_types = array(
@@ -92,6 +94,7 @@ class e107_user_extended
8 => UE_LAN_8, 8 => UE_LAN_8,
9 => UE_LAN_9, 9 => UE_LAN_9,
10=> UE_LAN_10 10=> UE_LAN_10
// 12=> UE_LAN_10
); );
//load array with field names from main user table, so we can disallow these //load array with field names from main user table, so we can disallow these

View File

@@ -24,4 +24,20 @@ class _blank_user // plugin-folder + '_user'
return $var; return $var;
} }
function fields()
{
$fields = array(
);
}
} }

View File

@@ -25,5 +25,6 @@
</userClasses> </userClasses>
<extendedFields> <extendedFields>
<field name="custom" type='EUF_TEXTAREA' default='0' active="true" /> <field name="custom" type='EUF_TEXTAREA' default='0' active="true" />
<field name="custom2" type='EUF_ADDON' data="str" default='0' active="true" system="false" text="My Label" />
</extendedFields> </extendedFields>
</e107Plugin> </e107Plugin>