public static function reposition($request) { $response = Utils::response(); $pagina = $request->getParameter('pagina', 1); // Verifica a sessão $auth = sfContext::getInstance()->getUser()->isAuthenticated(); if (!$auth) { $response['auth'] = false; return $response; } $post = $request->getParameter('post', false); if (is_array($post)) { $tblCore = Doctrine_Core::getTable(sfConfig::get('table_model')); foreach ($post as $p) { $item = $tblCore->find(intval($p['id'])); if ($item) { $num = static::generateNum($item, $pagina, $p['pos']); $item->moveToPosition(intval($num)); $item->free(true); $response['success'] = true; } } } if ($response['success']) { $response['msg'] = 'Dados reposicionados.'; } else { $response['msg'] = 'Nenhum dado foi alterado ou reposicionado.'; } return $response; }
public function executeRemoveFile(sfWebRequest $request) { $g = static::galeriaInfo(); $this->getResponse()->setContentType('application/json'); // Response $response = Utils::response(); // Verifica a sessão $auth = $this->getUser()->isAuthenticated(); if (!$auth) { $response['auth'] = false; $response['msg'] = "Sessão expirada. Efetue o login novamente."; return $this->renderText(json_encode($response)); } // Verificando Method if ($request->isMethod(sfRequest::POST) || $request->isMethod(sfRequest::DELETE)) { $result = Doctrine_Core::getTable($g['tabela'])->find($request['id']); } else { $response['msg'] = "Os métodos permitidos são: POST ou DELETE."; } // Do it if ($result) { $result->delete(); $response['success'] = true; $response['msg'] = "O arquivo foi removido com sucesso."; $response['data'] = array('id' => $request['id']); } else { $response['msg'] = "Arquivo não encontrado."; } return $this->renderText(json_encode($response)); }