/** * Handle user removal from ownCloud */ public static function notifyUserDeletion($args) { try { \OCP\DB::beginTransaction(); $query = \OCP\DB::prepare('SELECT `pid`, `title` FROM `*PREFIX*collaboration_project` WHERE `pid` IN (SELECT DISTINCT(`pid`) FROM `*PREFIX*collaboration_works_on` WHERE `member`=?) AND `completed`=?'); $result = $query->execute(array($args['uid'], false)); $projs = $result->fetchAll(); if (count($projs) != 0) { $projects = $projs[0]['title']; $pids = $projs[0]['pid']; for ($i = 1; $i < count($projs); $i++) { $projects .= ', ' . $projs[$i]['title']; $pids .= ' ' . $projs[$i]['pid']; } OC_Collaboration_Post::createPost('Member Removed', 'Owncloud member \'' . $args['uid'] . '\' has been removed from owncloud and hence from the project(s) ' . $projects, OC_User::getUser(), NULL, 'Member removal', OC_Collaboration_Project::getMembersWorkingOnProjects(explode(' ', $pids)), true); } OC_Collaboration_Project::deleteMemberRole(NULL, $args['uid'], NULL, OC_User::getUser(), true); OC_Collaboration_Skillset::removeSkillsOfMember($args['uid']); OC_Collaboration_Post::removePostsByMember($args['uid'], true); \OCP\DB::commit(); OC_Log::write('collaboration', 'User deletion notification posted.', OCP\Util::INFO); } catch (\Exception $e) { OC_Log::write('collaboration', __METHOD__ . ', Exception: ' . $e->getMessage(), OCP\Util::DEBUG); return false; } }