X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=plugins%2Fadmin%2Fapplications%2Fclass_applicationGeneric.inc;h=27cf79eb1084ccbf5b2b05857364cfb76b732f73;hb=46b995937ce49d16cd6d3d1e1f69a70d421453e8;hp=44c07f444b818bf795b3714e10d68ebca06dd8d8;hpb=e299f0ca47a924516f2afbe4e922f2418b75315c;p=gosa.git
diff --git a/plugins/admin/applications/class_applicationGeneric.inc b/plugins/admin/applications/class_applicationGeneric.inc
index 44c07f444..27cf79eb1 100644
--- a/plugins/admin/applications/class_applicationGeneric.inc
+++ b/plugins/admin/applications/class_applicationGeneric.inc
@@ -31,7 +31,9 @@ class application extends plugin
/* Load icon */
$ldap= $config->get_ldap_link();
- $this->iconData= $ldap->get_attribute($dn, "gosaApplicationIcon");
+ if ($dn != 'new'){
+ $this->iconData= $ldap->get_attribute($dn, "gosaApplicationIcon");
+ }
if ($this->iconData == ""){
$this->set_picture("");
}
@@ -41,45 +43,44 @@ class application extends plugin
/* This is always an account */
$this->is_account= TRUE;
- if ($this->dn == "new"){
+ if ($this->dn == "new"){
$ui= get_userinfo();
$this->base= dn2base($ui->dn);
} else {
- $this->base= preg_replace ("/^[^,]+,[^,]+,/", "", $this->dn);
- }
+ $this->base= preg_replace ("/^[^,]+,[^,]+,/", "", $this->dn);
+ }
}
function execute()
{
/* Do we represent a valid group? */
if (!$this->is_account && $this->parent == NULL){
- $display= "
".
+ $display= "
".
_("This 'dn' is no application.")."";
return ($display);
}
- /* Fill templating stuff */
- $smarty= get_smarty();
- $smarty->assign("cn", $this->cn);
- $smarty->assign("bases", $this->config->idepartments);
+ /* Fill templating stuff */
+ $smarty= get_smarty();
+ $smarty->assign("cn", $this->cn);
+ $smarty->assign("bases", $this->config->idepartments);
if ($this->dn == "new"){
- $smarty->assign("selectmode", "");
- $smarty->assign("namemode", "");
- } else {
- $smarty->assign("namemode", "readonly");
- $smarty->assign("selectmode", "disabled");
- }
+ $smarty->assign("selectmode", "");
+ $smarty->assign("namemode", "");
+ } else {
+ $smarty->assign("namemode", "readonly");
+ $smarty->assign("selectmode", "disabled");
+ }
/* Get random number for pictures */
- srand((double)microtime()*1000000);
+ srand((double)microtime()*1000000);
$smarty->assign("rand", rand(0, 10000));
- /* Variables */
- foreach(array("description", "gosaApplicationExecute", "gosaApplicationName") as $val){
-
- $smarty->assign($val, $this->$val);
- $smarty->assign($val."ACL", chkacl($this->acl, $val));
- }
+ /* Variables */
+ foreach(array("description", "gosaApplicationExecute", "gosaApplicationName") as $val){
+ $smarty->assign($val, $this->$val);
+ $smarty->assign($val."ACL", chkacl($this->acl, $val));
+ }
/* Checkboxes */
foreach (array("G" => "exec_for_groupmembers", "O" => "overwrite_config",
@@ -142,33 +143,59 @@ class application extends plugin
}
/* Check for picture upload */
-
-
if (isset($_FILES['picture_file']['name']) && $_FILES['picture_file']['name'] != ""){
if (!is_uploaded_file($_FILES['picture_file']['tmp_name'])) {
print_red (_("The specified picture has not been uploaded correctly."));
}
- /* Load the new uploaded Photo */
- if(!$handle = imagick_ReadImage($_FILES['picture_file']['tmp_name'])) {
- gosa_log("Can't Load image");
- }
-
- /* Resizing image to 147x200 and blur */
- if(!imagick_resize($handle,48,48,IMAGICK_FILTER_GAUSSIAN,0)){
- gosa_log("imagick_resize failed");
- }
-
- /* Converting image to JPEG */
- if(!imagick_convert($handle,"PNG")) {
- gosa_log("Can't Convert to PNG");
- }
-
- if(imagick_writeimage($handle,$_FILES['picture_file']['tmp_name'])){
- gosa_log("can't write to specified folder");
+ if (!function_exists("imagick_blob2image")){
+ /* Get temporary file name for conversation */
+ $fname = tempnam ("/tmp", "GOsa");
+
+ /* Open file and write out photoData */
+ $fp = fopen ($fname, "w");
+ fwrite ($fp, $_FILES['picture_file']['tmp_name']);
+ fclose ($fp);
+
+ /* Build conversation query. Filename is generated automatically, so
+ we do not need any special security checks. Exec command and save
+ output. For PHP safe mode, you'll need a configuration which respects
+ image magick as executable... */
+ $query= "convert -size 48x48 $fname -resize 48x48 +profile \"*\" -";
+ @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__, $query, "Execute");
+
+ /* Read data written by convert */
+ $output= "";
+ $sh= popen($query, 'r');
+ while (!feof($sh)){
+ $output.= fread($sh, 4096);
+ }
+ pclose($sh);
+
+ unlink($fname);
+ } else {
+
+ /* Load the new uploaded Photo */
+ if(!$handle = imagick_ReadImage($_FILES['picture_file']['tmp_name'])){
+ gosa_log("Can't Load image");
+ }
+
+ /* Resizing image to 147x200 and blur */
+ if(!imagick_resize($handle,48,48,IMAGICK_FILTER_GAUSSIAN,0)){
+ gosa_log("imagick_resize failed");
+ }
+
+ /* Converting image to JPEG */
+ if(!imagick_convert($handle,"PNG")) {
+ gosa_log("Can't Convert to PNG");
+ }
+
+ if(imagick_writeimage($handle,$_FILES['picture_file']['tmp_name'])){
+ gosa_log("can't write to specified folder");
+ }
+
+ imagick_free($handle);
}
-
- imagick_free($handle);
/* Activate new picture */
$this->set_picture($_FILES['picture_file']['tmp_name']);