예제 #1
0
<?php

/**
 * Classified-ads-script
 * 
 * @copyright  Copyright (c) Szilard Szabo
 * @license    GPL v3
 * @package    Frontend
 */
include "./admin/include/common.php";
include "Pager/Pager.php";
$g_id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
$exists = Ad::exists($g_id, array("active  " => 1));
if ($exists) {
    $ad = Ad::get_one($g_id);
    $is_favourite = Favourite::exists(User::get_id(), $ad['id']);
    $reviews = AdReview::get_all(array('ad_id' => $g_id));
}
include "./templates/ad.php";
 * Classified-ads-script
 * 
 * @copyright  Copyright (c) Szilard Szabo
 * @license    GPL v3
 * @package    Frontend
 */
include "./admin/include/common.php";
include "Pager/Pager.php";
$r_id = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0;
$r_remove = isset($_REQUEST['remove']) ? 1 : 0;
if (USER::is_logged_in()) {
    $user_id = USER::get_id();
    if ($r_id > 0 && Ad::exists($r_id, array('active' => 1))) {
        if (!Favourite::exists($user_id, $r_id)) {
            Favourite::add($user_id, $r_id);
        } else {
            if ($r_remove > 0) {
                Favourite::delete($user_id, $r_id);
            }
        }
    }
    $rpp = 15;
    $tct = Favourite::count($user_id);
    if ($tct > 0) {
        $pager_options = array('mode' => 'Sliding', 'perPage' => $rpp, 'delta' => 2, 'totalItems' => $tct);
        $pager = @Pager::factory($pager_options);
        list($from, $to) = $pager->getOffsetByPageId();
        $ads = Favourite::get_all($user_id, $from - 1 . ", {$rpp}");
    }
}
include "./templates/user-favourites.php";
예제 #3
0
 /**
  * Returns the static model of the specified AR class.
  * Please note that you should have this exact method in all your CActiveRecord descendants!
  * @param string $className active record class name.
  * @return Favourite the static model class
  */
 public static function model($className = __CLASS__)
 {
     return parent::model($className);
 }
예제 #4
0
 public function FavCount($id)
 {
     return Favourite::where('fav_fl_id', $id)->count();
 }