public function actionIndex() { $this->active_link = 'dashboard'; //count users $users = User::model()->count('status != '.User::STATUS_DELETED); $objects = Objects::model()->active()->count(array('select'=>'id')); $objectsNew = Objects::model()->active()->count(array('select'=>'id','condition'=>'verified = false')); $polls = PollChoice::model()->count(); $photos = ObjectsImages::model()->count(); $videos = ObjectsHttp::model()->count(array('condition'=>'type='.ObjectsHttp::TYPE_VIDEO)); $this->render('dashboard',array('users'=>$users,'objects'=>$objects, 'objectsNew'=>$objectsNew, 'polls'=>$polls,'photos'=>$photos, 'videos'=>$videos )); }
public function run() { $controller = $this->getController(); $id = (int)Yii::app()->request->getQuery('id',null); // check that you have access to this note $file = ObjectsImages::model()->findByPk($id); if(isset($file->objectid)){ // $pin = $controller->_loadModel($file->pinboard->id); // remove it from disk also in model issueFile // if($file->delete()) { if(isset(Yii::app()->session['deleteObjectsFiles'])){ $sessAr = unserialize(Yii::app()->session['deleteObjectsFiles']); if(isset($sessAr['id']) && $sessAr['id'] == $file->objectid->id && isset($sessAr['files']) && is_array($sessAr['files'])) { $files = $sessAr['files']; if(!in_array($id, $files)) { $files[] = $id; } $sessAr = serialize(array('id'=>$file->objectid->id,'files'=>$files)); Yii::app()->session['deleteObjectsFiles'] = $sessAr; } } else { $sessAr = serialize(array('id'=>$file->objectid->id,'files'=>array($id))); Yii::app()->session['deleteObjectsFiles'] = $sessAr; } echo "[]"; Yii::app()->end(); // } } echo 'error'; Yii::app()->end(); }
protected function beforeDelete() { if (!parent::beforeDelete()) { return false; } Comment::model()->updateAll(array('user_id' => 0), array('condition' => 'user_id=' . $this->id)); ObjectsImages::model()->updateAll(array('uploaded_by' => null), array('condition' => 'uploaded_by=' . $this->id)); Objects::model()->updateAll(array('author' => null), array('condition' => 'author=' . $this->id)); $this->deleteModelDir(); // удалили модель? удаляем и файл и всю папку return true; }
public function actionObject($id){ $id = (int)$id; $model = ObjectsImages::model()->findByPk($id); if(!$model) throw new CHttpException(404, Yii::t('site','Page not found')); // if(Yii::app()->user->isGuest && $model->issue->is_public !== true) // Yii::app()->user->loginRequired(); $available_mime = Yii::app()->params['mime_fileview']; $filename = $model->filename; $realname = $model->realname; $uploadPath = $model->objectid->getFileFolder(); if(file_exists($uploadPath.$filename )) { $type = CFileHelper::getMimeType($uploadPath.$filename); // get yii framework mime if(in_array($type, $available_mime)){ //.. get the content of the requested file $content=file_get_contents($uploadPath.$filename); //.. send appropriate headers header('Content-Type:' . $type); header("Content-Length: ". filesize($uploadPath.$filename)); header('Content-Disposition: inline; filename="' . $realname . '"'); header('Content-Transfer-Encoding: binary'); header('Accept-Ranges: bytes'); echo $content; exit; } else { throw new CHttpException(404, Yii::t('site','Page not found')); } } else{ throw new CHttpException(404, Yii::t('site','Page not found')); } }
<?php if(!empty($pohs)){ ?> <div class="row"> <div class="col-sm-12 col-md-10 col-md-offset-1"> <div class="rootCategory" style="font-size:18px;text-align:center;margin-bottom:18px;"> ПОХОЖЕЕ </div> <div class="card"> <div class="item-article-list three-column"> <?php foreach ($pohs as $poh) { $url = Yii::app()->createAbsoluteUrl('/fastreview/item', array( 'id'=>$poh->id, 'dash'=>'-', 'itemurl'=>$poh->url)); $imgs = ObjectsImages::model()->find(array('condition'=>'object='.$poh->id,'order'=>'date_uploaded, id')); if($imgs) { $src = $imgs->getUrl('320x320xT','adaptiveResizeQuadrant',false,'filename'); } else { $src = '/img/cap.gif'; } ?> <div class="article-bg-container" > <a href="<?php echo $url; ?>" class="article-bg c-white t-uppercase text-center" style="background-image:url('<?php echo $src; ?>');"> <div class="article_caption_title vertical-align-center p-l-20 p-r-20"><?php echo CHtml::encode($poh->title); ?></div> </a> </div> <?php }
public function actionDeleteFile($id) { $id = (int)$id; // check that you have access to this note $file = ObjectsImages::model()->findByPk($id); if(isset($file->objectid)){ // remove it from disk also in model issueFile if($file->delete()) { echo "[]"; Yii::app()->end(); } } echo 'error'; Yii::app()->end(); }