Beispiel #1
0
 /**
  * function ->update2 ($data)
  */
 public function update2($data)
 {
     $now = strtotime('now');
     $username = Yii::$app->user->identity->username;
     if ($this->load($data)) {
         if ($log = new UserLog()) {
             $log->username = $username;
             $log->action = 'Update';
             $log->object_class = 'NoreplyEmail';
             $log->object_pk = $this->id;
             $log->created_at = $now;
             $log->is_success = 0;
             $log->save();
         }
         $this->start_sending_at = strtotime($this->start_sending_at);
         empty($this->last_sent_at) or $this->last_sent_at = strtotime($this->last_sent_at);
         if ($this->image_path != null && trim($this->image_path) != '' && is_dir(Yii::$app->params['images_folder'] . $this->image_path)) {
             $path = $this->image_path;
         } else {
             do {
                 $path = FileUtils::generatePath($now);
             } while (file_exists(Yii::$app->params['images_folder'] . $path));
         }
         $this->image_path = $path;
         $targetFolder = Yii::$app->params['images_folder'] . $this->image_path;
         $targetUrl = Yii::$app->params['images_url'] . $this->image_path;
         $this->content = FileUtils::copyContentImages(['content' => $this->content, 'defaultFromFolder' => Yii::$app->params['uploads_folder'], 'toFolder' => $targetFolder, 'toUrl' => $targetUrl, 'removeInputImage' => true]);
         if ($this->save()) {
             if ($log) {
                 $log->is_success = 1;
                 $log->save();
             }
             return true;
         }
         return false;
     }
     return false;
 }
 /**
  * function ->update2 ($data)
  */
 public function update2($data)
 {
     $now = strtotime('now');
     $username = Yii::$app->user->identity->username;
     if ($this->load($data)) {
         if ($log = new UserLog()) {
             $log->username = $username;
             $log->action = "Update ProductCategoryTranslation, id = {$this->id}";
             $log->created_at = $now;
             $log->type = 2;
             $log->is_success = 0;
             $log->save();
         }
         if ($this->image_path != null && trim($this->image_path) != '' && is_dir(Yii::$app->params['images_folder'] . $this->image_path)) {
             $path = $this->image_path;
         } else {
             do {
                 $path = FileUtils::generatePath($now);
             } while (file_exists(Yii::$app->params['images_folder'] . $path));
         }
         $this->image_path = $path;
         $targetFolder = Yii::$app->params['images_folder'] . $this->image_path;
         $targetUrl = Yii::$app->params['images_url'] . $this->image_path;
         $this->description = FileUtils::copyContentImages(['content' => $this->description, 'defaultFromFolder' => Yii::$app->params['uploads_folder'], 'toFolder' => $targetFolder, 'toUrl' => $targetUrl, 'removeInputImage' => true]);
         if ($this->save()) {
             if ($log) {
                 $log->is_success = 1;
                 $log->save();
             }
             return true;
         }
         return false;
     }
     return false;
 }