function createsubcategory() { JRequest::checkToken() or jexit('Invalid Token'); $task = $this->input->get('task', '', 'string'); $post['title'] = $this->input->get('subcategoryname', '', 'string'); $post['description'] = $this->input->get('phocagallerycreatesubcatdescription', '', 'string'); $post['parent_id'] = $this->input->get('parentcategoryid', 0, 'int'); $task = $this->input->get('task', '', 'string'); $post['title'] = $this->input->get('subcategoryname', '', 'string'); $post['description'] = $this->input->get('phocagallerycreatesubcatdescription', '', 'string'); $post['parent_id'] = $this->input->get('parentcategoryid', 0, 'int'); $catid = $this->input->get('catid', '', 'string'); $tab = $this->input->get('tab', 0, 'int'); $Itemid = $this->input->get('Itemid', 0, 'int'); $limitStart = $this->input->get('limitstart', 0, 'int'); $catid = (int) $catid; $paramsC = JComponentHelper::getParams('com_phocagallery'); $maxCreateCatChar = $paramsC->get('max_create_cat_char', 1000); $enableUserSubCatApprove = $paramsC->get('enable_usersubcat_approve', 0); $enableDirectSubCat = $paramsC->get('enable_direct_subcat', 0); $post['description'] = substr($post['description'], 0, (int) $maxCreateCatChar); $post['alias'] = $post['title']; //PhocaGalleryText::getAliasName($post['title']); $post['aliasfolder'] = PhocaGalleryText::getAliasName($post['title']); $model = $this->getModel('user'); $userSubCatCount = $paramsC->get('user_subcat_count', 5); $user = JFactory::getUser(); $post['approved'] = 0; $id = $catid; if ($enableUserSubCatApprove == 0) { $post['approved'] = 1; } if ($limitStart > 0) { $limitStartUrl = '&limitstart=' . $limitStart; } else { $limitStartUrl = ''; } // Lang $userLang = PhocaGalleryUser::getUserLang(); $post['language'] = $userLang['lang']; $neededAccessLevels = PhocaGalleryAccess::getNeededAccessLevels(); $access = PhocaGalleryAccess::isAccess($user->getAuthorisedViewLevels(), $neededAccessLevels); $app = JFactory::getApplication(); // USER IS NOT LOGGED if (!$access) { $app->enqueueMessage($this->_loginstr); $app->redirect($this->_loginurl); exit; } if ($enableDirectSubCat != 1) { $msg = JText::_('COM_PHOCAGALLERY_NOT_AUTHORISED_ACTION'); $app->enqueueMessage($msg); $this->setRedirect(JRoute::_('index.php?option=com_phocagallery&view=category&id=' . $id . '&tab=' . $tab . '&Itemid=' . $Itemid . $limitStartUrl, false)); return; } if ((int) $post['parent_id'] < 1) { $msg = JText::_('COM_PHOCAGALLERY_PARENT_CATEGORY_NOT_SELECTED'); $app->enqueueMessage($msg); $this->setRedirect(JRoute::_('index.php?option=com_phocagallery&view=category&id=' . $id . '&tab=' . $tab . '&Itemid=' . $Itemid . $limitStartUrl, false)); return; } // $isOwnerCategory = $model->isOwnerCategory($this->_user->id, (int)$post['parent_id']); // $limitStartUrl = $this->getLimitStartUrl(0, 'subcat', (int)$isOwnerCategory ); // if(!$isOwnerCategory) { // $msg = JText::_( 'COM_PHOCAGALLERY_PARENT_CATEGORY_NOT_ASSIGNED_TO_USER' ); // $app->redirect(JRoute::_($this->_url. $limitStartUrl->subcat . $limitStartUrl->image, false), $msg); // exit; // } $subCatCount = $model->getCountUserSubCat($user->id); $subCatCount = (int) $subCatCount + 1; if ((int) $subCatCount > (int) $userSubCatCount) { $msg = JText::_('COM_PHOCAGALLERY_MAX_SUBCAT_COUNT_REACHED'); $app->enqueueMessage($msg); $this->setRedirect(JRoute::_('index.php?option=com_phocagallery&view=category&id=' . $id . '&tab=' . $tab . '&Itemid=' . $Itemid . $limitStartUrl, false)); return; } $ownerMainCategory = $model->getOwnerMainCategory($user->id); if (!$ownerMainCategory) { // - - - - - // NEW // - - - - - $msg = ''; // Create an user folder on the server $userFolder = PhocaGalleryText::getAliasName($user->username) . '-' . substr($post['aliasfolder'], 0, 10) . '-' . substr(md5(uniqid(time())), 0, 4); $errorMsg = ''; $createdFolder = PhocaGalleryFileFolder::createFolder($userFolder, $errorMsg); if ($errorMsg != '') { $msg = JText::_('COM_PHOCAGALLERY_ERROR_FOLDER_CREATING') . ': ' . JText::_($errorMsg); $app->enqueueMessage($msg); $this->setRedirect(JRoute::_('index.php?option=com_phocagallery&view=category&id=' . $id . '&tab=' . $tab . '&Itemid=' . $Itemid . $limitStartUrl, false)); return false; } } else { $userFolder = $ownerMainCategory->userfolder; } if ($post['title'] != '') { $post['access'] = 0; $post['image_position'] = 'left'; $post['published'] = 1; $post['accessuserid'] = '-1'; $post['uploaduserid'] = $user->id; $post['deleteuserid'] = $user->id; $post['userfolder'] = $userFolder; $post['owner_id'] = $user->id; $id = $model->store($post); if ($id && $id > 0) { $msg = JText::_('COM_PHOCAGALLERY_SUCCESS_CREATING_CATEGORY'); } else { $msg = JText::_('COM_PHOCAGALLERY_ERROR_CREATING_CATEGORY'); } } else { $msg = JText::_('COM_PHOCAGALLERY_ERROR_TITLE'); } $app->enqueueMessage($msg); $this->setRedirect(JRoute::_('index.php?option=com_phocagallery&view=category&id=' . $id . '&Itemid=' . $Itemid . $limitStartUrl, false)); }
function editimage() { JRequest::checkToken() or jexit('Invalid Token'); $task = JRequest::getVar('task', '', 'post', 'string', 0); $post['title'] = JRequest::getVar('imagename', '', 'post', 'string', 0); $post['description'] = JRequest::getVar('phocagalleryuploaddescription', '', 'post', 'string', 0); $post['id'] = JRequest::getVar('id', 0, 'post', 'int'); $paramsC = JComponentHelper::getParams('com_phocagallery'); $maxCreateCatChar = $paramsC->get('max_create_cat_char', 1000); $post['description'] = substr($post['description'], 0, (int) $maxCreateCatChar); $post['alias'] = $post['title']; //PhocaGalleryText::getAliasName($post['title']); $model = $this->getModel('user'); // Lang $userLang = PhocaGalleryUser::getUserLang(); $post['language'] = $userLang['lang']; $app = JFactory::getApplication(); // USER IS NOT LOGGED if ($this->_user->aid < 1 && $this->_user->id < 1) { $app->redirect($this->_loginurl, $this->_loginstr); exit; } $isOwnerCategory = $model->isOwnerCategoryImage($this->_user->id, (int) $post['id']); if (!$isOwnerCategory) { $msg = JText::_('COM_PHOCAGALLERY_PARENT_CATEGORY_NOT_ASSIGNED_TO_USER'); $app->redirect(JRoute::_($this->_url . $limitStartUrl->subcat . $limitStartUrl->image, false), $msg); exit; } if ((int) $post['id'] < 1) { $msg = JText::_('COM_PHOCAGALLERY_PARENT_CATEGORY_NOT_SELECTED'); $app->redirect(JRoute::_($this->_url . $limitStartUrl->subcat . $limitStartUrl->image, false), $msg); exit; } $ownerMainCategory = $model->getOwnerMainCategory($this->_user->id); if (!$ownerMainCategory) { $msg = JText::_('COM_PHOCAGALLERY_MAIN_CATEGORY_NOT_CREATED'); $app->redirect(JRoute::_($this->_url . $limitStartUrl->subcat . $limitStartUrl->image, false), $msg); } if ($post['title'] != '') { $id = $model->storeimage($post, '', 1); if ($id && $id > 0) { $msg = JText::_('COM_PHOCAGALLERY_SUCCESS_SAVING_ITEM'); } else { $msg = JText::_('COM_PHOCAGALLERY_ERROR_SAVING_ITEM'); } } else { $msg = JText::_('COM_PHOCAGALLERY_ERROR_TITLE'); } $this->setRedirect(JRoute::_($this->_url . $limitStartUrl->subcat . $limitStartUrl->image, false), $msg); }