delete() public method

It does not take care on database info upgrade because it trusts of the cool Template::UpdateStatus() function.
public delete ( ) : mixed
return mixed
function friendOrStranger($dataBase, $table, $receiver_id)
{
    //    $db = new Connect($dataBase,$table);
    $template = new Template();
    $check = $template->selectWhere($dataBase, $table, array('sender_id' => $_SESSION['userId'], 'receiver_id' => $receiver_id));
    if ($check) {
        $template->delete($dataBase, $table, $_SESSION['userId'], $receiver_id);
        $returnResult = 'Добави';
    } else {
        $template->insert($dataBase, $table, array('sender_id' => $_SESSION['userId'], 'receiver_id' => $receiver_id));
        $returnResult = 'Премахни';
    }
    return json_encode($returnResult);
}
Example #2
0
 public function delete()
 {
     $template = new Template($this->getFileName());
     $template->delete();
     return new JSONResponse(false, 'success', $this->translate('_template_has_been_successfully_deleted'));
 }
Example #3
0
 function deleteAction()
 {
     $id = AF::get($_POST, 'id', 0);
     $modelsID = explode(',', $id);
     $errors = FALSE;
     foreach ($modelsID as $id) {
         $model = new Template();
         $model->model_uset_id = $this->user->user_id;
         if ($model->fillFromDbPk($id)) {
             $model->delete($id);
         } else {
             $errors = TRUE;
         }
         if ($model->getErrors()) {
             $errors = TRUE;
         }
         unset($model);
     }
     if (isset($_POST['ajax'])) {
         AF::setJsonHeaders('json');
         if ($errors) {
             Message::echoJsonError(__('template_not_deleted'));
         } else {
             $countE = AF::get($_POST, 'countE', 100000);
             if (count($modelsID) >= $countE) {
                 $link = AF::link(array('templates' => 'view'));
                 Message::echoJsonRedirect($link);
             } else {
                 Message::echoJsonSuccess(__('template_deleted'));
             }
         }
     }
     $this->redirect();
 }
Example #4
0
if (!$isFile) {
        $deleted = rmdir($fileFullPath.$Name);
	if ($deleted) {
		$logtext = getGS('Directory $1 was deleted', mysql_real_escape_string($fileFullName));
		Log::Message($logtext, $g_user->getUserId(), 112);
		camp_html_add_msg($logtext, "ok");
	} else {
		camp_html_add_msg(camp_get_error_message(CAMP_ERROR_RMDIR, $fileFullPath));
	}
} else {
	$inUse = Template::InUse($fileFullName);
	if ($inUse === CAMP_ERROR_READ_FILE || $inUse === CAMP_ERROR_READ_DIR) {
                camp_html_add_msg(getGS("There are some files which can not be readed so Newscoop was not able to determine whether '$1' is in use or not. Please fix this, then try to delete the template again.", basename($fileFullName)));
	} elseif ($inUse == false) {
	        $template = new Template($fileFullName);
		if ($template->exists() && $template->delete()) {
			// Clear compiled template
			require_once($GLOBALS['g_campsiteDir']."/template_engine/classes/CampTemplate.php");
			CampTemplate::singleton()->clear_compiled_tpl($fileFullName);

			$logtext = getGS('Template object $1 was deleted', mysql_real_escape_string($fileFullName));
			Log::Message($logtext, $g_user->getUserId(), 112);
			camp_html_add_msg($logtext, "ok");
		} else {
			camp_html_add_msg(camp_get_error_message(CAMP_ERROR_DELETE_FILE, $fileFullName));
		}
	} else {
		camp_html_add_msg(getGS("The template object $1 is in use and can not be deleted.", $fileFullName));
	}
}
Example #5
0
<?php

//Imports
require_once 'session.php';
require_once 'variables_site.php';
require_once 'db/db_conn.php';
require_once 'db/SELECT.php';
require_once 'db/DELETE.php';
require_once 'classes/Template.php';
if (!isset($_POST['id']) || !is_numeric($_POST['id'])) {
    http_response_code(400);
    exit;
}
$con = connect_db();
$ADK_MSG_TMPL = new Template();
$ADK_MSG_TMPL->id = intval($_POST['id']);
$ADK_MSG_TMPL->delete($con);
$ADK_MSG_TMPLS = new Templates();
$ADK_MSG_TMPLS->get($con, $_SESSION['ADK_USER_ID']);
$con->close();
echo json_encode($ADK_MSG_TMPLS);
http_response_code(200);
 /**
  * @return array Errors  Import Template information
  */
 public static function importTemplates($root, $companyId, &$errors)
 {
     $nodeTemplates = $root->getElementsByTagName('template');
     foreach ($nodeTemplates as $nodeTemplate) {
         if ($root->getAttribute('version') > 1.0) {
             $errors[] = '*TemplateVersion*' . Yii::t('lazy8', 'There maybe problems because this is a file version greater then this programs version');
             $errors[] = Yii::t('lazy8', 'Select a file and try again');
         }
         $modelTemplate = new Template();
         $modelTemplate->companyId = $companyId;
         $modelTemplate->name = $nodeTemplate->getAttribute('name');
         $modelTemplate->desc = $nodeTemplate->getAttribute('desc');
         $modelTemplate->sortOrder = $nodeTemplate->getAttribute('sortorder');
         $modelTemplate->allowAccountingView = $nodeTemplate->getAttribute('allowaccountingview') == '1' ? 1 : 0;
         $modelTemplate->allowFreeTextField = $nodeTemplate->getAttribute('allowfreetextfield') == '1' ? 1 : 0;
         $modelTemplate->freeTextFieldDefault = $nodeTemplate->getAttribute('freetextfielddefault');
         $modelTemplate->allowFilingTextField = $nodeTemplate->getAttribute('allowfilingtextfield') == '1' ? 1 : 0;
         $modelTemplate->filingTextFieldDefault = $nodeTemplate->getAttribute('filingtextfielddefault');
         $modelTemplate->forceDateToday = $nodeTemplate->getAttribute('forcedatetoday');
         if (!$modelTemplate->save()) {
             $errors[] = Yii::t('lazy8', 'Could not create the modelTemplate, bad paramters') . ';name=' . $modelTemplate->name . ';' . serialize($modelTemplate->getErrors());
             return $errors;
         }
         $nodesTemplateRows = $nodeTemplate->getElementsByTagName('templaterow');
         foreach ($nodesTemplateRows as $nodesTemplateRow) {
             $modelTemplateRow = new TemplateRow();
             $modelTemplateRow->templateId = $modelTemplate->id;
             $modelTemplateRow->name = $nodesTemplateRow->getAttribute('name');
             $modelTemplateRow->desc = $nodesTemplateRow->getAttribute('desc');
             $modelTemplateRow->sortOrder = $nodesTemplateRow->getAttribute('sortorder');
             $modelTemplateRow->isDebit = $nodesTemplateRow->getAttribute('isdebit') == '1' ? 1 : 0;
             $modelTemplateRow->defaultAccountId = Template::FindAccountId($nodesTemplateRow->getAttribute('defaultaccount'), $modelTemplate->companyId);
             $modelTemplateRow->defaultValue = $nodesTemplateRow->getAttribute('defaultvalue');
             $modelTemplateRow->allowMinus = $nodesTemplateRow->getAttribute('allowminus') == '1' ? 1 : 0;
             $modelTemplateRow->phpFieldCalc = $nodesTemplateRow->getAttribute('phpfieldcalc');
             $modelTemplateRow->allowChangeValue = $nodesTemplateRow->getAttribute('allowchangevalue') == '1' ? 1 : 0;
             $modelTemplateRow->allowRepeatThisRow = $nodesTemplateRow->getAttribute('allowrepeatthisrow') == '1' ? 1 : 0;
             $modelTemplateRow->allowCustomer = $nodesTemplateRow->getAttribute('allowcustomer') == '1' ? 1 : 0;
             $modelTemplateRow->allowNotes = $nodesTemplateRow->getAttribute('allownotes') == '1' ? 1 : 0;
             $modelTemplateRow->isFinalBalance = $nodesTemplateRow->getAttribute('isfinalbalance') == '1' ? 1 : 0;
             if (!$modelTemplateRow->save()) {
                 $modelTemplate->delete();
                 $errors[] = Yii::t('lazy8', 'Could not create the TemplateRow, bad paramters') . ';' . serialize($modelTemplateRow->getErrors());
                 return;
             }
             $nodesTemplateRowAccounts = $nodesTemplateRow->getElementsByTagName('templaterowaccount');
             foreach ($nodesTemplateRowAccounts as $nodesTemplateRowAccount) {
                 $modelTemplateRowAccount = new TemplateRowAccount();
                 $modelTemplateRowAccount->templateRowId = $modelTemplateRow->id;
                 $modelTemplateRowAccount->accountId = Template::FindAccountId($nodesTemplateRowAccount->getAttribute('code'), $modelTemplate->companyId);
                 if ($modelTemplateRowAccount->accountId != 0) {
                     if (!$modelTemplateRowAccount->save()) {
                         $modelTemplate->delete();
                         $errors[] = Yii::t('lazy8', 'Could not create the TemplateRowAccount, bad paramters') . ';' . serialize($modelTemplateRowAccount->getErrors());
                         return;
                     }
                 } else {
                     $errors[] = Yii::t('lazy8', 'Could not create the Account, bad account number') . ';' . $nodesTemplateRowAccount->getAttribute('code');
                 }
             }
         }
     }
 }
	if (!$g_user->hasPermission('DeleteTempl')) {
		camp_html_display_error(getGS("You do not have the right to delete templates."));
		exit;
	}
	break;
}

$templateCodes = $f_template_codes;

switch ($f_template_list_action) {
case "delete":
	$anyDeleted = 0;
	$anyInUse = 0;
	foreach ($templateCodes as $templateCode) {
		$templateObj = new Template($templateCode);
		$deleted = $templateObj->delete();
		if ($deleted == true) {
			$anyDeleted = 1;
		} elseif (!$anyInUse) {
			$anyInUse = 1;
		}
	}
	if ($anyDeleted == 1) {
	        // Clear compiled templates
	        require_once($GLOBALS['g_campsiteDir']."/template_engine/classes/CampTemplate.php");
		CampTemplate::singleton()->clear_compiled_tpl();
		camp_html_add_msg(getGS("Template(s) deleted."), "ok");
	}
	if ($anyInUse == 1) {
		camp_html_add_msg(getGS("Some templates could not be deleted because they are in use."));
	}