| 1 |
<?php |
| 2 |
/** |
| 3 |
* Single project: files |
| 4 |
* |
| 5 |
* @package UpStream |
| 6 |
*/ |
| 7 |
|
| 8 |
// Prevent direct access. |
| 9 |
if ( ! defined( 'ABSPATH' ) ) { |
| 10 |
exit; |
| 11 |
} |
| 12 |
|
| 13 |
if ( ! upstream_are_files_disabled() && ! upstream_disable_files() ) : |
| 14 |
|
| 15 |
$collapse_box = isset( $plugin_options['collapse_project_files'] ) |
| 16 |
&& true === (bool) $plugin_options['collapse_project_files']; |
| 17 |
|
| 18 |
$collapse_box_state = \UpStream\Frontend\upstream_get_section_collapse_state( 'files' ); |
| 19 |
|
| 20 |
if ( false !== $collapse_box_state ) { |
| 21 |
$collapse_box = 'closed' === $collapse_box_state; |
| 22 |
} |
| 23 |
|
| 24 |
$item_type = 'file'; |
| 25 |
$current_user_id = get_current_user_id(); |
| 26 |
$users = upstream_admin_get_all_project_users(); |
| 27 |
$rowset = array(); |
| 28 |
$project_id = upstream_post_id(); |
| 29 |
|
| 30 |
$meta = (array) get_post_meta( $project_id, '_upstream_project_files', true ); |
| 31 |
foreach ( $meta as $data ) { |
| 32 |
if ( ! isset( $data['id'] ) |
| 33 |
|| ! isset( $data['created_by'] ) |
| 34 |
|| ! upstream_override_access_object( true, UPSTREAM_ITEM_TYPE_FILE, $data['id'], UPSTREAM_ITEM_TYPE_PROJECT, $project_id, UPSTREAM_PERMISSIONS_ACTION_VIEW ) |
| 35 |
) { |
| 36 |
continue; |
| 37 |
} |
| 38 |
|
| 39 |
$data['created_by'] = (int) $data['created_by']; |
| 40 |
$data['created_time'] = isset( $data['created_time'] ) ? (int) $data['created_time'] : 0; |
| 41 |
$data['title'] = isset( $data['title'] ) ? (string) $data['title'] : ''; |
| 42 |
$data['file_id'] = isset( $data['file_id'] ) ? (int) $data['file_id'] : 0; |
| 43 |
$data['description'] = isset( $data['description'] ) ? (string) $data['description'] : ''; |
| 44 |
|
| 45 |
$rowset[ $data['id'] ] = $data; |
| 46 |
} |
| 47 |
|
| 48 |
$l = array( |
| 49 |
'LB_TITLE' => __( 'Title', 'upstream' ), |
| 50 |
'LB_NONE' => __( 'none', 'upstream' ), |
| 51 |
'LB_DESCRIPTION' => __( 'Description', 'upstream' ), |
| 52 |
'LB_COMMENTS' => __( 'Comments', 'upstream' ), |
| 53 |
'LB_FILE' => __( 'File', 'upstream' ), |
| 54 |
'LB_UPLOADED_AT' => __( 'Upload Date', 'upstream' ), |
| 55 |
); |
| 56 |
|
| 57 |
$are_comments_enabled = upstream_are_comments_enabled_on_files(); |
| 58 |
|
| 59 |
$table_settings = array( |
| 60 |
'id' => 'files', |
| 61 |
'type' => 'file', |
| 62 |
'data-ordered-by' => 'created_at', |
| 63 |
'data-order-dir' => 'DESC', |
| 64 |
); |
| 65 |
|
| 66 |
$columns_schema = \UpStream\Frontend\upstream_get_files_fields( $are_comments_enabled ); |
| 67 |
?> |
| 68 |
<div class="col-md-12 col-sm-12 col-xs-12"> |
| 69 |
<div class="x_panel" data-section="files"> |
| 70 |
<div class="x_title"> |
| 71 |
<h2> |
| 72 |
<i class="fa fa-bars sortable_handler"></i> |
| 73 |
<i class="fa fa-file"></i> <?php echo esc_html( upstream_file_label_plural() ); ?> |
| 74 |
</h2> |
| 75 |
<ul class="nav navbar-right panel_toolbox"> |
| 76 |
<li> |
| 77 |
<a class="collapse-link"> |
| 78 |
<i class="fa fa-chevron-<?php echo $collapse_box ? 'down' : 'up'; ?>"></i> |
| 79 |
</a> |
| 80 |
</li> |
| 81 |
<?php do_action( 'upstream_project_files_top_right', $project_id ); ?> |
| 82 |
</ul> |
| 83 |
<div class="clearfix"></div> |
| 84 |
</div> |
| 85 |
<div class="x_content" style="display: <?php echo $collapse_box ? 'none' : 'block'; ?>;"> |
| 86 |
<div class="c-data-table table-responsive"> |
| 87 |
<form class="form-inline c-data-table__filters" data-target="#files"> |
| 88 |
<div class="d-none d-sm-flex justify-content-between"> |
| 89 |
<div class="form-group"> |
| 90 |
<div class="input-group"> |
| 91 |
<div class="input-group-text"> |
| 92 |
<i class="fa fa-search"></i> |
| 93 |
</div> |
| 94 |
<input type="search" class="form-control" |
| 95 |
placeholder="<?php echo esc_attr( $l['LB_TITLE'] ); ?>" data-column="title" |
| 96 |
data-compare-operator="contains"> |
| 97 |
</div> |
| 98 |
</div> |
| 99 |
<div class="form-group"> |
| 100 |
<div class="btn-group"> |
| 101 |
<a href="#files-filters" role="button" class="btn border btn-light btn-sm" |
| 102 |
data-bs-toggle="collapse" aria-expanded="false" aria-controls="files-filters"> |
| 103 |
<i class="fa fa-filter"></i> <?php esc_html_e( 'Toggle Filters', 'upstream' ); ?> |
| 104 |
</a> |
| 105 |
</div> |
| 106 |
<div class="btn-group"> |
| 107 |
<button class="btn btn-light border btn-sm dropdown-toggle upstream-export-button" |
| 108 |
type="button" id="dropdownMenuButton1" data-bs-toggle="dropdown" aria-expanded="false"> |
| 109 |
<i class="fa fa-download"></i> <?php esc_html_e( 'Export', 'upstream' ); ?> |
| 110 |
</button> |
| 111 |
<ul class="dropdown-menu" aria-labelledby="dropdownMenuButton1"> |
| 112 |
<li><a class="dropdown-item" href="#" data-action="export" data-type="txt"> |
| 113 |
<i class="fa fa-file-text-o"></i> <?php esc_html_e( 'Plain Text', 'upstream' ); ?> |
| 114 |
</a></li> |
| 115 |
<li><a class="dropdown-item" href="#" data-action="export" data-type="csv"> |
| 116 |
<i class="fa fa-file-code-o"></i> <?php esc_html_e( 'CSV', 'upstream' ); ?> |
| 117 |
</a></li> |
| 118 |
</ul> |
| 119 |
</div> |
| 120 |
</div> |
| 121 |
</div> |
| 122 |
<div class="d-flex justify-content-between d-sm-none"> |
| 123 |
<div class="btn-group"> |
| 124 |
<a href="#files-filters" role="button" class="btn border btn-light btn-sm" |
| 125 |
data-bs-toggle="collapse" aria-expanded="false" aria-controls="files-filters"> |
| 126 |
<i class="fa fa-filter"></i> <?php esc_html_e( 'Toggle Filters', 'upstream' ); ?> |
| 127 |
</a> |
| 128 |
</div> |
| 129 |
<div class="btn-group"> |
| 130 |
<button class="btn btn-light border btn-sm dropdown-toggle upstream-export-button" |
| 131 |
type="button" id="dropdownMenuButton1" data-bs-toggle="dropdown" aria-expanded="false"> |
| 132 |
<i class="fa fa-download"></i> <?php esc_html_e( 'Export', 'upstream' ); ?> |
| 133 |
</button> |
| 134 |
<ul class="dropdown-menu" aria-labelledby="dropdownMenuButton1"> |
| 135 |
<li><a class="dropdown-item" href="#" data-action="export" data-type="txt"> |
| 136 |
<i class="fa fa-file-text-o"></i> <?php esc_html_e( 'Plain Text', 'upstream' ); ?> |
| 137 |
</a></li> |
| 138 |
<li><a class="dropdown-item" href="#" data-action="export" data-type="csv"> |
| 139 |
<i class="fa fa-file-code-o"></i> <?php esc_html_e( 'CSV', 'upstream' ); ?> |
| 140 |
</a></li> |
| 141 |
</ul> |
| 142 |
</div> |
| 143 |
</div> |
| 144 |
<div id="files-filters" class="collapse"> |
| 145 |
<div class="form-group d-block d-sm-none"> |
| 146 |
<div class="input-group"> |
| 147 |
<div class="input-group-text"> |
| 148 |
<i class="fa fa-search"></i> |
| 149 |
</div> |
| 150 |
<input type="search" class="form-control" |
| 151 |
placeholder="<?php echo esc_html( $l['LB_TITLE'] ); ?>" data-column="title" |
| 152 |
data-compare-operator="contains"> |
| 153 |
</div> |
| 154 |
</div> |
| 155 |
<div class="form-group d-sm-inline-block"> |
| 156 |
<div class="input-group flex-nowrap"> |
| 157 |
<div class="input-group-text"> |
| 158 |
<i class="fa fa-user"></i> |
| 159 |
</div> |
| 160 |
<select class="form-control o-select2" data-column="created_by" |
| 161 |
data-placeholder="<?php esc_html_e( 'Uploader', 'upstream' ); ?>" multiple> |
| 162 |
<option value></option> |
| 163 |
<option value="<?php echo esc_attr( $current_user_id ); ?>"> |
| 164 |
<?php |
| 165 |
esc_html_e( |
| 166 |
'Me', |
| 167 |
'upstream' |
| 168 |
); |
| 169 |
?> |
| 170 |
</option> |
| 171 |
<optgroup label="<?php esc_attr_e( 'Users' ); ?>"> |
| 172 |
<?php foreach ( $users as $user_id => $user_name ) : ?> |
| 173 |
<?php |
| 174 |
if ( $user_id === $current_user_id ) { |
| 175 |
continue; |
| 176 |
} |
| 177 |
?> |
| 178 |
<option value="<?php echo esc_attr( $user_id ); ?>"><?php echo esc_html( $user_name ); ?></option> |
| 179 |
<?php endforeach; ?> |
| 180 |
</optgroup> |
| 181 |
</select> |
| 182 |
</div> |
| 183 |
</div> |
| 184 |
<div class="form-group d-sm-inline-block"> |
| 185 |
<div class="input-group flex-nowrap"> |
| 186 |
<div class="input-group-text"> |
| 187 |
<i class="fa fa-user"></i> |
| 188 |
</div> |
| 189 |
<select class="form-control o-select2" data-column="assigned_to" |
| 190 |
data-placeholder="<?php esc_attr_e( 'Assignee', 'upstream' ); ?>" multiple> |
| 191 |
<option value></option> |
| 192 |
<option value="__none__"><?php esc_html_e( 'Nobody', 'upstream' ); ?></option> |
| 193 |
<option value="<?php echo esc_attr( $current_user_id ); ?>"> |
| 194 |
<?php |
| 195 |
esc_html_e( |
| 196 |
'Me', |
| 197 |
'upstream' |
| 198 |
); |
| 199 |
?> |
| 200 |
</option> |
| 201 |
<optgroup label="<?php esc_attr_e( 'Users' ); ?>"> |
| 202 |
<?php foreach ( $users as $user_id => $user_name ) : ?> |
| 203 |
<?php |
| 204 |
if ( $user_id === $current_user_id ) { |
| 205 |
continue; |
| 206 |
} |
| 207 |
?> |
| 208 |
<option value="<?php echo esc_attr( $user_id ); ?>"><?php echo esc_html( $user_name ); ?></option> |
| 209 |
<?php endforeach; ?> |
| 210 |
</optgroup> |
| 211 |
</select> |
| 212 |
</div> |
| 213 |
</div> |
| 214 |
<div class="form-group d-sm-inline-block"> |
| 215 |
<div class="input-group"> |
| 216 |
<div class="input-group-text"> |
| 217 |
<i class="fa fa-calendar"></i> |
| 218 |
</div> |
| 219 |
<input type="text" class="form-control o-datepicker" |
| 220 |
placeholder="<?php echo esc_html( $l['LB_UPLOADED_AT'] ); ?>" |
| 221 |
id="files-filter-uploaded_at_from"> |
| 222 |
</div> |
| 223 |
<input type="hidden" id="files-filter-uploaded_at_from_timestamp" |
| 224 |
data-column="created_time" data-compare-operator=">="> |
| 225 |
</div> |
| 226 |
|
| 227 |
<?php |
| 228 |
do_action( |
| 229 |
'upstream:project.files.filters', |
| 230 |
$table_settings, |
| 231 |
$columns_schema, |
| 232 |
$project_id |
| 233 |
); |
| 234 |
?> |
| 235 |
</div> |
| 236 |
</form> |
| 237 |
<?php |
| 238 |
\UpStream\Frontend\upstream_render_table( |
| 239 |
$table_settings, |
| 240 |
$columns_schema, |
| 241 |
$rowset, |
| 242 |
'file', |
| 243 |
$project_id |
| 244 |
); |
| 245 |
?> |
| 246 |
</div> |
| 247 |
</div> |
| 248 |
</div> |
| 249 |
</div> |
| 250 |
<?php endif; ?> |
| 251 |
|