NEW Can delete a website even if not empty
This commit is contained in:
parent
5e94e46461
commit
37c725fc6c
@ -4914,8 +4914,9 @@ class Form
|
||||
* @param string $question Question
|
||||
* @param string $action Action
|
||||
* @param array|string $formquestion An array with complementary inputs to add into forms: array(array('label'=> ,'type'=> , 'size'=>, 'morecss'=>, 'moreattr'=>'autofocus' or 'style=...'))
|
||||
* 'type' can be 'hidden', 'text', 'password', 'checkbox', 'radio', 'date', 'select', 'multiselect', 'morecss', 'other' or 'onecolumn'...
|
||||
* @param string $selectedchoice '' or 'no', or 'yes' or '1' or '0'
|
||||
* 'type' can be 'text', 'password', 'checkbox', 'radio', 'date', 'select', 'multiselect', 'morecss',
|
||||
* 'other', 'onecolumn' or 'hidden'...
|
||||
* @param int|string $selectedchoice '' or 'no', or 'yes' or '1', 1, '0' or 0
|
||||
* @param int|string $useajax 0=No, 1=Yes, 2=Yes but submit page with &confirm=no if choice is No, 'xxx'=Yes and preoutput confirm box with div id=dialog-confirm-xxx
|
||||
* @param int|string $height Force height of box (0 = auto)
|
||||
* @param int $width Force width of box ('999' or '90%'). Ignored and forced to 90% on smartphones.
|
||||
|
||||
@ -324,7 +324,8 @@ WarningAvailableOnlyForHTTPSServers=Available only if using HTTPS secured connec
|
||||
WarningModuleXDisabledSoYouMayMissEventHere=Module %s has not been enabled. So you may miss a lot of event here.
|
||||
WarningPaypalPaymentNotCompatibleWithStrict=The value 'Strict' makes the online payment features not working correctly. Use 'Lax' instead.
|
||||
WarningThemeForcedTo=Warning, theme has been forced to <b>%s</b> by hidden constant MAIN_FORCETHEME
|
||||
|
||||
WarningPagesWillBeDeleted=Warning, this will also delete all existing pages/containers of the website. You should export your website before, so you have a backup to re-import it later.
|
||||
|
||||
# Validate
|
||||
RequireValidValue = Value not valid
|
||||
RequireAtLeastXString = Requires at least %s character(s)
|
||||
|
||||
@ -524,7 +524,7 @@ class MyObject extends CommonObject
|
||||
* Delete object in database
|
||||
*
|
||||
* @param User $user User that deletes
|
||||
* @param bool $notrigger false=launch triggers after, true=disable triggers
|
||||
* @param bool $notrigger false=launch triggers, true=disable triggers
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
public function delete(User $user, $notrigger = false)
|
||||
|
||||
@ -30,6 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
|
||||
//require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
|
||||
//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
|
||||
|
||||
|
||||
/**
|
||||
* Class Website
|
||||
*/
|
||||
@ -50,6 +51,10 @@ class Website extends CommonObject
|
||||
*/
|
||||
public $ismultientitymanaged = 1;
|
||||
|
||||
|
||||
protected $childtablesoncascade = array();
|
||||
|
||||
|
||||
/**
|
||||
* @var string String with name of icon for website. Must be the part after the 'object_' into object_myobject.png
|
||||
*/
|
||||
@ -580,8 +585,8 @@ class Website extends CommonObject
|
||||
/**
|
||||
* Delete object in database
|
||||
*
|
||||
* @param User $user User that deletes
|
||||
* @param bool $notrigger false=launch triggers after, true=disable triggers
|
||||
* @param User $user User that deletes
|
||||
* @param bool $notrigger false=launch triggers, true=disable triggers
|
||||
*
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
@ -596,20 +601,8 @@ class Website extends CommonObject
|
||||
$this->db->begin();
|
||||
|
||||
if (!$error) {
|
||||
if (!$notrigger) {
|
||||
// Uncomment this and change WEBSITE to your own tag if you
|
||||
// want this action calls a trigger.
|
||||
|
||||
//// Call triggers
|
||||
//$result=$this->call_trigger('WEBSITE_DELETE',$user);
|
||||
//if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
|
||||
//// End call triggers
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element;
|
||||
$sql .= ' WHERE rowid='.((int) $this->id);
|
||||
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'website_page';
|
||||
$sql .= ' WHERE fk_website = '.((int) $this->id);
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql) {
|
||||
@ -619,6 +612,12 @@ class Website extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
// Delete common code. This include execution of trigger.
|
||||
$result = $this->deleteCommon($user, $notrigger);
|
||||
if ($result <= 0) {
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (!$error && !empty($this->ref)) {
|
||||
$pathofwebsite = DOL_DATA_ROOT.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/'.$this->ref;
|
||||
|
||||
|
||||
@ -1230,7 +1230,7 @@ if ($action == 'confirm_deletesite' && $confirm == 'yes' && $permissiontodelete)
|
||||
exit;
|
||||
} else {
|
||||
$db->rollback();
|
||||
dol_print_error($db);
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
@ -2741,7 +2741,8 @@ if (!GETPOST('hide_websitemenu')) {
|
||||
|
||||
print '<input type="submit" class="button bordertransp"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("CloneSite")).'" name="createfromclone">';
|
||||
|
||||
print '<input type="submit" class="buttonDelete bordertransp" name="deletesite" value="'.$langs->trans("Delete").'"'.($atleastonepage ? ' disabled="disabled"' : '').'>';
|
||||
//print '<input type="submit" class="buttonDelete bordertransp" name="deletesite" value="'.$langs->trans("Delete").'"'.($atleastonepage ? ' disabled="disabled"' : '').'>';
|
||||
print '<input type="submit" class="buttonDelete bordertransp" name="deletesite" value="'.$langs->trans("Delete").'">';
|
||||
|
||||
// Regenerate all pages
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=regeneratesite&token='.newToken().'&website='.urlencode($website->ref).'" class="button bordertransp"'.$disabled.' title="'.dol_escape_htmltag($langs->trans("RegenerateWebsiteContent")).'"><span class="far fa-hdd"></span></a>';
|
||||
@ -2964,7 +2965,12 @@ if (!GETPOST('hide_websitemenu')) {
|
||||
//array('type' => 'other','name' => 'newwebsite','label' => $langs->trans("WebSite"), 'value' => $formwebsite->selectWebsite($object->id, 'newwebsite', 0))
|
||||
);
|
||||
|
||||
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteWebsite'), '', 'confirm_deletesite', $formquestion, 0, 1, 200);
|
||||
if ($atleastonepage) {
|
||||
$langs->load("errors");
|
||||
$formquestion[] = array('type' => 'onecolumn', 'value' => '<div class="warning">'.$langs->trans("WarningPagesWillBeDeleted").'</div>');
|
||||
}
|
||||
|
||||
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteWebsite'), '', 'confirm_deletesite', $formquestion, 0, 1, 210 + ($atleastonepage ? 70 : 0), 580);
|
||||
|
||||
print $formconfirm;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user