Permalink
Browse files

Merge remote-tracking branch 'dstockto/cs_event_deletetrack' into api…

…v1-siteadmin-deletetrack
  • Loading branch information...
2 parents 6c5f197 + f35371d commit f05428b0822ccf44486f32cc0d5aac3117f39fa7 @lornajane lornajane committed Jan 9, 2013
Showing with 100 additions and 32 deletions.
  1. +100 −32 src/system/application/libraries/wsactions/event/Deletetrack.php
@@ -1,64 +1,132 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
-
-class Deletetrack extends BaseWsRequest {
-
- private $CI = null;
- private $xml= null;
+<?php
+/**
+ * Joindin webservice for deleting tracks
+ *
+ * PHP version 5
+ *
+ * @category Joind.in
+ * @package Configuration
+ * @copyright 2009 - 2012 Joind.in
+ * @license http://github.com/joindin/joind.in/blob/master/doc/LICENSE JoindIn
+ */
+if (!defined('BASEPATH')) {
+ exit('No direct script access allowed');
+}
+/**
+ * Joindin webservice for deleting tracks
+ *
+ * PHP version 5
+ *
+ * @category Joind.in
+ * @package Configuration
+ * @copyright 2009 - 2012 Joind.in
+ * @license http://github.com/joindin/joind.in/blob/master/doc/LICENSE JoindIn
+ */
+class Deletetrack extends BaseWsRequest
+{
+ protected $CI = null;
+ protected $xml = null;
- public function Deletetrack($xml) {
- $this->CI=&get_instance(); //print_r($this->CI);
- $this->xml=$xml;
+ /**
+ * Instantiates the webservice to delete tracks
+ *
+ * @param string $xml XML provided to webservice
+ */
+ public function __construct($xml)
+ {
+ $this->CI = &get_instance(); //print_r($this->CI);
+ $this->xml = $xml;
}
- public function checkSecurity($xml) {
- $this->CI->load->model('user_model','um');
- $this->CI->load->model('user_admin_model','uam');
+
+ /**
+ * Ensures the user is allowed to perform the action
+ *
+ * @param string $xml XML sent to webservice
+ *
+ * @return boolean
+ */
+ public function checkSecurity($xml)
+ {
+ $this->CI->load->model('user_model', 'um');
+ $this->CI->load->model('user_admin_model', 'uam');
// Check for a valid logged in user, either via the auth or sessions
if ($this->CI->um->isAuth() || $this->isValidLogin($xml)) {
// They either need to be an admin of the event or a site admin
- $user=false;
+ $user = false;
if ($this->CI->um->isAuth()) {
- $user=$this->CI->session->userdata('username');
+ $user = $this->CI->session->userdata('username');
} elseif (!$this->CI->um->isAuth()) {
- $user=(string)$xml->auth->user;
+ $user = (string)$xml->auth->user;
}
- $udata=$this->CI->um->getUserByUsername($user);
+ $udata = $this->CI->um->getUserByUsername($user);
if (!empty($udata)) {
- $user=$udata[0]->ID;
+ $user = $udata[0]->ID;
} else {
return false;
}
- $eid = (int)$xml->action->event_id;
- $rtype = 'event';
+ $eid = (int)$xml->action->event_id;
+ $rtype = 'event';
// Event ID must be an integer
- if (!is_int($eid)) { return array('output'=>'json','data'=>array('items'=>array('msg'=>'Invalid Event ID!'))); }
+ if (!is_int($eid)) {
+ return array(
+ 'output'=>'json',
+ 'data'=>array(
+ 'items'=>array(
+ 'msg'=>'Invalid Event ID!')
+ )
+ );
+ }
- $is_evt_admin = $this->CI->uam->hasPerm($user, $eid, $rtype);
- $is_site_admin= $this->CI->um->isSiteAdmin($user);
+ $is_evt_admin = $this->CI->uam
+ ->hasPerm($user, $eid, $rtype);
+ $is_site_admin = $this->CI->um->isSiteAdmin($user);
if ($is_site_admin || $is_evt_admin) {
return true;
- } else { return false; }
+ } else {
+ return false;
+ }
- } else { return false; }
+ } else {
+ return false;
+ }
}
- //-----------------------
- public function run() {
- $this->CI->load->model('event_track_model','etm');
- $this->CI->load->model('talks_model','tm');
+
+ /**
+ * Does the work to delete the track from the database
+ *
+ * @return array
+ */
+ public function run()
+ {
+ $this->CI->load->model('event_track_model', 'etm');
+ $this->CI->load->model('talks_model', 'tm');
- $tid=(int)$this->xml->action->track_id;
+ $tid = (int)$this->xml->action->track_id;
// Add the track to the event
- $ret=$this->CI->etm->deleteEventTrack($tid);
+ $ret = $this->CI->etm->deleteEventTrack($tid);
if (!$ret) {
- return array('output'=>'json','data'=>array('items'=>array('msg'=>'Track still in use!')));
+ return array(
+ 'output'=>'json',
+ 'data'=>array(
+ 'items'=>array(
+ 'msg'=>'Track still in use!')
+ )
+ );
} else {
- return array('output'=>'json','data'=>array('items'=>array('msg'=>'Success')));
+ return array(
+ 'output'=>'json',
+ 'data'=>array(
+ 'items'=>array(
+ 'msg'=>'Success')
+ )
+ );
}
}
}

0 comments on commit f05428b

Please sign in to comment.