/** * 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 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; }
/** * @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;')) : ''); }
/** * 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.")); } } } }
/** * @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")); }
<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">
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; } }
<?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));
?> <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')); ?>
/** * Widget initialization * @return array */ public function init() { return array('name' => __CLASS__, 'label' => AdminModule::t('Relation Belongs To', array(), __CLASS__), 'fieldType' => array('INTEGER'), 'params' => $this->params, 'paramsLabels' => array('modelName' => AdminModule::t('Model Name', array(), __CLASS__), 'optionName' => AdminModule::t('Lable field name', array(), __CLASS__), 'emptyField' => AdminModule::t('Empty item name', array(), __CLASS__), 'relationName' => AdminModule::t('Profile model relation name', array(), __CLASS__))); }
/** * 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'))); }
</div> <div class="checkbox"> <?php echo CHtml::activeCheckBox($model, 'rememberMe'); ?> <?php echo CHtml::activeLabelEx($model, 'rememberMe'); ?> </div> <div class="login-bottom-links"> <?php echo CHtml::link(AdminModule::t("Registrasi Pengguna"), Yii::app()->getModule('admin')->registrationUrl, array('class' => 'link')); ?> | <?php echo CHtml::link(AdminModule::t("Lupa Kata Sandi?"), Yii::app()->getModule('admin')->recoveryUrl, array('class' => 'link')); ?> <br/> © 2015 <strong>Disperindag</strong>. Dev by <a href="http://media-sakti.com" target="_blank">Media SAKTI</a> </div> <?php echo CHtml::endForm(); ?> </div> </div> </div> <?php $form = new CForm(array('elements' => array('username' => array('type' => 'text', 'maxlength' => 32), 'password' => array('type' => 'password', 'maxlength' => 32), 'rememberMe' => array('type' => 'checkbox')), 'buttons' => array('login' => array('type' => 'submit', 'label' => 'Login'))), $model); ?> <!-- Bottom Scripts -->
<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',
<ol class="breadcrumb bc-3"> <li> <a href="/admin">Beranda</a> </li> <li class="active"> <strong><?php $this->breadcrumbs = array(AdminModule::t("Berita")); ?> </strong> </li> <?php if (AdminModule::isAdmin()) { $this->layout = '/layouts/column2'; } ?> </ol> <div class="mail-env"> <!-- Mail Body --> <div class="mail-body"> <div class="mail-header"> <!-- title --> <h3 class="mail-title"> Semua Berita <span class="count">(6)</span> </h3> <!-- search --> <form method="get" role="form" class="mail-search"> <div class="input-group"> <input type="text" class="form-control" name="s" placeholder="Cari berita..."/>
/** * Widget initialization * @return array */ public function init() { return array('name' => __CLASS__, 'label' => AdminModule::t('jQueryUI autocomplete', array(), __CLASS__), 'fieldType' => array('INTEGER'), 'params' => $this->params, 'paramsLabels' => array('modelName' => AdminModule::t('Model Name', array(), __CLASS__), 'optionName' => AdminModule::t('Lable field name', array(), __CLASS__), 'emptyFieldLabel' => AdminModule::t('Empty item name', array(), __CLASS__), 'emptyFieldValue' => AdminModule::t('Empty item value', array(), __CLASS__), 'relationName' => AdminModule::t('Profile model relation name', array(), __CLASS__), 'minLength' => AdminModule::t('minimal start research length', array(), __CLASS__))); }
/** * Verify Old Password */ public function verifyOldPassword($attribute, $params) { if (User::model()->notsafe()->findByPk(Yii::app()->user->id)->password != Yii::app()->getModule('admin')->encrypting($this->{$attribute})) { $this->addError($attribute, AdminModule::t("Old Password is incorrect.")); } }
public static function getWidgets($fieldType = '') { $basePath = Yii::getPathOfAlias('application.modules.admin.components'); $widgets = array(); $list = array('' => AdminModule::t('No')); if (self::$_widgets) { $widgets = self::$_widgets; } else { $d = dir($basePath); while (false !== ($file = $d->read())) { if (strpos($file, 'UW') === 0) { list($className) = explode('.', $file); if (class_exists($className)) { $widgetClass = new $className(); if ($widgetClass->init()) { $widgets[$className] = $widgetClass->init(); if ($fieldType) { if (in_array($fieldType, $widgets[$className]['fieldType'])) { $list[$className] = $widgets[$className]['label']; } } else { $list[$className] = $widgets[$className]['label']; } } } } } $d->close(); } return array($list, $widgets); }
/** * @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')); }
<nav id="header_right"> <ul id="header_links"> <li><?php echo AdminModule::t('Logged in as') . ' ' . Yii::app()->user->name; ?> </li> | <li><?php 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)) { ?>
/** * @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; }
public static function activeDateField($model, $attribute, $htmlOptions = array()) { // SET UP ARRAYS OF OPTIONS FOR DAY, MONTH, YEAR $x = 1; $dayOptions = array('00' => ' - '); while ($x < 31) { $dayOptions[($x < 10 ? '0' : '') . $x] = $x; $x++; } $monthOptions = array('00' => ' - ', '01' => AdminModule::t('January'), '02' => AdminModule::t('February'), '03' => AdminModule::t('March'), '04' => AdminModule::t('April'), '05' => AdminModule::t('May'), '06' => AdminModule::t('June'), '07' => AdminModule::t('July'), '08' => AdminModule::t('August'), '09' => AdminModule::t('September'), '10' => AdminModule::t('October'), '11' => AdminModule::t('November'), '12' => AdminModule::t('December')); $yearOptions = array('0000' => ' - '); $x = 1901; while ($x < 2030) { $yearOptions[$x] = $x; $x++; } parent::resolveNameID($model, $attribute, $htmlOptions); if ($model->{$attribute} != '0000-00-00' && isset($model->{$attribute})) { if (is_array($model->{$attribute})) { $new = $model->{$attribute}; $day = $new['day']; $month = $new['month']; $year = $new['year']; } else { $new = explode('-', $model->{$attribute}); // intval removes leading zero $day = $new[2]; $month = $new[1]; $year = $new[0]; } } else { // DEFAULT TO 0 IF THERE IS NO DATE SET $day = '00'; $month = '00'; $year = '0000'; } //echo "<pre>"; print_r(array($day,$month,$year)); die(); $return = parent::dropDownList($htmlOptions['name'] . '[day]', $day, $dayOptions); $return .= parent::dropDownList($htmlOptions['name'] . '[month]', $month, $monthOptions); $return .= parent::dropDownList($htmlOptions['name'] . '[year]', $year, $yearOptions); return $return; }