PageRenderTime 42ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/src/system/application/libraries/wsactions/user/Unlink.php

https://github.com/heiglandreas/joind.in
PHP | 99 lines | 42 code | 13 blank | 44 comment | 5 complexity | 07405d9e23e2cb1e1ea78b8089b29288 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. <?php
  2. /**
  3. * Joindin webservice for unlinking a speaker from a talk
  4. *
  5. * PHP version 5
  6. *
  7. * @category Joind.in
  8. * @package WebServices
  9. * @copyright 2009 - 2012 Joind.in
  10. * @license http://github.com/joindin/joind.in/blob/master/doc/LICENSE JoindIn
  11. */
  12. if (!defined('BASEPATH')) {
  13. exit('No direct script access allowed');
  14. }
  15. // Unlink a user from a talk
  16. /**
  17. * Joindin webservice for unlinking a speaker from a talk
  18. *
  19. * PHP version 5
  20. *
  21. * @category Joind.in
  22. * @package WebServices
  23. * @copyright 2009 - 2012 Joind.in
  24. * @license http://github.com/joindin/joind.in/blob/master/doc/LICENSE JoindIn
  25. */
  26. class Unlink extends BaseWsRequest
  27. {
  28. public $CI = null;
  29. public $xml = null;
  30. /**
  31. * Instantiates the unlink object. Sets the xml value on the object
  32. * and gets the CodeIgniter instance
  33. *
  34. * @param string $xml XML to set
  35. */
  36. public function __construct($xml)
  37. {
  38. $this->CI = &get_instance(); //print_r($this->CI);
  39. $this->xml = $xml;
  40. }
  41. /**
  42. * Only site admins can use this functionality
  43. *
  44. * Determines if the user is an admin and able to use this functionality
  45. *
  46. * @param string $xml XML to check
  47. *
  48. * @return boolean
  49. */
  50. public function checkSecurity($xml)
  51. {
  52. $this->CI->load->model('user_model');
  53. // Check for a valid login
  54. //if ($this->isValidLogin($xml) || $this->CI->user_model->isAuth()) {
  55. if ($this->CI->user_model->isAuth()) {
  56. // Now check to see if they're a site admin
  57. $user = $this->CI->session->userdata('username');
  58. if (!$this->CI->user_model->isSiteAdmin($user)) {
  59. return false;
  60. } else {
  61. return true;
  62. }
  63. } else {
  64. return false;
  65. }
  66. }
  67. /**
  68. * Runs the user unlink webservice code
  69. *
  70. * @return array
  71. */
  72. public function run()
  73. {
  74. $this->CI->load->model('talk_speaker_model');
  75. $result = array();
  76. $talk_id = (int)$this->xml->action->talk_id;
  77. $speaker_id = (int)$this->xml->action->speaker_id;
  78. $css_row_id = (string)$this->xml->action->css_row_id;
  79. $result['talk_id'] = $talk_id;
  80. $result['speaker_id'] = $speaker_id;
  81. $result['css_row_id'] = $css_row_id;
  82. $this->CI->talk_speaker_model->unlinkSpeaker($talk_id, $speaker_id);
  83. $result['msg'] = 'Success';
  84. return array('output'=>'json', 'items'=>$result);
  85. }
  86. }