public function DatesAction() { $this->autoRenderOff(); $manager = $this->getArticlesManager(); $dates = $manager->getDates(); $dates = ArrayUtils::filterNulls($dates); $dates = array_values($dates); $dates = json_encode($dates, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE); echo $dates; }
public function isAllow($group, $resource, $user = null, $owner = null) { $resource = $this->prepareResource($resource); $params = ["-c" => $this->getAclFile(), "-g" => $group, "-r" => $resource, "-u" => $user, "-o" => $owner]; $params = ArrayUtils::filterNulls($params); $params = ArrayUtils::implodePairs(" ", $params, " "); $output = []; exec("x-acl " . $params, $output, $code); if ($code !== 0) { throw new \RuntimeException("Error in acl check. Code: {$code}. Msg: " . implode(" ", $output)); } $output = reset($output); return $output === "Access allow"; }
public function getMonths() { $table = $this->getTable(); $sql = "select distinct to_char(created, 'YYYY-MM') from {$table}"; $months = $this->getAdapter()->selectCol($sql); $months = array_map(function ($value) { return new \DateTime($value); }, ArrayUtils::filterNulls($months)); return $months; }
public function insertRaw(array $fields, $table = null, $rawFields = null) { $adapter = $this->getAdapter(); if (is_null($table)) { $table = $this->getTable(); } $idField = $this->getIdField($table); if (isset($fields[$idField]) || array_key_exists($idField, $fields)) { unset($fields[$idField]); } $fields = ArrayUtils::filterNulls($fields); if (!empty($rawFields)) { $rawFields = ArrayUtils::filterNulls($rawFields); } return $adapter->insert($table, $fields, $idField, $rawFields); }