Minor - Code style - refs BT#9092

1.10.x
Yannick Warnier 11 years ago
parent 7964fe977a
commit c920e16b25
  1. 137
      plugin/advanced_subscription/src/HookAdvancedSubscription.php

@ -8,6 +8,10 @@
require_once __DIR__ . '/../config.php'; require_once __DIR__ . '/../config.php';
/**
* Class HookAdvancedSubscription extends the HookObserver to implements
* specific behaviour when the AdvancedSubscription plugin is enabled
*/
class HookAdvancedSubscription extends HookObserver implements class HookAdvancedSubscription extends HookObserver implements
HookAdminBlockObserverInterface, HookAdminBlockObserverInterface,
HookWSRegistrationObserverInterface, HookWSRegistrationObserverInterface,
@ -15,6 +19,9 @@ class HookAdvancedSubscription extends HookObserver implements
{ {
public $plugin; public $plugin;
/**
* Constructor. Calls parent, mainly.
*/
protected function __construct() protected function __construct()
{ {
$this->plugin = AdvancedSubscriptionPlugin::create(); $this->plugin = AdvancedSubscriptionPlugin::create();
@ -52,7 +59,7 @@ class HookAdvancedSubscription extends HookObserver implements
/** /**
* Add Webservices to registration.soap.php * Add Webservices to registration.soap.php
* @param HookWSRegistrationEventInterface $hook * @param HookWSRegistrationEventInterface $hook
* @return int * @return mixed (int or false)
*/ */
public function hookWSRegistration(HookWSRegistrationEventInterface $hook) public function hookWSRegistration(HookWSRegistrationEventInterface $hook)
{ {
@ -73,15 +80,24 @@ class HookAdvancedSubscription extends HookObserver implements
'all', 'all',
'', '',
array( array(
'id' => array('name' => 'id', 'type' => 'xsd:int'), // session.id // session.id
'name' => array('name' => 'name', 'type' => 'xsd:string'), // session.name 'id' => array('name' => 'id', 'type' => 'xsd:int'),
'short_description' => array('name' => 'short_description', 'type' => 'xsd:string'), // session.short_description // session.name
'mode' => array('name' => 'mode', 'type' => 'xsd:string'), // session.mode 'name' => array('name' => 'name', 'type' => 'xsd:string'),
'date_start' => array('name' => 'date_start', 'type' => 'xsd:string'), // session.date_start // session.short_description
'date_end' => array('name' => 'date_end', 'type' => 'xsd:string'), // session.date_end 'short_description' => array('name' => 'short_description', 'type' => 'xsd:string'),
'duration' => array('name' => 'duration', 'type' => 'xsd:string'), // session.human_text_duration // session.mode
'vacancies' => array('name' => 'vacancies', 'type' => 'xsd:string'), // session.vacancies 'mode' => array('name' => 'mode', 'type' => 'xsd:string'),
'schedule' => array('name' => 'schedule', 'type' => 'xsd:string'), // session.schedule // session.date_start
'date_start' => array('name' => 'date_start', 'type' => 'xsd:string'),
// session.date_end
'date_end' => array('name' => 'date_end', 'type' => 'xsd:string'),
// session.human_text_duration
'duration' => array('name' => 'duration', 'type' => 'xsd:string'),
// session.vacancies
'vacancies' => array('name' => 'vacancies', 'type' => 'xsd:string'),
// session.schedule
'schedule' => array('name' => 'schedule', 'type' => 'xsd:string'),
) )
); );
@ -123,10 +139,14 @@ class HookAdvancedSubscription extends HookObserver implements
'all', 'all',
'', '',
array( array(
'user_id' => array('name' => 'user_id', 'type' => 'xsd:int'), // user.user_id // user.user_id
'session_id' => array('name' => 'session_id', 'type' => 'xsd:int'), // session.id 'user_id' => array('name' => 'user_id', 'type' => 'xsd:int'),
'profile_completed' => array('name' => 'profile_completed', 'type' => 'xsd:float'), // user.profile_completes // session.id
'is_connected' => array('name' => 'is_connected', 'type' => 'xsd:boolean'), // user.is_connected 'session_id' => array('name' => 'session_id', 'type' => 'xsd:int'),
// user.profile_completes
'profile_completed' => array('name' => 'profile_completed', 'type' => 'xsd:float'),
// user.is_connected
'is_connected' => array('name' => 'is_connected', 'type' => 'xsd:boolean'),
'secret_key' => array('name' => 'secret_key', 'type' => 'xsd:string'), 'secret_key' => array('name' => 'secret_key', 'type' => 'xsd:string'),
) )
); );
@ -139,17 +159,28 @@ class HookAdvancedSubscription extends HookObserver implements
'all', 'all',
'', '',
array( array(
'id' => array('name' => 'id', 'type' => 'xsd:string'), // session.id // session.id
'cost' => array('name' => 'cost', 'type' => 'xsd:float'), // session.cost 'id' => array('name' => 'id', 'type' => 'xsd:string'),
'place' => array('name' => 'place', 'type' => 'xsd:string'), // session.place // session.cost
'allow_visitors' => array('name' => 'allow_visitors', 'type' => 'xsd:string'), // session.allow_visitors 'cost' => array('name' => 'cost', 'type' => 'xsd:float'),
'duration' => array('name' => 'duration', 'type' => 'xsd:int'), // session.duration // session.place
'brochure' => array('name' => 'brochure', 'type' => 'xsd:string'), // session.brochure 'place' => array('name' => 'place', 'type' => 'xsd:string'),
'banner' => array('name' => 'banner', 'type' => 'xsd:string'), // session.banner // session.allow_visitors
'description' => array('name' => 'description', 'type' => 'xsd:string'), // session.description 'allow_visitors' => array('name' => 'allow_visitors', 'type' => 'xsd:string'),
'status' => array('name' => 'status', 'type' => 'xsd:string'), // status // session.duration
'action_url' => array('name' => 'action_url', 'type' => 'xsd:string'), // action_url 'duration' => array('name' => 'duration', 'type' => 'xsd:int'),
'message' => array('name' => 'error_message', 'type' => 'xsd:string'), // message // session.brochure
'brochure' => array('name' => 'brochure', 'type' => 'xsd:string'),
// session.banner
'banner' => array('name' => 'banner', 'type' => 'xsd:string'),
// session.description
'description' => array('name' => 'description', 'type' => 'xsd:string'),
// status
'status' => array('name' => 'status', 'type' => 'xsd:string'),
// action_url
'action_url' => array('name' => 'action_url', 'type' => 'xsd:string'),
// message
'message' => array('name' => 'error_message', 'type' => 'xsd:string'),
) )
); );
@ -163,10 +194,14 @@ class HookAdvancedSubscription extends HookObserver implements
'all', 'all',
'', '',
array( array(
'id' => array('name' => 'id', 'type' => 'xsd:string'), // session_category.id // session_category.id
'category_name' => array('name' => 'category_name', 'type' => 'xsd:string'), // session_category.name 'id' => array('name' => 'id', 'type' => 'xsd:string'),
'access_url_id' => array('name' => 'access_url_id', 'type' => 'xsd:int'), // session_category.access_url_id // session_category.access_url_id
'secret_key' => array('name' => 'secret_key', 'type' => 'xsd:string') // secret key 'access_url_id' => array('name' => 'access_url_id', 'type' => 'xsd:int'),
// session_category.name
'category_name' => array('name' => 'category_name', 'type' => 'xsd:string'),
// secret key
'secret_key' => array('name' => 'secret_key', 'type' => 'xsd:string'),
), ),
array(), array(),
'tns:listSessionsDetailsByCategory' 'tns:listSessionsDetailsByCategory'
@ -367,6 +402,7 @@ class HookAdvancedSubscription extends HookObserver implements
} else { } else {
// Nothing to do // Nothing to do
} }
return false;
} }
/** /**
@ -377,8 +413,10 @@ class HookAdvancedSubscription extends HookObserver implements
{ {
global $debug; global $debug;
if ($debug) error_log('WSUserSubscribedInCourse'); if ($debug) {
if ($debug) error_log('Params '. print_r($params, 1)); error_log('WSUserSubscribedInCourse');
error_log('Params ' . print_r($params, 1));
}
if (!WSHelperVerifyKey($params)) { if (!WSHelperVerifyKey($params)) {
//return return_error(WS_ERROR_SECRET_KEY); //return return_error(WS_ERROR_SECRET_KEY);
@ -408,7 +446,11 @@ class HookAdvancedSubscription extends HookObserver implements
'target', 'target',
'schedule' 'schedule'
); );
$sessionList = SessionManager::getShortSessionListAndExtraByCategory($sessionCategoryId, $params['target'], $fields); $sessionList = SessionManager::getShortSessionListAndExtraByCategory(
$sessionCategoryId,
$params['target'],
$fields
);
return $sessionList; return $sessionList;
} }
@ -421,8 +463,10 @@ class HookAdvancedSubscription extends HookObserver implements
{ {
global $debug; global $debug;
if ($debug) error_log('WSUserSubscribedInCourse'); if ($debug) {
if ($debug) error_log('Params '. print_r($params, 1)); error_log('WSUserSubscribedInCourse');
error_log('Params ' . print_r($params, 1));
}
if (!WSHelperVerifyKey($params)) { if (!WSHelperVerifyKey($params)) {
return return_error(WS_ERROR_SECRET_KEY); return return_error(WS_ERROR_SECRET_KEY);
@ -497,20 +541,21 @@ class HookAdvancedSubscription extends HookObserver implements
* The extra data (field_name, field_value) * The extra data (field_name, field_value)
* The course data (course_id, course_code, course_title, * The course data (course_id, course_code, course_title,
* coach_username, coach_firstname, coach_lastname) * coach_username, coach_firstname, coach_lastname)
* @param array List of parameters (id, category_name, access_url_id, secret_key) * @param array $params List of parameters (id, category_name, access_url_id, secret_key)
* @return array|soap_fault Sessions list (id=>[title=>'title',url='http://...',date_start=>'...',date_end=>'']) * @return array|soap_fault Sessions list (id=>[title=>'title',url='http://...',date_start=>'...',date_end=>''])
*/ */
function WSListSessionsDetailsByCategory($params) public function WSListSessionsDetailsByCategory($params)
{ {
global $debug; global $debug;
if ($debug) error_log('WSListSessionsDetailsByCategory'); if ($debug) {
if ($debug) error_log('Params '. print_r($params, 1)); error_log('WSListSessionsDetailsByCategory');
error_log('Params ' . print_r($params, 1));
}
$secretKey = $params['secret_key']; $secretKey = $params['secret_key'];
// Check if secret key is valid // Check if secret key is valid
if(!WSHelperVerifyKey($secretKey)) { if (!WSHelperVerifyKey($secretKey)) {
return return_error(WS_ERROR_SECRET_KEY); return return_error(WS_ERROR_SECRET_KEY);
} }
@ -563,8 +608,9 @@ class HookAdvancedSubscription extends HookObserver implements
} }
/** /**
* Return notification content when the hook has been triggered
* @param HookNotificationContentEventInterface $hook * @param HookNotificationContentEventInterface $hook
* @return int * @return mixed (int or false)
*/ */
public function hookNotificationContent(HookNotificationContentEventInterface $hook) public function hookNotificationContent(HookNotificationContentEventInterface $hook)
{ {
@ -574,8 +620,7 @@ class HookAdvancedSubscription extends HookObserver implements
return $data; return $data;
} elseif ($data['type'] === HOOK_EVENT_TYPE_POST) { } elseif ($data['type'] === HOOK_EVENT_TYPE_POST) {
if ( if (isset($data['content']) &&
isset($data['content']) &&
!empty($data['content']) && !empty($data['content']) &&
isset($data['advanced_subscription_pre_content']) && isset($data['advanced_subscription_pre_content']) &&
!empty($data['advanced_subscription_pre_content']) !empty($data['advanced_subscription_pre_content'])
@ -596,9 +641,11 @@ class HookAdvancedSubscription extends HookObserver implements
// Hook type is not valid // Hook type is not valid
// Nothing to do // Nothing to do
} }
return false;
} }
/** /**
* Return the notification data title if the hook was triggered
* @param HookNotificationTitleEventInterface $hook * @param HookNotificationTitleEventInterface $hook
* @return int * @return int
*/ */
@ -610,8 +657,7 @@ class HookAdvancedSubscription extends HookObserver implements
return $data; return $data;
} elseif ($data['type'] === HOOK_EVENT_TYPE_POST) { } elseif ($data['type'] === HOOK_EVENT_TYPE_POST) {
if ( if (isset($data['advanced_subscription_pre_title']) &&
isset($data['advanced_subscription_pre_title']) &&
!empty($data['advanced_subscription_pre_title']) !empty($data['advanced_subscription_pre_title'])
) { ) {
$data['title'] = $data['advanced_subscription_pre_title']; $data['title'] = $data['advanced_subscription_pre_title'];
@ -622,5 +668,6 @@ class HookAdvancedSubscription extends HookObserver implements
// Hook type is not valid // Hook type is not valid
// Nothing to do // Nothing to do
} }
return false;
} }
} }
Loading…
Cancel
Save