当前位置: 首页>>代码示例>>PHP>>正文


PHP Ad::delete方法代码示例

本文整理汇总了PHP中Ad::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP Ad::delete方法的具体用法?PHP Ad::delete怎么用?PHP Ad::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Ad的用法示例。


在下文中一共展示了Ad::delete方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: handleGetQuery

 public static function handleGetQuery(array $sanitized_get_array)
 {
     // The result of the request
     $ajax_result = array('status' => '', 'message' => '', 'data' => '');
     $id = (int) $sanitized_get_array['id'];
     $mode = $sanitized_get_array['mode'];
     if ($mode == 'show') {
         $ad_fields = Ad::find_by_id($id)->getFieldsForTemplate();
         unset($ad_fields['db_fields']);
         $ajax_result['status'] = 'success';
         $ajax_result['data'] = $ad_fields;
     } elseif ($mode == 'delete') {
         $ad_title = Ad::find_by_id($id)->getTitle();
         $sanitized_ad_title = htmlentities($ad_title);
         Ad::delete($id);
         $ajax_result['status'] = 'success';
         if (Ad::count_all()) {
             $ajax_result['message'] = 'Ad "' . $sanitized_ad_title . '" has been deleted successfully';
         } else {
             $ajax_result['message'] = 'There is no more ads in database';
         }
     } else {
         $ajax_result['status'] = 'error';
         $ajax_result['message'] = 'Undefined mode';
     }
     return $ajax_result;
 }
开发者ID:gorvic,项目名称:L17,代码行数:27,代码来源:Ad.php

示例2: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     /*
      * Verifies access to the particular AD.
      */
     if (Yii::app()->user->checkAccess('AdCreate', $this->bizruleCreate())) {
         $model = new Ad();
         // Uncomment the following line if AJAX validation is needed
         // $this->performAjaxValidation($model);
         if (isset($_POST['Ad'])) {
             $model->attributes = $_POST['Ad'];
             if ($model->save()) {
                 $screenAdAssignment = new ScreenAdAssignment();
                 $screenAdAssignment->ad_id = $model->id;
                 $screenAdAssignment->screen_id = $this->_screen->id;
                 if ($screenAdAssignment->save()) {
                     Yii::app()->user->setFlash('success', YII::t('ad', 'Ad created successfully.'));
                     $this->redirect(array('screen/view', 'id' => $this->_screen->id));
                 } else {
                     Yii::app()->user->setFlash('error', YII::t('ad', 'Could not assign the Ad to the Screen.'));
                     $model->delete();
                 }
             }
         }
         $this->render('create', array('model' => $model));
     } else {
         throw new CHttpException(403, YII::t('default', 'You are not authorized to perform this action.'));
     }
 }
开发者ID:nurielmeni,项目名称:nymedia,代码行数:33,代码来源:AdController.php

示例3: pageController

function pageController()
{
    session_start();
    if (!Auth::check()) {
        header('Location: /auth/login');
        exit;
    }
    $username = Auth::user();
    $user = User::findUserByUsername($username);
    $adid = Input::get('id');
    $ad = Ad::find($adid);
    $item_name = $ad->attributes['item_name'];
    $price = $ad->attributes['price'];
    $description = $ad->attributes['description'];
    $image_path = $ad->attributes['image_path'];
    $contact = $ad->attributes['contact'];
    $errors = array();
    if (!empty($_POST)) {
        if (Input::notEmpty('item_name')) {
            $item_name = ValidateAd::getItemName();
        }
        if (Input::notEmpty('price')) {
            $price = ValidateAd::getPrice();
        }
        if (Input::notEmpty('description')) {
            $description = ValidateAd::getDescription();
        }
        if (Input::notEmpty('contact')) {
            $contact = ValidateAd::getContact();
        }
        $errors = ValidateAd::getErrors();
        if (empty($errors)) {
            $ad->attributes['item_name'] = $item_name;
            $ad->attributes['price'] = $price;
            $ad->attributes['description'] = $description;
            $ad->attributes['contact'] = $contact;
            $ad->attributes['image_path'] = $image_path;
            $ad->save();
        }
        if (!Input::notEmpty('delete-id')) {
            //if the form has been submitted
            Ad::delete($ad->attributes['id']);
            header("Location: /ads");
            die;
            //delete the specific ad - going to need to somehow tie in the ad id to the delete buttn for that specific id
        }
    }
    return array('ad' => $ad, 'username' => $username, 'item_name' => $item_name, 'price' => $price, 'description' => $description, 'image_path' => $image_path, 'contact' => $contact);
}
开发者ID:adlisterproject,项目名称:sketchy-b,代码行数:49,代码来源:edit.php

示例4: header

<?php

require_once '../bootstrap.php';
if (!Auth::check()) {
    header("Location: login.php");
    exit;
}
$ads = [];
$ads = Ad::all();
if (Input::has('id') && Input::get('id') >= 0) {
    $id = Input::get('id');
} else {
    $id = 0;
}
Ad::isOwner($ads[$id]['user_id']);
Ad::delete($id);
header("Refresh: 3;url=/profile");
?>

<html>
<head>
    <title>Instrument Exchange</title>
    <!-- Bootstrap styling -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
    <!-- Custom styling for site -->
    <link rel="stylesheet" type="text/css" href="../css/main.css">
</head>
<body>
    <?// include "../views/partials/navbar.php"; ?>

开发者ID:asleepArmadillo,项目名称:Adlister,代码行数:29,代码来源:deletesuccess.php

示例5: header

 * Admin area
 * 
 * @copyright  Copyright (c) Szilard Szabo
 * @license    GPL v3
 * @package    Admin
 */
include "./include/common.php";
include "Pager/Pager.php";
if (!User::is_logged_in() || User::get_id() != 1) {
    header('Location: index.php');
    exit;
}
if (isset($_GET['d'])) {
    $d = (int) $_GET['d'];
    if ($d > 0) {
        Ad::delete($d);
    }
}
if (isset($_GET['o'])) {
    $o = (int) $_GET['o'];
    $r = (int) $_GET['r'];
    if ($r != 0) {
        $r = 1;
    }
    $a['sponsored'] = $r;
    $a['sponsoredon'] = $r = 0 ? '' : date('Y-m-d', time());
    Ad::update($o, $a);
}
$tct = Ad::count();
//total count
$rpp = 10;
开发者ID:noverkill,项目名称:classified-ads-script,代码行数:31,代码来源:ad-list.php

示例6: header

<?php

/**
 * Classified-ads-script
 * 
 * @copyright  Copyright (c) Szilard Szabo
 * @license    GPL v3
 * @package    Frontend
 */
include "./admin/include/common.php";
if (!User::is_logged_in() || User::get_id() != 1) {
    header('Location: index.php');
    exit;
}
$id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
$exists = User::exists(0, array('id' => $id));
if ($exists) {
    $user = User::get_one($id);
    UserBanned::create($user, $id);
    Ad::delete(0, array('user_id' => $id));
    User::delete($id);
}
include "./templates/user-ban.php";
开发者ID:noverkill,项目名称:classified-ads-script,代码行数:23,代码来源:user-ban.php

示例7: campaign

 /**
  * @before _secure
  * @after _cleanUp
  */
 public function campaign($id = null)
 {
     $view = $this->getActionView();
     $org = $this->_org;
     $active = RequestMethods::get('active', 1);
     $fields = ['_id', 'title', 'description', 'image', 'url', 'device', 'expiry', 'created'];
     $commFields = ['model', 'rate', 'revenue', 'coverage'];
     if ($id) {
         $campaign = Ad::first(['_id' => $id, 'org_id' => $org->_id], $fields);
     } else {
         $campaign = null;
     }
     if ($id && !$campaign) {
         return $this->failure('30');
     }
     $type = RequestMethods::type();
     switch ($type) {
         case 'GET':
             if (!$id) {
                 // display list of campaigns
                 $ads = Ad::all(['org_id' => $org->_id, 'live' => $active], $fields);
                 $ads = Ad::objectArr($ads, $fields);
                 $results = [];
                 foreach ($ads as $id => $a) {
                     $arr = Utils::toArray($a);
                     $comms = Commission::all(['ad_id' => $a->_id], $commFields);
                     $arr['commissions'] = Ad::objectArr($comms, $commFields);
                     $results[$id] = (object) $arr;
                 }
                 $data = ['campaigns' => $results];
                 $view->set('data', $data);
             } else {
                 $ads = Ad::objectArr($campaign, $fields);
                 $campaign = array_shift($ads);
                 $comm = Commission::all(['ad_id' => $campaign->_id], $commFields);
                 $data = ['campaign' => $campaign, 'commissions' => Commission::objectArr($comm, $commFields)];
                 $view->set('data', $data);
             }
             break;
         case 'POST':
             if ($id) {
                 // edit a particular campaign
             } else {
                 // create a new campaign
                 $fields = ['title', 'description', 'url', 'expiry', 'category', 'device', 'user_id'];
                 $img = RequestMethods::post('image');
                 // contains image url
                 $campaign = new Ad(['org_id' => $org->_id, 'type' => 'article', 'image' => Utils::media($img, 'download')]);
                 foreach ($fields as $f) {
                     $campaign->{$f} = RequestMethods::post($f);
                 }
                 $view->set('success', false);
                 $visibility = RequestMethods::post('visibility', 'public');
                 if ($visibility === 'private') {
                     $campaign->getMeta()['private'] = true;
                 }
                 $opts = ['devices' => array_keys(Shared\Markup::devices()), 'advertisers' => $org->users('advertiser', false)];
                 if (true) {
                     // $campaign->save();
                     $arr = ArrayMethods::reArray($_POST['commissions']);
                     var_dump($arr);
                     var_dump($_POST['commissions']);
                     $view->set('success', true);
                 } else {
                     $data = ['errors' => $campaign->errors];
                     $view->set('data', $data);
                 }
             }
             break;
         case 'DELETE':
             $message = $campaign->delete();
             $view->set($message);
             break;
     }
 }
开发者ID:vNative,项目名称:vnative,代码行数:79,代码来源:api.php

示例8: header

} else {
    header("Location: welcome.php");
    exit;
}
if (Input::has('logout') && $_GET['logout'] == 'true') {
    Auth::logoutUser();
    header("Location: welcome.php");
    exit;
}
if (empty($_GET['page'])) {
    $page = '1';
} else {
    $page = $_GET['page'];
}
if (!empty($_GET['delete'])) {
    Ad::delete($_GET['id']);
}
$user = $_SESSION['email'];
$userPosts = Ad::paginateUserAds(5, ($page - 1) * 5, $user);
?>
<html>
<head>
    <title>Home</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">

    <link rel="stylesheet" href="../css/sidebar.css">
    <link rel="stylesheet" href="../css/custom.css"> 

    <link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
</head>
开发者ID:adLister,项目名称:AdLister,代码行数:31,代码来源:myaccount.php

示例9: Ad

require 'connect_to_db.php';
require_once __DIR__ . "/firephp/FirePHP.class.php";
$firePHP = FirePHP::getInstance(true);
$firePHP->setEnabled(true);
require 'HtmlOption.php';
require 'functions_DbSimple.php';
require 'Ad.php';
require 'AdStorage.php';
require 'AdCompany.php';
require 'AdPrivate.php';
$db->setErrorHandler('databaseErrorHandler');
$db->setLogger('myLogger');
if (!empty($_GET['action']) && $_GET['action'] === 'delete') {
    $ad = new Ad();
    $ad->setId($_GET['id']);
    echo $ad->delete($db);
    die;
}
$smarty_dir = __DIR__ . '/smarty/';
require_once $smarty_dir . 'libs/Smarty.class.php';
$smarty = new Smarty();
$smarty->compile_check = true;
$smarty->debugging = true;
$smarty->template_dir = $smarty_dir . 'templates/';
$smarty->compile_dir = $smarty_dir . 'templates_c/';
$smarty->config_dir = $smarty_dir . 'configs/';
$smarty->cache_dir = $smarty_dir . 'cache/';
if (!empty($_POST)) {
    $id = !empty($_POST['id']) ? $_POST['id'] : null;
    if ($_POST['type'] === 'private') {
        $ad = new AdPrivate($_POST);
开发者ID:nakuzm,项目名称:Ads12,代码行数:31,代码来源:index.php

示例10: array

<?php

/**
 * Classified-ads-script
 * 
 * @copyright  Copyright (c) Szilard Szabo
 * @license    GPL v3
 * @package    Frontend
 */
include "./admin/include/common.php";
include "./admin/include/thumb.php";
$panels = array();
$g_id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
$g_code = isset($_GET['code']) ? trim(strip_tags($_GET['code'])) : '';
$exists = Ad::exists($g_id, array("code" => $g_code, "active" => 1));
if ($exists) {
    Ad::delete($g_id, array("code" => $g_code));
}
include "./templates/ad-removal.php";
开发者ID:noverkill,项目名称:classified-ads-script,代码行数:19,代码来源:ad-removal.php


注:本文中的Ad::delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。