Open Monograph Press  1.1
 All Classes Namespaces Functions Variables Groups Pages
PKPAuthorGridRow.inc.php
1 <?php
2 
16 import('lib.pkp.classes.controllers.grid.GridRow');
17 
18 class PKPAuthorGridRow extends GridRow {
20  var $_submission;
21 
23  var $_reaadOnly;
24 
28  function PKPAuthorGridRow($submission, $readOnly = false) {
29  $this->_submission = $submission;
30  $this->_readOnly = $readOnly;
31  parent::GridRow();
32  }
33 
34  //
35  // Overridden methods from GridRow
36  //
41  function initialize($request) {
42  // Do the default initialization
43  parent::initialize($request);
44 
45  // Retrieve the submission from the request
46  $submission = $this->getSubmission();
47 
48  // Is this a new row or an existing row?
49  $rowId = $this->getId();
50  if (!empty($rowId) && is_numeric($rowId)) {
51  // Only add row actions if this is an existing row
52  $router = $request->getRouter();
53  $actionArgs = $this->getRequestArgs();
54  $actionArgs['authorId'] = $rowId;
55 
56  if ($this->canAdminister($request)) {
57  // Add row-level actions
58  import('lib.pkp.classes.linkAction.request.AjaxModal');
59  $this->addAction(
60  new LinkAction(
61  'editAuthor',
62  new AjaxModal(
63  $router->url($request, null, null, 'editAuthor', null, $actionArgs),
64  __('grid.action.editContributor'),
65  'modal_edit'
66  ),
67  __('grid.action.edit'),
68  'edit'
69  )
70  );
71 
72  import('lib.pkp.classes.linkAction.request.RemoteActionConfirmationModal');
73  $this->addAction(
74  new LinkAction(
75  'deleteAuthor',
77  __('common.confirmDelete'),
78  __('common.delete'),
79  $router->url($request, null, null, 'deleteAuthor', null, $actionArgs),
80  'modal_delete'
81  ),
82  __('grid.action.delete'),
83  'delete'
84  )
85  );
86 
87  $authorDao = DAORegistry::getDAO('AuthorDAO');
88  $userDao = DAORegistry::getDAO('UserDAO');
89  $author = $authorDao->getById($rowId);
90 
91  if ($author && !$userDao->userExistsByEmail($author->getEmail())) {
92  $this->addAction(
93  new LinkAction(
94  'addUser',
95  new AjaxModal(
96  $router->url($request, null, null, 'addUser', null, $actionArgs),
97  __('grid.user.add'),
98  'modal_add_user',
99  true
100  ),
101  __('grid.user.add'),
102  'add_user')
103  );
104  }
105  }
106  }
107  }
108 
113  function getSubmission() {
114  return $this->_submission;
115  }
116 
121  function getRequestArgs() {
122  $submission = $this->getSubmission();
123  return array(
124  'submissionId' => $submission->getId()
125  );
126  }
135  function allowedToCreateUser($request) {
136  return false;
137  }
138 
143  function isReadOnly() {
144  return $this->_readOnly;
145  }
146 }
147 
148 ?>
static & getDAO($name, $dbconn=null)
A modal that retrieves its content from via AJAX.
Class defining basic operations for handling HTML gridRows.
Definition: GridRow.inc.php:25
PKPAuthorGridRow($submission, $readOnly=false)
Class defining a simple confirmation modal with a remote action and ok/cancel buttons.
addAction($action, $position=GRID_ACTION_POSITION_DEFAULT)
Base class for author grid row definition.
Base class defining an action that can be performed by the user in the user interface.