blob: b5ec876d7a787fdd9b94083ab14b05df40eb4b1f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
<?php
/**
* InstitutePlanColumn
* model class for table institute_plan_columns
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* @author Timo Hartge <hartge@data-quest.de>
* @license GPL2 or any version
* @since Stud.IP 4.5
* *
*
* @property array $id alias for pk
* @property string $range_id database column
* @property int $column database column
* @property string|null $name database column
* @property int $visible database column
* @property int $mkdate database column
* @property int $chdate database column
*/
class InstitutePlanColumn extends SimpleORMap
{
protected static function configure($config = [])
{
$config['db_table'] = 'institute_plan_columns';
parent::configure($config);
}
public static function findByInstitute($institute_id)
{
return self::findBySQL('range_id=?', [$institute_id]);
}
/**
* returns the last column for given institute
*
* @param string $institut_id
*
* @return InstitutePlanColumn last column
*/
public static function getLastColumnOfInstitute($institute_id)
{
return self::findOneBySQL('range_id=? ORDER BY `column` DESC', [$institute_id]);
}
/**
* Sets the visibility of multiple columns for given institute
*
* @param string $institut_id
* @param array $columns_change column number to be changed
* @param int $visibility 0 or 1
*
* @return int number of changes
*/
public static function setVisbilities($institute_id, $columns_change, $visibility)
{
$changes = 0;
foreach (self::findBySQL('range_id=?', [$institute_id]) as $plan_column) {
if (in_array($plan_column->column, $columns_change)) {
$plan_column->visible = $visibility;
if ($plan_column->store()) {
$changes++;
}
}
}
return $changes;
}
}
|