コード例 #1
0
 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionImagesUpload()
 {
     $imagePaths = null;
     $propertyImages = new PropertyImages();
     $session = new CHttpSession();
     $session->open();
     if (!isset($session['totalImages'])) {
         $session['totalImages'] = 0;
     }
     if ($session['totalImages'] < Yii::app()->params['uploadImagesLimit']) {
         $imagePath = ImageUtils::uploadImage($propertyImages, 'image');
         $session['totalImages'] = $session['totalImages'] + 1;
         if (isset($session['PropertyImages'])) {
             $images = $session['PropertyImages'];
         } else {
             $images = array();
         }
         $images[] = $imagePath;
         $session['PropertyImages'] = $images;
         print_r($propertyImages, true);
     } else {
         throw new CException(500);
     }
     Yii::app()->end();
 }
コード例 #2
0
ファイル: WheelController.php プロジェクト: romeo14/pow
 public function actionUpdate()
 {
     $wheelId = 63;
     $model = new Wheel();
     $model = WheelApi::getWheelById($wheelId);
     //var_dump($model);die();
     $modelFeatures = new WheelFeatures();
     //var_dump($modelFeatures);
     $modelImages = new Images();
     $wheelImageId = array($wheelId);
     $image = ImagesApi::getPrimaryImageForWheels($wheelImageId);
     if ($image) {
         $wheelImage = $image[$wheelId];
     } else {
         $wheelImage = ImageUtils::getDefaultImage("wheel");
     }
     if (isset($_POST['update'])) {
         $model->attributes = $_POST['Wheel'];
         //var_dump($model->attributes);
         $modelImages->attributes = $_POST['Images'];
         $updateWheel = WheelApi::updateWheelById($wheelId, $_POST['Wheel']);
         if ($updateWheel) {
             if (!$updateWheel->hasErrors()) {
                 if (isset($_POST['feature_id'])) {
                     $deleteWheelFeatures = WheelFeaturesApi::deleteAllFeaturesOfWheel($wheelId);
                     $updateWheelFeature = WheelFeaturesApi::addWheelFeatures($wheelId, $_POST['feature_id']);
                     //var_dump($updateWheelFeature);die();
                 }
                 if (isset($_POST['Images'])) {
                     $entityId = EntityApi::getIdByType('WHEEL');
                     $filename = ImagesApi::getImage($wheelId, $entityId);
                     $imagePath = ImageUtils::uploadImage($modelImages, 'filename');
                     if ($imagePath) {
                         $image = ImagesApi::addImage($wheelId, $entityId, $imagePath);
                         if ($image) {
                             if ($filename) {
                                 $deleteWheelImage = ImagesApi::deleteImage($wheelId, $entityId, $filename);
                             }
                         }
                         if (file_exists($imagePath)) {
                             unlink($imagePath);
                         }
                     }
                 }
             }
         }
     }
     $postedImage = ImagesApi::getPrimaryImageForWheels($wheelImageId);
     $wheelImage = isset($_POST['Images']) ? $postedImage[$wheelId] : $wheelImage;
     $modelFeatures = WheelFeaturesApi::getAllWheelFeatures($wheelId);
     $this->render('update', array('model' => $model, 'modelFeatures' => $modelFeatures, 'modelImages' => $modelImages, 'wheelImage' => $wheelImage, 'postedImage' => $postedImage));
     //$this->render('update',array('$userProfile'=>$userProfile,'userImage'=>$userImage,'userAge'=>$userAge,'userAddress'=>$userAddress));
 }
コード例 #3
0
 public function actionindex()
 {
     $model = new Feedback();
     if (isset($_POST['Feedback'])) {
         $model->attributes = $_POST['Feedback'];
         if ($model->validate()) {
             $imagePath = ImageUtils::uploadImage($model, 'image');
             if ($imagePath) {
                 $model->image = FeedbackImagesApi::addImage($imagePath);
             }
             if ($model->save()) {
                 EmailApi::sendEmail($model->email_id, "FEEDBACK.SUCCESS");
                 $this->redirect('/feedback/thanks');
             }
         }
     }
     $feedbackTopics = new FeedbackTopic();
     $this->renderPartial('index', array('model' => $model, 'feedbackTopics' => $feedbackTopics));
 }
コード例 #4
0
 public function actionPost()
 {
     Yii::beginProfile('project_post');
     $model = new Projects();
     $modelCity = new GeoCity();
     $modelState = new GeoState();
     $modelAmenities = new ProjectAmenities();
     $modelImages = new ProjectImages();
     $amenities = null;
     if (isset($_POST['submit'])) {
         $model->attributes = $_POST['Projects'];
         $modelImages->attributes = $_POST['ProjectImages'];
         $amenities = isset($_POST['amenity_id']) ? $_POST['amenity_id'] : null;
         /*if($amenities){
         	 $amenity_data = null;
         	 foreach($amenities as $i=>$amenity){
         	 if($i!=0)
         	 $amenity_data.=',';
         	 $amenity_data.=$amenity;
         	 }
         	 $amenities = $amenity_data;
         	 }*/
         $valid = true;
         $model->user_id = Yii::app()->user->id;
         $valid = $valid && $model->validate();
         if ($amenities == null) {
             $modelAmenities->addError('amenity_id', 'Amenities cannot be blank.');
             $valid = false;
         }
         $modelImages->image = CUploadedFile::getInstance($modelImages, 'image');
         if ($modelImages->image == "") {
             $modelImages->addError('image', 'Image cannot be blank.');
             $valid = false;
         }
         if ($valid) {
             $data = $_POST['Projects'];
             $project = ProjectApi::createProject('1', $data);
             if (!$project->hasErrors()) {
                 $amenities = ProjectAmenitiesApi::addAmenitiesForProject($project->id, $_POST['amenity_id']);
                 $imagePath = ImageUtils::uploadImage($modelImages, 'image');
                 if ($amenities && $imagePath) {
                     $image = ProjectImagesApi::addImage($project->id, $imagePath);
                     if (!$image) {
                         ProjectApi::deleteProjectById($project->id);
                         ProjectAmenitiesApi::deleteAllAmenitiesForProject($project->id);
                     }
                     if (file_exists($imagePath)) {
                         unlink($imagePath);
                     }
                     $data = array();
                     $user = UserApi::getUserById($project->user_id);
                     $user ? $data["user"] = $user->id : null;
                     $data["project"] = $project->id;
                     EmailApi::sendEmail($user->email_id, "ACTIVITY.PROJECT.NEW", $data);
                     $this->redirect('/project/' . $project->id);
                 } else {
                     ProjectApi::deleteProjectById($project->id);
                     ProjectAmenitiesApi::deleteAllAmenitiesForProject($project->id);
                 }
             } else {
                 if (isset($property->id)) {
                     ProjectApi::deleteProjectById($property->id);
                 }
             }
         }
     }
     $this->render('post', array('model' => $model, 'modelState' => $modelState, 'modelCity' => $modelCity, 'modelAmenities' => $modelAmenities, 'modelImages' => $modelImages, 'amenities' => $amenities));
     Yii::endProfile('project_post');
 }
コード例 #5
0
 public function actionUpdate()
 {
     Yii::beginProfile('builder_update');
     $userId = Yii::app()->user->id;
     $model = BuilderProfileApi::getBuilderDetails($userId);
     if (!$model) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     $image = $model->image;
     $projectType = new UserBuilderProjectType();
     $projecttypes = '';
     $modelState = new GeoState();
     $locationCity = new UserBuilderLocations();
     $locations = '';
     $projectTypeIds = UserBuilderProjectTypeApi::getProjectTypes($model->id);
     if ($projectTypeIds) {
         foreach ($projectTypeIds as $types) {
             $projecttypes[] = $types->project_type_id;
         }
     }
     $locationCityIds = UserBuilderLocationsApi::getLocations($model->id);
     if ($locationCityIds) {
         foreach ($locationCityIds as $cities) {
             $locations[] = $cities->city_id;
         }
     }
     $this->performAjaxValidation($model);
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'builder-form') {
         echo CActiveForm::validate($model);
         Yii::app()->end();
     }
     if (isset($_POST['submit'])) {
         $model->attributes = $_POST['UserBuilderProfile'];
         $valid = true;
         $model->user_id = $userId;
         $valid = $valid && $model->validate();
         $builder = "";
         if (!isset($_POST['project_type_id'])) {
             $projectType->addError('UserBuilderProjectType', 'Project Type cannot be blank.');
             $valid = false;
         }
         if (!isset($_POST['city_id'])) {
             $locationCity->addError('city_id', 'City cannot be blank.');
             $valid = false;
         }
         if ($valid) {
             $data = $_POST['UserBuilderProfile'];
             $data['image'] = $image;
             $imagePath = ImageUtils::uploadImage($model, 'image');
             if ($imagePath) {
                 $image = BuilderProfileApi::addImage($userId, $imagePath);
                 if ($image) {
                     $data['image'] = $image;
                     ImageUtils::deleteImage($imagePath);
                 }
             }
             $builder = BuilderProfileApi::updateBuilderProfile($userId, $data);
             UserBuilderProjectTypeApi::deleteProjectTypes($builder->id);
             $projecttypes = UserBuilderProjectTypeApi::createProjectTypes($builder->id, $_POST['project_type_id']);
             UserBuilderLocationsApi::deleteLocations($builder->id);
             $locations = UserBuilderLocationsApi::createLocations($builder->id, $_POST['city_id']);
         }
         if ($builder) {
             $data = array();
             $user = UserApi::getUserById(Yii::app()->user->id);
             $user ? $data["user"] = $user->id : null;
             $data["builder"] = $builder->id;
             EmailApi::sendEmail($user->email_id, "ACTIVITY.BUILDER.CREATE", $data);
             Yii::app()->user->setFlash('success', 'You are Successfully updated Builder Profile.');
             $this->redirect('/builder/' . $userId);
         }
     }
     $this->render('update', array('model' => $model, 'projectType' => $projectType, 'projecttypes' => $projecttypes, 'modelState' => $modelState, 'locationCity' => $locationCity, 'locations' => $locations, 'locationCityIds' => $locationCityIds));
     Yii::endProfile('builder_update');
 }
コード例 #6
0
 public function actionUpdate()
 {
     Yii::beginProfile('specialist_update');
     $userId = Yii::app()->user->id;
     $modelCity = new UserSpecialistLocations();
     $model = SpecialistProfileApi::getSpecialistDetails($userId);
     if (!$model) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     $image = $model->image;
     $specialistType = new UserSpecialistType();
     $specialistTypes = SpecialistTypeApi::getSpecialistTypeByUserId($userId);
     $specialists = "";
     if ($specialistTypes) {
         foreach ($specialistTypes as $types) {
             $specialists[] = $types->id;
         }
     }
     $locationCityIds = UserSpecialistLocationsApi::getLocations($model->id);
     $this->performAjaxValidation($model);
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'specialist-form') {
         echo CActiveForm::validate($model);
         Yii::app()->end();
     }
     if (isset($_POST['submit'])) {
         $model->attributes = $_POST['UserSpecialistProfile'];
         $specialists = isset($_POST['specialist_type_id']) ? $_POST['specialist_type_id'] : null;
         $valid = true;
         $model->user_id = $userId;
         $valid = $valid && $model->validate();
         if ($specialists == null) {
             $specialistType->addError('specialist_type_id', 'Specialist Type cannot be blank.');
             $valid = false;
         }
         $specialist = "";
         if ($valid) {
             $data = $_POST['UserSpecialistProfile'];
             $data['image'] = $image;
             $imagePath = ImageUtils::uploadImage($model, 'image');
             if ($imagePath) {
                 $image = SpecialistApi::addImage($userId, $imagePath);
                 if ($image) {
                     $data['image'] = $image;
                     ImageUtils::deleteImage($imagePath);
                 }
             }
             $specialist = SpecialistProfileApi::updateProfileByUserId($userId, $data);
             SpecialistTypeApi::delete($userId);
             $specialists = SpecialistTypeApi::createSpecialistTypes($userId, $_POST['specialist_type_id']);
             UserSpecialistLocationsApi::deleteLocations($specialist->id);
             $locations = UserSpecialistLocationsApi::createLocations($specialist->id, $_POST['city_id']);
         }
         if ($specialist) {
             $data = array();
             $user = UserApi::getUserById(Yii::app()->user->id);
             $user ? $data["user"] = $user->id : null;
             $data["specialist"] = $specialist->id;
             EmailApi::sendEmail($user->email_id, "ACTIVITY.SPECIALIST.CREATE", $data);
             Yii::app()->user->setFlash('success', 'You are Successfully updated Specialist Profile.');
             $this->redirect('/specialist/' . $userId);
         }
     }
     $this->render('update', array('model' => $model, 'specialistType' => $specialistType, 'specialists' => $specialists, 'locationCityIds' => $locationCityIds, 'modelCity' => $modelCity));
     Yii::endProfile('specialist_update');
 }