Minor - cosmetic changes.

1.9.x
Julio Montoya 12 years ago
parent 0159c7dd21
commit 4cd1a376f7
  1. 7
      main/admin/usergroup_export.php
  2. 34
      main/admin/usergroups.php
  3. 76
      main/inc/lib/model.lib.php
  4. 2
      main/inc/local.inc.php

@ -8,7 +8,6 @@
*/
// name of the language file that needs to be included
$language_file = 'admin';
$cidReset = true;
require_once '../inc/global.inc.php';
@ -27,7 +26,7 @@ set_time_limit(0);
$form = new FormValidator('export_users');
$form->addElement('header', $tool_name);
$form->addElement('style_submit_button', 'submit',get_lang('Export'),'class="save"');
$form->addElement('style_submit_button', 'submit', get_lang('Export'), 'class="save"');
if ($form->validate()) {
$user_group = new UserGroup;
@ -35,9 +34,9 @@ if ($form->validate()) {
$data = $user_group->get_all_for_export();
$data = array_merge($header, $data);
$filename = 'export_classes_'.api_get_local_time();
Export::export_table_csv($data,$filename);
Export::export_table_csv($data, $filename);
exit;
}
Display :: display_header($tool_name);
$form->display();
Display :: display_footer();
Display::display_footer();

@ -17,16 +17,16 @@ api_protect_admin_script(true);
//Add the JS needed to use the jqgrid
$htmlHeadXtra[] = api_get_jqgrid_js();
// setting breadcrumbs
$interbreadcrumb[]=array('url' => 'index.php','name' => get_lang('PlatformAdmin'));
$interbreadcrumb[] = array('url' => 'index.php','name' => get_lang('PlatformAdmin'));
$action = $_GET['action'];
if ($action == 'add') {
$interbreadcrumb[]=array('url' => 'usergroups.php','name' => get_lang('Classes'));
$interbreadcrumb[]=array('url' => '#','name' => get_lang('Add'));
$interbreadcrumb[] = array('url' => 'usergroups.php','name' => get_lang('Classes'));
$interbreadcrumb[] = array('url' => '#','name' => get_lang('Add'));
} elseif ($action == 'edit') {
$interbreadcrumb[]=array('url' => 'usergroups.php','name' => get_lang('Classes'));
$interbreadcrumb[]=array('url' => '#','name' => get_lang('Edit'));
$interbreadcrumb[] = array('url' => 'usergroups.php','name' => get_lang('Classes'));
$interbreadcrumb[] = array('url' => '#','name' => get_lang('Edit'));
} else {
$interbreadcrumb[]=array('url' => '#','name' => get_lang('Classes'));
$interbreadcrumb[] = array('url' => '#','name' => get_lang('Classes'));
}
// The header.
@ -35,11 +35,11 @@ Display::display_header($tool_name);
// Tool name
if (isset($_GET['action']) && $_GET['action'] == 'add') {
$tool = 'Add';
$interbreadcrumb[] = array ('url' => api_get_self(), 'name' => get_lang('Group'));
$interbreadcrumb[] = array('url' => api_get_self(), 'name' => get_lang('Group'));
}
if (isset($_GET['action']) && $_GET['action'] == 'editnote') {
$tool = 'Modify';
$interbreadcrumb[] = array ('url' => api_get_self(), 'name' => get_lang('Group'));
$interbreadcrumb[] = array('url' => api_get_self(), 'name' => get_lang('Group'));
}
//jqgrid will use this URL to do the selects
@ -47,17 +47,19 @@ if (isset($_GET['action']) && $_GET['action'] == 'editnote') {
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_usergroups';
//The order is important you need to check the the $column variable in the model.ajax.php file
$columns = array(get_lang('Name'), get_lang('Users'), get_lang('Courses'), get_lang('Sessions'), get_lang('Actions'));
$columns = array(
get_lang('Name'), get_lang('Users'), get_lang('Courses'), get_lang('Sessions'), get_lang('Actions')
);
//Column config
$column_model = array(
array('name'=>'name', 'index'=>'name', 'width'=>'35', 'align'=>'left'),
//array('name'=>'description', 'index'=>'description', 'width'=>'500', 'align'=>'left'),
array('name'=>'users', 'index'=>'users', 'width'=>'15', 'align'=>'left'),
array('name'=>'courses', 'index'=>'courses', 'width'=>'15', 'align'=>'left'),
array('name'=>'sessions', 'index'=>'sessions', 'width'=>'15', 'align'=>'left'),
array('name'=>'actions', 'index'=>'actions', 'width'=>'20', 'align'=>'left','sortable'=>'false','formatter'=>'action_formatter'),
);
);
//Autowidth
$extra_params['autowidth'] = 'true';
//height auto
@ -71,13 +73,14 @@ $action_links = 'function action_formatter (cellvalue, options, rowObject) {
.' <a href="add_sessions_to_usergroup.php?id=\'+options.rowId+\'"><img src="../img/icons/22/sessions_to_class.png" title="'.get_lang('SubscribeClassToSessions').'"></a>'
.' <a href="?action=edit&id=\'+options.rowId+\'"><img width="20px" src="../img/edit.png" title="'.get_lang('Edit').'" ></a>'
.' <a onclick="javascript:if(!confirm('."\'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES))."\'".')) return false;" href="?action=delete&id=\'+options.rowId+\'"><img title="'.get_lang('Delete').'" src="../img/delete.png"></a>\';
}';
}';
?>
<script>
$(function() {
<?php
// grid definition see the $usergroup>display() function
echo Display::grid_js('usergroups', $url,$columns,$column_model,$extra_params, array(), $action_links,true);
echo Display::grid_js('usergroups', $url,$columns, $column_model, $extra_params, array(), $action_links, true);
?>
});
</script>
@ -129,8 +132,8 @@ if (isset($_GET['action']) && $_GET['action'] == 'add') {
$form->setConstants(array('sec_token' => $token));
$form->display();
}
}// Action handling: Editing a note
elseif (isset($_GET['action']) && $_GET['action'] == 'edit' && is_numeric($_GET['id'])) {
} elseif (isset($_GET['action']) && $_GET['action'] == 'edit' && is_numeric($_GET['id'])) {
// Action handling: Editing a note
// Initialize the object
$form = new FormValidator('career', 'post', api_get_self().'?action='.Security::remove_XSS($_GET['action']).'&id='.Security::remove_XSS($_GET['id']));
// Settting the form elements
@ -169,6 +172,7 @@ elseif (isset($_GET['action']) && $_GET['action'] == 'edit' && is_numeric($_GET[
$form->display();
}
}
// Action handling: deleting a note
elseif (isset($_GET['action']) && $_GET['action'] == 'delete' && is_numeric($_GET['id'])) {
$res = $usergroup->delete(Security::remove_XSS($_GET['id']));

@ -11,21 +11,21 @@
*/
class Model {
var $table;
var $columns;
var $required;
var $is_course_model =false;
public $table;
public $columns;
public $required;
public $is_course_model =false;
// var $pk; some day this will be implemented
public function __construct() {
public function __construct()
{
}
/**
* Useful finder - experimental akelos like only use in notification.lib.php send function
*/
public function find($type, $options = null) {
switch($type) {
public function find($type, $options = null)
{
switch ($type) {
case 'all':
return self::get_all($options);
break;
@ -36,27 +36,35 @@ class Model {
}
/**
* Delets an item
* Deletes an item
*/
public function delete($id) {
if (empty($id) or $id != strval(intval($id))) { return false; }
public function delete($id)
{
if (empty($id) or $id != strval(intval($id))) {
return false;
}
$params = array('id = ?' => $id);
if ($this->is_course_model) {
$course_id = api_get_course_int_id();
$params = array('id = ? AND c_id = ?' => array($id, $course_id));
}
// Database table definition
$result = Database :: delete($this->table,$params );
if ($result != 1){
$result = Database::delete($this->table, $params);
if ($result != 1) {
return false;
}
return true;
}
private function clean_parameters($params){
/**
* @param array $params
* @return array
*/
private function clean_parameters($params)
{
$clean_params = array();
if (!empty($params)) {
foreach($params as $key=>$value) {
foreach ($params as $key=>$value) {
if (in_array($key, $this->columns)) {
$clean_params[$key] = $value;
}
@ -74,8 +82,11 @@ class Model {
/**
* Gets an element
*/
public function get($id) {
if (empty($id)) { return array(); }
public function get($id)
{
if (empty($id)) {
return array();
}
$params = array('id = ?'=>intval($id));
if ($this->is_course_model) {
$course_id = api_get_course_int_id();
@ -85,18 +96,29 @@ class Model {
return $result;
}
public function get_all($options = null) {
/**
* @param array $options
* @return array
*/
public function get_all($options = null)
{
return Database::select('*', $this->table, $options);
}
public function get_all_for_export($options = null) {
/**
* @param array $options
* @return array
*/
public function get_all_for_export($options = null)
{
return Database::select('name, description', $this->table, $options);
}
/**
* Get the count of elements
*/
public function get_count() {
public function get_count()
{
$row = Database::select('count(*) as count', $this->table, array('where' => array('parent_id = ?' => '0')),'first');
return $row['count'];
}
@ -104,7 +126,8 @@ class Model {
/**
* a little bit of javascript to display
*/
public function javascript() {
public function javascript()
{
}
/**
@ -142,7 +165,7 @@ class Model {
if (!empty($params)) {
$id = Database::insert($this->table, $params, $show_query);
if (is_numeric($id)){
if (is_numeric($id)) {
return $id;
}
}
@ -151,11 +174,12 @@ class Model {
/**
* Updates the obj in the database. The $params['id'] must exist in order to update a record
*
* @param array $values
* @return bool
*
*/
public function update($params) {
public function update($params)
{
$params = $this->clean_parameters($params);
if ($this->is_course_model) {
@ -178,7 +202,7 @@ class Model {
unset($params['id']); //To not overwrite the id
if (is_numeric($id)) {
$result = Database::update($this->table, $params, array('id = ?'=>$id));
if ($result){
if ($result) {
return true;
}
}

@ -1207,7 +1207,7 @@ if (api_get_setting('student_view_enabled') == "true") {
if (isset($_cid)) {
$tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
$time = api_get_utc_datetime();
$sql="UPDATE $tbl_course SET last_visit= '$time' WHERE code='$_cid'";
$sql = "UPDATE $tbl_course SET last_visit= '$time' WHERE code='$_cid'";
Database::query($sql);
}

Loading…
Cancel
Save