Minor - cosmetic changes.

1.9.x
Julio Montoya 12 years ago
parent 0159c7dd21
commit 4cd1a376f7
  1. 1
      main/admin/usergroup_export.php
  2. 12
      main/admin/usergroups.php
  3. 64
      main/inc/lib/model.lib.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';

@ -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
@ -72,6 +74,7 @@ $action_links = 'function action_formatter (cellvalue, options, rowObject) {
.' <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() {
@ -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,20 +11,20 @@
*/
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) {
public function find($type, $options = null)
{
switch ($type) {
case 'all':
return self::get_all($options);
@ -36,10 +36,13 @@ 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();
@ -53,7 +56,12 @@ class Model {
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) {
@ -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()
{
}
/**
@ -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) {

Loading…
Cancel
Save