diff options
Diffstat (limited to 'protected/models')
| -rw-r--r-- | protected/models/Angebot.php | 96 | ||||
| -rw-r--r-- | protected/models/AngebotVerein.php | 96 | ||||
| -rw-r--r-- | protected/models/ContactForm.php | 42 | ||||
| -rw-r--r-- | protected/models/Kategorie.php | 101 | ||||
| -rw-r--r-- | protected/models/LoginForm.php | 77 | ||||
| -rw-r--r-- | protected/models/Standort.php | 96 | ||||
| -rw-r--r-- | protected/models/User.php | 109 | ||||
| -rw-r--r-- | protected/models/Verein.php | 119 |
8 files changed, 736 insertions, 0 deletions
diff --git a/protected/models/Angebot.php b/protected/models/Angebot.php new file mode 100644 index 0000000..03b5496 --- /dev/null +++ b/protected/models/Angebot.php @@ -0,0 +1,96 @@ +<?php + +/** + * This is the model class for table "angebot". + * + * The followings are the available columns in table 'angebot': + * @property integer $id + * @property integer $kategorie_id + * @property string $name + * @property string $beschreibung + * @property integer $published + */ +class Angebot extends CActiveRecord +{ + /** + * Returns the static model of the specified AR class. + * @param string $className active record class name. + * @return Angebot the static model class + */ + public static function model($className=__CLASS__) + { + return parent::model($className); + } + + /** + * @return string the associated database table name + */ + public function tableName() + { + return 'angebot'; + } + + /** + * @return array validation rules for model attributes. + */ + public function rules() + { + // NOTE: you should only define rules for those attributes that + // will receive user inputs. + return array( + array('kategorie_id, published', 'numerical', 'integerOnly'=>true), + array('name', 'length', 'max'=>80), + array('beschreibung', 'safe'), + // The following rule is used by search(). + // Please remove those attributes that should not be searched. + array('id, kategorie_id, name, beschreibung, published', 'safe', 'on'=>'search'), + ); + } + + /** + * @return array relational rules. + */ + public function relations() + { + // NOTE: you may need to adjust the relation name and the related + // class name for the relations automatically generated below. + return array( + ); + } + + /** + * @return array customized attribute labels (name=>label) + */ + public function attributeLabels() + { + return array( + 'id' => 'ID', + 'kategorie_id' => 'Kategorie', + 'name' => 'Name', + 'beschreibung' => 'Beschreibung', + 'published' => 'Published', + ); + } + + /** + * 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; + + $criteria->compare('id',$this->id); + $criteria->compare('kategorie_id',$this->kategorie_id); + $criteria->compare('name',$this->name,true); + $criteria->compare('beschreibung',$this->beschreibung,true); + $criteria->compare('published',$this->published); + + return new CActiveDataProvider($this, array( + 'criteria'=>$criteria, + )); + } +}
\ No newline at end of file diff --git a/protected/models/AngebotVerein.php b/protected/models/AngebotVerein.php new file mode 100644 index 0000000..54cb734 --- /dev/null +++ b/protected/models/AngebotVerein.php @@ -0,0 +1,96 @@ +<?php + +/** + * This is the model class for table "angebot_verein". + * + * The followings are the available columns in table 'angebot_verein': + * @property integer $angebot_id + * @property integer $verein_id + * @property integer $menge + * @property double $preis + * @property integer $published + */ +class AngebotVerein extends CActiveRecord +{ + /** + * Returns the static model of the specified AR class. + * @param string $className active record class name. + * @return AngebotVerein the static model class + */ + public static function model($className=__CLASS__) + { + return parent::model($className); + } + + /** + * @return string the associated database table name + */ + public function tableName() + { + return 'angebot_verein'; + } + + /** + * @return array validation rules for model attributes. + */ + public function rules() + { + // NOTE: you should only define rules for those attributes that + // will receive user inputs. + return array( + array('angebot_id, verein_id, menge', 'required'), + array('angebot_id, verein_id, menge, published', 'numerical', 'integerOnly'=>true), + array('preis', 'numerical'), + // The following rule is used by search(). + // Please remove those attributes that should not be searched. + array('angebot_id, verein_id, menge, preis, published', 'safe', 'on'=>'search'), + ); + } + + /** + * @return array relational rules. + */ + public function relations() + { + // NOTE: you may need to adjust the relation name and the related + // class name for the relations automatically generated below. + return array( + ); + } + + /** + * @return array customized attribute labels (name=>label) + */ + public function attributeLabels() + { + return array( + 'angebot_id' => 'Angebot', + 'verein_id' => 'Verein', + 'menge' => 'Menge', + 'preis' => 'Preis', + 'published' => 'Published', + ); + } + + /** + * 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; + + $criteria->compare('angebot_id',$this->angebot_id); + $criteria->compare('verein_id',$this->verein_id); + $criteria->compare('menge',$this->menge); + $criteria->compare('preis',$this->preis); + $criteria->compare('published',$this->published); + + return new CActiveDataProvider($this, array( + 'criteria'=>$criteria, + )); + } +}
\ No newline at end of file diff --git a/protected/models/ContactForm.php b/protected/models/ContactForm.php new file mode 100644 index 0000000..86541cb --- /dev/null +++ b/protected/models/ContactForm.php @@ -0,0 +1,42 @@ +<?php + +/** + * ContactForm class. + * ContactForm is the data structure for keeping + * contact form data. It is used by the 'contact' action of 'SiteController'. + */ +class ContactForm extends CFormModel +{ + public $name; + public $email; + public $subject; + public $body; + public $verifyCode; + + /** + * Declares the validation rules. + */ + public function rules() + { + return array( + // name, email, subject and body are required + array('name, email, subject, body', 'required'), + // email has to be a valid email address + array('email', 'email'), + // verifyCode needs to be entered correctly + array('verifyCode', 'captcha', 'allowEmpty'=>!CCaptcha::checkRequirements()), + ); + } + + /** + * Declares customized attribute labels. + * If not declared here, an attribute would have a label that is + * the same as its name with the first letter in upper case. + */ + public function attributeLabels() + { + return array( + 'verifyCode'=>'Verification Code', + ); + } +}
\ No newline at end of file diff --git a/protected/models/Kategorie.php b/protected/models/Kategorie.php new file mode 100644 index 0000000..4e39910 --- /dev/null +++ b/protected/models/Kategorie.php @@ -0,0 +1,101 @@ +<?php + +/** + * This is the model class for table "kategorie". + * + * The followings are the available columns in table 'kategorie': + * @property integer $id + * @property string $name + * @property string $einheiten + * @property double $default_menge + * @property string $default_einheit + * @property integer $published + */ +class Kategorie extends CActiveRecord +{ + /** + * Returns the static model of the specified AR class. + * @param string $className active record class name. + * @return Kategorie the static model class + */ + public static function model($className=__CLASS__) + { + return parent::model($className); + } + + /** + * @return string the associated database table name + */ + public function tableName() + { + return 'kategorie'; + } + + /** + * @return array validation rules for model attributes. + */ + public function rules() + { + // NOTE: you should only define rules for those attributes that + // will receive user inputs. + return array( + array('name, einheiten, default_einheit', 'required'), + array('published', 'numerical', 'integerOnly'=>true), + array('default_menge', 'numerical', "numberPattern"=>"/^\s*[-+]?[0-9]*(,|\.)?[0-9]+([eE][-+]?[0-9]+)?\s*$/"), + array('name, einheiten', 'length', 'max'=>100), + array('default_einheit', 'length', 'max'=>20), + // The following rule is used by search(). + // Please remove those attributes that should not be searched. + array('id, name, einheiten, default_menge, default_einheit, published', 'safe', 'on'=>'search'), + ); + } + + /** + * @return array relational rules. + */ + public function relations() + { + // NOTE: you may need to adjust the relation name and the related + // class name for the relations automatically generated below. + return array( + ); + } + + /** + * @return array customized attribute labels (name=>label) + */ + public function attributeLabels() + { + return array( + 'id' => 'ID', + 'name' => 'Name', + 'einheiten' => 'Einheiten', + 'default_menge' => 'Standardmenge', + 'default_einheit' => 'Standardeinheit', + 'published' => 'Published', + ); + } + + /** + * 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; + + $criteria->compare('id',$this->id); + $criteria->compare('name',$this->name,true); + $criteria->compare('einheiten',$this->einheiten,true); + $criteria->compare('default_menge',$this->default_menge); + $criteria->compare('default_einheit',$this->default_einheit,true); + $criteria->compare('published',$this->published); + + return new CActiveDataProvider($this, array( + 'criteria'=>$criteria, + )); + } +}
\ No newline at end of file diff --git a/protected/models/LoginForm.php b/protected/models/LoginForm.php new file mode 100644 index 0000000..eb36e4a --- /dev/null +++ b/protected/models/LoginForm.php @@ -0,0 +1,77 @@ +<?php + +/** + * LoginForm class. + * LoginForm is the data structure for keeping + * user login form data. It is used by the 'login' action of 'SiteController'. + */ +class LoginForm extends CFormModel +{ + public $username; + public $password; + public $rememberMe; + + private $_identity; + + /** + * Declares the validation rules. + * The rules state that username and password are required, + * and password needs to be authenticated. + */ + public function rules() + { + return array( + // username and password are required + array('username, password', 'required'), + // rememberMe needs to be a boolean + array('rememberMe', 'boolean'), + // password needs to be authenticated + array('password', 'authenticate'), + ); + } + + /** + * Declares attribute labels. + */ + public function attributeLabels() + { + return array( + 'rememberMe'=>'Remember me next time', + ); + } + + /** + * Authenticates the password. + * This is the 'authenticate' validator as declared in rules(). + */ + public function authenticate($attribute,$params) + { + if(!$this->hasErrors()) + { + $this->_identity=new UserIdentity($this->username,$this->password); + if(!$this->_identity->authenticate()) + $this->addError('password','Incorrect username or password.'); + } + } + + /** + * Logs in the user using the given username and password in the model. + * @return boolean whether login is successful + */ + public function login() + { + if($this->_identity===null) + { + $this->_identity=new UserIdentity($this->username,$this->password); + $this->_identity->authenticate(); + } + if($this->_identity->errorCode===UserIdentity::ERROR_NONE) + { + $duration=$this->rememberMe ? 3600*24*30 : 0; // 30 days + Yii::app()->user->login($this->_identity,$duration); + return true; + } + else + return false; + } +} diff --git a/protected/models/Standort.php b/protected/models/Standort.php new file mode 100644 index 0000000..cd4f284 --- /dev/null +++ b/protected/models/Standort.php @@ -0,0 +1,96 @@ +<?php + +/** + * This is the model class for table "standort". + * + * The followings are the available columns in table 'standort': + * @property integer $id + * @property string $name + * @property double $pos_lat + * @property double $pos_long + * @property integer $published + */ +class Standort extends CActiveRecord +{ + /** + * Returns the static model of the specified AR class. + * @param string $className active record class name. + * @return Standort the static model class + */ + public static function model($className=__CLASS__) + { + return parent::model($className); + } + + /** + * @return string the associated database table name + */ + public function tableName() + { + return 'standort'; + } + + /** + * @return array validation rules for model attributes. + */ + public function rules() + { + // NOTE: you should only define rules for those attributes that + // will receive user inputs. + return array( + array('published', 'numerical', 'integerOnly'=>true), + array('pos_lat, pos_long', 'numerical'), + array('name', 'length', 'max'=>80), + // The following rule is used by search(). + // Please remove those attributes that should not be searched. + array('id, name, pos_lat, pos_long, published', 'safe', 'on'=>'search'), + ); + } + + /** + * @return array relational rules. + */ + public function relations() + { + // NOTE: you may need to adjust the relation name and the related + // class name for the relations automatically generated below. + return array( + ); + } + + /** + * @return array customized attribute labels (name=>label) + */ + public function attributeLabels() + { + return array( + 'id' => 'ID', + 'name' => 'Name', + 'pos_lat' => 'Pos Lat', + 'pos_long' => 'Pos Long', + 'published' => 'Published', + ); + } + + /** + * 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; + + $criteria->compare('id',$this->id); + $criteria->compare('name',$this->name,true); + $criteria->compare('pos_lat',$this->pos_lat); + $criteria->compare('pos_long',$this->pos_long); + $criteria->compare('published',$this->published); + + return new CActiveDataProvider($this, array( + 'criteria'=>$criteria, + )); + } +}
\ No newline at end of file diff --git a/protected/models/User.php b/protected/models/User.php new file mode 100644 index 0000000..f3a2163 --- /dev/null +++ b/protected/models/User.php @@ -0,0 +1,109 @@ +<?php + +/** + * This is the model class for table "astaf_user". + * + * The followings are the available columns in table 'astaf_user': + * @property integer $id + * @property string $username + * @property string $algorithm + * @property string $salt + * @property string $password + * @property string $created_at + * @property string $last_login + * @property integer $is_active + * @property integer $is_super_admin + */ +class User extends CActiveRecord +{ + /** + * Returns the static model of the specified AR class. + * @param string $className active record class name. + * @return User the static model class + */ + public static function model($className=__CLASS__) + { + return parent::model($className); + } + + /** + * @return string the associated database table name + */ + public function tableName() + { + return 'astaf_user'; + } + + /** + * @return array validation rules for model attributes. + */ + public function rules() + { + // NOTE: you should only define rules for those attributes that + // will receive user inputs. + return array( + array('username, password', 'required'), + array('is_active, is_super_admin', 'numerical', 'integerOnly'=>true), + array('username, password', 'length', 'max'=>128), + array('created_at', 'safe'), + // The following rule is used by search(). + // Please remove those attributes that should not be searched. + array('id, username, created_at, last_login, is_active, is_super_admin', 'safe', 'on'=>'search'), + ); + } + + /** + * @return array relational rules. + */ + public function relations() + { + // NOTE: you may need to adjust the relation name and the related + // class name for the relations automatically generated below. + return array( + ); + } + + /** + * @return array customized attribute labels (name=>label) + */ + public function attributeLabels() + { + return array( + 'id' => 'ID', + 'username' => 'Username', + 'password' => 'Password', + 'created_at' => 'Created At', + 'last_login' => 'Last Login', + 'is_active' => 'Is Active', + 'is_super_admin' => 'Is Super Admin', + ); + } + + /** + * 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; + + $criteria->compare('id',$this->id); + $criteria->compare('username',$this->username,true); + $criteria->compare('password',$this->password,true); + $criteria->compare('created_at',$this->created_at,true); + $criteria->compare('last_login',$this->last_login,true); + $criteria->compare('is_active',$this->is_active); + $criteria->compare('is_super_admin',$this->is_super_admin); + + return new CActiveDataProvider($this, array( + 'criteria'=>$criteria, + )); + } + + public function checkPassword($password) { + return sha1($this->salt.$password) == $this->password; + } +}
\ No newline at end of file diff --git a/protected/models/Verein.php b/protected/models/Verein.php new file mode 100644 index 0000000..dba05db --- /dev/null +++ b/protected/models/Verein.php @@ -0,0 +1,119 @@ +<?php + +/** + * This is the model class for table "verein". + * + * The followings are the available columns in table 'verein': + * @property integer $id + * @property string $name + * @property string $url + * @property string $bild + * @property string $email + * @property string $slug + * @property string $kontaktdaten + * @property string $beschreibung + * @property integer $standort_id + * @property integer $published + */ +class Verein extends CActiveRecord +{ + public $uploadedImage; + /** + * Returns the static model of the specified AR class. + * @param string $className active record class name. + * @return Verein the static model class + */ + public static function model($className=__CLASS__) + { + return parent::model($className); + } + + /** + * @return string the associated database table name + */ + public function tableName() + { + return 'verein'; + } + + /** + * @return array validation rules for model attributes. + */ + public function rules() + { + // NOTE: you should only define rules for those attributes that + // will receive user inputs. + return array( + array("email, name", "required"), + array('standort_id, published', 'numerical', 'integerOnly'=>true), + array('name, url', 'length', 'max'=>255), + array('bild, email, slug', 'length', 'max'=>100), + array("url", "url", "allowEmpty"=>true, "message"=>"Die eingebene URL ist ung�ltig."), + array("email", "email", "message"=>"Die eingebene eMail-Adresse ist ung�ltig."), + array("uploadedImage", "file", "types"=>"jpg, gif, png", "allowEmpty"=>true, "wrongType"=>'Die Datei "{file}" konnte nicht hochgeladen werden. Es sind nur Dateien mit den folgenden Endungen erlaubt: {extensions}.'), + array('kontaktdaten, beschreibung', 'safe'), + // The following rule is used by search(). + // Please remove those attributes that should not be searched. + array('id, name, url, bild, email, slug, kontaktdaten, beschreibung, standort_id, published', 'safe', 'on'=>'search'), + ); + } + + /** + * @return array relational rules. + */ + public function relations() + { + // NOTE: you may need to adjust the relation name and the related + // class name for the relations automatically generated below. + return array( + "standort"=>array(self::HAS_ONE, "Standort", array('id'=>'standort_id')) + ); + } + + /** + * @return array customized attribute labels (name=>label) + */ + public function attributeLabels() + { + return array( + 'id' => 'ID', + 'name' => 'Name', + 'url' => 'Homepage', + 'bild' => 'Logo', + 'email' => 'Email', + 'slug' => 'Anmeldename', + 'kontaktdaten' => 'Kontaktdaten', + 'beschreibung' => 'Beschreibung', + 'standort_id' => 'Standort', + 'standort' => 'Standort', + 'published' => 'Öffentlich', + ); + } + + /** + * 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; + + $criteria->compare('id',$this->id); + $criteria->compare('name',$this->name,true); + $criteria->compare('url',$this->url,true); + $criteria->compare('bild',$this->bild,true); + $criteria->compare('email',$this->email,true); + $criteria->compare('slug',$this->slug,true); + $criteria->compare('kontaktdaten',$this->kontaktdaten,true); + $criteria->compare('beschreibung',$this->beschreibung,true); + $criteria->compare('standort_id',$this->standort_id); + $criteria->compare('published',$this->published); + + return new CActiveDataProvider($this, array( + 'criteria'=>$criteria, + )); + } +}
\ No newline at end of file |
