Example #1
0
 public function beforeFind()
 {
     $attrs = $this->attributeLabels();
     if ($this->tableName() != "sites") {
         if (@$attrs['site_id']) {
             $this->getDbCriteria()->mergeWith(array('alias' => 't', 'condition' => "t.site_id=" . (int) Sites::model()->getCurrentSite()->id));
         }
     }
     //var_dump($this->dbCriteria);
     parent::beforeFind();
 }
Example #2
0
 public function init()
 {
     $site = Sites::model()->getCurrentSite();
     //echo $site->theme;
     Yii::app()->theme = $site->theme;
     $this->site_id = $site->id;
     Yii::import('application.extensions.sesmail.*');
     require_once 'vendors/aws-sdk/sdk.class.php';
     $this->ses = new YiiSesMail();
     if (stristr($_SERVER['REQUEST_URI'], 'admin')) {
         //if(!Yii::app()->user->isSuperUser) {
         //	$this->redirect("/");
         //	exit;
         //}
         $session = new CHttpSession();
         $session->open();
         $site_id = $session['site_id'];
         // override the site_id (since switched)
         if ($site_id) {
             $this->site_id = $site_id;
         }
         $this->sites = CHtml::listData(Sites::model()->findAll(), 'id', 'name');
         $this->admin = 1;
         $this->layout = '//layouts/admin';
     } else {
         $this->isEditor = Yii::app()->user->checkAccess('admin');
         $this->niches = Offers::model()->getNiches($this->site_id);
         //$this->site_id = $site->getCurrentSite();
         //Yii::import('application.extensions.sesmail.*');
         //require_once('protected/extensions/sesmail/YiiSesMail.php');
         //require_once('vendors/aws-sdk/sdk.class.php');
         $session = new CHttpSession();
         $session->open();
         $seenOffer = $session['seenBackout'];
         if ($seenOffer) {
             $this->hideBackout = true;
         }
         Yii::import('application.modules.user.models.*');
         $this->registration_model = new RegistrationForm();
         $this->login_model = new UserLogin();
     }
     parent::init();
 }
Example #3
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Sites::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Example #4
0
 /**
  * Retrieves a list of models based on the current search/filter conditions.
  * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
  */
 public function search()
 {
     // Warning: Please modify the following code to remove attributes that
     // should not be searched.
     $criteria = new CDbCriteria();
     if (@$_GET['term']) {
         //$this->title = CHtml::encode($_GET['term']);
         $criteria->addSearchCondition('title', CHtml::encode($_GET['term']));
         $criteria->addSearchCondition('slug', CHtml::encode($_GET['term']));
         //$this->url   = CHtml::encode($_GET['term']);
         //$this->slug  = CHtml::encode($_GET['term']);
     }
     $criteria->compare('site_id', (int) Sites::model()->getCurrentSite()->id);
     $criteria->compare('id', $this->id);
     $criteria->compare('title', $this->title, true);
     $criteria->compare('description', $this->description, true);
     $criteria->compare('featured', $this->featured);
     $criteria->compare('taken_count', $this->taken_count);
     $criteria->compare('taken_max', $this->taken_max);
     $criteria->compare('slug', $this->slug, true);
     $criteria->compare('url', $this->url, true);
     $criteria->compare('our_price', $this->our_price, true);
     $criteria->compare('regular_price', $this->regular_price, true);
     $criteria->compare('valid_from', $this->valid_from, true);
     $criteria->compare('valid_to', $this->valid_to, true);
     $criteria->compare('created', $this->created, true);
     $criteria->compare('updated', $this->updated, true);
     return new CActiveDataProvider($this, array('criteria' => $criteria));
 }
Example #5
0
 public function getAllSites()
 {
     $sites = CHtml::listData(Sites::model()->findAll(), 'id', 'name');
     return $sites;
 }
Example #6
0
	<?php 
echo $form->errorSummary($model);
?>


	<?php 
echo $form->textFieldRow($model, 'name', array('class' => 'span5', 'maxlength' => 255));
?>


	<?php 
echo $form->label($model, 'site_id');
?>

	<?php 
echo $form->dropDownList($model, 'site_id', Sites::model()->getAllSites());
?>
<br />
	
	<div class="form-actions">
		<?php 
$this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'submit', 'type' => 'primary', 'label' => $model->isNewRecord ? 'Create' : 'Save'));
?>

	</div>

<?php 
$this->endWidget();
?>

Example #7
0
 public function scopes()
 {
     return array('published' => array('condition' => 'published = 1'), 'currentSite' => array('condition' => 'site_id = :siteId', 'params' => array(':siteId' => (int) Sites::model()->getCurrentSite()->id)));
 }