public function executeGet(sfWebRequest $request) { include_once sfConfig::get('sf_root_dir') . '/apps/api/lib/PlancakeApiServer.class.php'; $tags = PlancakeApiServer::getTags(array('api_ver' => sfConfig::get('app_api_version'), 'camel_case_keys' => 1)); if ($request->isXmlHttpRequest()) { return $this->renderJson($tags); } }
/** * Executes index action * * @param sfRequest $request A request object */ public function executeSync(sfWebRequest $request) { include_once sfConfig::get('sf_root_dir') . '/apps/api/lib/PlancakeApiServer.class.php'; parse_str(urldecode($request->getContent()), $requestParams); $tasks = isset($requestParams['tasks']) && is_array($requestParams['tasks']) ? $requestParams['tasks'] : array(); $changes = PlancakeApiServer::sync(array('from_ts' => $requestParams['from_ts'], 'tasks' => $tasks, 'camel_case_keys' => 1, 'api_ver' => sfConfig::get('app_api_version'))); if ($request->isXmlHttpRequest()) { return $this->renderJson($changes); } }
public function executeScheduledTasksForTodo(sfWebRequest $request) { $loggedInUser = PcUserPeer::getLoggedInUser(); if ($loggedInUser->hasGoogleCalendarIntegrationActive()) { $gcal = new GoogleCalendarInterface($loggedInUser); $gcal->init(); $gcal->syncPlancake(); } include_once sfConfig::get('sf_root_dir') . '/apps/api/lib/PlancakeApiServer.class.php'; $apiVersion = sfConfig::get('app_api_version'); $doneParam = $request->getParameter('done'); $typeParam = $request->getParameter('type'); $extraParam = $request->getParameter('extraParam'); $filters = array(); $filters['list_id'] = $loggedInUser->getTodo()->getId(); $filters['only_with_due_date'] = 1; $tasks = PlancakeApiServer::getTasks(array_merge($filters, array('api_ver' => $apiVersion, 'camel_case_keys' => 1))); $tasks['tasks'] = array_reverse($tasks['tasks']); // to make them easier to show on the UI if ($request->isXmlHttpRequest()) { return $this->renderJson($tasks); } }
public function executeGetTasks(sfWebRequest $request) { include_once sfConfig::get('sf_root_dir') . '/apps/api/lib/PlancakeApiServer.class.php'; $apiVersion = sfConfig::get('app_api_version'); $doneParam = $request->getParameter('done'); $typeParam = $request->getParameter('type'); $extraParam = urldecode($request->getParameter('extraParam')); $filters = array(); $filters['completed'] = (int) $doneParam; if ($typeParam == "list") { $filters['list_id'] = (int) $extraParam; $user = PcUserPeer::getLoggedInUser(); /* // This was to hide scheduled tasks from the Todo list if ( $user->getTodo()->getId() == $filters['list_id']) { $filters['only_without_due_date'] = 1; } */ } else { if ($typeParam == "tag") { $filters['tag_id'] = (int) $extraParam; } else { if ($typeParam == "starred") { $filters['only_starred'] = 1; } else { if ($typeParam == "today") { $filters['only_due_today_or_tomorrow'] = 1; } else { if ($typeParam == "calendar") { $filters['by_date'] = $extraParam; } else { if ($typeParam == "search") { $filters['search_query'] = $extraParam; } } } } } } $tasks = PlancakeApiServer::getTasks(array_merge($filters, array('api_ver' => $apiVersion, 'camel_case_keys' => 1))); if ($request->isXmlHttpRequest()) { return $this->renderJson($tasks); } }