本文整理汇总了PHP中Campaign::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP Campaign::delete方法的具体用法?PHP Campaign::delete怎么用?PHP Campaign::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Campaign
的用法示例。
在下文中一共展示了Campaign::delete方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: delete
public function delete($id)
{
$id = (int) $id;
$this->load->model('Campaign');
$result = Campaign::delete($id);
if ($result === true) {
redirect('/Campaign/view_all');
} elseif ($result instanceof Standard_error) {
$this->layout->add_basic_assets()->menu()->view('others/form_failure', array('message' => $result->message));
}
}
示例2: admindeleteAction
function admindeleteAction()
{
$this->view->title = "Delete Campaign";
if ($this->_request->isPost()) {
$id = (int) $this->_request->getPost('id');
$del = $this->_request->getPost('del');
if ($del == 'Yes' && $id > 0) {
$campaignModel = new Campaign();
$where = 'id = ' . $id;
$campaignModel->delete($where);
}
$this->_redirect('campaign/adminindex');
} else {
$id = (int) $this->_request->getParam('id');
if ($id > 0) {
$campaignModel = new Campaign();
$this->view->campaign = $campaignModel->fetchRow('id=' . $id);
}
}
}
示例3: getAdminInterface
function getAdminInterface()
{
$this->addJS('/modules/Campaigns/js/voteadmin.js');
$this->addCSS('/modules/Campaigns/css/campaign.css');
switch (@$_REQUEST['section']) {
case 'addedit':
if ($this->user->hasPerm('addcampaign')) {
$campaign = new Campaign(@$_REQUEST['campaign_id']);
$form = $campaign->getAddEditForm();
$this->smarty->assign('form', $form);
$this->smarty->assign('status', $campaign->getId());
if ($form->isSubmitted() && isset($_REQUEST['submit'])) {
if ($form->validate()) {
return $this->topLevelAdmin();
}
}
return $this->smarty->fetch('admin/campaigns_addedit.tpl');
}
return $this->smarty->fetch('../../../cms/templates/error.tpl');
case 'campaigndelete':
$campaign = new Campaign($_REQUEST['campaign_id']);
if ($this->user->hasPerm('addcampaign') && $this->user->getAuthGroup() == $campaign->getGroup() && strpos($campaign->getStatus(), 'pcoming') > 0) {
$campaign->delete();
unset($campaign);
return $this->topLevelAdmin();
}
return $this->smarty->fetch('../../../cms/templates/error.tpl');
case 'viewresults':
if ($this->user->hasPerm('viewcampaign')) {
$campaign = new Campaign($_REQUEST['campaign_id']);
$this->smarty->assign('campaign', $campaign);
$campaign->addResultViewer($this->user->getId());
return $this->smarty->fetch('admin/campaign_results.tpl');
}
return $this->smarty->fetch('admin/campaign_recips_addedit.tpl');
case 'questionedit':
if ($this->user->hasPerm('addcampaign')) {
$campaign = new Campaign($_REQUEST['campaign_id']);
$this->smarty->assign('campaign', $campaign);
if (isset($_REQUEST['choices_submit'])) {
if (!is_null(@$_REQUEST['choice'])) {
foreach ($_REQUEST['choice'] as $key => $achoice) {
if (is_numeric($key)) {
$choice = new CampaignChoice($key);
if (!empty($achoice['main'])) {
$choice->setCampaign($_REQUEST['campaign_id']);
$choice->setChoice($achoice['main']);
$choice->save();
if (is_array(@$_REQUEST['choice'][$key])) {
$choice->createChildren($_REQUEST['choice'][$key]);
}
} else {
$choice->delete();
}
}
}
}
if (!is_null(@$_REQUEST['nChoice'])) {
if (isset($_REQUEST['nChoice'])) {
foreach ($_REQUEST['nChoice'] as $key => $achoice) {
if (!empty($achoice['main'])) {
$choice = new CampaignChoice();
$choice->setCampaign($_REQUEST['campaign_id']);
$choice->setChoice($achoice['main']);
$choice->save();
if (is_array(@$_REQUEST['nChoice'][$key])) {
$choice->createChildren($_REQUEST['nChoice'][$key]);
}
}
}
}
}
return $this->topLevelAdmin();
}
return $this->smarty->fetch('admin/campaign_choices_addedit.tpl');
}
return $this->smarty->fetch('../../../cms/templates/error.tpl');
case 'reciplist':
return $this->recipTopLevelAdmin();
case 'recipaddedit':
if ($this->user->hasPerm('addcampaignrecips')) {
if (!is_null(@$_REQUEST['recipient_id'])) {
$recipient = new CampaignUser($_REQUEST['recipient_id']);
} else {
$recipient = new CampaignUser();
$recipient->setGroup($this->user->getAuthGroup());
}
$form = $recipient->getAddEditForm();
$this->smarty->assign('form', $form);
if ($form->isSubmitted() && isset($_REQUEST['submit'])) {
if ($form->validate()) {
return $this->recipTopLevelAdmin();
}
}
return $this->smarty->fetch('admin/campaign_recips_addedit.tpl');
}
return $this->smarty->fetch('../../../cms/templates/error.tpl');
case 'recipcsvup':
if ($this->user->hasPerm('addcampaignrecips')) {
$form = Campaign::getCSVForm();
//.........这里部分代码省略.........
示例4: postProcess
public function postProcess()
{
//ADD
if (Tools::isSubmit('submitAddcampaign')) {
parent::validateRules();
if (count($this->errors)) {
return false;
}
// ADD WAY
if (!($id_campaign = (int) Tools::getValue('id_campaign')) && empty($this->errors)) {
$defaultLanguage = new Language((int) Configuration::get('PS_LANG_DEFAULT'));
// Include voucher :
// Create campaign :
$campaign = new Campaign();
$campaign->name = Tools::getValue('name');
$campaign->email_tpl = Tools::getValue('email_tpl');
$campaign->execution_time_day = Tools::getValue('execution_time_day');
$campaign->execution_time_hour = Tools::getValue('execution_time_hour');
$campaign->voucher_prefix = Tools::getValue('voucher_prefix');
$campaign->voucher_amount = Tools::getValue('voucher_amount');
$campaign->voucher_amount_type = Tools::getValue('voucher_amount_type');
$campaign->voucher_day = Tools::getValue('voucher_day');
$campaign->active = Tools::getValue('active');
// Create email files :
$path = _PS_ROOT_DIR_ . '/modules/superabandonedcart/mails/' . $defaultLanguage->iso_code . '/';
if (!file_exists($path)) {
if (!mkdir($path, 0777, true)) {
$this->errors[] = Tools::displayError('Mails directory could not be created. Please check system permissions');
}
}
$tpl_file_name = $campaign->getFileName('html');
// create html files
$f = fopen($path . $tpl_file_name, 'w');
fwrite($f, $campaign->email_tpl);
fwrite($f, PHP_EOL);
fclose($f);
$tpl_file_name = $campaign->getFileName('txt');
// create txt files
$f = fopen($path . $tpl_file_name, 'w');
fwrite($f, strip_tags($campaign->email_tpl));
fwrite($f, PHP_EOL);
fclose($f);
if (!$campaign->save()) {
$this->errors[] = Tools::displayError('An error has occurred: Can\'t save the current object');
}
// UPDATE WAY
} elseif ($id_campaign = Tools::getValue('id_campaign')) {
$defaultLanguage = new Language((int) Configuration::get('PS_LANG_DEFAULT'));
// Create campaign :
$campaign = new Campaign($id_campaign);
$campaign->name = Tools::getValue('name');
$campaign->email_tpl = Tools::getValue('email_tpl');
$campaign->execution_time_day = Tools::getValue('execution_time_day');
$campaign->execution_time_hour = Tools::getValue('execution_time_hour');
$campaign->voucher_prefix = Tools::getValue('voucher_prefix');
$campaign->voucher_amount = Tools::getValue('voucher_amount');
$campaign->voucher_amount_type = Tools::getValue('voucher_amount_type');
$campaign->voucher_day = Tools::getValue('voucher_day');
$campaign->active = Tools::getValue('active');
$path = _PS_ROOT_DIR_ . '/modules/superabandonedcart/mails/' . $defaultLanguage->iso_code . '/';
if (!file_exists($path)) {
if (!mkdir($path, 0777, true)) {
$this->errors[] = Tools::displayError('Mails directory could not be created. Please check system permissions');
}
}
$tpl_file_name = $campaign->getFileName('html');
// create html files
$f = fopen($path . $tpl_file_name, 'w');
fwrite($f, $campaign->email_tpl);
fwrite($f, PHP_EOL);
fclose($f);
$tpl_file_name = $campaign->getFileName('txt');
// create txt files
$f = fopen($path . $tpl_file_name, 'w');
fwrite($f, strip_tags($campaign->email_tpl));
fwrite($f, PHP_EOL);
fclose($f);
if (!$campaign->save()) {
$this->errors[] = Tools::displayError('An error has occurred: Can\'t save the current object');
}
}
} elseif (Tools::isSubmit('statuscampaign') && Tools::getValue($this->identifier)) {
if ($this->tabAccess['edit'] === '1') {
if (Validate::isLoadedObject($object = $this->loadObject())) {
if ($object->toggleStatus()) {
$identifier = (int) $object->id_parent ? '&id_campaign=' . (int) $object->id_parent : '';
Tools::redirectAdmin($this->context->link->getAdminLink('AdminSuperAbandonedCart'));
} else {
$this->errors[] = Tools::displayError('An error occurred while updating the status.');
}
} else {
$this->errors[] = Tools::displayError('An error occurred while updating the status for an object.') . ' <b>' . $this->table . '</b> ' . Tools::displayError('(cannot load object)');
}
} else {
$this->errors[] = Tools::displayError('You do not have permission to edit this.');
}
} elseif (Tools::getIsset('deletecampaign') && Tools::getValue($this->identifier)) {
$id_campaign = (int) Tools::getValue($this->identifier);
$b = new Campaign($id_campaign);
$b->delete();
//.........这里部分代码省略.........
示例5: realpath
* and open the template in the editor.
*/
if (!defined('SU')) {
die;
}
ini_set("display_errors", 1);
error_reporting(E_ALL);
include_once 'include/common.php';
$msg = "";
$error = "";
require_once realpath(dirname(__FILE__)) . '/../classes/dashboard/Campaign.php';
$campaign = new Campaign();
if (isset($_REQUEST['sub']) && $_REQUEST['sub'] == 'delete') {
if (isset($_REQUEST['id'])) {
$id = (int) $_REQUEST['id'];
if ($campaign->delete($id)) {
$msg = "Campaign deleted successfully";
} else {
$error = "Error deleting campaign";
}
}
}
$q = "SELECT * FROM campaigns";
$r = $db->Execute($q);
$campaigns = $campaign->get_campaigns();
?>
<div class="row">
<div class="col-sm-4">
<ol class="breadcrumb bc-3">
<li> <a href="admin.php?act=dashboard"><i class="entypo-home"></i>Dashboard</a> </li>
<li class="active"> <strong>Campaigns</strong> </li>
示例6: deleteAction
function deleteAction()
{
$id = AF::get($_POST, 'id', 0);
$modelsID = explode(',', $id);
$errors = FALSE;
foreach ($modelsID as $id) {
$model = new Campaign();
$model->model_uset_id = $this->user->user_id;
if ($model->findByPk($id)) {
// if beforeDelete() returns an error, indicate this to the user
if (!$model->delete($id)) {
$errors = TRUE;
}
} else {
$errors = TRUE;
}
if ($model->getErrors()) {
$errors = TRUE;
}
unset($model);
}
if (isset($_POST['ajax'])) {
AF::setJsonHeaders('json');
if ($errors) {
Message::echoJsonError(__('campaign_no_deleted'));
} else {
Message::echoJsonSuccess(__('campaign_deleted'));
}
}
$this->redirect();
}