public function upload()
 {
     // Check for token
     JSession::checkToken() or K2Response::throwError(JText::_('JINVALID_TOKEN'));
     // Get user
     $user = JFactory::getUser();
     // Permissions check
     if (!$user->authorise('k2.item.create', 'com_k2') && !$user->authorise('k2.item.edit', 'com_k2') && !$user->authorise('k2.item.edit.own', 'com_k2')) {
         K2Response::throwError(JText::_('K2_YOU_ARE_NOT_AUTHORIZED_TO_PERFORM_THIS_OPERATION'), 403);
     }
     // Get input
     $input = JFactory::getApplication()->input;
     $upload = $input->get('upload', '', 'cmd');
     $url = $input->get('url', '', 'string');
     $archive = $input->files->get('archive');
     // Create the gallery and delete the previous one if it is set
     $gallery = K2HelperGalleries::add($archive, $url, $upload);
     // Response
     echo json_encode($gallery);
     // Return
     return $this;
 }
Esempio n. 2
0
 /**
  * Close method.
  *
  * @return boolean	True on success false on failure.
  */
 public function close()
 {
     // Clean up any temporary images and files
     K2HelperImages::purge('item');
     K2HelperGalleries::purge();
     K2HelperMedia::purge();
     K2HelperAttachments::purge();
     return true;
 }