protected function setupRouter() { if (Environment::isProduction() && isset($this->cache['router'])) { $this->setRouter($this->cache['router']); } else { // SiteRoute::initialize(); $router = $this->getRouter(); // pripojim routy z bootstrapu foreach ($this->routes as $route) { $router[] = $route; } // Homepage $router[] = new Route('index.php', array('module' => 'Front', 'presenter' => 'Files', 'action' => 'list'), Route::ONE_WAY); // Modules routes // foreach ($this->modules as $module) // $module->setupRouter($router); if (is_callable(array('AdminModule', 'createRoutes'))) { AdminModule::createRoutes($router); } FrontModule::createRoutes($router); // setups routes for submodules /** * Default route, match only * Simple Front module presenters * Simple Admin module presenters */ $router[] = new Route('[<lang [a-z]{2}>/]<module Front|Admin>/<presenter>/<action>/<id>', array('module' => 'Front', 'presenter' => 'Homepage', 'action' => 'default', 'id' => NULL)); $this->cache->save('router', $router); } }
/** * Authenticates the password. * This is the 'authenticate' validator as declared in rules(). */ public function authenticate($attribute, $params) { if (!$this->hasErrors()) { $identity = new UserIdentity($this->username, $this->password); $identity->authenticate(); switch ($identity->errorCode) { case UserIdentity::ERROR_NONE: $duration = $this->rememberMe ? Yii::app()->controller->module->rememberMeTime : 0; Yii::app()->user->login($identity, $duration); break; case UserIdentity::ERROR_EMAIL_INVALID: $this->addError("username", AdminModule::t("Email anda salah.")); break; case UserIdentity::ERROR_USERNAME_INVALID: $this->addError("username", AdminModule::t("Username anda salah.")); break; case UserIdentity::ERROR_STATUS_NOTACTIV: $this->addError("status", AdminModule::t("Akun anda belum aktif.")); break; case UserIdentity::ERROR_STATUS_BAN: $this->addError("status", AdminModule::t("Akun anda sudah diblok.")); break; case UserIdentity::ERROR_PASSWORD_INVALID: $this->addError("password", AdminModule::t("Kata sandi anda salah.")); break; } } }
/** * Registration user */ public function actionRegistration() { //var_dump("test");exit; $model = new RegistrationForm(); $profile = new Profile(); $profile->regMode = true; //var_dump($model);exit; // ajax validator if (isset($_POST['ajax']) && $_POST['ajax'] === 'registration-form') { echo UActiveForm::validate(array($model, $profile)); Yii::app()->end(); } //var_dump($_POST['ajax']);exit; if (Yii::app()->user->id) { $this->redirect(Yii::app()->controller->module->profileUrl); } else { if (isset($_POST['RegistrationForm'])) { //var_dump($_POST['RegistrationForm']);exit; $model->attributes = $_POST['RegistrationForm']; $profile->attributes = isset($_POST['Profile']) ? $_POST['Profile'] : array(); if ($model->validate() && $profile->validate()) { $soucePassword = $model->password; $model->activkey = AdminModule::encrypting(microtime() . $model->password); $model->password = AdminModule::encrypting($model->password); $model->verifyPassword = AdminModule::encrypting($model->verifyPassword); $model->superuser = 0; $model->status = Yii::app()->controller->module->activeAfterRegister ? User::STATUS_ACTIVE : User::STATUS_NOACTIVE; if ($model->save()) { $profile->user_id = $model->id; $profile->save(); if (Yii::app()->controller->module->sendActivationMail) { $activation_url = $this->createAbsoluteUrl('/admin/user/activation/activation', array("activkey" => $model->activkey, "email" => $model->email)); AdminModule::sendMail($model->email, AdminModule::t("Anda registrasi dari {site_name}", array('{site_name}' => Yii::app()->name)), AdminModule::t("Silahkan Aktifkan akun anda melalui link {activation_url}", array('{activation_url}' => $activation_url))); } if ((Yii::app()->controller->module->loginNotActiv || Yii::app()->controller->module->activeAfterRegister && Yii::app()->controller->module->sendActivationMail == false) && Yii::app()->controller->module->autoLogin) { $identity = new UserIdentity($model->username, $soucePassword); $identity->authenticate(); Yii::app()->user->login($identity, 0); $this->redirect(Yii::app()->controller->module->returnUrl); } else { if (!Yii::app()->controller->module->activeAfterRegister && !Yii::app()->controller->module->sendActivationMail) { Yii::app()->user->setFlash('registration', AdminModule::t("Terima kasih anda sudah mendaftar. Hubungi Admin untuk mengaktifkan akun anda.")); } elseif (Yii::app()->controller->module->activeAfterRegister && Yii::app()->controller->module->sendActivationMail == false) { Yii::app()->user->setFlash('registration', AdminModule::t("Terima kasih anda sudah mendaftar. Silahkan {{login}}.", array('{{login}}' => CHtml::link(AdminModule::t('Login'), Yii::app()->controller->module->loginUrl)))); } elseif (Yii::app()->controller->module->loginNotActiv) { Yii::app()->user->setFlash('registration', AdminModule::t("Terima kasih anda sudah mendaftar. Silahkan cek email anda atau login.")); } else { Yii::app()->user->setFlash('registration', AdminModule::t("Terima kasih anda sudah mendaftar. Silahkan cek email anda.")); } $this->refresh(); } } } else { $profile->validate(); } } $this->render('/user/registration', array('model' => $model, 'profile' => $profile)); } }
public function layoutTemplate() { $sLayoutName = self::getLayoutName(); if (isset($aDashboardConfig['layout'])) { $sLayoutName = $aDashboardConfig['layout']; } return Module::constructTemplateForModuleAndType(AdminModule::getType(), AdminModule::getNameByClassName('DashboardAdminModule'), 'layouts/' . $sLayoutName)->render(); }
/** * @param $value * * @return string */ public function editAttribute($model, $field, $params = array()) { if (!isset($params['options'])) { $params['options'] = array(); } $options = $params['options']; unset($params['options']); return CHtml::activeFileField($model, $field->varname, $params) . ($model->getAttribute($field->varname) ? '<br/>' . CHtml::activeCheckBox($model, '[uwfdel]' . $field->varname, $params) . ' ' . CHtml::activeLabelEx($model, '[uwfdel]' . $field->varname, array('label' => AdminModule::t('Delete file'), 'style' => 'display:inline;')) : ''); }
protected function beforeRender() { parent::beforeRender(); $this->template->modules = AdminModule::getModules(); $this->template->title = 'Admin'; $this->template->heading = 'Administrácia'; $this->template->isAdminModule = TRUE; $this->setRenderSections(array(self::RENDER_SECTION_FILEUPLOAD => false, self::RENDER_SECTION_FILTERS => false, self::RENDER_SECTION_OPTIONS => false)); }
public function rules() { $rules = array(array('username, password, verifyPassword, email', 'required'), array('username', 'length', 'max' => 20, 'min' => 3, 'message' => AdminModule::t("Incorrect username (length between 3 and 20 characters).")), array('password', 'length', 'max' => 128, 'min' => 4, 'message' => AdminModule::t("Incorrect password (minimal length 4 symbols).")), array('email', 'email'), array('username', 'unique', 'message' => AdminModule::t("This user's name already exists.")), array('email', 'unique', 'message' => AdminModule::t("This user's email address already exists.")), array('username', 'match', 'pattern' => '/^[A-Za-z0-9_]+$/u', 'message' => AdminModule::t("Incorrect symbols (A-z0-9)."))); if (!(isset($_POST['ajax']) && $_POST['ajax'] === 'registration-form')) { array_push($rules, array('verifyCode', 'captcha', 'allowEmpty' => !AdminModule::doCaptcha('registration'))); } array_push($rules, array('verifyPassword', 'compare', 'compareAttribute' => 'password', 'message' => AdminModule::t("Retype Password is incorrect."))); return $rules; }
/** * Recovery password */ public function actionRecovery() { $form = new UserRecoveryForm(); if (Yii::app()->user->id) { $this->redirect(Yii::app()->controller->module->returnUrl); } else { $email = isset($_GET['email']) ? $_GET['email'] : ''; $activkey = isset($_GET['activkey']) ? $_GET['activkey'] : ''; if ($email && $activkey) { $form2 = new UserChangePassword(); $find = User::model()->notsafe()->findByAttributes(array('email' => $email)); if (isset($find) && $find->activkey == $activkey) { if (isset($_POST['UserChangePassword'])) { $form2->attributes = $_POST['UserChangePassword']; if ($form2->validate()) { $find->password = Yii::app()->controller->module->encrypting($form2->password); $find->activkey = Yii::app()->controller->module->encrypting(microtime() . $form2->password); if ($find->status == 0) { $find->status = 1; } $find->save(); Yii::app()->user->setFlash('recoveryMessage', AdminModule::t("New password is saved.")); $this->redirect(Yii::app()->controller->module->recoveryUrl); } } $this->render('changepassword', array('form' => $form2)); } else { Yii::app()->user->setFlash('recoveryMessage', AdminModule::t("Incorrect recovery link.")); $this->redirect(Yii::app()->controller->module->recoveryUrl); } } else { if (isset($_POST['UserRecoveryForm'])) { $form->attributes = $_POST['UserRecoveryForm']; if ($form->validate()) { $user = User::model()->notsafe()->findbyPk($form->user_id); $activation_url = 'http://' . $_SERVER['HTTP_HOST'] . $this->createUrl(implode(Yii::app()->controller->module->recoveryUrl), array("activkey" => $user->activkey, "email" => $user->email)); $subject = AdminModule::t("You have requested the password recovery site {site_name}", array('{site_name}' => Yii::app()->name)); $message = AdminModule::t("You have requested the password recovery site {site_name}. To receive a new password, go to {activation_url}.", array('{site_name}' => Yii::app()->name, '{activation_url}' => $activation_url)); AdminModule::sendMail($user->email, $subject, $message); Yii::app()->user->setFlash('recoveryMessage', AdminModule::t("Please check your email. An instructions was sent to your email address.")); $this->refresh(); } } $this->render('recovery', array('form' => $form)); } } }
public static function getDashboardMenu() { $dashboard = new Dashboard(); $menuItems = $dashboard->getMenuItems(); //for settings foreach (Settings::getCategories() as $settingsCategory) { $menuItems['Settings'][] = array(Awecms::generateFriendlyName($settingsCategory) . ' Settings', array('/admin/settings/' . $settingsCategory)); } //reading the menu items into an array that zii.widgets.jui.CJuiAccordion can take as panels $menuConfig = array(); foreach ($menuItems as $menuName => $menuItem) { $menuConfig[$menuName] = ''; foreach ($menuItem as $menuLink) { $menuConfig[$menuName] .= CHtml::link(AdminModule::t($menuLink[0]), $menuLink[1]) . "<br/>"; } } return $menuConfig; }
/** * Activation user account */ public function actionActivation() { $email = $_GET['email']; $activkey = $_GET['activkey']; if ($email && $activkey) { $find = User::model()->notsafe()->findByAttributes(array('email' => $email)); if (isset($find) && $find->status) { $this->render('/user/message', array('title' => AdminModule::t("User activation"), 'content' => AdminModule::t("You account is active."))); } elseif (isset($find->activkey) && $find->activkey == $activkey) { $find->activkey = AdminModule::encrypting(microtime()); $find->status = 1; $find->save(); $this->render('/user/message', array('title' => AdminModule::t("User activation"), 'content' => AdminModule::t("You account is activated."))); } else { $this->render('/user/message', array('title' => AdminModule::t("User activation"), 'content' => AdminModule::t("Incorrect activation URL."))); } } else { $this->render('/user/message', array('title' => AdminModule::t("User activation"), 'content' => AdminModule::t("Incorrect activation URL."))); } }
/** * Change password */ public function actionChangepassword() { $model = new UserChangePassword(); if (Yii::app()->user->id) { // ajax validator if (isset($_POST['ajax']) && $_POST['ajax'] === 'changepassword-form') { echo UActiveForm::validate($model); Yii::app()->end(); } if (isset($_POST['UserChangePassword'])) { $model->attributes = $_POST['UserChangePassword']; if ($model->validate()) { $new_password = User::model()->notsafe()->findbyPk(Yii::app()->user->id); $new_password->password = AdminModule::encrypting($model->password); $new_password->activkey = AdminModule::encrypting(microtime() . $model->password); $new_password->save(); Yii::app()->user->setFlash('profileMessage', AdminModule::t("New password is saved.")); $this->redirect(array("profile")); } } $this->render('changepassword', array('model' => $model)); } }
public function checkexists($attribute, $params) { if (!$this->hasErrors()) { if (strpos($this->login_or_email, "@")) { $user = User::model()->findByAttributes(array('email' => $this->login_or_email)); if ($user) { $this->user_id = $user->id; } } else { $user = User::model()->findByAttributes(array('username' => $this->login_or_email)); if ($user) { $this->user_id = $user->id; } } if ($user === null) { if (strpos($this->login_or_email, "@")) { $this->addError("login_or_email", AdminModule::t("Email is incorrect.")); } else { $this->addError("login_or_email", AdminModule::t("Username is incorrect.")); } } } }
public function getPageData() { $oPage = PageQuery::create()->findPk($this->iPageId); $aResult = $oPage->toArray(BasePeer::TYPE_PHPNAME, false); // addition related page fields $aResult['PageLink'] = LinkUtil::absoluteLink(LinkUtil::link($oPage->getFullPathArray(), 'FrontendManager', array(), AdminManager::getContentLanguage()), null, 'auto'); $aResult['PageHref'] = LinkUtil::absoluteLink(LinkUtil::link($oPage->getFullPathArray(), 'FrontendManager', array(), AdminManager::getContentLanguage()), null, 'default', true); // page properties are displayed if added to template try { $mAvailableProperties = $this->getAvailablePageProperties($oPage); if (count($mAvailableProperties) > 0) { $aResult['page_properties'] = $mAvailableProperties; } } catch (Exception $e) { ErrorHandler::handleException($e, true); } // page references are displayed if exist $mReferences = AdminModule::getReferences(ReferencePeer::getReferences($oPage)); $aResult['CountReferences'] = count($mReferences); if ($mReferences !== null) { $aResult['page_references'] = $mReferences; } return $aResult; }
/** * Return admins. * @return array syperusers names */ public static function getAdmins() { if (!self::$_admins) { $admins = User::model()->active()->superuser()->findAll(); $return_name = array(); foreach ($admins as $admin) { array_push($return_name, $admin->username); } self::$_admins = $return_name ? $return_name : array(''); } return self::$_admins; }
/** * @return array customized attribute labels (name=>label) */ public function attributeLabels() { return array('berita_id' => AdminModule::t("Id"), 'isi_berita' => AdminModule::t("Isi Berita"), 'url' => AdminModule::t("url"), 'judul' => AdminModule::t('Judul'), 'imageid' => AdminModule::t('Lokasi Image'), 'tgl_berita' => AdminModule::t('Tgl Berita'), 'tgl_update' => AdminModule::t('Tgl Update'), 'tags_id' => AdminModule::t('Tags'), 'kategori_id' => AdminModule::t('Kategori'), 'is_publish' => AdminModule::t('Status'), 'is_draft' => AdminModule::t('Is Draft'), 'is_archive' => AdminModule::t('Is Archive')); }
<li> <a href="/admin">Beranda</a> </li> <li class="active"> <!-- <strong>Tambah Pengguna</strong>--> <strong> <?php echo AdminModule::t("Registration"); ?> </strong> </li> </ol> <h2><?php echo AdminModule::t("Registration"); ?> </h2> <br /> <?php if (Yii::app()->user->hasFlash('registration')) { ?> <div class="success"> <?php echo Yii::app()->user->getFlash('registration'); ?> </div> <?php } else { ?> <div class="row">
/** * @return array customized attribute labels (name=>label) */ public function attributeLabels() { return array('id' => AdminModule::t("Id"), 'username' => AdminModule::t("Username"), 'password' => AdminModule::t("Password"), 'verifyPassword' => AdminModule::t("Retype Password"), 'email' => AdminModule::t("E-mail"), 'verifyCode' => AdminModule::t("Verification Code"), 'activkey' => AdminModule::t("activation key"), 'createtime' => AdminModule::t("Registration date"), 'create_at' => AdminModule::t("Registration date"), 'lastvisit_at' => AdminModule::t("Last visit"), 'superuser' => AdminModule::t("Superuser"), 'status' => AdminModule::t("Status")); }
<?php /* @var $this AnswerController */ /* @var $model Answer */ $this->breadcrumbs = array(AdminModule::t('Answers') => array('index'), $model->id => array('view', 'id' => $model->id), AdminModule::t('Update')); $this->menu = array(array('label' => AdminModule::t('List Answer'), 'icon' => 'icon-list', 'url' => array('index')), array('label' => AdminModule::t('Create Answer'), 'icon' => 'icon-plus', 'url' => array('create')), array('label' => AdminModule::t('View Answer'), 'icon' => ' icon-eye-open', 'url' => array('view', 'id' => $model->id)), array('label' => AdminModule::t('Manage Answer'), 'icon' => 'icon-folder-open', 'url' => array('admin'))); ?> <h1><?php echo AdminModule::t('Update Answer'); ?> <?php echo $model->id; ?> </h1> <?php echo $this->renderPartial('_form', array('model' => $model));
protected function getModuleType() { return AdminModule::getType(); }
public static function itemAlias($type, $code = NULL) { $_items = array('field_type' => array('INTEGER' => AdminModule::t('INTEGER'), 'VARCHAR' => AdminModule::t('VARCHAR'), 'TEXT' => AdminModule::t('TEXT'), 'DATE' => AdminModule::t('DATE'), 'FLOAT' => AdminModule::t('FLOAT'), 'DECIMAL' => AdminModule::t('DECIMAL'), 'BOOL' => AdminModule::t('BOOL'), 'BLOB' => AdminModule::t('BLOB'), 'BINARY' => AdminModule::t('BINARY')), 'required' => array(self::REQUIRED_NO => AdminModule::t('No'), self::REQUIRED_NO_SHOW_REG => AdminModule::t('No, but show on registration form'), self::REQUIRED_YES_SHOW_REG => AdminModule::t('Yes and show on registration form'), self::REQUIRED_YES_NOT_SHOW_REG => AdminModule::t('Yes')), 'visible' => array(self::VISIBLE_ALL => AdminModule::t('For all'), self::VISIBLE_REGISTER_USER => AdminModule::t('Registered users'), self::VISIBLE_ONLY_OWNER => AdminModule::t('Only owner'), self::VISIBLE_NO => AdminModule::t('Hidden'))); if (isset($code)) { return isset($_items[$type][$code]) ? $_items[$type][$code] : false; } else { return isset($_items[$type]) ? $_items[$type] : false; } }
function AdminUpdate() { parent::AdminModule(); }
public function renderAdmin(Template $oTemplate = null) { if ($this->sModuleName === null) { $this->sModuleName = self::DEFAULT_MODULE; } try { $this->oModule = AdminModule::getModuleInstance($this->sModuleName); } catch (Exception $e) { LinkUtil::redirect(LinkUtil::link(array(self::DEFAULT_MODULE, 'module_not_found', $this->sModuleName))); } if (!Module::isModuleAllowed('admin', $this->sModuleName, Session::getSession()->getUser())) { LinkUtil::redirect(LinkUtil::link(array(self::DEFAULT_MODULE, 'module_denied', $this->sModuleName))); } $this->doAdmin($oTemplate); }
?> <div class="col-sm-5"> <?php $this->widget('CCaptcha'); ?> <?php echo $form->textField($model, 'verifyCode', array('class' => 'form-control')); ?> <?php echo $form->error($model, 'verifyCode'); ?> <p class="text-danger"><?php echo AdminModule::t("Please enter the letters as they are shown in the image above."); ?> <br/><?php echo AdminModule::t("Letters are not case-sensitive."); ?> </p> </div> </div> <?php } ?> <div class="form-group"> <div class="col-sm-offset-3 col-sm-5"> <?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save', array('class' => 'btn btn-primary add-post')); ?> <?php echo CHtml::resetButton('Cancel', array('class' => 'btn btn-primary cancel')); ?>
echo CHtml::link(AdminModule::t('Account Settings'), array('/user/profile/edit')); ?> </li> | <li><?php echo CHtml::link(AdminModule::t('Visit Website'), Yii::app()->baseUrl . '/'); ?> </li> | <li><?php echo CHtml::link(AdminModule::t('Log out'), array('/user/logout')); ?> </li> </ul> </nav> <nav id="admin_menu"> <?php $this->widget('MenuRenderer', array('name' => 'admin', 'append' => array(array('label' => Yii::t('app', 'Settings'), 'items' => Settings::getCategoriesAsLinks()), array('label' => Yii::t('app', 'Modules'), 'items' => AdminModule::getLinkForModules())))); ?> </nav> </header> <div class="clear"></div> <?php if (isset($this->breadcrumbs)) { ?> <?php $this->widget('Breadcrumbs', array('links' => $this->breadcrumbs, 'homeLink' => '<a href="' . Yii::app()->baseUrl . '/admin">Dashboard</a>')); ?> <?php } ?> <?php
/** * @return array customized attribute labels (name=>label) */ public function attributeLabels() { $labels = array('user_id' => AdminModule::t('User ID')); $model = $this->getFields(); foreach ($model as $field) { $labels[$field->varname] = Yii::app()->getModule('admin')->fieldsMessage ? AdminModule::t($field->title, array(), Yii::app()->getModule('admin')->fieldsMessage) : AdminModule::t($field->title); } return $labels; }
function AdminUrlRedirectionGenerate() { parent::AdminModule(); }
function AdminUser() { parent::AdminModule(); }
<div class="panel-title"><?php echo AdminModule::t("Daftar Pengguna"); ?> </div> <div class="panel-options"> <a href="/admin/user/registration" class="bg"><i class="entypo-user-add"></i><?php echo AdminModule::t('Tambah User'); ?> </a> <a href="/admin/user/admin" class="bg"><i class="entypo-users"></i><?php echo AdminModule::t('Pengaturan Pengguna'); ?> </a> <a href="/admin/profilefield/admin" class="bg"><i class="entypo-user"></i><?php echo AdminModule::t('Atur Profile User'); ?> </a> </div> </div> <?php // $this->widget('zii.widgets.grid.CGridView', array( // 'dataProvider'=>$dataProvider, // 'columns'=>array( // array( // 'name' => 'username', // 'type'=>'raw', // 'value' => 'CHtml::link(CHtml::encode($data->username),array("user/view","id"=>$data->id))', // ), // 'create_at',
function AdminGeneralConfig() { parent::AdminModule(); }
/** * Initialization * @return array */ public function init() { return array('name' => __CLASS__, 'label' => AdminModule::t('jQueryUI datepicker'), 'fieldType' => array('DATE', 'VARCHAR'), 'params' => $this->params, 'paramsLabels' => array('dateFormat' => AdminModule::t('Date format'))); }