Exemplo n.º 1
0
 public static function addAds($uid)
 {
     if (!$uid) {
         return false;
     }
     $model = new Ads();
     $thekeyid = zmf::filterInput($_POST['Ads']['id']);
     $attachid = zmf::filterInput($_POST['Ads']['attachid'], 't', 1);
     $intoData = $_POST['Ads'];
     $intoData['attachid'] = $attachid;
     $intoData['status'] = 1;
     $intoData['uid'] = $uid;
     if (isset($intoData['start_time'])) {
         $intoData['start_time'] = strtotime($intoData['start_time']);
     }
     if (isset($intoData['expired_time'])) {
         $intoData['expired_time'] = strtotime($intoData['expired_time']);
     }
     $model->attributes = $intoData;
     if ($model->validate()) {
         if ($model->updateByPk($thekeyid, $intoData)) {
             zmf::delFCache("notSaveAds{$uid}");
             if ($attachid) {
                 Attachments::model()->updateAll(array('status' => Posts::STATUS_DELED), "logid={$thekeyid} AND uid={$uid} AND classify='ads'");
                 Attachments::model()->updateAll(array('status' => Posts::STATUS_PASSED), "id={$attachid}");
             }
             return true;
         } else {
             $info = $_POST['Ads'];
         }
     } else {
         $info = $_POST['Ads'];
     }
     return $info;
 }