Пример #1
0
 /**
  * update one or more user favourites
  *
  * @param array $users
  */
 public static function update_favourites($users)
 {
     global $USER, $WEBSERVICE_INSTITUTION, $WEBSERVICE_OAUTH_USER;
     $params = self::validate_parameters(self::update_favourites_parameters(), array('users' => $users));
     db_begin();
     foreach ($params['users'] as $user) {
         $dbuser = self::checkuser($user);
         $ownerid = $dbuser->id;
         // Make sure auth is valid
         if (!($authinstance = get_record('auth_instance', 'id', $dbuser->authinstance))) {
             throw new WebserviceInvalidParameterException('update_favourites | ' . get_string('invalidauthtype', 'auth.webservice', $dbuser->authinstance));
         }
         // check the institution is allowed
         // basic check authorisation to edit for the current institution
         if (!$USER->can_edit_institution($authinstance->institution)) {
             throw new WebserviceInvalidParameterException('update_favourites | ' . get_string('accessdeniedforinstuser', 'auth.webservice', $authinstance->institution, $dbuser->id));
         }
         // are we allowed to delete for this institution
         if ($WEBSERVICE_INSTITUTION != $user['institution'] || !$USER->can_edit_institution($user['institution'])) {
             throw new WebserviceInvalidParameterException('update_favourites | ' . get_string('accessdeniedforinst', 'auth.webservice', $user['institution']));
         }
         // check that the favourites exist and we are allowed to administer them
         $favourites = array();
         foreach ($user['favourites'] as $favourite) {
             $dbuser = self::checkuser($favourite);
             // Make sure auth is valid
             if (!($authinstance = get_record('auth_instance', 'id', $dbuser->authinstance))) {
                 throw new WebserviceInvalidParameterException('update_favourites | ' . get_string('invalidauthtype', 'auth.webservice', $dbuser->authinstance));
             }
             // check the institution is allowed
             // basic check authorisation to edit for the current institution of the user
             if (!$USER->can_edit_institution($authinstance->institution)) {
                 throw new WebserviceInvalidParameterException('update_favourites | ' . get_string('accessdeniedforinstuser', 'auth.webservice', $authinstance->institution, $dbuser->username));
             }
             $favourites[] = $dbuser->id;
         }
         // now do the update
         update_favorites($ownerid, $user['shortname'], $user['institution'], $favourites);
     }
     db_commit();
     return null;
 }
Пример #2
0
                            if (in_array($i, $keep2)) {
                                $newgedrec .= $facts2[$i]["subrec"] . "\n";
                                echo $pgv_lang["adding"], " ", $facts2[$i]["fact"], " ", $pgv_lang["from"], " ", $gid2, "<br />\n";
                            }
                        }
                    }
                    replace_gedrec($gid1, $newgedrec);
                    if ($SYNC_GEDCOM_FILE) {
                        write_file();
                    }
                    write_changes();
                    $rec = GedcomRecord::getInstance($gid1);
                    $pid = $rec->getXrefLink();
                    // $pid is embedded in $pgv_lang['record_updated']
                    echo '<br />', print_text('record_updated', 0, 1), '<br />';
                    $fav_count = update_favorites($gid2, $gid1);
                    if ($fav_count > 0) {
                        echo '<br />', $fav_count, ' ', $pgv_lang["updated_favorites"], '<br />';
                    }
                    echo "<br /><a href=\"edit_merge.php?action=choose\">", $pgv_lang["merge_more"], "</a><br />\n";
                    echo "<br /><br /><br />\n";
                }
            }
        }
    }
}
if ($action == "choose") {
    ?>
	<script language="JavaScript" type="text/javascript">
	<!--
	var pasteto;