Commit 59ab0469 authored by Jonny Bradley's avatar Jonny Bradley

[REF] Convert messulib to dependency injection (and fix a few little errors along the way)

parent a1eb4c9a
......@@ -164,6 +164,9 @@
<service id="tiki.lib.memcache" class="Memcachelib">
<file>%kernel.root_dir%/lib/cache/memcachelib.php</file>
</service>
<service id="tiki.lib.message" class="Messu">
<file>%kernel.root_dir%/lib/messu/messulib.php</file>
</service>
<service id="tiki.lib.menu" class="MenuLib">
<file>%kernel.root_dir%/lib/menubuilder/menulib.php</file>
</service>
......
......@@ -984,9 +984,7 @@ class Services_User_Controller
function action_send_message($input) {
global $smarty, $user;
include_once ('lib/messu/messulib.php');
$userlib = TikiLib::lib('user');
//ensures a user was selected to send a message to.
if (empty($input->userwatch->text())) {
throw new Services_Exception(tra('No user was selected.'));
......@@ -1005,7 +1003,7 @@ class Services_User_Controller
die;
}
//if message is successfully sent
if ($messulib->post_message($input->userwatch->text(), $user, $input->to->text(), '', $input->subject->text(), $input->body->text(), $priority, '', isset($input->replytome) ? 'y' : '', isset($input->bccme) ? 'y' : '')) {
if (TikiLib::lib('message')->post_message($input->userwatch->text(), $user, $input->to->text(), '', $input->subject->text(), $input->body->text(), $priority, '', isset($input->replytome) ? 'y' : '', isset($input->bccme) ? 'y' : '')) {
$message = tra('Your Message was successfully sent to') . ' ' . $userlib->clean_user($input->userwatch->text());
$type = "feedback";
$heading = "Success!";
......
......@@ -504,6 +504,8 @@ class Messu extends TikiLib
$query = 'select * from `messu_' . $dbsource . "` where `user`=? $mid";
$result = $this->query($query, $bindvars);
$ret = [];
while ($res = $result->fetchRow()) {
$res['parsed'] = $this->parse_data($res['body']);
$res['len'] = strlen($res['parsed']);
......@@ -515,4 +517,3 @@ class Messu extends TikiLib
}
}
$messulib = new Messu;
......@@ -47,7 +47,7 @@ class TikiLib extends TikiDb_Bridge
/** Gets a library reference
*
* @param $name
* @return \ActivityLib|\AreasLib|array|\AutoSaveLib|\BannerLib|\BigBlueButtonLib|\CalendarLib|\Captcha|\CartLib|\CreditsLib|\CryptLib|\DCSLib|\EditLib|\ErrorReportLib|\FaqLib|\FlaggedRevisionLib|\FileGalLib|\FileGalBatchLib|\GeoLib|\GoalEventLib|\GoalLib|\GoalRewardLib|\groupAlertLib|\HeaderLib|\IconsetLib|\KalturaLib|\LoginLib|\LogsLib|\MailinLib|\MimeLib|mixed|\ModLib|\MonitorLib|\MonitorMailLib|\OAuthLib|object|\PageContentLib|\ParserLib|\PaymentLib|\PerspectiveLib|\PollLib|\PollLibShared|\PreferencesLib|\QueueLib|\QuizLib|\RatingConfigLib|\ReferencesLib|\RegistrationLib|\RSSLib|\ScormLib|\SearchStatsLib|\SheetLib|\Smarty_Tiki|\SocialLib|\StatsLib|\StoredSearchLib|\ThemeControlLib|\ThemeGenLib|\ThemeLib|\Tiki_Connect_Client|\Tiki\Wiki\SlugManager|\Tiki_Connect_Server|\TikiAccessLib|\TikiDate|\TikiLib|\Tracker\Tabular\Manager|\TrackerLib|\UnifiedSearchLib|\UserMailinLib|\UserModulesLib|\Validators|\VimeoLib|\WikiLingoTikiEvents|\WikiLib|\WizardLib|\WYSIWYGLib|\ZoteroLib
* @return \ActivityLib|\AreasLib|array|\AutoSaveLib|\BannerLib|\BigBlueButtonLib|\CalendarLib|\Captcha|\CartLib|\CreditsLib|\CryptLib|\DCSLib|\EditLib|\ErrorReportLib|\FaqLib|\FlaggedRevisionLib|\FileGalLib|\FileGalBatchLib|\GeoLib|\GoalEventLib|\GoalLib|\GoalRewardLib|\groupAlertLib|\HeaderLib|\IconsetLib|\KalturaLib|\LoginLib|\LogsLib|\MailinLib|\Messu|\MimeLib|mixed|\ModLib|\MonitorLib|\MonitorMailLib|\OAuthLib|object|\PageContentLib|\ParserLib|\PaymentLib|\PerspectiveLib|\PollLib|\PollLibShared|\PreferencesLib|\QueueLib|\QuizLib|\RatingConfigLib|\ReferencesLib|\RegistrationLib|\RSSLib|\ScormLib|\SearchStatsLib|\SheetLib|\Smarty_Tiki|\SocialLib|\StatsLib|\StoredSearchLib|\ThemeControlLib|\ThemeGenLib|\ThemeLib|\Tiki_Connect_Client|\Tiki\Wiki\SlugManager|\Tiki_Connect_Server|\TikiAccessLib|\TikiDate|\TikiLib|\Tracker\Tabular\Manager|\TrackerLib|\UnifiedSearchLib|\UserMailinLib|\UserModulesLib|\UsersLib|\Validators|\VimeoLib|\WikiLingoTikiEvents|\WikiLib|\WizardLib|\WYSIWYGLib|\ZoteroLib
* @throws Exception
*/
public static function lib($name)
......
......@@ -2253,6 +2253,7 @@ class UsersLib extends TikiLib
function change_login($from,$to)
{
global $user;
$cachelib = TikiLib::lib('cache');
if ( $from == 'admin' ) return false;
......@@ -7102,8 +7103,7 @@ class UsersLib extends TikiLib
return false;
}
global $messulib; include_once('lib/messu/messulib.php');
$messulib->post_message(
TikiLib::lib('message')->post_message(
$prefs['contact_user'],
$prefs['contact_user'],
$prefs['contact_user'],
......
......@@ -10,7 +10,7 @@
$section = 'user_messages';
require_once ('tiki-setup.php');
include_once ('lib/messu/messulib.php');
$messulib = TikiLib::lib('message');
$access->check_user($user);
$access->check_feature('feature_messages');
$access->check_permission('tiki_p_messages');
......
......@@ -10,7 +10,7 @@
$section = 'user_messages';
require_once ('tiki-setup.php');
include_once ('lib/messu/messulib.php');
$messulib = TikiLib::lib('message');
$access->check_user($user);
$access->check_feature('feature_messages');
$auto_query_args = array('to', 'cc', 'bcc', 'subject', 'body', 'priority', 'replyto_hash', 'groupbr');
......
......@@ -10,7 +10,7 @@
$section = 'user_messages';
require_once ('tiki-setup.php');
include_once ('lib/messu/messulib.php');
$messulib = TikiLib::lib('message');
$access->check_user($user);
$access->check_feature('feature_messages');
$access->check_permission('tiki_p_messages');
......
......@@ -10,7 +10,7 @@
$section = 'user_messages';
require_once ('tiki-setup.php');
include_once ('lib/messu/messulib.php');
$messulib = TikiLib::lib('message');
$access->check_user($user);
$access->check_feature('feature_messages');
$access->check_permission('tiki_p_messages');
......
......@@ -10,7 +10,7 @@
$section = 'user_messages';
require_once ('tiki-setup.php');
include_once ('lib/messu/messulib.php');
$messulib = TikiLib::lib('message');
$access->check_user($user);
$access->check_feature('feature_messages');
$access->check_permission('tiki_p_messages');
......
......@@ -10,7 +10,7 @@
$section = 'user_messages';
require_once ('tiki-setup.php');
include_once ('lib/messu/messulib.php');
$messulib = TikiLib::lib('message');
$access->check_user($user);
$access->check_feature('feature_messages');
$access->check_permission('tiki_p_messages');
......
......@@ -10,7 +10,7 @@
$section = 'user_messages';
require_once ('tiki-setup.php');
include_once ('lib/messu/messulib.php');
$messulib = TikiLib::lib('message');
$access->check_user($user);
$access->check_feature('feature_messages');
$access->check_permission('tiki_p_messages');
......
......@@ -10,7 +10,7 @@
$section = 'user_messages';
require_once ('tiki-setup.php');
include_once ('lib/messu/messulib.php');
$messulib = TikiLib::lib('message');
$access->check_user($user);
$access->check_feature('feature_messages');
$access->check_permission('tiki_p_messages');
......
......@@ -10,7 +10,7 @@
require_once ('tiki-setup.php');
include_once ('lib/messu/messulib.php');
$messulib = TikiLib::lib('message');
include_once ('lib/userprefs/scrambleEmail.php');
// This feature needs both 'feature_contact' and 'feature_messages' to work
......
......@@ -100,10 +100,9 @@ if ($prefs['feature_tasks'] == 'y') {
if ($prefs['feature_messages'] == 'y' && $tiki_p_messages == 'y') {
$mytiki_msgs = $tikilib->get_user_preference($user, 'mytiki_msgs', 'y');
if ($mytiki_msgs == 'y') {
include_once ('lib/messu/messulib.php');
$unread = $tikilib->user_unread_messages($userwatch);
$smarty->assign_by_ref('unread', $unread);
$msgs = $messulib->list_user_messages($user, 0, -1, 'date_desc', '', 'isRead', 'n', '', 'messages');
$msgs = TikiLib::lib('message')->list_user_messages($user, 0, -1, 'date_desc', '', 'isRead', 'n', '', 'messages');
$smarty->assign_by_ref('msgs', $msgs['data']);
$smarty->assign('mytiki_msgs', 'y');
}
......
......@@ -51,7 +51,6 @@ if (empty($_REQUEST['report']) || $_REQUEST['report'] != 'y') {
// message related
if (isset($prefs['feature_messages']) and $prefs['feature_messages'] == 'y') {
include_once ('lib/messu/messulib.php');
$logslib = TikiLib::lib('logs');
$smarty->assign('priority', (isset($_REQUEST['priority'])?$_REQUEST['priority']:3));
......@@ -460,7 +459,7 @@ function sendMail($sender, $recipients, $subject, $tokenlist = array())
function sendMessage($recipients, $subject)
{
global $errors, $prefs, $user;
global $messulib;
$messulib = TikiLib::lib('message');
$userlib = TikiLib::lib('user');
$tikilib = TikiLib::lib('tiki');
$smarty = TikiLib::lib('smarty');
......
......@@ -9,7 +9,7 @@
// $Id$
require_once ('tiki-setup.php');
include_once ('lib/messu/messulib.php');
$messulib = TikiLib::lib('message');
include_once ('lib/userprefs/scrambleEmail.php');
if ($prefs['feature_unified_user_details'] == 'y'){
......
......@@ -8,7 +8,7 @@
$section = 'mytiki';
require_once ('tiki-setup.php');
include_once ('lib/tasks/tasklib.php');
include_once ('lib/messu/messulib.php');
$messulib = TikiLib::lib('message');
$access->check_feature('feature_tasks', '', 'community');
$access->check_user($user);
......
......@@ -9,7 +9,7 @@
// $Id$
require_once ('tiki-setup.php');
include_once ('lib/messu/messulib.php');
$messulib = TikiLib::lib('message');
include_once ('lib/userprefs/scrambleEmail.php');
$trklib = TikiLib::lib('trk');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment