public static function panelHtml() { $data = array('main_menu' => self::getMainMenu(), 'more_menu' => self::getMoreMenu(), 'modes' => array("view" => array("name" => fx::alang("mode_view"), "key" => "view"), "edit" => array("name" => fx::alang("mode_edit"), "key" => "edit")), 'profile' => array('logout' => array('name' => fx::alang('Sign out', 'system'), 'href' => fx::user()->getLogoutUrl())), 'is_front' => $_SERVER['REQUEST_URI'] !== fx::config('path.admin')); $res = fx::template('@admin:panel')->render($data); return $res; }
/** * Check if infoblock's scope.visibility allows the current user to see this block * @return bool Is the block available */ public function isAvailableForUser() { $c_user = fx::user(); $ib_visibility = isset($this['scope']['visibility']) ? $this['scope']['visibility'] : null; if (!$ib_visibility || $ib_visibility === 'all') { return true; } if ($ib_visibility === 'nobody') { return false; } if ($ib_visibility === 'admin' && !$c_user->isAdmin()) { return false; } if ($ib_visibility === 'user' && $c_user->isGuest()) { return false; } if ($ib_visibility === 'guest' && !$c_user->isGuest()) { return false; } return true; }
public function doFormCreate() { $this->onFormReady(function ($e) { unset($e['form']['fields']['is_published']); unset($e['form']['fields']['avatar']); unset($e['form']['fields']['is_admin']); $e['form']['fields']['email']['required'] = true; $e['form']['fields']['name']['required'] = true; }); if ($this->getParam('force_login') && fx::user()->isGuest()) { $this->onFormCompleted(function ($e) { $form = $e['form']; $user = $e['entity']; $user->login($form->email, $form->password, true); }); } return parent::doFormCreate(); }