当前位置: 首页>>代码示例>>PHP>>正文


PHP CFile::selectFilesBySrc方法代码示例

本文整理汇总了PHP中CFile::selectFilesBySrc方法的典型用法代码示例。如果您正苦于以下问题:PHP CFile::selectFilesBySrc方法的具体用法?PHP CFile::selectFilesBySrc怎么用?PHP CFile::selectFilesBySrc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CFile的用法示例。


在下文中一共展示了CFile::selectFilesBySrc方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: deleteFiles

function deleteFiles($order_id, $types)
{
    $types = !is_array($types) ? array($types) : $types;
    $rows = CFile::selectFilesBySrc('file_reserves_order', $order_id);
    if (!$rows) {
        return 0;
    }
    foreach ($rows as $row) {
        if (!in_array($row['doc_type'], $types)) {
            continue;
        }
        $file = new CFile();
        $file->Delete($row['id']);
    }
}
开发者ID:Nikitian,项目名称:fl-ru-damp,代码行数:15,代码来源:docs_update.php

示例2: deleteFiles

 /**
  * Удаление файлов указанных типов
  * @todo Удалять из очереди тоже нужно наверно
  * 
  * @param type $srcId
  * @param type $types
  * @return boolean
  */
 public function deleteFiles($srcId, $types)
 {
     $types = !is_array($types) ? array($types) : $types;
     $this->clearQueue($srcId, $types);
     $rows = CFile::selectFilesBySrc($this->file_table, $srcId);
     if (!$rows) {
         return false;
     }
     foreach ($rows as $row) {
         if (!in_array($row['doc_type'], $types)) {
             continue;
         }
         $file = new CFile();
         $file->Delete($row['id']);
     }
     return true;
 }
开发者ID:Nikitian,项目名称:fl-ru-damp,代码行数:25,代码来源:DocGenReserves.php

示例3: getAttached

 /**
  * Получить список файлов сообщения.
  *  
  * @param type $msg_id
  *
  * @return type
  */
 public function getAttached($msg_id)
 {
     return CFile::selectFilesBySrc($this->TABLE_FILES, $msg_id, 'id');
     //return $this->db()->rows("SELECT * FROM {$this->TABLE_FILES} WHERE src_id = ?i", $msg_id);
 }
开发者ID:kapai69,项目名称:fl-ru-damp,代码行数:12,代码来源:TServiceMsgModel.php

示例4: _getCommunityAttachPoll

 /**
  * Вспомогательная функция для получения аттачей и опросов для сообществ
  * 
  * @param type $aReturn 
  */
 function _getCommunityAttachPoll(&$aReturn = array())
 {
     // ответы на опросы -----
     $ids = '';
     $lnk = array();
     for ($i = 0, $c = count($aReturn); $i < $c; $i++) {
         if (!$aReturn[$i]['parent_id']) {
             $ids .= ",{$aReturn[$i]['theme_id']}";
             $lnk[$aReturn[$i]['theme_id']] =& $aReturn[$i];
         }
     }
     if ($ids) {
         $res = $GLOBALS['DB']->rows("SELECT * FROM commune_poll_answers WHERE theme_id IN (" . substr($ids, 1) . ") ORDER BY id");
         if ($res) {
             foreach ($res as $row) {
                 $lnk[$row['theme_id']]['answers'][] = $row;
             }
         }
     }
     //-----------------------
     // аттачи ---------------
     $id_attach = $x = array();
     foreach ($aReturn as $k => $v) {
         $x[$v['id']] = $v;
         if ($v['file_exists']) {
             $id_attach[$v['id']] = $v['id'];
         }
     }
     if ($id_attach) {
         //$ret = $GLOBALS['DB']->rows("SELECT file.*, commune_attach.cid, commune_attach.small FROM commune_attach JOIN file_commune as file ON file.id = commune_attach.fid WHERE commune_attach.cid IN (".implode(", ", $id_attach).")");
         $ret = CFile::selectFilesBySrc(commune::FILE_TABLE, $id_attach);
         if ($ret) {
             foreach ($ret as $k => $val) {
                 $x[$val['src_id']]['attach'][] = $val;
             }
             foreach ($x as $k => $val) {
                 $r[] = $val;
             }
             $aReturn = $r;
         }
     }
     //-----------------------
 }
开发者ID:Nikitian,项目名称:fl-ru-damp,代码行数:48,代码来源:user_content.php

示例5: getByID

 /**
  * Получаем услугу, принадлежащую текущему пользователю, по ID и
  * заполняем свойства обьекта.
  * 
  * @param type $id
  *
  * @return bool
  */
 public function getByID($id)
 {
     $row = $this->db()->row("\n            SELECT \n                s.*,\n                COALESCE((sc.sbr_minus + sc.order_minus),0) AS minus_feedbacks\n            FROM {$this->TABLE} AS s \n            LEFT JOIN {$this->TABLE_COUNTERS} AS sc ON sc.service_id = s.id\n            WHERE \n                s.deleted = FALSE \n                AND s.user_id = ?i \n                AND s.id = ?i", $this->uid, $id);
     if ($this->arrayToFieldsProps($row)) {
         $tservices_tags = new tservices_tags();
         $this->tags = $tservices_tags->getsByTServiceId($id);
         $this->images = CFile::selectFilesBySrc($this->TABLE_FILES, $id, 'id', 'small = 1 AND preview=\'f\'');
         $this->preview = CFile::selectFilesBySrc($this->TABLE_FILES, $id, 'id', 'small = 1 AND preview=\'t\'');
         $this->is_angry = $row['minus_feedbacks'] > 0;
         return true;
     }
     return false;
 }
开发者ID:kapai69,项目名称:fl-ru-damp,代码行数:21,代码来源:tservices.php

示例6: addAttachedFiles

 /**
  * Связывает файлы загруженные ассинхронно с сообщением
  *
  * @param   array     $files              Список загруженных файлов
  * @param   string    $login              Логин пользователя
  * @param   integer   $msg_id             ID сообщения
  * @param   boolean   $from_draft         Файлы из черновика
  */
 function addAttachedFiles($files, $msg_id, $login = NULL, $from_draft = false)
 {
     global $DB;
     if (!$login) {
         $login = $_SESSION['login'];
     }
     $bModeration = false;
     $old_files = $this->getAttachedFiles($msg_id);
     if ($from_draft) {
         $notdeleted_files = array();
         if ($files) {
             foreach ($files as $f) {
                 if ($f['status'] == 3 || in_array($f['id'], $old_files)) {
                     array_push($notdeleted_files, $f['id']);
                 }
             }
         }
         $attaches = CFile::selectFilesBySrc(self::FILE_TABLE, $msg_id);
         if ($attaches) {
             foreach ($attaches as $attach) {
                 if (in_array($attach['id'], $notdeleted_files)) {
                     continue;
                 }
                 $cFile = new CFile($attach['id']);
                 $cFile->table = self::FILE_TABLE;
                 if ($cFile->id) {
                     $cFile->Delete($cFile->id);
                 }
             }
         }
     }
     $max_image_size = array('width' => blogs::MAX_IMAGE_WIDTH, 'height' => blogs::MAX_IMAGE_HEIGHT, 'less' => 0);
     if ($files) {
         foreach ($files as $file) {
             switch ($file['status']) {
                 case 4:
                     // Удаляем файл
                     $cFile = new CFile($file['id']);
                     $cFile->table = self::FILE_TABLE;
                     if ($cFile->id) {
                         $cFile->Delete($cFile->id);
                     }
                     break;
                 case 1:
                     if (in_array($file['id'], $old_files)) {
                         $need_copy = false;
                     } else {
                         $bModeration = true;
                         $need_copy = true;
                     }
                     // Добавляем файл
                     $cFile = new CFile($file['id']);
                     $cFile->proportional = 1;
                     $cFile->table = self::FILE_TABLE;
                     $ext = $cFile->getext();
                     if ($need_copy) {
                         $tmp_dir = "users/" . substr($login, 0, 2) . "/" . $login . "/upload/";
                         $tmp_name = $cFile->secure_tmpname($tmp_dir, '.' . $ext);
                         $tmp_name = substr_replace($tmp_name, "", 0, strlen($tmp_dir));
                         $cFile->_remoteCopy($tmp_dir . $tmp_name, true);
                     }
                     if (in_array($ext, $GLOBALS['graf_array'])) {
                         $is_image = TRUE;
                     } else {
                         $is_image = FALSE;
                     }
                     if ($is_image && $ext != 'swf' && $ext != 'flv') {
                         if ($cFile->image_size['width'] > $max_image_size['width'] || $cFile->image_size['height'] > $max_image_size['height']) {
                             if ($need_copy) {
                                 if ($cFile->resizeImage($cFile->path . 'sm_' . $cFile->name, $max_image_size['width'], $cFile->image_size['height'], 'landscape')) {
                                     $cFile->small = 2;
                                 }
                             } else {
                                 $cFile->small = 2;
                             }
                         } else {
                             $cFile->small = 1;
                         }
                     } else {
                         $cFile->small = $ext == 'flv' ? 2 : 0;
                     }
                     $cFile->updateFileParams(array('src_id' => $msg_id, 'small' => $cFile->small), false);
                     break;
             }
         }
     }
     if ($bModeration && $login == $_SESSION['login'] && !hasPermissions('blogs')) {
         // отравляем сообщение на модерирование сразу по факту создания или редактирования
         // появились новые файлы и это правит автор, и он не админ и не ПРО - отправить на модерирование
         /*require_once( $_SERVER['DOCUMENT_ROOT'] . '/classes/user_content.php' );
           $DB->query( 'UPDATE blogs_msgs SET moderator_status = 0 WHERE id = ?i', $msg_id );
           $DB->insert( 'moderation', array('rec_id' => $msg_id, 'rec_type' => user_content::MODER_BLOGS) );*/
//.........这里部分代码省略.........
开发者ID:amage,项目名称:fl-ru-damp,代码行数:101,代码来源:blogs.php

示例7: generateArchive

 /**
  * Создание архива документов 
  * по последней задаче
  * 
  * Рекомендуется запускать 
  * в кроне с интервалом 1-2 минуты
  * 
  * @return boolean
  * @throws Exception
  */
 public function generateArchive()
 {
     //Получаем последнюю задачу на создания архива
     $last = $this->db()->row("\n            SELECT \n                rda.*,\n                u.email\n            FROM " . self::$_TABLE_ARCHIVE . " AS rda\n            LEFT JOIN users AS u ON u.uid = rda.uid\n            WHERE \n                rda.status IN(0,-1) \n                AND rda.try_count < ?i\n            ORDER BY rda.id DESC, rda.status DESC\n            LIMIT 1\n        ", self::TRY_COUNT);
     if (!$last) {
         return false;
     }
     $archObj = new ReservesArchiveItemModel($last);
     //Ставим статус в работе
     $this->updateArchive($archObj->id, array('status' => self::STATUS_INPROGRESS));
     try {
         //Получаем файлы документов
         require_once ABS_PATH . '/classes/reserves/ReservesTServiceOrderModel.php';
         $bs_ids = $archObj->getFields();
         $files = CFile::selectFilesBySrc(ReservesTServiceOrderModel::$_TABLE_RESERVES_FILES, $bs_ids, NULL, $this->db()->parse('doc_type IN(?l)', $this->doc_req));
         if (!$files) {
             throw new Exception('Нет файлов документов');
         }
         $_archive_dir = uniqid();
         $_archive_path = self::TMP_PATH . $_archive_dir . DIRECTORY_SEPARATOR;
         $_dav_temp_path = self::DAV_TMP_PATH . $_archive_dir . DIRECTORY_SEPARATOR;
         $filelist = array();
         $cfile = new CFile();
         if (!$cfile->MakeDir(trim($_dav_temp_path, '/'))) {
             throw new Exception('Не удалось создать временную директорию в хранилище');
         }
         //Формируем массив файлов для архива
         foreach ($files as $file) {
             $cfile->name = $file['fname'];
             $cfile->path = $file['path'];
             $info = new SplFileInfo($file['fname']);
             $_ext = $info->getExtension();
             $name = $info->getBasename(".{$_ext}");
             //Создаем временную директорию для файлов на локальной файловой системе
             $_local_tmp_path = "{$_archive_path}{$file['src_id']}/";
             if (!file_exists($_local_tmp_path)) {
                 if (!mkdir($_local_tmp_path, 0777, true)) {
                     throw new Exception("Нет прав на создание: {$_local_tmp_path}");
                 }
             }
             //Сколько копий документа сделать в зависимости от его типа
             $doc_cnt = isset($this->doc_type_cnt[$file['doc_type']]) && $this->doc_type_cnt[$file['doc_type']] > 1 ? $this->doc_type_cnt[$file['doc_type']] : 1;
             $_prefix = sprintf('%07d-', $file['src_id']);
             while ($doc_cnt > 0) {
                 $_suffix = $doc_cnt > 1 ? "-{$doc_cnt}" : '';
                 $_dav_tmp_filename = "{$_dav_temp_path}{$name}{$_suffix}.{$_ext}";
                 if (!$cfile->copyFileTo($_dav_tmp_filename)) {
                     throw new Exception("Не удалось скопировать: {$_dav_tmp_filename}");
                 }
                 $_tmp_name = empty($file['original_name']) ? $name : $file['original_name'];
                 $_local_tmp_filename = "{$_local_tmp_path}{$_prefix}{$_tmp_name}{$_suffix}.{$_ext}";
                 //Кодировка имен файлов для Windows
                 $_local_tmp_filename = iconv('WINDOWS-1251', 'CP866', $_local_tmp_filename);
                 //$_local_tmp_filename = iconv('WINDOWS-1251', 'UTF-8', $_local_tmp_filename);
                 $filelist[$_dav_tmp_filename] = $_local_tmp_filename;
                 //Перемещаем нужные документы из хранища во временную папку
                 if (!$cfile->copyToLocalPathFromDav($_dav_tmp_filename, $_local_tmp_filename)) {
                     throw new Exception("Не удалось переместить файл из хранища {$_dav_tmp_filename} \n                                             в локальную файловую систему {$_local_tmp_filename}");
                 }
                 $doc_cnt--;
             }
         }
         if (empty($filelist)) {
             throw new Exception("Не удалось сформировать массив документов");
         }
         /*
          * @todo: пока используем CFile::copyToLocalPathFromDav
          *             
         //Перемещаем нужные документы из хранища во временную папку
         $cfile = new CFile();
         $res = $cfile->copyFilesToLocalPath($filelist);
         
         if (!$res) {
             throw new Exception("Не удалось переместить файлы из хранища");
         }
         */
         //Создаем архив документов
         $_zip_filename = self::TMP_PATH . "{$_archive_dir}.zip";
         $zip = new ZipArchive();
         if ($zip->open($_zip_filename, ZipArchive::CREATE)) {
             foreach ($filelist as $filename) {
                 $localname = basename($filename);
                 $zip->addFile($filename, $localname);
             }
             $zip->close();
         }
         if (!file_exists($_zip_filename)) {
             throw new Exception("Не удалось создать архив.");
         }
         //Загружаем архив документов
//.........这里部分代码省略.........
开发者ID:Nikitian,项目名称:fl-ru-damp,代码行数:101,代码来源:ReservesArchiveModel.php

示例8: DeleteAttach

 /**
  * Удалить файл, прикрепленный к комментарию
  * 
  * @param  int $cid ID комментария
  * @param  int $id_attach ID файла
  * @param  bool $mark_only опционально. установить в true если нужно только пометить файл как удаленный
  * @return bool true - успех, false - провал
  */
 public static function DeleteAttach($cid, $id_attach, $mark_only = false)
 {
     global $DB;
     //$sql = "SELECT file.*, commune_attach.cid, commune_attach.small, commune_attach.id AS att_id, commune_attach.sort AS att_sort FROM commune_attach JOIN file_commune as file ON file.id = commune_attach.fid WHERE commune_attach.cid = ?i AND commune_attach.fid = ?i";
     //$ret = $DB->row($sql, $cid, $id_attach);
     $ret = CFile::selectFilesBySrc(self::FILE_TABLE, $cid, 'sort', "id = {$id_attach}");
     $login = $_SESSION['login'];
     $dir = "users/" . substr($login, 0, 2) . "/" . $login . "/upload/";
     $file = $ret['fname'];
     $file = str_replace('sm_', '', $file);
     $cfile = new CFile($ret['id']);
     if ($file && $login) {
         if ($mark_only) {
             // только пометить на удаление
             $cfile->updateFileParams(array('deleted' => true), false);
             //$sql = "UPDATE commune_attach SET is_deleted = true WHERE id = {$ret['att_id']}";
             //$DB->squery($sql);
         } else {
             $cfile->Delete(0, $dir, $file);
             $cfile->Delete(0, $dir, 'sm_' . $file);
             //              $sql = "DELETE FROM commune_attach WHERE id = {$ret['att_id']}";
             //              $DB->squery($sql);
         }
         $sql = "UPDATE " . self::FILE_TABLE . " SET sort = sort-1 WHERE sort > {$ret['sort']} AND src_id = {$cid}";
         $DB->squery($sql);
         $sql = "SELECT max(sort) FROM " . self::FILE_TABLE . " WHERE id <> {$ret['id']} AND src_id = {$cid}";
         $max_sort = $DB->val($sql) + 1;
         $sql = "UPDATE " . self::FILE_TABLE . " SET sort = {$max_sort} WHERE id = {$ret['id']} AND src_id = {$cid}";
         $DB->squery($sql);
         return true;
     }
     return false;
 }
开发者ID:Nikitian,项目名称:fl-ru-damp,代码行数:41,代码来源:commune.php

示例9: getData

 /**
  * Получение данных сообщений, либо одного сообщения по ID
  * 
  * @param integer $message_id 
  * @return array
  */
 public function getData($message_id = NULL)
 {
     $model = $this->model();
     $resource_id = $this->_resource_id;
     if (isset($model['resource_id'])) {
         $resource_id = $model['resource_id'];
     }
     $fields = array();
     $sql_fields = array();
     foreach ($model as $tid => $table) {
         if ($tid == 'attaches' || !is_array($table['fields'])) {
             continue;
         }
         if ($tid == 'users' && !get_uid(false)) {
             continue;
         }
         $fields[$table['table']] = array();
         foreach ($table['fields'] as $k => $v) {
             if (!$v) {
                 continue;
             }
             $fields[$tid][$k] = str_replace("ONLY ", "", $table['table']) . "." . $v;
             if (isset($model[$tid]['expr'][$k])) {
                 $sql_fields[] = $model[$tid]['expr'][$k] . " AS {$k}";
             } else {
                 $sql_fields[] = str_replace("ONLY ", "", $table['table']) . "." . $v . " AS {$k}";
             }
         }
     }
     $sql_fields_author = array('u_auth.uid AS author_uid', 'u_auth.login AS author_login', 'u_auth.uname AS author_uname', 'u_auth.usurname AS author_usurname', 'u_auth.photo AS author_photo', 'u_auth.is_banned AS author_is_banned', 'u_auth.is_pro AS author_is_pro', 'u_auth.is_profi AS author_is_profi', 'u_auth.is_verify AS author_is_verify', 'u_auth.is_team AS author_is_team', 'u_auth.is_pro_test AS author_is_pro_test', 'u_auth.role AS author_role', 'u_auth.warn AS warn', 'u_auth.reg_date AS author_reg_date');
     $sql_fields_mod = array('u_mod.uid AS mod_uid', 'u_mod.login AS mod_login', 'u_mod.uname AS mod_uname', 'u_mod.usurname AS mod_usurname', 'u_mod.role AS mod_role', 'u_mod2.uid AS mod_uid_del', 'u_mod2.login AS mod_login_del', 'u_mod2.uname AS mod_uname_del', 'u_mod2.usurname AS mod_usurname_del', 'u_mod2.role AS mod_role_del');
     $sql_fields_inner = array();
     if (!empty($model['users']['inner_fields'])) {
         foreach ($model['users']['inner_fields'] as $name_field => $as_name) {
             $sql_fields_inner[] = "{$name_field} as {$as_name}";
         }
     }
     $sql_fields = implode(", ", array_merge($sql_fields, $sql_fields_author, $sql_fields_mod, $sql_fields_inner));
     if ($model['comments']['set']) {
         $sql[] = $model['comments']['set'] . ';';
     }
     $sql[] = "SELECT {$sql_fields} FROM " . $model['comments']['table'];
     if (isset($model['users']) && get_uid(false)) {
         $sql[] = "LEFT JOIN " . $model['users']['table'] . " ON " . $fields['comments']['id'] . " = " . $fields['users']['comment'] . " AND " . $fields['users']['user'] . " = " . get_uid(false);
     }
     // Данные автора комментария
     $sql[] = "LEFT JOIN users as u_auth ON u_auth.uid = " . $fields['comments']['author'];
     // Данные модератора или админа, редактировавшего коммент
     $sql[] = "LEFT JOIN users as u_mod ON u_mod.uid = " . $fields['comments']['modified'];
     // Данные модератора или админа, удалившего коммент
     $sql[] = "LEFT JOIN users as u_mod2 ON u_mod2.uid = " . $fields['comments']['deleted'];
     if (!empty($model['users']['inner'])) {
         $sql[] = implode(" \n ", $model['users']['inner']);
     }
     $sql[] = "WHERE " . $fields['comments'][!$message_id ? 'resource' : 'id'] . " = ? ";
     if (isset($model['comments']['where'])) {
         $sql[] = "AND " . implode(" AND ", $model['comments']['where']);
     }
     $sql[] = "ORDER BY " . $fields['comments']['created_time'];
     $sql = implode(" \n ", $sql);
     $DB = new DB('master');
     $res = $DB->rows($sql, !$message_id ? $resource_id : $message_id);
     $this->msg_num = count($res);
     $comment_ids = array();
     $comment_arr = array();
     if ($this->msg_num) {
         foreach ($res as $row) {
             $comment_ids[] = $row['id'];
             $comments_arr[$row['id']] = $row;
         }
     }
     // Выбираем файлы
     if (count($comment_ids) && isset($model['attaches'])) {
         $tbl = $model['attaches']['table'];
         $fl_tbl = $model['attaches']['file_table'];
         if ($tbl == $fl_tbl) {
             if ($model['attaches']['fields']['inline']) {
                 $where = " {$tbl}." . $model['attaches']['fields']['inline'] . " = FALSE";
             }
             $res = CFile::selectFilesBySrc($tbl, $comment_ids, 'id', $where);
         } else {
             $exclude_inline = '';
             if ($model['attaches']['fields']['inline']) {
                 $exclude_inline = " AND {$tbl}." . $model['attaches']['fields']['inline'] . " = FALSE";
             }
             $sql = array();
             $sql[] = "SELECT * FROM " . $tbl;
             $sql[] = "INNER JOIN {$fl_tbl} file ON file.id = {$tbl}." . $model['attaches']['fields']['file'];
             $sql[] = "WHERE {$tbl}." . $model['attaches']['fields']['comment'] . " IN (" . implode(', ', $comment_ids) . "){$exclude_inline}";
             $sql = implode(" \n ", $sql);
             $res = $DB->rows($sql);
         }
         foreach ($res as $file) {
             $comments_arr[$file[$model['attaches']['fields']['comment']]]['attach'][] = $file;
//.........这里部分代码省略.........
开发者ID:Nikitian,项目名称:fl-ru-damp,代码行数:101,代码来源:Comments.php


注:本文中的CFile::selectFilesBySrc方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。