mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-29 16:55:05 +02:00
WIP: Must do low changes
This commit is contained in:
parent
6cad02635e
commit
4c332a3543
@ -13,13 +13,15 @@
|
|||||||
// GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
// Load global vars
|
// Load global vars
|
||||||
// TESTING
|
// TESTING
|
||||||
|
/*
|
||||||
/* ini_set('display_errors', 1);
|
ini_set('display_errors', 1);
|
||||||
ini_set('display_startup_errors', 1);
|
ini_set('display_startup_errors', 1);
|
||||||
error_reporting(E_ALL); */
|
error_reporting(E_ALL); */
|
||||||
// END
|
// END
|
||||||
global $config;
|
global $config;
|
||||||
hd($_POST);
|
/*
|
||||||
|
hd($_POST);
|
||||||
|
hd($_REQUEST); */
|
||||||
check_login();
|
check_login();
|
||||||
|
|
||||||
if (! check_acl($config['id_user'], 0, 'PM')) {
|
if (! check_acl($config['id_user'], 0, 'PM')) {
|
||||||
@ -69,7 +71,6 @@ if (is_ajax()) {
|
|||||||
// Stop any execution.
|
// Stop any execution.
|
||||||
exit;
|
exit;
|
||||||
} else {
|
} else {
|
||||||
//hd($_POST);
|
|
||||||
// Run.
|
// Run.
|
||||||
$moduleTemplates->run();
|
$moduleTemplates->run();
|
||||||
// Get the id_np.
|
// Get the id_np.
|
||||||
|
@ -80,7 +80,7 @@ class ModuleTemplates extends HTML
|
|||||||
/**
|
/**
|
||||||
* Private Enterprise Numbers of Block Templates
|
* Private Enterprise Numbers of Block Templates
|
||||||
*
|
*
|
||||||
* @var [type]
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $pen;
|
private $pen;
|
||||||
|
|
||||||
@ -131,9 +131,8 @@ class ModuleTemplates extends HTML
|
|||||||
$this->id_np = get_parameter('id_np', -1);
|
$this->id_np = get_parameter('id_np', -1);
|
||||||
$this->name = get_parameter('name', '');
|
$this->name = get_parameter('name', '');
|
||||||
$this->description = get_parameter('description', '');
|
$this->description = get_parameter('description', '');
|
||||||
$pensList = get_parameter('pen', []);
|
$this->pen = get_parameter('pen', '');
|
||||||
// Separate all PENs received.
|
// Separate all PENs received.
|
||||||
$this->pen = explode(',', $pensList);
|
|
||||||
$this->offset = get_parameter('offset', 0);
|
$this->offset = get_parameter('offset', 0);
|
||||||
$this->ajaxController = $ajax_controller;
|
$this->ajaxController = $ajax_controller;
|
||||||
$this->ncGroup = get_parameter('ncgroup', -1);
|
$this->ncGroup = get_parameter('ncgroup', -1);
|
||||||
@ -216,6 +215,8 @@ class ModuleTemplates extends HTML
|
|||||||
{
|
{
|
||||||
// Get action if is needed.
|
// Get action if is needed.
|
||||||
$action = get_parameter('submit_button', '');
|
$action = get_parameter('submit_button', '');
|
||||||
|
// Success variable.
|
||||||
|
$success = false;
|
||||||
// Evaluate the modules allowed.
|
// Evaluate the modules allowed.
|
||||||
if (!empty($action)) {
|
if (!empty($action)) {
|
||||||
$numberComponent = [];
|
$numberComponent = [];
|
||||||
@ -236,12 +237,14 @@ class ModuleTemplates extends HTML
|
|||||||
],
|
],
|
||||||
['id_np' => $this->id_np]
|
['id_np' => $this->id_np]
|
||||||
);
|
);
|
||||||
// The update gone fine!
|
if ($dbResult_tnp === false) {
|
||||||
if ($dbResult_tnp != false) {
|
$success = false;
|
||||||
// Clean the PENs associated with this id_np.
|
} else {
|
||||||
db_process_sql_delete('tnetwork_profile_pen', ['id_np' => $this->id_np]);
|
db_process_sql_delete('tnetwork_profile_pen', ['id_np' => $this->id_np]);
|
||||||
|
$pensList = explode(',', $this->pen);
|
||||||
|
if (count($pensList) > 0) {
|
||||||
// Set again the new PENs associated.
|
// Set again the new PENs associated.
|
||||||
foreach ($this->pen as $currentPen) {
|
foreach ($pensList as $currentPen) {
|
||||||
$dbResult_pen = db_process_sql_insert(
|
$dbResult_pen = db_process_sql_insert(
|
||||||
'tnetwork_profile_pen',
|
'tnetwork_profile_pen',
|
||||||
[
|
[
|
||||||
@ -249,6 +252,15 @@ class ModuleTemplates extends HTML
|
|||||||
'id_np' => $this->id_np,
|
'id_np' => $this->id_np,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
if ($dbResult_pen === false) {
|
||||||
|
$success = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$success = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$success = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -265,9 +277,9 @@ class ModuleTemplates extends HTML
|
|||||||
if ($dbResult_tnp != false) {
|
if ($dbResult_tnp != false) {
|
||||||
// Set the new id_np.
|
// Set the new id_np.
|
||||||
$this->id_np = $dbResult_tnp;
|
$this->id_np = $dbResult_tnp;
|
||||||
|
$pensList = explode(',', $this->pen);
|
||||||
// Insert all of new PENs associated with this id_np.
|
// Insert all of new PENs associated with this id_np.
|
||||||
foreach ($this->pen as $currentPen) {
|
foreach ($pensList as $currentPen) {
|
||||||
hd($currentPen);
|
|
||||||
$dbResult_pen = db_process_sql_insert(
|
$dbResult_pen = db_process_sql_insert(
|
||||||
'tnetwork_profile_pen',
|
'tnetwork_profile_pen',
|
||||||
[
|
[
|
||||||
@ -279,16 +291,28 @@ class ModuleTemplates extends HTML
|
|||||||
if ($dbResult_pen === false) {
|
if ($dbResult_pen === false) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$success = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'Delete':
|
||||||
|
// Only in this case, catch delete_profile.
|
||||||
|
$deleteProfile = get_parameter('delete_profile', -1);
|
||||||
|
$dbResult = db_process_sql_delete('tnetwork_profile', ['id_np' => $deleteProfile]);
|
||||||
|
|
||||||
|
if ($dbResult != false) {
|
||||||
|
$success = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
$dbResult_tnp = false;
|
$success = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($dbResult_tnp === false || $dbResult_pen === false) {
|
if ($success === false) {
|
||||||
ui_print_error_message(__('Error saving data'));
|
ui_print_error_message(__('Error saving data'));
|
||||||
} else {
|
} else {
|
||||||
ui_print_success_message(__('Changes saved sucessfully'));
|
ui_print_success_message(__('Changes saved sucessfully'));
|
||||||
@ -299,19 +323,7 @@ class ModuleTemplates extends HTML
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the match between this id_np and one pen in db
|
* Show the adding modules form
|
||||||
*
|
|
||||||
* @param integer $pen
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
private function penMatch($pen)
|
|
||||||
{
|
|
||||||
return db_get_num_rows('SELECT * FROM tnetwork_profile_pen WHERE pen = %d AND id_np = %d', $pen, $this->id_np);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Undocumented function
|
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
@ -326,6 +338,7 @@ class ModuleTemplates extends HTML
|
|||||||
// 2 arrays. 1 with the groups, 1 with the groups by parent
|
// 2 arrays. 1 with the groups, 1 with the groups by parent
|
||||||
$groups = [];
|
$groups = [];
|
||||||
$groups_compound = [];
|
$groups_compound = [];
|
||||||
|
$groups_compound[0] = 'Group - All';
|
||||||
foreach ($result as $row) {
|
foreach ($result as $row) {
|
||||||
$groups[$row['id_sg']] = $row['name'];
|
$groups[$row['id_sg']] = $row['name'];
|
||||||
}
|
}
|
||||||
@ -339,8 +352,6 @@ class ModuleTemplates extends HTML
|
|||||||
$groups_compound[$row['id_sg']] .= $row['name'];
|
$groups_compound[$row['id_sg']] .= $row['name'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// For erase
|
|
||||||
// $group_filter .= html_print_select($groups_compound, 'ncgroup', $ncgroup, 'javascript:this.form.submit();', __('Group').' - '.__('All'), -1, true, false, true, '" style="width:350px');
|
|
||||||
// Get the components for show in a list for select
|
// Get the components for show in a list for select
|
||||||
if ($this->ncGroup > 0) {
|
if ($this->ncGroup > 0) {
|
||||||
$sql = sprintf(
|
$sql = sprintf(
|
||||||
@ -412,6 +423,7 @@ class ModuleTemplates extends HTML
|
|||||||
'type' => 'select',
|
'type' => 'select',
|
||||||
'script' => 'this.form.submit()',
|
'script' => 'this.form.submit()',
|
||||||
'fields' => $groups_compound,
|
'fields' => $groups_compound,
|
||||||
|
'nothing' => $groups_compound[0],
|
||||||
'return' => true,
|
'return' => true,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
@ -538,19 +550,24 @@ class ModuleTemplates extends HTML
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Undocumented function
|
* General setter
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function setNetworkProfile()
|
private function setNetworkProfile()
|
||||||
{
|
{
|
||||||
if ($this->id_np !== 0) {
|
// Get t
|
||||||
$profileInfo = db_get_row('tnetwork_profile', 'id_np', $this->id_np);
|
$profileInfo = db_get_row('tnetwork_profile', 'id_np', $this->id_np);
|
||||||
$this->name = $profileInfo['name'];
|
$this->name = $profileInfo['name'];
|
||||||
$this->description = $profileInfo['description'];
|
$this->description = $profileInfo['description'];
|
||||||
|
|
||||||
$penInfo = db_get_all_rows_filter('tnetwork_profile_pen', ['id_np' => $this->id_np]);
|
$penInfo = db_get_all_rows_filter('tnetwork_profile_pen', ['id_np' => $this->id_np]);
|
||||||
$this->pen = $penInfo['pen'];
|
$penList = [];
|
||||||
|
foreach ($penInfo as $pen) {
|
||||||
|
$penList[] = $pen['pen'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->pen = implode(',', $penList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -630,7 +647,7 @@ class ModuleTemplates extends HTML
|
|||||||
true,
|
true,
|
||||||
['title' => 'Export to CSV']
|
['title' => 'Export to CSV']
|
||||||
);
|
);
|
||||||
$data[3] = '<a href="'.$this->baseUrl.'&delete_profile=1&delete_profile='.$row['id_np'].'" '.'onclick="if (!confirm(\''.__('Are you sure?').'\')) return false;">'.html_print_image('images/cross.png', true, ['title' => __('Delete')]).'</a>';
|
$data[3] = '<a href="'.$this->baseUrl.'&submit_button=Delete&delete_profile='.$row['id_np'].'" '.'onclick="if (!confirm(\''.__('Are you sure?').'\')) return false;">'.html_print_image('images/cross.png', true, ['title' => __('Delete')]).'</a>';
|
||||||
$data[3] .= '<a href="'.$this->baseUrl.'&export_profile='.$row['id_np'].'">'.html_print_image('images/csv.png', true, ['title' => __('Export to CSV')]).'</a>';
|
$data[3] .= '<a href="'.$this->baseUrl.'&export_profile='.$row['id_np'].'">'.html_print_image('images/csv.png', true, ['title' => __('Export to CSV')]).'</a>';
|
||||||
|
|
||||||
array_push($table->data, $data);
|
array_push($table->data, $data);
|
||||||
@ -893,7 +910,9 @@ class ModuleTemplates extends HTML
|
|||||||
|
|
||||||
echo $javascript;
|
echo $javascript;
|
||||||
|
|
||||||
|
if ($createNewBlock === false) {
|
||||||
$this->addingModulesForm();
|
$this->addingModulesForm();
|
||||||
|
}
|
||||||
|
|
||||||
$this->printGoBackButton($this->baseUrl);
|
$this->printGoBackButton($this->baseUrl);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user