DAONotifications Class Reference
Model for notifications. More...
Public Member Functions |
|
add_sent_as ($val) | |
Add a sent as. |
|
click_track_fingerprint ($source, $url) | |
Return a fingerprint for given source and
url. |
|
create_click_track_link ($source, $url) | |
Turn given URL into a clicktracked URL.
|
|
get_description () | |
Get description for this instance. |
|
get_filters () | |
Return array of user status filters.
|
|
get_message ($click_track_source=false) | |
Returns message. |
|
get_status () | |
Returns status. |
|
get_title () | |
Get title for this class. |
|
get_user () | |
Return assigned User. |
|
is_active () | |
Returns true, if status is active. |
|
is_deleted () | |
Returns true, if status is deleted. |
|
is_disabled () | |
Returns true, if status is disabled.
|
|
is_unconfirmed () | |
Returns true, if status is unconfirmed.
|
|
set_status ($status) | |
Set status. |
|
Public Attributes |
|
$id | |
$id_user | |
$message | |
$read_action | |
$read_through | |
$sent_as | |
$source | |
$source_data | |
$source_id | |
$status | |
$title | |
Protected Member Functions |
|
create_table_object () | |
Create the table object describing this
dataobejcts table. |
|
get_actions_for_context ($context, $user, $params) | |
To be overloaded. |
Detailed Description
Model for notifications.
Definition at line 25 of file notifications.model.php.
Member Function Documentation
DAONotifications::add_sent_as | ( | $ | val | ) |
Add a sent as.
Definition at line 70 of file notifications.model.php.
00070 { 00071 DBFieldSet::set_set_value($this->sent_as, $val); 00072 }
DAONotifications::click_track_fingerprint | ( | $ | source, | |
$ | url | |||
) |
Return a fingerprint for given source and url.
Used for click tracking, to protect it from beeing spoofed
Definition at line 97 of file notifications.model.php.
00097 { 00098 return sha1( 00099 $this->id . 00100 $this->id_user . 00101 $this->message . 00102 $source . 00103 $this->creationdate . 00104 $url . 00105 $this->title 00106 ); 00107 }
DAONotifications::create_click_track_link | ( | $ | source, | |
$ | url | |||
) |
Turn given URL into a clicktracked URL.
Definition at line 112 of file notifications.model.php.
00112 { 00113 $new_url = Url::create(ActionMapper::get_url('clicktrack', $this)); 00114 $new_url->replace_query_parameter('src', $source); 00115 $new_url->replace_query_parameter('url', $url); 00116 $new_url->replace_query_parameter('token', $this->click_track_fingerprint($source, $url)); 00117 return $new_url->build(); 00118 }
DAONotifications::create_table_object | ( | ) | [protected] |
Create the table object describing this dataobejcts table.
Reimplemented from DataObjectBase.
Definition at line 41 of file notifications.model.php.
00041 { 00042 return new DBTable( 00043 'notifications', 00044 array_merge(array( 00045 new DBFieldInt('id', null, DBFieldInt::AUTOINCREMENT | DBFieldInt::UNSIGNED | DBField::NOT_NULL), 00046 new DBFieldInt('id_user', null, DBFieldInt::UNSIGNED), // Null allowed! 00047 new DBFieldText('title', 200, null, DBField::NOT_NULL), 00048 new DBFieldText('message', DBFieldText::BLOB_LENGTH_SMALL, null, DBField::NOT_NULL), 00049 new DBFieldText('source', 100, Notifications::SOURCE_APP, DBField::NOT_NULL), 00050 new DBFieldInt('source_id', null, DBFieldInt::UNSIGNED), // Null allowed! 00051 new DBFieldSerialized('source_data', DBFieldSerialized::BLOB_LENGTH_SMALL, null, DBField::NONE), 00052 new DBFieldSet('sent_as', array_keys(Notifications::get_delivery_methods()), null, DBField::NONE), 00053 new DBFieldEnum('read_through', array_keys(Notifications::get_read_sources()), Notifications::READ_UNKNOWN, DBField::NOT_NULL), 00054 new DBFieldText('read_action', 30, null, DBField::NONE), 00055 new DBFieldEnum('status', array_keys(Notifications::get_status()), Notifications::STATUS_NEW, DBField::NOT_NULL), 00056 ), $this->get_timestamp_field_declarations() 00057 ), 00058 'id', 00059 new DBRelation( 00060 'users', 00061 new DBFieldRelation('id_user', 'id'), 00062 DBRelation::NONE // null allowed! 00063 ) 00064 ); 00065 }
DAONotifications::get_actions_for_context | ( | $ | context, | |
$ | user, | |||
$ | params | |||
) | [protected] |
To be overloaded.
Returns array of actions with action title as key and action description as value
Subclasses can return array of actions, this class will detect if they are commands or actions.
Optionally, params can be added in brackets like 'status[DISABLED]' => 'Disable this item'.
- Parameters:
-
string $context mixed $user mixed $params
- Returns:
- array
Reimplemented from DataObjectBase.
Definition at line 132 of file notifications.model.php.
00132 { 00133 $ret = array(); 00134 $arrStates = array_keys(Notifications::get_status()); 00135 foreach($arrStates as $state) { 00136 $cmd = 'status[' . $state . ']'; 00137 $desc = tr('Set ' . $state); 00138 $ret[$cmd] = $desc; 00139 } 00140 $ret['exclude'] = tr('End notification', 'notifications'); 00141 return $ret; 00142 }
DAONotifications::get_description | ( | ) |
Get description for this instance.
- Returns:
- string
Implements ISelfDescribing.
Definition at line 197 of file notifications.model.php.
DAONotifications::get_filters | ( | ) |
Return array of user status filters.
Array has filter as key and a readable description as value
Reimplemented from DataObjectBase.
Definition at line 147 of file notifications.model.php.
00147 { 00148 $sources = array(); 00149 foreach(Notifications::get_all_sources($this->id_user) as $source => $descr) { 00150 $sources[$source] = new DBFilterColumn('notifications.source', $source, $descr); 00151 } 00152 return array( 00153 new DBFilterGroup( 00154 'status', 00155 tr('Status', 'notifications'), 00156 array( 00157 'new' => new DBFilterColumn('notifications.status', Notifications::STATUS_NEW, tr('Unread', 'notifications')), 00158 'read' => new DBFilterColumn('notifications.status', Notifications::STATUS_READ, tr('Read', 'notifications')), 00159 ), 00160 'new' 00161 ), 00162 new DBFilterGroup( 00163 'source', 00164 tr('Source', 'notifications'), 00165 $sources 00166 ) 00167 ); 00168 }
DAONotifications::get_message | ( | $ | click_track_source =
false |
) |
Returns message.
- Parameters:
-
string $click_track_source If set, all Links are turned into click tracking links for given source (one of the DELIVER_* constants)
- Returns:
- string
Definition at line 82 of file notifications.model.php.
00082 { 00083 $ret = $this->message; 00084 if ($click_track_source) { 00085 $injector = new ClickTrackInjecter($this, $click_track_source); 00086 $reg = '@<a(.*?)href="(.*?)"(.*?)>@'; 00087 $ret = String::preg_replace_callback($reg, array($injector, 'callback'), $ret); 00088 } 00089 return $ret; 00090 }
DAONotifications::get_status | ( | ) |
Returns status.
- Returns:
- string
Implements IStatusHolder.
Definition at line 219 of file notifications.model.php.
DAONotifications::get_title | ( | ) |
Get title for this class.
- Returns:
- string
Implements ISelfDescribing.
Definition at line 188 of file notifications.model.php.
DAONotifications::get_user | ( | ) |
Return assigned User.
- Returns:
- DAOUsers
Definition at line 175 of file notifications.model.php.
00175 { 00176 return Users::get($this->id_user); 00177 }
DAONotifications::is_active | ( | ) |
Returns true, if status is active.
- Returns:
- bool
Implements IStatusHolder.
Definition at line 228 of file notifications.model.php.
00228 { 00229 return $this->status == Notifications::STATUS_NEW; 00230 }
DAONotifications::is_deleted | ( | ) |
Returns true, if status is deleted.
- Returns:
- bool
Implements IStatusHolder.
Definition at line 246 of file notifications.model.php.
DAONotifications::is_disabled | ( | ) |
Returns true, if status is disabled.
- Returns:
- bool
Implements IStatusHolder.
Definition at line 255 of file notifications.model.php.
00255 { 00256 return $this->status == Notifications::STATUS_READ; 00257 }
DAONotifications::is_unconfirmed | ( | ) |
Returns true, if status is unconfirmed.
- Returns:
- bool
Implements IStatusHolder.
Definition at line 237 of file notifications.model.php.
DAONotifications::set_status | ( | $ | status | ) |
Set status.
- Parameters:
-
string $status
Implements IStatusHolder.
Definition at line 210 of file notifications.model.php.
00210 { 00211 $this->status = $status; 00212 }
Member Data Documentation
DAONotifications::$id |
Definition at line 26 of file notifications.model.php.
DAONotifications::$id_user |
Definition at line 27 of file notifications.model.php.
DAONotifications::$message |
Definition at line 29 of file notifications.model.php.
DAONotifications::$read_action |
Definition at line 35 of file notifications.model.php.
DAONotifications::$read_through |
Definition at line 34 of file notifications.model.php.
DAONotifications::$sent_as |
Definition at line 33 of file notifications.model.php.
DAONotifications::$source |
Definition at line 30 of file notifications.model.php.
DAONotifications::$source_data |
Definition at line 32 of file notifications.model.php.
DAONotifications::$source_id |
Definition at line 31 of file notifications.model.php.
DAONotifications::$status |
Definition at line 36 of file notifications.model.php.
DAONotifications::$title |
Definition at line 28 of file notifications.model.php.
The documentation for this class was generated from the following file:
- contributions/usermanagement.notifications/model/classes/notifications.model.php