summaryrefslogtreecommitdiff
path: root/protected/components
diff options
context:
space:
mode:
authortzur <tzur@ccwn.org>2012-04-15 15:30:09 +0200
committertzur <tzur@ccwn.org>2012-04-15 15:30:09 +0200
commit5b2095abddf9d0596a7715879357e8d9a3b786b2 (patch)
tree0c2b6fdc1484b697b1a3740582a906fb51c1d64f /protected/components
Initial version
Diffstat (limited to 'protected/components')
-rw-r--r--protected/components/Controller.php28
-rw-r--r--protected/components/UserIdentity.php38
2 files changed, 66 insertions, 0 deletions
diff --git a/protected/components/Controller.php b/protected/components/Controller.php
new file mode 100644
index 0000000..01ed7c8
--- /dev/null
+++ b/protected/components/Controller.php
@@ -0,0 +1,28 @@
+<?php
+/**
+ * Controller is the customized base controller class.
+ * All controller classes for this application should extend from this base class.
+ */
+class Controller extends CController
+{
+ /**
+ * @var string the default layout for the controller view. Defaults to '//layouts/column1',
+ * meaning using a single column layout. See 'protected/views/layouts/column1.php'.
+ */
+ public $layout='//layouts/column1';
+ /**
+ * @var array context menu items. This property will be assigned to {@link CMenu::items}.
+ */
+ public $menu=array();
+ /**
+ * @var array the breadcrumbs of the current page. The value of this property will
+ * be assigned to {@link CBreadcrumbs::links}. Please refer to {@link CBreadcrumbs::links}
+ * for more details on how to specify this property.
+ */
+ public $breadcrumbs=array();
+
+ public function accessRules()
+ {
+ return array(array("deny"));
+ }
+} \ No newline at end of file
diff --git a/protected/components/UserIdentity.php b/protected/components/UserIdentity.php
new file mode 100644
index 0000000..e506ef8
--- /dev/null
+++ b/protected/components/UserIdentity.php
@@ -0,0 +1,38 @@
+<?php
+
+/**
+ * UserIdentity represents the data needed to identity a user.
+ * It contains the authentication method that checks if the provided
+ * data can identity the user.
+ */
+class UserIdentity extends CUserIdentity
+{
+ public $id;
+ public $isAdmin;
+ /**
+ * Authenticates a user.
+ *
+ * @return boolean whether authentication succeeds.
+ */
+ public function authenticate()
+ {
+ $user = User::model()->find('LOWER(username)=?',array(strtolower($this->username)));
+ if ($user === null){
+ $this->errorCode = self::ERROR_USERNAME_INVALID;
+ } else if (!$user->checkPassword($this->password)) {
+ $this->errorCode = self::ERROR_PASSWORD_INVALID;
+ } else {
+ $this->id = $user->id;
+ $this->username = $user->username;
+ $this->setState("isAdmin", $user->is_super_admin);
+ $verein = Verein::model()->find('LOWER(slug)=?',array(strtolower($this->username)));
+ if (null !== $verein) {
+ $this->setState("vereinId", $verein->id);
+ } else {
+ $this->setState("vereinId", 0);
+ }
+ $this->errorCode = self::ERROR_NONE;
+ }
+ return $this->errorCode == self::ERROR_NONE;
+ }
+} \ No newline at end of file