当前位置: 首页>>代码示例>>PHP>>正文


PHP DiscussHelper::uploadCategoryAvatar方法代码示例

本文整理汇总了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();
 }
开发者ID:BetterBetterBetter,项目名称:B3App,代码行数:79,代码来源:category.php


注:本文中的DiscussHelper::uploadCategoryAvatar方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。