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


PHP stored_file::get_userid方法代码示例

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


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

示例1: replace_file_with

 /**
  * Replaces the fields that might have changed when file was overriden in filepicker:
  * reference, contenthash, filesize, userid
  *
  * Note that field 'source' must be updated separately because
  * it has different format for draft and non-draft areas and
  * this function will usually be used to replace non-draft area
  * file with draft area file.
  *
  * @param stored_file $newfile
  * @throws coding_exception
  */
 public function replace_file_with(stored_file $newfile)
 {
     if ($newfile->get_referencefileid() && $this->fs->get_references_count_by_storedfile($this)) {
         // The new file is a reference.
         // The current file has other local files referencing to it.
         // Double reference is not allowed.
         throw new moodle_exception('errordoublereference', 'repository');
     }
     $filerecord = new stdClass();
     $contenthash = $newfile->get_contenthash();
     if ($this->fs->content_exists($contenthash)) {
         $filerecord->contenthash = $contenthash;
     } else {
         throw new file_exception('storedfileproblem', 'Invalid contenthash, content must be already in filepool', $contenthash);
     }
     $filerecord->filesize = $newfile->get_filesize();
     $filerecord->referencefileid = $newfile->get_referencefileid();
     $filerecord->userid = $newfile->get_userid();
     $this->update($filerecord);
 }
开发者ID:qanuj,项目名称:moodle,代码行数:32,代码来源:stored_file.php

示例2: send_file

 /**
  * Repository method to serve the referenced file
  *
  * @see send_stored_file
  *
  * @param stored_file $storedfile the file that contains the reference
  * @param int $lifetime Number of seconds before the file should expire from caches (null means $CFG->filelifetime)
  * @param int $filter 0 (default)=no filtering, 1=all files, 2=html files only
  * @param bool $forcedownload If true (default false), forces download of file rather than view in browser/plugin
  * @param array $options additional options affecting the file serving
  */
 public function send_file($storedfile, $lifetime = null, $filter = 0, $forcedownload = false, array $options = null)
 {
     global $USER;
     $caller = '\\repository_office365::send_file';
     $reference = $this->unpack_reference($storedfile->get_reference());
     $fileuserid = $storedfile->get_userid();
     $sourceclient = $this->get_onedrive_apiclient(false, $fileuserid);
     if (empty($sourceclient)) {
         \local_o365\utils::debug('Could not construct api client for user', 'send_file', $fileuserid);
         send_file_not_found();
         die;
     }
     $fileinfo = $sourceclient->get_file_metadata($reference['id']);
     // Do embedding if relevant.
     $doembed = $this->do_embedding($reference, $forcedownload);
     if ($doembed === true) {
         if (\local_o365\utils::is_o365_connected($USER->id) !== true) {
             // Embedding currently only supported for logged-in Office 365 users.
             echo get_string('erroro365required', 'repository_office365');
             die;
         }
         if (!empty($sourceclient)) {
             if (isset($fileinfo['webUrl'])) {
                 $fileurl = $fileinfo['webUrl'];
             } else {
                 $fileurl = isset($reference['url']) ? $reference['url'] : '';
             }
             if (empty($fileurl)) {
                 $errstr = 'Embed was requested, but could not get file info to complete request.';
                 \local_o365\utils::debug($errstr, 'send_file', ['reference' => $reference, 'fileinfo' => $fileinfo]);
             } else {
                 try {
                     $embedurl = $sourceclient->get_embed_url($reference['id'], $fileurl);
                     $embedurl = isset($embedurl['value']) ? $embedurl['value'] : '';
                 } catch (\Exception $e) {
                     // Note: exceptions will already be logged in get_embed_url.
                     $embedurl = '';
                 }
                 if (!empty($embedurl)) {
                     redirect($embedurl);
                 } else {
                     if (!empty($fileurl)) {
                         redirect($fileurl);
                     } else {
                         $errstr = 'Embed was requested, but could not complete.';
                         \local_o365\utils::debug($errstr, 'send_file', $reference);
                     }
                 }
             }
         } else {
             \local_o365\utils::debug('Could not construct OneDrive client for system api user.', 'send_file');
         }
     }
     redirect($fileinfo['webUrl']);
 }
开发者ID:eugeneventer,项目名称:o365-moodle,代码行数:66,代码来源:lib.php

示例3: get_references_count_by_storedfile

 /**
  * Return the count files referring to provided stored_file instance
  * This won't work for draft files
  *
  * @param stored_file $storedfile
  * @return int
  */
 public function get_references_count_by_storedfile($storedfile)
 {
     global $DB;
     $params = array();
     $params['contextid'] = $storedfile->get_contextid();
     $params['component'] = $storedfile->get_component();
     $params['filearea'] = $storedfile->get_filearea();
     $params['itemid'] = $storedfile->get_itemid();
     $params['filename'] = $storedfile->get_filename();
     $params['filepath'] = $storedfile->get_filepath();
     $params['userid'] = $storedfile->get_userid();
     $reference = self::pack_reference($params);
     $sql = "SELECT COUNT(f.id)\n                  FROM {files} f\n             LEFT JOIN {files_reference} r\n                       ON f.referencefileid = r.id\n                 WHERE " . $DB->sql_compare_text('r.reference') . ' = ' . $DB->sql_compare_text('?') . "\n                 AND (f.component <> ? OR f.filearea <> ?)";
     $count = $DB->count_records_sql($sql, array($reference, 'user', 'draft'));
     return $count;
 }
开发者ID:nicusX,项目名称:moodle,代码行数:23,代码来源:file_storage.php

示例4: emarking_create_anonymous_page_from_storedfile

function emarking_create_anonymous_page_from_storedfile(stored_file $file)
{
    if (!$file) {
        throw new Exception('Stored file does not exist');
    }
    // Get file storage and copy file to temp folder.
    $fs = get_file_storage();
    $tmppath = $file->copy_content_to_temp('emarking', 'anonymous');
    // Treat the file as an image, get its size and draw a white rectangle.
    $size = getimagesize($tmppath);
    $image = imagecreatefrompng($tmppath);
    $white = imagecolorallocate($image, 255, 255, 255);
    $y2 = round($size[1] / 10, 0);
    imagefilledrectangle($image, 0, 0, $size[0], $y2, $white);
    // Save the new image to replace the file.
    if (!imagepng($image, $tmppath)) {
        return false;
    }
    clearstatcache();
    $filenameanonymous = emarking_get_anonymous_filename($file->get_filename());
    // Copy file from temp folder to Moodle's filesystem.
    $filerecordanonymous = array('contextid' => $file->get_contextid(), 'component' => 'mod_emarking', 'filearea' => 'pages', 'itemid' => $file->get_itemid(), 'filepath' => '/', 'filename' => $filenameanonymous, 'timecreated' => $file->get_timecreated(), 'timemodified' => time(), 'userid' => $file->get_userid(), 'author' => $file->get_author(), 'license' => 'allrightsreserved');
    $previousfile = $fs->get_file($file->get_contextid(), 'mod_emarking', 'pages', $file->get_itemid(), '/', $filenameanonymous);
    if ($previousfile) {
        $previousfile->delete();
    }
    $fileinfo = $fs->create_file_from_pathname($filerecordanonymous, $tmppath);
    return $fileinfo;
}
开发者ID:sikeze,项目名称:emarking,代码行数:29,代码来源:locallib.php


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