Beispiel #1
0
 if ($data->id) {
     $msg = get_string('msgErro', 'block_webgd_community');
     $webgdDao = new WebgdCommunityDao();
     if ($communityDao = $webgdDao->findCommunityById($data->id)) {
         $communityDao->name = $data->nome;
         $communityDao->description = $data->conteudo;
         $communityDao->close_community = $data->close_community;
         $realfilename = $mform->get_new_filename('video');
         // this gets the name of the file
         $random = rand();
         // generate some random number
         $new_file = $random . '_' . $realfilename;
         //add some random string to the file
         $dst = $CFG->dataroot . "/blocks/webgd_community/{$new_file}";
         // directory name+ new filename
         if ($mform->save_file('video', $dst, true)) {
             $communuty->video = $dst;
         }
         if ($id = $DB->update_record(TableResouces::$TABLE_PAGE_COMMUNITY, $communityDao)) {
             $msg = 'Comunidade editada com sucesso';
             $communityParticipants = $webgdDao->findCommunityParticipantsById($data->id);
             foreach ($communityParticipants as $participantes => $pt) {
                 if ($pt->id != $USER->id) {
                     $DB->delete_records(TableResouces::$TABLE_PAGE_COMMUNITY, array('id' => $pt->id));
                 }
             }
             $users = optional_param_array('users', 0, PARAM_INT);
             foreach ($users as $idUser) {
                 $communutyUser = new stdClass();
                 $communutyUser->community = $data->id;
                 $communutyUser->admin = 0;