$proposal_nr = Proposal::getInstance()->getProposalById($proposal_id); if (!$proposal_nr) { jsonBadResult(t('This proposal was already deleted!'), $args); return; } $title = altPropertyValue($proposal_nr, 'title'); $state = altPropertyValue($proposal_nr, 'state'); if (!Groups::isOwner(_PROPOSAL_OBJ, $proposal_id)) { jsonBadResult(t('You can only delete your own proposals!'), $args); } elseif ($state == 'published') { jsonBadResult(t('We could not remove your proposal: It has already been published.'), $args); } else { $num_deleted = db_delete(tableName(_PROPOSAL_OBJ))->condition(AbstractEntity::keyField(_PROPOSAL_OBJ), $proposal_id)->execute(); if ($num_deleted) { // junk the proposal comments too ThreadedComments::getInstance()->removethreadsForEntity($proposal_id, _PROPOSAL_OBJ); $args['before'] = ''; jsonGoodResult(TRUE, tt('You have removed the proposal %1$s', $title), $args); } else { jsonBadResult(t('We could not remove your proposal'), $args); } } } else { jsonBadResult(t('No proposal identifier submitted!'), $args); } break; case 'save_public': // no break so that the request filters down to 'save' $is_public = true; case 'submit': // no break so that the request filters down to 'save'
} unset($_POST); $form = drupal_get_form("vals_soc_project_form", $obj, $target); if ($originalPath) { $form['#action'] = url($originalPath); } // Process the submit button which uses ajax //$form['submit'] = ajax_pre_render_element($form['submit']); // Build renderable array // $build = array( // 'form' => $form, // '#attached' => $form['submit']['#attached'], // This will attach all needed JS behaviors onto the page // ); renderForm($form, $target); break; case 'delete': $type = altSubValue($_POST, 'type', ''); $id = altSubValue($_POST, 'id', ''); if (!isValidOrganisationType($type)) { echo jsonBadResult(t('There is no such type we can delete')); } elseif (count(Proposal::getProposalsPerProject($id))) { echo jsonBadResult(t('You cannot delte the project; there are already students working on a proposal for this project. You can still edit it though.')); } else { $result = Groups::removeGroup($type, $id); ThreadedComments::getInstance()->removethreadsForEntity($id, $type); echo $result ? jsonGoodResult(true, '', array('extra' => $mine ? array('mine' => 1) : '')) : jsonBadResult(); } break; default: echo "No such action: " . $_GET['action']; }
module_load_include('inc', 'vals_soc', 'includes/module/vals_soc.mail'); notify_all_of_new_comment($entity_details, $thread_details, $properties); } echo json_encode(array('result' => TRUE, 'id' => $result, 'type' => $type, 'entity_id' => $entity_id, 'msg' => tt('You succesfully added a comment to this %1$s', t_type($type)) . (_DEBUG ? showDrupalMessages() : ''))); } else { echo jsonBadResult(); } break; case 'view': $type = altSubValue($_POST, 'type', 'comment'); $id = altSubValue($_POST, 'id'); $target = altSubValue($_POST, 'target', ''); if (!($id && $type && $target)) { die(t('There are missing arguments. Please inform the administrator of this mistake.')); } $post = ThreadedComments::getInstance()->getPostById($id); if (!$post) { echo tt('The post for this %1$s cannot be found', t_type($type)); } else { $entity_id = $post['entity_id']; $entity_type = $post['entity_type']; $threaded_comments = new ThreadUIBuilder($entity_id, $entity_type); echo $threaded_comments->renderSingleComment($post); } break; case 'viewall': if (getRole() != _ANONYMOUS_TYPE) { $type = altSubValue($_GET, 'type'); $id = altSubValue($_GET, 'id'); module_load_include('inc', 'vals_soc', 'includes/ui/comments/threaded_comments'); $content = initComments($id, $type);