示例#1
0
    function view_file()
    {
        global $wpdb, $current_user, $cdm_comments, $cdm_google, $cdm_log;
        if (!is_user_logged_in()) {
            exit;
        }
        $file_types = array();
        $r = $wpdb->get_results($wpdb->prepare("SELECT *  FROM " . $wpdb->prefix . "sp_cu   where id = %d order by date desc", $_GET['id']), ARRAY_A);
        $ext = substr(strrchr($r[0]['file'], '.'), 1);
        $stream_file_types = get_option('sp_cu_stream_file_types');
        if ($stream_file_types != '') {
            $file_types = explode(",", $stream_file_types);
        }
        $html .= '<div id="view_file_refresh">

		



	';
        $html .= '<div class="sp_cu_manage">';
        $html = apply_filters('sp_cdm_view_file_first_add_button', $html, $r);
        if (CU_PREMIUM == 1 && get_option('sp_cu_user_uploads_disable') != 1 && get_option('sp_cu_user_disable_revisions') != 1 && cdm_file_permissions($r[0]['pid']) == 1) {
            if ($r[0]['form_id'] == '' or $r[0]['form_id'] == 0) {
                $revision_button = sp_cdm_revision_button();
                $html .= apply_filters('sp_cdm_viewfile_revision_button', $revision_button, $r);
            }
        }
        if (class_exists('cdmProductivityUser')) {
            $html .= '<span id="cdm_comment_button_holder">' . $cdm_comments->button() . '</span>';
        }
        $html = apply_filters('sp_cdm_view_file_add_button', $html, $r);
        if (class_exists('cdmProductivityGoogle')) {
            $shortlink_button = '<span id="cdm_shortlink_button_holder">' . $cdm_google->short_link_button($r[0]['id'], '' . SP_CDM_PLUGIN_URL . 'download.php?fid=' . base64_encode($r[0]['id'] . '|' . $r[0]['date'] . '|' . $r[0]['file']) . '') . '</span>';
            $html .= apply_filters('sp_cdm_viewfile_shortlink_button', $shortlink_button, $r);
        }
        if (get_option('sp_cu_js_redirect') == 1 or in_array($ext, $file_types)) {
            $target = 'target="_blank"';
        } else {
            $target = ' ';
        }
        $download_url = '<a ' . $target . ' href="' . SP_CDM_PLUGIN_URL . 'download.php?fid=' . base64_encode($r[0]['id'] . '|' . $r[0]['date'] . '|' . $r[0]['file']) . '" title="Download" style="margin-right:15px"  ><img src="' . SP_CDM_PLUGIN_URL . 'images/download.png"> ' . __("Download File", "sp-cdm") . '</a> ';
        $html .= apply_filters('sp_cdm_viewfile_download_url', $download_url, $r);
        if (cdm_user_can_delete($current_user->ID) == true && cdm_delete_permission($r[0]['pid']) == 1) {
            $delete_button = '

	<a href="javascript:sp_cu_confirm_delete(\'' . get_option('sp_cu_delete') . '\',200,\'' . SP_CDM_PLUGIN_URL . 'ajax.php?function=delete-file&dlg-delete-file=' . $r[0]['id'] . '\');" title="Delete" ><img src="' . SP_CDM_PLUGIN_URL . 'images/delete.png">' . __("Delete File", "sp-cdm") . '</a>';
            $html .= apply_filters('sp_cdm_viewfile_delete_button', $delete_button, $r);
        }
        $html .= '
<div style="clear:both"></div>
	 <em>' . date('F jS Y h:i A', strtotime($r[0]['date'])) . ' &bull; File ID: #' . $r[0]['id'] . '</em>

				</div>';
        $html .= '
<script type="text/javascript">
jQuery(".viewFileTabs").responsiveTabs({
 startCollapsed: false
});
</script>';
        $html = apply_filters('cdm/viewfile/under_date', $html, $r);
        $html .= '<div class="viewFileTabs">

	<ul>

		<li><a href="#cdm-file-main">' . __("File Info", "sp-cdm") . '</a></li>';
        $html = apply_filters('sp_cdm_view_file_after_file_info_tab', $html, $r);
        if (function_exists('sp_cdm_revision_add') && get_option('sp_cu_user_disable_revisions') != 1) {
            if ($r[0]['form_id'] == '' or $r[0]['form_id'] == 0) {
                $html .= '<li><a href="#cdm-file-revisions">' . __("Revisions", "sp-cdm") . '</a></li>';
            }
        }
        if (class_exists('cdmProductivityUser')) {
            $html .= '<li><a href="#cdm-file-comments">' . __("Comments", "sp-cdm") . '</a></li>';
        }
        if (class_exists('cdmProductivityLog')) {
            if (get_option('sp_cu_log_admin_only') == 1 && current_user_can('manage_options') or (get_option('sp_cu_log_admin_only') == 0 or get_option('sp_cu_log_admin_only') == '')) {
                $html .= '<li><a href="#cdm-file-log">' . __("Download Log", "sp-cdm") . '</a></li>';
            }
        }
        $html = apply_filters('sp_cdm_view_file_tab', $html, $r);
        $html .= '</ul>

	';
        $html = apply_filters('sp_cdm_view_file_content', $html, $r);
        if (function_exists('sp_cdm_revision_add') && get_option('sp_cu_user_disable_revisions') != 1) {
            if ($r[0]['form_id'] == '' or $r[0]['form_id'] == 0) {
                $html .= '<div id="cdm-file-revisions"><div id="cdm_comments"><h4>' . __("Revision History", "sp-cdm") . '</h4>

' . sp_cdm_file_history($r[0]['id']) . '</div></div>';
            }
        }
        if (class_exists('cdmProductivityUser')) {
            $html .= '<div id="cdm-file-comments"><div id="cdm_comments_container">' . $cdm_comments->view($r[0]['id']) . '</div></div>';
        }
        if (class_exists('cdmProductivityLog')) {
            $html .= '<div id="cdm-file-log">' . $cdm_log->view($r[0]['id']) . '</div>';
        }
        $html .= '<div id="cdm-file-main">';
        if (get_option('sp_cu_wp_folder') == '') {
            $wp_con_folder = '/';
        } else {
            $wp_con_folder = get_option('sp_cu_wp_folder');
        }
        //print_r($r);
        $ext = substr(strrchr($r[0]['file'], '.'), 1);
        if ($r[0]['pid'] != 0) {
            $projecter = $wpdb->get_results("SELECT *\r\n\r\n\t\r\n\r\n\t\t\t\t\t\t\t\t\t FROM " . $wpdb->prefix . "sp_cu_project\r\n\r\n\t\t\t\t\t\t\t\t\t WHERE id = '" . $r[0]['pid'] . "'\r\n\r\n\t\t\t\t\t\t\t\t\t ", ARRAY_A);
            $project_title = '' . stripslashes($projecter[0]['name']) . '';
        } else {
            $project_title = '' . __("None", "sp-cdm") . '';
        }
        if ($ext == 'png' or $ext == 'jpg' or $ext = 'jpeg' or $ext = 'gif') {
            $icon = '<td width="160"><img src="' . SP_CDM_UPLOADS_DIR_URL . '' . $r[0]['uid'] . '/' . $r[0]['file'] . '" width="150"></td>';
        } else {
            $icon = '';
        }
        $ext = preg_replace('/^.*\\./', '', $r[0]['file']);
        $images_arr = array("jpg", "png", "jpeg", "gif", "bmp");
        if (get_option('sp_cu_user_projects_thumbs_pdf') == 1 && class_exists('imagick')) {
            $info = new Imagick();
            $formats = $info->queryFormats();
        } else {
            $formats = array();
        }
        if (in_array(strtolower($ext), $images_arr)) {
            if (get_option('sp_cu_overide_upload_path') != '' && get_option('sp_cu_overide_upload_url') == '') {
                $img = '<img src="' . SP_CDM_PLUGIN_URL . 'images/package_labled.png">';
            } else {
                $img = '<img src="' . sp_cdm_thumbnail('' . SP_CDM_UPLOADS_DIR_URL . '' . $r[0]['uid'] . '/' . $r[0]['file'] . '', 250) . '">';
            }
        } elseif ($ext == 'xls' or $ext == 'xlsx') {
            $img = '<img src="' . SP_CDM_PLUGIN_URL . 'images/microsoft_office_excel.png">';
        } elseif ($ext == 'doc' or $ext == 'docx') {
            $img = '<img src="' . SP_CDM_PLUGIN_URL . 'images/microsoft_office_word.png">';
        } elseif ($ext == 'pub' or $ext == 'pubx') {
            $img = '<img src="' . SP_CDM_PLUGIN_URL . 'images/microsoft_office_publisher.png">';
        } elseif ($ext == 'ppt' or $ext == 'pptx') {
            $img = '<img src="' . SP_CDM_PLUGIN_URL . 'images/microsoft_office_powerpoint.png">';
        } elseif ($ext == 'adb' or $ext == 'accdb') {
            $img = '<img src="' . SP_CDM_PLUGIN_URL . 'images/microsoft_office_access.png">';
        } elseif (in_array(strtoupper($ext), $formats)) {
            if (file_exists('' . SP_CDM_UPLOADS_DIR . '' . $r[0]['uid'] . '/' . $r[0]['file'] . '_big.png')) {
                $img = '<img src="' . SP_CDM_UPLOADS_DIR_URL . '' . $r[0]['uid'] . '/' . $r[0]['file'] . '_big.png" width="250">';
            } else {
                $img = '<img src="' . SP_CDM_PLUGIN_URL . 'images/adobe.png">';
            }
        } elseif ($ext == 'pdf' or $ext == 'xod') {
            $img = '<img src="' . SP_CDM_PLUGIN_URL . 'images/adobe.png">';
        } else {
            $img = '<img src="' . SP_CDM_PLUGIN_URL . 'images/package_labled.png">';
        }
        $img = apply_filters('sp_cdm_viewfile_image', $img, $r[0]);
        $file_info .= '

				

				<div id="sp_cu_viewfile">

				

				

				

				<div class="sp_cu_item">

				

		<div class="cdm-two-column"><div class="l-column">';
        $info_left_column .= '
<a ' . $target . ' href="' . SP_CDM_PLUGIN_URL . 'download.php?fid=' . base64_encode($r[0]['id'] . '|' . $r[0]['date'] . '|' . $r[0]['file']) . '" title="Download" style="margin-right:15px"  >


' . $img . '

</a>

';
        $info_left_column = apply_filters('sp_cdm_viewfile_replace_file_info', $info_left_column, $r);
        $file_info .= $info_left_column;
        $file_info .= '</div><div class="r-column">';
        $info_right_column .= '<div class="sp_su_project">

<strong>' . __("File Name", "sp-cdm") . ': </strong> ' . stripslashes($r[0]['name']) . '<br>


</div>
<div class="sp_su_project">

<strong>' . sp_cdm_folder_name() . ': </strong>' . $project_title . '

</div>

<div class="sp_su_project">

<strong>' . __("File Type ", "sp-cdm") . ': </strong>' . $ext . '

</div>
<div class="sp_su_project">

<strong>' . __("File Size ", "sp-cdm") . ': </strong>' . cdm_file_size('' . SP_CDM_UPLOADS_DIR . '' . $r[0]['uid'] . '/' . $r[0]['file'] . '') . ' 

</div>
';
        $extra_file_info = '';
        $info_right_column .= apply_filters('sp_cdm_file_view_info', $extra_file_info, $r[0]);
        if (CU_PREMIUM == 1) {
            if ($r[0]['cid'] != '' && $r[0]['cid'] != 0) {
            }
        }
        if ($r[0]['tags'] != "") {
            $info_right_column .= '

<div class="sp_su_notes">

<strong>' . __("Tags ", "sp-cdm") . ': </strong> ' . stripslashes($r[0]['tags']) . '

</div>';
        }
        if ($r[0]['notes'] != "") {
            $info_right_column .= '

<div class="sp_su_notes">

<strong>' . __("Notes ", "sp-cdm") . ': </strong> ' . stripslashes($r[0]['notes']) . '

</div>';
        }
        if (CU_PREMIUM == 1) {
            if (sp_cdm_get_form_fields($r[0]['id']) != '') {
                $info_right_column .= '

<div class="sp_su_notes">

' . sp_cdm_get_form_fields($r[0]['id']) . '

</div>';
            }
        } else {
            if ($r[0]['notes'] != "") {
                $info_right_column .= '

<div class="sp_su_notes">

<strong>' . __("Notes: ", "sp-cdm") . ':</strong> <em>' . stripslashes($r[0]['notes']) . '</em>

</div>';
            }
        }
        $info_right_column = apply_filters('sp_cdm_view_file_notes', $info_right_column, $r);
        $file_info .= $info_right_column;
        $file_info .= '

	




</div><div style="clear:both"></div>

  </div></div>';
        $file_info = apply_filters('sp_cdm_viewfile_replace_file_infos', $file_info, $r, $info_left_column, $info_right_column);
        $html .= $file_info;
        $html .= '</div></div>

  

 

  </div>

  

  

  

  </div>

  ';
        $html = apply_filters('sp_cdm_viewfile', $html, $r);
        return $html;
    }
示例#2
0
		

		<script>

	jQuery(function() {

		jQuery( ".file-info-tabs" ).tabs();

	});

	</script>

	<div class="view-file-info"><h2>' . stripslashes($r[0]['name']) . '</h2></div>';
        $html .= '<div class="sp_cu_manage">';
        if (CU_PREMIUM == 1 && get_option('sp_cu_user_uploads_disable') != 1) {
            $html .= sp_cdm_revision_button();
        }
        if (class_exists('cdmProductivityUser')) {
            $html .= '<span id="cdm_comment_button_holder">' . $cdm_comments->button() . '</span>';
        }
        if (class_exists('cdmProductivityGoogle')) {
            $html .= '<span id="cdm_shortlink_button_holder">' . $cdm_google->short_link_button($r[0]['id'], '' . SP_CDM_PLUGIN_URL . 'download.php?fid=' . base64_encode($r[0]['id'] . '|' . $r[0]['date'] . '|' . $r[0]['file']) . '') . '</span>';
        }
        if (get_option('sp_cu_js_redirect') == 1) {
            $target = 'target="_blank"';
        } else {
            $target = ' ';
        }
        $html .= '<a ' . $target . ' href="' . SP_CDM_PLUGIN_URL . 'download.php?fid=' . base64_encode($r[0]['id'] . '|' . $r[0]['date'] . '|' . $r[0]['file']) . '" title="Download" style="margin-right:15px"  ><img src="' . SP_CDM_PLUGIN_URL . 'images/download.png"> ' . __("Download File", "sp-cdm") . '</a> ';
        if (($current_user->ID == $r[0]['uid'] or cdmFindLockedGroup($current_user->ID, $r[0]['uid']) == true) && get_option('sp_cu_user_delete_disable') != 1 or current_user_can('manage_options')) {
            $html .= '