Open Journal Systems  3.0.0
 All Data Structures Namespaces Functions Variables Groups Pages
JournalGridHandler.inc.php
1 <?php
2 
16 import('lib.pkp.controllers.grid.admin.context.ContextGridHandler');
17 import('controllers.grid.admin.journal.form.JournalSiteSettingsForm');
18 
23  function JournalGridHandler() {
24  parent::ContextGridHandler();
25  }
26 
27 
28  //
29  // Public grid actions.
30  //
37  function editContext($args, $request) {
38  // Get the journal ID. (Not the same as the context!)
39  $journalId = $request->getUserVar('rowId');
40 
41  // Form handling.
42  $settingsForm = new JournalSiteSettingsForm(!isset($journalId) || empty($journalId) ? null : $journalId);
43  $settingsForm->initData();
44  return new JSONMessage(true, $settingsForm->fetch($args, $request));
45  }
46 
53  function updateContext($args, $request) {
54  // Identify the context Id.
55  $contextId = $request->getUserVar('contextId');
56 
57  // Form handling.
58  $settingsForm = new JournalSiteSettingsForm($contextId);
59  $settingsForm->readInputData();
60 
61  if (!$settingsForm->validate()) {
62  return new JSONMessage(false);
63  }
64 
66 
67  // The context settings form will return a context path in two cases:
68  // 1 - if a new context was created;
69  // 2 - if a press path of an existing context was edited.
70  $newContextPath = $settingsForm->execute($request);
71 
72  // Create the notification.
73  $notificationMgr = new NotificationManager();
74  $user = $request->getUser();
75  $notificationMgr->createTrivialNotification($user->getId());
76 
77  // Check for the two cases above.
78  if ($newContextPath) {
79  $context = $request->getContext();
80 
81  if (is_null($contextId)) {
82  // CASE 1: new press created.
83  // Create notification related to payment method configuration.
84  $contextDao = Application::getContextDAO();
85  $newContext = $contextDao->getByPath($newContextPath);
86  $notificationMgr->createNotification($request, null, NOTIFICATION_TYPE_CONFIGURE_PAYMENT_METHOD,
87  $newContext->getId(), ASSOC_TYPE_JOURNAL, $newContext->getId(), NOTIFICATION_LEVEL_NORMAL);
88 
89  // redirect and set the parameter to open the press
90  // setting wizard modal after redirection.
91  return $this->_getRedirectEvent($request, $newContextPath, true);
92  } else {
93  // CASE 2: check if user is in the context of
94  // the press being edited.
95  if ($context && $context->getId() == $contextId) {
96  return $this->_getRedirectEvent($request, $newContextPath, false);
97  }
98  }
99  }
100  return DAO::getDataChangedEvent($contextId);
101  }
102 
109  function deleteContext($args, $request) {
110  // Identify the journal Id.
111  $journalId = $request->getUserVar('rowId');
112  $journalDao = DAORegistry::getDAO('JournalDAO');
113  $journal = $journalDao->getById($journalId);
114 
115  if ($journal) {
116  $journalDao->deleteById($journalId);
117 
118  // Delete journal file tree
119  // FIXME move this somewhere better.
120  import('lib.pkp.classes.file.FileManager');
121  $fileManager = new FileManager($journalId);
122  $journalPath = Config::getVar('files', 'files_dir') . '/journals/' . $journalId;
123  $fileManager->rmtree($journalPath);
124 
125  import('classes.file.PublicFileManager');
126  $publicFileManager = new PublicFileManager();
127  $publicFileManager->rmtree($publicFileManager->getJournalFilesPath($journalId));
128 
129  return DAO::getDataChangedEvent($journalId);
130  }
131 
132  return new JSONMessage(false);
133  }
134 }
135 
136 ?>
static & getDAO($name, $dbconn=null)
Wrapper class for uploading files to a site/journal&#39;s public directory.
deleteContext($args, $request)
updateContext($args, $request)
static & loadCategory($category, $enabledOnly=false, $mainContextId=null)
Class defining basic operations for file management.
Class to represent a JSON (Javascript Object Notation) message.
static getVar($section, $key, $default=null)
Definition: Config.inc.php:35
_getRedirectEvent($request, $newContextPath, $openWizard)
editContext($args, $request)
Handle context grid requests.
static getContextDAO()
static getDataChangedEvent($elementId=null, $parentElementId=null, $content= '')
Definition: DAO.inc.php:633
Form for site administrator to edit basic journal settings.
Handle journal grid requests.