/** * Constructor * * @param table Database row */ function Link($db_row = NULL) { // Call parent constructor: parent::DataObject('T_links', 'link_', 'link_ID', 'datecreated', 'datemodified', 'creator_user_ID', 'lastedit_user_ID'); if ($db_row != NULL) { $this->ID = $db_row->link_ID; $this->ltype_ID = $db_row->link_ltype_ID; // source of link: if ($db_row->link_itm_ID != NULL) { // Item $this->LinkOwner =& get_link_owner('item', $db_row->link_itm_ID); } elseif ($db_row->link_cmt_ID != NULL) { // Comment $this->LinkOwner =& get_link_owner('comment', $db_row->link_cmt_ID); } else { // User $this->LinkOwner =& get_link_owner('user', $db_row->link_usr_ID); } $this->file_ID = $db_row->link_file_ID; // TODO: dh> deprecated, check where it's used, and fix it. $this->File =& $this->get_File(); $this->position = $db_row->link_position; $this->order = $db_row->link_order; } else { // New object: } }
// Process uploaded files: if ($action != 'switchtab' && isset($_FILES) && count($_FILES)) { // Check that this action request is not a CSRF hacked request: $Session->assert_received_crumb('file'); $upload_result = process_upload($fm_FileRoot->ID, $path, false, false, $upload_quickmode); if (isset($upload_result)) { $failedFiles = $upload_result['failedFiles']; $uploadedFiles = $upload_result['uploadedFiles']; $renamedFiles = $upload_result['renamedFiles']; $renamedMessages = $upload_result['renamedMessages']; foreach ($uploadedFiles as $uploadedFile) { $success_msg = sprintf(T_('The file «%s» has been successfully uploaded to the server.'), $uploadedFile->dget('name')); // Allow to insert/link new upload into currently edited link object: if ($mode == 'upload' && !empty($link_object_ID) && !empty($link_type)) { // The filemanager has been opened from a link owner object, offer to insert an img tag into original object. $LinkOwner = get_link_owner($link_type, $link_object_ID); // TODO: Add plugin hook to allow generating JS insert code(s) $img_tag = format_to_output($uploadedFile->get_tag(), 'formvalue'); if ($uploadedFile->is_image()) { $link_msg = $LinkOwner->translate('Link this image to your owner'); $link_note = T_('recommended - allows automatic resizing'); } else { $link_msg = $LinkOwner->translate('Link this file to your owner'); $link_note = $LinkOwner->translate('The file will be linked for download at the end of the owner'); } $success_msg .= '<ul>' . '<li>' . action_icon(T_('Link this file!'), 'link', regenerate_url('fm_selected,ctrl', 'ctrl=files&action=link_inpost&fm_selected[]=' . rawurlencode($uploadedFile->get_rdfp_rel_path()) . '&' . url_crumb('file')), ' ' . $link_msg, 5, 5, array('target' => $iframe_name)) . ' (' . $link_note . ')</li>' . '<li>' . T_('or') . ' <a href="#" onclick="if( window.focus && window.opener ){' . 'window.opener.focus(); textarea_wrap_selection( window.opener.document.getElementById(\'' . $LinkOwner->type . 'form_post_content\'), \'' . format_to_output($uploadedFile->get_tag(), 'formvalue') . '\', \'\', 1, window.opener.document ); } return false;">' . $LinkOwner->translate('Insert the following code snippet into your owner') . '</a> : <input type="text" value="' . $img_tag . '" size="60" /></li>' . '</ul>'; } $Messages->add($success_msg, 'success'); } } if ($upload_quickmode && !empty($failedFiles)) {
$Messages->add(T_('Nothing selected.'), 'error'); break; } $edited_File =& $selected_Filelist->get_by_idx(0); // Load meta data AND MAKE SURE IT IS CREATED IN DB: $edited_File->load_meta(true); // Check a file for min size $min_size = $Settings->get('min_picture_size'); $image_sizes = $edited_File->get_image_size('widthheight'); if ($image_sizes[0] < $min_size || $image_sizes[1] < $min_size) { // Don't use this file as profile picture because it has small sizes $Messages->add(sprintf(T_('Your profile picture must have a minimum size of %dx%d pixels.'), $min_size, $min_size), 'error'); break; } // Link file to user $LinkOwner = get_link_owner('user', $edited_User->ID); $edited_File->link_to_Object($LinkOwner); // Assign avatar: $edited_User->set('avatar_file_ID', $edited_File->ID); // update profileupdate_date, because a publicly visible user property was changed $edited_User->set_profileupdate_date(); // Save to DB: $edited_User->dbupdate(); $Messages->add(T_('Your profile picture has been changed.'), 'success'); // REDIRECT / EXIT header_redirect($admin_url . '?ctrl=user&user_tab=avatar&user_ID=' . $edited_User->ID); break; case 'link_data': // fp> do we need to go through this block + redirect or could the link icons link directly to $linkctrl ? // Check that this action request is not a CSRF hacked request: $Session->assert_received_crumb('file');