Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
changeicon.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @package FDL
5 */
6 /**
7  * Change icon of a document
8  *
9  * @author Anakeen
10  * @version $Id: changeicon.php,v 1.8 2006/11/16 16:41:19 eric Exp $
11  * @package FDL
12  * @subpackage GED
13  */
14 /**
15  */
16 
17 include_once ("FDL/Class.Doc.php");
18 include_once ("FDL/Class.DocAttr.php");
19 include_once ("FREEDOM/freedom_mod.php");
20 include_once ("VAULT/Class.VaultFile.php");
21 
23 {
24  global $_FILES;
25 
26  $dbaccess = $action->dbaccess;
27  $docid = GetHttpVars("id", 0);
28 
30  $err = $doc->canEdit();
31  if ($err != "") $action->AddWarningMsg($err);
32  else {
33  //print_r($_FILES);
34  $fileinfo = $_FILES["ifile"];
35  if (is_array($fileinfo)) {
36  // if no file specified, keep current file
37  if (($fileinfo['tmp_name'] == "none") || ($fileinfo['tmp_name'] == "") || ($fileinfo['size'] == 0)) {
38  $vid = getHttpVars("vid");
39 
40  $fileVaultInfo = \Dcp\VaultManager::getFileInfo($vid);
41 
42  if ($fileVaultInfo) {
43  if ($fileVaultInfo->public_access !== "t") {
44  $action->exitError("File cannot be used as icon");
45  }
46  $doc->changeIcon(sprintf("%s|%s|%s", $fileVaultInfo->mime_s, $fileVaultInfo->id_file, $fileVaultInfo->name));
47  } else {
48  $action->addWarningMsg(_("no file specified : change icon aborted"));
49  }
50  } else {
51  if (!is_uploaded_file($fileinfo['tmp_name'])) $action->ExitError(_("file not expected : possible attack : update aborted"));
52 
53  $imageSize = getimagesize($fileinfo['tmp_name']);
54  if (!$imageSize) {
55  $action->exitError("File is not recognized like an image");
56  }
57 
58  $vid = \Dcp\VaultManager::storeFile($fileinfo['tmp_name'], $fileinfo['name'], true);
59  $fileVaultInfo = \Dcp\VaultManager::getFileInfo($vid);
60 
61  $doc->changeIcon(sprintf("%s|%s|%s", $fileVaultInfo->mime_s, $fileVaultInfo->id_file, $fileVaultInfo->name));
62  }
63  }
64  }
65 
66  redirect($action, "FDL", "FDL_CARD&sole=Y&id=" . $doc->id);
67 }
addWarningMsg($msg)
global $action
exitError($texterr, $exit=true, $code="")
changeicon(Action &$action)
Definition: changeicon.php:22
$docid
Definition: cleanFamily.php:13
static getFileInfo($idfile, $teng_name="")
getHttpVars($name, $def="", $scope="all")
Definition: Lib.Http.php:124
new_Doc($dbaccess, $id= '', $latest=false)
$dbaccess
Definition: checkVault.php:17
if($file) if($subject==""&&$file) if($subject=="") $err
static storeFile($filepath, $ftitle="", $public_access=false)
← centre documentaire © anakeen