本文整理汇总了PHP中osc_logged_admin_id函数的典型用法代码示例。如果您正苦于以下问题:PHP osc_logged_admin_id函数的具体用法?PHP osc_logged_admin_id怎么用?PHP osc_logged_admin_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了osc_logged_admin_id函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: osc_deleteResource
/**
* Remove resources from disk
* @param <type> $id
* @param boolean $admin
* @return boolean
*/
function osc_deleteResource($id, $admin)
{
if (defined('DEMO')) {
return false;
}
if (is_array($id)) {
$id = $id[0];
}
$resource = ItemResource::newInstance()->findByPrimaryKey($id);
if (!is_null($resource)) {
Log::newInstance()->insertLog('item', 'delete resource', $resource['pk_i_id'], $id, $admin ? 'admin' : 'user', $admin ? osc_logged_admin_id() : osc_logged_user_id());
$backtracel = '';
foreach (debug_backtrace() as $k => $v) {
if ($v['function'] == "include" || $v['function'] == "include_once" || $v['function'] == "require_once" || $v['function'] == "require") {
$backtracel .= "#" . $k . " " . $v['function'] . "(" . $v['args'][0] . ") called@ [" . $v['file'] . ":" . $v['line'] . "] / ";
} else {
$backtracel .= "#" . $k . " " . $v['function'] . " called@ [" . $v['file'] . ":" . $v['line'] . "] / ";
}
}
Log::newInstance()->insertLog('item', 'delete resource backtrace', $resource['pk_i_id'], $backtracel, $admin ? 'admin' : 'user', $admin ? osc_logged_admin_id() : osc_logged_user_id());
@unlink(osc_base_path() . $resource['s_path'] . $resource['pk_i_id'] . "." . $resource['s_extension']);
@unlink(osc_base_path() . $resource['s_path'] . $resource['pk_i_id'] . "_original." . $resource['s_extension']);
@unlink(osc_base_path() . $resource['s_path'] . $resource['pk_i_id'] . "_thumbnail." . $resource['s_extension']);
@unlink(osc_base_path() . $resource['s_path'] . $resource['pk_i_id'] . "_preview." . $resource['s_extension']);
osc_run_hook('delete_resource', $resource);
}
}
示例2: doModel
function doModel()
{
parent::doModel();
//specific things for this class
switch ($this->action) {
case 'bulk_actions':
switch (Params::getParam('bulk_actions')) {
case 'delete_all':
$ids = Params::getParam("id");
if (is_array($ids)) {
foreach ($ids as $id) {
osc_deleteResource($id, true);
}
$log_ids = substr(implode(",", $ids), 0, 250);
Log::newInstance()->insertLog('media', 'delete bulk', $log_ids, $log_ids, 'admin', osc_logged_admin_id());
$this->resourcesManager->deleteResourcesIds($ids);
}
osc_add_flash_ok_message(_m('Resource deleted'), 'admin');
break;
default:
break;
}
$this->redirectTo(osc_admin_base_url(true) . '?page=media');
break;
case 'delete':
$ids = Params::getParam('id');
if (is_array($ids)) {
foreach ($ids as $id) {
osc_deleteResource($id, true);
}
$log_ids = substr(implode(",", $ids), 0, 250);
Log::newInstance()->insertLog('media', 'delete', $log_ids, $log_ids, 'admin', osc_logged_admin_id());
$this->resourcesManager->deleteResourcesIds($ids);
}
osc_add_flash_ok_message(_m('Resource deleted'), 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=media');
break;
default:
$this->doView('media/index.php');
break;
}
}
示例3: doModel
//.........这里部分代码省略.........
if( !osc_validate_username($sUserName) ) {
osc_add_flash_warning_message( _m("Username invalid"), 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=admins&action=edit&id=' . $adminId);
}
if( $sName == '' ) {
osc_add_flash_warning_message( _m("Name invalid"), 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=admins&action=edit&id=' . $adminId);
}
$aAdmin = $this->adminManager->findByPrimaryKey($adminId);
if( count($aAdmin) == 0 ) {
osc_add_flash_error_message( _m("This admin doesn't exist"), 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=admins');
}
if( $aAdmin['s_email'] != $sEmail ) {
if($this->adminManager->findByEmail( $sEmail ) ) {
osc_add_flash_warning_message( _m('Existing email'), 'admin');
$this->redirectTo(osc_admin_base_url(true).'?page=admins&action=edit&id=' . $adminId);
}
}
if( $aAdmin['s_username'] != $sUserName ) {
if( $this->adminManager->findByUsername( $sUserName ) ) {
osc_add_flash_warning_message( _m('Existing username'), 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=admins&action=edit&id=' . $adminId);
}
}
$conditions = array('pk_i_id' => $adminId);
$array = array();
if(osc_logged_admin_id()==$adminId) {
if($sOldPassword != '' ) {
if( $sPassword=='' ) {
osc_add_flash_warning_message( _m("Password invalid"), 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=admins&action=edit&id=' . $adminId);
} else {
$firstCondition = osc_verify_password($sOldPassword, $aAdmin['s_password']);
$secondCondition = ( $sPassword == $sPassword2 );
if( $firstCondition && $secondCondition ) {
$array['s_password'] = osc_hash_password($sPassword);
} else {
osc_add_flash_warning_message( _m("The password couldn't be updated. Passwords don't match"), 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=admins&action=edit&id=' . $adminId);
}
}
}
} else {
if( $sPassword!='') {
if($sPassword == $sPassword2) {
$array['s_password'] = osc_hash_password($sPassword);
} else {
osc_add_flash_warning_message( _m("The password couldn't be updated. Passwords don't match"), 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=admins&action=edit&id=' . $adminId);
}
}
}
if($adminId!=osc_logged_admin_id()) {
$array['b_moderator'] = $bModerator;
}
$array['s_name'] = Params::getParam('s_name');
$array['s_username'] = $sUserName;
示例4: doModel
function doModel()
{
parent::doModel();
//specific things for this class
switch ($this->action) {
case 'bulk_actions':
osc_csrf_check();
switch (Params::getParam('bulk_actions')) {
case 'delete':
$ids = Params::getParam("id");
if (is_array($ids)) {
foreach ($ids as $id) {
osc_deleteResource($id, true);
}
$log_ids = substr(implode(",", $ids), 0, 250);
Log::newInstance()->insertLog('media', 'delete bulk', $log_ids, $log_ids, 'admin', osc_logged_admin_id());
$this->resourcesManager->deleteResourcesIds($ids);
}
osc_add_flash_ok_message(_m('Resource deleted'), 'admin');
break;
default:
if (Params::getParam("bulk_actions") != "") {
osc_run_hook("media_bulk_" . Params::getParam("bulk_actions"), Params::getParam('id'));
}
break;
}
$this->redirectTo(osc_admin_base_url(true) . '?page=media');
break;
case 'delete':
osc_csrf_check();
$ids = Params::getParam('id');
if (is_array($ids)) {
foreach ($ids as $id) {
osc_deleteResource($id, true);
}
$log_ids = substr(implode(",", $ids), 0, 250);
Log::newInstance()->insertLog('media', 'delete', $log_ids, $log_ids, 'admin', osc_logged_admin_id());
$this->resourcesManager->deleteResourcesIds($ids);
}
osc_add_flash_ok_message(_m('Resource deleted'), 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=media');
break;
default:
require_once osc_lib_path() . "osclass/classes/datatables/MediaDataTable.php";
// set default iDisplayLength
if (Params::getParam('iDisplayLength') != '') {
Cookie::newInstance()->push('listing_iDisplayLength', Params::getParam('iDisplayLength'));
Cookie::newInstance()->set();
} else {
// set a default value if it's set in the cookie
if (Cookie::newInstance()->get_value('listing_iDisplayLength') != '') {
Params::setParam('iDisplayLength', Cookie::newInstance()->get_value('listing_iDisplayLength'));
} else {
Params::setParam('iDisplayLength', 10);
}
}
$this->_exportVariableToView('iDisplayLength', Params::getParam('iDisplayLength'));
// Table header order by related
if (Params::getParam('sort') == '') {
Params::setParam('sort', 'date');
}
if (Params::getParam('direction') == '') {
Params::setParam('direction', 'desc');
}
$page = (int) Params::getParam('iPage');
if ($page == 0) {
$page = 1;
}
Params::setParam('iPage', $page);
$params = Params::getParamsAsArray();
$mediaDataTable = new MediaDataTable();
$mediaDataTable->table($params);
$aData = $mediaDataTable->getData();
if (count($aData['aRows']) == 0 && $page != 1) {
$total = (int) $aData['iTotalDisplayRecords'];
$maxPage = ceil($total / (int) $aData['iDisplayLength']);
$url = osc_admin_base_url(true) . '?' . Params::getServerParam('QUERY_STRING', false, false);
if ($maxPage == 0) {
$url = preg_replace('/&iPage=(\\d)+/', '&iPage=1', $url);
$this->redirectTo($url);
}
if ($page > 1) {
$url = preg_replace('/&iPage=(\\d)+/', '&iPage=' . $maxPage, $url);
$this->redirectTo($url);
}
}
$this->_exportVariableToView('aData', $aData);
$this->_exportVariableToView('aRawRows', $mediaDataTable->rawRows());
$bulk_options = array(array('value' => '', 'data-dialog-content' => '', 'label' => __('Bulk actions')), array('value' => 'delete', 'data-dialog-content' => sprintf(__('Are you sure you want to %s the selected media files?'), strtolower(__('Delete'))), 'label' => __('Delete')));
$bulk_options = osc_apply_filter("media_bulk_filter", $bulk_options);
$this->_exportVariableToView('bulk_options', $bulk_options);
$this->doView('media/index.php');
break;
}
}
示例5: disable
public function disable($user_id)
{
$user = $this->manager->findByPrimaryKey($user_id);
if( !$user ) {
return false;
}
$this->manager->update( array('b_enabled' => 0), array('pk_i_id' => $user_id) );
Log::newInstance()->insertLog('user', 'disable', $user_id, $user['s_email'], $this->is_admin ? 'admin' : 'user', $this->is_admin ? osc_logged_admin_id() : osc_logged_user_id());
if( $user['b_active'] == 1 ) {
$mItem = new ItemActions(true);
$items = Item::newInstance()->findByUserID($user_id);
foreach($items as $item) {
$mItem->disable($item['pk_i_id']);
}
}
osc_run_hook('disable_user', $user);
return true;
}
示例6: doModel
//.........这里部分代码省略.........
}
$aItem = Item::newInstance()->findByPrimaryKey($item);
// Check if the item exists
if (count($aItem) == 0) {
$json['success'] = false;
$json['msg'] = _m("The listing doesn't exist");
echo json_encode($json);
return false;
}
if (!osc_is_admin_user_logged_in()) {
// Check if the item belong to the user
if ($userId != null && $userId != $aItem['fk_i_user_id']) {
$json['success'] = false;
$json['msg'] = _m("The listing doesn't belong to you");
echo json_encode($json);
return false;
}
// Check if the secret passphrase match with the item
if ($userId == null && $aItem['fk_i_user_id'] == null && $secret != $aItem['s_secret']) {
$json['success'] = false;
$json['msg'] = _m("The listing doesn't belong to you");
echo json_encode($json);
return false;
}
}
// Does id & code combination exist?
$result = ItemResource::newInstance()->existResource($id, $code);
if ($result > 0) {
$resource = ItemResource::newInstance()->findByPrimaryKey($id);
if ($resource['fk_i_item_id'] == $item) {
// Delete: file, db table entry
if (defined(OC_ADMIN)) {
osc_deleteResource($id, true);
Log::newInstance()->insertLog('ajax', 'deleteimage', $id, $id, 'admin', osc_logged_admin_id());
} else {
osc_deleteResource($id, false);
Log::newInstance()->insertLog('ajax', 'deleteimage', $id, $id, 'user', osc_logged_user_id());
}
ItemResource::newInstance()->delete(array('pk_i_id' => $id, 'fk_i_item_id' => $item, 's_name' => $code));
$json['msg'] = _m('The selected photo has been successfully deleted');
$json['success'] = 'true';
} else {
$json['msg'] = _m("The selected photo does not belong to you");
$json['success'] = 'false';
}
} else {
$json['msg'] = _m("The selected photo couldn't be deleted");
$json['success'] = 'false';
}
echo json_encode($json);
return true;
break;
case 'alerts':
// Allow to register to an alert given (not sure it's used on admin)
$encoded_alert = Params::getParam("alert");
$alert = osc_decrypt_alert(base64_decode($encoded_alert));
// check alert integrity / signature
$stringToSign = osc_get_alert_public_key() . $encoded_alert;
$signature = hex2b64(hmacsha1(osc_get_alert_private_key(), $stringToSign));
$server_signature = Session::newInstance()->_get('alert_signature');
if ($server_signature != $signature) {
echo '-2';
return false;
}
$email = Params::getParam("email");
$userid = Params::getParam("userid");
示例7: _e
?>
</div>
</div>
<div class="input-line">
<label><?php
_e('E-mail <em>(required)</em>');
?>
</label>
<div class="input">
<?php
AdminForm::email_text($admin);
?>
</div>
</div>
<?php
if ($admin_edit && osc_logged_admin_id() == $admin['pk_i_id']) {
?>
<div class="input-line">
<label><?php
_e('Current password');
?>
</label>
<div class="input">
<?php
AdminForm::old_password_text($admin);
?>
<p class="help-inline"><em><?php
_e('If you would like to change the password type a new one. Otherwise leave this blank');
?>
</em></p>
</div>
示例8: doModel
//.........这里部分代码省略.........
$this->doView('items/frm.php');
break;
case 'item_edit_post':
$mItems = new ItemActions(true);
$mItems->prepareData(false);
// set all parameters into session
foreach ($mItems->data as $key => $value) {
Session::newInstance()->_setForm($key, $value);
}
$meta = Params::getParam('meta');
if (is_array($meta)) {
foreach ($meta as $key => $value) {
Session::newInstance()->_setForm('meta_' . $key, $value);
Session::newInstance()->_keepForm('meta_' . $key);
}
}
$success = $mItems->edit();
if ($success == 1) {
Session::newInstance()->_clearVariables();
osc_add_flash_ok_message(_m('Changes saved correctly'), 'admin');
$this->redirectTo(osc_admin_base_url(true) . "?page=items");
} else {
osc_add_flash_error_message($success, 'admin');
$this->redirectTo(osc_admin_base_url(true) . "?page=items&action=item_edit&id=" . Params::getParam('id'));
}
break;
case 'deleteResource':
//delete resource
$id = Params::getParam('id');
$name = Params::getParam('name');
$fkid = Params::getParam('fkid');
// delete files
osc_deleteResource($id, true);
Log::newInstance()->insertLog('items', 'deleteResource', $id, $id, 'admin', osc_logged_admin_id());
$result = ItemResource::newInstance()->delete(array('pk_i_id' => $id, 'fk_i_item_id' => $fkid, 's_name' => $name));
if ($result === false) {
osc_add_flash_error_message(_m('Some error has occurred'), 'admin');
} else {
osc_add_flash_ok_message(_m('Resource deleted'), 'admin');
}
$this->redirectTo(osc_admin_base_url(true) . "?page=items");
break;
case 'post':
// add item
$form = count(Session::newInstance()->_getForm());
$keepForm = count(Session::newInstance()->_getKeepForm());
if ($form == 0 || $form == $keepForm) {
Session::newInstance()->_dropKeepForm();
}
$this->_exportVariableToView("new_item", TRUE);
$this->doView('items/frm.php');
break;
case 'post_item':
//post item
$mItem = new ItemActions(true);
$mItem->prepareData(true);
// set all parameters into session
foreach ($mItem->data as $key => $value) {
Session::newInstance()->_setForm($key, $value);
}
$meta = Params::getParam('meta');
if (is_array($meta)) {
foreach ($meta as $key => $value) {
Session::newInstance()->_setForm('meta_' . $key, $value);
Session::newInstance()->_keepForm('meta_' . $key);
}
示例9: doModel
function doModel()
{
parent::doModel();
//specific things for this class
switch ($this->action) {
case 'bulk_actions':
switch (Params::getParam('bulk_actions')) {
case 'delete_all':
$ids = Params::getParam("id");
if (is_array($ids)) {
foreach ($ids as $id) {
osc_deleteResource($id, true);
}
$log_ids = substr(implode(",", $ids), 0, 250);
Log::newInstance()->insertLog('media', 'delete bulk', $log_ids, $log_ids, 'admin', osc_logged_admin_id());
$this->resourcesManager->deleteResourcesIds($ids);
}
osc_add_flash_ok_message(_m('Resource deleted'), 'admin');
break;
default:
break;
}
$this->redirectTo(osc_admin_base_url(true) . '?page=media');
break;
case 'delete':
$ids = Params::getParam('id');
if (is_array($ids)) {
foreach ($ids as $id) {
osc_deleteResource($id, true);
}
$log_ids = substr(implode(",", $ids), 0, 250);
Log::newInstance()->insertLog('media', 'delete', $log_ids, $log_ids, 'admin', osc_logged_admin_id());
$this->resourcesManager->deleteResourcesIds($ids);
}
osc_add_flash_ok_message(_m('Resource deleted'), 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=media');
break;
default:
if (Params::getParam('iDisplayLength') == '') {
Params::setParam('iDisplayLength', 10);
}
$this->_exportVariableToView('iDisplayLength', Params::getParam('iDisplayLength'));
require_once osc_admin_base_path() . 'ajax/media_processing.php';
$params = Params::getParamsAsArray("get");
$media_processing = new MediaProcessingAjax($params);
$aData = $media_processing->result($params);
$page = (int) Params::getParam('iPage');
if (count($aData['aaData']) == 0 && $page != 1) {
$total = (int) $aData['iTotalDisplayRecords'];
$maxPage = ceil($total / (int) $aData['iDisplayLength']);
$url = osc_admin_base_url(true) . '?' . $_SERVER['QUERY_STRING'];
if ($maxPage == 0) {
$url = preg_replace('/&iPage=(\\d)+/', '&iPage=1', $url);
$this->redirectTo($url);
}
if ($page > 1) {
$url = preg_replace('/&iPage=(\\d)+/', '&iPage=' . $maxPage, $url);
$this->redirectTo($url);
}
}
$this->_exportVariableToView('aMedia', $aData);
$this->doView('media/index.php');
break;
}
}
示例10: doModel
function doModel()
{
//specific things for this class
switch ($this->action) {
case 'bulk_actions':
break;
case 'regions':
//Return regions given a countryId
$regions = Region::newInstance()->findByCountry(Params::getParam("countryId"));
echo json_encode($regions);
break;
case 'cities':
//Returns cities given a regionId
$cities = City::newInstance()->findByRegion(Params::getParam("regionId"));
echo json_encode($cities);
break;
case 'location':
// This is the autocomplete AJAX
$cities = City::newInstance()->ajax(Params::getParam("term"));
foreach ($cities as $k => $city) {
$cities[$k]['label'] = $city['label'] . " (" . $city['region'] . ")";
}
echo json_encode($cities);
break;
case 'location_countries':
// This is the autocomplete AJAX
$countries = Country::newInstance()->ajax(Params::getParam("term"));
echo json_encode($countries);
break;
case 'location_regions':
// This is the autocomplete AJAX
$regions = Region::newInstance()->ajax(Params::getParam("term"), Params::getParam("country"));
echo json_encode($regions);
break;
case 'location_cities':
// This is the autocomplete AJAX
$cities = City::newInstance()->ajax(Params::getParam("term"), Params::getParam("region"));
echo json_encode($cities);
break;
case 'delete_image':
// Delete images via AJAX
$id = Params::getParam('id');
$item = Params::getParam('item');
$code = Params::getParam('code');
$secret = Params::getParam('secret');
$json = array();
if (Session::newInstance()->_get('userId') != '') {
$userId = Session::newInstance()->_get('userId');
$user = User::newInstance()->findByPrimaryKey($userId);
} else {
$userId = null;
$user = null;
}
// Check for required fields
if (!(is_numeric($id) && is_numeric($item) && preg_match('/^([a-z0-9]+)$/i', $code))) {
$json['success'] = false;
$json['msg'] = _m("The selected photo couldn't be deleted, the url doesn't exist");
echo json_encode($json);
return false;
}
$aItem = Item::newInstance()->findByPrimaryKey($item);
// Check if the item exists
if (count($aItem) == 0) {
$json['success'] = false;
$json['msg'] = _m("The listing doesn't exist");
echo json_encode($json);
return false;
}
if (!osc_is_admin_user_logged_in()) {
// Check if the item belong to the user
if ($userId != null && $userId != $aItem['fk_i_user_id']) {
$json['success'] = false;
$json['msg'] = _m("The listing doesn't belong to you");
echo json_encode($json);
return false;
}
// Check if the secret passphrase match with the item
if ($userId == null && $aItem['fk_i_user_id'] == null && $secret != $aItem['s_secret']) {
$json['success'] = false;
$json['msg'] = _m("The listing doesn't belong to you");
echo json_encode($json);
return false;
}
}
// Does id & code combination exist?
$result = ItemResource::newInstance()->existResource($id, $code);
if ($result > 0) {
$resource = ItemResource::newInstance()->findByPrimaryKey($id);
if ($resource['fk_i_item_id'] == $item) {
// Delete: file, db table entry
if (defined(OC_ADMIN)) {
osc_deleteResource($id, true);
Log::newInstance()->insertLog('ajax', 'deleteimage', $id, $id, 'admin', osc_logged_admin_id());
} else {
osc_deleteResource($id, false);
Log::newInstance()->insertLog('ajax', 'deleteimage', $id, $id, 'user', osc_logged_user_id());
}
ItemResource::newInstance()->delete(array('pk_i_id' => $id, 'fk_i_item_id' => $item, 's_name' => $code));
$json['msg'] = _m('The selected photo has been successfully deleted');
$json['success'] = 'true';
//.........这里部分代码省略.........
示例11: doModel
//.........这里部分代码省略.........
}
switch ($iUpdated) {
case 0:
$msg = _m('No user has been enabled');
break;
case 1:
$msg = _m('One user has been enabled');
break;
default:
$msg = sprintf(_m('%s users have been enabled'), $iUpdated);
break;
}
osc_add_flash_ok_message($msg, 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=users');
break;
case 'disable':
require_once LIB_PATH . 'osclass/UserActions.php';
$iUpdated = 0;
$userId = Params::getParam('id');
if (!is_array($userId)) {
osc_add_flash_error_message(_m('User id isn\'t in the correct format'), 'admin');
}
$userActions = new UserActions(true);
foreach ($userId as $id) {
$iUpdated += $userActions->disable($id);
}
switch ($iUpdated) {
case 0:
$msg = _m('No user has been disabled');
break;
case 1:
$msg = _m('One user has been disabled');
break;
default:
$msg = sprintf(_m('%s users have been disabled'), $iUpdated);
break;
}
osc_add_flash_ok_message($msg, 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=users');
break;
case 'delete':
//delete
$iDeleted = 0;
$userId = Params::getParam('id');
if (!is_array($userId)) {
osc_add_flash_error_message(_m('User id isn\'t in the correct format'), 'admin');
}
foreach ($userId as $id) {
$user = $this->userManager->findByPrimaryKey($id);
Log::newInstance()->insertLog('user', 'delete', $id, $user['s_email'], 'admin', osc_logged_admin_id());
if ($this->userManager->deleteUser($id)) {
$iDeleted++;
}
}
switch ($iDeleted) {
case 0:
$msg = _m('No user has been deleted');
break;
case 1:
$msg = _m('One user has been deleted');
break;
default:
$msg = sprintf(_m('%s users have been deleted'), $iDeleted);
break;
}
osc_add_flash_ok_message($msg, 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=users');
break;
case 'settings':
// calling the users settings view
$this->doView('users/settings.php');
break;
case 'settings_post':
// updating users
$iUpdated = 0;
$enabledUserValidation = Params::getParam('enabled_user_validation');
$enabledUserValidation = $enabledUserValidation != '' ? true : false;
$enabledUserRegistration = Params::getParam('enabled_user_registration');
$enabledUserRegistration = $enabledUserRegistration != '' ? true : false;
$enabledUsers = Params::getParam('enabled_users');
$enabledUsers = $enabledUsers != '' ? true : false;
$notifyNewUser = Params::getParam('notify_new_user');
$notifyNewUser = $notifyNewUser != '' ? true : false;
$iUpdated += Preference::newInstance()->update(array('s_value' => $enabledUserValidation), array('s_name' => 'enabled_user_validation'));
$iUpdated += Preference::newInstance()->update(array('s_value' => $enabledUserRegistration), array('s_name' => 'enabled_user_registration'));
$iUpdated += Preference::newInstance()->update(array('s_value' => $enabledUsers), array('s_name' => 'enabled_users'));
$iUpdated += Preference::newInstance()->update(array('s_value' => $notifyNewUser), array('s_name' => 'notify_new_user'));
if ($iUpdated > 0) {
osc_add_flash_ok_message(_m('Users\' settings have been updated'), 'admin');
}
$this->redirectTo(osc_admin_base_url(true) . '?page=users&action=settings');
break;
default:
// manage users view
$aUsers = $this->userManager->listAll();
$this->_exportVariableToView("users", $aUsers);
$this->doView("users/index.php");
break;
}
}
示例12: doModel
//.........这里部分代码省略.........
$sUserName = strip_tags($sUserName);
$sUserName = trim($sUserName);
// Checks for legit data
if (!osc_validate_email($sEmail, true)) {
osc_add_flash_warning_message(_m("Email invalid"), 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=admins&action=edit&id=' . $adminId);
}
if (!osc_validate_username($sUserName)) {
osc_add_flash_warning_message(_m("Username invalid"), 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=admins&action=edit&id=' . $adminId);
}
if ($sName == '') {
osc_add_flash_warning_message(_m("Name invalid"), 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=admins&action=edit&id=' . $adminId);
}
$aAdmin = $this->adminManager->findByPrimaryKey($adminId);
if (count($aAdmin) == 0) {
osc_add_flash_error_message(_m("This admin doesn't exist"), 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=admins');
}
if ($aAdmin['s_email'] != $sEmail) {
if ($this->adminManager->findByEmail($sEmail)) {
osc_add_flash_warning_message(_m('Existing email'), 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=admins&action=edit&id=' . $adminId);
}
}
if ($aAdmin['s_username'] != $sUserName) {
if ($this->adminManager->findByUsername($sUserName)) {
osc_add_flash_warning_message(_m('Existing username'), 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=admins&action=edit&id=' . $adminId);
}
}
$conditions = array('pk_i_id' => $adminId);
$array = array();
if (osc_logged_admin_id() == $adminId) {
if ($sOldPassword != '') {
if ($sPassword == '') {
osc_add_flash_warning_message(_m("Password invalid"), 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=admins&action=edit&id=' . $adminId);
} else {
$firstCondition = sha1($sOldPassword) == $aAdmin['s_password'];
$secondCondition = $sPassword == $sPassword2;
if ($firstCondition && $secondCondition) {
$array['s_password'] = sha1($sPassword);
} else {
osc_add_flash_warning_message(_m("The password couldn't be updated. Passwords don't match"), 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=admins&action=edit&id=' . $adminId);
}
}
}
} else {
if ($sPassword != '' && $sPassword == $sPassword2) {
$array['s_password'] = sha1($sPassword);
} else {
osc_add_flash_warning_message(_m("The password couldn't be updated. Passwords don't match"), 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=admins&action=edit&id=' . $adminId);
}
}
$array['s_name'] = Params::getParam('s_name');
$array['s_username'] = $sUserName;
$array['s_email'] = $sEmail;
$iUpdated = $this->adminManager->update($array, $conditions);
if ($iUpdated > 0) {
osc_add_flash_ok_message(_m('The admin has been updated'), 'admin');
}
$this->redirectTo(osc_admin_base_url(true) . '?page=admins');
break;
case 'delete':
if (defined('DEMO')) {
osc_add_flash_warning_message(_m("This action cannot be done because is a demo site"), 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=admins');
}
// deleting and admin
$isDeleted = false;
$adminId = Params::getParam('id');
if (!is_array($adminId)) {
osc_add_flash_error_message(_m("The admin id isn't in the correct format"), 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=admins');
}
// Verification to avoid an administrator trying to remove to itself
if (in_array(Session::newInstance()->_get('adminId'), $adminId)) {
osc_add_flash_error_message(_m("The operation hasn't been completed. You're trying to remove yourself!"), 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=admins');
}
$isDeleted = $this->adminManager->deleteBatch($adminId);
if ($isDeleted) {
osc_add_flash_ok_message(_m('The admin has been deleted correctly'), 'admin');
} else {
osc_add_flash_error_message(_m('The admin couldn\'t be deleted'), 'admin');
}
$this->redirectTo(osc_admin_base_url(true) . '?page=admins');
break;
default:
// calling manage admins view
$admins = $this->adminManager->listAll();
$this->_exportVariableToView('admins', $admins);
$this->doView('admins/index.php');
break;
}
}
示例13: doModel
//.........这里部分代码省略.........
osc_add_flash_ok_message($msg, 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=users');
break;
case 'disable':
require_once LIB_PATH . 'osclass/UserActions.php';
$iUpdated = 0;
$userId = Params::getParam('id');
if (!is_array($userId)) {
osc_add_flash_error_message(_m("User id isn't in the correct format"), 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=users');
}
$userActions = new UserActions(true);
foreach ($userId as $id) {
$iUpdated += $userActions->disable($id);
}
if ($iUpdated == 0) {
$msg = _m('No users have been disabled');
} else {
$msg = sprintf(_mn('One user has been blocked', '%s users have been blocked', $iUpdated), $iUpdated);
}
osc_add_flash_ok_message($msg, 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=users');
break;
case 'delete':
//delete
$iDeleted = 0;
$userId = Params::getParam('id');
if (!is_array($userId)) {
osc_add_flash_error_message(_m("User id isn't in the correct format"), 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=users');
}
foreach ($userId as $id) {
$user = $this->userManager->findByPrimaryKey($id);
Log::newInstance()->insertLog('user', 'delete', $id, $user['s_email'], 'admin', osc_logged_admin_id());
if ($this->userManager->deleteUser($id)) {
$iDeleted++;
}
}
if ($iDeleted == 0) {
$msg = _m('No users have been deleted');
} else {
$msg = sprintf(_mn('One user has been deleted', '%s users have been deleted', $iDeleted), $iDeleted);
}
osc_add_flash_ok_message($msg, 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=users');
break;
case 'settings':
// calling the users settings view
$this->doView('users/settings.php');
break;
case 'settings_post':
// updating users
$iUpdated = 0;
$enabledUserValidation = Params::getParam('enabled_user_validation');
$enabledUserValidation = $enabledUserValidation != '' ? true : false;
$enabledUserRegistration = Params::getParam('enabled_user_registration');
$enabledUserRegistration = $enabledUserRegistration != '' ? true : false;
$enabledUsers = Params::getParam('enabled_users');
$enabledUsers = $enabledUsers != '' ? true : false;
$notifyNewUser = Params::getParam('notify_new_user');
$notifyNewUser = $notifyNewUser != '' ? true : false;
$iUpdated += Preference::newInstance()->update(array('s_value' => $enabledUserValidation), array('s_name' => 'enabled_user_validation'));
$iUpdated += Preference::newInstance()->update(array('s_value' => $enabledUserRegistration), array('s_name' => 'enabled_user_registration'));
$iUpdated += Preference::newInstance()->update(array('s_value' => $enabledUsers), array('s_name' => 'enabled_users'));
$iUpdated += Preference::newInstance()->update(array('s_value' => $notifyNewUser), array('s_name' => 'notify_new_user'));
if ($iUpdated > 0) {
示例14: doModel
//.........这里部分代码省略.........
foreach ($mItems->data as $key => $value) {
Session::newInstance()->_setForm($key, $value);
}
$meta = Params::getParam('meta');
if (is_array($meta)) {
foreach ($meta as $key => $value) {
Session::newInstance()->_setForm('meta_' . $key, $value);
Session::newInstance()->_keepForm('meta_' . $key);
}
}
$success = $mItems->edit();
if ($success == 1) {
osc_add_flash_ok_message(_m('Changes saved correctly'), 'admin');
$url = osc_admin_base_url(true) . "?page=items";
// if Referer is saved that means referer is ManageListings or ReportListings
if (Session::newInstance()->_get('osc_admin_referer') != '') {
$url = Session::newInstance()->_get('osc_admin_referer');
}
Session::newInstance()->_clearVariables();
$this->redirectTo($url);
} else {
osc_add_flash_error_message($success, 'admin');
$this->redirectTo(osc_admin_base_url(true) . "?page=items&action=item_edit&id=" . Params::getParam('id'));
}
break;
case 'deleteResource':
//delete resource
osc_csrf_check();
$id = Params::getParam('id');
$name = Params::getParam('name');
$fkid = Params::getParam('fkid');
// delete files
osc_deleteResource($id, true);
Log::newInstance()->insertLog('items', 'deleteResource', $id, $id, 'admin', osc_logged_admin_id());
$result = ItemResource::newInstance()->delete(array('pk_i_id' => $id, 'fk_i_item_id' => $fkid, 's_name' => $name));
if ($result === false) {
osc_add_flash_error_message(_m('An error has occurred'), 'admin');
} else {
osc_add_flash_ok_message(_m('Resource deleted'), 'admin');
}
$this->redirectTo(osc_admin_base_url(true) . "?page=items");
break;
case 'post':
// add item
$form = count(Session::newInstance()->_getForm());
$keepForm = count(Session::newInstance()->_getKeepForm());
if ($form == 0 || $form == $keepForm) {
Session::newInstance()->_dropKeepForm();
}
$this->_exportVariableToView("new_item", TRUE);
osc_run_hook('post_item');
$this->doView('items/frm.php');
break;
case 'post_item':
//post item
osc_csrf_check();
$mItem = new ItemActions(true);
$mItem->prepareData(true);
// set all parameters into session
foreach ($mItem->data as $key => $value) {
Session::newInstance()->_setForm($key, $value);
}
$meta = Params::getParam('meta');
if (is_array($meta)) {
foreach ($meta as $key => $value) {
Session::newInstance()->_setForm('meta_' . $key, $value);
示例15: delete
/**
*
* @param <type> $secret
* @param <type> $itemId
*/
public function delete($secret, $itemId)
{
$item = $this->manager->findByPrimaryKey($itemId);
if ($item['s_secret'] == $secret) {
$this->deleteResourcesFromHD($itemId);
Log::newInstance()->insertLog('item', 'delete', $itemId, $item['s_title'], $this->is_admin ? 'admin' : 'user', $this->is_admin ? osc_logged_admin_id() : osc_logged_user_id());
return $this->manager->deleteByPrimaryKey($itemId);
}
return false;
}