public function actionPickAtt()
 {
     $return_id = $_GET['return_id'];
     $rtype = $_GET['rtype'];
     $criteria = new CDbCriteria();
     if (isset($_GET['keyword'])) {
         $screen_name = trim($_GET['keyword']);
         $criteria->condition = 'screen_name like :screen_name';
         $criteria->params = array(':screen_name' => "%{$screen_name}%");
         $partial_tpl = '_att';
         //$atts = Attachment::model()->findAll($criteria);
         //$this->renderPartial('_att',array('return_id' => $return_id,'atts' => $atts,'rtype' => $rtype ),false,true);
     } else {
         $partial_tpl = 'pickatt';
         //$atts = Attachment::model()->findAll();
         //$this->renderPartial('pickatt',array('return_id' => $return_id,'atts' => $atts ,'rtype' => $rtype ),false,true);
     }
     $item_count = Attachment::model()->count($criteria);
     $page_size = 10;
     $pages = new CPagination($item_count);
     $pages->setPageSize($page_size);
     $pagination = new CLinkPager();
     $pagination->cssFile = false;
     $pagination->setPages($pages);
     $pagination->init();
     $criteria->limit = $page_size;
     $criteria->offset = $pages->offset;
     $select_pagination = new CListPager();
     $select_pagination->htmlOptions['onchange'] = "";
     $select_pagination->setPages($pages);
     $select_pagination->init();
     $atts = Attachment::model()->findAll($criteria);
     $this->renderPartial($partial_tpl, array('return_id' => $return_id, 'atts' => $atts, 'rtype' => $rtype, 'pagination' => $pagination, 'select_pagination' => $select_pagination), false, true);
 }
Exemple #2
0
 public function fetchAllBodyIdByKeywordFromAttach($keyword, $whereAdd = "1", $queryArchiveId = 0)
 {
     $kwBodyIds = array();
     $queryParam = "uid = " . Ibos::app()->user->uid;
     $kwAttachments = Attachment::model()->fetchAllByKeywordFileName($keyword, $queryParam);
     if (!empty($kwAttachments)) {
         $kwAids = array_keys($kwAttachments);
         $emailData = $this->fetchAllByArchiveIds("e.*,eb.*,", "{$whereAdd} AND attachmentid!=''", $queryArchiveId);
         foreach ($emailData as $email) {
             if (array_intersect($kwAids, explode(",", $email["attachmentid"]))) {
                 $kwBodyIds[] = $email["bodyid"];
             }
         }
     }
     return $kwBodyIds;
 }
 public function actionRepairUpload()
 {
     $index = $this->request->getParam("selectedIndex");
     $pre_id = $this->request->getParam("upload_save_to_db_id");
     $inputFileName = "repair_attached_file" . $index;
     $attach = CUploadedFile::getInstanceByName($inputFileName);
     $retValue = "";
     if ($attach == null) {
         $retValue = "提示:不能上传空文件。";
     } else {
         if ($attach->size > 2000000) {
             $retValue = "提示:文件大小不能超过2M。";
         } else {
             $retValue = '恭喜,上传成功!';
             if ($pre_id == 0) {
                 $f = file_get_contents($attach->tempName);
                 $a = new Attachment();
                 $a->ref_type = "failParts";
                 $a->data = $f;
                 $a->file_path = $attach->name;
                 $a->save();
                 $cur_id = $a->id;
             } else {
                 $trans = Yii::app()->db->beginTransaction();
                 try {
                     $f = file_get_contents($attach->tempName);
                     $a = new Attachment();
                     $a->ref_type = "failParts";
                     $a->data = $f;
                     $a->file_path = $attach->name;
                     $a->save();
                     $cur_id = $a->id;
                     $pre = Attachment::model()->findByPk($pre_id);
                     $pre->delete();
                     $trans->commit();
                 } catch (Exception $e) {
                     $retValue = $e->getMessage();
                     $cur_id = 0;
                     $trans->rollback();
                 }
             }
             echo "<script type='text/javascript'>window.top.window.successUpload('{$retValue}',{$cur_id},{$index})</script>";
             exit;
         }
     }
     echo "<script type='text/javascript'>window.top.window.stopUpload('{$retValue}',{$index})</script>";
 }
Exemple #4
0
 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));
     }
 }
Exemple #5
0
 public function actionIndex()
 {
     $systemInfo = EnvUtil::getSystemInfo();
     $databaseSize = DatabaseUtil::getDatabaseSize();
     list($dataSize, $dataUnit) = explode(" ", $databaseSize);
     $appClosed = Setting::model()->fetchSettingValueByKey("appclosed");
     $newVersion = Ibos::app()->setting->get("newversion");
     $getSecurityUrl = Ibos::app()->urlManager->createUrl("dashboard/index/getsecurity");
     $mainModule = Module::model()->fetchByPk("main");
     $authkey = Ibos::app()->setting->get("config/security/authkey");
     $unit = Setting::model()->fetchSettingValueByKey("unit");
     $license = Setting::model()->fetchSettingValueByKey("license");
     $licenseUrl = $this->getLicenseUrl(unserialize($unit), $authkey);
     if (isset($_GET["attachsize"])) {
         $attachSize = Attachment::model()->getTotalFilesize();
         $attachSize = is_numeric($attachSize) ? ConvertUtil::sizeCount($attachSize) : Ibos::lang("Unknow");
     } else {
         $attachSize = "";
     }
     $data = array("sys" => $systemInfo, "dataSize" => $dataSize, "dataUnit" => $dataUnit, "appClosed" => $appClosed, "newVersion" => $newVersion, "getSecurityUrl" => $getSecurityUrl, "installDate" => $mainModule["installdate"], "authkey" => $authkey, "license" => unserialize($license), "licenseUrl" => $licenseUrl, "attachSize" => $attachSize);
     $this->render("index", $data);
 }
Exemple #6
0
 public function actionPhotos()
 {
     $criteria = new CDbCriteria();
     $criteria->condition = 'user_id = :user_id';
     $criteria->params = array(':user_id' => User()->id);
     $criteria->order = 'c_time DESC';
     if (isset($_GET['keyword'])) {
         $partial_tpl = '_photos';
     } else {
         $partial_tpl = 'photos';
     }
     $item_count = Attachment::model()->count($criteria);
     $pages = new CPagination($item_count);
     $pages->setPageSize($page_size);
     $pagination = new CLinkPager();
     $pagination->cssFile = false;
     $pagination->setPages($pages);
     $pagination->init();
     $criteria->limit = 6;
     $criteria->offset = $pages->offset;
     $select_pagination = new CListPager();
     $photos = Attachment::model()->findAll($criteria);
     $this->renderPartial($partial_tpl, array('photos' => $photos, 'pagination' => $pagination, 'select_pagination' => $select_pagination), false, true);
 }
 /**
  * WFormRelationHasMany::delete
  */
 public function testDeleteWithoutCascade()
 {
     $product = $this->_getProductWithRelation(1, array('cascadeDelete' => false));
     $this->assertCount(1, $product->images);
     $id = $product->images[0]->primaryKey;
     $this->assertTrue($product->delete());
     $this->assertNotEmpty(Attachment::model()->findByPk($id));
 }
Exemple #8
0
 public function download($attach, $downloadInfo)
 {
     $attachUrl = FileUtil::getAttachUrl();
     $attachment = FileUtil::fileName($attachUrl . "/" . $attach["attachment"]);
     Attachment::model()->updateDownload($attach["aid"]);
     header("Location:{$attachment}");
 }
Exemple #9
0
 * @author Brett O'Donnell <*****@*****.**>
 * @author Zain Ul abidin <*****@*****.**>
 * @copyright 2013 Mr PHP
 * @link https://github.com/cornernote/yii-dressing
 * @license BSD-3-Clause https://raw.github.com/cornernote/yii-dressing/master/license.txt
 */
$this->pageTitle = $this->getName() . ' ' . Yii::t('dressing', ucfirst($task));
$attachment = $id ? Attachment::model()->findByPk($id) : new Attachment('search');
/** @var YdActiveForm $form */
$form = $this->beginWidget('dressing.widgets.YdActiveForm', array('id' => 'attachment-' . $task . '-form', 'type' => 'horizontal', 'action' => array('/attachment/delete', 'id' => $id, 'task' => $task, 'confirm', 1)));
echo $this->getGridIdHiddenFields($id);
echo $form->beginModalWrap();
echo $form->errorSummary($attachment);
echo '<fieldset>';
echo '<legend>' . Yii::t('dressing', 'Selected Records') . '</legend>';
$attachments = Attachment::model()->findAll('t.id IN (' . implode(',', YdHelper::getGridIds($id)) . ')');
if ($attachments) {
    echo '<ul>';
    foreach ($attachments as $attachment) {
        echo '<li>';
        echo $attachment->getName();
        echo '</li>';
    }
    echo '</ul>';
}
echo '</fieldset>';
echo $form->endModalWrap();
echo '<div class="' . $form->getSubmitRowClass() . '">';
$this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'submit', 'type' => 'primary', 'label' => Yii::t('dressing', 'Confirm ' . ucfirst($task)), 'htmlOptions' => array('class' => 'pull-right')));
echo '</div>';
$this->endWidget();
Exemple #10
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;
             }
         }
     }
 }
 public static function model($className = __CLASS__)
 {
     return parent::model($className);
 }
Exemple #12
0
 public static function getAttachData($aid, $filterUnused = true)
 {
     $attach = array();
     $aid = is_array($aid) ? $aid : explode(",", trim($aid, ","));
     $records = Attachment::model()->fetchAllByPk($aid, $filterUnused ? "tableid != 127" : "");
     foreach ($records as $record) {
         if (!empty($record)) {
             $data = AttachmentN::model()->fetch($record["tableid"], $record["aid"]);
             $data["tableid"] = $record["tableid"];
             $attach[$record["aid"]] = $data;
         }
     }
     return $attach;
 }
Exemple #13
0
 public function download($attach, $downloadInfo = array())
 {
     $file = FileUtil::getAttachUrl() . "/" . $attach["attachment"];
     if (file_exists($file)) {
         if (Ibos::app()->browser->name == "msie" || Ibos::app()->browser->getVersion() == "10.0" || Ibos::app()->browser->getVersion() == "11.0") {
             $usingIe = true;
         } else {
             $usingIe = false;
         }
         $typeArr = array("1" => "application/octet-stream", "3" => "application/msword", "4" => "application/msexcel", "5" => "application/mspowerpoint", "7" => "application/octet-stream", "8" => "application/x-shockwave-flash", "10" => "application/pdf");
         $attachType = AttachUtil::Attachtype(StringUtil::getFileExt($attach["filename"]), "id");
         $content = false;
         if (isset($downloadInfo["directView"])) {
             if (!in_array($attachType, array("1", "7", "8", "10"))) {
                 $content = true;
             }
             $contentType = $typeArr[$attachType];
         } else {
             if (in_array($attachType, array("3", "4", "5")) && $usingIe) {
                 $contentType = $typeArr[$attachType];
             } else {
                 $content = 1;
                 $contentType = "application/octet-stream";
             }
         }
         ob_end_clean();
         header("Cache-control: private");
         header("Content-type: {$contentType}");
         header("Accept-Ranges: bytes");
         header("Content-Length: " . sprintf("%u", $this->fileSize($file)));
         if ($usingIe) {
             $attach["filename"] = urlencode($attach["filename"]);
         }
         if ($content) {
             header("Content-Disposition: attachment; filename=\"" . $attach["filename"] . "\"");
         } else {
             header("Content-Disposition: filename=\"" . $attach["filename"] . "\"");
         }
         Attachment::model()->updateDownload($attach["aid"]);
         readfile($file);
         exit;
     }
 }
Exemple #14
0
				upload_error_handler : uploadError,
				upload_success_handler : uploadSuccess,
				upload_complete_handler : uploadComplete,
				queue_complete_handler : queueComplete	// Queue plugin event
			};

			swfu = new SWFUpload(settings);
	     };
	</script>
	
<table width="100%">
  <tr>
    <td width="150" class="blue">remind for categorys</td>
    <td class="green">
      <?php 
$atts = Attachment::model()->findAll();
echo "<ul class='atm_photos' >";
foreach ($atts as $t) {
    echo '<li>';
    echo "<a class='lightbox' href='" . Yii::app()->request->baseUrl . '/upfiles/' . $t->path . "' >";
    echo "<img src='/upfiles/s" . $t->path . "' /> ";
    echo '</a>';
    echo '<p>' . $t->screen_name . '</p>';
    ?>
			<input type="text" value="<?php 
    echo $t->screen_name;
    ?>
" size="5" >
			<input type="text" value="<?php 
    echo $t->id;
    ?>
 public function loadModel()
 {
     if ($this->_model === null) {
         if (isset($_GET['id'])) {
             $this->_model = Attachment::model()->findbyPk($_GET['id']);
         }
         if ($this->_model === null) {
             throw new CHttpException(404, 'The requested page does not exist.');
         }
     }
     return $this->_model;
 }