public function actionDoUpgrade()
 {
     $siteInfo = new SiteForm();
     $siteInfo->getSetting();
     if (UpgradeInfo::compareVersion($siteInfo->version, "1.3.0") < 0) {
         $siteInfo->version = "1.3.0";
         $siteInfo->saveSetting();
     }
     $criteria = new CDbCriteria();
     //$criteria->select = 'version';
     $criteria->condition = 'status=:status';
     $criteria->order = 'versionId';
     $criteria->params = array(':status' => 'not installed');
     $upgradeInfos = UpgradeInfo::model()->findAll($criteria);
     $vertionString = '';
     foreach ($upgradeInfos as $upgradeInfo) {
         if (UpgradeInfo::compareVersion($siteInfo->version, $upgradeInfo->version) >= 0) {
             $upgradeInfo->status = "skipped";
             $upgradeInfo->save();
             continue;
         }
         $vertionString .= '"' . strval($upgradeInfo->version) . '",';
     }
     $this->layout = "/layouts/nonav_column1";
     $this->render('do_upgrade_fancy', array('versions' => $vertionString));
 }
示例#2
0
 /**
  * 用来更新upgradeinfo信息
  * Enter description here ...
  * @param json $response 从服务器得到的需要更新的更新包信息 
  */
 public static function updateUpgradeInfo($response)
 {
     $result = json_decode($response, true);
     $siteInfo = new SiteForm();
     $siteInfo->getSetting();
     if (count($result)) {
         //对每一个需要更新的包
         foreach ($result as $r) {
             $model = new UpgradeInfo();
             $model->versionId = $r['id'];
             if (UpgradeInfo::model()->findByAttributes(array('versionId' => $r['id']))) {
                 continue;
             }
             $model->version = $r['version'];
             $model->name = $r['name'];
             $model->addTime = $r['addTime'];
             $model->description = $r['description'];
             if (UpgradeInfo::compareVersion($siteInfo->version, $model->version) < 0) {
                 $model->save();
             }
         }
     }
 }