static function thumb_top($theme, $item)
 {
     if (favourites_configuration::isUsersOnly() && identity::active_user()->name == "guest") {
         return;
     }
     if ($item->type == "album" && favourites_configuration::canSelectAlbums() || $item->type != "album" && favourites_configuration::canSelectItems()) {
         $view = new View("add_to_favourites.html");
         $view->item = $item;
         $view->favourites = Favourites::getOrCreate();
         return $view->render();
     }
 }
 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndex()
 {
     if (Yii::app()->user->isGuest) {
         $this->layout = 'login';
         $model = new LoginForm();
         // if it is ajax validation request
         if (isset($_POST['ajax']) && $_POST['ajax'] === 'login-form') {
             echo CActiveForm::validate($model);
             Yii::app()->end();
         }
         // collect user input data
         if (isset($_POST['LoginForm'])) {
             $date = date('Y-m-d H:i:s');
             $model->attributes = $_POST['LoginForm'];
             // validate user input and redirect to the previous page if valid
             if ($model->validate() && $model->login()) {
                 $loginUserID = Yii::app()->user->getId();
                 Users::model()->updateByPk($loginUserID, array('LoginStatus' => 1, 'LastLoginDate' => $date));
                 /* $this->redirect(array('site/index')); */
                 $this->redirect(Yii::app()->user->returnUrl);
             }
         }
         // display the login form
         $this->render('login', array('model' => $model));
     } else {
         $pageCount = 20;
         $loginUserId = Yii::app()->user->getId();
         $favourites = Favourites::model()->findByAttributes(array('UserId' => $loginUserId));
         if (!empty($favourites)) {
             $favourites = explode(',', $favourites->FavouriteIds);
         }
         $criteria = new CDbCriteria();
         $condition = "Status=1 AND SearchStatus=1 AND Objid <> {$loginUserId}";
         if (isset($_GET['searchAttList'])) {
             $criteria->condition = "UserId !='" . $loginUserId . "'";
             $options_list = UserOptions::model()->findAll($criteria);
             $key = array();
             $i = 0;
             $hasAttrUser = array();
             if ($_GET['searchAttList'] !== '') {
                 $values = explode(',', $_GET['searchAttList']);
                 foreach ($options_list as $option) {
                     $AttrOption = CJSON::decode($option->AttributeValueId);
                     foreach ($AttrOption['basic'] as $attr) {
                         if (is_array($attr)) {
                             foreach ($values as $value) {
                                 array_push($key, in_array($value, $attr));
                             }
                         }
                     }
                     foreach ($values as $value) {
                         array_push($key, in_array($value, $AttrOption['basic']));
                     }
                     $key = array_filter($key);
                     if (count($key) == count($values)) {
                         $hasAttrUser[$i++] = $option->UserId;
                     }
                 }
                 $condition .= !empty($hasAttrUser) ? " AND Objid IN(" . implode(',', $hasAttrUser) . ")" : ' AND Objid = 0';
             }
         }
         if (isset($_GET['MinAge']) && isset($_GET['MaxAge'])) {
             $minAge = $_GET['MinAge'];
             $maxAge = $_GET['MaxAge'];
             $minAge1 = $_GET['MinAge'] - 1;
             $maxAge1 = $_GET['MaxAge'] + 1;
             $toDate = date('Y-m-d', strtotime('-' . $minAge1 . ' years'));
             $fromDate = date('Y-m-d', strtotime('-' . $maxAge1 . ' years'));
             $condition .= " AND DateOfBirth BETWEEN '" . $fromDate . "' AND '" . $toDate . "'";
         }
         if (isset($_GET['Gender'])) {
             $condition .= $_GET['Gender'] !== '' ? " AND Gender=" . $_GET['Gender'] : " AND Gender=0 OR Gender=1";
         }
         $criteria->addCondition($condition);
         if (isset($_GET['type'])) {
             $criteria->compare("LoginStatus", 1, true);
         }
         $model = Profile::model()->findAll($criteria);
         $count = Profile::model()->count($criteria);
         $pages = new CPagination($count);
         $pages->pageSize = $pageCount;
         $pages->applyLimit($criteria);
         $this->render('list', array('models' => $model, 'pages' => $pages, 'pageCount' => $pageCount, 'favourites' => $favourites));
     }
 }
 public function clear_favourites()
 {
     Favourites::getOrCreate()->clear();
 }
Exemple #4
0
function checkFavourite($id)
{
    $user1 = getUserObject($id);
    $user2 = Auth::user()->id;
    $check = Favourites::where('user_id', $user2)->where('friend_id', $user1)->first();
    if ($check != null) {
        return true;
    } else {
        return false;
    }
}
 public function actionRemoveFavourite($id)
 {
     $favId = $id;
     $UserId = Yii::app()->user->getId();
     $model = Favourites::model()->findByAttributes(array('UserId' => $UserId));
     if ($model) {
         $favlist = explode(',', $model->FavouriteIds);
         if ($count = count($favlist) == 1) {
             $model->delete();
         } else {
             $key = array_search($favId, $favlist);
             unset($favlist[$key]);
             $model->FavouriteIds = implode(',', $favlist);
             $model->save();
         }
     }
 }
#!/usr/bin/env php
<?php 
require dirname(dirname(__FILE__)) . '/lib/autoload.php';
$command = new Commando\Command();
$command->option()->describedAs('Command to run: default is update.');
$command->option('cache-only')->boolean()->describedAs('Do not load metadata, only use existing cache.');
if ($command[0] === 'termcolor') {
    phpterm_demo();
    exit;
}
DiscoUtils::log("DiscoJuice update script. Now updating feide feed.", true);
$fav = Favourites::getByID('uuid:d665541c-2fe6-4843-8752-314587f4edd1');
if ($fav === null) {
    DiscoUtils::log("No favourites found");
    $fav = new Favourites(array('id' => 'uuid:d665541c-2fe6-4843-8752-314587f4edd1', 'favs' => array('foo1', 'foo2', 'bar3')));
    $fav->save();
} else {
    print_r($fav);
}
DiscoUtils::log("Done.");
Exemple #7
0
                         $response = array();
                     }
                 } else {
                     if (DiscoUtils::route('post', '^/favs$', $parameters, $qs)) {
                         // $inputraw = file_get_contents("php://input");
                         $userid = $gk->getUserID();
                         // $response = array(
                         // 	'userid' => $userid,
                         // 	'data' => $inputraw,
                         // 	'qs' => $qs,
                         // 	'parameters' => $parameters,
                         // 	'headers' => getallheaders(),
                         // );
                         $fav = new Favourites(array('id' => $userid, 'favs' => $qs));
                         $fav->save();
                         $fav = Favourites::getByID($userid);
                         $data = $fav->getView();
                         if (!empty($data) && isset($data['favs'])) {
                             $response = $data['favs'];
                         } else {
                             $response = array();
                         }
                     } else {
                         throw new Exception('Invalid request');
                     }
                 }
             }
         }
     }
 }
 header('Content-Type: application/json; charset=utf-8');
Exemple #8
0
 //-----------------------
 if (isset($_POST['update'])) {
     $id = $_POST['id'];
     $name = trim($_POST['name']);
     $url = trim($_POST['url']);
     if ($name == '') {
         $error_string[] = $msg_favourites10;
     }
     if ($url == '' || $url == 'http://') {
         $error_string[] = $msg_favourites11;
     }
     if ($error_string) {
         error($msg_script5, $error_string, $msg_script7, $msg_charset);
     } else {
         include FOLDER_PATH . 'classes/class_favourites.inc.php';
         $MW_FAVE = new Favourites();
         $MW_FAVE->prefix = $database['prefix'];
         $MW_FAVE->update_fave_sql($_POST);
         updated($msg_favourites13, 'index.php?cmd=favourites&edit=' . $id, $msg_script4, $msg_script6, $msg_charset);
     }
 }
 //-----------------------
 // SCRIPT ACTION
 // Delete Favourites
 //-----------------------
 if (isset($_POST['remove'])) {
     $faveid = isset($_POST['faveid']) ? $_POST['faveid'] : '';
     if (!empty($faveid)) {
         mysql_query("DELETE FROM " . $database['prefix'] . "favourites \n                    WHERE id IN(" . implode(",", $faveid) . ")\n                    ") or die(mysql_error());
         updated($msg_favourites14, 'index.php?cmd=favourites', $msg_script4, $msg_script6, $msg_charset);
     }
        } else {
            ?>
                                      <span class="mail"><?php 
            echo CHtml::link('Mail', array('/upgradepack/'));
            ?>
</span>
                                      <span class="chat"><?php 
            echo CHtml::link('Chat', array('/upgradepack/'));
            ?>
</span>
                                      <?php 
        }
        ?>
                                      <?php 
        $loginUserIds = Yii::app()->user->getId();
        if (Favourites::model()->findByAttributes(array('UserId' => $loginUserIds, 'FavouriteIds' => $model->Objid))) {
            ?>
                                      <span class="favactive fav" id="favouriteBlock<?php 
            echo $model->UserId;
            ?>
">Fav</span>
																			<?php 
        } else {
            ?>
                                        
                                      <?php 
            echo CHtml::ajaxLink('<span class="favinactive fav" id="favouriteBlock<?php echo $model->UserId; ?>">Fav</span>', Yii::app()->createUrl('/message/addToFavourite'), array('data' => array('id' => $model->Objid), 'update' => '#favouriteBlock' . $model->UserId));
            ?>

                                     <?php 
        }