This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /** |
||
4 | * This is the model class for table "club". |
||
5 | * |
||
6 | * The followings are the available columns in table 'club': |
||
7 | * @property string $id |
||
8 | * @property integer $owner |
||
9 | * @property string $name |
||
10 | * @property string $created |
||
11 | */ |
||
12 | class ClubAR extends CActiveRecord |
||
13 | { |
||
14 | /** |
||
15 | * Returns the static model of the specified AR class. |
||
16 | * @param string $className active record class name. |
||
17 | * @return Club the static model class |
||
18 | */ |
||
19 | public static function model($className = __CLASS__) |
||
20 | { |
||
21 | return parent::model($className); |
||
22 | } |
||
23 | |||
24 | /** |
||
25 | * @return string the associated database table name |
||
26 | */ |
||
27 | public function tableName() |
||
28 | { |
||
29 | return 'club'; |
||
30 | } |
||
31 | |||
32 | /** |
||
33 | * @return array validation rules for model attributes. |
||
34 | */ |
||
35 | public function rules() |
||
36 | { |
||
37 | // NOTE: you should only define rules for those attributes that |
||
38 | // will receive user inputs. |
||
39 | return array( |
||
40 | ['name', 'clean'], |
||
41 | ['name', 'required'], |
||
42 | ['name', 'length', 'min'=>6, 'max'=>14], |
||
43 | ['name', 'levelRequirement'], |
||
44 | ['name', 'hasOtherClub'], |
||
45 | ['name', 'nameIsFree'], |
||
46 | ['id, owner', 'safe', 'on'=>'search'], |
||
47 | ); |
||
48 | } |
||
49 | |||
50 | public function clean($attribute) |
||
51 | { |
||
52 | $this->$attribute = trim($this->$attribute); |
||
53 | $this->$attribute = strip_tags($this->$attribute); |
||
54 | $this->$attribute = htmlspecialchars($this->$attribute); |
||
55 | } |
||
56 | |||
57 | public function levelRequirement($attribute, $params) |
||
58 | { |
||
59 | View Code Duplication | if (Yii::app()->player->model->level < Yii::app()->params['clubCreateLevelRequirement']) { |
|
0 ignored issues
–
show
|
|||
60 | $this->addError($attribute, 'Saját klub indĂtásához minimum ' . Yii::app()->params['clubCreateLevelRequirement'] . '. szintre kell fejlĹ‘dnöd.'); |
||
61 | } |
||
62 | } |
||
63 | |||
64 | public function hasOtherClub($attribute, $params) |
||
65 | { |
||
66 | if (Yii::app()->player->model->in_club) { |
||
67 | $this->addError($attribute, 'Egy másik klub tagja vagy. Először lépj ki abból.'); |
||
68 | } |
||
69 | } |
||
70 | |||
71 | public function nameIsFree($attribute, $params) |
||
72 | { |
||
73 | $clubWithSameName = Yii::app()->db->createCommand() |
||
74 | ->select('id') |
||
75 | ->from('club') |
||
76 | ->where('name=:name', [':name'=>$this->$attribute]) |
||
77 | ->queryScalar(); |
||
78 | if ($clubWithSameName) { |
||
79 | $this->addError($attribute, 'Ez a név már foglalt.'); |
||
80 | } |
||
81 | } |
||
82 | |||
83 | /** |
||
84 | * @return array customized attribute labels (name=>label) |
||
85 | */ |
||
86 | public function attributeLabels() |
||
87 | { |
||
88 | return array( |
||
89 | 'id' => 'ID', |
||
90 | 'owner' => 'Tulajdonos', |
||
91 | 'name' => 'Klub neve', |
||
92 | 'created' => 'Létrehozva', |
||
93 | ); |
||
94 | } |
||
95 | |||
96 | /** |
||
97 | * Retrieves a list of models based on the current search/filter conditions. |
||
98 | * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions. |
||
99 | */ |
||
100 | public function search() |
||
101 | { |
||
102 | // Warning: Please modify the following code to remove attributes that |
||
103 | // should not be searched. |
||
104 | |||
105 | $criteria=new CDbCriteria; |
||
0 ignored issues
–
show
Equals sign not aligned correctly; expected 1 space but found 0 spaces
This check looks for improperly formatted assignments. Every assignment must have exactly one space before and one space after the equals operator. To illustrate: $a = "a";
$ab = "ab";
$abc = "abc";
will have no issues, while $a = "a";
$ab = "ab";
$abc = "abc";
will report issues in lines 1 and 2. ![]() |
|||
106 | |||
107 | $criteria->compare('id', $this->id, true); |
||
108 | $criteria->compare('owner', $this->owner); |
||
109 | $criteria->compare('name', $this->name, true); |
||
110 | $criteria->compare('created', $this->created, true); |
||
111 | |||
112 | return new CActiveDataProvider($this, array( |
||
113 | 'criteria'=>$criteria, |
||
114 | )); |
||
115 | } |
||
116 | |||
117 | protected function beforeSave() |
||
0 ignored issues
–
show
The return type could not be reliably inferred; please add a
@return annotation.
Our type inference engine in quite powerful, but sometimes the code does not
provide enough clues to go by. In these cases we request you to add a ![]() |
|||
118 | { |
||
119 | $this->owner = Yii::app()->player->uid; |
||
120 | return parent::beforeSave(); |
||
121 | } |
||
122 | |||
123 | protected function afterSave() |
||
124 | { |
||
125 | $forum = new Forum; |
||
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 5 spaces but found 1 space
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line. To visualize $a = "a";
$ab = "ab";
$abc = "abc";
will produce issues in the first and second line, while this second example $a = "a";
$ab = "ab";
$abc = "abc";
will produce no issues. ![]() |
|||
126 | $forum->id = $this->id; |
||
0 ignored issues
–
show
The property
id cannot be accessed from this context as it is declared private in class Forum .
This check looks for access to properties that are not accessible from the current context. If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class. ![]() |
|||
127 | $forum->save(Yii::app()->player->model->user . ' megalapĂtotta a klubot.', true); |
||
128 | |||
129 | Yii::app()->badge->model->triggerSimple('club_create'); |
||
130 | |||
131 | //delete inactive join request |
||
132 | Yii::app()->db->createCommand()->delete('club_members', 'uid=:uid AND approved=0', [':uid'=>Yii::app()->player->model->uid]); |
||
133 | parent::afterSave(); |
||
134 | } |
||
135 | } |
||
0 ignored issues
–
show
|
|||
136 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.