Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
public function getPartnerSettings($partner_id)
{
public function getPartnerSettings($partner_id)
{
- if ($this->partners_settings == null && !$this->fetched(self::FETCH_PARTNER)) {
+ if ($this->partners_settings === null && !$this->fetched(self::FETCH_PARTNER)) {
$this->setPartnersSettings($this->getProfileField(self::FETCH_PARTNER));
}
$this->setPartnersSettings($this->getProfileField(self::FETCH_PARTNER));
}
- if ($this->partners_settings == null) {
+ if ($this->partners_settings === null) {
return PartnerSettings::getEmpty($partner_id);
}
return $this->partners_settings->get($partner_id);
return PartnerSettings::getEmpty($partner_id);
}
return $this->partners_settings->get($partner_id);
public function addPartnerSharingFilter($partner_id)
{
$this->requireProfiles();
public function addPartnerSharingFilter($partner_id)
{
$this->requireProfiles();
- $sub = "ppss_$partner_id";
+ $sub = "ppss_" . $partner_id;
$this->ppss[$sub] = $partner_id;
return $sub;
}
$this->ppss[$sub] = $partner_id;
return $sub;
}
$sub = $this->addPartnerSharingFilter($partner_id);
$this->visibility_field = $sub . '.sharing_level';
}
$sub = $this->addPartnerSharingFilter($partner_id);
$this->visibility_field = $sub . '.sharing_level';
}
/** VISIBILITY
*/
private $vlevels = array();
/** VISIBILITY
*/
private $vlevels = array();
+ /** Since this method might perform inner joins on tables which have been
+ * joined previously (e.g when using addVisibilityFieldFilter), it has to
+ * come after the Joins() methods for those tables.
+ * This is due to the implementation logic for discovering joins and the
+ * ordering used by PHP introspection.
+ */
protected function visibilityJoins()
{
$joins = array();
protected function visibilityJoins()
{
$joins = array();
'newsletter', 'axletter', 'epletter', 'bandeau', 'survey',
'fusionax', 'gadgets', 'googleapps', 'poison',
'openid', 'reminder', 'api', 'urlshortener', 'deltaten',
'newsletter', 'axletter', 'epletter', 'bandeau', 'survey',
'fusionax', 'gadgets', 'googleapps', 'poison',
'openid', 'reminder', 'api', 'urlshortener', 'deltaten',
- 'geoloc', 'ptawebservice');
+ 'geoloc', 'sharingapi');
}
public function find_hook()
}
public function find_hook()
+; The SharingAPI section contains parameters about the 'sharing' webservice
+[SharingAPI]
+
+; $globals->sharingapi->max_result_per_query
+; Maximum number of results returned in an API response.
+max_result_per_query = 10;
+
+
; The register section contains parameters for the registration process
[Register]
; The register section contains parameters for the registration process
[Register]
-; The PTA section contains parameters about the 'RSPTA' webservice
-[PTA]
-
-; $globals->pta->max_result_per_query
-; Maximum number of results returned in an API response.
-max_result_per_query = 10;
-
-
; The merge section contains parameters about the merge's state.
[Merge]
; The merge section contains parameters about the merge's state.
[Merge]
***************************************************************************/
***************************************************************************/
-class PTAWebServiceModule extends PlModule
+class SharingAPIModule extends PlModule
{
function handlers()
{
return array(
{
function handlers()
{
return array(
- 'pta/ws/directory/1/search' => $this->make_api_hook('search', AUTH_COOKIE, 'api_user_readonly'),
- 'pta/ws/bulkmail/1/get_context' => $this->make_api_hook('bulkmail', AUTH_COOKIE, 'api_user_readonly'),
- 'pta/picture' => $this->make_hook('picture_token', AUTH_PUBLIC),
+ 'api/1/sharing/search' => $this->make_api_hook('search', AUTH_COOKIE, 'api_user_readonly'),
+ 'api/1/sharing/bulkmail' => $this->make_api_hook('bulkmail', AUTH_COOKIE, 'api_user_readonly'),
+ 'api/1/sharing/picture' => $this->make_hook('picture_token', AUTH_PUBLIC),
const ORDER_NAME = 'name';
const ORDER_PROMOTION = 'promotion';
const ORDER_NAME = 'name';
const ORDER_PROMOTION = 'promotion';
- public static $ORDER_CHOICES = array(
+ public static $order_choices = array(
self::ORDER_RAND,
self::ORDER_NAME,
self::ORDER_PROMOTION,
self::ORDER_RAND,
self::ORDER_NAME,
self::ORDER_PROMOTION,
$this->partner = $partner;
global $globals;
$this->partner = $partner;
global $globals;
- $this->fields = array_intersect($payload->v('fields'), WSRequestFields::$CHOICES);
- $this->order = array_intersect($payload->v('order', array()), self::$ORDER_CHOICES);
+ $this->fields = array_intersect($payload->v('fields'), WSRequestFields::$choices);
+ $this->order = array_intersect($payload->v('order', array()), self::$order_choices);
$this->criteria = array();
$criteria = new PlDict($payload->v('criteria'));
$this->criteria = array();
$criteria = new PlDict($payload->v('criteria'));
- foreach (WSRequestCriteria::$CHOICES_SIMPLE as $criterion) {
+ foreach (WSRequestCriteria::$choices_simple as $criterion) {
if ($criteria->has($criterion)) {
$this->criteria[$criterion] = $criteria->s($criterion);
}
}
if ($criteria->has($criterion)) {
$this->criteria[$criterion] = $criteria->s($criterion);
}
}
- foreach (WSRequestCriteria::$CHOICES_ENUM as $criterion) {
+ foreach (WSRequestCriteria::$choices_enum as $criterion) {
if ($criteria->has($criterion)) {
$this->criteria[$criterion] = $criteria->s($criterion);
}
}
if ($criteria->has($criterion)) {
$this->criteria[$criterion] = $criteria->s($criterion);
}
}
- foreach (WSRequestCriteria::$CHOICES_LIST as $criterion) {
+ foreach (WSRequestCriteria::$choices_list as $criterion) {
if ($criteria->has($criterion)) {
$this->criteria[$criterion] = $criteria->v($criterion);
}
}
if ($criteria->has($criterion)) {
$this->criteria[$criterion] = $criteria->v($criterion);
}
}
- // Amount may not exceed $globals->pta->max_result_per_query.
+ // Amount may not exceed $globals->sharingapi->max_result_per_query.
$amount = $payload->i('amount', self::DEFAULT_AMOUNT);
$amount = $payload->i('amount', self::DEFAULT_AMOUNT);
- $this->amount = min($amount, $globals->pta->max_result_per_query);
+ $this->amount = min($amount, $globals->sharingapi->max_result_per_query);
// ENUM fields
case WSRequestCriteria::SCHOOL:
// Useless criterion: we don't need to check on origin school
// ENUM fields
case WSRequestCriteria::SCHOOL:
// Useless criterion: we don't need to check on origin school
- if (WSRequestCriteria::$CHOICES_ENUM[$criterion][$value]) {
+ if (WSRequestCriteria::$choices_enum[$criterion][$value]) {
$cond->addChild(new PFC_True());
} else {
$cond->addChild(new PFC_False());
};
break;
case WSRequestCriteria::DIPLOMA:
$cond->addChild(new PFC_True());
} else {
$cond->addChild(new PFC_False());
};
break;
case WSRequestCriteria::DIPLOMA:
- $diploma = WSRequestCriteria::$CHOICES_ENUM[$criterion][$value];
+ $diploma = WSRequestCriteria::$choices_enum[$criterion][$value];
$id_X = XDB::fetchOneCell('SELECT id
FROM profile_education_enum
WHERE abbreviation = {?}', 'X');
$id_X = XDB::fetchOneCell('SELECT id
FROM profile_education_enum
WHERE abbreviation = {?}', 'X');
WSRequestFields::PIC_LARGE => 'large',
);
$size = $size_mappings[$field];
WSRequestFields::PIC_LARGE => 'large',
);
$size = $size_mappings[$field];
- return pl_url("pta/picture/$size/$token");
+ return pl_url("api/1/sharing/picture/$size/$token");
protected function jobToResponse($job)
{
protected function jobToResponse($job)
{
- $data = array();
- $data['company'] = $job->company->name;
- $data['title'] = $job->description;
- $data['sector'] = array_pop($job->terms);
- $data['entry'] = null;
- $data['left'] = null;
+ $data = array(
+ 'company' => $job->company->name,
+ 'title' => $job->description,
+ 'sector' => array_pop($job->terms),
+ 'entry' => null,
+ 'left' => null,
+ );
foreach($job->phones() as $phone) {
if ($this->isVisible($phone->pub)) {
$data['phone'] = $phone->display;
foreach($job->phones() as $phone) {
if ($this->isVisible($phone->pub)) {
$data['phone'] = $phone->display;
protected function addressToResponse($address)
{
protected function addressToResponse($address)
{
- $data = array();
- $data['street'] = $address->postalText;
- $data['zipcode'] = $address->postalCode;
- $data['city'] = $address->locality;
- $data['country'] = $address->country;
- $data['latitude'] = $address->latitude;
- $data['longitude'] = $address->longitude;
+ $data = array(
+ 'street' => $address->postalText,
+ 'zipcode' => $address->postalCode,
+ 'city' => $address->locality,
+ 'country' => $address->country,
+ 'latitude' => $address->latitude,
+ 'longitude' => $address->longitude,
+ );
const ALT_DIPLOMA = 'alt_diploma';
const NOT_UID = 'not_uid';
const ALT_DIPLOMA = 'alt_diploma';
const NOT_UID = 'not_uid';
- public static $CHOICES_SIMPLE = array(
+ public static $choices_simple = array(
self::FIRSTNAME,
self::LASTNAME,
self::PROMOTION,
self::FIRSTNAME,
self::LASTNAME,
self::PROMOTION,
const DIPLOMA_MASTER = 'MASTER';
const DIPLOMA_PHD = 'PHD';
const DIPLOMA_MASTER = 'MASTER';
const DIPLOMA_PHD = 'PHD';
- public static $CHOICES_ENUM = array(
+ public static $choices_enum = array(
self::SCHOOL => array(
self::SCHOOL_AGRO => false,
self::SCHOOL_ENSAE => false,
self::SCHOOL => array(
self::SCHOOL_AGRO => false,
self::SCHOOL_ENSAE => false,
- public static $CHOICES_LIST = array(
+ public static $choices_list = array(
self::HOBBIES,
self::JOB_COMPETENCIES,
self::JOB_RESUME,
self::HOBBIES,
self::JOB_COMPETENCIES,
self::JOB_RESUME,
const DIPLOMA_MASTER = 'master';
const DIPLOMA_PHD = 'phd';
const DIPLOMA_MASTER = 'master';
const DIPLOMA_PHD = 'phd';
- public static $CHOICES = array(
+ public static $choices = array(
self::UID,
self::FIRSTNAME,
self::LASTNAME,
self::UID,
self::FIRSTNAME,
self::LASTNAME,
public static function profileDegreeToWSDiploma($degree)
{
switch ($degree) {
public static function profileDegreeToWSDiploma($degree)
{
switch ($degree) {
- case Profile::DEGREE_X:
- return self::DIPLOMA_ING;
- case Profile::DEGREE_M:
- return self::DIPLOMA_MASTER;
- case Profile::DEGREE_D:
- return self::DIPLOMA_PHD;
- default:
- return null;
+ case Profile::DEGREE_X:
+ return self::DIPLOMA_ING;
+ case Profile::DEGREE_M:
+ return self::DIPLOMA_MASTER;
+ case Profile::DEGREE_D:
+ return self::DIPLOMA_PHD;
+ default:
+ return null;