Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge remote-tracking branch 'dstockto/cs_event_attend'

  • Loading branch information...
commit fdd65581171146e66233f7e936e525072cdb197c 2 parents 72d4d80 + 8e08ed4
@lornajane lornajane authored
Showing with 98 additions and 26 deletions.
  1. +98 −26 src/system/application/libraries/wsactions/event/Attend.php
View
124 src/system/application/libraries/wsactions/event/Attend.php
@@ -1,15 +1,57 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php
+/**
+ * Joindin webservice for indicating someone attended
+ * 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 Attend extends BaseWsRequest {
-
- var $CI = null;
- var $xml = null;
+if (!defined('BASEPATH')) {
+ exit('No direct script access allowed');
+}
+
+/**
+ * Joindin webservice for indicating someone attended
+ * 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 Attend extends BaseWsRequest
+{
+ public $CI = null;
+ public $xml = null;
- public function Attend($xml) {
- $this->CI=&get_instance(); //print_r($this->CI);
- $this->xml=$xml;
+ /**
+ * Builds the webservice
+ *
+ * @param string $xml XML setn to service
+ */
+ public function __construct($xml)
+ {
+ $this->CI = &get_instance(); //print_r($this->CI);
+ $this->xml = $xml;
}
- public function checkSecurity($xml) {
+
+ /**
+ * Determines if the user is logged in or has a valid public
+ * key to use this API
+ *
+ * @param string $xml XML sent to service
+ *
+ * @return boolean
+ */
+ public function checkSecurity($xml)
+ {
// Just check the key combination on the URL
if ($this->isValidLogin($xml) || $this->checkPublicKey()) {
return true;
@@ -17,38 +59,68 @@ public function checkSecurity($xml) {
return false;
}
- //-----------------------
- public function run() {
+
+ /**
+ * Does the work to mark someone as attending an event
+ *
+ * @return array
+ */
+ public function run()
+ {
$this->CI->load->library('wsvalidate');
$this->CI->load->model('user_attend_model');
- $rules=array(
- 'eid' =>'required|isevent',
- //'reqkey' =>'required|reqkey'
+ $rules = array(
+ 'eid' =>'required|isevent',
+ //'reqkey' =>'required|reqkey'
);
- $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) {
//see if were logged in - if not, we return the redirect: message back
- if ($this->CI->wsvalidate->validate_loggedin() || $this->isValidLogin($this->xml)) {
- $uid=$this->CI->session->userdata('ID');
+ if ($this->CI->wsvalidate->validate_loggedin()
+ || $this->isValidLogin($this->xml)
+ ) {
+ $uid = $this->CI->session->userdata('ID');
if (!$uid) {
// its an API call, grab from the XML
- $user=$this->CI->user_model->getUserByUsername((string)$this->xml->auth->user);
- $uid = $user[0]->ID;
+ $user = $this->CI->user_model
+ ->getUserByUsername((string)$this->xml->auth->user);
+ $uid = $user[0]->ID;
}
//check to see if they have a record - if they do, remove
//if they don't, add...
$this->CI->user_attend_model->chgAttendStat($uid, $eid);
- return array('output'=>'json','data'=>array('items'=>array('msg'=>'Success')));
-
+ return array(
+ 'output'=>'json',
+ 'data'=>array(
+ 'items'=>array(
+ 'msg'=>'Success')
+ )
+ );
} else {
- $this->CI->session->set_userdata('ref_url','event/view/'.$eid);
- return array('output'=>'json','data'=>array('items'=>array('msg'=>'redirect:/user/login')));
+ $this->CI->session->set_userdata('ref_url', 'event/view/'.$eid);
+
+ return array(
+ 'output'=>'json',
+ 'data'=>array(
+ 'items'=>array(
+ 'msg'=>'redirect:/user/login')
+ )
+ );
}
- } else { return array('output'=>'json','data'=>array('items'=>array('msg'=>'Fail'))); }
+ } else {
+ return array(
+ 'output'=>'json',
+ 'data'=>array(
+ 'items'=>array(
+ 'msg'=>'Fail')
+ )
+ );
+ }
}
- //-----------------------
}
Please sign in to comment.
Something went wrong with that request. Please try again.