/** * Display a list of all categories * * @return void */ public function displayTask() { // Get filters $this->view->filters = array('sort' => Request::getState($this->_option . '.' . $this->_controller . '.sort', 'filter_order', 'title'), 'sort_Dir' => Request::getState($this->_option . '.' . $this->_controller . '.sortdir', 'filter_order_Dir', 'ASC'), 'limit' => Request::getState($this->_option . '.' . $this->_controller . '.limit', 'limit', Config::get('list_limit'), 'int'), 'start' => Request::getState($this->_option . '.' . $this->_controller . '.limitstart', 'limitstart', 0, 'int')); $obj = new Archive(); // Get record count $this->view->total = $obj->products('count', $this->view->filters); // Get records $this->view->rows = $obj->products('list', $this->view->filters); // For all records here get SKUs $skus = new \stdClass(); $warehouse = new Warehouse(); foreach ($this->view->rows as $r) { $key = $r->pId; $allSkus = $warehouse->getProductSkus($r->pId, 'all', false); // Count how many active and how many inactive SKUs there are $skuCounter = new \stdClass(); $skuCounter->active = 0; $skuCounter->inactive = 0; foreach ($allSkus as $skuInfo) { if ($skuInfo->sActive) { $skuCounter->active++; } else { $skuCounter->inactive++; } } $skus->{$key} = $skuCounter; } $this->view->skus = $skus; // access groups $accessGroups = array(); if ($this->config->get('productAccess')) { $ag = \Hubzero\Access\Group::all()->rows(); $accessGroups[0] = 'None'; foreach ($ag as $obj) { $accessGroups[$obj->get('id')] = $obj->get('title'); } } else { $ag = Access::assetgroups(); $accessGroups[0] = 'All'; foreach ($ag as $obj) { $accessGroups[$obj->value] = $obj->text; } } $this->view->ag = $accessGroups; // Output the HTML $this->view->set('config', $this->config)->display(); }
/** * Edit an entry * * @param object $row * @return void */ public function editTask($row = null) { Request::setVar('hidemainmenu', 1); if (!$row) { // Incoming $id = Request::getVar('id', array()); // Get the single ID we're working with if (is_array($id)) { $id = !empty($id) ? $id[0] : 0; } $row = Accessgroup::oneOrNew($id); } $entries = Accessgroup::all(); /*$entries ->select('a.*') ->select('b.id', 'level', true) ->from($entries->getTableName(), 'a') ->joinRaw($entries->getTableName() . '` AS b', 'a.lft > b.lft AND a.rgt < b.rgt', 'left') ->group('a.id, a.title, a.lft, a.rgt');*/ if (!$row->isNew()) { $entries->where('id', '!=', $row->get('id')); } $options = $entries->order('lft', 'asc')->rows(); // Output the HTML $this->view->set('row', $row)->set('options', $options)->setErrors($this->getErrors())->setLayout('edit')->display(); }
/** * Edit an entry * * @param object $row * @return void */ public function editTask($row = null) { Request::setVar('hidemainmenu', 1); if (!$row) { // Incoming $id = Request::getVar('id', array()); // Get the single ID we're working with if (is_array($id)) { $id = !empty($id) ? $id[0] : 0; } $row = Viewlevel::oneOrNew($id); } $row->set('rules', json_decode($row->get('rules'))); $groups = Accessgroup::all()->order('lft', 'asc')->rows(); // Output the HTML $this->view->set('row', $row)->set('groups', $groups)->setErrors($this->getErrors())->setLayout('edit')->display(); }
/** * Gets the parent groups that a leaf group belongs to in its branch back to the root of the tree * (including the leaf group id). * * @param mixed $groupId An integer or array of integers representing the identities to check. * @return mixed True if allowed, false for an explicit deny, null for an implicit deny. */ protected static function getGroupPath($groupId) { // Preload all groups if (empty(self::$userGroups)) { self::$userGroups = Group::all()->order('lft', 'asc')->rows(); } // Make sure groupId is valid if (!array_key_exists($groupId, self::$userGroups)) { return array(); } // Get parent groups and leaf group if (!isset(self::$userGroupPaths[$groupId])) { self::$userGroupPaths[$groupId] = array(); foreach (self::$userGroups as $group) { if ($group->get('lft') <= self::$userGroups[$groupId]->get('lft') && $group->get('rgt') >= self::$userGroups[$groupId]->get('rgt')) { self::$userGroupPaths[$groupId][] = $group->get('id'); } } } return self::$userGroupPaths[$groupId]; }
/** * Display a list of site members * * @return void */ public function displayTask() { // Get filters $filters = array('search' => urldecode(Request::getState($this->_option . '.' . $this->_controller . '.search', 'search', '')), 'sort' => Request::getState($this->_option . '.' . $this->_controller . '.sort', 'filter_order', 'registerDate'), 'sort_Dir' => Request::getState($this->_option . '.' . $this->_controller . '.sortdir', 'filter_order_Dir', 'DESC'), 'registerDate' => Request::getState($this->_option . '.' . $this->_controller . '.registerDate', 'registerDate', ''), 'activation' => Request::getState($this->_option . '.' . $this->_controller . '.activation', 'activation', 0, 'int'), 'state' => Request::getState($this->_option . '.' . $this->_controller . '.state', 'state', '*'), 'access' => Request::getState($this->_option . '.' . $this->_controller . '.access', 'access', 0, 'int'), 'approved' => Request::getState($this->_option . '.' . $this->_controller . '.approved', 'approved', '*'), 'group_id' => Request::getState($this->_option . '.' . $this->_controller . '.group_id', 'group_id', 0, 'int'), 'range' => Request::getState($this->_option . '.' . $this->_controller . '.range', 'range', '')); // Build query $entries = Member::all(); $a = $entries->getTableName(); $b = '#__user_usergroup_map'; $entries->select($a . '.*')->including(['accessgroups', function ($accessgroup) { $accessgroup->select('*'); }])->including(['notes', function ($note) { $note->select('id')->select('user_id'); }]); if ($filters['group_id']) { $entries->join($b, $b . '.user_id', $a . '.id', 'left')->whereEquals($b . '.group_id', (int) $filters['group_id']); /*->group($a . '.id') ->group($a . '.name') ->group($a . '.username') ->group($a . '.password') ->group($a . '.usertype') ->group($a . '.block') ->group($a . '.sendEmail') ->group($a . '.registerDate') ->group($a . '.lastvisitDate') ->group($a . '.activation') ->group($a . '.params') ->group($a . '.email');*/ } if ($filters['search']) { if (is_numeric($filters['search'])) { $entries->whereEquals($a . '.id', (int) $filters['search']); } else { $entries->whereLike($a . '.name', strtolower((string) $filters['search']), 1)->orWhereLike($a . '.username', strtolower((string) $filters['search']), 1)->orWhereLike($a . '.email', strtolower((string) $filters['search']), 1)->resetDepth(); } } if ($filters['registerDate']) { $entries->where($a . '.registerDate', '>=', $filters['registerDate']); } if ($filters['access'] > 0) { $entries->whereEquals($a . '.access', (int) $filters['access']); } if (is_numeric($filters['state'])) { $entries->whereEquals($a . '.block', (int) $filters['state']); } if (is_numeric($filters['approved'])) { $entries->whereEquals($a . '.approved', (int) $filters['approved']); } if ($filters['activation'] < 0) { $entries->where($a . '.activation', '<', 0); } if ($filters['activation'] > 0) { $entries->where($a . '.activation', '>', 0); } // Apply the range filter. if ($filters['range']) { // Get UTC for now. $dNow = Date::of('now'); $dStart = clone $dNow; switch ($filters['range']) { case 'past_week': $dStart->modify('-7 day'); break; case 'past_1month': $dStart->modify('-1 month'); break; case 'past_3month': $dStart->modify('-3 month'); break; case 'past_6month': $dStart->modify('-6 month'); break; case 'post_year': case 'past_year': $dStart->modify('-1 year'); break; case 'today': // Ranges that need to align with local 'days' need special treatment. $offset = Config::get('offset'); // Reset the start time to be the beginning of today, local time. $dStart = Date::of('now', $offset); $dStart->setTime(0, 0, 0); // Now change the timezone back to UTC. $tz = new \DateTimeZone('GMT'); $dStart->setTimezone($tz); break; } if ($filters['range'] == 'post_year') { $entries->where($a . '.registerDate', '<', $dStart->format('Y-m-d H:i:s')); } else { $entries->where($a . '.registerDate', '>=', $dStart->format('Y-m-d H:i:s')); $entries->where($a . '.registerDate', '<=', $dNow->format('Y-m-d H:i:s')); } } // Get records $rows = $entries->order($a . '.' . $filters['sort'], $filters['sort_Dir'])->paginated('limitstart', 'limit')->rows(); // Access groups $accessgroups = Accessgroup::all()->ordered()->rows(); // Output the HTML $this->view->set('rows', $rows)->set('accessgroups', $accessgroups)->set('filters', $filters)->setLayout($this->getTask() == 'modal' ? 'modal' : 'display')->display(); }