public function beforeAction($action) { if (Yum::module()->enableOnlineStatus && !Yii::app()->user->isGuest) { Yii::app()->user->data()->setLastAction(); } return parent::beforeAction($action); }
public function tableName() { if (isset(Yum::module('profile')->profileCommentTable)) { return Yum::module('profile')->profileCommentTable; } return '{{profile_comment}}'; }
public function checkAccess($operation, $params=array(), $allowCaching=true) { if(!Yum::hasModule('role') || Yum::module('role')->useYiiCheckAccess ) return parent::checkAccess($operation, $params, $allowCaching); return $this->can($operation); }
public function tableName() { if (isset(Yum::module('profile')->privacySettingTable)) { return Yum::module('profile')->privacySettingTable; } return '{{privacysetting}}'; }
public function rules() { $rules = parent::rules(); /* FIXME: As soon as i grasp how i can dynamically add variables to a class in PHP, i will enable this code snippet for flexibility: $profile = new YumProfile; $profile_rules = $profile->rules(); foreach($profile_rules as $rule) if(isset($rule[0]) && is_string($rule[0])) $this->${$rule[0]} = ''; $rules = array_merge($rules, $profile->rules()); */ $rules[] = array('username', 'required'); $rules[] = array('password, verifyPassword', 'required'); $rules[] = array('password', 'compare', 'compareAttribute'=>'verifyPassword', 'message' => Yum::t("Retype password is incorrect.")); if(Yum::module('registration')->enableCaptcha) $rules[] = array('verifyCode', 'captcha', 'allowEmpty'=>CCaptcha::checkRequirements()); return $rules; }
public function actionCreate() { $this->layout = Yum::module()->adminLayout; $model = new YumPermission(); $this->performAjaxValidation($model, 'permission-create-form'); if (isset($_POST['YumPermission'])) { $model->attributes = $_POST['YumPermission']; if ($model->validate()) { if ($_POST['YumPermission']['type'] == 'user') { $model->subordinate = $_POST['YumPermission']['subordinate_id']; $model->principal = $_POST['YumPermission']['principal_id']; } else { if ($_POST['YumPermission']['type'] == 'role') { $model->subordinate_role = $_POST['YumPermission']['subordinate_id']; $model->principal_role = $_POST['YumPermission']['principal_id']; } } if ($model->save()) { $this->redirect(array('admin')); } return; } } $model->type = 'user'; // preselect 'user' $this->render('create', array('model' => $model)); }
public function actionEditAvatar() { $model = YumUser::model()->findByPk(Yii::app()->user->id); if (isset($_POST['YumUser'])) { $model->attributes = $_POST['YumUser']; $model->setScenario('avatarUpload'); if (Yum::module('avatar')->avatarMaxWidth != 0) { $model->setScenario('avatarSizeCheck'); } $model->avatar = CUploadedFile::getInstanceByName('YumUser[avatar]'); if ($model->validate()) { if ($model->avatar instanceof CUploadedFile) { // Prepend the id of the user to avoid filename conflicts $filename = Yum::module('avatar')->avatarPath . '/' . $model->id . '_' . $_FILES['YumUser']['name']['avatar']; $model->avatar->saveAs($filename); $model->avatar = $filename; if ($model->save()) { Yum::setFlash(Yum::t('The image was uploaded successfully')); Yum::log(Yum::t('User {username} uploaded avatar image {filename}', array('{username}' => $model->username, '{filename}' => $model->avatar))); $this->redirect(array('//profile/profile/view')); } } } } $this->render('edit_avatar', array('model' => $model)); }
public function tableName() { if (isset(Yum::module('profile')->profileVisitTable)) { return Yum::module('profile')->profileVisitTable; } return '{{profile_visit}}'; }
public function tableName() { if (isset(Yum::module()->translationTable)) { return Yum::module()->translationTable; } else { return '{{translation}}'; } }
/** * Adds the CAdvancedArBehavior and, if enabled, the LoggableBehavior to * every YUM Active Record model * @return array */ public function behaviors() { $behaviors = array('CAdvancedArBehavior'); if (Yum::module()->enableAuditTrail) { $behaviors = array_merge($behaviors, array('LoggableBehavior' => 'application.modules.auditTrail.behaviors.LoggableBehavior')); } return $behaviors; }
public function rules() { $rules = array(array('login_or_email', 'required'), array('login_or_email', 'checkexists')); if (Yum::module('registration')->validEmailPattern) { $rules[] = array('login_or_email', 'match', 'pattern' => Yum::module('registration')->validEmailPattern, 'message' => Yum::t('Incorrect symbols. (A-z0-9)')); } return $rules; }
public function createRandomPassword() { $lowercase = Yum::module()->passwordRequirements['minLowerCase']; $uppercase = Yum::module()->passwordRequirements['minUpperCase']; $minnumbers = Yum::module()->passwordRequirements['minDigits']; $max = Yum::module()->passwordRequirements['maxLen']; $chars = "abcdefghijkmnopqrstuvwxyz"; $numbers = "1023456789"; srand((double) microtime() * 1000000); $i = 0; $current_lc = 0; $current_uc = 0; $current_dd = 0; $password = ''; while ($i <= $max) { if ($current_lc < $lowercase) { $charnum = rand() % 22; $tmpchar = substr($chars, $charnum, 1); $password = $password . $tmpchar; $i++; } if ($current_uc < $uppercase) { $charnum = rand() % 22; $tmpchar = substr($chars, $charnum, 1); $password = $password . strtoupper($tmpchar); $i++; } if ($current_dd < $minnumbers) { $charnum = rand() % 9; $tmpchar = substr($numbers, $charnum, 1); $password = $password . $tmpchar; $i++; } if ($current_lc == $lowercase && $current_uc == $uppercase && $current_dd == $numbers && $i < $max) { $charnum = rand() % 22; $tmpchar = substr($chars, $charnum, 1); $password = $password . $tmpchar; $i++; if ($i < $max) { $charnum = rand() % 9; $tmpchar = substr($numbers, $charnum, 1); $password = $password . $tmpchar; $i++; } if ($i < $max) { $charnum = rand() % 22; $tmpchar = substr($chars, $charnum, 1); $password = $password . strtoupper($tmpchar); $i++; } } } return $password; }
public function beforeAction($event) { if (Yii::app()->user->isAdmin()) { $this->layout = Yum::module('usergroup')->adminLayout; } else { $this->layout = Yum::module('usergroup')->layout; } return parent::beforeAction($event); }
public function tableName() { if (isset(Yum::module()->textSettingsTable)) $this->_tableName = Yum::module()->textSettingsTable; elseif (isset(Yii::app()->modules['user']['textSettingsTable'])) $this->_tableName = Yii::app()->modules['user']['textSettingsTable']; else $this->_tableName = '{{yumtextsettings}}'; // fallback if nothing is set return Yum::resolveTableName($this->_tableName, $this->getDbConnection()); }
public function actionAdmin() { $this->layout = Yum::module()->adminLayout; $model = new YumAction('search'); $model->unsetAttributes(); if (isset($_GET['YumAction'])) { $model->attributes = $_GET['YumAction']; } $this->render('admin', array('model' => $model)); }
protected function renderContent() { if (Yum::module('message')->messageSystem === false) { return false; } if (!Yii::app()->user->isGuest) { $messages = YumMessage::model()->unread()->limit(10)->findAll(); $this->render('messages', array('messages' => $messages)); } }
public function tableName() { if (isset(Yum::module('membership')->paymentTable)) { $this->_tableName = Yum::module('membership')->paymentTable; } else { $this->_tableName = '{{payment}}'; } // fallback if nothing is set return Yum::resolveTableName($this->_tableName, $this->getDbConnection()); }
public function actionDelete($id) { $comment = YumProfileComment::model()->findByPk($id); if ($comment->user_id == Yii::app()->user->id || $comment->profile_id == Yii::app()->user->id) { $comment->delete(); $this->redirect(array(Yum::module('profile')->profileView, 'id' => $comment->profile->user_id)); } else { throw new CHttpException(403, Yum::t('You are not the owner of this Comment or this Profile!')); } }
public function beforeAction($action) { if (Yum::module()->enableOnlineStatus && !Yii::app()->user->isGuest) { Yii::app()->user->data()->setLastAction(); } if (Yum::module()->enableBootstrap) { Yum::register('css/bootstrap.min.css'); } return parent::beforeAction($action); }
/** * Returns resolved table name (incl. table prefix when it is set in db configuration) * Following algorith of searching valid table name is implemented: * - try to find out table name stored in currently used module * - if not found try to get table name from UserModule configuration * - if not found user default {{profiles}} table name * @return string */ public function tableName() { if (isset(Yum::module('profile')->profileTable)) { $this->_tableName = Yum::module('profile')->profileTable; } else { $this->_tableName = '{{profiles}}'; } // fallback if nothing is set return Yum::resolveTableName($this->_tableName, $this->getDbConnection()); }
public function can($action, $subaction = null) { if (!Yum::hasModule('role')) { throw new CException(Yum::t('Role module is not activated')); } Yii::import('user.role.models.*'); if (Yum::module('role')->adminIsGod && Yii::app()->user->isAdmin()) { return true; } return $this->data()->can($action, $subaction); }
public function relations() { return array( 'activeusers'=>array(self::MANY_MANY, 'YumUser', Yum::module('role')->userRoleTable . '(role_id, user_id)', 'condition' => 'status = 3'), 'users'=>array(self::MANY_MANY, 'YumUser', Yum::module('role')->userRoleTable. '(role_id, user_id)'), 'permissions' => array(self::HAS_MANY, 'YumPermission', 'principal_id'), 'memberships' => array(self::HAS_MANY, 'YumMembership', 'membership_id'), 'managed_by' => array(self::HAS_MANY, 'YumPermission', 'subordinate_id'), ); }
public function rules() { $passwordRequirements = Yum::module()->passwordRequirements; $passwordrule = array_merge(array('password', 'YumPasswordValidator'), $passwordRequirements); $rules[] = $passwordrule; $rules[] = array('currentPassword', 'safe'); $rules[] = array('currentPassword', 'required', 'on' => 'user_request'); $rules[] = array('password, verifyPassword', 'required'); $rules[] = array('password', 'compare', 'compareAttribute' => 'verifyPassword', 'message' => Yum::t('Retyped password is incorrect')); return $rules; }
protected function renderContent() { if (!Yum::module('profile')->enableProfileVisitLogging) { return false; } parent::renderContent(); if (Yii::app()->user->isGuest) { return false; } $this->render('profile_visits', array('visits' => Yii::app()->user->data()->visits)); }
public function search() { $criteria = new CDbCriteria(); $criteria->compare('principal_id', $this->principal_id); $criteria->compare('subordinate_id', $this->subordinate_id); $criteria->compare('type', $this->type, true); $criteria->compare('template', $this->template); $criteria->compare('comment', $this->comment, true); $criteria->compare('action', $this->action); $criteria->compare('subaction', $this->subaction); return new CActiveDataProvider(get_class($this), array('criteria' => $criteria, 'pagination' => array('pageSize' => Yum::module()->pageSize))); }
public function actionDelete() { $this->layout = Yum::module()->adminLayout; if (Yii::app()->request->isPostRequest) { $this->loadModel()->delete(); if (!isset($_POST['ajax'])) { $this->redirect(array('index')); } } else { throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.'); } }
/** * Declares the validation rules. * The rules state that username and password are required, * and password needs to be authenticated. */ public function rules() { if (!isset($this->scenario)) { $this->scenario = 'login'; } $rules = array(array('username, password', 'required', 'on' => 'login'), array('rememberMe', 'boolean')); if (Yum::module()->captchaAfterUnsuccessfulLogins !== false) { $rules[] = array('verifyCode', 'captcha', 'on' => 'captcha', 'allowEmpty' => !CCaptcha::checkRequirements()); $rules[] = array('username, password', 'required', 'on' => 'captcha'); } return $rules; }
public function tableName() { if (isset(Yum::module()->userUsergroupTable)) { $this->_tableName = Yum::module()->userUsergroupTable; } elseif (isset(Yii::app()->modules['user']['userUsergroupTable'])) { $this->_tableName = Yii::app()->modules['user']['userUsergroupTable']; } else { $this->_tableName = '{{user_has_usergroup}}'; } // fallback if nothing is set return Yum::resolveTableName($this->_tableName, $this->getDbConnection()); }
/** * Returns resolved table name (incl. table prefix when it is set in db configuration) * Following algorithm of searching valid table name is implemented: * - try to find out table name stored in currently used module * - if not found try to get table name from UserModule configuration * - if not found user default {{profile_field}} table name * @return string */ public function tableName() { if (isset(Yum::module('profile')->profileFieldsTable)) { $this->_tableName = Yum::module('profile')->profileFieldsTable; } elseif (isset(Yii::app()->modules['user']['profileFieldsTable'])) { $this->_tableName = Yii::app()->modules['user']['profileFieldsTable']; } else { $this->_tableName = '{{profile_field}}'; } // fallback if nothing is set return Yum::resolveTableName($this->_tableName, $this->getDbConnection()); }
public function rules() { $rules = array(); foreach (YumProfile::getProfileFields() as $field) { $rules[] = array($field, 'safe'); } foreach (Yum::module('profile')->requiredProfileFields as $field) { $rules[] = array($field, 'required'); } $rules = array_merge($rules, Yum::module('profile')->profileRules); return $rules; }