'Arduino Projects Proposal Form', 'description' => 'Arduino Projects Proposal Form', 'page callback' => 'drupal_get_form', 'page arguments' => array( 'arduino_projects_blog_proposal_form' ), 'access arguments' => array( 'arduino projects create proposal' ), 'type' => MENU_NORMAL_ITEM, 'file' => 'proposal.inc' ); $items['arduino-projects/my-proposals'] = array( 'title' => 'My Arduino Projects Proposals', 'description' => 'My Arduino Projects Proposals', 'page callback' => 'arduino_projects_blog_my_proposal', 'access callback' => 'user_access', 'access arguments' => array( 'arduino projects display own proposal' ), 'file' => 'proposal.inc' ); $items['arduino-projects/my-proposals/edit'] = array( 'title' => 'Edit My Proposal', 'description' => 'Edit My Proposal', 'page callback' => 'drupal_get_form', 'page arguments' => array( 'arduino_projects_blog_my_proposal_edit_form' ), 'access arguments' => array( 'arduino projects edit own proposal' ), 'type' => MENU_CALLBACK, 'file' => 'my_proposals.inc' ); $items['arduino-projects/my-proposals/view'] = array( 'title' => 'View My Proposal', 'description' => 'View My Proposal', 'page callback' => 'drupal_get_form', 'page arguments' => array( 'arduino_projects_blog_my_proposal_view_form' ), 'access arguments' => array( 'arduino projects view own proposal' ), 'type' => MENU_CALLBACK, 'file' => 'my_proposals.inc' ); $items['arduino-projects/manage-proposal'] = array( 'title' => 'Manage Arduino Projects Proposals', 'description' => 'Manage Arduino Projects Proposals', 'page callback' => 'arduino_projects_blog_proposal_pending', 'access callback' => 'user_access', 'access arguments' => array( 'arduino projects manage proposal' ), 'file' => 'manage_proposal.inc' ); $items['arduino-projects/manage-proposal/pending'] = array( 'title' => 'Pending Proposals', 'description' => 'Pending arduino projects Proposals Queue', 'page callback' => 'arduino_projects_blog_proposal_pending', 'access callback' => 'user_access', 'access arguments' => array( 'arduino projects manage proposal' ), 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => 1, 'file' => 'manage_proposal.inc' ); $items['arduino-projects/manage-proposal/all'] = array( 'title' => 'All Proposals', 'description' => 'All Proposals', 'page callback' => 'arduino_projects_blog_proposal_all', 'access callback' => 'user_access', 'access arguments' => array( 'arduino projects manage proposal' ), 'type' => MENU_LOCAL_TASK, 'weight' => 4, 'file' => 'manage_proposal.inc' ); $items['arduino-projects/manage-proposal/approve'] = array( 'title' => 'Proposal Approval Form', 'description' => 'Proposal Approval Form', 'page callback' => 'drupal_get_form', 'page arguments' => array( 'arduino_projects_blog_proposal_approval_form' ), 'access arguments' => array( 'arduino projects manage proposal' ), 'type' => MENU_CALLBACK, 'file' => 'manage_proposal.inc' ); $items['arduino-projects/manage-proposal/edit'] = array( 'title' => 'Edit Proposal', 'description' => 'Edit Proposal', 'page callback' => 'drupal_get_form', 'page arguments' => array( 'arduino_projects_blog_proposal_edit_form' ), 'access arguments' => array( 'arduino projects edit proposal' ), 'type' => MENU_CALLBACK, 'file' => 'manage_proposal.inc' ); $items['arduino-projects/manage-proposal/status'] = array( 'title' => 'Proposal Status', 'description' => 'Proposal Status', 'page callback' => 'drupal_get_form', 'page arguments' => array( 'arduino_projects_blog_proposal_status_form' ), 'access arguments' => array( 'arduino projects approve proposal' ), 'type' => MENU_CALLBACK, 'file' => 'manage_proposal.inc' ); /* Final project Submission*/ $items['arduino-projects/code'] = array( 'title' => 'Project Submission', 'description' => 'Project Submission', 'page callback' => 'list_steps', 'access callback' => 'user_access', 'access arguments' => array( 'arduino projects upload code' ), 'file' => 'upload_project.inc' ); $items['arduino-projects/code/list-steps'] = array( 'title' => 'List Steps', 'description' => 'List Steps', 'page callback' => 'list_steps', 'access arguments' => array( 'arduino projects upload code' ), 'type' => MENU_DEFAULT_LOCAL_TASK, 'file' => 'upload_project.inc', 'weight' => 1 ); $items['arduino-projects/code/view-step'] = array( 'title' => 'View Step', 'description' => 'View Step', 'page callback' => 'view_steps', 'access arguments' => array( 'arduino projects upload code' ), 'type' => MENU_CALLBACK, 'file' => 'upload_project.inc', 'weight' => 3 ); $items['arduino-projects/code/step/edit'] = array( 'title' => 'Edit Step', 'description' => 'Edit Step', 'page callback' => 'drupal_get_form', 'page arguments' => array( 'upload_step_edit_form' ), 'access arguments' => array( 'arduino projects edit uploaded step' ), 'type' => MENU_CALLBACK, 'file' => 'editstep.inc' ); $items['arduino-projects/code/upload'] = array( 'title' => 'Project Submission', 'description' => 'Project Submission', 'page callback' => 'upload_examples', 'access arguments' => array( 'arduino projects upload code' ), 'type' => MENU_LOCAL_TASK, 'file' => 'code.inc', 'weight' => 3 ); $items['arduino-projects/code/update-introduction'] = array( 'title' => 'Introduction', 'description' => 'Introduction', 'page callback' => 'update_introduction', 'access arguments' => array( 'arduino projects upload code' ), 'type' => MENU_LOCAL_TASK, 'file' => 'upload_project.inc', 'weight' => 2 ); $items['arduino-projects/code-approval'] = array( 'title' => 'Manage Project Approval', 'description' => 'Manage Project Approval', 'page callback' => 'introduction_approval', 'access arguments' => array( 'arduino projects bulk manage code' ), 'type' => MENU_NORMAL_ITEM, 'file' => 'code_approval.inc' ); $items['arduino-projects/code-approval/introduction'] = array( 'title' => 'Introduction Approval', 'description' => 'Introduction Approval', 'page callback' => 'drupal_get_form', 'page arguments' => array( 'introduction_approval_form' ), 'access arguments' => array( 'arduino projects bulk manage code' ), 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => 1, 'file' => 'code_approval.inc' ); $items['arduino-projects/code-approval/step'] = array( 'title' => 'Step approval form', 'description' => 'Step approval form', 'page callback' => 'drupal_get_form', 'page arguments' => array( 'step_approval_form' ), 'access arguments' => array( 'arduino projects bulk manage code' ), 'type' => MENU_LOCAL_TASK, 'weight' => 2, 'file' => 'code_approval.inc' ); $items['arduino-projects/code-approval/bulk'] = array( 'title' => 'Bulk Manage', 'description' => 'Bulk Manage', 'page callback' => 'drupal_get_form', 'page arguments' => array( 'bulk_approval_form' ), 'access arguments' => array( 'arduino projects bulk manage code' ), 'type' => MENU_LOCAL_TASK, 'weight' => 3, 'file' => 'code_approval.inc' ); $items['arduino-projects/abstract-approval/bulk'] = array( 'title' => 'Bulk Manage', 'description' => 'Bulk Mangage', 'page callback' => 'drupal_get_form', 'page arguments' => array( 'arduino_projects_blog_abstract_bulk_approval_form' ), 'access arguments' => array( 'arduino projects bulk manage abstract' ), 'type' => MENU_LOCAL_TASK, 'weight' => 2, 'file' => 'abstract_bulk_approval.inc' ); /* CODE DOWNLOADS */ $items['arduino-projects/download/reference-images'] = array( 'title' => 'Download Reference Images', 'description' => 'Download Reference Images', 'page callback' => 'arduino_projects_blog_download_reference_images', 'access arguments' => array( 'arduino projects download reference images' ), 'type' => MENU_CALLBACK, 'file' => 'download.inc' ); $items['arduino-projects/download/step-images'] = array( 'title' => 'Download Step Images', 'description' => 'Download Step Images', 'page callback' => 'arduino_projects_blog_download_step_images', 'access arguments' => array( 'arduino projects download step files' ), 'type' => MENU_CALLBACK, 'file' => 'download.inc' ); $items['arduino-projects/download/step-gifs'] = array( 'title' => 'Download Step Gifs', 'description' => 'Download Step Gifs', 'page callback' => 'arduino_projects_blog_download_step_gifs', 'access arguments' => array( 'arduino projects download step files' ), 'type' => MENU_CALLBACK, 'file' => 'download.inc' ); $items['arduino-projects/download/abstract-file'] = array( 'title' => 'Download abstract file', 'description' => 'Download abstract file', 'page callback' => 'arduino_projects_blog_project_files', 'access arguments' => array( 'arduino projects download code' ), 'type' => MENU_CALLBACK, 'file' => 'download.inc' ); $items['arduino-projects/download/file'] = array( 'title' => 'Code Download', 'description' => 'Code Download', 'page callback' => 'arduino_projects_blog_download_solution_file', 'access arguments' => array( 'arduino projects download code' ), 'type' => MENU_CALLBACK, 'file' => 'download.inc' ); $items['arduino-projects/projects-in-progress'] = array( 'title' => 'Projects in Progress', 'page callback' => 'arduino_projects_in_progress', 'access arguments' => array( 'arduino projects download code' ), 'file' => 'project_details.inc' ); $items['arduino-projects/completed-projects'] = array( 'title' => 'Completed Projects', 'page callback' => 'arduino_projects_completed', 'access arguments' => array( 'arduino projects download code' ), 'file' => 'project_details.inc' ); $items['arduino-projects/project-details'] = array( 'title' => 'Projects Details', 'page callback' => 'drupal_get_form', 'page arguments' => array( 'arduino_projects_details' ), //'page callback' => 'arduino_projects_details', 'access arguments' => array( 'arduino projects download code' ), 'file' => 'run.inc' ); $items['arduino-projects/full-download/project'] = array( 'title' => 'Code Download', 'description' => 'Code Download', 'page callback' => 'arduino_projects_blog_download_full_project', 'access arguments' => array( 'arduino projects download code' ), 'type' => MENU_CALLBACK, 'file' => 'full_download.inc' ); /* DOWNLOAD FOR EVERYONE */ $items['arduino-projects/arduino-projects-run'] = array( 'title' => 'Download Codes', 'page callback' => 'drupal_get_form', 'page arguments' => array( 'arduino_projects_blog_run_form' ), 'access arguments' => array( 'arduino projects download code' ), 'type' => MENU_NORMAL_ITEM, 'file' => 'run.inc' ); /* ADMIN SETTINGS */ $items['admin/settings/arduino-projects'] = array( 'title' => 'Arduino Projects Settings', 'description' => 'Arduino Projects Settings', 'page callback' => 'drupal_get_form', 'page arguments' => array( 'arduino_projects_blog_settings_form' ), 'access arguments' => array( 'administer arduino projects' ), 'type' => MENU_NORMAL_ITEM, 'file' => 'settings.inc' ); /* AJAX REQUEST */ $items['arduino-projects/certificates'] = array( 'title' => 'List of Arduino Projects Certificates', 'description' => 'List of Arduino Projects Certificates', 'page callback' => '_list_pssp_certificates', 'access arguments' => array( 'list Arduino Projects certificates' ), 'file' => 'pdf/list_pssp_certificate.inc' ); $items['arduino-projects/certificates/generate-pdf'] = array( 'title' => 'Download Certificate', 'description' => 'Download Certificate', 'page callback' => 'drupal_get_form', 'page arguments' => array( 'generate_pdf' ), 'type' => MENU_CALLBACK, 'access arguments' => array( 'generate pdf' ), 'file' => 'pdf/cert_new.inc' ); $items['arduino-projects/certificates-custom'] = array( 'title' => 'List of Arduino Projects Custom Certificates', 'description' => 'List of Arduino Projects Custom Certificates', 'page callback' => '_list_pssp_custom_certificates', 'access arguments' => array( 'list Arduino Projects custom certificates' ), 'file' => 'pdf/list_mentor_certificates.inc' ); $items['arduino-projects/certificates-custom/pdf'] = array( 'title' => 'Download Certificate', 'description' => 'Download Certificate', 'page callback' => 'drupal_get_form', 'page arguments' => array( 'generate_pdf' ), 'type' => MENU_CALLBACK, 'access arguments' => array( 'generate pdf' ), 'file' => 'pdf/mentor_cert_pdf.inc' ); $items["arduino-projects/certificates/verify"] = array( "title" => "Certificate Verification", "page callback" => "verify_certificates", "access arguments" => array( "verify certificates" ), 'type' => MENU_CALLBACK, 'file' => 'pdf/verify_certificates.inc' ); return $items; } /** * Implementation of hook_perm(). */ function arduino_projects_blog_permission() { return array( 'arduino projects create proposal' => array( 'title' => t('arduino projects create proposal'), 'restrict access' => TRUE ), 'arduino projects display own proposal' => array( 'title' => t('arduino projects display own proposal'), 'restrict access' => TRUE ), 'arduino projects manage proposal' => array( 'title' => t('arduino projects manage proposal'), 'restrict access' => TRUE ), 'arduino projects edit proposal' => array( 'title' => t('arduino projects edit proposal'), 'restrict access' => TRUE ), 'arduino projects edit own proposal' => array( 'title' => t('arduino projects edit own proposal'), 'restrict access' => TRUE ), 'arduino projects view own proposal' => array( 'title' => t('arduino projects view own proposal'), 'restrict access' => TRUE ), 'arduino projects approve proposal' => array( 'title' => t('arduino projects approve proposal'), 'restrict access' => TRUE ), 'arduino projects edit uploaded step' => array( 'title' => t('arduino projects edit uploaded step'), 'restrict access' => TRUE ), 'arduino projects propose solution' => array( 'title' => t('arduino projects propose solution'), 'restrict access' => TRUE ), 'arduino projects approve abstract' => array( 'title' => t('arduino projects approve code'), 'restrict access' => TRUE ), 'arduino projects bulk manage code' => array( 'title' => t('arduino projects bulk manage code'), 'restrict access' => TRUE ), 'arduino projects bulk manage abstract' => array( 'title' => t('arduino projects bulk manage abstract'), 'restrict access' => TRUE ), 'arduino projects bulk delete code' => array( 'title' => t('arduino projects bulk delete code'), 'restrict access' => TRUE ), 'arduino projects upload code' => array( 'title' => t('arduino projects upload code'), 'restrict access' => TRUE ), 'arduino projects download code' => array( 'title' => t('arduino projects download code'), 'restrict access' => TRUE ), 'arduino projects download reference images' => array( 'title' => t('arduino projects download reference images'), 'restrict access' =>TRUE ), 'arduino projects download step files' => array( 'title' => t('arduino projects download step files'), 'restrict access' =>TRUE ), 'administer arduino projects' => array( 'title' => t('administer arduino projects'), 'restrict access' => TRUE ), 'arduino projects generate abstract' => array( 'title' => t('arduino projects generate abstract'), 'restrict access' => TRUE ), "list Arduino Projects certificates" => array( "title" => t("list Arduino Projects certificates"), "description" => t("Allows users to list Arduino Projects certificates.") ), "list Arduino Projects custom certificates" => array( "title" => t("list Arduino Projects custom certificates"), "description" => t("Allows users to list Arduino Projects custom certificates.") ), "generate pdf" => array( "title" => t("Generate pdf"), "description" => t("Allows users to Generate pdf.") ) ); // return array('arduino projects create proposal', 'arduino projects manage proposal', 'arduino projects edit proposal', 'arduino projects approve proposal', 'arduino projects propose solution', 'arduino projects approve code', 'arduino projects bulk manage abstract', 'arduino projects bulk delete code', 'arduino projects upload code', 'arduino projects download code', 'administer arduino projects', 'arduino projects generate lab'); } /*************************** VALIDATION FUNCTIONS *****************************/ function arduino_projects_blog_check_valid_filename($file_name) { if (!preg_match('/^[0-9a-zA-Z\.\_]+$/', $file_name)) return FALSE; else if (substr_count($file_name, ".") > 1) return FALSE; else return TRUE; } function arduino_projects_blog_check_name($name = '') { if (!preg_match('/^[0-9a-zA-Z\ ]+$/', $name)) return FALSE; else return TRUE; } /************************* USER VERIFICATION FUNCTIONS ************************/ function arduino_projects_blog_get_proposal() { global $user; //$proposal_q = db_query("SELECT * FROM {arduino_projects_blog_proposal} WHERE solution_provider_uid = ".$user->uid." AND solution_status = 2 ORDER BY id DESC LIMIT 1"); $query = db_select('arduino_projects_blog_proposal'); $query->fields('arduino_projects_blog_proposal'); $query->condition('uid', $user->uid); $query->orderBy('id', 'DESC'); $query->range(0, 1); $proposal_q = $query->execute(); $proposal_data = $proposal_q->fetchObject(); if (!$proposal_data) { drupal_set_message("You do not have any approved arduino projects proposal. Please propose the Arduino Projects proposal", 'error'); drupal_goto(''); } //!$proposal_data switch ($proposal_data->approval_status) { case 0: drupal_set_message(t('Proposal is awaiting approval.'), 'status'); return FALSE; case 1: return $proposal_data; case 2: drupal_set_message(t('Proposal has been dis-approved.'), 'error'); return FALSE; case 3: drupal_set_message(t('Proposal has been marked as completed.'), 'status'); return FALSE; default: drupal_set_message(t('Invalid proposal state. Please contact site administrator for further information.'), 'error'); return FALSE; } //$proposal_data->approval_status return FALSE; } /*************************************************************************/ /***** Function To convert only first charater of string in uppercase ****/ /*************************************************************************/ function ucname($string) { $string = ucwords(strtolower($string)); foreach (array( '-', '\'' ) as $delimiter) { if (strpos($string, $delimiter) !== false) { $string = implode($delimiter, array_map('ucfirst', explode($delimiter, $string))); } } return $string; } function arduino_projects_blog_ucname($string) { $string = ucwords(strtolower($string)); foreach (array( '-', '\'' ) as $delimiter) { if (strpos($string, $delimiter) !== false) { $string = implode($delimiter, array_map('ucfirst', explode($delimiter, $string))); } //strpos($string, $delimiter) !== false } //array( '-', '\'' ) as $delimiter return $string; } function _df_sentence_case($string) { $string = ucwords(strtolower($string)); foreach (array( '-', '\'' ) as $delimiter) { if (strpos($string, $delimiter) !== false) { $string = implode($delimiter, array_map('ucfirst', explode($delimiter, $string))); } //strpos($string, $delimiter) !== false } //array( '-', '\'' ) as $delimiter return $string; } function _df_list_of_states() { $states = array( 0 => '-Select-' ); $query = db_select('list_states_of_india'); $query->fields('list_states_of_india'); //$query->orderBy('', ''); $states_list = $query->execute(); while ($states_list_data = $states_list->fetchObject()) { $states[$states_list_data->state] = $states_list_data->state; } //$states_list_data = $states_list->fetchObject() return $states; } function _df_list_of_cities() { $city = array( 0 => '-Select-' ); $query = db_select('list_cities_of_india'); $query->fields('list_cities_of_india'); $query->orderBy('city', 'ASC'); $city_list = $query->execute(); while ($city_list_data = $city_list->fetchObject()) { $city[$city_list_data->city] = $city_list_data->city; } //$city_list_data = $city_list->fetchObject() return $city; } function _df_list_of_pincodes() { $pincode = array( 0 => '-Select-' ); $query = db_select('list_of_all_india_pincode'); $query->fields('list_of_all_india_pincode'); $query->orderBy('pincode', 'ASC'); $pincode_list = $query->execute(); while ($pincode_list_data = $pincode_list->fetchObject()) { $pincode[$pincode_list_data->pincode] = $pincode_list_data->pincode; } //$pincode_list_data = $pincode_list->fetchObject() return $pincode; } function _df_list_of_departments() { $department = array(); $query = db_select('list_of_departments'); $query->fields('list_of_departments'); $query->orderBy('id', 'DESC'); $department_list = $query->execute(); while ($department_list_data = $department_list->fetchObject()) { $department[$department_list_data->department] = $department_list_data->department; } //$department_list_data = $department_list->fetchObject() return $department; } function generateVideoEmbedUrl($url){ //This is a general function for generating an embed link of an FB/Vimeo/Youtube Video. $finalUrl = ''; if(strpos($url, 'facebook.com/') !== false) { //it is FB video $finalUrl.='https://www.facebook.com/plugins/video.php?href='.rawurlencode($url).'&show_text=1&width=200'; }else if(strpos($url, 'vimeo.com/') !== false) { //it is Vimeo video $videoId = explode("vimeo.com/",$url)[1]; if(strpos($videoId, '&') !== false){ $videoId = explode("&",$videoId)[0]; } $finalUrl.='https://player.vimeo.com/video/'.$videoId; }else if(strpos($url, 'youtube.com/') !== false) { //it is Youtube video $videoId = explode("v=",$url)[1]; if(strpos($videoId, '&') !== false){ $videoId = explode("&",$videoId)[0]; } $finalUrl.='https://www.youtube.com/embed/'.$videoId; }else if(strpos($url, 'youtu.be/') !== false){ //it is Youtube video $videoId = explode("youtu.be/",$url)[1]; if(strpos($videoId, '&') !== false){ $videoId = explode("&",$videoId)[0]; } $finalUrl.='https://www.youtube.com/embed/'.$videoId; }else{ //Enter valid video URL } return $finalUrl; } function convertLinkToEmbed($videoLink, $width, $height) { $embed = ''; if (preg_match('/https:\/\/(?:www.)?(youtube).com\/watch\\?v=(.*?)/', $videoLink)) $embed = preg_replace("/\s*[a-zA-Z\/\/:\.]*youtube.com\/watch\?v=([a-zA-Z0-9\-_]+)([a-zA-Z0-9\/\*\-\_\?\&\;\%\=\.]*)/i", "", $videoLink); if (preg_match('/https:\/\/vimeo.com\/(\\d+)/', $videoLink, $regs)) $embed = ''; return $embed; } function _apb_dir_name($project, $proposar_name) { $project_title = ucname($project); $proposar_name = ucname($proposar_name); $dir_name = $project_title . ' By ' . $proposar_name; $directory_name = str_replace("__", "_", str_replace(" ", "_", str_replace("/", " ", $dir_name))); return $directory_name; } function arduino_projects_blog_files_path() { return $_SERVER['DOCUMENT_ROOT'] . base_path() . 'project_uploads/'; } function DF_RenameDir($proposal_id, $dir_name) { $proposal_id = $proposal_id; $dir_name = $dir_name; $query = db_query("SELECT directory_name,id FROM arduino_projects_blog_proposal WHERE id = :proposal_id", array( ':proposal_id' => $proposal_id )); $result = $query->fetchObject(); if ($result != NULL) { $files = scandir(arduino_projects_blog_path()); $files_id_dir = arduino_projects_blog_path() . $result->id; //var_dump($files);die; $file_dir = arduino_projects_blog_path() . $result->directory_name; if (is_dir($file_dir)) { $new_directory_name = rename(arduino_projects_blog_path() . $result->directory_name, arduino_projects_blog_path() . $dir_name); return $new_directory_name; } //is_dir($file_dir) else if (is_dir($files_id_dir)) { $new_directory_name = rename(arduino_projects_blog_path() . $result->id, arduino_projects_blog_path() . $dir_name); return $new_directory_name; } //is_dir($files_id_dir) else { drupal_set_message('Directory not available for rename.'); return; } } //$result != NULL else { drupal_set_message('Project directory name not present in databse'); return; } //var_dump($files);die; /* if ($files != NULL) { $new_directory_name = rename(arduino_projects_blog_path() . $result->directory_name, arduino_projects_blog_path() . $dir_name) or drupal_set_message("Unable to rename folder"); } else { $new_directory_name = 'Can not rename the directory. Directory not present'; }*/ return; } function CreateReadmeFileOmPSSPProject($proposal_id) { $result = db_query(" SELECT * from arduino_projects_blog_proposal WHERE id = :proposal_id", array( ":proposal_id" => $proposal_id )); $proposal_data = $result->fetchObject(); $root_path = arduino_projects_blog_path(); $readme_file = fopen($root_path . $proposal_data->directory_name . "/README.txt", "w") or die("Unable to open file!"); $txt = ""; $txt .= "About the Arduino Projects"; $txt .= "\n" . "\n"; $txt .= "Title Of The Arduino Projects Project: " . $proposal_data->project_title . "\n"; $txt .= "Proposar Name: " . $proposal_data->name_title . " " . $proposal_data->contributor_name . "\n"; $txt .= "University: " . $proposal_data->university . "\n"; $txt .= "\n" . "\n"; $txt .= "Arduino Projects Project By FOSSEE, IIT Bombay" . "\n"; fwrite($readme_file, $txt); fclose($readme_file); return $txt; } function rrmdir_project($prop_id) { $proposal_id = $prop_id; $result = db_query(" SELECT * from arduino_projects_blog_proposal WHERE id = :proposal_id", array( ":proposal_id" => $proposal_id )); $proposal_data = $result->fetchObject(); $root_path = arduino_projects_blog_path(); $dir = $root_path . $proposal_data->directory_name; if ($proposal_data->id == $prop_id) { if (is_dir($dir)) { $objects = scandir($dir); foreach ($objects as $object) { if ($object != "." && $object != "..") { if (filetype($dir . "/" . $object) == "dir") { rrmdir($dir . "/" . $object); } //filetype($dir . "/" . $object) == "dir" else { unlink($dir . "/" . $object); } } //$object != "." && $object != ".." } //$objects as $object reset($objects); rmdir($dir); $msg = drupal_set_message("Directory deleted successfully"); return $msg; } //is_dir($dir) $msg = drupal_set_message("Directory not present"); return $msg; } //$proposal_data->id == $prop_id else { $msg = drupal_set_message("Data not found"); return $msg; } } function rrmdir($dir) { if (is_dir($dir)) { $objects = scandir($dir); foreach ($objects as $object) { if ($object != "." && $object != "..") { if (filetype($dir . "/" . $object) == "dir") rrmdir($dir . "/" . $object); else unlink($dir . "/" . $object); } //$object != "." && $object != ".." } //$objects as $object reset($objects); rmdir($dir); } //is_dir($dir) }