function cdm_user_can_delete($uid) { if (is_admin()) { return true; } if ((($current_user->ID == $r[0]['uid'] or cdmFindLockedGroup($current_user->ID, $r[0]['uid']) == true or get_option('' . $this->namesake . '_project_remove_' . $r[0]['pid'] . '') == 1) && get_option('sp_cu_user_delete_disable') != 1 or current_user_can('manage_options')) && (get_option('sp_cdm_groups_addon_global_remove_roles_' . sp_cdm_get_current_user_role_name() . '') == '' or get_option('sp_cdm_groups_addon_global_remove_roles_' . sp_cdm_get_current_user_role_name() . '') == 1)) { return true; } else { return false; } }
function remove_cat($project_id = NULL) { global $wpdb, $current_user; if (!is_user_logged_in()) { exit; } if ($project_id != NULL) { $project_id = $project_id; } else { $project_id = $_REQUEST['id']; } $r = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "sp_cu_project where id = %d ", $project_id), ARRAY_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') or cdm_folder_permissions($project_id) == 1) { #delete this projects files $f = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "sp_cu where pid = %d ", $project_id), ARRAY_A); for ($j = 0; $j < count($f); $j++) { $this->delete_file($f[$j]['id']); #$this->remove_cat($id); } #find and remove sub folders $p = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "sp_cu_project where parent = %d ", $project_id), ARRAY_A); for ($i = 0; $i < count($p); $i++) { $this->remove_cat($p[$i]['id']); } #delete the project sp_cdm_user_logs::write('Deleted folder: ' . $r[0]['name'] . ''); $wpdb->query($wpdb->prepare("DELETE FROM " . $wpdb->prefix . "sp_cu_project WHERE id = %d", $project_id)); } else { sp_cdm_user_logs::write('Error: Failed removing folder: ' . $r[0]['name'] . ''); } }
$content .= '</tbody></table><div style="clear:both"></div></div>'; break; case "thumbnails": if (CU_PREMIUM == 1) { $find_groups = cdmFindGroups($_GET['uid']); } if ($_REQUEST['search'] != "") { $search_project .= " AND " . $wpdb->prefix . "sp_cu_project.name LIKE '%" . $_REQUEST['search'] . "%' "; $search_file .= " AND (name LIKE '%" . $_REQUEST['search'] . "%' or tags LIKE '%" . $_REQUEST['search'] . "%') "; } $r_projects = $wpdb->get_results("SELECT " . $wpdb->prefix . "sp_cu.name,\r\n\r\n\t\t\t\t\t\t\t\t\t\t\t\t " . $wpdb->prefix . "sp_cu.id,\r\n\r\n\t\t\t\t\t\t\t\t\t\t\t\t " . $wpdb->prefix . "sp_cu.pid ,\r\n\r\n\t\t\t\t\t\t\t\t\t\t\t\t " . $wpdb->prefix . "sp_cu.uid,\r\n\r\n\t\t\t\t\t\t\t\t\t\t\t\t " . $wpdb->prefix . "sp_cu.parent,\r\n\r\n\t\t\t\t\t\t\t\t\t\t\t\t " . $wpdb->prefix . "sp_cu_project.name AS project_name\r\n\r\n\t\t\t\t\t\t\t\t\t\t\t\t \r\n\r\n\t\t\t\t\t\t\t\t\t\tFROM " . $wpdb->prefix . "sp_cu \r\n\r\n\t\t\t\t\t\t\t\t\t\tLEFT JOIN " . $wpdb->prefix . "sp_cu_project ON " . $wpdb->prefix . "sp_cu.pid = " . $wpdb->prefix . "sp_cu_project.id\r\n\r\n\t\t\t\t\t\t\t\t\t\tWHERE (" . $wpdb->prefix . "sp_cu.uid = '" . $_GET['uid'] . "' " . $find_groups . ")\r\n\r\n\t\t\t\t\t\t\t\t\t\tAND pid != 0\r\n\r\n\t\t\t\t\t\t\t\t\t\tAND " . $wpdb->prefix . "sp_cu.parent = 0 \r\n\r\n\t\t\t\t\t\t\t\t\t\t" . $sub_projects . "\r\n\r\n\t\t\t\t\t\t\t\t\t\t" . $search_project . "\r\n\r\n\t\t\t\t\t\t\t\t\t\tGROUP BY pid\r\n\r\n\t\t\t\t\t\t\t\t\t\tORDER by date desc", ARRAY_A); echo '<div id="dlg_cdm_thumbnails">'; if ($_GET['pid'] != "") { $r_current_project = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "sp_cu_project WHERE id = " . $_GET['pid'] . "", ARRAY_A); } if ($_GET['pid'] != "0" && $_GET['pid'] != '' && (get_option('sp_cu_user_projects') == 1 and get_option('sp_cu_user_projects_modify') != 1 or current_user_can('manage_options')) && $_GET['uid'] == $r_current_project[0]['uid'] or cdmFindLockedGroup($current_user->ID, $r_current_project[0]['uid']) == true) { $r_project_info = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "sp_cu_project where id = " . $_GET['pid'] . "", ARRAY_A); echo ' <div style="padding-right:10px"> <a href="javascript:sp_cu_dialog(\'#edit_category_' . $_GET['pid'] . '\',550,130)"><img src="' . SP_CDM_PLUGIN_URL . 'images/application_edit.png"> ' . __("Edit", "sp-cdm") . ' ' . sp_cdm_folder_name() . ' ' . __("Name", "sp-cdm") . '</a> <a href="javascript:sp_cu_remove_project()" style="margin-left:20px"> <img src="' . SP_CDM_PLUGIN_URL . 'images/delete_small.png"> ' . __("Remove", "sp-cdm") . ' ' . sp_cdm_folder_name() . '</a> <div style="display:none">