Example #1
0
 public static function getAttachNameSearch($attachName = "")
 {
     $condition = array();
     if (!empty($attachName)) {
         $runIds = array();
         foreach (FlowRun::model()->fetchAllAttachID() as $run) {
             $table = "attachment_" . AttachUtil::getTableId($run["runid"]);
             $sql = "SELECT 1 FROM {{$table}} WHERE FIND_IN_SET(aid,'{$run["attachmentid"]}') AND filename LIKE '%{$attachName}%'";
             $flag = Ibos::app()->db->createCommand()->setText($sql)->queryScalar();
             if ($flag) {
                 $runIds[] = $run["runid"];
             }
         }
         if (!empty($runIds)) {
             $condition[] = sprintf("FIND_IN_SET(fr.runid,'%s')", implode(",", $runIds));
         } else {
             $condition[] = "1=2";
         }
     }
     return $condition;
 }
Example #2
0
 protected function handleImgComponent(&$formData)
 {
     foreach ($GLOBALS["_FILES"] as $key => $value) {
         if (strtolower(substr($key, 0, 5)) == "data_") {
             $formData["{$key}"] = "";
             $old = $_POST["imgid_" . substr($key, 5)];
             if ($value["name"] != "") {
                 if (!empty($old)) {
                     AttachUtil::delAttach($old);
                 }
                 $upload = FileUtil::getUpload($_FILES[$key], "workflow");
                 $upload->save();
                 $attach = $upload->getAttach();
                 $attachment = "workflow/" . $attach["attachment"];
                 $imgData = array("dateline" => TIMESTAMP, "filename" => $attach["name"], "filesize" => $attach["size"], "isimage" => $attach["isimage"], "attachment" => $attachment, "uid" => $this->uid);
                 $aid = Attachment::model()->add(array("uid" => $this->uid, "rid" => $this->runid, "tableid" => AttachUtil::getTableId($this->runid)), true);
                 $imgData["aid"] = $aid;
                 $newAttach = AttachmentN::model()->add(sprintf("rid:%d", $this->runid), $imgData, true);
                 $formData["{$key}"] = $newAttach;
             } else {
                 $formData["{$key}"] = $old;
             }
         }
     }
 }