Esempio n. 1
0
        exit;
    } else {
        new NotifyWidgetFailure($ret[1]);
    }
}
if (isset($_GET['mod'])) {
    $mod = $_GET['mod'];
} else {
    $mod = "none";
}
switch ($mod) {
    case 'add':
        image_add($type, $target_uuid);
        break;
    case 'edit':
        image_edit($type, $target_uuid);
        break;
    default:
        image_add($type, $target_uuid);
        break;
}
function image_add($type, $target_uuid)
{
    $params = getParams();
    $item_uuid = $_GET['itemid'];
    $label = urldecode($_GET['itemlabel']);
    $f = new PopupForm(sprintf(_T("Add the image <b>%s</b> to <b>%s</b>", "imaging"), $label, $params['hostname']));
    # Need to get the name of the target
    $f->push(new Table());
    // form preseeding
    $f->add(new HiddenTpl("itemid"), array("value" => $item_uuid, "hide" => True));
Esempio n. 2
0
function thumbnail_create()
{
    $id = gps('id');
    $width = gps('width');
    $height = gps('height');
    if (!is_numeric($width) && !is_numeric($height)) {
        image_edit(messenger('invalid_width_or_height', "({$width})/({$height})", ''), $id);
        return;
    }
    $crop = gps('crop');
    $t = new txp_thumb($id);
    $t->crop = $crop == '1';
    $t->hint = '0';
    if (is_numeric($width)) {
        $t->width = $width;
    }
    if (is_numeric($height)) {
        $t->height = $height;
    }
    if ($t->write()) {
        image_edit(messenger('thumbnail', $id, 'saved'), $id);
    } else {
        image_edit(messenger('thumbnail', $id, 'not_saved'), $id);
    }
}
Esempio n. 3
0
function thumbnail_delete()
{
    global $txp_user;
    $id = assert_int(gps('id'));
    $author = fetch('author', 'txp_image', 'id', $id);
    if (!has_privs('image.edit') && !($author === $txp_user && has_privs('image.edit.own'))) {
        image_list(gTxt('restricted_area'));
        return;
    }
    $t = new txp_thumb($id);
    if ($t->delete()) {
        callback_event('thumbnail_deleted', '', false, $id);
        update_lastmod();
        image_edit(gTxt('thumbnail_deleted'), $id);
    } else {
        image_edit(array(gTxt('thumbnail_delete_failed'), E_ERROR), $id);
    }
}
Esempio n. 4
0
function thumbnail_delete()
{
    $id = assert_int(gps('id'));
    $t = new txp_thumb($id);
    if ($t->delete()) {
        image_edit(gTxt('thumbnail_deleted'), $id);
    } else {
        image_edit(gTxt('thumbnail_delete_failed'), $id);
    }
}
Esempio n. 5
0
function thumbnail_insert()
{
    global $txpcfg, $extensions, $txp_user, $img_dir, $path_from_root;
    extract($txpcfg);
    $id = gps('id');
    $file = $_FILES['thefile']['tmp_name'];
    $name = $_FILES['thefile']['name'];
    list(, , $extension) = getimagesize($file);
    if ($extensions[$extension]) {
        $ext = $extensions[$extension];
        $newpath = $doc_root . $path_from_root . $img_dir . '/' . $id . 't' . $ext;
        if (move_uploaded_file($file, $newpath) == false) {
            image_list($newpath . sp . gTxt('upload_dir_perms'));
        } else {
            chmod($newpath, 0755);
            safe_update("txp_image", "thumbnail='1'", "id='{$id}'");
            image_edit(messenger('image', $name, 'uploaded'), $id);
        }
    } else {
        image_list(gTxt('only_graphic_files_allowed'));
    }
}
Esempio n. 6
0
$itemid = $_GET['itemid'];

if (($type == '' && (xmlrpc_isComputerRegistered($target_uuid) || xmlrpc_isComputerInProfileRegistered($target_uuid))) || ($type == 'group' && xmlrpc_isProfileRegistered($target_uuid)))  {


    if(isset($_GET['mod']))
        $mod = $_GET['mod'];
    else
        $mod = "none";

    switch($mod) {
        case 'log':
            image_logs($itemid);
            break;
        case 'edit':
            image_edit($target_uuid, $type, $itemid);
            break;
        case 'convert':
            image_convert();
            break;
        default:
            if (empty($type)) {
                image_list($type, _T("Available images", "imaging"));
            }
            image_list($type, _T("Available masters", "imaging"), false);
            break;
    }
} else {
    /* register the target (computer or profile) */
    $params = array('target_uuid'=>$target_uuid, 'type'=>$type, 'from'=>"services", "target_name"=>$target_name);
    header("Location: " . urlStrRedirect("base/computers/".$type."register_target", $params));
Esempio n. 7
0
function thumbnail_create()
{
    extract(doSlash(gpsa(array('id', 'width', 'height'))));
    if (!is_numeric($width) && !is_numeric($height)) {
        image_edit(messenger('invalid_width_or_height', "({$width})/({$height})", ''), $id);
        return;
    }
    $crop = gps('crop');
    $t = new txp_thumb($id);
    $t->crop = $crop == '1';
    $t->hint = '0';
    if (is_numeric($width)) {
        $t->width = $width;
    }
    if (is_numeric($height)) {
        $t->height = $height;
    }
    if ($t->write()) {
        global $prefs;
        $prefs['thumb_w'] = $width;
        $prefs['thumb_h'] = $height;
        $prefs['thumb_crop'] = $crop;
        // hidden prefs
        set_pref('thumb_w', $width, 'image', 2);
        set_pref('thumb_h', $height, 'image', 2);
        set_pref('thumb_crop', $crop, 'image', 2);
        $message = gTxt('thumbnail_saved', array('{id}' => $id));
        image_edit($message, $id);
    } else {
        $message = gTxt('thumbnail_not_saved', array('{id}' => $id));
        image_edit($message, $id);
    }
}
Esempio n. 8
0
function thumbnail_insert()
{
    global $txpcfg, $extensions, $txp_user, $img_dir, $path_to_site;
    extract($txpcfg);
    $id = gps('id');
    $file = $_FILES['thefile']['tmp_name'];
    $name = $_FILES['thefile']['name'];
    $file = get_uploaded_file($file);
    list(, , $extension) = getimagesize($file);
    if ($file !== false && $extensions[$extension]) {
        $ext = $extensions[$extension];
        $newpath = IMPATH . $id . 't' . $ext;
        if (shift_uploaded_file($file, $newpath) == false) {
            image_list($newpath . sp . gTxt('upload_dir_perms'));
        } else {
            chmod($newpath, 0755);
            safe_update("txp_image", "thumbnail='1'", "id='{$id}'");
            image_edit(messenger('image', $name, 'uploaded'), $id);
        }
    } else {
        if ($file === false) {
            image_list(upload_get_errormsg($_FILES['thefile']['error']));
        } else {
            image_list(gTxt('only_graphic_files_allowed'));
        }
    }
}