Skip to content

Commit

Permalink
PORTAL: Agoraportal: Fixed bug when uploading files to Moodle2 when a…
Browse files Browse the repository at this point in the history
… client has two services, one of them inactive
  • Loading branch information
toniginard committed Apr 25, 2017
1 parent 0529182 commit 39f3893
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
3 changes: 3 additions & 0 deletions html/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ NODES
- Polylang: Added plugin (Trello #1198)
- bp-moderation: Removed links in BuddyPress index page

PORTAL
- Agoraportal: Fixed bug when uploading files to Moodle2 when a client has two services, one of them inactive (Trello #1581)

ZIKULA
- Removed code (Trello #1255)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ public function files() {

//TODO: Now the only service that allow to update files is moodle2
// In the future other services will allow to update files.
$service = Service::get_by_client_and_servicename($client->clientId, 'moodle2');
$service = Service::get_by_client_and_servicename($client->clientId, 'moodle2', 1);
if(!$service) {
return LogUtil::registerError($this->__('El centre no té el servei Moodle 2 activat'));
}
Expand Down
15 changes: 12 additions & 3 deletions html/portal/modules/Agoraportal/lib/Agoraportal/Services.php
Original file line number Diff line number Diff line change
Expand Up @@ -362,11 +362,18 @@ public static function get_by_id($id) {
* Retrieves the Service seeking by ClientId and ServiceTypeId
* @param $client clientId to look for
* @param $service servicetypeid to look for
* @param null $state Whether the service is active, pending, etc. Must be a number
* @return false|Service
*/
public static function get_by_client_and_service($client, $service) {
public static function get_by_client_and_service($client, $service, $state = null) {
$where = "clientId = $client AND serviceId = $service";

if (!is_null($state)) {
$where .= " AND state = $state";
}

$row = DBUtil::selectObject(self::TABLE, $where);

return self::get_subclass($row);
}

Expand All @@ -389,16 +396,18 @@ public static function get_by_servicename_and_activeid($servicename, $activeid)

/**
* Retrieves the Service seeking by ClientId and ServiceName
*
* @param $client
* @param $servicename
* @param null $state Whether the service is active, pending, etc. Must be a number
* @return false|Service
*/
public static function get_by_client_and_servicename($client, $servicename) {
public static function get_by_client_and_servicename($client, $servicename, $state = null) {
$service = ServiceType::get_by_name($servicename);
if (!$service) {
return false;
}
return self::get_by_client_and_service($client, $service->serviceId);
return self::get_by_client_and_service($client, $service->serviceId, $state);
}

/**
Expand Down

0 comments on commit 39f3893

Please sign in to comment.