Example #1
0
 public function afterUninstall()
 {
     Yii::app()->settings->clear('contacts');
     $db = Yii::app()->db;
     $db->createCommand()->dropTable(ContactsMaps::model()->tableName());
     $db->createCommand()->dropTable(ContactsMarkers::model()->tableName());
     $db->createCommand()->dropTable(ContactsRouter::model()->tableName());
     $db->createCommand()->dropTable(ContactsRouterTranslate::model()->tableName());
     return parent::afterUninstall();
 }
 /**
  * Действие редактирование и добавление
  * @param bool $new
  * @throws CHttpException
  */
 public function actionUpdate($new = false)
 {
     $mapsCount = ContactsMaps::model()->count();
     if ($mapsCount < 1) {
         throw new CHttpException(403);
     }
     $model = $new === true ? new ContactsMarkers() : ContactsMarkers::model()->findByPk($_GET['id']);
     $this->pageName = $model->isNewRecord ? Yii::t('app', 'CREATE', 1) : Yii::t('app', 'UPDATE', 1);
     $oldImage = $model->icon_file;
     $this->breadcrumbs = array(Yii::t('ContactsModule.default', 'MODULE_NAME') => array('/admin/contacts'), Yii::t('ContactsModule.default', 'MARKERS') => array('/admin/contacts/markers'), $this->pageName);
     if (isset($_POST['ContactsMarkers'])) {
         $model->attributes = $_POST['ContactsMarkers'];
         if ($model->validate()) {
             $model->uploadFile('icon_file', 'webroot.uploads', $oldImage);
             $model->save();
             $this->redirect(array('index'));
         }
     }
     $this->render('update', array('model' => $model));
 }