本文整理汇总了PHP中EasyBlogHelper::uploadCategoryAvatar方法的典型用法代码示例。如果您正苦于以下问题:PHP EasyBlogHelper::uploadCategoryAvatar方法的具体用法?PHP EasyBlogHelper::uploadCategoryAvatar怎么用?PHP EasyBlogHelper::uploadCategoryAvatar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EasyBlogHelper
的用法示例。
在下文中一共展示了EasyBlogHelper::uploadCategoryAvatar方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
function save()
{
// Check for request forgeries
JRequest::checkToken() or jexit('Invalid Token');
// @task: Check for acl rules.
$this->checkAccess('category');
$mainframe = JFactory::getApplication();
$message = '';
$type = 'message';
if (JRequest::getMethod() == 'POST') {
$post = JRequest::get('post');
if (empty($post['title'])) {
$mainframe->enqueueMessage(JText::_('COM_EASYBLOG_CATEGORIES_INVALID_CATEGORY'), 'error');
$url = 'index.php?option=com_easyblog&view=category';
$mainframe->redirect(JRoute::_($url, false));
return;
}
$category = EasyBlogHelper::getTable('Category', 'Table');
$user = JFactory::getUser();
if (!isset($post['created_by']) || empty($post['created_by'])) {
$post['created_by'] = $user->id;
}
$post['description'] = JRequest::getVar('description', '', 'REQUEST', 'none', JREQUEST_ALLOWHTML);
$catId = JRequest::getVar('catid', '');
$isNew = empty($catId) ? true : false;
if (!empty($catId)) {
$category->load($catId);
}
$category->bind($post);
if (!$category->store()) {
JError::raiseError(500, $category->getError());
} else {
//save the category acl
$category->deleteACL();
if ($category->private == CATEGORY_PRIVACY_ACL) {
$category->saveACL($post);
}
// Set the meta for the category
$category->createMeta();
// AlphaUserPoints
// since 1.2
if ($isNew && EasyBlogHelper::isAUPEnabled()) {
AlphaUserPointsHelper::newpoints('plgaup_easyblog_add_category', '', 'easyblog_add_category_' . $category->id, JText::sprintf('AUP NEW CATEGORY CREATED', $post['title']));
}
$file = JRequest::getVar('Filedata', '', 'files', 'array');
if (!empty($file['name'])) {
$newAvatar = EasyBlogHelper::uploadCategoryAvatar($category, true);
$category->avatar = $newAvatar;
$category->store();
//now update the avatar.
}
$message = JText::_('COM_EASYBLOG_CATEGORIES_SAVED_SUCCESS');
}
} else {
$message = JText::_('COM_EASYBLOG_INVALID_REQUEST');
$type = 'error';
}
// Redirect to new form once again if necessary
$saveNew = JRequest::getInt('savenew', 0);
if ($saveNew) {
$mainframe->redirect('index.php?option=com_easyblog&view=category', $message, $type);
$mainframe->close();
}
$mainframe->redirect('index.php?option=com_easyblog&view=categories', $message, $type);
}
示例2: saveCategory
function saveCategory()
{
$id = JRequest::getVar('id', '');
$acl = EasyBlogACLHelper::getRuleSet();
$my = JFactory::getUser();
$redirect = EasyBlogRouter::_('index.php?option=com_easyblog&view=dashboard&layout=categories', false);
$mainframe = JFactory::getApplication();
// @rule: Sanity checks
if (empty($id)) {
EasyBlogHelper::setMessageQueue(JText::_('COM_EASYBLOG_DASHBOARD_CATEGORIES_ID_IS_EMPTY_ERROR'), 'error');
$mainframe->redirect($redirect);
$mainframe->close();
}
// @rule: Check if the user is really allowed to create category.
if (!$acl->rules->create_category) {
EasyBlogHelper::setMessageQueue(JText::_('COM_EASYBLOG_NOT_ALLOWED'), 'error');
$mainframe->redirect($redirect);
$mainframe->close();
}
// @rule: Check if the user is really allowed to edit this category
$category = EasyBlogHelper::getTable('Category', 'Table');
$category->load($id);
if ($category->id && $category->created_by != $my->id && !EasyBlogHelper::isSiteAdmin()) {
EasyBlogHelper::setMessageQueue(JText::_('COM_EASYBLOG_NOT_ALLOWED'), 'error');
$mainframe->redirect($redirect);
$mainframe->close();
}
$post = JRequest::get('POST');
$post['description'] = JRequest::getVar('description', '', 'REQUEST', 'none', JREQUEST_ALLOWHTML);
$category->bind($post);
$model = $this->getModel('Category');
if ($model->isExist($category->title, $category->id)) {
EasyBlogHelper::setMessageQueue(JText::_('COM_EASYBLOG_DASHBOARD_CATEGORIES_ALREADY_EXISTS_ERROR'), 'error');
$mainframe->redirect($redirect);
$mainframe->close();
}
$avatar = JRequest::getVar('Filedata', '', 'files', 'array');
if (isset($avatar['name']) && !empty($avatar['name'])) {
$category->avatar = EasyBlogHelper::uploadCategoryAvatar($category);
}
$category->store();
//save acl
$category->deleteACL();
if ($category->private == CATEGORY_PRIVACY_ACL) {
$category->saveACL($post);
}
EasyBlogHelper::setMessageQueue(JText::_('COM_EASYBLOG_DASHBOARD_CATEGORIES_UPDATED_SUCCESSFULLY'), 'success');
$mainframe->redirect($redirect);
$mainframe->close();
}