Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * This is the model class for table "archivo".
- *
- * The followings are the available columns in table 'archivo':
- * @property integer $id_pro
- * @property integer $id_arc
- * @property integer $id_tip_arc
- * @property string $nombre_arc
- * @property string $url_arcventas
- * @property double $tamano_arc
- * @property double $version_arc
- * @property string $fecha_cre_arc
- *
- * The followings are the available model relations:
- * @property TipoArchivo $idTipArc
- * @property Proyecto $idPro
- * @property Video[] $videos
- * @property Video[] $videos1
- */
- class Archivo extends CActiveRecord
- {
- /**
- * Returns the static model of the specified AR class.
- * @param string $className active record class name.
- * @return Archivo 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 'archivo';
- }
- /**
- * @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('id_pro, id_tip_arc, nombre_arc, url_arc, fecha_cre_arc', 'required'),
- array('id_pro, id_tip_arc', 'numerical', 'integerOnly'=>true),
- array('tamano_arc, version_arc', 'numerical'),
- array('nombre_arc', 'length', 'max'=>100),
- // The following rule is used by search().
- // Please remove those attributes that should not be searched.
- array('id_pro, id_arc, id_tip_arc, nombre_arc, url_arc, tamano_arc, version_arc, fecha_cre_arc', '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(
- 'idTipArc' => array(self::BELONGS_TO, 'TipoArchivo', 'id_tip_arc'),
- 'idPro' => array(self::BELONGS_TO, 'Proyecto', 'id_pro'),
- 'videos' => array(self::HAS_MANY, 'Video', 'id_pro'),
- 'videos1' => array(self::HAS_MANY, 'Video', 'id_arc'),
- );
- }
- /**
- * @return array customized attribute labels (name=>label)
- */
- public function attributeLabels()
- {
- return array(
- 'id_pro' => 'Id Pro',
- 'id_arc' => 'Id Arc',
- 'id_tip_arc' => 'Id Tip Arc',
- 'nombre_arc' => 'Nombre Arc',
- 'url_arc' => 'Url Arc',
- 'tamano_arc' => 'Tamano Arc',
- 'version_arc' => 'Version Arc',
- 'fecha_cre_arc' => 'Fecha Cre Arc',
- );
- }
- /**
- * 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_pro',$this->id_pro);
- $criteria->compare('id_arc',$this->id_arc);
- $criteria->compare('id_tip_arc',$this->id_tip_arc);
- $criteria->compare('nombre_arc',$this->nombre_arc,true);
- $criteria->compare('url_arc',$this->url_arc,true);
- $criteria->compare('tamano_arc',$this->tamano_arc);
- $criteria->compare('version_arc',$this->version_arc);
- $criteria->compare('fecha_cre_arc',$this->fecha_cre_arc,true);
- return new CActiveDataProvider($this, array(
- 'criteria'=>$criteria,
- ));
- }
- public function onFileUploaded($fullFileName,$userdata) {
- // userdata is the same passed via widget config.
- // fullFileName es la ruta del archivo
- // listo para leer.
- $userid = $userdata;
- //siendo este ultimo algun ID pasado al widget
- //en la vista en donde lo pusiste. supon que es
- //el ID del usuario activo que tu tienes.
- //bueno, simple:
- //$nuevaRuta = crea_nueva_ruta($userid);
- //mover_archivo($fullFileName, $nuevaRuta);
- $archivo = Archivo::model()->findByPk($userid);
- // podrias usar esa foto como perfil:
- $archivo->url_arc =$fullFileName;
- // o podrias almacenar esa foto o archivo
- // en su lista de archivos...
- //$almacen = $archivo->getAlmacen();
- //$almacen->agregar($nuevaRuta);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement