本文整理汇总了PHP中DiscussHelper::uploadCategoryAvatar方法的典型用法代码示例。如果您正苦于以下问题:PHP DiscussHelper::uploadCategoryAvatar方法的具体用法?PHP DiscussHelper::uploadCategoryAvatar怎么用?PHP DiscussHelper::uploadCategoryAvatar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DiscussHelper
的用法示例。
在下文中一共展示了DiscussHelper::uploadCategoryAvatar方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
public function save()
{
// Check for request forgeries
JRequest::checkToken() or jexit('Invalid Token');
$mainframe = JFactory::getApplication();
$task = $this->getTask();
$message = '';
$type = 'success';
if (JRequest::getMethod() == 'POST') {
$post = JRequest::get('post');
if (empty($post['title'])) {
DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_CATEGORIES_INVALID_CATEGORY'), DISCUSS_QUEUE_ERROR);
$url = 'index.php?option=com_easydiscuss&view=categories';
$mainframe->redirect(JRoute::_($url, false));
return;
}
$category = JTable::getInstance('Category', 'Discuss');
$user = JFactory::getUser();
$post['created_by'] = $user->id;
$catId = JRequest::getVar('catid', '');
$isNew = empty($catId) ? true : false;
$alterOrdering = true;
if (!empty($catId)) {
$category->load($catId);
$newParentId = $post['parent_id'];
if ($category->parent_id != $newParentId) {
$alterOrdering = true;
} else {
$alterOrdering = false;
}
$post['id'] = $catId;
}
$category->bind($post);
// Description might contain html codes
$description = JRequest::getVar('description', '', 'post', 'string', JREQUEST_ALLOWRAW);
$category->description = $description;
// Bind params
$params = DiscussHelper::getRegistry('');
$params->set('show_description', $post['show_description']);
$params->set('maxlength', $post['maxlength']);
$params->set('maxlength_size', $post['maxlength_size']);
$params->set('cat_notify_custom', $post['cat_notify_custom']);
$params->set('cat_email_parser', $post['cat_email_parser']);
$params->set('cat_email_parser_password', $post['cat_email_parser_password']);
$params->set('cat_email_parser_switch', $post['cat_email_parser_switch']);
$category->params = $params->toString();
if (!$category->store($alterOrdering)) {
JError::raiseError(500, $category->getError());
exit;
}
//save the category acl
$category->deleteACL();
$category->saveACL($post);
$file = JRequest::getVar('Filedata', '', 'files', 'array');
if (!empty($file['name'])) {
$newAvatar = DiscussHelper::uploadCategoryAvatar($category, true);
$category->avatar = $newAvatar;
$category->store();
//now update the avatar.
}
// now we need to rerun the category ordering incase admin assign the correct category tree as a child of another category.
$category->rebuildOrdering();
$message = JText::_('COM_EASYDISCUSS_CATEGORIES_SAVED_SUCCESS');
} else {
$message = JText::_('COM_EASYDISCUSS_INVALID_REQUEST');
$type = 'error';
}
DiscussHelper::setMessageQueue($message, $type);
if ($task == 'savePublishNew') {
$mainframe->redirect('index.php?option=com_easydiscuss&view=category');
$mainframe->close();
}
if ($task == 'apply') {
$mainframe->redirect('index.php?option=com_easydiscuss&view=category&catid=' . $category->id);
$mainframe->close();
}
$mainframe->redirect('index.php?option=com_easydiscuss&view=categories');
$mainframe->close();
}