コード例 #1
0
ファイル: RecruitAttach.php プロジェクト: AxelPanda/ibos
 public function upload()
 {
     $uid = intval(EnvUtil::getRequest("uid"));
     $this->upload->save();
     $attach = $this->upload->getAttach();
     $attachment = $attach["type"] . "/" . $attach["attachment"];
     $data = array("dateline" => TIMESTAMP, "filename" => $attach["name"], "filesize" => $attach["size"], "attachment" => $attachment, "isimage" => $attach["isimage"], "uid" => $uid);
     $aid = Attachment::model()->add(array("uid" => $uid, "tableid" => 127), true);
     $data["aid"] = $aid;
     AttachmentUnused::model()->add($data);
     $file["aid"] = $aid;
     $file["name"] = $attach["name"];
     $file["url"] = FileUtil::fileName(FileUtil::getAttachUrl() . "/" . $attachment);
     if (!empty($file) && is_array($file)) {
         return CJSON::encode($file);
     } else {
         return CJSON::encode(array("aid" => 0, "url" => 0, "name" => 0));
     }
 }
コード例 #2
0
ファイル: AttachUtil.php プロジェクト: AxelPanda/ibos
 public static function updateAttach($aid, $relateId = 0)
 {
     $aid = is_array($aid) ? $aid : explode(",", $aid);
     $relateId = 0 < $relateId ? $relateId : mt_rand(0, 9);
     $uid = Ibos::app()->user->uid;
     $records = Attachment::model()->findAllByPk($aid);
     $count = 0;
     foreach ($records as $record) {
         $id = $record["aid"];
         if (strcasecmp($record["uid"], $uid) !== 0 || strcasecmp($record["tableid"], 127) !== 0) {
             continue;
         } else {
             $unused = AttachmentUnused::model()->fetchByPk($id);
             $tableId = self::getTableId($relateId);
             Attachment::model()->modify($id, array("tableid" => $tableId));
             AttachmentN::model()->add($tableId, $unused);
             AttachmentUnused::model()->deleteByPk($id);
             $count++;
         }
     }
     return !!$count;
 }