public function getMessagePrefix($message) { if ($this->prefix !== null) { return call_user_func($this->prefix, $message); } $ip = Utility::getIp(); $userID = LuLu::getIdentity()->username; if (empty($userID)) { return "[{$ip}]"; } else { return "[{$ip}]<br/>[{$userID}]"; } }
public function actionCreate() { $model = new Content(); $model->user_id = LuLu::getIdentity()->id; $model->user_name = LuLu::getIdentity()->username; $model->content_type = $this->content_type; $model->loadDefaultValues(); $bodyModel = $this->findBodyModel(); $bodyModel->loadDefaultValues(); if ($this->saveContent($model, $bodyModel)) { return $this->redirect(['index']); } return $this->render('create', ['model' => $model, 'bodyModel' => $bodyModel]); }
public function beforeValidate() { if (!$this->userValidate) { return parent::beforeValidate(); } if (parent::beforeValidate()) { if ($this->hasAttribute('sort_num')) { if ($this->sort_num === null || $this->sort_num === '') { $this->sort_num = Constants::getSortNum(); } } if ($this->hasAttribute('created_at')) { if (empty($this->created_at)) { $this->created_at = time(); } } if ($this->hasAttribute('updated_at')) { $this->updated_at = time(); } if ($this->hasAttribute('created_by')) { if (empty($this->created_by)) { $this->created_by = LuLu::getIdentity()->username; } } if ($this->hasAttribute('updated_by')) { if (empty($this->updated_by)) { $this->updated_by = LuLu::getIdentity()->username; } } return true; } return false; }
public function checkHomePermission($permission = null, $params = [], $user = null) { if ($user === null) { $user = LuLu::getIdentity()->username; } if ($permission === null) { $permission = LuLu::getApp()->controller->uniqueId; } $permission = 'home_' . $permission; $rows = $this->getPermissionsByUser($user); if (!isset($rows[$permission])) { return false; } return $this->executeRule($rows[$permission], $params, $user); }
public function checkPermission($role = null, $permission = null, $params = []) { if ($role === null) { $role = LuLu::getIdentity()->role; } if ($permission === null) { $m = LuLu::getApp()->controller->module->id; $c = LuLu::getApp()->controller->id; $permission = empty($m) ? $c : $m . '/' . $c; } $rows = $this->getPermissionsByRole($role); if (!isset($rows[$permission])) { return false; } return $this->executeRule($role, $rows[$permission], $params); }