function perform(&$request, &$response) { $request->setStatus(Request::STATUS_SUCCESS); if ($request->hasAttribute('popup')) { $response->write(closePopupResponse($request)); } $toolkit =& Limb::toolkit(); $datasource =& $toolkit->getDatasource('RequestedObjectDatasource'); $datasource->setRequest($request); if (!($object = wrapWithSiteObject($datasource->fetch()))) { return; } $site_object_controller =& $object->getController(); $action = $site_object_controller->getAction($request); switch ($action) { case 'publish': $status = $this->getPublishStatus($object); break; case 'unpublish': $status = $this->getUnpublishStatus($object); break; default: return; break; } $object->set('status', $status); $object->update(false); $this->_applyAccessPolicy($object, $action); $datasource->flushCache(); }
function perform(&$request, &$response) { if ($request->hasAttribute('popup')) { $response->write(closePopupNoParentReloadResponse()); } $request->setStatus(Request::STATUS_FAILURE); if (!($version = $request->get('version'))) { return; } if (!($node_id = $request->get('version_node_id'))) { return; } $toolkit =& Limb::toolkit(); $datasource =& $toolkit->getDatasource('SingleObjectDatasource'); $datasource->setNodeId($node_id); if (!($site_object = wrapWithSiteObject($datasource->fetch()))) { return; } if (!is_subclass_of($site_object, 'ContentObject')) { return; } if (!$site_object->recoverVersion((int) $version)) { return; } if ($request->hasAttribute('popup')) { $response->write(closePopupResponse($request)); } $request->setStatus(Request::STATUS_SUCCESS); }
protected function _validPerform($request, $response) { if ($request->hasAttribute('popup')) { $response->write(closePopupResponse($request)); } $data = $this->dataspace->export(); if (!isset($data['ids']) || !is_array($data['ids'])) { $request->setStatus(Request::STATUS_FAILURE); return; } $objects = $this->_getObjects(array_keys($data['ids'])); foreach ($objects as $id => $item) { if (!isset($item['actions']['publish']) || !isset($item['actions']['unpublish'])) { continue; } $object = wrapWithSiteObject($item); $status = $object->get('status'); if ($status & SITE_OBJECT_PUBLISHED_STATUS) { $status &= ~SITE_OBJECT_PUBLISHED_STATUS; $action = 'unpublish'; } else { $status |= SITE_OBJECT_PUBLISHED_STATUS; $action = 'publish'; } $object->set('status', $status); $object->update(false); $this->_applyAccessPolicy($object, $action); } $request->setStatus(Request::STATUS_SUCCESS); }
protected function _validPerform($request, $response) { $data = $this->dataspace->export(); $request->setStatus(Request::STATUS_FAILURE); if ($request->hasAttribute('popup')) { $response->write(closePopupResponse($request)); } if (!isset($data['ids']) || !is_array($data['ids'])) { return; } $objects = $this->_getObjectsToDelete(array_keys($data['ids'])); foreach ($objects as $id => $item) { if ($item['delete_status'] !== 0) { continue; } $site_object = wrapWithSiteObject($item); try { $site_object->delete(); } catch (LimbException $e) { MessageBox::writeNotice("object {$id} - {$item['title']} couldn't be deleted!"); $request->setStatus(Request::STATUS_FAILURE); throw $e; } } $request->setStatus(Request::STATUS_SUCCESS); $response->write(closePopupResponse($request)); }
public function perform() { $toolkit = Limb :: toolkit(); $request = $toolkit->getRequest(); // maybe we should use some kind of template here instead of close_popup_response($request) if($request->hasAttribute('popup')) $toolkit->getResponse()->write(closePopupResponse($request)); return Limb :: STATUS_OK; }
protected function _validPerform($request, $response) { $data = $this->dataspace->export(); $object = Limb::toolkit()->createSiteObject('SiteStructure'); if (isset($data['priority'])) { $object->savePriority($data['priority']); } $request->setStatus(Request::STATUS_SUCCESS); if ($request->hasAttribute('popup')) { $response->write(closePopupResponse($request)); } }
function _validPerform(&$request, &$response) { $params = array(); $params['identifier'] = $this->dataspace->get('identifier'); $params['parent_path'] = $this->dataspace->get('parent_path'); $params['class'] = $this->dataspace->get('class_name'); $params['title'] = $this->dataspace->get('title'); $toolkit =& Limb::toolkit(); $object =& $toolkit->createSiteObject($params['Class']); $datasource =& $toolkit->getDatasource('SingleObjectDatasource'); $datasource->setPath($params['parent_path']); $is_root = false; if (!($parent_data = $datasource->fetch())) { if ($params['parent_path'] == '/') { $is_root = true; } else { MessageBox::writeNotice('parent wasn\'t retrieved by path ' . $params['parent_path']); $request->setStatus(Request::STATUS_FAILURE); return; } } if (!$is_root) { $params['parent_node_id'] = $parent_data['node_id']; } else { $params['parent_node_id'] = 0; } $object->merge($params); $object->create($is_root); if (catch_error($e, 'LimbException')) { MessageBox::writeNotice('object wasn\'t registered!'); $request->setStatus(Request::STATUS_FAILURE); return; } elseif (catch_error($e, 'LimbException')) { return throw_error($e); } if (!$is_root) { $parent_object =& $toolkit->createSiteObject($parent_data['ClassName']); $parent_object->merge($parent_data); $controller =& $parent_object->getController(); $action = $controller->determineAction(); $access_policy = new AccessPolicy(); $access_policy->saveNewObjectAccess($object, $parent_object, $action); } $request->setStatus(Request::STATUS_FORM_SUBMITTED); if ($request->hasAttribute('popup')) { $response->write(closePopupResponse($request)); } }
protected function _validPerform($request, $response) { $locale_id = $this->dataspace->get('locale_id'); if ($request->hasAttribute('popup')) { $response->write(closePopupResponse($request)); } elseif (isset($_SERVER['HTTP_REFERER'])) { $response->redirect($_SERVER['HTTP_REFERER']); } else { $response->redirect('/'); } if (!Locale::isValidLocaleId($locale_id)) { $request->setStatus(Request::STATUS_FAILURE); } Limb::toolkit()->getUser()->set('locale_id', $locale_id); $request->setStatus(Request::STATUS_SUCCESS); }
public function _validPerform($request, $response) { parent::_validPerform($request, $response); if ($this->_changingOwnPassword()) { Limb::toolkit()->getUser()->logout(); MessageBox::writeWarning(Strings::get('need_relogin', 'user')); } else { $object_data = $this->_loadObjectData(); Limb::toolkit()->getSession()->storageDestroyUser($object_data['id']); } if ($request->getStatus() == Request::STATUS_SUCCESS) { if ($request->hasAttribute('popup')) { $response->write(closePopupResponse($request, '/')); } } }