public function view($id = null)
 {
     $tmpPost = $this->Post->find('first', array('conditions' => array('Post.id' => $this->request->params['id'])));
     $this->set('tmpPost', $tmpPost);
     $data = array('applicationId' => '1020646643727437143', 'format' => 'xml', 'isbn' => $tmpPost['Post']['isbn']);
     $items = parent::search($data);
     $this->set('items', $items);
     $tmp = $this->Review->find('all', array('conditions' => array('Review.post_id' => $tmpPost['Post']['id'], 'Review.user_id' => $this->Auth->user('id'))));
     if (!empty($tmp)) {
         $this->set('tmp', $tmp);
     }
     $tmpReviews = $this->Review->find('all', array('conditions' => array('Review.post_id' => $tmpPost['Post']['id'])));
     if (!empty($tmpReviews)) {
         $this->set('tmpReviews', $tmpReviews);
     }
 }
Пример #2
0
 public function search($q = null, $fields = array())
 {
     if (isset($this->request->data['q'])) {
         $this->redirect(Router::uri('blogSearch', array('q' => $this->request->data['q'])));
     }
     parent::search($q, array('text', 'headline', 'tags'));
     $this->action = 'index';
     $this->data->set('q', $q);
     return true;
 }
Пример #3
0
});
$routes->get('/tasks/incomplete/:id', 'check_logged_in', function ($id) {
    AppController::markInComplete($id);
});
$routes->get('/tasks/edit/:id', 'check_logged_in', function ($id) {
    AppController::editTask($id);
});
$routes->post('/tasks/edit/:id', 'check_logged_in', function ($id) {
    AppController::updateTask($id);
});
$routes->get('/tasks/delete/:id', 'check_logged_in', function ($id) {
    AppController::deleteTask($id);
});
$routes->get('/hiekkalaatikko', function () {
    AuthController::sandbox();
});
$routes->get('/categories/create', 'check_logged_in', function () {
    CategoriesController::createCategory();
});
$routes->post('/categories/create', 'check_logged_in', function () {
    CategoriesController::storeCategory();
});
$routes->get('/categories/delete/:id', 'check_logged_in', function ($id) {
    CategoriesController::deleteCategory($id);
});
$routes->get('/tasks/category/:id', 'check_logged_in', function ($id) {
    AppController::categoryTasks($id);
});
$routes->post('/tasks/search', 'check_logged_in', function () {
    AppController::search();
});
 public function register()
 {
     $data = array('applicationId' => '1020646643727437143', 'format' => 'xml', 'isbn' => $this->request->params['pass']['0']);
     $items = parent::search($data);
     if ($this->request->is('post')) {
         $tmp = NULL;
         $tmp = $this->Post->find('first', array('conditions' => array('Post.isbn' => $items['0']['ISBN'])));
         if (!empty($tmp)) {
             $tmpReview['Review']['reading'] = $this->request->data['Review']['reading'];
             $tmpReview['Review']['value'] = $this->request->data['Review']['value'];
             $tmpReview['Review']['username'] = $this->Auth->user('username');
             $tmpReview['Review']['post_id'] = $tmp['Post']['id'];
             $tmpReview['Review']['user_id'] = $this->Auth->user('id');
             if ($this->Review->save($tmpReview)) {
                 $this->redirect('/posts/view/' . $tmp['Post']['id']);
             }
         }
         $tmpsave['Post']['title'] = $items['0']['TITLE'];
         if (!empty($items['0']['AUTHOR'])) {
             $tmpsave['Post']['author'] = $items['0']['AUTHOR'];
         }
         if (!empty($items['0']['SALESDATE'])) {
             $tmpsave['Post']['salesdate'] = $items['0']['SALESDATE'];
         }
         $tmpsave['Post']['thumbnail'] = $items['0']['LARGEIMAGEURL'];
         $tmpsave['Post']['isbn'] = $items['0']['ISBN'];
         $this->Post->save($tmpsave);
         $tmpReview['Review']['reading'] = $this->request->data['Review']['reading'];
         $tmpReview['Review']['value'] = $this->request->data['Review']['value'];
         $tmpReview['Review']['username'] = $this->Auth->user('username');
         $tmpReview['Review']['post_id'] = $this->Post->getLastInsertId();
         $tmpReview['Review']['user_id'] = $this->Auth->user('id');
         if ($this->Review->save($tmpReview)) {
             $this->redirect('/posts/view/' . $this->Post->getLastInsertId());
             $this->Session->setFlash('Success');
         }
     }
 }