Permalink
Browse files

Merge remote-tracking branch 'enygma/JOINDIN-63'

  • Loading branch information...
2 parents 434b385 + 6ad83d9 commit 24ca55d3bda179e8dbaa299e29c7481c2c7c5cf7 @lornajane committed Jun 7, 2012
View
46 src/system/application/controllers/talk.php
@@ -888,6 +888,52 @@ function claim($talkId, $claimId=null)
}
/**
+ * Unlink a talk claim from a speaker
+ *
+ * @param int $talkId Talk ID
+ * @param int $speakerId Speaker ID
+ *
+ * @return null
+ */
+ public function unlink($talkId,$speakerId)
+ {
+ if (!$this->user_model->isAuth()) {
+ redirect('talk/view/'.$talkId);
+ }
+
+ // get the event the talk is a part of
+ $this->load->model('talks_model');
+ $this->load->model('user_model');
+
+ $event = $this->talks_model->getTalkEvent($talkId);
+ error_log(print_r($event,true));
+
+ // ensure that the user is either a site admin or event admin
+ if ($this->user_model->isSiteAdmin() || $this->user_model->isAdminEvent($event->ID)) {
+
+ $data = array(
+ 'talkId' => $talkId,
+ 'speakerId' => $speakerId
+ );
+
+ $this->template->write_view('content','talk/unlink',$data);
+
+ if (isset($_POST['answer']) && ($_POST['answer'] == 'yes')) {
+
+ $this->load->model('talk_speaker_model');
+ $user = $this->user_model->getUser($speakerId);
+
+ $this->talk_speaker_model->unlinkSpeaker($talkId,$user[0]->ID);
+ redirect('talk/view/'.$talkId);
+ }
+
+ $this->template->render();
+ } else {
+ redirect('talk/view/'.$talkId);
+ }
+ }
+
+ /**
* Validates whether the given date is within the event's period.
*
* @param string $str The string to validate.
View
16 src/system/application/models/talk_speaker_model.php
@@ -107,6 +107,22 @@ public function deleteSpeaker($talk_id, $speaker_name) {
);
$this->db->delete('talk_speaker', $where);
}
+
+ /**
+ * Unlink a speaker claim from a talk
+ *
+ * @param int $talk_id Talk ID
+ * @param int $speaker_id Speaker ID
+ *
+ * @return null
+ */
+ public function unlinkSpeaker($talk_id, $speaker_id) {
+ $data = array('speaker_id' => null);
+ $this->db->update(
+ 'talk_speaker', $data,
+ array('speaker_id' => $speaker_id, 'talk_id' => $talk_id)
+ );
+ }
/**
* Find all speakers for a given talk ID #
View
6 src/system/application/views/talk/modules/_talk_detail.php
@@ -10,7 +10,11 @@
<?php
if (!empty($speaker->speaker_id) && $speaker->status!='pending') {
if (empty($speaker->full_name)) { $speaker->full_name = 'N/A'; }
- $speaker_names[] = '<a href="/user/view/'.$speaker->speaker_id.'">'.$speaker->full_name.'</a>';
+ $speaker_link = '<a href="/user/view/'.$speaker->speaker_id.'">'.$speaker->full_name.'</a> ';
+ if ($admin) {
+ $speaker_link .= '<a class="btn-small" href="/talk/unlink/'.$speaker->talk_id.'/'.$speaker->speaker_id.'">< unlink</a>';
+ }
+ $speaker_names[] = $speaker_link;
} else {
$speaker_names[] = $speaker->speaker_name;
}
View
30 src/system/application/views/talk/unlink.php
@@ -0,0 +1,30 @@
+<?php
+menu_pagetitle('Unlink Talk Claim');
+?>
+<?php
+if (isset($talkId)) {
+ echo form_open('talk/unlink/'.$talkId.'/'.$speakerId);
+ ?>
+
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td>
+ Are you sure you wish to unlink this talk claim?<br/>
+ <input type="submit" value="yes" name="answer">
+ <input type="button" value="no" onClick="document.location='/talk/view/<?php echo $talkId?>'">
+ </td>
+ </tr>
+ </table>
+
+ <?php
+ echo form_close();
+
+} else {
+ if (isset($error) && $error == '') {
+ echo 'talk removed!';
+ } else {
+ echo 'Error: ' . htmlentities($error);
+ }
+}
+
+?>

0 comments on commit 24ca55d

Please sign in to comment.