/** * Cria um novo tipo de Usuário * @param string $user_type_descr Descrição completa do tipo de usuário * @param string $user_type_abrev abreviação do tipo de usuário * @return bollean true caso sucesso, false caso ocorra algum erro */ public function createUserType($user_type_descr, $user_type_abrev) { $user_type = new UserType(); $user_type->user_type_descr = $user_type_descr; $user_type->user_type_abrev = $user_type_abrev; return $user_type->save(); }
protected function body() { if (!$this->userHasPrivileges(User::usersPrivPresets)) { return false; } $privilegeGroups = array('users', 'subscriptions', 'plugins', 'assignments', 'submissions', 'lectures', 'groups', 'other'); $inputs = array_merge(array('name' => array('isAlphaNumeric', 'isNotEmpty')), array_combine($privilegeGroups, array_pad(array(), count($privilegeGroups), array()))); if (!$this->isInputValid($inputs)) { return false; } $id = $this->getParams('id'); $name = $this->getParams('name'); $privileges = array(); foreach ($privilegeGroups as $i => $group) { $value = $this->getParams($group); $privileges = array_merge($privileges, $value != '' ? explode(';', $value) : array()); } if (count($privileges)) { $privileges = array_combine($privileges, array_pad(array(), count($privileges), true)); } $privileges = User::instance()->packPrivileges($privileges); if ($id === null || $id === '') { $usertype = new \UserType(); $usertype->setName($name); $usertype->setPrivileges($privileges); Repositories::persistAndFlush($usertype); } else { /** @var \UserType $usertype */ $usertype = Repositories::findEntity(Repositories::UserType, $id); $usertype->setName($name); $usertype->setPrivileges($privileges); Repositories::persistAndFlush($usertype); } return true; }
public function insert(UserType $ut) { $query = "INSERT INTO `user_type`(`description`) VALUES ('" . $ut->getDescription() . "')"; $this->con->openConnection(); $this->con->executeRawQuery($query); $this->con->closeConnection(); }
public function addUserType(UserType $userType) { $type = $userType->getEntityName(); if (isset($this->userTypes[$type])) { throw new InvalidArgumentException("Type '{$type}' is already exists."); } $this->userTypes[$type] = $userType; }
function plugin_debate_addPermissions() { $Admin = new UserType(1); $ChiefEditor = new UserType(2); $Editor = new UserType(3); $Admin->setPermission('plugin_debate_admin', true); $ChiefEditor->setPermission('plugin_debate_admin', true); $Editor->setPermission('plugin_debate_admin', true); }
private function getUserType($selectResult) { $UserType = new UserType(); $count = 0; while ($list = mysqli_fetch_assoc($selectResult)) { $UserType->setUserTypeId($list['utp_usertype_id']); $UserType->setUserTypeName($list['utp_type_name']); } // while return $UserType; }
function plugin_soundcloud_install() { global $LiveUserAdmin; $LiveUserAdmin->addRight(array('area_id' => 0, 'right_define_name' => 'plugin_soundcloud_preferences', 'has_implied' => 1)); $LiveUserAdmin->addRight(array('area_id' => 0, 'right_define_name' => 'plugin_soundcloud_browser', 'has_implied' => 1)); $LiveUserAdmin->addRight(array('area_id' => 0, 'right_define_name' => 'plugin_soundcloud_upload', 'has_implied' => 1)); $LiveUserAdmin->addRight(array('area_id' => 0, 'right_define_name' => 'plugin_soundcloud_update', 'has_implied' => 1)); $LiveUserAdmin->addRight(array('area_id' => 0, 'right_define_name' => 'plugin_soundcloud_delete', 'has_implied' => 1)); $Admin = new UserType(1); $Admin->setPermission('plugin_soundcloud_preferences', true); $Admin->setPermission('plugin_soundcloud_browser', true); $Admin->setPermission('plugin_soundcloud_upload', true); $Admin->setPermission('plugin_soundcloud_update', true); $Admin->setPermission('plugin_soundcloud_delete', true); require_once $GLOBALS['g_campsiteDir'] . '/install/classes/CampInstallationBase.php'; $GLOBALS['g_db'] = $GLOBALS['g_ado_db']; $errors = CampInstallationBaseHelper::ImportDB(CS_PATH_PLUGINS . DIR_SEP . 'soundcloud/install/sql/plugin_soundcloud.sql', $error_queries); unset($GLOBALS['g_db']); }
function plugin_interview_addPermissions() { $Admin = new UserType(1); $ChiefEditor = new UserType(2); $Editor = new UserType(3); $Admin->setPermission('plugin_interview_admin', true); $Admin->setPermission('plugin_interview_moderator', true); $ChiefEditor->setPermission('plugin_interview_moderator', true); }
echo $form->labelEx($model, 'password'); ?> <?php echo $form->passwordField($model, 'password', array('size' => 50, 'maxlength' => 50)); ?> <?php echo $form->error($model, 'password'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'type'); ?> <?php echo $form->dropDownList($model, 'type', CHtml::listData(UserType::findAll(), 'id', 'name')); ?> <?php echo $form->error($model, 'type'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'status'); ?> <?php echo $form->dropDownList($model, 'status', CHtml::listData(UserStatus::findAll(), 'id', 'name')); ?> <?php echo $form->error($model, 'status');
$fields = array('UName', 'Name', 'Title', 'Gender', 'Age', 'EMail', 'City', 'StrAddress', 'State', 'CountryCode', 'Phone', 'Fax', 'Contact', 'Phone2', 'PostalCode', 'Employer', 'EmployerType', 'Position'); if ($isNewUser) { $action = 'do_add.php'; foreach ($fields as $index=>$field) { $$field = Input::Get($field, 'string', ''); } } else { $action = 'do_edit.php'; foreach ($fields as $index=>$field) { $$field = $editUser->getProperty($field); } } $userTypes = UserType::GetUserTypes(); $countries = Country::GetCountries(1); $my_user_type = $editUser->getUserType(); ?> <script type="text/javascript" src="<?php echo $Campsite['WEBSITE_URL']; ?>/js/campsite.js"></script> <script type="text/javascript" src="<?php echo $Campsite['WEBSITE_URL']; ?>/js/pwd_meter/js/pwd_meter_min.js"></script> <script type="text/javascript" src="<?php echo $Campsite['WEBSITE_URL']; ?>/js/pwd_meter/js/pwd_generator_min.js"></script> <link href="<?php echo $Campsite['WEBSITE_URL']; ?>/js/pwd_meter/css/default.css" rel="stylesheet" type="text/css" /> <form name="user_add" method="POST" action="<?php echo $action; ?>" onsubmit="return <?php camp_html_fvalidate(); ?>;"> <?php echo SecurityToken::FormParameter(); ?> <input type="hidden" name="uType" value="<?php echo $uType; ?>"> <?php
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = UserType::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function getUserTypes() { $saved_db = DbUtil::switchToGlobal(); $lab_config_id = $this->id; $retval = array(); $query_string = "SELECT * FROM user_type"; $resultset = query_associative_all($query_string, $row_count); if ($resultset != null) { foreach ($resultset as $record) { $retval[] = UserType::getObject($record); } } DbUtil::switchRestore($saved_db); return $retval; }
<select id="form<?php echo $class_name; ?> SelectUserType" class="fullWidth ui-widget-content ui-corner-all"> <option value="0" <?php echo !$obj->has_UserType() ? "selected" : ""; ?> ><<?php echo Language::string(73); ?> ></option> <?php $sql = $logged_user->mysql_list_rights_filter("UserType", "`name` ASC"); $z = mysql_query($sql); while ($r = mysql_fetch_array($z)) { $type = UserType::from_mysql_id($r[0]); ?> <option value="<?php echo $type->id; ?> " <?php echo $obj->UserType_id == $type->id ? "selected" : ""; ?> ><?php echo $type->name; ?> ( <?php echo $type->get_system_data(); ?> )</option> <?php
if (!SecurityToken::isValid()) { camp_html_display_error(getGS('Invalid security token!')); exit; } $canManage = $g_user->hasPermission('ManageUserTypes'); if (!$canManage) { $error = getGS("You do not have the right to delete user types."); camp_html_display_error($error); exit; } $uTypeId = Input::Get('UType', 'string', ''); if (is_numeric($uTypeId) && $uTypeId > 0) { $userType = new UserType($uTypeId); if (!$userType->exists()) { camp_html_display_error(getGS('No such user type.')); exit; } $userType->delete(); } else { camp_html_display_error(getGS('No such user type.')); exit; } $msg = getGS("User Type '$1' successfully deleted", $userType->getName()); camp_html_add_msg($msg, 'ok'); camp_html_goto_page("/$ADMIN/user_types/"); ?>
/** * Get the user type that matches the given config variables. * * @param array * $p_configVars An array of permissions variables * * @return mixed * bool False The config passed does not match any user type * object $userType The user type object matching */ public static function GetUserTypeFromConfig($p_configVars) { global $LiveUserAdmin; if (!is_array($p_configVars) || count($p_configVars) == 0) { return false; } $configVarsSize = sizeof($p_configVars); $userTypes = UserType::GetUserTypes(); foreach ($userTypes as $userType) { $uTypeConfigSize = sizeof($userType->m_config); if ($configVarsSize > $uTypeConfigSize) { $diff = array_diff_key($p_configVars, $userType->m_config); } else { $diff = array_diff_key($userType->m_config, $p_configVars); } if (sizeof($diff) == 0) { return $userType; } } return false; }
/** * Edit usertype * * @return Response */ public function editUserType(Request $request) { //Validate the Request $this->validate($request, ['id' => 'numeric', 'name' => 'required|unique:user_types|max:255']); $ut = UserType::find($request->id); $ut->name = $request->name; $ut->save(); return Redirect::to('admin/usertype'); }
public function get_UserType() { return UserType::from_mysql_id($this->UserType_id); }
/** * @return \yii\db\ActiveQuery */ public function getUserType() { return $this->hasOne(UserType::className(), ['id' => 'user_type']); }
<?php $form = $this->beginWidget('CActiveForm', array('id' => 'user-form', 'enableAjaxValidation' => false)); ?> <p class="note">Fields with <span class="required">*</span> are required.</p> <?php echo $form->errorSummary($model); ?> <div class="row"> <?php echo $form->labelEx($model, 'user_type_id'); ?> <?php echo $form->dropDownList($model, 'user_type_id', UserType::All(), array('maxlength' => 10)); ?> <?php echo $form->error($model, 'user_type_id'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'login'); ?> <?php echo $form->textField($model, 'login', array('size' => 60, 'maxlength' => 255)); ?> <?php echo $form->error($model, 'login');
public function run() { DB::table('usertypes')->delete(); UserType::create(array('description' => 'Atleta')); UserType::create(array('description' => 'Psicólogo')); }
if ($canManage) { echo "</a>"; } ?> </td> <td><?php echo htmlspecialchars($row['UName']); ?></TD> <td><?php echo htmlspecialchars($row['EMail']); ?></td> <?php if ($uType == "Subscribers" && $g_user->hasPermission("ManageSubscriptions")) { ?> <td><a href="<?php echo "/$ADMIN/users/subscriptions/?f_user_id=$userId"; ?>"> <?php putGS("Subscriptions"); ?> </td> <?php } ?> <?php if ($uType == "Staff") { ?> <td><?php $userType = new UserType($editUser->getUserType()); if ($userType) { echo htmlspecialchars($userType->getName()); } unset($userType); ?></td> <?php } ?> <td> <?php $creationDate = $row['time_created']; if ((int)$creationDate == 0) { putGS('N/A'); } else { echo $creationDate; }
private static function loadItems() { self::$_items = array(); $models = self::model()->findAll(); foreach ($models as $model) { self::$_items[$model->user_type_id] = $model->user_type_name; } }
/** * Updates the permissions for the user. * * @param array * $p_permissions The list of permissions * * @return bool */ public function updatePermissions($p_permissions) { global $LiveUserAdmin; if (!is_array($p_permissions) || sizeof($p_permissions) == 0) { return false; } $permissions = array(); // generate an array of granted permissions foreach ($p_permissions as $permission => $value) { if ($value) { $permissions[$permission] = $value; } } // find out whether the given config matches an specific user type $userType = UserType::GetUserTypeFromConfig($permissions); if ($userType) { $this->setUserType($userType->getId()); $this->setProperty('fk_user_type', $userType->getId()); } else { foreach ($p_permissions as $permission => $value) { $filter = array('filters' => array('right_define_name' => $permission)); $right = $LiveUserAdmin->perm->getRights($filter); if (!is_array($right) || sizeof($right) == 0) { continue; } $params = array('right_id' => $right[0]['right_id'], 'perm_user_id' => $this->getPermUserId()); // revoke or grant the given right if (isset($this->m_config[$permission])) { if (!$value) { $LiveUserAdmin->perm->revokeUserRight($params); unset($this->m_config[$permission]); } } if ($value) { $LiveUserAdmin->perm->grantUserRight($params); } } // remove this user from current user type if any $filter = array('group_id' => $this->getUserType(), 'perm_user_id' => $this->getPermUserId()); $LiveUserAdmin->perm->removeUserFromGroup($filter); $this->setProperty('fk_user_type', 'NULL', true, true); } } // fn updatePermissions
<?php require_once($GLOBALS['g_campsiteDir']. "/$ADMIN_DIR/user_types/utypes_common.php"); require_once($GLOBALS['g_campsiteDir']. "/$ADMIN_DIR/users/permission_list.php"); camp_load_translation_strings("users"); $canManage = $g_user->hasPermission('ManageUserTypes'); if (!$canManage) { $error = getGS("You do not have the right to change user type permissions."); camp_html_display_error($error); exit; } $uTypeId = Input::Get('UType', 'string', ''); if (is_numeric($uTypeId) && $uTypeId > 0) { $userType = new UserType($uTypeId); if ($userType->getName() == '') { camp_html_display_error(getGS('No such user type.')); exit; } } else { camp_html_display_error(getGS('No such user type.')); exit; } $rights = camp_get_permission_list(); $crumbs = array(); $crumbs[] = array(getGS("Staff User Types"), "/$ADMIN/user_types/"); $crumbs[] = array(getGS("Change user type permissions"), ""); echo camp_html_breadcrumbs($crumbs);
/** * Generate array for dropdown list to use in child form. * @return array $_items */ public static function items() { self::$_items = CHtml::listData(self::model()->findAll(), 'user_type_id', 'user_type_name'); return self::$_items; }
/** * @return \yii\db\ActiveQuery */ public function getUserTypes() { return $this->hasMany(UserType::className(), ['role' => 'id']); }
<?php $this->breadcrumbs = array('Users' => array('index'), 'Manage'); $this->menu = array(array('label' => 'List User', 'url' => array('index')), array('label' => 'Create User', 'url' => array('create'))); ?> <h1>Manage Users</h1> <?php $this->widget('zii.widgets.grid.CGridView', array('id' => 'user-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array('user_id', 'wlabel_id', 'username', array('name' => 'type', 'filter' => CHtml::listData(UserType::findAll(), 'id', 'name'), 'value' => '$data->getType($data->type)'), array('name' => 'status', 'filter' => CHtml::listData(UserStatus::findAll(), 'id', 'name'), 'value' => '$data->getStatus($data->status)'), 'date_created', array('class' => 'CButtonColumn', 'template' => '{update}{delete}', 'afterDelete' => 'function(link,success,data){ if(success) alert("Delete completed successfuly"); }'))));
public function getType($type) { return UserType::getType($type); }
<?php /* @var $this UserController */ /* @var $model User */ $this->breadcrumbs = array('Users' => array('index'), 'Manage'); $this->menu = array(array('label' => 'Create User', 'url' => array('create'))); Yii::app()->clientScript->registerScript('search', "\n\$('.search-button').click(function(){\n\t\$('.search-form').toggle();\n\treturn false;\n});\n\$('.search-form form').submit(function(){\n\t\$.fn.yiiGridView.update('user-grid', {\n\t\tdata: \$(this).serialize()\n\t});\n\treturn false;\n});\n"); ?> <h1>Manage Users</h1> <p> You may optionally enter a comparison operator (<b><</b>, <b><=</b>, <b>></b>, <b>>=</b>, <b><></b> or <b>=</b>) at the beginning of each of your search values to specify how the comparison should be done. </p> <?php echo CHtml::link('Advanced Search', '#', array('class' => 'search-button')); ?> <div class="search-form" style="display:none"> <?php $this->renderPartial('_search', array('model' => $model)); ?> </div><!-- search-form --> <?php $this->widget('zii.widgets.grid.CGridView', array('id' => 'user-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array('id', array('name' => 'country_id', 'value' => '!empty($data->country->name)?$data->country->name:"N/A"', 'filter' => CHtml::listData(Country::model()->findAll(array('order' => 'name')), 'id', 'name')), 'username', 'email', array('name' => 'type', 'value' => '!empty($data->userType->name)?$data->userType->name:"N/A"', 'filter' => CHtml::listData(UserType::model()->findAll(array('order' => 'name')), 'id', 'name')), array('name' => 'nofMessages', 'filter' => ''), array('name' => 'numberOfComments', 'filter' => ''), array('name' => 'nofMessagesRead', 'filter' => ''), array('name' => 'messageDetails', 'filter' => '', 'type' => 'raw'), array('class' => 'CButtonColumn', 'template' => '{update}{delete}', 'htmlOptions' => array('style' => 'min-width:50px'), 'header' => 'Actions', 'buttons' => array()))));
echo $form->textField($model, 'email', array("class" => "span3")); ?> </td> <td style='width:300px;'><?php echo $form->error($model, 'email'); ?> </td> </div></tr> <tr><div class="row"> <td style='width:150px;'><?php echo $form->labelEx($model, 'user_type'); ?> </td> <td><?php echo $form->dropdownList($model, 'user_type', CHtml::listData(UserType::model()->findAll(), 'id', 'type'), array('prompt' => 'Select Type', 'class' => 'span3', 'ajax' => array('type' => 'POST'))); ?> </td> <td style='width:300px;'><?php echo $form->error($model, 'user_type'); ?> </td> </div></tr> <tr><div class="row buttons"> <td style="padding-left: 109px;"> </td> <td>