Permalink
Browse files

tinggal 404

  • Loading branch information...
wie88 committed Mar 11, 2013
1 parent 5f2c4a0 commit f158defdf21a15414e9c359310aa4ae9ab05ebf7
View
29 app/Controller/AdsController.php 100644 → 100755
@@ -21,7 +21,7 @@ class AdsController extends AppController {
public function isAuthorized($user) {
parent::isAuthorized($user);
- if($this->request->params['action'] && $this->Auth->user('rule')!="admin"){
+ if($this->request->params['action'] == "confirm" && $this->Auth->user('rule')!="admin"){
return false;
}
return true;
@@ -158,6 +158,30 @@ public function showByUser(){
}
}
+ public function showActive(){
+ if($this->request->is("Ajax")){
+ $this->autoRender = false;
+ $this->autoLayout = false;
+ $id = $this->Auth->user('id');
+ $this->paginate = array("limit"=>5,'conditions'=>array('Ad.User_id'=>$id,'Ad.status'=>1));
+ $result = $this->paginate('Ad');
+ $this->set('ads',$result);
+ $this->render("showIklan");
+ }
+ }
+
+ public function showNonActive(){
+ if($this->request->is("Ajax")){
+ $this->autoRender = false;
+ $this->autoLayout = false;
+ $id = $this->Auth->user('id');
+ $this->paginate = array("limit"=>5,'conditions'=>array('Ad.User_id'=>$id,'Ad.status'=>0));
+ $result = $this->paginate('Ad');
+ $this->set('ads',$result);
+ $this->render("showIklan");
+ }
+ }
+
public function edit(){
if($this->request->isAjax()){
$this->autoLayout = False;
@@ -166,7 +190,8 @@ public function edit(){
$data = array(
"Ad.ads_title"=>"'".$this->request->data['Ad']['ads_title']."'",
"Ad.category_id"=>$this->request->data['Ad']['category_id'],
- "Ad.ads_body"=>"'".$this->request->data['Ad']['ads_body']."'"
+ "Ad.ads_body"=>"'".$this->request->data['Ad']['ads_body']."'",
+ "Ad.status"=>0
);
$filePath = WWW_ROOT.DS."files".DS.$this->request->data['Ad']['id'].".jpg";
if($this->request->data['Ad']['image']['tmp_name']!=""){
@@ -0,0 +1,88 @@
+<div id="content-inside">
+<?php foreach($ads as $ad):?>
+ <div class="Ads-box box-shadow">
+ <div class="Ads-image">
+ <?= $this->Html->image('../files/'.$ad['Ad']['image'],array('class'=>'Ads-image')) ?>
+ </div>
+ <div class="Ads-content">
+ <h2><?= $ad['Ad']['ads_title'] ?></h2>
+ <p><?= $ad['Ad']['ads_body'] ?></p>
+ </div>
+ <div class="Ads-contact">
+ <strong>C : <?= $ad['User']['first_name']." ".$ad['User']['last_name'] ?> <br/> +62<?= $ad['User']['handphone'] ?> </strong>
+ </div>
+ <?php if($loggedInUser['id'] == $ad['User']['id']): ?>
+ <div class="menu-ads">
+ <?= $this->Html->link('hapus',array("controller"=>"ads","action"=>"delete"),array('class'=>'delete-link','aid'=>hash("sha256",rand(1000000,1000000000000000000000000000000000)),'ad'=>$ad['Ad']['id'])); ?>
+ |
+ <?= $this->Html->link('edit',array("controller"=>"ads","action"=>"edit"),array('class'=>'edit-link','aid'=>hash("sha256",rand(1000000,1000000000000000000000000000000000)),'ad'=>$ad['Ad']['id'])); ?>
+ </div>
+ <?php endif; ?>
+ </div>
+<?php endforeach; ?>
+</div>
+<div id="page-nav" style="position: relative;display:none;">
+ <?php echo $this->paginator->numbers(); ?>
+</div>
+<?= $this->Html->script('jquery.ads-add'); ?>
+<?= $this->Html->script('jquery.edit.delete'); ?>
+<script>
+
+ $(document).ready(function(){$(".active-menu-item").removeClass("active-menu-item");$("#iklan").addClass("active-menu-item")});
+
+ $('#content-inside').masonry({
+ itemSelector: '.Ads-box'
+ });
+
+ $("#content-inside").infinitescroll({
+ navSelector : '#page-nav', // selector for the paged navigation
+ nextSelector : '#page-nav a', // selector for the NEXT link (to page 2)
+ itemSelector : '.Ads-box', // selector for all items you'll retrieve
+ loading: {
+ finishedMsg: 'No more pages to load.',
+ img: 'http://i.imgur.com/6RMhx.gif'
+ }
+ },
+ function( newElements ) {
+ $elem = $(newElements);
+ $elem.find('.delete-link').click(function(e){
+ e.preventDefault();
+ if(window.confirm("Apakah anda yakin ingin menghapus iklan ini?")){
+ $(this).parent().parent().addClass('delete-mark');
+ $.post($(this).attr("href"),{id:$(this).attr("ad")},handleDelete,"JSON");
+ }
+ });
+
+ function handleDelete(response){
+ if(response.status == 1){
+ $(".delete-mark").fadeOut("fast").remove();
+ $('#content-inside').masonry('reload');
+ }
+ else{
+ alert("Penghapusan Iklan gagal. Silahkan refresh halaman ini");
+ }
+ }
+ $elem.find(".edit-link").click(function(e){
+ e.preventDefault();
+ $(this).parent().parent().addClass('edit-mark');
+ $.post($(this).attr('href'),{id:$(this).attr('ad')},handleEdit,"HTML");
+ });
+
+ function handleEdit(response){
+ $("#container").after($(response));
+ }
+ $("#content-inside").masonry('appended',$elem,true);
+
+ }
+ );
+</script>
+<style>
+ #infscr-loading{
+ position:absolute;
+ bottom:10px;
+ left:50%;
+ margin-left:-100px;
+ width:200px;
+ text-align: center;
+ }
+</style>
@@ -105,7 +105,12 @@ $cakeDescription = __d('cake_dev', 'CakePHP: the rapid development php framework
<div id="content">
<div id="left-nav">
<ul id="nav-main">
- <li><a href="javascript:void(0)" class="nav-menu-item" hash="iklan" id="iklan" link="<?= Router::url(array("controller"=>"ads","action"=>"showByUser")) ?>">Iklan Saya</a></li>
+ <li><a href="javascript:void(0)" class="nav-menu-item" hash="iklan" id="iklan" link="<?= Router::url(array("controller"=>"ads","action"=>"showByUser")) ?>">Iklan Saya</a>
+ <ul>
+ <li><a href="javascript:void(0)" class="nav-menu-sub-item" hash="iklan-aktif" link="<?= Router::url(array("controller"=>"ads","action"=>"showActive")) ?>">Iklan Aktif</a></li>
+ <li><a href="javascript:void(0)" class="nav-menu-sub-item" hash="iklan-non-aktif" link="<?= Router::url(array("controller"=>"ads","action"=>"showNonActive")) ?>">Iklan Non Aktif</a></li>
+ </ul>
+ </li>
<li>
<a href="javascript:void(0)" class="nav-menu-item active-menu-item" id="profil-button">Profil</a>
<ul>
@@ -127,10 +132,6 @@ $cakeDescription = __d('cake_dev', 'CakePHP: the rapid development php framework
<li>Copyright &copy; 2013 Futura Creative Inc.</li>
<li>Contact Us</li>
</ul>
- <ul class="icons">
- <li><?= $this->Html->image('fb-icon.png') ?></li>
- <li><?= $this->Html->image('tw-icon.png') ?></li>
- </ul>
</div>
</div>
<?= $this->Html->script('jquery.user.menu'); ?>
@@ -1,2 +1,2 @@
-1362736999
+1362993244
a:11:{s:2:"id";a:5:{s:4:"type";s:7:"integer";s:4:"null";b:0;s:7:"default";N;s:6:"length";i:10;s:3:"key";s:7:"primary";}s:9:"ads_title";a:6:{s:4:"type";s:6:"string";s:4:"null";b:0;s:7:"default";N;s:6:"length";i:40;s:7:"collate";s:17:"latin1_swedish_ci";s:7:"charset";s:6:"latin1";}s:8:"ads_body";a:6:{s:4:"type";s:4:"text";s:4:"null";b:0;s:7:"default";N;s:6:"length";N;s:7:"collate";s:17:"latin1_swedish_ci";s:7:"charset";s:6:"latin1";}s:11:"category_id";a:4:{s:4:"type";s:7:"integer";s:4:"null";b:0;s:7:"default";N;s:6:"length";i:4;}s:7:"user_id";a:4:{s:4:"type";s:7:"integer";s:4:"null";b:0;s:7:"default";N;s:6:"length";i:10;}s:7:"city_id";a:4:{s:4:"type";s:7:"integer";s:4:"null";b:0;s:7:"default";N;s:6:"length";i:4;}s:8:"state_id";a:4:{s:4:"type";s:7:"integer";s:4:"null";b:0;s:7:"default";N;s:6:"length";i:4;}s:10:"issue_date";a:4:{s:4:"type";s:4:"date";s:4:"null";b:0;s:7:"default";N;s:6:"length";N;}s:10:"issue_time";a:4:{s:4:"type";s:4:"time";s:4:"null";b:0;s:7:"default";N;s:6:"length";N;}s:5:"image";a:6:{s:4:"type";s:6:"string";s:4:"null";b:0;s:7:"default";N;s:6:"length";i:100;s:7:"collate";s:17:"latin1_swedish_ci";s:7:"charset";s:6:"latin1";}s:6:"status";a:4:{s:4:"type";s:7:"integer";s:4:"null";b:0;s:7:"default";s:1:"0";s:6:"length";i:1;}}
@@ -1,2 +1,2 @@
-1362736999
+1362993244
a:2:{s:2:"id";a:5:{s:4:"type";s:7:"integer";s:4:"null";b:0;s:7:"default";N;s:6:"length";i:4;s:3:"key";s:7:"primary";}s:5:"cname";a:6:{s:4:"type";s:6:"string";s:4:"null";b:0;s:7:"default";N;s:6:"length";i:40;s:7:"collate";s:17:"latin1_swedish_ci";s:7:"charset";s:6:"latin1";}}
@@ -1,2 +1,2 @@
-1362736999
+1362993244
a:3:{s:2:"id";a:5:{s:4:"type";s:7:"integer";s:4:"null";b:0;s:7:"default";N;s:6:"length";i:4;s:3:"key";s:7:"primary";}s:5:"cname";a:6:{s:4:"type";s:6:"string";s:4:"null";b:1;s:7:"default";N;s:6:"length";i:100;s:7:"collate";s:17:"latin1_swedish_ci";s:7:"charset";s:6:"latin1";}s:5:"state";a:4:{s:4:"type";s:7:"integer";s:4:"null";b:1;s:7:"default";N;s:6:"length";i:3;}}
@@ -1,2 +1,2 @@
-1362736999
+1362993244
a:5:{i:0;s:3:"ads";i:1;s:10:"categories";i:2;s:6:"cities";i:3;s:6:"states";i:4;s:5:"users";}
@@ -1,2 +1,2 @@
-1362736999
+1362993244
a:2:{s:2:"id";a:5:{s:4:"type";s:7:"integer";s:4:"null";b:0;s:7:"default";N;s:6:"length";i:3;s:3:"key";s:7:"primary";}s:5:"sname";a:6:{s:4:"type";s:6:"string";s:4:"null";b:0;s:7:"default";N;s:6:"length";i:30;s:7:"collate";s:15:"utf8_general_ci";s:7:"charset";s:4:"utf8";}}
@@ -1,2 +1,2 @@
-1362736999
+1362993244
a:15:{s:2:"id";a:5:{s:4:"type";s:7:"integer";s:4:"null";b:0;s:7:"default";N;s:6:"length";i:10;s:3:"key";s:7:"primary";}s:10:"first_name";a:6:{s:4:"type";s:6:"string";s:4:"null";b:0;s:7:"default";N;s:6:"length";i:30;s:7:"collate";s:17:"latin1_swedish_ci";s:7:"charset";s:6:"latin1";}s:9:"last_name";a:6:{s:4:"type";s:6:"string";s:4:"null";b:0;s:7:"default";N;s:6:"length";i:30;s:7:"collate";s:17:"latin1_swedish_ci";s:7:"charset";s:6:"latin1";}s:8:"username";a:6:{s:4:"type";s:6:"string";s:4:"null";b:0;s:7:"default";N;s:6:"length";i:40;s:7:"collate";s:17:"latin1_swedish_ci";s:7:"charset";s:6:"latin1";}s:8:"password";a:6:{s:4:"type";s:6:"string";s:4:"null";b:0;s:7:"default";N;s:6:"length";i:40;s:7:"collate";s:17:"latin1_swedish_ci";s:7:"charset";s:6:"latin1";}s:13:"jenis_kelamin";a:6:{s:4:"type";s:6:"string";s:4:"null";b:0;s:7:"default";N;s:6:"length";i:1;s:7:"collate";s:17:"latin1_swedish_ci";s:7:"charset";s:6:"latin1";}s:9:"tgl_lahir";a:4:{s:4:"type";s:4:"date";s:4:"null";b:0;s:7:"default";N;s:6:"length";N;}s:6:"alamat";a:6:{s:4:"type";s:6:"string";s:4:"null";b:0;s:7:"default";N;s:6:"length";i:50;s:7:"collate";s:17:"latin1_swedish_ci";s:7:"charset";s:6:"latin1";}s:5:"state";a:4:{s:4:"type";s:7:"integer";s:4:"null";b:0;s:7:"default";N;s:6:"length";i:4;}s:4:"city";a:4:{s:4:"type";s:7:"integer";s:4:"null";b:0;s:7:"default";N;s:6:"length";i:4;}s:9:"handphone";a:6:{s:4:"type";s:6:"string";s:4:"null";b:0;s:7:"default";N;s:6:"length";i:12;s:7:"collate";s:17:"latin1_swedish_ci";s:7:"charset";s:6:"latin1";}s:17:"security_question";a:6:{s:4:"type";s:4:"text";s:4:"null";b:0;s:7:"default";N;s:6:"length";N;s:7:"collate";s:17:"latin1_swedish_ci";s:7:"charset";s:6:"latin1";}s:15:"security_answer";a:6:{s:4:"type";s:4:"text";s:4:"null";b:0;s:7:"default";N;s:6:"length";N;s:7:"collate";s:17:"latin1_swedish_ci";s:7:"charset";s:6:"latin1";}s:6:"status";a:6:{s:4:"type";s:6:"string";s:4:"null";b:0;s:7:"default";s:1:"1";s:6:"length";i:1;s:7:"collate";s:17:"latin1_swedish_ci";s:7:"charset";s:6:"latin1";}s:4:"rule";a:6:{s:4:"type";s:23:"enum('regular','admin')";s:4:"null";b:0;s:7:"default";s:7:"regular";s:6:"length";i:7;s:7:"collate";s:17:"latin1_swedish_ci";s:7:"charset";s:6:"latin1";}}
@@ -1,2 +1,2 @@
-1362736999
+1362993244
a:1:{s:11:"LC_MESSAGES";a:0:{}}
@@ -1,2 +1,2 @@
-1362736638
+1362993244
a:1:{s:11:"LC_MESSAGES";a:0:{}}
@@ -1,2 +1,2 @@
-1362736999
+1362993244
a:1:{s:11:"LC_MESSAGES";a:0:{}}
Oops, something went wrong.

0 comments on commit f158def

Please sign in to comment.