當前位置: 首頁>>代碼示例>>PHP>>正文


PHP EasyBlogHelper::uploadCategoryAvatar方法代碼示例

本文整理匯總了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);
 }
開發者ID:alexinteam,項目名稱:joomla3,代碼行數:65,代碼來源:category.php

示例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();
 }
開發者ID:Tommar,項目名稱:vino2,代碼行數:50,代碼來源:dashboard.php


注:本文中的EasyBlogHelper::uploadCategoryAvatar方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。