Permalink
Browse files

Merge remote-tracking branch 'dstockto/cs_event_claim' into phpcs8

  • Loading branch information...
2 parents 6031940 + 1732a43 commit 3f0a7b8820e798cc8b67b1dbe2c7a65fa5e0cd31 @lornajane lornajane committed Jan 19, 2013
Showing with 88 additions and 25 deletions.
  1. +88 −25 src/system/application/libraries/wsactions/event/Claim.php
@@ -1,50 +1,113 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php
+/**
+ * Joindin webservice for claiming a talk
+ * an event
+ *
+ * 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
+ */
-/* "Claiming an event" - requesting to be added as an admin */
-class Claim extends BaseWsRequest {
+if (!defined('BASEPATH')) {
+ exit('No direct script access allowed');
+}
- var $CI = null;
- var $xml = null;
+/**
+ * Joindin webservice for claiming a talk
+ * an event
+ *
+ * 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 Claim extends BaseWsRequest
+{
+ public $CI = null;
+ public $xml = null;
- public function Claim($xml) {
- $this->CI=&get_instance(); //print_r($this->CI);
- $this->xml=$xml;
+ /**
+ * Instantiate the web service
+ *
+ * @param string $xml XML sent to service
+ */
+ public function __construct($xml)
+ {
+ $this->CI = &get_instance(); //print_r($this->CI);
+ $this->xml = $xml;
}
- public function checkSecurity($xml) {
+
+ /**
+ * Public service
+ *
+ * @param string $xml XML sent to webservice
+ *
+ * @return true
+ */
+ public function checkSecurity($xml)
+ {
// public function!
return true;
}
- //-----------------------
- public function run() {
+
+ /**
+ * Does the work to claim a talk
+ *
+ * @return array
+ */
+ public function run()
+ {
$this->CI->load->library('wsvalidate');
$this->CI->load->model('user_admin_model');
$this->CI->load->model('event_model');
- $rules=array(
+ $rules = array(
'eid'=>'required|isevent'
);
- $eid=$this->xml->action->eid;
- $ret=$this->CI->wsvalidate->validate($rules, $this->xml->action);
+
+ $eid = $this->xml->action->eid;
+ $ret = $this->CI->wsvalidate->validate($rules, $this->xml->action);
+
if (!$ret) {
// Passed validation...
// Be sure they're logged in
- if ($this->CI->wsvalidate->validate_loggedin()) { error_log('logged in!');
- $uid=$this->CI->session->userdata('ID');
- $arr=array(
- 'uid' => $uid,
- 'rid' => $eid,
- 'rtype' => 'event',
- 'rcode' => 'pending'
+ if ($this->CI->wsvalidate->validate_loggedin()) {
+ error_log('logged in!');
+ $uid = $this->CI->session->userdata('ID');
+ $arr = array(
+ 'uid' => $uid,
+ 'rid' => $eid,
+ 'rtype' => 'event',
+ 'rcode' => 'pending'
);
+
// Be sure we don't already have a claim pending
- $q=$this->CI->db->get_where('user_admin', $arr);
- $ret=$q->result();
+ $q = $this->CI->db->get_where('user_admin', $arr);
+ $ret = $q->result();
if (isset($ret[0]->ID)) {
- return array('output'=>'json','data'=>array('items'=>array('msg'=>'You already have an outstanding claim on this event')));
+ return array(
+ 'output'=>'json',
+ 'data'=>array(
+ 'items'=>array(
+ 'msg'=>'You already have an outstanding '.
+ 'claim on this event'
+ )
+ )
+ );
} else {
//we're good isert the row!
$this->CI->db->insert('user_admin', $arr);
- return array('output'=>'json','data'=>array('items'=>array('msg'=>'Success')));
+ return array('output'=>'json',
+ 'data'=>array(
+ 'items'=>array(
+ 'msg'=>'Success')
+ )
+ );
}
}
}

0 comments on commit 3f0a7b8

Please sign in to comment.