| 1: | <?php
|
| 2: | |
| 3: | |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | |
| 9: | |
| 10: |
|
| 11: |
|
| 12: | |
| 13: | |
| 14: | |
| 15: | |
| 16: | |
| 17: | |
| 18: |
|
| 19: |
|
| 20: |
|
| 21: | |
| 22: | |
| 23: |
|
| 24: | class XoopsXmlRpcApi
|
| 25: | {
|
| 26: |
|
| 27: | public $params;
|
| 28: |
|
| 29: |
|
| 30: | public $response;
|
| 31: |
|
| 32: |
|
| 33: | public $module;
|
| 34: |
|
| 35: |
|
| 36: | public $xoopsTagMap = array();
|
| 37: |
|
| 38: |
|
| 39: | public $user;
|
| 40: |
|
| 41: | public $isadmin = false;
|
| 42: |
|
| 43: | |
| 44: | |
| 45: | |
| 46: | |
| 47: |
|
| 48: | public function __construct(&$params, &$response, &$module)
|
| 49: | {
|
| 50: | $this->params =& $params;
|
| 51: | $this->response =& $response;
|
| 52: | $this->module =& $module;
|
| 53: | }
|
| 54: |
|
| 55: | |
| 56: | |
| 57: | |
| 58: |
|
| 59: | public function _setUser(&$user, $isadmin = false)
|
| 60: | {
|
| 61: | if (is_object($user)) {
|
| 62: | $this->user =& $user;
|
| 63: | $this->isadmin = $isadmin;
|
| 64: | }
|
| 65: | }
|
| 66: |
|
| 67: | |
| 68: | |
| 69: | |
| 70: | |
| 71: | |
| 72: |
|
| 73: | public function _checkUser($username, $password)
|
| 74: | {
|
| 75: | if (isset($this->user)) {
|
| 76: | return true;
|
| 77: | }
|
| 78: |
|
| 79: | $member_handler = xoops_getHandler('member');
|
| 80: | $this->user = $member_handler->loginUser(addslashes($username), addslashes($password));
|
| 81: | if (!is_object($this->user)) {
|
| 82: | unset($this->user);
|
| 83: |
|
| 84: | return false;
|
| 85: | }
|
| 86: |
|
| 87: | $moduleperm_handler = xoops_getHandler('groupperm');
|
| 88: | if (!$moduleperm_handler->checkRight('module_read', $this->module->getVar('mid'), $this->user->getGroups())) {
|
| 89: | unset($this->user);
|
| 90: |
|
| 91: | return false;
|
| 92: | }
|
| 93: |
|
| 94: | return true;
|
| 95: | }
|
| 96: |
|
| 97: | |
| 98: | |
| 99: |
|
| 100: | public function _checkAdmin()
|
| 101: | {
|
| 102: | if ($this->isadmin) {
|
| 103: | return true;
|
| 104: | }
|
| 105: | if (!isset($this->user)) {
|
| 106: | return false;
|
| 107: | }
|
| 108: | if (!$this->user->isAdmin($this->module->getVar('mid'))) {
|
| 109: | return false;
|
| 110: | }
|
| 111: | $this->isadmin = true;
|
| 112: |
|
| 113: | return true;
|
| 114: | }
|
| 115: |
|
| 116: | |
| 117: | |
| 118: | |
| 119: | |
| 120: | |
| 121: |
|
| 122: | public function &_getPostFields($post_id = null, $blog_id = null)
|
| 123: | {
|
| 124: | $ret = array();
|
| 125: | $ret['title'] = array('required' => true, 'form_type' => 'textbox', 'value_type' => 'text');
|
| 126: | $ret['hometext'] = array('required' => false, 'form_type' => 'textarea', 'data_type' => 'textarea');
|
| 127: | $ret['moretext'] = array('required' => false, 'form_type' => 'textarea', 'data_type' => 'textarea');
|
| 128: | $ret['categories'] = array('required' => false, 'form_type' => 'select_multi', 'data_type' => 'array');
|
| 129: |
|
| 130: | |
| 131: | |
| 132: | |
| 133: | |
| 134: | |
| 135: | |
| 136: | |
| 137: | |
| 138: | |
| 139: | |
| 140: | |
| 141: | |
| 142: |
|
| 143: |
|
| 144: | return $ret;
|
| 145: | }
|
| 146: |
|
| 147: | |
| 148: | |
| 149: | |
| 150: |
|
| 151: | public function _setXoopsTagMap($xoopstag, $blogtag)
|
| 152: | {
|
| 153: | if (trim($blogtag) != '') {
|
| 154: | $this->xoopsTagMap[$xoopstag] = $blogtag;
|
| 155: | }
|
| 156: | }
|
| 157: |
|
| 158: | |
| 159: | |
| 160: | |
| 161: | |
| 162: |
|
| 163: | public function _getXoopsTagMap($xoopstag)
|
| 164: | {
|
| 165: | if (isset($this->xoopsTagMap[$xoopstag])) {
|
| 166: | return $this->xoopsTagMap[$xoopstag];
|
| 167: | }
|
| 168: |
|
| 169: | return $xoopstag;
|
| 170: | }
|
| 171: |
|
| 172: | |
| 173: | |
| 174: | |
| 175: | |
| 176: | |
| 177: | |
| 178: |
|
| 179: | public function _getTagCdata(&$text, $tag, $remove = true)
|
| 180: | {
|
| 181: | $ret = '';
|
| 182: | $match = array();
|
| 183: | if (preg_match("/\<" . $tag . "\>(.*)\<\/" . $tag . "\>/is", $text, $match)) {
|
| 184: | if ($remove) {
|
| 185: | $text = str_replace($match[0], '', $text);
|
| 186: | }
|
| 187: | $ret = $match[1];
|
| 188: | }
|
| 189: |
|
| 190: | return $ret;
|
| 191: | }
|
| 192: |
|
| 193: |
|
| 194: |
|
| 195: | |
| 196: | |
| 197: | |
| 198: | |
| 199: |
|
| 200: | public function &_getXoopsApi(&$params)
|
| 201: | {
|
| 202: | if (strtolower(get_class($this)) !== 'xoopsapi') {
|
| 203: | require_once(XOOPS_ROOT_PATH . '/class/xml/rpc/xoopsapi.php');
|
| 204: |
|
| 205: | return new XoopsApi($params, $this->response, $this->module);
|
| 206: | } else {
|
| 207: | return $this;
|
| 208: | }
|
| 209: | }
|
| 210: | }
|
| 211: | |