static function getFields() { return SearchFields_Task::getFields(); }
private function _putIdAction($path) { $xmlstr = $this->getPayload(); $xml_in = new SimpleXMLElement($xmlstr); $in_id = array_shift($path); if (empty($in_id)) { $this->_error("ID was not provided."); } if (null == ($task = DAO_Task::get($in_id))) { $this->_error("ID not valid."); } $fields = array(); $flds = SearchFields_Task::getFields(); unset($flds[DAO_Task::ID]); foreach ($flds as $idx => $f) { $idx_name = $this->translate($idx, true); if ($idx_name == null) { continue; } @($value = DevblocksPlatform::importGPC($xml_in->{$idx_name}, 'string')); if ($this->isValid($idx_name, $value)) { $fields[$idx_name] = $value; } } if (!empty($fields)) { DAO_Task::update($task->id, $fields); } $this->_getIdAction(array($task->id)); }
/** * Enter description here... * * @param DevblocksSearchCriteria[] $params * @param integer $limit * @param integer $page * @param string $sortBy * @param boolean $sortAsc * @param boolean $withCounts * @return array */ static function search($columns, $params, $limit = 10, $page = 0, $sortBy = null, $sortAsc = null, $withCounts = true) { $db = DevblocksPlatform::getDatabaseService(); $fields = SearchFields_Task::getFields(); // Sanitize if (!isset($fields[$sortBy])) { $sortBy = null; } list($tables, $wheres) = parent::_parseSearchParams($params, $columns, $fields, $sortBy); $start = $page * $limit; // [JAS]: 1-based [TODO] clean up + document $select_sql = sprintf("SELECT " . "t.id as %s, " . "t.due_date as %s, " . "t.is_completed as %s, " . "t.completed_date as %s, " . "t.title as %s, " . "t.content as %s, " . "t.worker_id as %s, " . "t.source_extension as %s, " . "t.source_id as %s ", SearchFields_Task::ID, SearchFields_Task::DUE_DATE, SearchFields_Task::IS_COMPLETED, SearchFields_Task::COMPLETED_DATE, SearchFields_Task::TITLE, SearchFields_Task::CONTENT, SearchFields_Task::WORKER_ID, SearchFields_Task::SOURCE_EXTENSION, SearchFields_Task::SOURCE_ID); $join_sql = "FROM task t "; // "LEFT JOIN contact_org o ON (o.id=a.contact_org_id) " // [JAS]: Dynamic table joins // (isset($tables['o']) ? "LEFT JOIN contact_org o ON (o.id=a.contact_org_id)" : " "). // (isset($tables['mc']) ? "INNER JOIN message_content mc ON (mc.message_id=m.id)" : " "). // Custom field joins list($select_sql, $join_sql, $has_multiple_values) = self::_appendSelectJoinSqlForCustomFieldTables($tables, $params, 't.id', $select_sql, $join_sql); $where_sql = "" . (!empty($wheres) ? sprintf("WHERE %s ", implode(' AND ', $wheres)) : ""); $sort_sql = !empty($sortBy) ? sprintf("ORDER BY %s %s ", $sortBy, $sortAsc || is_null($sortAsc) ? "ASC" : "DESC") : " "; $sql = $select_sql . $join_sql . $where_sql . ($has_multiple_values ? 'GROUP BY t.id ' : '') . $sort_sql; $rs = $db->SelectLimit($sql, $limit, $start) or die(__CLASS__ . '(' . __LINE__ . ')' . ':' . $db->ErrorMsg()); /* @var $rs ADORecordSet */ $results = array(); if (is_a($rs, 'ADORecordSet')) { while (!$rs->EOF) { $result = array(); foreach ($rs->fields as $f => $v) { $result[$f] = $v; } $id = intval($rs->fields[SearchFields_Task::ID]); $results[$id] = $result; $rs->MoveNext(); } } // [JAS]: Count all $total = -1; if ($withCounts) { $count_sql = ($has_multiple_values ? "SELECT COUNT(DISTINCT t.id) " : "SELECT COUNT(t.id) ") . $join_sql . $where_sql; $total = $db->GetOne($count_sql); } return array($results, $total); }