2012-10-26 81 views
-1

我得到這個錯誤的所有實體,當我嘗試做一個管理行動列表實例化一個特定類的所有實體:錯誤時嘗試管理類

包括(authenticate.php):未能打開流:在查看文件夾的管理文件沒有這樣的文件或目錄 /home/user/NetBeansProjects/yii/framework/YiiBase.php(423)

{ 
412        include($classFile); 
413        if(YII_DEBUG && basename(realpath($classFile))!==$className.'.php') 
414         throw new CException(Yii::t('yii','Class name "{class}" does not match class file "{file}".', array(
415          '{class}'=>$className, 
416          '{file}'=>$classFile, 
417        ))); 
418        break; 
419       } 
420      } 
421     } 
422     else 
423      include($className.'.php'); 
424    } 
425    else // class name with namespace in PHP 5.3 
426    { 
427     $namespace=str_replace('\\','.',ltrim($className,'\\')); 
428     if(($path=self::getPathOfAlias($namespace))!==false) 
429      include($path.'.php'); 
430     else 
431      return false; 
432    } 
433    return class_exists($className,false) || interface_exists($className,false); 
434   } 
435   return true; 

CGridView

<?php $this->widget('zii.widgets.grid.CGridView', array(
    'id'=>'utente-crea-evento-grid', 
    'dataProvider'=>$model->search(), 
    'filter'=>$model, 
    'columns'=>array(
     'id', 
     'status', 
     'username', 
     'password', other properties 

管理行動

public function actionAdmin() 
    { 
     $model=new UtenteCreaEvento('search'); 
     $model->unsetAttributes(); // clear any default values 
     if(isset($_GET['UtenteCreaEvento'])) 
      $model->attributes=$_GET['UtenteCreaEvento']; 

     $this->render('admin',array(
      'model'=>$model, 
     )); 
    } 

更堆棧跟蹤信息

#0 
+ /home/sigturk/NetBeansProjects/yii/framework/YiiBase.php(423): YiiBase::autoload() 
#1 
+ /home/sigturk/NetBeansProjects/yii/framework/YiiBase.php(298): YiiBase::autoload("authenticate") 
#2 
+ /home/sigturk/NetBeansProjects/yii/framework/validators/CValidator.php(187): YiiBase::import("authenticate", true) 
#3 
+ /home/sigturk/NetBeansProjects/yii/framework/base/CModel.php(285): CValidator::createValidator("authenticate", UtenteCreaEvento, "password", array()) 
#4 
+ /home/sigturk/NetBeansProjects/yii/framework/base/CModel.php(259): CModel->createValidators() 
#5 
+ /home/sigturk/NetBeansProjects/yii/framework/web/helpers/CHtml.php(1871): CModel->getValidators("numTel") 
#6 
+ /home/sigturk/NetBeansProjects/yii/framework/web/helpers/CHtml.php(1217): CHtml::activeInputField("text", UtenteCreaEvento, "numTel", array("name" => "UtenteCreaEvento[numTel]", "id" => "UtenteCreaEvento_numTel")) 
#7 
+ /home/sigturk/NetBeansProjects/yii/framework/web/widgets/CActiveForm.php(658): CHtml::activeTextField(UtenteCreaEvento, "numTel", array()) 
#8 
– /home/sigturk/NetBeansProjects/sitoEventi/protected/views/utenteCreaEvento/_search.php(42): CActiveForm->textField(UtenteCreaEvento, "numTel") 
37   <?php echo $form->textField($model,'cognome',array('size'=>60,'maxlength'=>128)); ?> 
38  </div> 
39 
40  <div class="row"> 
41   <?php echo $form->label($model,'numTel'); ?> 
42   <?php echo $form->textField($model,'numTel'); ?> 
43  </div> 
44 
45  <div class="row"> 
46   <?php echo $form->label($model,'numEventiCreati'); ?> 
47   <?php echo $form->textField($model,'numEventiCreati'); ?> 
#9 
+ /home/sigturk/NetBeansProjects/yii/framework/web/CBaseController.php(127): require("/home/sigturk/NetBeansProjects/sitoEventi/protected/views/utente...") 
#10 
+ /home/sigturk/NetBeansProjects/yii/framework/web/CBaseController.php(96): CBaseController->renderInternal("/home/sigturk/NetBeansProjects/sitoEventi/protected/views/utente...", array("model" => UtenteCreaEvento), true) 
#11 
+ /home/sigturk/NetBeansProjects/yii/framework/web/CController.php(870): CBaseController->renderFile("/home/sigturk/NetBeansProjects/sitoEventi/protected/views/utente...", array("model" => UtenteCreaEvento), true) 
#12 
– /home/sigturk/NetBeansProjects/sitoEventi/protected/views/utenteCreaEvento/admin.php(40): CController->renderPartial("_search", array("model" => UtenteCreaEvento)) 
35 
36 <?php echo CHtml::link('Advanced Search','#',array('class'=>'search-button')); ?> 
37 <div class="search-form" style="display:none"> 
38 <?php $this->renderPartial('_search',array(
39  'model'=>$model, 
40)); ?> 
41 </div><!-- search-form --> 
42 
43 <?php $this->widget('zii.widgets.grid.CGridView', array(
44  'id'=>'utente-crea-evento-grid', 
45  'dataProvider'=>$model->search(), 
#13 
+ /home/sigturk/NetBeansProjects/yii/framework/web/CBaseController.php(127): require("/home/sigturk/NetBeansProjects/sitoEventi/protected/views/utente...") 
#14 
+ /home/sigturk/NetBeansProjects/yii/framework/web/CBaseController.php(96): CBaseController->renderInternal("/home/sigturk/NetBeansProjects/sitoEventi/protected/views/utente...", array("model" => UtenteCreaEvento), true) 
#15 
+ /home/sigturk/NetBeansProjects/yii/framework/web/CController.php(870): CBaseController->renderFile("/home/sigturk/NetBeansProjects/sitoEventi/protected/views/utente...", array("model" => UtenteCreaEvento), true) 
#16 
+ /home/sigturk/NetBeansProjects/yii/framework/web/CController.php(783): CController->renderPartial("admin", array("model" => UtenteCreaEvento), true) 
#17 
– /home/sigturk/NetBeansProjects/sitoEventi/protected/controllers/UtenteCreaEventoController.php(146): CController->render("admin", array("model" => UtenteCreaEvento)) 
141   if(isset($_GET['UtenteCreaEvento'])) 
142    $model->attributes=$_GET['UtenteCreaEvento']; 
143 
144   $this->render('admin',array(
145    'model'=>$model, 
146  )); 
147  } 
148 
149  /** 
150  * Returns the data model based on the primary key given in the GET variable. 
151  * If the data model is not found, an HTTP exception will be raised. 
#18 */ 
+ /home/sigturk/NetBeansProjects/yii/framework/web/actions/CInlineAction.php(50): UtenteCreaEventoController->actionAdmin() 
#19 
+ /home/sigturk/NetBeansProjects/yii/framework/web/CController.php(309): CInlineAction->runWithParams(array()) 
#20 
+ /home/sigturk/NetBeansProjects/yii/framework/web/filters/CFilterChain.php(134): CController->runAction(CInlineAction) 
#21 
+ /home/sigturk/NetBeansProjects/yii/framework/web/filters/CFilter.php(41): CFilterChain->run() 
#22 
+ /home/sigturk/NetBeansProjects/yii/framework/web/CController.php(1146): CFilter->filter(CFilterChain) 
#23 
+ /home/sigturk/NetBeansProjects/yii/framework/web/filters/CInlineFilter.php(59): CController->filterAccessControl(CFilterChain) 
#24 
+ /home/sigturk/NetBeansProjects/yii/framework/web/filters/CFilterChain.php(131): CInlineFilter->filter(CFilterChain) 
#25 
+ /home/sigturk/NetBeansProjects/yii/framework/web/CController.php(292): CFilterChain->run() 
#26 
+ /home/sigturk/NetBeansProjects/yii/framework/web/CController.php(266): CController->runActionWithFilters(CInlineAction, array("accessControl", "postOnly + delete")) 
#27 
+ /home/sigturk/NetBeansProjects/yii/framework/web/CWebApplication.php(283): CController->run("admin") 
#28 
+ /home/sigturk/NetBeansProjects/yii/framework/web/CWebApplication.php(142): CWebApplication->runController("utenteCreaEvento/admin") 
#29 
+ /home/sigturk/NetBeansProjects/yii/framework/base/CApplication.php(162): CWebApplication->processRequest() 
#30 
+ /home/sigturk/NetBeansProjects/sitoEventi/index.php(13): CApplication->run() 

模型

class UtenteCreaEvento extends CActiveRecord 
{ 
    /** 
    * Returns the static model of the specified AR class. 
    * @param string $className active record class name. 
    * @return UtenteCreaEvento 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 'tbl_utenteCreaEvento'; 
    } 

    /** 
    * @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, nome, cognome, email', 'required'), 
      array('status, numTel, numEventiCreati, numFeedPositivi, statoCanone', 'numerical', 'integerOnly'=>true), 
      array('username, password, nome, cognome', 'length', 'max'=>128), 
         array('password','length','min'=>6), 
      array('password','authenticate'), 
         array('email', 'length', 'max'=>256), 
      array('email', 'email'), 
         array('numTel, numEventiCreati, numFeedPositivi, statoCanone','safe'), 
      // The following rule is used by search(). 
      // Please remove those attributes that should not be searched. 
      array('id, status, username, nome, cognome, numTel, numEventiCreati, numFeedPositivi, email, statoCanone, dataCreazioneProfilo', '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(
      'eventiCreati' => array(self::HAS_MANY, 'Evento', 'creatoDa'), 
      'fotoCaricate' => array(self::HAS_MANY, 'Foto', 'caricataDaUtenteEventi'), 
     ); 
    } 

    /** 
    * @return array customized attribute labels (name=>label) 
    */ 
    public function attributeLabels() 
    { 
     return array(
      'id' => 'ID', 
      'status' => 'Status', 
      'username' => 'Username', 
      'password' => 'Password', 
      'nome' => 'Nome', 
      'cognome' => 'Cognome', 
      'numTel' => 'Num Tel', 
      'numEventiCreati' => 'Num Eventi Creati', 
      'numFeedPositivi' => 'Num Feed Positivi', 
      'email' => 'Email', 
      'statoCanone' => 'Stato Canone', 
      'dataCreazioneProfilo' => 'Data Creazione Profilo', 
     ); 
    } 

    /** 
    * 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,true); 
     $criteria->compare('status',$this->status); 
     $criteria->compare('username',$this->username,true); 
     $criteria->compare('password',$this->password,true); 
     $criteria->compare('nome',$this->nome,true); 
     $criteria->compare('cognome',$this->cognome,true); 
     $criteria->compare('numTel',$this->numTel); 
     $criteria->compare('numEventiCreati',$this->numEventiCreati); 
     $criteria->compare('numFeedPositivi',$this->numFeedPositivi); 
     $criteria->compare('email',$this->email,true); 
     $criteria->compare('statoCanone',$this->statoCanone); 
     $criteria->compare('dataCreazioneProfilo',$this->dataCreazioneProfilo,true); 

     return new CActiveDataProvider($this, array(
      'criteria'=>$criteria, 
     )); 
    } 

     /** 
    * This is invoked before the record is saved. 
    * @return boolean whether the record should be saved. 
    */ 
    protected function beforeSave() 
    { 
       if ($this->isNewRecord) 
       $this->dataCreazioneProfilo = new CDbExpression('NOW()'); 
       $this->status = 0; 
       $this->statoCanone = 0; 

      return parent::beforeSave(); 
     } 

控制器

public function actionView($id) 
    { 
     $this->render('view',array(
      'model'=>$this->loadModel($id), 
     )); 
    } 

    /** 
    * Creates a new model. 
    * If creation is successful, the browser will be redirected to the 'view' page. 
    */ 
    public function actionCreate() 
    { 
     $model=new UtenteCreaEvento; 

     // Uncomment the following line if AJAX validation is needed 
     // $this->performAjaxValidation($model); 

     if(isset($_POST['UtenteCreaEvento'])) 
     { 
      $model->attributes=$_POST['UtenteCreaEvento']; 
      if($model->save()) 
       $this->redirect(array('view','id'=>$model->id)); 
     } 

     $this->render('create',array(
      'model'=>$model, 
     )); 
    } 

    /** 
    * Updates a particular model. 
    * If update is successful, the browser will be redirected to the 'view' page. 
    * @param integer $id the ID of the model to be updated 
    */ 
    public function actionUpdate($id) 
    { 
     $model=$this->loadModel($id); 

     // Uncomment the following line if AJAX validation is needed 
     // $this->performAjaxValidation($model); 

     if(isset($_POST['UtenteCreaEvento'])) 
     { 
      $model->attributes=$_POST['UtenteCreaEvento']; 
      if($model->save()) 
       $this->redirect(array('view','id'=>$model->id)); 
     } 

     $this->render('update',array(
      'model'=>$model, 
     )); 
    } 

    /** 
    * Deletes a particular model. 
    * If deletion is successful, the browser will be redirected to the 'admin' page. 
    * @param integer $id the ID of the model to be deleted 
    */ 
    public function actionDelete($id) 
    { 
//  $this->loadModel($id)->delete(); 
       $utentecreaEvento = new UtenteCreaEvento(); 
       $utentecreaEvento = UtenteCreaEvento::model()->find('id',$id); 
       $utentecreaEvento->status = 0; 

     // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser 
     if(!isset($_GET['ajax'])) 
      $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin')); 
    } 

    /** 
    * Lists all models. 
    */ 
    public function actionIndex() 
    { 
     $dataProvider=new CActiveDataProvider('UtenteCreaEvento'); 
     $this->render('index',array(
      'dataProvider'=>$dataProvider, 
     )); 
    } 

    /** 
    * Manages all models. 
    */ 
    public function actionAdmin() 
    { 
     $model=new UtenteCreaEvento('search'); 
     $model->unsetAttributes(); // clear any default values 
     if(isset($_GET['UtenteCreaEvento'])) 
      $model->attributes=$_GET['UtenteCreaEvento']; 

     $this->render('admin',array(
      'model'=>$model, 
     )); 
    } 

    /** 
    * 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=UtenteCreaEvento::model()->findByPk($id); 
     if($model===null) 
      throw new CHttpException(404,'The requested page does not exist.'); 
     return $model; 
    } 

    /** 
    * Performs the AJAX validation. 
    * @param CModel the model to be validated 
    */ 
    protected function performAjaxValidation($model) 
    { 
     if(isset($_POST['ajax']) && $_POST['ajax']==='utente-crea-evento-form') 
     { 
      echo CActiveForm::validate($model); 
      Yii::app()->end(); 
     } 
    } 

只有當我嘗試庸俗化這個類的實體時,我纔會得到這種錯誤,但所有其他類型的行爲都不會給出任何問題。 在此先感謝

+0

這不必對權限做任何事情,show是您的CGridView配置和您的管理員操作。 – Asgaroth

+0

插件( 'zii.widgets.grid.CGridView',陣列( \t 'ID'=> 'utente-CREA-事件摘要柵', \t '的dataProvider'=> $模型 - >搜索(), \t '過濾器'=> $模型, \t '列'=>數組( \t \t 'ID', \t \t '狀態', \t \t '用戶名', \t \t '密碼',..... @Asgaroth – And1

+0

只是編輯你的問題,並在那裏添加代碼。你可以刪除權限部分,它不相關 – Asgaroth

回答

1

在您的驗證規則中,您指定了array('password','authenticate'),。因此,模型應該包含一個名爲authenticate()的函數,或者您必須添加從CValidator延伸的authenticate類。

+0

我已經定義了作爲基本項目的UserIdentity類,它在Execute CuserIdentity中定義了公共函數authenticate()並且這個類位於組件文件夾中。並且爲了解決我的問題,最好是將這個函數帶入模型類或專用類中? thx @ dInGd0nG – And1

+0

對不起,但你讓我想到使用規則數組的好處('password','authenticate')。因爲如果我從我的編程中刪除它,我沒有麻煩寫下來,所有的工作都很完美。你能向我解釋一下它有用嗎? @ dInGd0nG – And1

+0

這解決了我的問題也:) – shail

相關問題