XOOPS  2.6.0
xmlrpcapi.php
Go to the documentation of this file.
1 <?php
2 /*
3  You may not change or alter any portion of this comment or credits
4  of supporting developers from this source code or any supporting source code
5  which is considered copyrighted (c) material of the original comment or credit authors.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 */
11 
23 {
24 
25  // reference to method parameters
26  protected $params;
27 
28  // reference to xmlrpc document class object
32  protected $response;
33 
34  // reference to module class object
38  protected $module;
39 
40  // map between xoops tags and blogger specific tags
41  protected $xoopsTagMap = array();
42 
43  // user class object
44  protected $user;
45 
46  protected $isadmin = false;
47 
48 
50  {
51  $this->params = $params;
52  $this->response = $response;
53  $this->module = $module;
54  }
55 
56  function _setUser(XoopsUser &$user, $isadmin = false)
57  {
58  if (is_object($user)) {
59  $this->user = $user;
60  $this->isadmin = $isadmin;
61  }
62  }
63 
64  function _checkUser($username, $password)
65  {
67 
68  $member_handler = $xoops->getHandlerMember();
69  $this->user = $member_handler->loginUser(addslashes($username), addslashes($password));
70  if (!is_object($this->user)) {
71  $this->user = null;
72  return false;
73  }
74  $moduleperm_handler = $xoops->getHandlerGroupperm();
75  if (!$moduleperm_handler->checkRight('module_read', $this->module->getVar('mid'), $this->user->getGroups())) {
76  $this->user = null;
77  return false;
78  }
79  return true;
80  }
81 
82  function _checkAdmin()
83  {
84  if ($this->isadmin) {
85  return true;
86  }
87  if (!is_object($this->user)) {
88  return false;
89  }
90  if (!$this->user->isAdmin($this->module->getVar('mid'))) {
91  return false;
92  }
93  $this->isadmin = true;
94  return true;
95  }
96 
97  function _getPostFields($post_id = null, $blog_id = null)
98  {
99  $ret = array();
100  $ret['title'] = array('required' => true, 'form_type' => 'textbox', 'value_type' => 'text');
101  $ret['hometext'] = array('required' => false, 'form_type' => 'textarea', 'data_type' => 'textarea');
102  $ret['moretext'] = array('required' => false, 'form_type' => 'textarea', 'data_type' => 'textarea');
103  $ret['categories'] = array('required' => false, 'form_type' => 'select_multi', 'data_type' => 'array');
104  /*
105  if (!isset($blog_id)) {
106  if (!isset($post_id)) {
107  return false;
108  }
109  $itemman = $this->mf->get(MANAGER_ITEM);
110  $item = $itemman->get($post_id);
111  $blog_id = $item->getVar('sect_id');
112  }
113  $sectman = $this->mf->get(MANAGER_SECTION);
114  $this->section = $sectman->get($blog_id);
115  $ret = $this->section->getVar('sect_fields');
116  */
117  return $ret;
118  }
119 
124  function _setXoopsTagMap($xoopstag, $blogtag)
125  {
126  if (trim($blogtag) != '') {
127  $this->xoopsTagMap[$xoopstag] = $blogtag;
128  }
129  }
130 
131  function _getXoopsTagMap($xoopstag)
132  {
133  if (isset($this->xoopsTagMap[$xoopstag])) {
134  return $this->xoopsTagMap[$xoopstag];
135  }
136  return $xoopstag;
137  }
138 
139  function _getTagCdata(&$text, $tag, $remove = true)
140  {
141  $ret = '';
142  $match = array();
143  if (preg_match("/<" . $tag . ">(.*)<\/" . $tag . ">/is", $text, $match)) {
144  if ($remove) {
145  $text = str_replace($match[0], '', $text);
146  }
147  $ret = $match[1];
148  }
149  return $ret;
150  }
151 
152  // kind of dirty method to load XOOPS API and create a new object thereof
153  // returns itself if the calling object is XOOPS API
155  {
156  if (strtolower(get_class($this)) != 'xoopsapi') {
158  require_once($xoops_root_path . '/class/xml/rpc/xoopsapi.php');
159  return new XoopsApi($params, $this->response, $this->module);
160  } else {
161  return $this;
162  }
163  }
164 }
165 
166 ?>
if($uname== ''||$pass== '') $member_handler
Definition: checklogin.php:44
_getXoopsApi(&$params)
Definition: xmlrpcapi.php:154
static getInstance()
Definition: Xoops.php:160
$text
Definition: qrrender.php:27
_getTagCdata(&$text, $tag, $remove=true)
Definition: xmlrpcapi.php:139
XoopsXmlRpcApi(array &$params, XoopsXmlRpcResponse &$response, XoopsModule &$module)
Definition: xmlrpcapi.php:49
_getPostFields($post_id=null, $blog_id=null)
Definition: xmlrpcapi.php:97
$xoops
Definition: admin.php:25
if(DIRECTORY_SEPARATOR!="/") $xoops_root_path
Definition: config.php:7
_getXoopsTagMap($xoopstag)
Definition: xmlrpcapi.php:131
static get($name)
_checkUser($username, $password)
Definition: xmlrpcapi.php:64
_setXoopsTagMap($xoopstag, $blogtag)
Definition: xmlrpcapi.php:124
_setUser(XoopsUser &$user, $isadmin=false)
Definition: xmlrpcapi.php:56
$moduleperm_handler
Definition: cp_header.php:31