本文整理汇总了PHP中TSession类的典型用法代码示例。如果您正苦于以下问题:PHP TSession类的具体用法?PHP TSession怎么用?PHP TSession使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TSession类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onSave
public function onSave($param)
{
try {
$this->form->validate();
$object = $this->form->getData();
TTransaction::open('permission');
$user = SystemUser::newFromLogin(TSession::getValue('login'));
$user->name = $object->name;
$user->email = $object->email;
if ($object->password1) {
if ($object->password1 != $object->password2) {
throw new Exception(_t('The passwords do not match'));
}
$user->password = md5($object->password1);
} else {
unset($user->password);
}
$user->store();
$this->form->setData($object);
new TMessage('info', TAdiantiCoreTranslator::translate('Record saved'));
TTransaction::close();
} catch (Exception $e) {
new TMessage('error', $e->getMessage());
}
}
示例2: acesso
public static function acesso($nivel)
{
$user = TSession::getValue('user');
if ($user->permissao < $nivel) {
AdiantiCoreApplication::loadPage('Home');
}
}
示例3: __construct
/**
* Class constructor
* Creates the page and the registration form
*/
function __construct()
{
parent::__construct();
// security check
if (TSession::getValue('logged') !== TRUE) {
throw new Exception(_t('Not logged'));
}
// security check
TTransaction::open('library');
if (User::newFromLogin(TSession::getValue('login'))->role->mnemonic !== 'LIBRARIAN') {
throw new Exception(_t('Permission denied'));
}
TTransaction::close();
// defines the database
parent::setDatabase('library');
// defines the active record
parent::setActiveRecord('Publisher');
// creates the form
$this->form = new TQuickForm('form_Publisher');
// create the form fields
$id = new TEntry('id');
$name = new TEntry('name');
$id->setEditable(FALSE);
// define the sizes
$this->form->addQuickField(_t('Code'), $id, 100);
$this->form->addQuickField(_t('Name'), $name, 200);
// define the form action
$this->form->addQuickAction(_t('Save'), new TAction(array($this, 'onSave')), 'ico_save.png');
// add the form to the page
parent::add($this->form);
}
示例4: run
public static function run($debug = FALSE)
{
new TSession();
if ($_REQUEST) {
$class = isset($_REQUEST['class']) ? $_REQUEST['class'] : '';
if (TSession::getValue('logged')) {
// logged
$programs = (array) TSession::getValue('programs');
// programs with permission
$programs = array_merge($programs, array('Adianti\\Base\\TStandardSeek' => TRUE, 'LoginForm' => TRUE, 'AdiantiMultiSearchService' => TRUE, 'AdiantiUploaderService' => TRUE, 'EmptyPage' => TRUE));
// default programs
if (isset($programs[$class])) {
parent::run($debug);
} else {
new TMessage('error', _t('Permission denied'));
}
} else {
if ($class == 'LoginForm') {
parent::run($debug);
} else {
new TMessage('error', _t('Permission denied'), new TAction(array('LoginForm', 'onLogout')));
}
}
}
}
示例5: __construct
/**
* Class Constructor
* @param $name name of the field
* @param $model name of the Model
* @param $form name of the Form
* @param $database name of the Database
* @param $filtros name of the field of filters (Array)
* @param $fields name of the fields of columns
*/
public function __construct($name, $model, $form, $database, $filtros, $fields)
{
parent::__construct($name);
$this->useOutEvent = TRUE;
$this->setProperty('class', 'tfield tseekentry', TRUE);
// classe CSS
$image = new TImage('lib/adianti/images/ico_find.png');
$this->button = new TElement('button');
$this->button->{'class'} = 'btn btn-default tseekbutton';
$this->button->{'type'} = 'button';
$this->button->{'id'} = 'Pbutton_' . $name;
$this->button->{'onmouseover'} = 'style.cursor = \'pointer\'';
$this->button->{'name'} = '_' . $this->name . '_link';
$this->button->{'onmouseout'} = 'style.cursor = \'default\'';
$this->button->add($image);
$url = 'index.php?class=PDBStandartSeek&method=onReload';
$action = "__adianti_load_page( '{$url}');";
$action .= "return false;";
$this->button->onclick = $action;
//configuração
TSession::setValue('Model', $model);
// model
TSession::setValue('form', $form);
//form de retorno
TSession::setValue('database', $database);
TSession::setValue('filtros', $filtros);
TSession::setValue('fields', $fields);
}
示例6: checkCliente
public static function checkCliente()
{
if (!TSession::getValue('cliente_logado')) {
new TMessage('info', 'Você não esta logado');
TCoreApplication::executeMethod('ClientesLogin');
}
}
示例7: onSave
/**
* method onSave()
* Executed whenever the user clicks at the save button
*/
function onSave()
{
try {
TTransaction::open('app');
// open a transaction
// get the form data into an active record SystemUser
$object = $this->form->getData('StdClass');
$this->form->validate();
// form validation
$senhaatual = $object->current;
$senhanova = $object->password;
$confirmacao = $object->confirmation;
$usuario = new SystemUser(TSession::getValue("userid"));
if ($usuario->password == md5($senhaatual)) {
if ($senhanova == $confirmacao) {
$usuario->password = md5($senhanova);
$usuario->store();
new TMessage('info', TAdiantiCoreTranslator::translate('Record saved'));
} else {
new TMessage('error', "A nova senha deve ser igual a sua confirmação.");
}
} else {
new TMessage('error', "A senha atual não confere.");
}
TTransaction::close();
// close the transaction
// shows the success message
} catch (Exception $e) {
// in case of exception
new TMessage('error', '<b>Error</b> ' . $e->getMessage());
// shows the exception error message
TTransaction::rollback();
// undo all pending operations
}
}
示例8: onSave
/**
* method onSave()
* Executed whenever the user clicks at the save button
*/
function onSave()
{
try {
// open a transaction with database 'changeman'
TTransaction::open('changeman');
// get the form data into an active record Issue
$object = $this->form->getData();
// form validation
$this->form->validate();
$member = Member::newFromLogin(TSession::getValue('login'));
if ($member->password !== md5($object->current_password)) {
throw new Exception(_t('Current password does not match'));
}
if ($object->new_password1 !== $object->new_password2) {
throw new Exception(_t('New password does not match the confirm password'));
}
// stores the object
$member->password = md5($object->new_password1);
$member->store();
// fill the form with the active record data
$this->form->setData($object);
// close the transaction
TTransaction::close();
// shows the success message
new TMessage('info', _t('Password changed successfully'));
// reload the listing
} catch (Exception $e) {
// shows the exception error message
new TMessage('error', '<b>Error</b> ' . $e->getMessage());
// undo all pending operations
TTransaction::rollback();
}
}
示例9: checkPermission
public static function checkPermission($action)
{
//pega as funcionalidades que o usuario logado pode acessar
$funcionalidades = TSession::getValue('funcionalidades');
//retorna true ou falso, indicando se o usuario pode ou nao acessar a tela
return isset($funcionalidades[$action]) and $funcionalidades[$action];
}
示例10: onSave
/**
* method onSave()
* Executed whenever the user clicks at the save button
*/
function onSave()
{
try {
// open a transaction with database 'changeman'
TTransaction::open('changeman');
// get the form data into an active record Note
$object = $this->form->getData('Note');
$logged = Member::newFromLogin(TSession::getValue('login'));
$object->id_user = $logged->id;
$object->register_date = date('Y-m-d');
$object->register_time = date('H:i');
// form validation
$this->form->validate();
// stores the object
$object->store();
$issue = new Issue($object->id_issue);
$project = new Project($issue->id_project);
$member = new Member($issue->id_user);
// who has opened the issue
// read email configuration file
$ini = parse_ini_file('app/config/email.ini');
$members = $project->getMembers(array('MEMBER', 'MANAGER'));
$members = array_merge($members, array($member));
// merge the logged user
$mail_template = file_get_contents('app/resources/note.html');
$mail_template = str_replace('{DESCRIPTION}', $issue->description, $mail_template);
$mail_template = str_replace('{OPENER}', $member->name . ' ' . $issue->register_date . ' ' . $issue->issue_time, $mail_template);
$mail_template = str_replace('{NOTE}', $object->note, $mail_template);
$mail_template = str_replace('{MEMBER}', $logged->name . ' ' . $object->register_date . ' ' . $object->register_time, $mail_template);
$mail = new TMail();
$mail->setFrom($ini['from'], $ini['name']);
$mail->setSubject(_t('Note') . ' #' . $issue->id . ': ' . $issue->title);
$mail->setHtmlBody($mail_template);
foreach ($members as $member) {
$emails = explode(',', $member->email);
foreach ($emails as $email) {
$mail->addAddress(trim($email), $member->name);
// echo "{$email}, {$member-> name} <br>";
}
}
$mail->SetUseSmtp();
$mail->SetSmtpHost($ini['host'], $ini['port']);
$mail->SetSmtpUser($ini['user'], $ini['pass']);
$mail->setReplyTo($ini['repl']);
$mail->send();
// fill the form with the active record data
$this->form->setData($object);
// close the transaction
TTransaction::close();
// shows the success message
new TMessage('info', TAdiantiCoreTranslator::translate('Record saved'));
// reload the listing
} catch (Exception $e) {
// shows the exception error message
new TMessage('error', '<b>Error</b> ' . $e->getMessage());
// undo all pending operations
TTransaction::rollback();
}
}
示例11: require_connection
public function require_connection()
{
if (!TSession::try_get_value('id_user', $id_user)) {
return $this->connected = false;
} else {
return $this->connected = $id_user;
}
}
示例12: onDelete
public function onDelete($param)
{
$key = $param['key'];
$objects = TSession::getValue('session_contacts');
unset($objects[$key]);
TSession::setValue('session_contacts', $objects);
$this->onReload();
}
示例13: __construct
/**
* Class constructor
* Creates the page and the registration form
*/
function __construct()
{
parent::__construct();
// security check
if (TSession::getValue('logged') !== TRUE) {
throw new Exception(_t('Not logged'));
}
}
示例14: __construct
/**
* Class constructor
* Creates the page, the form and the listing
*/
public function __construct()
{
parent::__construct();
parent::setDatabase('samples');
// defines the database
parent::setActiveRecord('Product');
// defines the active record
parent::setDefaultOrder('id', 'asc');
// defines the default order
parent::addFilterField('description', 'like');
// add a filter field
parent::addFilterField('unity', '=');
// add a filter field
// creates the form, with a table inside
$this->form = new TQuickForm('form_search_Product');
$this->form->class = 'tform';
$this->form->style = 'width: 650px';
$this->form->setFormTitle('Products');
$units = array('PC' => 'Pieces', 'GR' => 'Grain');
// create the form fields
$description = new TEntry('description');
$unit = new TCombo('unity');
$unit->addItems($units);
// add a row for the filter field
$this->form->addQuickField('Description', $description, 200);
$this->form->addQuickField('Unit', $unit, 200);
$this->form->setData(TSession::getValue('Product_filter_data'));
$this->form->addQuickAction(_t('Find'), new TAction(array($this, 'onSearch')), 'ico_find.png');
$this->form->addQuickAction(_t('New'), new TAction(array('ProductForm', 'onEdit')), 'ico_new.png');
// creates a DataGrid
$this->datagrid = new TQuickGrid();
$this->datagrid->setHeight(320);
// creates the datagrid columns
$id = $this->datagrid->addQuickColumn('ID', 'id', 'center', 50);
$description = $this->datagrid->addQuickColumn('Description', 'description', 'left', 300);
$stock = $this->datagrid->addQuickColumn('Stock', 'stock', 'right', 70);
$sale_price = $this->datagrid->addQuickColumn('Sale Price', 'sale_price', 'right', 70);
$unity = $this->datagrid->addQuickColumn('Unit', 'unity', 'right', 70);
// create the datagrid actions
$edit_action = new TDataGridAction(array('ProductForm', 'onEdit'));
$delete_action = new TDataGridAction(array($this, 'onDelete'));
// add the actions to the datagrid
$this->datagrid->addQuickAction(_t('Edit'), $edit_action, 'id', 'ico_edit.png');
$this->datagrid->addQuickAction(_t('Delete'), $delete_action, 'id', 'ico_delete.png');
// create the datagrid model
$this->datagrid->createModel();
// create the page navigation
$this->pageNavigation = new TPageNavigation();
$this->pageNavigation->setAction(new TAction(array($this, 'onReload')));
$this->pageNavigation->setWidth($this->datagrid->getWidth());
// create the page container
$container = new TVBox();
$container->add(new TXMLBreadCrumb('menu.xml', 'ProductList'));
$container->add($this->form);
$container->add($this->datagrid);
$container->add($this->pageNavigation);
parent::add($container);
}
示例15: __construct
/**
* Class constructor
* Creates the page and the registration form
*/
function __construct()
{
parent::__construct();
// security check
if (TSession::getValue('logged') !== TRUE) {
throw new Exception(_t('Not logged'));
}
// security check
TTransaction::open('library');
if (User::newFromLogin(TSession::getValue('login'))->role->mnemonic !== 'LIBRARIAN') {
throw new Exception(_t('Permission denied'));
}
TTransaction::close();
// defines the database
parent::setDatabase('library');
// defines the active record
parent::setActiveRecord('Classification');
// creates the form
$this->form = new TQuickForm('form_Classification');
// create the form fields
$id = new TEntry('id');
$description = new TEntry('description');
$id->setEditable(FALSE);
// define the sizes
$this->form->addQuickField(_t('Code'), $id, 100);
$this->form->addQuickField(_t('Description'), $description, 200);
// define the form action
$this->form->addQuickAction(_t('Save'), new TAction(array($this, 'onSave')), 'ico_save.png');
$this->form->addQuickAction(_t('New'), new TAction(array($this, 'onEdit')), 'ico_new.png');
// creates a DataGrid
$this->datagrid = new TQuickGrid();
$this->datagrid->setHeight(320);
// creates the datagrid columns
$this->datagrid->addQuickColumn(_t('Code'), 'id', 'left', 100, new TAction(array($this, 'onReload')), array('order', 'id'));
$this->datagrid->addQuickColumn(_t('Description'), 'description', 'left', 200, new TAction(array($this, 'onReload')), array('order', 'description'));
// add the actions to the datagrid
$this->datagrid->addQuickAction(_t('Edit'), new TDataGridAction(array($this, 'onEdit')), 'id', 'ico_edit.png');
$this->datagrid->addQuickAction(_t('Delete'), new TDataGridAction(array($this, 'onDelete')), 'id', 'ico_delete.png');
// create the datagrid model
$this->datagrid->createModel();
// creates the page navigation
$this->pageNavigation = new TPageNavigation();
$this->pageNavigation->setAction(new TAction(array($this, 'onReload')));
$this->pageNavigation->setWidth($this->datagrid->getWidth());
// creates the page structure using a table
$table = new TTable();
// add a row to the form
$row = $table->addRow();
$row->addCell($this->form);
// add a row to the datagrid
$row = $table->addRow();
$row->addCell($this->datagrid);
// add a row for page navigation
$row = $table->addRow();
$row->addCell($this->pageNavigation);
// add the table inside the page
parent::add($table);
}