Open Journal Systems  3.0.0
 All Classes 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  $json = new JSONMessage(true, $settingsForm->fetch($args, $request));
45 
46  return $json->getString();
47  }
48 
55  function updateContext($args, $request) {
56  // Identify the context Id.
57  $contextId = $request->getUserVar('contextId');
58 
59  // Form handling.
60  $settingsForm = new JournalSiteSettingsForm($contextId);
61  $settingsForm->readInputData();
62 
63  if (!$settingsForm->validate()) {
64  $json = new JSONMessage(false);
65  return $json->getString();
66  }
67 
69 
70  // The context settings form will return a context path in two cases:
71  // 1 - if a new context was created;
72  // 2 - if a press path of an existing context was edited.
73  $newContextPath = $settingsForm->execute($request);
74 
75  // Create the notification.
76  $notificationMgr = new NotificationManager();
77  $user = $request->getUser();
78  $notificationMgr->createTrivialNotification($user->getId());
79 
80  // Check for the two cases above.
81  if ($newContextPath) {
82  $context = $request->getContext();
83 
84  if (is_null($contextId)) {
85  // CASE 1: new press created.
86  // Create notification related to payment method configuration.
87  $contextDao = Application::getContextDAO();
88  $newContext = $contextDao->getByPath($newContextPath);
89  $notificationMgr->createNotification($request, null, NOTIFICATION_TYPE_CONFIGURE_PAYMENT_METHOD,
90  $newContext->getId(), ASSOC_TYPE_JOURNAL, $newContext->getId(), NOTIFICATION_LEVEL_NORMAL);
91 
92  // redirect and set the parameter to open the press
93  // setting wizard modal after redirection.
94  return $this->_getRedirectEvent($request, $newContextPath, true);
95  } else {
96  // CASE 2: check if user is in the context of
97  // the press being edited.
98  if ($context && $context->getId() == $contextId) {
99  return $this->_getRedirectEvent($request, $newContextPath, false);
100  }
101  }
102  }
103  return DAO::getDataChangedEvent($contextId);
104  }
105 
112  function deleteContext($args, $request) {
113  // Identify the journal Id.
114  $journalId = $request->getUserVar('rowId');
115  $journalDao = DAORegistry::getDAO('JournalDAO');
116  $journal = $journalDao->getById($journalId);
117 
118  if ($journal) {
119  $journalDao->deleteById($journalId);
120 
121  // Delete journal file tree
122  // FIXME move this somewhere better.
123  import('lib.pkp.classes.file.FileManager');
124  $fileManager = new FileManager($journalId);
125  $journalPath = Config::getVar('files', 'files_dir') . '/journals/' . $journalId;
126  $fileManager->rmtree($journalPath);
127 
128  import('classes.file.PublicFileManager');
129  $publicFileManager = new PublicFileManager();
130  $publicFileManager->rmtree($publicFileManager->getJournalFilesPath($journalId));
131 
132  return DAO::getDataChangedEvent($journalId);
133  }
134 
135  $json = new JSONMessage(false);
136  return $json->getString();
137  }
138 }
139 
140 ?>
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
static getDataChangedEvent($elementId=null, $parentElementId=null)
Definition: DAO.inc.php:606
_getRedirectEvent($request, $newContextPath, $openWizard)
editContext($args, $request)
Handle context grid requests.
static getContextDAO()
Form for site administrator to edit basic journal settings.
Handle journal grid requests.