-
Notifications
You must be signed in to change notification settings - Fork 0
/
feedback_reloaded.entity.inc
83 lines (69 loc) · 3.05 KB
/
feedback_reloaded.entity.inc
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
73
74
75
76
77
78
79
80
81
82
83
<?php
/**
* @file
* Feedback entity and controller classes.
*/
class FeedbackRController extends EntityAPIController {
/**
* Add properties as pseudo-fields.
*/
public function buildContent($entity, $view_mode = 'full', $langcode = NULL, $content = array()) {
$user = user_load($entity->uid);
$status_options = array(
'0' => t('New'),
'1' => t('Processed'),
);
$content['created By'] = array('#markup' => t('<b>Submitted by: </b><a href="!link">!user</a><br>', array('!user' => $user->name, '!link' => 'user/'.$user->uid)));
$content['created on'] = array('#markup' => t('<b>Date of submission:</b> !created<br>', array('!created' => format_date($entity->timestamp))));
$content['status'] = array('#markup' => t('<b>Status:</b> !status<br>', array('!status' => $status_options[$entity->status])));
$content['location'] = array('#markup' => t('<b>Location:</b> <a href="!location">!location</a><br>', array('!location' => $entity->url)));
$content['message'] = array('#markup' => t('<b>Problem Description:</b><br> !message<br>', array('!message' => $entity->message)));
$content['useragent'] = array('#markup' => t('<b>Useragent:</b><br> !useragent<br>', array('!useragent' => $entity->useragent)));
$content['screenshot'] = array('#markup' => t('<b>Screenshot (click on image to see in full size):</b> <br><a href="!link"><img style="width: 100%; height: 50%;" title="Click to see full size image" src="!link"></a>', array('!link' => $entity->screenshoturl)));
return parent::buildContent($entity, $view_mode, $langcode, $content);
}
}
class FeedbackRTypeController extends EntityAPIControllerExportable {
}
/**
* FeedbackR class.
*/
class FeedbackR extends Entity {
public function __construct($values = array()) {
if (isset($values['type']) && is_object($values['type'])) {
$values['type'] = $values['type']->name;
}
parent::__construct($values, 'feedback_reloaded');
}
protected function defaultLabel() {
$username = isset($this->uid) ? user_load($this->uid)->name : 'username';
$type_label = feedback_reloaded_get_types($this->type)->getTranslation('label');
if(!empty($this->title))
return t('@title', array('@title' => $this->title));
else
return t('@type Feedback by @username', array('@type' => $type_label, '@username' => $username));
}
protected function defaultUri() {
return array('path' => 'feedback/' . $this->identifier());
}
}
/**
* FeedbackRType class.
*/
class FeedbackRType extends Entity {
public $name;
public $label;
public $weight = 0;
public function __construct($values = array()) {
parent::__construct($values, 'feedback_reloaded_type');
}
/**
* Returns whether the feedback type is locked and thus may not be deleted or renamed.
*
* Feedbacl types provided in code are automatically treated as locked, as well
* as any fixed subscription type.
*/
public function isLocked() {
return isset($this->status) && empty($this->is_new) && (($this->status & ENTITY_IN_CODE) || ($this->status & ENTITY_FIXED));
}
}