本文整理汇总了PHP中ArtefactTypeFileBase::file_exists方法的典型用法代码示例。如果您正苦于以下问题:PHP ArtefactTypeFileBase::file_exists方法的具体用法?PHP ArtefactTypeFileBase::file_exists怎么用?PHP ArtefactTypeFileBase::file_exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArtefactTypeFileBase
的用法示例。
在下文中一共展示了ArtefactTypeFileBase::file_exists方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pieform_element_filebrowser_update
function pieform_element_filebrowser_update(Pieform $form, $element, $data)
{
global $USER;
$collide = !empty($data['collide']) ? $data['collide'] : 'fail';
try {
$artefact = artefact_instance_from_id($data['artefact']);
} catch (ArtefactNotFoundException $e) {
$parentfolder = $element['folder'] ? $element['folder'] : null;
$result = array('error' => true, 'message' => get_string('editingfailed', 'artefact.file'), 'newlist' => pieform_element_filebrowser_build_filelist($form, $element, $parentfolder));
return $result;
}
if (!$USER->can_edit_artefact($artefact) || $artefact->get('locked')) {
return array('error' => true, 'message' => get_string('noeditpermission', 'mahara'));
}
if ($existingid = ArtefactTypeFileBase::file_exists($data['title'], $artefact->get('owner'), $data['folder'], $artefact->get('institution'), $artefact->get('group'))) {
if ($existingid != $data['artefact']) {
if ($collide == 'replace') {
log_debug('deleting ' . $existingid);
$copy = artefact_instance_from_id($existingid);
$copy->delete();
} else {
return array('error' => true, 'message' => get_string('fileexists', 'artefact.file'));
}
}
}
$artefact->set('title', $data['title']);
$artefact->set('description', $data['description']);
$oldtags = $artefact->get('tags');
$newtags = preg_split("/\\s*,\\s*/", trim($data['tags']));
$updatetags = $oldtags != $newtags;
if ($updatetags) {
$artefact->set('tags', $newtags);
}
if ($form->get_property('group') && $data['permissions']) {
$artefact->set('rolepermissions', $data['permissions']);
}
$artefact->commit();
$returndata = array('error' => false, 'message' => get_string('changessaved', 'artefact.file'), 'newlist' => pieform_element_filebrowser_build_filelist($form, $element, $artefact->get('parent')));
if ($updatetags && $form->submitted_by_js()) {
$smarty = smarty_core();
$tagdata = tags_sideblock();
$smarty->assign('sbdata', $tagdata);
$returndata['tagblockhtml'] = $smarty->fetch('sideblocks/tags.tpl');
}
return $returndata;
}
示例2: pieform_element_filebrowser_update
function pieform_element_filebrowser_update(Pieform $form, $element, $data)
{
global $USER;
$collide = !empty($data['collide']) ? $data['collide'] : 'fail';
try {
$artefact = artefact_instance_from_id($data['artefact']);
} catch (ArtefactNotFoundException $e) {
$parentfolder = $element['folder'] ? $element['folder'] : null;
$result = array('error' => true, 'message' => get_string('editingfailed', 'artefact.file'), 'newlist' => pieform_element_filebrowser_build_filelist($form, $element, $parentfolder));
return $result;
}
if (!$USER->can_edit_artefact($artefact) || $artefact->get('locked')) {
return array('error' => true, 'message' => get_string('noeditpermission', 'mahara'));
}
if ($existingid = ArtefactTypeFileBase::file_exists($data['title'], $artefact->get('owner'), $data['folder'], $artefact->get('institution'), $artefact->get('group'))) {
if ($existingid != $data['artefact']) {
if ($collide == 'replace') {
log_debug('deleting ' . $existingid);
$copy = artefact_instance_from_id($existingid);
$copy->delete();
} else {
return array('error' => true, 'message' => get_string('fileexists', 'artefact.file'));
}
}
}
$artefact->set('title', trim($data['title']));
$artefact->set('description', $data['description']);
$artefact->set('allowcomments', (int) $data['allowcomments']);
$oldtags = $artefact->get('tags');
$newtags = preg_split("/\\s*,\\s*/", trim($data['tags']));
$updatetags = $oldtags != $newtags;
if ($updatetags) {
$artefact->set('tags', $newtags);
}
if (get_config('licensemetadata')) {
foreach (array('license', 'licensor', 'licensorurl') as $licensef) {
if ($data[$licensef] !== null) {
$data[$licensef] = trim($data[$licensef]);
if ($artefact->get($licensef) !== $data[$licensef]) {
$artefact->set($licensef, $data[$licensef]);
}
}
}
}
if ($form->get_property('group') && $data['permissions']) {
$artefact->set('rolepermissions', $data['permissions']);
}
$artefact->commit();
$prefix = $form->get_name() . '_' . $element['name'];
$newtabdata = isset($element['tabs']) ? pieform_element_filebrowser_configure_tabs($element['tabs'], $prefix) : null;
$group = null;
$institution = null;
$user = null;
if (!empty($element['tabs'])) {
$newtabdata = pieform_element_filebrowser_configure_tabs($element['tabs'], $prefix);
if ($newtabdata['owner'] == 'site') {
$institution = 'mahara';
} else {
if ($newtabdata['owner'] == 'institution') {
$institution = $newtabdata['ownerid'];
} else {
if ($newtabdata['owner'] == 'group') {
$group = $newtabdata['ownerid'];
} else {
if ($newtabdata['owner'] == 'user') {
$user = true;
}
}
}
}
}
$returndata = array('error' => false, 'message' => get_string('changessaved', 'artefact.file'), 'newlist' => pieform_element_filebrowser_build_filelist($form, $element, $artefact->get('parent'), null, $user, $group, $institution));
if ($updatetags && $form->submitted_by_js()) {
$smarty = smarty_core();
$tagdata = tags_sideblock();
$smarty->assign('sbdata', $tagdata);
$returndata['tagblockhtml'] = $smarty->fetch('sideblocks/tags.tpl');
}
return $returndata;
}
示例3: pieform_element_filebrowser_update
function pieform_element_filebrowser_update(Pieform $form, $element, $data)
{
global $USER;
$collide = !empty($data['collide']) ? $data['collide'] : 'fail';
$artefact = artefact_instance_from_id($data['artefact']);
if (!$USER->can_edit_artefact($artefact)) {
return array('error' => true, 'message' => get_string('noeditpermission', 'mahara'));
}
if ($existingid = ArtefactTypeFileBase::file_exists($data['title'], $artefact->get('owner'), $data['folder'], $artefact->get('institution'), $artefact->get('group'))) {
if ($existingid != $data['artefact']) {
if ($collide == 'replace') {
log_debug('deleting ' . $existingid);
$copy = artefact_instance_from_id($existingid);
$copy->delete();
} else {
return array('error' => true, 'message' => get_string('fileexists', 'artefact.file'));
}
}
}
$artefact->set('title', $data['title']);
$artefact->set('description', $data['description']);
$artefact->set('tags', preg_split("/\\s*,\\s*/", trim($data['tags'])));
if ($form->get_property('group') && $data['permissions']) {
$artefact->set('rolepermissions', $data['permissions']);
}
$artefact->commit();
return array('error' => false, 'message' => get_string('changessaved', 'artefact.file'), 'newlist' => pieform_element_filebrowser_build_filelist($form, $element, $artefact->get('parent')));
}