Example #1
0
 public function post()
 {
     // Set variables to be used
     APIHelper::setSessionUser();
     // Include dependencies
     jimport('joomla.database.table');
     $language = JFactory::getLanguage();
     $language->load('joomla', JPATH_ADMINISTRATOR);
     $language->load('com_categories', JPATH_ADMINISTRATOR);
     require_once JPATH_ADMINISTRATOR . '/components/com_categories/models/category.php';
     // Fake parameters
     $_POST['task'] = 'apply';
     $_REQUEST['task'] = 'apply';
     $_REQUEST[JUtility::getToken()] = 1;
     $_POST[JUtility::getToken()] = 1;
     $data = JRequest::getVar('jform', array(), 'post', 'array');
     $context = 'category';
     // Clear userstate just in case
     $model = APIodel::getInstance('Category', 'CategoriesModel');
     $success = $model->save($data);
     if ($model->getError()) {
         $response = $this->getErrorResponse(400, $model->getError());
     } elseif (!$success) {
         $response = $this->getErrorResponse(400, JText::_('COM_API_ERROR_OCURRED'));
     } else {
         $response = $this->getSuccessResponse(201, JText::_('COM_CATEGORIES_SAVE_SUCCESS'));
         // Get the ID of the category that was modified or inserted
         $response->id = $model->get('state')->get($context . '.id');
         // Checkin category
         $model->checkin($response->id);
     }
     $this->plugin->setResponse($response);
 }
Example #2
0
 public function post()
 {
     // Set variables to be used
     APIHelper::setSessionUser();
     JFactory::getLanguage()->load('com_users', JPATH_ADMINISTRATOR);
     // Include dependencies
     jimport('joomla.application.component.controller');
     jimport('joomla.form.form');
     jimport('joomla.database.table');
     APIodel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_users/models');
     JForm::addFormPath(JPATH_ADMINISTRATOR . '/components/com_users/models/forms');
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_users/tables');
     // Get user data
     $data = JRequest::getVar('jform', array(), 'post', 'array');
     if (!isset($data['groups'])) {
         $data['groups'] = array();
     }
     // Save user
     $model = APIodel::getInstance('User', 'UsersModel');
     $model->getState('user.id');
     // This is only here to trigger populateState()
     $success = $model->save($data);
     if ($model->getError()) {
         $response = $this->getErrorResponse(400, $model->getError());
     } elseif (!$success) {
         $response = $this->getErrorResponse(400, JText::_('COM_API_ERROR_OCURRED'));
     } else {
         $response = $this->getSuccessResponse(201, JText::_('COM_API_SUCCESS'));
         $response->id = $model->getState('user.id');
     }
     $this->plugin->setResponse($response);
 }
Example #3
0
 public function get()
 {
     require_once JPATH_ADMINISTRATOR . '/components/com_menus/models/menus.php';
     require_once JPATH_PLUGINS . '/api/menus/resources/helper.php';
     $model = APIodel::getInstance('APIHelperModel', 'MenusModel');
     $model->_setCache('getstart', $model->getState('list.start'));
     $menus = $model->getItems();
     if (false === $menus || empty($menus) && $model->getError()) {
         $response = $this->getErrorResponse(400, $model->getError());
     } else {
         $response = $menus;
     }
     $this->plugin->setResponse($response);
 }
Example #4
0
 public function get()
 {
     $extension = JRequest::getWord('extension');
     APIHelper::setSessionUser();
     require_once JPATH_ADMINISTRATOR . '/components/com_categories/models/categories.php';
     require_once JPATH_PLUGINS . '/api/categories/resources/helper.php';
     $model = APIodel::getInstance('APIHelperModel', 'CategoriesModel');
     $model->_setCache('getstart', $model->getState('list.start'));
     $categories = $model->getItems();
     if (false === $categories) {
         $response = $this->getErrorResponse(400, $model->getError());
     } else {
         $response = $categories;
     }
     $this->plugin->setResponse($response);
 }
Example #5
0
 public function get()
 {
     // Set variables to be used
     APIHelper::setSessionUser();
     APIodel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_users/models');
     $model = APIodel::getInstance('User', 'UsersModel');
     $grouplist = $model->getGroups();
     $groups = $model->getAssignedGroups(JRequest::getInt('user_id'));
     if (!$grouplist) {
         $html = '';
     } else {
         JHtml::addIncludePath(JPATH_ROOT . '/components/com_users/helpers/html');
         $html = JHtml::_('access.usergroups', 'jform[groups]', $groups, true);
     }
     $this->plugin->setResponse(array('html' => $html));
 }
Example #6
0
 public function delete($id = null)
 {
     // Include dependencies
     jimport('joomla.database.table');
     APIodel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_users/models');
     JFactory::getLanguage()->load('com_users', JPATH_ADMINISTRATOR);
     $model = APIodel::getInstance('User', 'UsersModel');
     try {
         $success = $model->delete(JRequest::getVar('cid', array(), 'post', 'array'));
     } catch (JException $e) {
         $success = false;
         $model->setError($e->getMessage());
     }
     if ($model->getError()) {
         $response = $this->getErrorResponse(400, $model->getError());
     } elseif (false === $success) {
         $response = $this->getErrorResponse(400, JText::_('COM_API_ERROR_OCURRED'));
     } else {
         $response = $this->getSuccessResponse(200, JText::_('COM_API_SUCCESS'));
     }
     $this->plugin->setResponse($response);
 }
Example #7
0
 public function get()
 {
     require_once JPATH_ADMINISTRATOR . '/components/com_menus/models/item.php';
     $model = APIodel::getInstance('item', 'MenusModel');
     $this->plugin->setResponse($model->getItem(JRequest::getInt('id', 0))->getProperties());
 }
Example #8
0
 public function get()
 {
     require_once JPATH_ADMINISTRATOR . '/components/com_content/models/article.php';
     $model = APIodel::getInstance('article', 'contentModel');
     $this->plugin->setResponse($model->getItem(JRequest::getInt('id', 0))->getProperties());
 }