本文整理汇总了PHP中CFile::load方法的典型用法代码示例。如果您正苦于以下问题:PHP CFile::load方法的具体用法?PHP CFile::load怎么用?PHP CFile::load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFile
的用法示例。
在下文中一共展示了CFile::load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadFile
function loadFile()
{
$this->_ref_file = new CFile();
if ($this->file_id) {
$this->_ref_file->load($this->file_id);
}
}
示例2: loadTimedPictures
function loadTimedPictures($results, $time_min, $time_max)
{
$type_id = $this->value_type_id;
if (!isset($results[$type_id]["none"])) {
return $this->_graph_data = array();
}
$data = $results[$type_id]["none"];
foreach ($data as $_i => $_d) {
$data[$_i]["position"] = $this->getPosition($_d["datetime"], $time_min, $time_max);
if ($_d["file_id"]) {
$file = new CFile();
$file->load($_d["file_id"]);
$data[$_i]["file"] = $file;
}
}
return $this->_graph_data = $data;
}
示例3: delete
public function delete(CAppUI $AppUI = null)
{
global $AppUI;
$perms = $AppUI->acl();
$result = false;
$this->_error = array();
/*
* TODO: This should probably use the canDelete method from above too to
* not only check permissions but to check dependencies... luckily the
* previous version didn't check it either, so we're no worse off.
*/
if ($perms->checkModuleItem('projects', 'delete', $this->project_id)) {
$q = $this->_query;
$q->addTable('tasks');
$q->addQuery('task_id');
$q->addWhere('task_project = ' . (int) $this->project_id);
$tasks_to_delete = $q->loadColumn();
$q->clear();
foreach ($tasks_to_delete as $task_id) {
$q->setDelete('user_tasks');
$q->addWhere('task_id =' . $task_id);
$q->exec();
$q->clear();
$q->setDelete('task_dependencies');
$q->addWhere('dependencies_req_task_id =' . (int) $task_id);
$q->exec();
$q->clear();
}
$q->setDelete('tasks');
$q->addWhere('task_project =' . (int) $this->project_id);
$q->exec();
$q->clear();
$q->addTable('files');
$q->addQuery('file_id');
$q->addWhere('file_project = ' . (int) $this->project_id);
$files_to_delete = $q->loadColumn();
$q->clear();
foreach ($files_to_delete as $file_id) {
$file = new CFile();
$file->load($file_id);
$file->delete($AppUI);
}
$q->setDelete('events');
$q->addWhere('event_project =' . (int) $this->project_id);
$q->exec();
$q->clear();
// remove the project-contacts and project-departments map
$q->setDelete('project_contacts');
$q->addWhere('project_id =' . (int) $this->project_id);
$q->exec();
$q->clear();
$q->setDelete('project_departments');
$q->addWhere('project_id =' . (int) $this->project_id);
$q->exec();
$q->clear();
$q->setDelete('tasks');
$q->addWhere('task_represents_project =' . (int) $this->project_id);
$q->clear();
if ($msg = parent::delete()) {
return $msg;
}
return true;
}
return $result;
}
示例4: CFile
*/
// post values
$dispo = CValue::post("tab_disposition");
$user_id = CValue::post("user_id");
$cat_id = CValue::post("category_id");
$print = CValue::post("print", 0);
// files
$file_array = CValue::post("file");
$data = $file_array[$dispo];
// context
$object_guid = CValue::post("context_guid");
$context = CMbObject::loadFromGuid($object_guid);
// get data uri
foreach ($data as $_key => &$_data) {
$file = new CFile();
$file->load($_data["file_id"]);
$file->getDataURI();
$_data["file_uri"] = $file->_data_uri;
}
//user
$user = CMediusers::get($user_id);
// file
$file = new CFile();
$file->setObject($context);
$file->file_name = CAppUI::tr("CFile-create-mozaic") . " de " . CAppUI::tr($context->_class) . " du " . CMbDT::dateToLocale(CMbDT::date()) . ".pdf";
$file->file_type = "application/pdf";
$file->file_category_id = $cat_id;
$file->author_id = CMediusers::get()->_id;
$file->fillFields();
$file->updateFormFields();
$file->forceDir();
示例5: die
<?php
/* FILES $Id$ */
if (!defined('DP_BASE_DIR')) {
die('You should not access this file directly.');
}
//addfile sql
$file_id = intval(dPgetParam($_POST, 'file_id', 0));
$coReason = dPgetParam($_POST, 'file_co_reason', '');
$obj = new CFile();
if ($file_id) {
$obj->_message = 'updated';
$oldObj = new CFile();
$oldObj->load($file_id);
} else {
$obj->_message = 'added';
}
$obj->file_category = intval(dPgetParam($_POST, 'file_category', 0));
if (!$obj->bind($_POST)) {
$AppUI->setMsg($obj->getError(), UI_MSG_ERROR);
$AppUI->redirect();
}
if (!ini_get('safe_mode')) {
set_time_limit(600);
}
ignore_user_abort(1);
$obj->checkout($AppUI->user_id, $file_id, $coReason);
// We now have to display the required page
// Destroy the post stuff, and allow the page to display index.php again.
$a = 'index';
unset($_GET['a']);
示例6: store
function store($object_id)
{
global $AppUI, $db, $_FILES, $m, $_POST;
$file_uploaded = false;
// instantiate the file object and eventually load exsiting file data
$obj = new CFile();
if ($_POST[$this->field_name . '_id']) {
$obj->load($_POST[$this->field_name . '_id']);
// create an old object for the case that
// the file must be replaced
if ($_POST[$this->field_name . '_id'] > 0) {
$oldObj = new CFile();
$oldObj->load($_POST[$this->field_name . '_id']);
}
}
// if the cf lives in the projects module
// affiliate the file to the suitable project
if ($m == 'projects' && !empty($_POST['project_id'])) {
$obj->file_project = $_POST['project_id'];
}
// todo: implement task affiliation here, too
$upload = null;
if (isset($_FILES[$this->field_name])) {
$upload = $_FILES[$this->field_name];
if ($upload['size'] > 0) {
// store file with a unique name
$obj->file_name = $upload['name'];
$obj->file_type = $upload['type'];
$obj->file_size = $upload['size'];
$obj->file_date = str_replace("'", '', $db->DBTimeStamp(time()));
$obj->file_real_filename = uniqid(rand());
$obj->file_owner = $AppUI->user_id;
$obj->file_version++;
$obj->file_version_id = $obj->file_id;
$res = $obj->moveTemp($upload);
if ($res) {
$file_uploaded = true;
}
if ($msg = $obj->store()) {
$AppUI->setMsg($msg, UI_MSG_ERROR);
} else {
// reset the cf field_name to the file_id
$this->setValue($obj->file_id);
}
}
}
// Delete the existing (old) file in case of file replacement
// (through addedit not through c/o-versions)
if ($_POST[$this->field_name . '_id'] && $upload['size'] > 0 && $file_uploaded) {
$oldObj->deleteFile();
}
if ($upload['size'] > 0 && $file_uploaded) {
return parent::store($object_id);
} else {
if ($upload['size'] > 1 && !$file_uploaded) {
$AppUI->setMsg('File could not be stored!', UI_MSG_ERROR, true);
return true;
}
}
}
示例7: die
die('You should not access this file directly.');
}
$file_id = intval(w2PgetParam($_GET, 'file_id', 0));
// check permissions for this record
$perms =& $AppUI->acl();
$canEdit = $perms->checkModuleItem($m, 'edit', $file_id);
if (!$canEdit) {
$AppUI->redirect('m=public&a=access_denied');
}
$canAdmin = $perms->checkModule('system', 'edit');
$file_parent = intval(w2PgetParam($_GET, 'file_parent', 0));
// check if this record has dependencies to prevent deletion
$msg = '';
$obj = new CFile();
// load the record data
if ($file_id > 0 && !$obj->load($file_id)) {
$AppUI->setMsg('File');
$AppUI->setMsg('invalidID', UI_MSG_ERROR, true);
$AppUI->redirect();
}
// setup the title block
$titleBlock = new CTitleBlock('Checkout', 'folder5.png', $m, "{$m}.{$a}");
$titleBlock->addCrumb('?m=files', 'files list');
$titleBlock->show();
if ($obj->file_project) {
$file_project = $obj->file_project;
}
if ($obj->file_task) {
$file_task = $obj->file_task;
$task_name = $obj->getTaskName();
} elseif ($file_task) {
示例8: testLoad
public function testLoad()
{
$this->obj->bind($this->post_data);
$result = $this->obj->store();
$this->assertTrue($result);
$item = new CFile();
$item->overrideDatabase($this->mockDB);
$this->post_data['file_id'] = $this->obj->file_id;
$this->mockDB->stageHash($this->post_data);
$item->load($this->obj->file_id);
$this->assertEquals($this->obj->file_name, $item->file_name);
$this->assertEquals($this->obj->file_real_filename, $item->file_real_filename);
$this->assertEquals($this->obj->file_parent, $item->file_parent);
$this->assertEquals($this->obj->file_description, $item->file_description);
$this->assertNotEquals($this->obj->file_date, '');
}
示例9: die
<?php
/**
* This file exists exclusively because it allows the Files module to use the
* same url generation that the other modules do. Aka.. it makes our lives
* easier and it's one less thing to have to code around.
*/
if (!defined('W2P_BASE_DIR')) {
die('You should not access this file directly.');
}
$file_id = (int) w2PgetParam($_GET, 'file_id', 0);
$file = new CFile();
if (!$file->load($file_id)) {
$AppUI->redirect(ACCESS_DENIED);
}
header("Location: fileviewer.php?file_id=" . $file_id);
示例10: die
<?php
/* FILES $Id$ */
if (!defined('DP_BASE_DIR')) {
die('You should not access this file directly.');
}
//addfile sql
$file_id = intval(dPgetParam($_POST, 'file_id', 0));
$coReason = dPgetParam($_POST, 'file_co_reason', '');
$co_cancel = intval(dPgetParam($_POST, 'co_cancel', 0));
$not = dPgetParam($_POST, 'notify', '0');
$notcont = dPgetParam($_POST, 'notify_contacts', '0');
$obj = new CFile();
$obj->load($file_id);
//set checkout messages
if ($msg = $obj->checkout($AppUI->user_id, $coReason)) {
$AppUI->setMsg($msg, UI_MSG_ERROR);
} else {
$AppUI->setMsg('File checkout completed', UI_MSG_OK);
//Notification
$obj->_message = $co_cancel ? 'reverted' : 'checked out';
if ($not) {
$obj->notify();
}
if ($notcont) {
$obj->notifyContacts();
}
}
//Checkout Cancellation
if ($co_cancel) {
if ($msg = $obj->checkout('', '')) {
示例11: CFile
<?php
/**
* $Id: $
*
* @package Mediboard
* @subpackage Cabinet
* @author SARL OpenXtrem <dev@openxtrem.com>
* @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html
* @version $Revision: $
*/
CCanDo::checkRead();
$file_id = CValue::get("id");
$name_readonly = CValue::get("name_readonly", 0);
$file = new CFile();
$file->load($file_id);
$file->canDo();
$object_id = CValue::get("object_id");
$object_class = CValue::get("object_class");
$smarty = new CSmartyDP();
$smarty->assign("_file", $file);
$smarty->assign("object_id", $object_id);
$smarty->assign("object_class", $object_class);
$smarty->assign("name_readonly", $name_readonly);
$smarty->display("inc_widget_line_file.tpl");
示例12: intval
require_once $AppUI->getModuleClass('companies');
require_once $AppUI->getModuleClass('projects');
require_once $AppUI->getModuleClass('tasks');
$file_task = intval(dPgetParam($_GET, 'file_task', 0));
$file_parent = intval(dPgetParam($_GET, 'file_parent', 0));
$file_project = intval(dPgetParam($_GET, 'project_id', 0));
$file_helpdesk_item = intval(dPgetParam($_GET, 'file_helpdesk_item', 0));
$q = new DBQuery();
// check if this record has dependencies to prevent deletion
$msg = '';
$obj = new CFile();
$canDelete = $obj->canDelete($msg, $file_id);
// load the record data
// $obj = null;
if ($file_id > 0) {
if (!$obj->load($file_id)) {
$AppUI->setMsg('File');
$AppUI->setMsg('invalidID', UI_MSG_ERROR, true);
$AppUI->redirect();
}
// Check to see if the task or the project is allowed.
if ($obj->file_task && !getPermission('tasks', 'view', $obj->file_task) || $obj->file_project && !getPermission('projects', 'view', $obj->file_project)) {
$AppUI->redirect('m=public&a=access_denied');
}
}
// If the file is checked out, check a few things, like if the user
// is trying to check it in, or if they are trying to overwrite.
if ($obj->file_checkout) {
if (!$ci || $obj->file_checkout != $AppUI->user_id) {
$AppUI->setMsg('File is currently checked out - it must be checked in first');
$AppUI->redirect('m=public&a=access_denied');
示例13: die
<?php
/* fileS $Id$ */
if (!defined('DP_BASE_DIR')) {
die('You should not access this file directly.');
}
global $AppUI;
$selected = dPgetParam($_POST, 'bulk_selected_file', 0);
$redirect = dPgetParam($_POST, 'redirect', '');
$bulk_file_project = dPgetParam($_POST, 'bulk_file_project', 'O');
$bulk_file_folder = dPgetParam($_POST, 'bulk_file_folder', 'O');
if (is_array($selected) && count($selected)) {
$upd_file = new CFile();
foreach ($selected as $key => $val) {
if ($key) {
$upd_file->load($key);
}
if (isset($_POST['bulk_file_project']) && $bulk_file_project != '' && $bulk_file_project != 'O') {
if ($upd_file->file_id) {
// move the file on filesystem if the affiliated project was changed
if ($upd_file->file_project != $bulk_file_project) {
$oldProject = $upd_file->file_project;
$upd_file->file_project = $bulk_file_project;
$res = $upd_file->moveFile($oldProject, $upd_file->file_real_filename);
if (!$res) {
$AppUI->setMsg('At least one File could not be moved', UI_MSG_ERROR);
}
}
$upd_file->store();
}
}
示例14: CFile
/**
* $Id$
*
* @category Drawing
* @package Mediboard
* @author SARL OpenXtrem <dev@openxtrem.com>
* @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html
* @version $Revision$
* @link http://www.mediboard.org
*/
CCanDo::checkEdit();
$draw_id = CValue::get('id');
$context_guid = CValue::get("context_guid");
$draw = new CFile();
$draw->load($draw_id);
$draw->loadRefsNotes();
$draw->loadRefAuthor();
$draw->loadRefsNotes();
$draw->getBinaryContent();
$user = CMediusers::get();
$user->loadRefFunction();
$functions = $user->loadRefsSecondaryFunctions();
$admin = $user->isAdmin();
$files_in_context = array();
$object = null;
if ($context_guid) {
$object = CMbObject::loadFromGuid($context_guid);
if ($object->_id) {
$object->loadRefsFiles();
foreach ($object->_ref_files as $file_id => $_file) {
示例15: addObservationDataToTemplate
/**
* Ajoute les données des graphiques de supervision
*
* @param CTemplateManager $template The template manager
* @param CMbObject $object The host object
* @param string $name The field name
*
* @return void
*/
static function addObservationDataToTemplate(CTemplateManager $template, CMbObject $object, $name)
{
$prefix = "Supervision";
$group_id = CGroups::loadCurrent()->_id;
$results = array();
$times = array();
if ($object->_id) {
list($results, $times) = CObservationResultSet::getResultsFor($object, false);
$times = array_combine($times, $times);
}
// CSupervisionGraphAxis
$axis = new CSupervisionGraphAxis();
$ds = $axis->getDS();
$where = array("supervision_graph_axis.in_doc_template" => "= '1'", "supervision_graph.owner_class" => "= 'CGroups'", "supervision_graph.owner_id" => $ds->prepare("= ?", $group_id));
$ljoin = array("supervision_graph" => "supervision_graph.supervision_graph_id = supervision_graph_axis.supervision_graph_id");
$order = array("supervision_graph.title", "supervision_graph_axis.title");
/** @var CSupervisionGraphAxis[] $axes */
$axes = $axis->loadList($where, $order, null, null, $ljoin);
CStoredObject::massLoadFwdRef($axes, "supervision_graph_id", null, true);
foreach ($axes as $_axis) {
$_graph = $_axis->loadRefGraph();
$_series = $_axis->loadRefsSeries();
$_axis->loadRefsLabels();
$_data = array_fill_keys($times, array());
foreach ($_series as $_serie) {
$_unit_id = $_serie->value_unit_id ?: "none";
$_unit_label = $_serie->loadRefValueUnit();
if (!isset($results[$_serie->value_type_id][$_unit_id])) {
continue;
}
foreach ($results[$_serie->value_type_id][$_unit_id] as $_value) {
foreach ($times as $_time) {
if ($_value["datetime"] != $_time) {
continue;
}
$_value["unit"] = $_unit_label->label;
$_data["{$_time}"][$_serie->_id] = $_value;
break;
}
}
}
$view = "";
if (count($_data)) {
$smarty = new CSmartyDP("modules/dPsalleOp");
$smarty->assign("data", $_data);
$smarty->assign("series", $_series);
$smarty->assign("times", $times);
$view = $smarty->fetch("inc_print_observation_result_set.tpl", '', '', 0);
$view = preg_replace('`([\\n\\r])`', '', $view);
}
$template->addProperty("{$name} - {$prefix} - {$_graph->title} - {$_axis->title}", trim($view), "", false);
}
// CSupervisionTimedPicture
// CSupervisionTimedData
$data = array("CSupervisionTimedPicture", "CSupervisionTimedData");
foreach ($data as $_class) {
/** @var CSupervisionTimedPicture|CSupervisionTimedData $_object */
$_object = new $_class();
$_table = $_object->_spec->table;
$_ds = $_object->getDS();
$where = array("{$_table}.in_doc_template" => "= '1'", "{$_table}.owner_class" => "= 'CGroups'", "{$_table}.owner_id" => $_ds->prepare("= ?", $group_id));
$order = "title";
/** @var CSupervisionTimedPicture[]|CSupervisionTimedData[] $_objects */
$_objects = $_object->loadList($where, $order);
foreach ($_objects as $_timed) {
$_data = array_fill_keys($times, null);
if (!isset($results[$_timed->value_type_id])) {
continue;
}
foreach ($results[$_timed->value_type_id]["none"] as $_value) {
foreach ($times as $_time) {
if ($_value["datetime"] != $_time) {
continue;
}
if ($_value["file_id"]) {
$_file = new CFile();
$_file->load($_value["file_id"]);
$_value["datauri"] = $_file->getDataURI();
$_value["file"] = $_file;
}
$_data["{$_time}"] = $_value;
break;
}
}
$view = "";
if (count($_data)) {
$smarty = new CSmartyDP("modules/dPsalleOp");
$smarty->assign("data", $_data);
$smarty->assign("times", $times);
$smarty->assign("timed_data", true);
$view = $smarty->fetch("inc_print_observation_result_set.tpl", '', '', 0);
//.........这里部分代码省略.........